OpenGL2: Fix dark lightmap on shader in mpteam6

Team Arena's mpteam6 map has a shader textures/base_wall2/space_concrete
that contains an opaque stage, two non-lightmap blendfunc filter stages,
a blendfunc add stage, and a lightmap stage. The lightmap was attached
to all four of the non-lightmap stages causing the filter stages to
darken the lightmap multiple times.

Change setting up the lightall GLSL shader to only use lightmap if it's
the first stage or not a blendfunc filter stage. Now only the opaque
and blendfunc add stages of the mpteam6 shader use the lightmap.

Reported by Alexander Nadeau (wareya).
This commit is contained in:
Zack Middleton 2018-02-04 11:15:13 -06:00
parent 0b6d97f849
commit 3d6aa05694
1 changed files with 12 additions and 1 deletions

View File

@ -2421,6 +2421,8 @@ static int CollapseStagesToGLSL(void)
if (!skip) if (!skip)
{ {
qboolean usedLightmap = qfalse;
for (i = 0; i < MAX_SHADER_STAGES; i++) for (i = 0; i < MAX_SHADER_STAGES; i++)
{ {
shaderStage_t *pStage = &stages[i]; shaderStage_t *pStage = &stages[i];
@ -2478,8 +2480,17 @@ static int CollapseStagesToGLSL(void)
case ST_COLORMAP: case ST_COLORMAP:
if (pStage2->bundle[0].tcGen == TCGEN_LIGHTMAP) if (pStage2->bundle[0].tcGen == TCGEN_LIGHTMAP)
{
int blendBits = pStage->stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS );
// Only add lightmap to blendfunc filter stage if it's the first time lightmap is used
// otherwise it will cause the shader to be darkened by the lightmap multiple times.
if (!usedLightmap || (blendBits != (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO)
&& blendBits != (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR)))
{ {
lightmap = pStage2; lightmap = pStage2;
usedLightmap = qtrue;
}
} }
break; break;