@@ -293,10 +293,20 @@ 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);
299- baseColor.rgb = max(baseColor.rgb, vec3(0.0));
296+ //For team colors applied to a diffuse or spec map, we assume that the base color of the diffuse
297+ //at this point is vec3(0.5). To get accurate results, we subtract 0.5 from the team colors
298+ vec3 team_color = ((base_color - vec3(0.5)) * teamMask.x) + ((stripe_color - vec3(0.5)) * teamMask.y);
299+ vec3 team_color_glow = (base_color * teamMask.b) + (stripe_color * teamMask.a);
300+
301+ #ifdef FLAG_HDR
302+ team_color = pow(team_color, vec3(SRGB_GAMMA));
303+ team_color_glow = pow(team_color_glow, vec3(SRGB_GAMMA)) * GLOW_MAP_SRGB_MULTIPLIER;
304+ #endif
305+
306+ baseColor.rgb += team_color;
307+ baseColor.rgb = max(baseColor.rgb, vec3(0.0)); // We need to make sure that nothing here ever goes negative
308+ specColor.rgb += team_color;
309+ specColor.rgb = max(specColor.rgb, vec3(0.03));
300310 #endif
301311#endif
302312 // Lights aren't applied when we are rendering to the G-buffers since that gets handled later
@@ -343,12 +353,12 @@ void main()
343353 vec3 glowColor = texture(sGlowmap, vec3(texCoord, float(sGlowmapIndex))).rgb;
344354 if(overrideGlow) glowColor = glowClr;
345355 #ifdef FLAG_HDR
346- glowColor = pow(glowColor, vec3(SRGB_GAMMA)) * 3.0f ;
356+ glowColor = pow(glowColor, vec3(SRGB_GAMMA)) * GLOW_MAP_SRGB_MULTIPLIER ;
347357 #endif
348358 #ifdef FLAG_MISC_MAP
349359 #ifdef FLAG_TEAMCOLOR
350360 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;
361+ glowColor = team_glow_enabled ? mix(max(team_color_glow, vec3(0.0) ), glowColor, clamp(glowColorLuminance - teamMask.b - teamMask.a, 0.0, 1.0)) : glowColor;
352362 #endif
353363 #endif
354364 emissiveColor.rgb += glowColor * GLOW_MAP_INTENSITY;
0 commit comments