Skip to content

Commit d671939

Browse files
committed
Set lightGrid point colour to r_forceAmbient after overbright shift
Avoid overflow and incorrect results due to the overbright shift. Also fix `r_forceAmbient` affecting lightGrid points inside of walls.
1 parent acdd999 commit d671939

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/engine/renderer/tr_bsp.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4134,13 +4134,6 @@ void R_LoadLightGrid( lump_t *l )
41344134
tmpDirected[ 2 ] = in->directed[ 2 ];
41354135
tmpDirected[ 3 ] = 255;
41364136

4137-
const byte forceAmbientNormalised = floatToUnorm8( r_forceAmbient.Get() );
4138-
if ( tmpAmbient[0] < forceAmbientNormalised &&
4139-
tmpAmbient[1] < forceAmbientNormalised &&
4140-
tmpAmbient[2] < forceAmbientNormalised ) {
4141-
VectorSet( tmpAmbient, forceAmbientNormalised, forceAmbientNormalised, forceAmbientNormalised );
4142-
}
4143-
41444137
if ( tr.legacyOverBrightClamping )
41454138
{
41464139
R_ColorShiftLightingBytes( tmpAmbient );
@@ -4153,6 +4146,18 @@ void R_LoadLightGrid( lump_t *l )
41534146
directedColor[ j ] = tmpDirected[ j ] * ( 1.0f / 255.0f );
41544147
}
41554148

4149+
const float forceAmbient = r_forceAmbient.Get();
4150+
if ( ambientColor[0] < forceAmbient &&
4151+
ambientColor[1] < forceAmbient &&
4152+
ambientColor[2] < forceAmbient &&
4153+
/* Make sure we don't change the (0, 0, 0) points because those are points in walls,
4154+
which we'll fill up by interpolating nearby points later */
4155+
ambientColor[0] != 0 &&
4156+
ambientColor[1] != 0 &&
4157+
ambientColor[2] != 0 ) {
4158+
VectorSet( ambientColor, forceAmbient, forceAmbient, forceAmbient );
4159+
}
4160+
41564161
// standard spherical coordinates to cartesian coordinates conversion
41574162

41584163
// decode X as cos( lat ) * sin( long )

0 commit comments

Comments
 (0)