Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/engine/renderer/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4106,12 +4106,6 @@ void R_LoadLightGrid( lump_t *l )
tmpDirected[ 2 ] = in->directed[ 2 ];
tmpDirected[ 3 ] = 255;

if ( tmpAmbient[0] < r_forceAmbient.Get() &&
tmpAmbient[1] < r_forceAmbient.Get() &&
tmpAmbient[2] < r_forceAmbient.Get() ) {
VectorSet( tmpAmbient, r_forceAmbient.Get(), r_forceAmbient.Get(), r_forceAmbient.Get() );
}

if ( tr.legacyOverBrightClamping )
{
R_ColorShiftLightingBytes( tmpAmbient );
Expand All @@ -4124,6 +4118,18 @@ void R_LoadLightGrid( lump_t *l )
directedColor[ j ] = tmpDirected[ j ] * ( 1.0f / 255.0f );
}

const float forceAmbient = r_forceAmbient.Get();
if ( ambientColor[0] < forceAmbient &&
ambientColor[1] < forceAmbient &&
ambientColor[2] < forceAmbient &&
/* Make sure we don't change the (0, 0, 0) points because those are points in walls,
which we'll fill up by interpolating nearby points later */
( ambientColor[0] != 0 ||
ambientColor[1] != 0 ||
ambientColor[2] != 0 ) ) {
VectorSet( ambientColor, forceAmbient, forceAmbient, forceAmbient );
}

// standard spherical coordinates to cartesian coordinates conversion

// decode X as cos( lat ) * sin( long )
Expand Down Expand Up @@ -4332,9 +4338,9 @@ void R_LoadEntities( lump_t *l, std::string &externalEntities )
}

// check for ambient color
else if ( !Q_stricmp( keyname, "_color" ) || !Q_stricmp( keyname, "ambientColor" ) )
else if ( !Q_stricmp( keyname, "ambientColor" ) )
{
if ( r_forceAmbient.Get() == 0 ) {
if ( r_forceAmbient.Get() == -1 ) {
sscanf( value, "%f %f %f", &tr.ambientLight[0], &tr.ambientLight[1],
&tr.ambientLight[2] );

Expand Down
4 changes: 2 additions & 2 deletions src/engine/renderer/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
cvar_t *r_wolfFog;
cvar_t *r_noFog;

Cvar::Range<Cvar::Cvar<float>> r_forceAmbient( "r_forceAmbient", "Minimal light amount in lightGrid", Cvar::NONE,
0.125f, 0.0f, 0.3f );
Cvar::Range<Cvar::Cvar<float>> r_forceAmbient( "r_forceAmbient", "Minimal light amount in lightGrid; -1 to use map value",
Cvar::CHEAT, -1.0f, -1.0f, 0.3f );
Cvar::Cvar<float> r_ambientScale( "r_ambientScale", "Scale lightGrid produced by ambientColor keyword by this much", Cvar::CHEAT, 1.0 );
cvar_t *r_lightScale;
cvar_t *r_debugSort;
Expand Down