Skip to content

Commit

Permalink
#5909: Set the alpha test value as evaluated in the material's shader…
Browse files Browse the repository at this point in the history
… stage. Remove texture matrix code.
  • Loading branch information
codereader committed Mar 13, 2022
1 parent 05bcddd commit 9a07cf2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 39 deletions.
20 changes: 0 additions & 20 deletions radiantcore/rendersystem/backend/DepthFillPass.cpp
Expand Up @@ -34,24 +34,4 @@ DepthFillPass::DepthFillPass(OpenGLShader& owner, OpenGLRenderSystem& renderSyst
assert(dynamic_cast<GLSLDepthFillAlphaProgram*>(_glState.glProgram));
}

#if 0
void DepthFillPass::activateShaderProgram(OpenGLState& current)
{
// We need a program, it is set up in the constructor
assert(_glState.glProgram);

// Let the base class enable the program
OpenGLShaderPass::activateShaderProgram(current);

#if 0 // TODO: Migrate to LightInteractions::depthFill
auto zFillAlphaProgram = static_cast<GLSLDepthFillAlphaProgram*>(current.glProgram);

zFillAlphaProgram->applyAlphaTest(_glState.alphaThreshold);

setTextureState(current.texture0, _glState.texture0, GL_TEXTURE0, GL_TEXTURE_2D);
setupTextureMatrix(GL_TEXTURE0, _glState.stage0);
#endif
}
#endif

}
5 changes: 0 additions & 5 deletions radiantcore/rendersystem/backend/DepthFillPass.h
Expand Up @@ -22,11 +22,6 @@ class DepthFillPass :
{
return *static_cast<GLSLDepthFillAlphaProgram*>(_glState.glProgram);
}

#if 0
protected:
virtual void activateShaderProgram(OpenGLState& current) override;
#endif
};

}
10 changes: 8 additions & 2 deletions radiantcore/rendersystem/backend/LightInteractions.cpp
Expand Up @@ -75,12 +75,18 @@ void LightInteractions::fillDepthBuffer(OpenGLState& state, RenderStateFlags glo
{
continue;
}


// Evaluate the shader stages of this material
depthFillPass->evaluateShaderStages(renderTime, entity);

// Apply our state to the current state object
depthFillPass->evaluateStagesAndApplyState(state, globalFlagsMask, renderTime, entity);
depthFillPass->applyState(state, globalFlagsMask);

auto depthFillProgram = depthFillPass->getDepthFillProgram();

// Apply the evaluated alpha test value
depthFillProgram.setAlphaTest(state.alphaThreshold);

// Set the modelview and projection matrix
depthFillProgram.setModelViewProjection(view.GetViewProjection());

Expand Down
Expand Up @@ -61,19 +61,9 @@ void GLSLDepthFillAlphaProgram::disable()
glDisableVertexAttribArray(GLProgramAttribute::TexCoord);
}

void GLSLDepthFillAlphaProgram::applyAlphaTest(float alphaTest)
void GLSLDepthFillAlphaProgram::setAlphaTest(float alphaTest)
{
glUniform1f(_locAlphaTest, alphaTest);

debug::assertNoGlErrors();

glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);

glMatrixMode(GL_TEXTURE);
glLoadIdentity();

debug::assertNoGlErrors();
}

void GLSLDepthFillAlphaProgram::setModelViewProjection(const Matrix4& modelViewProjection)
Expand Down
Expand Up @@ -23,7 +23,7 @@ class GLSLDepthFillAlphaProgram :
void setObjectTransform(const Matrix4& transform);
void setDiffuseTextureTransform(const Matrix4& transform);

void applyAlphaTest(float alphaTest);
void setAlphaTest(float alphaTest);
};

}

0 comments on commit 9a07cf2

Please sign in to comment.