Skip to content

Commit

Permalink
[rend2] Fix parallax mapping on alpha tested stages
Browse files Browse the repository at this point in the history
The parallax offset simply never got applied to the prepass, which created a mismatch between depth and actual stage rendering.
  • Loading branch information
SomaZ committed Apr 23, 2024
1 parent 433837f commit 7433777
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions shared/rd-rend2/tr_shade.cpp
Expand Up @@ -1249,6 +1249,11 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag
{
index |= LIGHTDEF_USE_ALPHA_TEST;
}

// TODO: remove light vertex def and fix parallax usage on unlit stages like glow stages
if (stage->glslShaderIndex & LIGHTDEF_USE_PARALLAXMAP &&
stage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)
index |= LIGHTDEF_USE_PARALLAXMAP | LIGHTDEF_USE_LIGHT_VERTEX;

result = &stage->glslShaderGroup[index];
backEnd.pc.c_lightallDraws++;
Expand Down Expand Up @@ -1676,6 +1681,23 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays
samplerBindingsWriter.AddStaticImage(tr.whiteImage, 0);
else if ( pStage->bundle[TB_COLORMAP].image[0] != 0 )
samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_COLORMAP], TB_COLORMAP);

// TODO: remove light requirement
if (pStage->glslShaderIndex & LIGHTDEF_USE_PARALLAXMAP &&
pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)
{
vec4_t enableTextures = {};
if (pStage->bundle[TB_NORMALMAP].image[0])
{
samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_NORMALMAP], TB_NORMALMAP);
enableTextures[0] = 1.0f;
}
else if (r_normalMapping->integer)
{
samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_NORMALMAP);
}
uniformDataWriter.SetUniformVec4(UNIFORM_ENABLETEXTURES, enableTextures);
}
}
else if ( pStage->glslShaderGroup == tr.lightallShader )
{
Expand Down

0 comments on commit 7433777

Please sign in to comment.