Skip to content

Commit

Permalink
Set lightGrid point colour to r_forceAmbient after overbright shift
Browse files Browse the repository at this point in the history
Avoid overflow and incorrect results due to the overbright shift.
  • Loading branch information
VReaperV committed Jan 26, 2025
1 parent 959edd9 commit 1d3667a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/engine/renderer/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4124,19 +4124,19 @@ 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 &&
tmpAmbient[2] < forceAmbientNormalised ) {
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 );
Expand Down

0 comments on commit 1d3667a

Please sign in to comment.