Skip to content

Commit 7c11475

Browse files
committed
Add SRGB adjustment to the team colors, make the logic less weird.
1 parent be9a881 commit 7c11475

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

code/def_files/data/effects/main-f.sdr

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,17 @@ void main()
293293
#ifdef FLAG_TEAMCOLOR
294294
vec4 teamMask = vec4(0.0, 0.0, 0.0, 0.0);
295295
teamMask = texture(sMiscmap, vec3(texCoord, float(sMiscmapIndex)));
296-
vec3 base = max(base_color - vec3(0.5), vec3(0.0));
297-
vec3 stripe = max(stripe_color - vec3(0.5), vec3(0.0));
298-
baseColor.rgb += (base * teamMask.x) + (stripe * teamMask.y);
296+
vec3 team_color = (base_color * teamMask.x) + (stripe_color * teamMask.y);
297+
vec3 team_color_glow = (base_color * teamMask.b) + (stripe_color * teamMask.a);
298+
#ifdef FLAG_HDR
299+
team_color = pow(team_color, vec3(SRGB_GAMMA));
300+
team_color_glow = pow(team_color_glow, vec3(SRGB_GAMMA)) * 3.0f;
301+
#endif
302+
303+
baseColor.rgb += team_color;
299304
baseColor.rgb = max(baseColor.rgb, vec3(0.0));
305+
specColor.rgb += team_color;
306+
specColor.rgb = max(specColor.rgb, vec3(0.03f));
300307
#endif
301308
#endif
302309
// Lights aren't applied when we are rendering to the G-buffers since that gets handled later
@@ -348,7 +355,7 @@ void main()
348355
#ifdef FLAG_MISC_MAP
349356
#ifdef FLAG_TEAMCOLOR
350357
float glowColorLuminance = dot(glowColor, vec3(0.299, 0.587, 0.114));
351-
glowColor = team_glow_enabled ? mix((base * teamMask.b) + (stripe * teamMask.a), glowColor, clamp(glowColorLuminance - teamMask.b - teamMask.a, 0.0, 1.0)) : glowColor;
358+
glowColor = team_glow_enabled ? mix(team_color_glow, glowColor, clamp(glowColorLuminance - teamMask.b - teamMask.a, 0.0, 1.0)) : glowColor;
352359
#endif
353360
#endif
354361
emissiveColor.rgb += glowColor * GLOW_MAP_INTENSITY;

0 commit comments

Comments
 (0)