diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/renderergl2/tr_bsp.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/renderergl2/tr_bsp.c b/src/renderergl2/tr_bsp.c index fcced63d..42478035 100644 --- a/src/renderergl2/tr_bsp.c +++ b/src/renderergl2/tr_bsp.c @@ -129,17 +129,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]; } |