Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/engine/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2143,7 +2143,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.glconfig.vidWidth / SMALLCHAR_WIDTH - 2;
g_consoleField.SetWidth(g_console_field_width);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ struct clientStatic_t
glconfig_t glconfig;
glconfig2_t glconfig2;
qhandle_t charSetShader;
qhandle_t whiteShader;
qhandle_t whiteShader; // used for console drawing
bool useLegacyConsoleFont;
bool useLegacyConsoleFace;
fontInfo_t *consoleFont;
Expand Down
30 changes: 28 additions & 2 deletions src/engine/renderer/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,7 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
filterType_t filterType;
char buffer[ 1024 ] = "";
bool loadMap = false;
bool colorspaceMatch = true;

while ( true )
{
Expand Down Expand Up @@ -2855,6 +2856,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, "colorspace" ) )
{
token = COM_ParseExt2( text, false );
if ( !Q_stricmp( token, "naive" ) )
{
colorspaceMatch = !tr.worldLinearizeTexture;
}
else if ( !Q_stricmp( token, "linear" ) )
{
colorspaceMatch = tr.worldLinearizeTexture;
}
else
{
Log::Warn( "unknown colorspace '%s' in shader '%s'", token, shader.name );
}
}
// alpha <arithmetic expression>
else if ( !Q_stricmp( token, "alpha" ) )
{
Expand Down Expand Up @@ -3233,6 +3251,11 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
}
}

if ( !colorspaceMatch )
{
return true; // parsing succeeded, but not active
}

// parsing succeeded
stage->active = true;

Expand Down Expand Up @@ -3866,8 +3889,6 @@ static bool ParseShader( const char *_text )
return false;
}

stage->active = true;

/* Examples of shaders with light styles, those
shaders are generated by the q3map2 map compiler.

Expand Down Expand Up @@ -6092,6 +6113,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 ) );
Expand Down