diff --git a/code/renderergl2/tr_bsp.c b/code/renderergl2/tr_bsp.c index c796e625..3413ff2d 100644 --- a/code/renderergl2/tr_bsp.c +++ b/code/renderergl2/tr_bsp.c @@ -128,17 +128,34 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) { /* =============== -R_ColorShiftLightingBytes +R_ColorShiftLightingFloats =============== */ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) { + float r, g, b; + scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits); - out[0] = in[0] * scale; - out[1] = in[1] * scale; - out[2] = in[2] * scale; + r = in[0] * scale; + g = in[1] * scale; + b = in[2] * scale; + + // normalize by color instead of saturating to white + if ( !r_hdr->integer && ( r > 1 || g > 1 || b > 1 ) ) { + float max; + + max = r > g ? r : g; + max = max > b ? max : b; + r = r / max; + g = g / max; + b = b / max; + } + + out[0] = r; + out[1] = g; + out[2] = b; out[3] = in[3]; }