Skip to content

Commit

Permalink
renderer: set white colormap for lightmap stage at shader loading time
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Apr 22, 2024
1 parent edbf073 commit 7fe2e83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 32 deletions.
44 changes: 12 additions & 32 deletions src/engine/renderer/tr_shade.cpp
Expand Up @@ -1081,15 +1081,10 @@ void Render_lightMapping( shaderStage_t *pStage )
}

// bind u_DiffuseMap
if ( pStage->type == stageType_t::ST_LIGHTMAP )
{
// standalone lightmap stage: paint shadows over a white texture
GL_BindToTMU( BIND_DIFFUSEMAP, tr.whiteImage );
}
else
{
GL_BindToTMU( BIND_DIFFUSEMAP, pStage->bundle[ TB_DIFFUSEMAP ].image[ 0 ] );
GL_BindToTMU( BIND_DIFFUSEMAP, pStage->bundle[ TB_DIFFUSEMAP ].image[ 0 ] );

if ( pStage->type != stageType_t::ST_LIGHTMAP )
{
gl_lightMappingShader->SetUniform_TextureMatrix( tess.svars.texMatrices[ TB_DIFFUSEMAP ] );
}

Expand Down Expand Up @@ -1423,15 +1418,10 @@ static void Render_forwardLighting_DBS_omni( shaderStage_t *pStage,
GL_CheckErrors();

// bind u_DiffuseMap
if ( pStage->type == stageType_t::ST_LIGHTMAP )
{
// standalone lightmap stage: paint shadows over a white texture
GL_BindToTMU( 0, tr.whiteImage );
}
else
{
GL_BindToTMU( 0, pStage->bundle[ TB_DIFFUSEMAP ].image[ 0 ] );
GL_BindToTMU( 0, pStage->bundle[ TB_DIFFUSEMAP ].image[ 0 ] );

if ( pStage->type != stageType_t::ST_LIGHTMAP )
{
gl_forwardLightingShader_omniXYZ->SetUniform_TextureMatrix( tess.svars.texMatrices[ TB_DIFFUSEMAP ] );
}

Expand Down Expand Up @@ -1594,15 +1584,10 @@ static void Render_forwardLighting_DBS_proj( shaderStage_t *pStage,
GL_CheckErrors();

// bind u_DiffuseMap
if ( pStage->type == stageType_t::ST_LIGHTMAP )
{
// standalone lightmap stage: paint shadows over a white texture
GL_BindToTMU( 0, tr.whiteImage );
}
else
{
GL_BindToTMU( 0, pStage->bundle[ TB_DIFFUSEMAP ].image[ 0 ] );
GL_BindToTMU( 0, pStage->bundle[ TB_DIFFUSEMAP ].image[ 0 ] );

if ( pStage->type != stageType_t::ST_LIGHTMAP )
{
gl_forwardLightingShader_projXYZ->SetUniform_TextureMatrix( tess.svars.texMatrices[ TB_DIFFUSEMAP ] );
}

Expand Down Expand Up @@ -1767,15 +1752,10 @@ static void Render_forwardLighting_DBS_directional( shaderStage_t *pStage, trRef
GL_CheckErrors();

// bind u_DiffuseMap
if ( pStage->type == stageType_t::ST_LIGHTMAP )
{
// standalone lightmap stage: paint shadows over a white texture
GL_BindToTMU( 0, tr.whiteImage );
}
else
{
GL_BindToTMU( 0, pStage->bundle[ TB_DIFFUSEMAP ].image[ 0 ] );
GL_BindToTMU( 0, pStage->bundle[ TB_DIFFUSEMAP ].image[ 0 ] );

if ( pStage->type != stageType_t::ST_LIGHTMAP )
{
gl_forwardLightingShader_directionalSun->SetUniform_TextureMatrix( tess.svars.texMatrices[ TB_DIFFUSEMAP ] );
}

Expand Down
6 changes: 6 additions & 0 deletions src/engine/renderer/tr_shader.cpp
Expand Up @@ -5193,6 +5193,12 @@ static void FinishStages()
break;

case stageType_t::ST_LIGHTMAP:
// standalone lightmap stage: paint shadows over a white texture
stage->bundle[ TB_DIFFUSEMAP ].image[ 0 ] = tr.whiteImage;
lightStageFound = true;
shaderHasNoLight = false;
break;

case stageType_t::ST_DIFFUSEMAP:
case stageType_t::ST_COLLAPSE_DIFFUSEMAP:
lightStageFound = true;
Expand Down

0 comments on commit 7fe2e83

Please sign in to comment.