Skip to content

Commit 9829f10

Browse files
committed
fixup: force overBright clamping
1 parent f9b2e98 commit 9829f10

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

src/engine/renderer/tr_bsp.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ static void R_LoadLightmaps( lump_t *l, const char *bspName )
648648
lightMapBuffer[( index * 4 ) + 2 ] = buf_p[( ( x + ( y * internalLightMapSize ) ) * 3 ) + 2 ];
649649
lightMapBuffer[( index * 4 ) + 3 ] = 255;
650650

651-
if ( tr.mapClampOverBright )
651+
if ( tr.forceLegacyMapOverBrightClamping )
652652
{
653653
R_ColorShiftLightingBytes( &lightMapBuffer[( index * 4 ) + 0 ] );
654654
}
@@ -1015,7 +1015,7 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, bspSurface_t *surf, in
10151015
cv->verts[ i ].lightColor = Color::Adapt( verts[ i ].color );
10161016

10171017

1018-
if ( tr.mapClampOverBright )
1018+
if ( tr.forceLegacyMapOverBrightClamping )
10191019
{
10201020
R_ColorShiftLightingBytes( cv->verts[ i ].lightColor.ToArray() );
10211021
}
@@ -1225,7 +1225,7 @@ static void ParseMesh( dsurface_t *ds, drawVert_t *verts, bspSurface_t *surf )
12251225

12261226
points[ i ].lightColor = Color::Adapt( verts[ i ].color );
12271227

1228-
if ( tr.mapClampOverBright )
1228+
if ( tr.forceLegacyMapOverBrightClamping )
12291229
{
12301230
R_ColorShiftLightingBytes( points[ i ].lightColor.ToArray() );
12311231
}
@@ -1352,7 +1352,7 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, bspSurface_t *surf,
13521352

13531353
cv->verts[ i ].lightColor = Color::Adapt( verts[ i ].color );
13541354

1355-
if ( tr.mapClampOverBright )
1355+
if ( tr.forceLegacyMapOverBrightClamping )
13561356
{
13571357
R_ColorShiftLightingBytes( cv->verts[ i ].lightColor.ToArray() );
13581358
}
@@ -4143,7 +4143,7 @@ void R_LoadLightGrid( lump_t *l )
41434143
tmpDirected[ 2 ] = in->directed[ 2 ];
41444144
tmpDirected[ 3 ] = 255;
41454145

4146-
if ( tr.mapClampOverBright )
4146+
if ( tr.forceLegacyMapOverBrightClamping )
41474147
{
41484148
R_ColorShiftLightingBytes( tmpAmbient );
41494149
R_ColorShiftLightingBytes( tmpDirected );
@@ -4389,12 +4389,10 @@ void R_LoadEntities( lump_t *l )
43894389
tr.mapOverBrightBits = Math::Clamp( atof( value ), 0.0, 3.0 );
43904390
}
43914391

4392-
/* Check for mapClampOverBright override: 1 will enable it
4393-
even if r_mapClampOverBright is false, and 0 will disable it
4394-
even if r_mapClampOverBright is true. */
4395-
else if ( !Q_stricmp( keyname, "mapClampOverBright" ) )
4392+
// Force forceLegacyMapOverBrightClamping even if r_forceLegacyMapOverBrightClamping is false.
4393+
else if ( !Q_stricmp( keyname, "forceLegacyMapOverBrightClamping" ) && !Q_stricmp( value, "1" ) )
43964394
{
4397-
tr.mapClampOverBright = !Q_stricmp( value, "1" );
4395+
tr.forceLegacyMapOverBrightClamping = true;
43984396
}
43994397

44004398
// check for deluxe mapping provided by NetRadiant's q3map2
@@ -7041,7 +7039,7 @@ void RE_LoadWorldMap( const char *name )
70417039

70427040
/* Used in GLSL code for the GLSL implementation
70437041
without color clamping and normalization. */
7044-
if ( !tr.mapClampOverBright )
7042+
if ( !tr.forceLegacyMapOverBrightClamping )
70457043
{
70467044
tr.mapLightFactor = pow( 2, tr.mapOverBrightBits );
70477045
tr.mapLightDivisor = 1.0f / tr.mapLightFactor;

src/engine/renderer/tr_image.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ image_t *R_FindImageFile( const char *imageName, imageParams_t &imageParams )
17391739
return nullptr;
17401740
}
17411741

