Skip to content

Commit 495777b

Browse files
committed
Implement stage-level colorspace shader keyword
Allows making conditional stages that depend on whether naive or linear blending is used.
1 parent 824c595 commit 495777b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/engine/renderer/tr_shader.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,7 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
20092009
filterType_t filterType;
20102010
char buffer[ 1024 ] = "";
20112011
bool loadMap = false;
2012+
bool blendRegimeMatch = true;
20122013

20132014
while ( true )
20142015
{
@@ -2844,6 +2845,23 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
28442845
continue;
28452846
}
28462847
}
2848+
// disable the stage if the renderer's blending mode does not match the specified mode
2849+
else if ( !Q_stricmp( token, "ifBlendRegime" ) )
2850+
{
2851+
token = COM_ParseExt2( text, false );
2852+
if ( !Q_stricmp( token, "naive" ) )
2853+
{
2854+
blendRegimeMatch = !tr.worldLinearizeTexture;
2855+
}
2856+
else if ( !Q_stricmp( token, "linear" ) )
2857+
{
2858+
blendRegimeMatch = tr.worldLinearizeTexture;
2859+
}
2860+
else
2861+
{
2862+
Log::Warn( "unknown parameter'%s' for ifBlendRegime in shader '%s'", token, shader.name );
2863+
}
2864+
}
28472865
// alpha <arithmetic expression>
28482866
else if ( !Q_stricmp( token, "alpha" ) )
28492867
{
@@ -3222,6 +3240,11 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
32223240
}
32233241
}
32243242

3243+
if ( !blendRegimeMatch )
3244+
{
3245+
return true; // parsing succeeded, but not active
3246+
}
3247+
32253248
// parsing succeeded
32263249
stage->active = true;
32273250

0 commit comments

Comments
 (0)