diff --git a/code/renderer/tr_shader.c b/code/renderer/tr_shader.c index aa1976a9c..5b86b68ef 100644 --- a/code/renderer/tr_shader.c +++ b/code/renderer/tr_shader.c @@ -1744,7 +1744,7 @@ static void FinishStage( shaderStage_t *stage ) } // revert lightmap texcoord correction if needed if ( bundle->lightmap == LIGHTMAP_INDEX_NONE ) { - if ( bundle->tcGen == TCGEN_LIGHTMAP ) { + if ( bundle->tcGen == TCGEN_LIGHTMAP && shader.lightmapIndex >= 0 ) { texModInfo_t *tmi; for ( n = bundle->numTexMods; n > 0; --n ) { bundle->texMods[n] = bundle->texMods[n - 1]; diff --git a/code/renderer/tr_vbo.c b/code/renderer/tr_vbo.c index bb494c034..f76b0e02b 100644 --- a/code/renderer/tr_vbo.c +++ b/code/renderer/tr_vbo.c @@ -369,6 +369,28 @@ static qboolean isStaticRGBgen( colorGen_t cgen ) } +static qboolean isStaticTCmod( const textureBundle_t *bundle ) +{ + int i; + + for ( i = 0; i < bundle->numTexMods; i++ ) { + switch ( bundle->texMods[i].type ) { + case TMOD_NONE: + case TMOD_SCALE: + case TMOD_TRANSFORM: + case TMOD_OFFSET: + case TMOD_SCALE_OFFSET: + case TMOD_OFFSET_SCALE: + break; + default: + return qfalse; + } + } + + return qtrue; +} + + static qboolean isStaticTCgen( shaderStage_t *stage, int bundle ) { switch ( stage->bundle[bundle].tcGen ) @@ -379,7 +401,7 @@ static qboolean isStaticTCgen( shaderStage_t *stage, int bundle ) case TCGEN_TEXTURE: return qtrue; case TCGEN_ENVIRONMENT_MAPPED: - if ( stage->bundle[bundle].numTexMods == 0 && ( stage->bundle[bundle].lightmap == LIGHTMAP_INDEX_NONE || !tr.mergeLightmaps ) ) { + if ( bundle == 0 && isStaticTCmod( &stage->bundle[bundle] ) ) { stage->tessFlags |= TESS_ENV0 << bundle; stage->tessFlags &= ~( TESS_ST0 << bundle ); return qtrue; @@ -398,28 +420,6 @@ static qboolean isStaticTCgen( shaderStage_t *stage, int bundle ) } -static qboolean isStaticTCmod( const textureBundle_t *bundle ) -{ - int i; - - for ( i = 0; i < bundle->numTexMods; i++ ) { - switch ( bundle->texMods[i].type ) { - case TMOD_NONE: - case TMOD_SCALE: - case TMOD_TRANSFORM: - case TMOD_OFFSET: - case TMOD_SCALE_OFFSET: - case TMOD_OFFSET_SCALE: - break; - default: - return qfalse; - } - } - - return qtrue; -} - - static qboolean isStaticAgen( alphaGen_t agen ) { switch ( agen ) diff --git a/code/renderervk/tr_shader.c b/code/renderervk/tr_shader.c index 45072e5b7..1a8495e71 100644 --- a/code/renderervk/tr_shader.c +++ b/code/renderervk/tr_shader.c @@ -1740,7 +1740,7 @@ static void FinishStage( shaderStage_t *stage ) } // revert lightmap texcoord correction if needed if ( bundle->lightmap == LIGHTMAP_INDEX_NONE ) { - if ( bundle->tcGen == TCGEN_LIGHTMAP ) { + if ( bundle->tcGen == TCGEN_LIGHTMAP && shader.lightmapIndex >= 0 ) { texModInfo_t *tmi; for ( n = bundle->numTexMods; n > 0; --n ) { bundle->texMods[n] = bundle->texMods[n - 1];