From 1d3667ab814f269f50615d035b6ad8649f5f0075 Mon Sep 17 00:00:00 2001 From: VReaperV Date: Thu, 23 Jan 2025 01:19:39 +0300 Subject: [PATCH] Set lightGrid point colour to r_forceAmbient after overbright shift Avoid overflow and incorrect results due to the overbright shift. --- src/engine/renderer/tr_bsp.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/renderer/tr_bsp.cpp b/src/engine/renderer/tr_bsp.cpp index f098114b1e..ffa51b516b 100644 --- a/src/engine/renderer/tr_bsp.cpp +++ b/src/engine/renderer/tr_bsp.cpp @@ -4124,6 +4124,12 @@ void R_LoadLightGrid( lump_t *l ) tmpDirected[ 2 ] = in->directed[ 2 ]; tmpDirected[ 3 ] = 255; + if ( tr.legacyOverBrightClamping ) + { + R_ColorShiftLightingBytes( tmpAmbient ); + R_ColorShiftLightingBytes( tmpDirected ); + } + const byte forceAmbientNormalised = floatToUnorm8( r_forceAmbient.Get() ); if ( tmpAmbient[0] < forceAmbientNormalised && tmpAmbient[1] < forceAmbientNormalised && @@ -4131,12 +4137,6 @@ void R_LoadLightGrid( lump_t *l ) VectorSet( tmpAmbient, forceAmbientNormalised, forceAmbientNormalised, forceAmbientNormalised ); } - if ( tr.legacyOverBrightClamping ) - { - R_ColorShiftLightingBytes( tmpAmbient ); - R_ColorShiftLightingBytes( tmpDirected ); - } - for ( j = 0; j < 3; j++ ) { ambientColor[ j ] = tmpAmbient[ j ] * ( 1.0f / 255.0f );