diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index 4a330bc91..1bd418d7e 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -330,7 +330,7 @@ static const char *fragmentShader_100 = {"\ gl_FragData[0] = newFragColor;\n\ gl_FragData[3] = vec4( float(polyEnableFog), float(stateEnableFogAlphaOnly), 0.0, 1.0);\n\ if (newFragColor.a > 0.999) gl_FragData[2] = vec4(float(polyID)/63.0, float(stateEnableAntialiasing), 0.0, 1.0);\n\ - if (newFragColor.a > 0.999 || polySetNewDepthForTranslucent) gl_FragData[1] = vec4( packVec3FromFloat(newFragDepth), 1.0);\n\ + if (polyEnableDepthWrite && (newFragColor.a > 0.999 || polySetNewDepthForTranslucent)) gl_FragData[1] = vec4( packVec3FromFloat(newFragDepth), 1.0);\n\ gl_FragDepth = newFragDepth;\n\ } \n\ "}; @@ -1289,6 +1289,7 @@ Render3DError OpenGLRenderer_1_2::InitGeometryProgram(const std::string &vertexS OGLRef.uniformPolyTexScale = glGetUniformLocation(OGLRef.programGeometryID, "polyTexScale"); OGLRef.uniformPolyMode = glGetUniformLocation(OGLRef.programGeometryID, "polyMode"); + OGLRef.uniformPolyEnableDepthWrite = glGetUniformLocation(OGLRef.programGeometryID, "polyEnableDepthWrite"); OGLRef.uniformPolySetNewDepthForTranslucent = glGetUniformLocation(OGLRef.programGeometryID, "polySetNewDepthForTranslucent"); OGLRef.uniformPolyAlpha = glGetUniformLocation(OGLRef.programGeometryID, "polyAlpha"); OGLRef.uniformPolyID = glGetUniformLocation(OGLRef.programGeometryID, "polyID"); @@ -2433,7 +2434,8 @@ Render3DError OpenGLRenderer_1_2::SetupPolygon(const POLY *thePoly) if (this->isShaderSupported) { - glUniform1i(OGLRef.uniformPolySetNewDepthForTranslucent, ((enableDepthWrite == GL_TRUE) || attr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE); + glUniform1i(OGLRef.uniformPolyEnableDepthWrite, enableDepthWrite); + glUniform1i(OGLRef.uniformPolySetNewDepthForTranslucent, (attr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE); } return OGLERROR_NOERR; @@ -2556,6 +2558,7 @@ Render3DError OpenGLRenderer_1_2::Reset() glUniform2f(OGLRef.uniformPolyTexScale, 1.0f, 1.0f); glUniform1i(OGLRef.uniformPolyMode, 0); + glUniform1i(OGLRef.uniformPolyEnableDepthWrite, GL_TRUE); glUniform1i(OGLRef.uniformPolySetNewDepthForTranslucent, GL_TRUE); glUniform1f(OGLRef.uniformPolyAlpha, 1.0f); glUniform1i(OGLRef.uniformPolyID, 0); @@ -3673,7 +3676,8 @@ Render3DError OpenGLRenderer_2_0::SetupPolygon(const POLY *thePoly) } glDepthMask(enableDepthWrite); - glUniform1i(OGLRef.uniformPolySetNewDepthForTranslucent, ((enableDepthWrite == GL_TRUE) || attr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE); + glUniform1i(OGLRef.uniformPolyEnableDepthWrite, enableDepthWrite); + glUniform1i(OGLRef.uniformPolySetNewDepthForTranslucent, (attr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE); return OGLERROR_NOERR; } diff --git a/desmume/src/OGLRender.h b/desmume/src/OGLRender.h index a808dacd6..c91f84481 100644 --- a/desmume/src/OGLRender.h +++ b/desmume/src/OGLRender.h @@ -376,6 +376,7 @@ struct OGLRenderRef GLint uniformPolyTexScale; GLint uniformPolyMode; + GLint uniformPolyEnableDepthWrite; GLint uniformPolySetNewDepthForTranslucent; GLint uniformPolyAlpha; GLint uniformPolyID; diff --git a/desmume/src/OGLRender_3_2.cpp b/desmume/src/OGLRender_3_2.cpp index 558b33d19..accb9e240 100644 --- a/desmume/src/OGLRender_3_2.cpp +++ b/desmume/src/OGLRender_3_2.cpp @@ -120,6 +120,7 @@ static const char *GeometryFragShader_150 = {"\ uniform float stateAlphaTestRef; \n\ \n\ uniform int polyMode; \n\ + uniform bool polyEnableDepthWrite;\n\ uniform bool polySetNewDepthForTranslucent;\n\ uniform int polyID; \n\ \n\ @@ -172,7 +173,7 @@ static const char *GeometryFragShader_150 = {"\ outFragColor = newFragColor;\n\ outFogAttributes = vec4( float(polyEnableFog), float(stateEnableFogAlphaOnly), 0.0, 1.0);\n\ if (newFragColor.a > 0.999) outPolyID = vec4(float(polyID)/63.0, float(stateEnableAntialiasing), 0.0, 1.0);\n\ - if (newFragColor.a > 0.999 || polySetNewDepthForTranslucent) outFragDepth = vec4( packVec3FromFloat(newFragDepth), 1.0);\n\ + if (polyEnableDepthWrite && (newFragColor.a > 0.999 || polySetNewDepthForTranslucent)) outFragDepth = vec4( packVec3FromFloat(newFragDepth), 1.0);\n\ gl_FragDepth = newFragDepth;\n\ } \n\ "};