OpenGL Renderer:

- Don’t output the depth to the secondary depth buffer if depth writing is disabled.
This commit is contained in:
rogerman 2015-04-25 19:07:54 +00:00
parent 74dbe2efdd
commit ecc22fb24d
3 changed files with 10 additions and 4 deletions

View File

@ -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;
}

View File

@ -376,6 +376,7 @@ struct OGLRenderRef
GLint uniformPolyTexScale;
GLint uniformPolyMode;
GLint uniformPolyEnableDepthWrite;
GLint uniformPolySetNewDepthForTranslucent;
GLint uniformPolyAlpha;
GLint uniformPolyID;

View File

@ -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\
"};