mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Fix BAR Fog with N64 Depth Compare
This commit is contained in:
parent
6a10a83d09
commit
1fe9ce3bf9
|
@ -20,7 +20,7 @@ namespace glsl {
|
||||||
bool _saveCombinerKeys(const graphics::Combiners & _combiners) const;
|
bool _saveCombinerKeys(const graphics::Combiners & _combiners) const;
|
||||||
bool _loadFromCombinerKeys(graphics::Combiners & _combiners);
|
bool _loadFromCombinerKeys(graphics::Combiners & _combiners);
|
||||||
|
|
||||||
const u32 m_formatVersion = 0x1FU;
|
const u32 m_formatVersion = 0x20U;
|
||||||
const u32 m_keysFormatVersion = 0x04;
|
const u32 m_keysFormatVersion = 0x04;
|
||||||
const opengl::GLInfo & m_glinfo;
|
const opengl::GLInfo & m_glinfo;
|
||||||
opengl::CachedUseProgram * m_useProgram;
|
opengl::CachedUseProgram * m_useProgram;
|
||||||
|
|
|
@ -60,20 +60,51 @@ namespace glsl {
|
||||||
"uniform lowp usampler2D uTlutImage;\n"
|
"uniform lowp usampler2D uTlutImage;\n"
|
||||||
"uniform sampler2D uDepthImage; \n"
|
"uniform sampler2D uDepthImage; \n"
|
||||||
"uniform lowp vec4 uFogColor; \n"
|
"uniform lowp vec4 uFogColor; \n"
|
||||||
"OUT lowp vec4 fragColor; \n"
|
;
|
||||||
|
|
||||||
|
if (config.frameBufferEmulation.N64DepthCompare != 0) {
|
||||||
|
if (_glinfo.imageTextures)
|
||||||
|
m_part += "layout(binding = 2, r32f) highp uniform restrict readonly image2D uDepthImageZ; \n";
|
||||||
|
|
||||||
|
if (_glinfo.ext_fetch) {
|
||||||
|
m_part +=
|
||||||
|
"layout(location = 0) OUT lowp vec4 fragColor; \n"
|
||||||
|
"layout(location = 1) inout highp vec4 depthZ; \n"
|
||||||
|
;
|
||||||
|
} else
|
||||||
|
m_part += "OUT lowp vec4 fragColor; \n";
|
||||||
|
} else
|
||||||
|
m_part += "OUT lowp vec4 fragColor; \n";
|
||||||
|
|
||||||
|
m_part +=
|
||||||
"lowp float get_alpha() \n"
|
"lowp float get_alpha() \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
;
|
;
|
||||||
if (_glinfo.fetch_depth) {
|
|
||||||
m_part +=
|
if (config.frameBufferEmulation.N64DepthCompare == 0) {
|
||||||
" highp float bufZ = gl_LastFragDepthARM; \n"
|
if (_glinfo.fetch_depth) {
|
||||||
;
|
m_part +=
|
||||||
|
" highp float bufZ = gl_LastFragDepthARM; \n"
|
||||||
|
;
|
||||||
|
} else {
|
||||||
|
m_part +=
|
||||||
|
" mediump ivec2 coord = ivec2(gl_FragCoord.xy); \n"
|
||||||
|
" highp float bufZ = texelFetch(uDepthImage,coord, 0).r; \n"
|
||||||
|
;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m_part +=
|
if (_glinfo.imageTextures) {
|
||||||
" mediump ivec2 coord = ivec2(gl_FragCoord.xy); \n"
|
m_part +=
|
||||||
" highp float bufZ = texelFetch(uDepthImage,coord, 0).r; \n"
|
" mediump ivec2 coord = ivec2(gl_FragCoord.xy); \n"
|
||||||
;
|
" highp float bufZ = imageLoad(uDepthImageZ,coord).r; \n"
|
||||||
|
;
|
||||||
|
} else if (_glinfo.ext_fetch) {
|
||||||
|
m_part +=
|
||||||
|
" highp float bufZ = depthZ.r; \n"
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_part +=
|
m_part +=
|
||||||
" highp int iZ = bufZ > 0.999 ? 262143 : int(floor(bufZ * 262143.0));\n"
|
" highp int iZ = bufZ > 0.999 ? 262143 : int(floor(bufZ * 262143.0));\n"
|
||||||
" mediump int y0 = clamp(iZ/512, 0, 511); \n"
|
" mediump int y0 = clamp(iZ/512, 0, 511); \n"
|
||||||
|
@ -90,7 +121,7 @@ namespace glsl {
|
||||||
"} \n"
|
"} \n"
|
||||||
;
|
;
|
||||||
|
|
||||||
if (_glinfo.fetch_depth)
|
if (config.frameBufferEmulation.N64DepthCompare == 0 && _glinfo.fetch_depth)
|
||||||
m_part = "#extension GL_ARM_shader_framebuffer_fetch_depth_stencil : enable \n" + m_part;
|
m_part = "#extension GL_ARM_shader_framebuffer_fetch_depth_stencil : enable \n" + m_part;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,8 +52,7 @@ void GLInfo::init() {
|
||||||
imageTextures = (numericVersion >= 31);
|
imageTextures = (numericVersion >= 31);
|
||||||
msaa = numericVersion >= 31;
|
msaa = numericVersion >= 31;
|
||||||
} else {
|
} else {
|
||||||
imageTextures = ((numericVersion >= 43) || (Utils::isExtensionSupported(*this, "GL_ARB_shader_image_load_store") &&
|
imageTextures = (numericVersion >= 42) || Utils::isExtensionSupported(*this, "GL_ARB_shader_image_load_store");
|
||||||
Utils::isExtensionSupported(*this, "GL_ARB_compute_shader")));
|
|
||||||
msaa = true;
|
msaa = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user