Skip to content

Commit 0e3539b

Browse files
committed
Add ifStatic shader keyword
The stage-level shader option ifStatic <expression> evaluates an expression at load time and disables the stage if the expression evaluates to a falsey float value.
1 parent 5343c4c commit 0e3539b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/engine/renderer/tr_shader.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,7 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
20132013
filterType_t filterType;
20142014
char buffer[ 1024 ] = "";
20152015
bool loadMap = false;
2016+
bool staticEnabled = true;
20162017

20172018
while ( true )
20182019
{
@@ -2033,6 +2034,12 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
20332034
{
20342035
ParseExpression( text, &stage->ifExp );
20352036
}
2037+
else if ( !Q_stricmp( token, "ifStatic" ) )
2038+
{
2039+
expression_t expr;
2040+
ParseExpression( text, &expr );
2041+
staticEnabled = !!RB_EvalExpression( &expr, 1.0f );
2042+
}
20362043
// map <name>
20372044
else if ( !Q_stricmp( token, "map" ) )
20382045
{
@@ -3226,6 +3233,12 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
32263233
}
32273234
}
32283235

3236+
if ( !staticEnabled )
3237+
{
3238+
// parsing succeeded, but stage disabled
3239+
return true;
3240+
}
3241+
32293242
// parsing succeeded
32303243
stage->active = true;
32313244

0 commit comments

Comments
 (0)