From 649a57f188e8545977eb60b7576398232e5be09a Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Fri, 3 May 2024 22:00:24 +0200 Subject: [PATCH] [rend2] Fix vertex lit shaders with lightmap stage --- shared/rd-rend2/tr_shader.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/shared/rd-rend2/tr_shader.cpp b/shared/rd-rend2/tr_shader.cpp index 309312fe6b..cce8e5dd61 100644 --- a/shared/rd-rend2/tr_shader.cpp +++ b/shared/rd-rend2/tr_shader.cpp @@ -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]; @@ -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; @@ -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;