Skip to content

Commit

Permalink
Add RSF_FORCE_LIGHTMAP
Browse files Browse the repository at this point in the history
Replaces RSF_NOLIGHTSCALE.

If this flag is used when registering a shader, all `ST_COLORMAP` stages will be changed to `ST_DIFFUSEMAP`. This is intended for use with particles and trails, to make them use the lightGrid in the GLSL code.
  • Loading branch information
VReaperV committed Jan 31, 2025
1 parent d138796 commit 552cc35
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,8 @@ enum class shaderProfilerRenderSubGroupsMode {

int autoSpriteMode;

bool forceLightMap;

uint8_t numDeforms;
deformStage_t deforms[ MAX_SHADER_DEFORMS ];

Expand Down
16 changes: 16 additions & 0 deletions src/engine/renderer/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5888,6 +5888,17 @@ static shader_t *FinishShader()
numStages = MAX_SHADER_STAGES;
GroupActiveStages();

if ( shader.forceLightMap ) {
for( size_t stage = 0; stage < numStages; stage++ ) {
shaderStage_t* pStage = &stages[numStages];

// TODO: Add lightmap as the first stage if there's a heatHaze stage here?
if ( pStage->type == stageType_t::ST_COLORMAP ) {
pStage->type = stageType_t::ST_DIFFUSEMAP;
}
}
}

// set appropriate stage information
for ( size_t stage = 0; stage < numStages; stage++ )
{
Expand Down Expand Up @@ -6375,6 +6386,11 @@ shader_t *R_FindShader( const char *name, shaderType_t type, int flags )
shader.entitySpriteFaceViewDirection = true;
}

if ( flags & RSF_FORCE_LIGHTMAP )
{
shader.forceLightMap = true;
}

// attempt to define shader from an explicit parameter file
shaderText = FindShaderInShaderText( strippedName );

Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ enum RegisterShaderFlags_t {
RSF_NOMIP = BIT( 2 ),
RSF_FITSCREEN = BIT( 3 ),
RSF_LIGHT_ATTENUATION = BIT( 4 ),
RSF_NOLIGHTSCALE = BIT( 5 ), // TODO(0.56): delete, does nothing
RSF_FORCE_LIGHTMAP = BIT( 5 ), // Used to make particles/trails work with the lightGrid in GLSL
RSF_SPRITE = BIT( 6 ),
};

Expand Down

0 comments on commit 552cc35

Please sign in to comment.