Skip to content

Commit 25f9368

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 62d97ab commit 25f9368

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
@@ -2105,6 +2105,7 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
21052105
char buffer[ 1024 ] = "";
21062106
bool loadMap = false;
21072107
bool loadAnimMap = false;
2108+
bool staticEnabled = true;
21082109

21092110
stage->convertColorFromSRGB = convertColorFromSRGB_NOP;
21102111

@@ -2130,6 +2131,12 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
21302131
{
21312132
ParseExpression( text, &stage->ifExp );
21322133
}
2134+
else if ( !Q_stricmp( token, "ifStatic" ) )
2135+
{
2136+
expression_t expr;
2137+
ParseExpression( text, &expr );
2138+
staticEnabled = !!RB_EvalExpression( &expr, 1.0f );
2139+
}
21332140
// map <name>
21342141
else if ( !Q_stricmp( token, "map" ) )
21352142
{
@@ -3339,6 +3346,12 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
33393346
}
33403347
}
33413348

3349+
if ( !staticEnabled )
3350+
{
3351+
// parsing succeeded, but stage disabled
3352+
return true;
3353+
}
3354+
33423355
// parsing succeeded
33433356
stage->active = true;
33443357

0 commit comments

Comments
 (0)