diff --git a/src/engine/client/cl_main.cpp b/src/engine/client/cl_main.cpp index 209e2b5fee..733e3a6afc 100644 --- a/src/engine/client/cl_main.cpp +++ b/src/engine/client/cl_main.cpp @@ -2141,7 +2141,7 @@ bool CL_InitRenderer() FS_FCloseFile( f ); } - cls.whiteShader = re.RegisterShader( "white", RSF_NOMIP ); + cls.whiteShader = re.RegisterShader( "white", RSF_NOMIP | RSF_2D ); g_console_field_width = cls.windowConfig.vidWidth / SMALLCHAR_WIDTH - 2; g_consoleField.SetWidth(g_console_field_width); diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 44d233ee97..8f4f761ea7 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -316,7 +316,7 @@ struct clientStatic_t // rendering info WindowConfig windowConfig; qhandle_t charSetShader; - qhandle_t whiteShader; + qhandle_t whiteShader; // used for console drawing bool useLegacyConsoleFont; bool useLegacyConsoleFace; fontInfo_t *consoleFont; diff --git a/src/engine/renderer/tr_shader.cpp b/src/engine/renderer/tr_shader.cpp index 647eae66c6..27f98e71c1 100644 --- a/src/engine/renderer/tr_shader.cpp +++ b/src/engine/renderer/tr_shader.cpp @@ -2009,6 +2009,7 @@ static bool ParseStage( shaderStage_t *stage, const char **text ) filterType_t filterType; char buffer[ 1024 ] = ""; bool loadMap = false; + bool blendRegimeMatch = true; while ( true ) { @@ -2844,6 +2845,23 @@ static bool ParseStage( shaderStage_t *stage, const char **text ) continue; } } + // disable the stage if the renderer's blending mode does not match the specified mode + else if ( !Q_stricmp( token, "ifBlendRegime" ) ) + { + token = COM_ParseExt2( text, false ); + if ( !Q_stricmp( token, "naive" ) ) + { + blendRegimeMatch = !tr.worldLinearizeTexture; + } + else if ( !Q_stricmp( token, "linear" ) ) + { + blendRegimeMatch = tr.worldLinearizeTexture; + } + else + { + Log::Warn( "unknown parameter'%s' for ifBlendRegime in shader '%s'", token, shader.name ); + } + } // alpha else if ( !Q_stricmp( token, "alpha" ) ) { @@ -3222,6 +3240,11 @@ static bool ParseStage( shaderStage_t *stage, const char **text ) } } + if ( !blendRegimeMatch ) + { + return true; // parsing succeeded, but not active + } + // parsing succeeded stage->active = true; @@ -6050,6 +6073,11 @@ shader_t *R_FindShader( const char *name, int flags ) // going to have to upload an image R_SyncRenderThread(); + if ( !( flags & RSF_2D ) && !tr.worldMapLoaded ) + { + Log::Warn( "non-2D shader '%s' registered before map colorspace is known, assuming naive blending", name ); + } + ClearGlobalShader(); Q_strncpyz( shader.name, strippedName, sizeof( shader.name ) );