1742-
if ( imageParams.bits & IF_LIGHTMAP && tr.mapClampOverBright )
1742+
if ( imageParams.bits & IF_LIGHTMAP && tr.forceLegacyMapOverBrightClamping )
17431743
{
17441744
R_ProcessLightmap( pic[ 0 ], width, height, imageParams.bits );
17451745
}
@@ -2961,7 +2961,7 @@ void R_InitImages()
29612961
always 1.0f. We can entirely remove it. */
29622962

29632963
tr.mapOverBrightBits = r_mapOverBrightBits.Get();
2964-
tr.mapClampOverBright = r_mapClampOverBright.Get();
2964+
tr.forceLegacyMapOverBrightClamping = r_forceLegacyMapOverBrightClamping.Get();
29652965

29662966
// create default texture and white texture
29672967
R_CreateBuiltinImages();

src/engine/renderer/tr_init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
8282
cvar_t *r_dynamicLightCastShadows;
8383
cvar_t *r_precomputedLighting;
8484
Cvar::Cvar<int> r_mapOverBrightBits("r_mapOverBrightBits", "default map light color shift", Cvar::NONE, 2);
85-
Cvar::Cvar<bool> r_mapClampOverBright("r_mapClampOverBright", "clamp over bright of legacy maps (enable multiplied color clamping and normalization)", Cvar::NONE, true);
85+
Cvar::Cvar<bool> r_forceLegacyMapOverBrightClamping("r_forceLegacyMapOverBrightClamping", "clamp over bright of legacy maps (enable multiplied color clamping and normalization)", Cvar::NONE, false);
8686
Cvar::Range<Cvar::Cvar<int>> r_lightMode("r_lightMode", "lighting mode: 0: fullbright (cheat), 1: vertex light, 2: grid light (cheat), 3: light map", Cvar::NONE, Util::ordinal(lightMode_t::MAP), Util::ordinal(lightMode_t::FULLBRIGHT), Util::ordinal(lightMode_t::MAP));
8787
cvar_t *r_lightStyles;
8888
cvar_t *r_exportTextures;
@@ -1116,7 +1116,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p
11161116
r_dynamicLightCastShadows = Cvar_Get( "r_dynamicLightCastShadows", "1", 0 );
11171117
r_precomputedLighting = Cvar_Get( "r_precomputedLighting", "1", CVAR_CHEAT | CVAR_LATCH );
11181118
Cvar::Latch( r_mapOverBrightBits );
1119-
Cvar::Latch( r_mapClampOverBright );
1119+
Cvar::Latch( r_forceLegacyMapOverBrightClamping );
11201120
Cvar::Latch( r_lightMode );
11211121
r_lightStyles = Cvar_Get( "r_lightStyles", "1", CVAR_LATCH | CVAR_ARCHIVE );
11221122
r_exportTextures = Cvar_Get( "r_exportTextures", "0", 0 );

src/engine/renderer/tr_local.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,7 +2832,7 @@ enum class dynamicLightRenderer_t { LEGACY, TILED };
28322832
// 1 / mapLightFactor
28332833
float mapLightDivisor;
28342834
// May have to be true on some legacy maps: clamp and normalize multiplied colors.
2835-
bool mapClampOverBright;
2835+
bool forceLegacyMapOverBrightClamping;
28362836

28372837
orientationr_t orientation; // for current entity
28382838

@@ -2959,7 +2959,7 @@ enum class dynamicLightRenderer_t { LEGACY, TILED };
29592959
extern cvar_t *r_dynamicLightCastShadows;
29602960
extern cvar_t *r_precomputedLighting;
29612961
extern Cvar::Cvar<int> r_mapOverBrightBits;
2962-
extern Cvar::Cvar<bool> r_mapClampOverBright;
2962+
extern Cvar::Cvar<bool> r_forceLegacyMapOverBrightClamping;
29632963
extern Cvar::Range<Cvar::Cvar<int>> r_lightMode;
29642964
extern cvar_t *r_lightStyles;
29652965
extern cvar_t *r_exportTextures;

0 commit comments

Comments
 (0)