1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Fix BAR Fog with N64 Depth Compare

This commit is contained in:
Logan McNaughton 2018-04-17 12:38:24 -06:00 committed by Sergey Lipskiy
parent 6a10a83d09
commit 1fe9ce3bf9
3 changed files with 43 additions and 13 deletions

View File

@ -20,7 +20,7 @@ namespace glsl {
bool _saveCombinerKeys(const graphics::Combiners & _combiners) const;
bool _loadFromCombinerKeys(graphics::Combiners & _combiners);
const u32 m_formatVersion = 0x1FU;
const u32 m_formatVersion = 0x20U;
const u32 m_keysFormatVersion = 0x04;
const opengl::GLInfo & m_glinfo;
opengl::CachedUseProgram * m_useProgram;

View File

@ -60,20 +60,51 @@ namespace glsl {
"uniform lowp usampler2D uTlutImage;\n"
"uniform sampler2D uDepthImage; \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"
"{ \n"
;
if (_glinfo.fetch_depth) {
m_part +=
" highp float bufZ = gl_LastFragDepthARM; \n"
;
if (config.frameBufferEmulation.N64DepthCompare == 0) {
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 {
m_part +=
" mediump ivec2 coord = ivec2(gl_FragCoord.xy); \n"
" highp float bufZ = texelFetch(uDepthImage,coord, 0).r; \n"
;
if (_glinfo.imageTextures) {
m_part +=
" 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 +=
" highp int iZ = bufZ > 0.999 ? 262143 : int(floor(bufZ * 262143.0));\n"
" mediump int y0 = clamp(iZ/512, 0, 511); \n"
@ -90,7 +121,7 @@ namespace glsl {
"} \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;
}
};

View File

@ -52,8 +52,7 @@ void GLInfo::init() {
imageTextures = (numericVersion >= 31);
msaa = numericVersion >= 31;
} else {
imageTextures = ((numericVersion >= 43) || (Utils::isExtensionSupported(*this, "GL_ARB_shader_image_load_store") &&
Utils::isExtensionSupported(*this, "GL_ARB_compute_shader")));
imageTextures = (numericVersion >= 42) || Utils::isExtensionSupported(*this, "GL_ARB_shader_image_load_store");
msaa = true;
}