Skip to content

Commit f57e346

Browse files
committed
Only enable team glow colors if team color texture mask has an alpha channel.
1 parent 768e097 commit f57e346

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

code/globalincs/def_files.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ char* Default_main_vertex_shader =
14671467
" gl_ClipVertex = (gl_ModelViewMatrix * orient * vertex);\n"
14681468
"}";
14691469

1470-
char *Default_main_fragment_shader =
1470+
char *Default_main_fragment_shader =
14711471
"#extension GL_EXT_texture_array : enable\n"
14721472
"#ifdef FLAG_LIGHT\n"
14731473
"uniform int n_lights;\n"
@@ -1510,6 +1510,7 @@ char *Default_main_fragment_shader =
15101510
"#ifdef FLAG_TEAMCOLOR\n"
15111511
"uniform vec3 base_color;\n"
15121512
"uniform vec3 stripe_color;\n"
1513+
"uniform bool team_glow_enabled;\n"
15131514
"vec2 teamMask = vec2(0.0, 0.0);\n"
15141515
"#endif\n"
15151516
"#ifdef FLAG_MISC_MAP\n"
@@ -1793,7 +1794,7 @@ char *Default_main_fragment_shader =
17931794
" #ifdef FLAG_MISC_MAP\n"
17941795
" #ifdef FLAG_TEAMCOLOR\n"
17951796
" float glowColorLuminance = dot(glowColor, vec3(0.299, 0.587, 0.114));\n"
1796-
" glowColor = mix((base * teamMask.b) + (stripe * teamMask.a), glowColor, clamp(glowColorLuminance - teamMask.b - teamMask.a, 0.0, 1.0));\n"
1797+
" glowColor = team_glow_enabled ? mix((base * teamMask.b) + (stripe * teamMask.a), glowColor, clamp(glowColorLuminance - teamMask.b - teamMask.a, 0.0, 1.0)) : glowColor;\n"
17971798
" #endif\n"
17981799
" #endif\n"
17991800
" baseColor.rgb += glowColor * GLOW_MAP_INTENSITY;\n"

code/graphics/gropenglshader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static opengl_shader_variant_t GL_shader_variants[] = {
125125
"Utility mapping" },
126126

127127
{ SDR_TYPE_MODEL, false, SDR_FLAG_MODEL_TEAMCOLOR, "FLAG_TEAMCOLOR",
128-
2, { "stripe_color", "base_color" }, 0, { NULL },
128+
3, { "stripe_color", "base_color", "team_glow_enabled" }, 0, { NULL },
129129
"Team Colors" },
130130

131131
{ SDR_TYPE_MODEL, false, SDR_FLAG_MODEL_DEFERRED, "FLAG_DEFERRED",

code/graphics/gropengltnl.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,7 @@ void opengl_tnl_set_material(int flags, uint shader_flags, int tmap_type)
21832183
// Team colors are passed to the shader here, but the shader needs to handle their application.
21842184
// By default, this is handled through the r and g channels of the misc map, but this can be changed
21852185
// in the shader; test versions of this used the normal map r and b channels
2186-
if ( shader_flags & SDR_FLAG_MODEL_TEAMCOLOR ) {
2186+
if ( (shader_flags & SDR_FLAG_MODEL_TEAMCOLOR) && (shader_flags & SDR_FLAG_MODEL_MISC_MAP) ) {
21872187
vec3d stripe_color;
21882188
vec3d base_color;
21892189

@@ -2197,6 +2197,12 @@ void opengl_tnl_set_material(int flags, uint shader_flags, int tmap_type)
21972197

21982198
GL_state.Uniform.setUniform3f("stripe_color", stripe_color);
21992199
GL_state.Uniform.setUniform3f("base_color", base_color);
2200+
2201+
if ( bm_has_alpha_channel(MISCMAP) ) {
2202+
GL_state.Uniform.setUniformi("team_glow_enabled", 1);
2203+
} else {
2204+
GL_state.Uniform.setUniformi("team_glow_enabled", 0);
2205+
}
22002206
}
22012207

22022208
if ( shader_flags & SDR_FLAG_MODEL_THRUSTER ) {

0 commit comments

Comments
 (0)