Skip to content

Commit b8b0936

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 959edd9 commit b8b0936

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Diff for: src/engine/renderer/tr_bsp.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -4124,13 +4124,6 @@ void R_LoadLightGrid( lump_t *l )
41244124
tmpDirected[ 2 ] = in->directed[ 2 ];
41254125
tmpDirected[ 3 ] = 255;
41264126

4127-
const byte forceAmbientNormalised = floatToUnorm8( r_forceAmbient.Get() );
4128-
if ( tmpAmbient[0] < forceAmbientNormalised &&
4129-
tmpAmbient[1] < forceAmbientNormalised &&
4130-
tmpAmbient[2] < forceAmbientNormalised ) {
4131-
VectorSet( tmpAmbient, forceAmbientNormalised, forceAmbientNormalised, forceAmbientNormalised );
4132-
}
4133-
41344127
if ( tr.legacyOverBrightClamping )
41354128
{
41364129
R_ColorShiftLightingBytes( tmpAmbient );
@@ -4143,6 +4136,18 @@ void R_LoadLightGrid( lump_t *l )
41434136
directedColor[ j ] = tmpDirected[ j ] * ( 1.0f / 255.0f );
41444137
}
41454138

4139+
const float forceAmbient = r_forceAmbient.Get();
4140+
if ( ambientColor[0] < forceAmbient &&
4141+
ambientColor[1] < forceAmbient &&
4142+
ambientColor[2] < forceAmbient &&
4143+
/* Make sure we don't change the (0, 0, 0) points because those are points in walls,
4144+
which we'll fill up by interpolating nearby points later */
4145+
ambientColor[0] != 0 &&
4146+
ambientColor[1] != 0 &&
4147+
ambientColor[2] != 0 ) {
4148+
VectorSet( ambientColor, forceAmbient, forceAmbient, forceAmbient );
4149+
}
4150+
41464151
// standard spherical coordinates to cartesian coordinates conversion
41474152

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

0 commit comments

Comments
 (0)