@@ -2020,6 +2020,7 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
20202020 filterType_t filterType;
20212021 char buffer[ 1024 ] = " " ;
20222022 bool loadMap = false ;
2023+ bool colorspaceMatch = true ;
20232024
20242025 while ( true )
20252026 {
@@ -2855,6 +2856,23 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
28552856 continue ;
28562857 }
28572858 }
2859+ // disable the stage if the renderer's blending mode does not match the specified mode
2860+ else if ( !Q_stricmp ( token, " colorspace" ) )
2861+ {
2862+ token = COM_ParseExt2 ( text, false );
2863+ if ( !Q_stricmp ( token, " naive" ) )
2864+ {
2865+ colorspaceMatch = !tr.worldLinearizeTexture ;
2866+ }
2867+ else if ( !Q_stricmp ( token, " linear" ) )
2868+ {
2869+ colorspaceMatch = tr.worldLinearizeTexture ;
2870+ }
2871+ else
2872+ {
2873+ Log::Warn ( " unknown colorspace '%s' in shader '%s'" , token, shader.name );
2874+ }
2875+ }
28582876 // alpha <arithmetic expression>
28592877 else if ( !Q_stricmp ( token, " alpha" ) )
28602878 {
@@ -3233,6 +3251,11 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
32333251 }
32343252 }
32353253
3254+ if ( !colorspaceMatch )
3255+ {
3256+ return true ; // parsing succeeded, but not active
3257+ }
3258+
32363259 // parsing succeeded
32373260 stage->active = true ;
32383261
@@ -3866,8 +3889,6 @@ static bool ParseShader( const char *_text )
38663889 return false ;
38673890 }
38683891
3869- stage->active = true ;
3870-
38713892 /* Examples of shaders with light styles, those
38723893 shaders are generated by the q3map2 map compiler.
38733894
0 commit comments