Skip to content

Commit

Permalink
[rend2] Fix vertex lit shaders with lightmap stage
Browse files Browse the repository at this point in the history
  • Loading branch information
SomaZ committed May 3, 2024
1 parent 63599ed commit 649a57f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions shared/rd-rend2/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3375,8 +3375,9 @@ static qboolean CollapseStagesToGLSL(void)
diffuse = pStage;
parallax = qfalse;
lightmap = NULL;
vertexlit = qfalse;

// we have a diffuse map, find matching lightmap
// we have a diffuse map, find matching lightmap or vertex lit stage
for (j = i + 1; j < MAX_SHADER_STAGES; j++)
{
shaderStage_t *pStage2 = &stages[j];
Expand All @@ -3396,6 +3397,16 @@ static qboolean CollapseStagesToGLSL(void)
lightmaps[j] = NULL;
break;
}

if (pStage2->bundle[0].isLightmap &&
pStage2->bundle[0].image[0] == tr.whiteImage &&
pStage2->rgbGen == CGEN_EXACT_VERTEX)
{
int blendBits = pStage2->stateBits & (GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS);
if (blendBits == (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) ||
blendBits == (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR))
vertexlit = qtrue;
}
}

tcgen = qfalse;
Expand All @@ -3415,7 +3426,6 @@ static qboolean CollapseStagesToGLSL(void)
diffuselit = qtrue;
}

vertexlit = qfalse;
if (diffuse->rgbGen == CGEN_VERTEX_LIT || diffuse->rgbGen == CGEN_EXACT_VERTEX_LIT || diffuse->rgbGen == CGEN_VERTEX || diffuse->rgbGen == CGEN_EXACT_VERTEX)
{
vertexlit = qtrue;
Expand Down

0 comments on commit 649a57f

Please sign in to comment.