@@ -3955,7 +3955,7 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump )
39553955 Log::Debug (" %i fog volumes loaded" , s_worldData.numFogs );
39563956}
39573957
3958- static void R_SetDefaultLightGrid ( )
3958+ static void R_SetConstantColorLightGrid ( const byte color[ 3 ] )
39593959{
39603960 world_t *w = &s_worldData;
39613961
@@ -3983,9 +3983,9 @@ static void R_SetDefaultLightGrid()
39833983 bspGridPoint2_t *gridPoint2 = (bspGridPoint2_t *) (gridPoint1 + w->numLightGridPoints );
39843984
39853985 // default some white light from above
3986- gridPoint1->color [ 0 ] = 64 ;
3987- gridPoint1->color [ 1 ] = 64 ;
3988- gridPoint1->color [ 2 ] = 64 ;
3986+ gridPoint1->color [ 0 ] = color[ 0 ] ;
3987+ gridPoint1->color [ 1 ] = color[ 1 ] ;
3988+ gridPoint1->color [ 2 ] = color[ 2 ] ;
39893989 gridPoint1->ambientPart = 128 ;
39903990 gridPoint2->direction [ 0 ] = floatToSnorm8 (0 .0f );
39913991 gridPoint2->direction [ 1 ] = floatToSnorm8 (0 .0f );
@@ -4039,9 +4039,16 @@ void R_LoadLightGrid( lump_t *l )
40394039 vec3_t ambientColor, directedColor, direction;
40404040 float scale;
40414041
4042+ if ( tr.ambientLightSet ) {
4043+ const byte color[3 ]{ floatToUnorm8 ( tr.ambientLight [0 ] ), floatToUnorm8 ( tr.ambientLight [1 ] ),
4044+ floatToUnorm8 ( tr.ambientLight [2 ] ) };
4045+ R_SetConstantColorLightGrid ( color );
4046+ }
4047+
40424048 if ( !r_precomputedLighting->integer )
40434049 {
4044- R_SetDefaultLightGrid ();
4050+ const byte color[3 ] { 64 , 64 , 64 };
4051+ R_SetConstantColorLightGrid ( color );
40454052 return ;
40464053 }
40474054
@@ -4081,7 +4088,8 @@ void R_LoadLightGrid( lump_t *l )
40814088 {
40824089 Log::Warn (" light grid mismatch, default light grid used" );
40834090
4084- R_SetDefaultLightGrid ();
4091+ const byte color[3 ]{ 64 , 64 , 64 };
4092+ R_SetConstantColorLightGrid ( color );
40854093
40864094 return ;
40874095 }
@@ -4116,6 +4124,12 @@ void R_LoadLightGrid( lump_t *l )
41164124 tmpDirected[ 2 ] = in->directed [ 2 ];
41174125 tmpDirected[ 3 ] = 255 ;
41184126
4127+ if ( tmpAmbient[0 ] < r_forceAmbient->value &&
4128+ tmpAmbient[1 ] < r_forceAmbient->value &&
4129+ tmpAmbient[2 ] < r_forceAmbient->value ) {
4130+ VectorSet ( tmpAmbient, r_forceAmbient->value , r_forceAmbient->value , r_forceAmbient->value );
4131+ }
4132+
41194133 if ( tr.legacyOverBrightClamping )
41204134 {
41214135 R_ColorShiftLightingBytes ( tmpAmbient );
@@ -4338,6 +4352,13 @@ void R_LoadEntities( lump_t *l, std::string &externalEntities )
43384352 // check for ambient color
43394353 else if ( !Q_stricmp ( keyname, " _color" ) || !Q_stricmp ( keyname, " ambientColor" ) )
43404354 {
4355+ if ( r_forceAmbient->value <= 0 ) {
4356+ sscanf ( value, " %f %f %f" , &tr.ambientLight [0 ], &tr.ambientLight [1 ],
4357+ &tr.ambientLight [2 ] );
4358+
4359+ VectorScale ( tr.ambientLight , r_ambientScale->value , tr.ambientLight );
4360+ tr.ambientLightSet = true ;
4361+ }
43414362 }
43424363
43434364 // check for deluxe mapping support
0 commit comments