From 1d1f4bdbb4b065aae92fabbb3aa60434f7bf81bb Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Tue, 9 Feb 2016 22:00:41 +0600 Subject: [PATCH] Alpha compare should happen after the 1st cycle of a two-cycle combiner Fixed invisible rocks in Mischief Makers intro. --- src/GLES2/GLSLCombiner_gles2.cpp | 7 ------- src/OGL3X/GLSLCombiner_ogl3x.cpp | 7 ------- src/ShaderUtils.cpp | 6 ++++++ 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/GLES2/GLSLCombiner_gles2.cpp b/src/GLES2/GLSLCombiner_gles2.cpp index dcc35fb7..150c027d 100644 --- a/src/GLES2/GLSLCombiner_gles2.cpp +++ b/src/GLES2/GLSLCombiner_gles2.cpp @@ -179,13 +179,6 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo strFragmentShader.append(" vec_color = vec4(input_color, vShadeColor.a); \n"); strFragmentShader.append(strCombiner); - strFragmentShader.append( - " if (uEnableAlphaTest != 0) { \n" - " lowp float alphaTestValue = (uAlphaCompareMode == 3 && alpha2 > 0.0) ? snoise() : uAlphaTestValue; \n" - " if (alpha2 < alphaTestValue) discard; \n" - " } \n" - ); - if (!g_weakGLSL) { strFragmentShader.append( " lowp int fogUsage = uFogUsage; \n" diff --git a/src/OGL3X/GLSLCombiner_ogl3x.cpp b/src/OGL3X/GLSLCombiner_ogl3x.cpp index 749f72c8..ef7b40c1 100644 --- a/src/OGL3X/GLSLCombiner_ogl3x.cpp +++ b/src/OGL3X/GLSLCombiner_ogl3x.cpp @@ -330,13 +330,6 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo strFragmentShader.append(" vec_color = vec4(input_color, vShadeColor.a); \n"); strFragmentShader.append(strCombiner); - strFragmentShader.append( - " if (uEnableAlphaTest != 0) { \n" - " lowp float alphaTestValue = (uAlphaCompareMode == 3 && alpha2 > 0.0) ? snoise() : uAlphaTestValue; \n" - " if (alpha2 < alphaTestValue) discard; \n" - " } \n" - ); - if (config.generalEmulation.enableNoise != 0) { strFragmentShader.append( " if (uColorDitherMode == 2) colorNoiseDither(snoise(), color2); \n" diff --git a/src/ShaderUtils.cpp b/src/ShaderUtils.cpp index 5dd73f70..291030c1 100644 --- a/src/ShaderUtils.cpp +++ b/src/ShaderUtils.cpp @@ -235,6 +235,12 @@ int compileCombiner(Combiner & _color, Combiner & _alpha, char * _strShader) } strcpy(_strShader, " alpha1 = "); int nInputs = _compileCombiner(_alpha.stage[0], AlphaInput, _strShader); + strcat(_strShader, + " if (uEnableAlphaTest != 0) { \n" + " lowp float alphaTestValue = (uAlphaCompareMode == 3 && alpha1 > 0.0) ? snoise() : uAlphaTestValue; \n" + " if (alpha1 < alphaTestValue) discard; \n" + " } \n" + ); strcat(_strShader, " color1 = "); nInputs |= _compileCombiner(_color.stage[0], ColorInput, _strShader); strcat(_strShader, fragment_shader_blender);