Skip to content

Commit

Permalink
Renderers: apply lightmap texcoord correction only if lightmap is act…
Browse files Browse the repository at this point in the history
…ually set

OpenGL: allow all static tcGens/tcMods for VBO/environment mapping (assuming that we have all tcMod corrections applied before)
  • Loading branch information
ec- committed Feb 6, 2024
1 parent feaf9d4 commit e1b388c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion code/renderer/tr_shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
46 changes: 23 additions & 23 deletions code/renderer/tr_vbo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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;
Expand All @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion code/renderervk/tr_shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit e1b388c

Please sign in to comment.