diff --git a/src/engine/renderer/tr_bsp.cpp b/src/engine/renderer/tr_bsp.cpp index a5bfab45ee..bc7a21ae00 100644 --- a/src/engine/renderer/tr_bsp.cpp +++ b/src/engine/renderer/tr_bsp.cpp @@ -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 ); @@ -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 ) @@ -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] ); diff --git a/src/engine/renderer/tr_init.cpp b/src/engine/renderer/tr_init.cpp index bcd1dc30db..7156dcf52d 100644 --- a/src/engine/renderer/tr_init.cpp +++ b/src/engine/renderer/tr_init.cpp @@ -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> r_forceAmbient( "r_forceAmbient", "Minimal light amount in lightGrid", Cvar::NONE, - 0.125f, 0.0f, 0.3f ); + Cvar::Range> r_forceAmbient( "r_forceAmbient", "Minimal light amount in lightGrid; -1 to use map value", + Cvar::CHEAT, -1.0f, -1.0f, 0.3f ); Cvar::Cvar 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;