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 @@ -2139,7 +2139,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);
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 @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,8 @@ enum class ssaoMode {
OP_GLOBAL5,
OP_GLOBAL6,
OP_GLOBAL7,
OP_NAIVE_BLENDING,
OP_LINEAR_BLENDING,
OP_FRAGMENTSHADERS,
OP_FRAMEBUFFEROBJECTS,
OP_SOUND,
Expand Down
10 changes: 10 additions & 0 deletions src/engine/renderer/tr_shade_calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ static float GetOpValue( const expOperation_t *op )
value = 1.0;
break;

case opcode_t::OP_NAIVE_BLENDING:
value = float( !tr.worldLinearizeTexture );
break;

case opcode_t::OP_LINEAR_BLENDING:
value = float( tr.worldLinearizeTexture );
break;

case opcode_t::OP_FRAGMENTSHADERS:
value = 1.0;
break;
Expand Down Expand Up @@ -272,6 +280,8 @@ static float EvalExpression( const expression_t *exp, float defaultValue )
case opcode_t::OP_GLOBAL5:
case opcode_t::OP_GLOBAL6:
case opcode_t::OP_GLOBAL7:
case opcode_t::OP_NAIVE_BLENDING:
case opcode_t::OP_LINEAR_BLENDING:
case opcode_t::OP_FRAGMENTSHADERS:
case opcode_t::OP_FRAMEBUFFEROBJECTS:
case opcode_t::OP_SOUND:
Expand Down
22 changes: 22 additions & 0 deletions src/engine/renderer/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ const opstring_t opStrings[] = {
{"global5", opcode_t::OP_GLOBAL5},
{"global6", opcode_t::OP_GLOBAL6},
{"global7", opcode_t::OP_GLOBAL7},
{"naiveBlending", opcode_t::OP_NAIVE_BLENDING},
{"linearBlending", opcode_t::OP_LINEAR_BLENDING},
{"fragmentShaders", opcode_t::OP_FRAGMENTSHADERS},
{"frameBufferObjects", opcode_t::OP_FRAMEBUFFEROBJECTS},
{"sound", opcode_t::OP_SOUND},
Expand Down Expand Up @@ -358,6 +360,8 @@ static bool IsOperand( opcode_t oc )
case opcode_t::OP_GLOBAL5:
case opcode_t::OP_GLOBAL6:
case opcode_t::OP_GLOBAL7:
case opcode_t::OP_NAIVE_BLENDING:
case opcode_t::OP_LINEAR_BLENDING:
case opcode_t::OP_FRAGMENTSHADERS:
case opcode_t::OP_FRAMEBUFFEROBJECTS:
case opcode_t::OP_SOUND:
Expand Down Expand Up @@ -2009,6 +2013,7 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
filterType_t filterType;
char buffer[ 1024 ] = "";
bool loadMap = false;
bool staticEnabled = true;

while ( true )
{
Expand All @@ -2029,6 +2034,12 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
{
ParseExpression( text, &stage->ifExp );
}
else if ( !Q_stricmp( token, "ifStatic" ) )
{
expression_t expr;
ParseExpression( text, &expr );
staticEnabled = !!RB_EvalExpression( &expr, 1.0f );
}
// map <name>
else if ( !Q_stricmp( token, "map" ) )
{
Expand Down Expand Up @@ -3222,6 +3233,12 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
}
}

if ( !staticEnabled )
{
// parsing succeeded, but stage disabled
return true;
}

// parsing succeeded
stage->active = true;

Expand Down Expand Up @@ -6050,6 +6067,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