This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.5a
in repository iortcw.

commit fec857dafe6c906beafc401d36fa57314d999d34
Author: MAN-AT-ARMS <m4n4t4...@gmail.com>
Date:   Fri Sep 16 18:14:26 2016 -0400

    All: Rend2: Remove map color scaling and r_forceSunMapLightScale
    
    Also simplify overbright code in ComputeShaderColors()
---
 MP/code/rend2/tr_backend.c |  3 --
 MP/code/rend2/tr_bsp.c     | 12 +-------
 MP/code/rend2/tr_image.c   |  4 ---
 MP/code/rend2/tr_init.c    |  2 --
 MP/code/rend2/tr_local.h   |  4 ---
 MP/code/rend2/tr_main.c    | 10 +------
 MP/code/rend2/tr_scene.c   |  6 ----
 MP/code/rend2/tr_shade.c   | 73 ++++++++++++++--------------------------------
 MP/code/rend2/tr_shader.c  |  6 ++--
 MP/code/rend2/tr_sky.c     |  4 +--
 MP/rend2-readme.md         | 10 ++-----
 SP/code/rend2/tr_backend.c |  3 --
 SP/code/rend2/tr_bsp.c     | 11 -------
 SP/code/rend2/tr_image.c   |  4 ---
 SP/code/rend2/tr_init.c    |  2 --
 SP/code/rend2/tr_local.h   |  4 ---
 SP/code/rend2/tr_main.c    | 10 +------
 SP/code/rend2/tr_scene.c   |  6 ----
 SP/code/rend2/tr_shade.c   | 71 +++++++++++++-------------------------------
 SP/code/rend2/tr_shader.c  |  6 ++--
 SP/code/rend2/tr_sky.c     |  4 +--
 SP/rend2-readme.md         | 10 ++-----
 22 files changed, 64 insertions(+), 201 deletions(-)

diff --git a/MP/code/rend2/tr_backend.c b/MP/code/rend2/tr_backend.c
index dcd2a69..8662635 100644
--- a/MP/code/rend2/tr_backend.c
+++ b/MP/code/rend2/tr_backend.c
@@ -786,9 +786,6 @@ void    RB_SetGL2D( void ) {
        // set time for 2D shaders
        backEnd.refdef.time = ri.Milliseconds();
        backEnd.refdef.floatTime = backEnd.refdef.time * 0.001f;
-
-       // reset color scaling
-       backEnd.refdef.colorScale = 1.0f;
 }
 
 
diff --git a/MP/code/rend2/tr_bsp.c b/MP/code/rend2/tr_bsp.c
index 3d1f0df..4f016c2 100644
--- a/MP/code/rend2/tr_bsp.c
+++ b/MP/code/rend2/tr_bsp.c
@@ -111,11 +111,7 @@ static void R_ColorShiftLightingBytes( byte in[4], byte 
out[4] ) {
        int shift, r, g, b;
 
        // shift the color data based on overbright range
-#if defined(USE_OVERBRIGHT)
        shift = r_mapOverBrightBits->integer - tr.overbrightBits;
-#else
-       shift = 0;
-#endif
 
        // shift the data based on overbright range
        r = in[0] << shift;
@@ -149,9 +145,7 @@ static void R_ColorShiftLightingFloats(float in[4], float 
out[4], float scale )
 {
        float   r, g, b;
 
-#if defined(USE_OVERBRIGHT)
        scale *= 1 << (r_mapOverBrightBits->integer - tr.overbrightBits);
-#endif
 
        r = in[0] * scale;
        g = in[1] * scale;
@@ -3035,11 +3029,8 @@ void R_LoadLightGrid( lump_t *l ) {
 
                if (hdrLightGrid)
                {
-#if defined(USE_OVERBRIGHT)
                        float lightScale = 1 << (r_mapOverBrightBits->integer - 
tr.overbrightBits);
-#else
-                       float lightScale = 1.0f;
-#endif
+
                        //ri.Printf(PRINT_ALL, "found!\n");
 
                        if (size != sizeof(float) * 6 * numGridPoints)
@@ -3518,7 +3509,6 @@ void RE_LoadWorldMap( const char *name ) {
        }
 
        // set default map light scale
-       tr.mapLightScale = 1.0f;
        tr.sunShadowScale = 0.5f;
 
        // set default sun direction to be used if it isn't
diff --git a/MP/code/rend2/tr_image.c b/MP/code/rend2/tr_image.c
index 54bb371..122e436 100644
--- a/MP/code/rend2/tr_image.c
+++ b/MP/code/rend2/tr_image.c
@@ -3018,11 +3018,7 @@ void R_SetColorMappings( void ) {
        int inf;
 
        // setup the overbright lighting
-#if defined(USE_OVERBRIGHT)
        tr.overbrightBits = r_overBrightBits->integer;
-#else
-       tr.overbrightBits = 0;
-#endif
 
        // allow 2 overbright bits
        if ( tr.overbrightBits > 2 ) {
diff --git a/MP/code/rend2/tr_init.c b/MP/code/rend2/tr_init.c
index 0250ee7..540d128 100644
--- a/MP/code/rend2/tr_init.c
+++ b/MP/code/rend2/tr_init.c
@@ -174,7 +174,6 @@ cvar_t  *r_imageUpsampleMaxSize;
 cvar_t  *r_imageUpsampleType;
 cvar_t  *r_genNormalMaps;
 cvar_t  *r_forceSun;
-cvar_t  *r_forceSunMapLightScale;
 cvar_t  *r_forceSunLightScale;
 cvar_t  *r_forceSunAmbientScale;
 cvar_t  *r_sunlightMode;
@@ -1370,7 +1369,6 @@ void R_Register( void ) {
        r_genNormalMaps = ri.Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
 
        r_forceSun = ri.Cvar_Get( "r_forceSun", "0", CVAR_ARCHIVE );
-       r_forceSunMapLightScale = ri.Cvar_Get( "r_forceSunMapLightScale", 
"1.0", CVAR_CHEAT );
        r_forceSunLightScale = ri.Cvar_Get( "r_forceSunLightScale", "1.0", 
CVAR_CHEAT );
        r_forceSunAmbientScale = ri.Cvar_Get( "r_forceSunAmbientScale", "0.5", 
CVAR_CHEAT );
        r_drawSunRays = ri.Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h
index b55edd7..c4ffdc2 100644
--- a/MP/code/rend2/tr_local.h
+++ b/MP/code/rend2/tr_local.h
@@ -58,7 +58,6 @@ typedef unsigned int glIndex_t;
 #define PSHADOW_MAP_SIZE      512
  
 #define USE_VERT_TANGENT_SPACE
-#define USE_OVERBRIGHT
 
 // a trRefEntity_t has all the information passed in by
 // the client game, as well as some locally derived info
@@ -855,7 +854,6 @@ typedef struct {
        float       sunDir[4];
        float       sunCol[4];
        float       sunAmbCol[4];
-       float       colorScale;
  
        float       autoExposureMinMax[2];
        float       toneMinAvgMaxLinear[3];
@@ -1741,7 +1739,6 @@ typedef struct {
 
        int viewCluster;
 
-       float                   mapLightScale;
        float                   sunShadowScale;
 
        qboolean                sunShadows;
@@ -1998,7 +1995,6 @@ extern  cvar_t  *r_imageUpsampleMaxSize;
 extern  cvar_t  *r_imageUpsampleType;
 extern  cvar_t  *r_genNormalMaps;
 extern  cvar_t  *r_forceSun;
-extern  cvar_t  *r_forceSunMapLightScale;
 extern  cvar_t  *r_forceSunLightScale;
 extern  cvar_t  *r_forceSunAmbientScale;
 extern  cvar_t  *r_sunlightMode;
diff --git a/MP/code/rend2/tr_main.c b/MP/code/rend2/tr_main.c
index a304455..e198528 100644
--- a/MP/code/rend2/tr_main.c
+++ b/MP/code/rend2/tr_main.c
@@ -2750,7 +2750,6 @@ void R_RenderCubemapSide( int cubemapIndex, int 
cubemapSide, qboolean subscene )
 {
        refdef_t refdef;
        viewParms_t     parms;
-       float oldColorScale = tr.refdef.colorScale;
 
        memset( &refdef, 0, sizeof( refdef ) );
        refdef.rdflags = 0;
@@ -2828,7 +2827,6 @@ void R_RenderCubemapSide( int cubemapIndex, int 
cubemapSide, qboolean subscene )
                R_LightForPoint(tr.refdef.vieworg, ambient, directed, lightDir);
                scale = directed[0] + directed[1] + directed[2] + ambient[0] + 
ambient[1] + ambient[2] + 1.0f;
 
-               tr.refdef.colorScale = 1.0f; //766.0f / scale;
                // only print message for first side
                if (scale < 1.0001f && cubemapSide == 0)
                {
@@ -2869,13 +2867,7 @@ void R_RenderCubemapSide( int cubemapIndex, int 
cubemapSide, qboolean subscene )
 
        R_RenderView(&parms);
 
-       if (subscene)
-       {
-               tr.refdef.colorScale = oldColorScale;
-       }
-       else
-       {
+       if (!subscene)
                RE_EndScene();
-       }
 }
 
diff --git a/MP/code/rend2/tr_scene.c b/MP/code/rend2/tr_scene.c
index 07cb46c..15d98b2 100644
--- a/MP/code/rend2/tr_scene.c
+++ b/MP/code/rend2/tr_scene.c
@@ -445,18 +445,12 @@ void RE_BeginScene(const refdef_t *fd)
 
        VectorCopy(tr.sunDirection, tr.refdef.sunDir);
        if ( (tr.refdef.rdflags & RDF_NOWORLDMODEL) || !(r_depthPrepass->value) 
){
-               tr.refdef.colorScale = 1.0f;
                VectorSet(tr.refdef.sunCol, 0, 0, 0);
                VectorSet(tr.refdef.sunAmbCol, 0, 0, 0);
        }
        else
        {
-#if defined(USE_OVERBRIGHT)
-               float scale = (1 << (r_mapOverBrightBits->integer - 
tr.overbrightBits)) / 255.0f;
-#else
                float scale = (1 << r_mapOverBrightBits->integer) / 255.0f;
-#endif
-               tr.refdef.colorScale = r_forceSun->integer ? 
r_forceSunMapLightScale->value : tr.mapLightScale;
 
                if (r_forceSun->integer)
                        VectorScale(tr.sunLight, scale * 
r_forceSunLightScale->value, tr.refdef.sunCol);
diff --git a/MP/code/rend2/tr_shade.c b/MP/code/rend2/tr_shade.c
index c364638..07037f6 100644
--- a/MP/code/rend2/tr_shade.c
+++ b/MP/code/rend2/tr_shade.c
@@ -481,18 +481,16 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
                || ((blend & GLS_SRCBLEND_BITS) == 
GLS_SRCBLEND_ONE_MINUS_DST_COLOR)
                || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR)
                || ((blend & GLS_DSTBLEND_BITS) == 
GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);
-       qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL);
-       float scale = 1.0f;
 
-#if defined(USE_OVERBRIGHT)
-       float exactLight = 1.0f;
-#else
-       float exactLight = (isBlend || !isWorldDraw) ? 1.0f : (float)(1 << 
r_mapOverBrightBits->integer);
-#endif
+       qboolean is2DDraw = backEnd.currentEntity == &backEnd.entity2D;
+
+       float overbright = (isBlend || is2DDraw) ? 1.0f : (float)(1 << 
tr.overbrightBits);
+
+       fog_t *fog;
 
        baseColor[0] = 
        baseColor[1] =
-       baseColor[2] = exactLight;
+       baseColor[2] =
        baseColor[3] = 1.0f;
 
        vertColor[0] =
@@ -505,11 +503,6 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
        //
        switch ( pStage->rgbGen )
        {
-               case CGEN_IDENTITY_LIGHTING:
-                       baseColor[0] = 
-                       baseColor[1] =
-                       baseColor[2] = tr.identityLight;
-                       break;
                case CGEN_EXACT_VERTEX:
                case CGEN_EXACT_VERTEX_LIT:
                        baseColor[0] = 
@@ -519,7 +512,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
 
                        vertColor[0] =
                        vertColor[1] =
-                       vertColor[2] = exactLight;
+                       vertColor[2] = overbright;
                        vertColor[3] = 1.0f;
                        break;
                case CGEN_CONST:
@@ -529,47 +522,32 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
                        baseColor[3] = pStage->constantColor[3] / 255.0f;
                        break;
                case CGEN_VERTEX:
-                       baseColor[0] = 
+               case CGEN_VERTEX_LIT:
+                       baseColor[0] =
                        baseColor[1] =
                        baseColor[2] =
                        baseColor[3] = 0.0f;
 
                        vertColor[0] =
                        vertColor[1] =
-                       vertColor[2] = tr.identityLight;
+                       vertColor[2] =
                        vertColor[3] = 1.0f;
                        break;
-               case CGEN_VERTEX_LIT:
-                       baseColor[0] = 
-                       baseColor[1] =
-                       baseColor[2] = 
-                       baseColor[3] = 0.0f;
-
-                       vertColor[0] =
-                       vertColor[1] =
-                       vertColor[2] = 
-                       vertColor[3] = tr.identityLight;
-                       break;
                case CGEN_ONE_MINUS_VERTEX:
                        baseColor[0] = 
                        baseColor[1] =
-                       baseColor[2] = tr.identityLight;
+                       baseColor[2] = 1.0f;
 
                        vertColor[0] =
                        vertColor[1] =
-                       vertColor[2] = -tr.identityLight;
+                       vertColor[2] = -1.0f;
                        break;
                case CGEN_FOG:
-                       {
-                               fog_t           *fog;
-
-                               fog = tr.world->fogs + tess.fogNum;
-
-                               baseColor[0] = ((unsigned char 
*)(&fog->colorInt))[0] / 255.0f;
-                               baseColor[1] = ((unsigned char 
*)(&fog->colorInt))[1] / 255.0f;
-                               baseColor[2] = ((unsigned char 
*)(&fog->colorInt))[2] / 255.0f;
-                               baseColor[3] = ((unsigned char 
*)(&fog->colorInt))[3] / 255.0f;
-                       }
+                       fog = tr.world->fogs + tess.fogNum;
+                       baseColor[0] = ((unsigned char *)(&fog->colorInt))[0] / 
255.0f;
+                       baseColor[1] = ((unsigned char *)(&fog->colorInt))[1] / 
255.0f;
+                       baseColor[2] = ((unsigned char *)(&fog->colorInt))[2] / 
255.0f;
+                       baseColor[3] = ((unsigned char *)(&fog->colorInt))[3] / 
255.0f;
                        break;
                case CGEN_WAVEFORM:
                        baseColor[0] = 
@@ -596,6 +574,11 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
                        break;
                case CGEN_IDENTITY:
                case CGEN_LIGHTING_DIFFUSE:
+                       baseColor[0] =
+                       baseColor[1] =
+                       baseColor[2] = overbright;
+                       break;
+               case CGEN_IDENTITY_LIGHTING:
                case CGEN_BAD:
                        break;
        }
@@ -654,18 +637,6 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
                        break;
        }
 
-       if (tr.overbrightBits && !isBlend)
-               scale *= 1 << tr.overbrightBits;
-
-       if ((backEnd.refdef.colorScale != 1.0f) && !isBlend && isWorldDraw)
-               scale *= backEnd.refdef.colorScale;
-
-       if (scale != 1.0f)
-       {
-               VectorScale(baseColor, scale, baseColor);
-               VectorScale(vertColor, scale, vertColor);
-       }
-
        // FIXME: find some way to implement this.
 #if 0
        // if in greyscale rendering mode turn all color values into greyscale.
diff --git a/MP/code/rend2/tr_shader.c b/MP/code/rend2/tr_shader.c
index e6abba6..876c35b 100644
--- a/MP/code/rend2/tr_shader.c
+++ b/MP/code/rend2/tr_shader.c
@@ -1775,10 +1775,12 @@ static qboolean ParseShader( char **text ) {
                        if (isGL2Sun)
                        {
                                token = COM_ParseExt( text, qfalse );
-                               tr.mapLightScale = atof(token);
+                               tr.sunShadowScale = atof(token);
 
+                               // parse twice, since older shaders may include 
mapLightScale before sunShadowScale
                                token = COM_ParseExt( text, qfalse );
-                               tr.sunShadowScale = atof(token);
+                               if (token[0])
+                                       tr.sunShadowScale = atof(token);
                        }
 
                        SkipRestOfLine( text );
diff --git a/MP/code/rend2/tr_sky.c b/MP/code/rend2/tr_sky.c
index 550ee11..53086bc 100644
--- a/MP/code/rend2/tr_sky.c
+++ b/MP/code/rend2/tr_sky.c
@@ -461,7 +461,7 @@ static void DrawSkySide( struct image_s *image, const int 
mins[2], const int max
 
                color[0] = 
                color[1] = 
-               color[2] = backEnd.refdef.colorScale;
+               color[2] =
                color[3] = 1.0f;
                GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color);
 
@@ -578,7 +578,7 @@ static void DrawSkySideInner( struct image_s *image, const 
int mins[2], const in
                
                color[0] = 
                color[1] = 
-               color[2] = backEnd.refdef.colorScale;
+               color[2] =
                color[3] = 1.0f;
                GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color);
 
diff --git a/MP/rend2-readme.md b/MP/rend2-readme.md
index 9493631..184833c 100644
--- a/MP/rend2-readme.md
+++ b/MP/rend2-readme.md
@@ -264,10 +264,6 @@ Cvars for the sunlight and cascaded shadow maps:
                                      1 - Do.
                                      2 - Sunrise, sunset.
 
-*  `r_forceSunMapLightScale`        - Cheat. Scale map brightness by this 
factor
-                                   when r_forceSun 1.
-                                     1.0 - Default
-                                     
 *  `r_forceSunLightScale`           - Cheat. Scale sun brightness by this 
factor
                                    when r_forceSun 1.
                                      1.0 - Default
@@ -506,7 +502,7 @@ and is the equivalent for 'exactVertex'.
 
 This adds a new keyword to sky materials, q3gl2_sun.  The syntax is:
 
-    q3gl2_sun <red> <green> <blue> <intensity> <degrees> <elevation> 
<mapLightScale> <ambientLightScale>
+    q3gl2_sun <red> <green> <blue> <intensity> <degrees> <elevation> 
<ambientLightScale>
   
 Note the first six parameters are the same as in q3map_sun or q3map_sunExt,
 and the last two indicate scaling factors for the map brightness and an ambient
@@ -527,7 +523,7 @@ There are currently two ways to use this in your own (and 
other people's) maps.
           surfaceparm nolightmap
           surfaceparm sky
           q3map_sunExt 240 238 200 100 195 35 3 16
-          q3gl2_sun 240 238 200 50 195 35 1.0 0.2
+          q3gl2_sun 240 238 200 50 195 35 0.2
           q3map_skylight 50 16
           q3map_lightimage $whiteimage
 
@@ -550,7 +546,7 @@ There are currently two ways to use this in your own (and 
other people's) maps.
           surfaceparm noimpact
           surfaceparm nolightmap
           surfaceparm sky
-          q3gl2_sun 240 238 200 50 195 35 0.5 0.2
+          q3gl2_sun 240 238 200 50 195 35 0.2
           q3map_skylight 50 16
           q3map_lightimage $whiteimage
 
diff --git a/SP/code/rend2/tr_backend.c b/SP/code/rend2/tr_backend.c
index e5a7d08..e264247 100644
--- a/SP/code/rend2/tr_backend.c
+++ b/SP/code/rend2/tr_backend.c
@@ -1136,9 +1136,6 @@ void    RB_SetGL2D( void ) {
        // set time for 2D shaders
        backEnd.refdef.time = ri.Milliseconds();
        backEnd.refdef.floatTime = backEnd.refdef.time * 0.001f;
-
-       // reset color scaling
-       backEnd.refdef.colorScale = 1.0f;
 }
 
 
diff --git a/SP/code/rend2/tr_bsp.c b/SP/code/rend2/tr_bsp.c
index 4e4fc37..f685e74 100644
--- a/SP/code/rend2/tr_bsp.c
+++ b/SP/code/rend2/tr_bsp.c
@@ -111,11 +111,7 @@ static void R_ColorShiftLightingBytes( byte in[4], byte 
out[4] ) {
        int shift, r, g, b;
 
        // shift the color data based on overbright range
-#if defined(USE_OVERBRIGHT)
        shift = r_mapOverBrightBits->integer - tr.overbrightBits;
-#else
-       shift = 0;
-#endif
 
        // shift the data based on overbright range
        r = in[0] << shift;
@@ -149,9 +145,7 @@ static void R_ColorShiftLightingFloats(float in[4], float 
out[4], float scale )
 {
        float   r, g, b;
 
-#if defined(USE_OVERBRIGHT)
        scale *= 1 << (r_mapOverBrightBits->integer - tr.overbrightBits);
-#endif
 
        r = in[0] * scale;
        g = in[1] * scale;
@@ -3024,11 +3018,7 @@ void R_LoadLightGrid( lump_t *l ) {
 
                if (hdrLightGrid)
                {
-#if defined(USE_OVERBRIGHT)
                        float lightScale = 1 << (r_mapOverBrightBits->integer - 
tr.overbrightBits);
-#else
-                       float lightScale = 1.0f;
-#endif
 
                        //ri.Printf(PRINT_ALL, "found!\n");
 
@@ -3506,7 +3496,6 @@ void RE_LoadWorldMap( const char *name ) {
        }
 
        // set default map light scale
-       tr.mapLightScale = 1.0f;
        tr.sunShadowScale = 0.5f;
 
        // set default sun direction to be used if it isn't
diff --git a/SP/code/rend2/tr_image.c b/SP/code/rend2/tr_image.c
index 9fd2fb5..e6b3b80 100644
--- a/SP/code/rend2/tr_image.c
+++ b/SP/code/rend2/tr_image.c
@@ -3028,11 +3028,7 @@ void R_SetColorMappings( void ) {
        int inf;
 
        // setup the overbright lighting
-#if defined(USE_OVERBRIGHT)
        tr.overbrightBits = r_overBrightBits->integer;
-#else
-       tr.overbrightBits = 0;
-#endif
 
        // allow 2 overbright bits
        if ( tr.overbrightBits > 2 ) {
diff --git a/SP/code/rend2/tr_init.c b/SP/code/rend2/tr_init.c
index c5ecc71..f539ba2 100644
--- a/SP/code/rend2/tr_init.c
+++ b/SP/code/rend2/tr_init.c
@@ -179,7 +179,6 @@ cvar_t  *r_imageUpsampleMaxSize;
 cvar_t  *r_imageUpsampleType;
 cvar_t  *r_genNormalMaps;
 cvar_t  *r_forceSun;
-cvar_t  *r_forceSunMapLightScale;
 cvar_t  *r_forceSunLightScale;
 cvar_t  *r_forceSunAmbientScale;
 cvar_t  *r_sunlightMode;
@@ -1393,7 +1392,6 @@ void R_Register( void ) {
        r_genNormalMaps = ri.Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
 
        r_forceSun = ri.Cvar_Get( "r_forceSun", "0", CVAR_ARCHIVE );
-       r_forceSunMapLightScale = ri.Cvar_Get( "r_forceSunMapLightScale", 
"1.0", CVAR_CHEAT );
        r_forceSunLightScale = ri.Cvar_Get( "r_forceSunLightScale", "1.0", 
CVAR_CHEAT );
        r_forceSunAmbientScale = ri.Cvar_Get( "r_forceSunAmbientScale", "0.5", 
CVAR_CHEAT );
        r_drawSunRays = ri.Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
diff --git a/SP/code/rend2/tr_local.h b/SP/code/rend2/tr_local.h
index 2bd9754..66b3ee5 100644
--- a/SP/code/rend2/tr_local.h
+++ b/SP/code/rend2/tr_local.h
@@ -58,7 +58,6 @@ typedef unsigned int glIndex_t;
 #define PSHADOW_MAP_SIZE      512
  
 #define USE_VERT_TANGENT_SPACE
-#define USE_OVERBRIGHT
 
 // a trRefEntity_t has all the information passed in by
 // the client game, as well as some locally derived info
@@ -859,7 +858,6 @@ typedef struct {
        float       sunDir[4];
        float       sunCol[4];
        float       sunAmbCol[4];
-       float       colorScale;
  
        float       autoExposureMinMax[2];
        float       toneMinAvgMaxLinear[3];
@@ -1755,7 +1753,6 @@ typedef struct {
 
        int viewCluster;
 
-       float                   mapLightScale;
        float                   sunShadowScale;
 
        qboolean                sunShadows;
@@ -2018,7 +2015,6 @@ extern  cvar_t  *r_imageUpsampleMaxSize;
 extern  cvar_t  *r_imageUpsampleType;
 extern  cvar_t  *r_genNormalMaps;
 extern  cvar_t  *r_forceSun;
-extern  cvar_t  *r_forceSunMapLightScale;
 extern  cvar_t  *r_forceSunLightScale;
 extern  cvar_t  *r_forceSunAmbientScale;
 extern  cvar_t  *r_sunlightMode;
diff --git a/SP/code/rend2/tr_main.c b/SP/code/rend2/tr_main.c
index fe4def0..cc7bab3 100644
--- a/SP/code/rend2/tr_main.c
+++ b/SP/code/rend2/tr_main.c
@@ -2792,7 +2792,6 @@ void R_RenderCubemapSide( int cubemapIndex, int 
cubemapSide, qboolean subscene )
 {
        refdef_t refdef;
        viewParms_t     parms;
-       float oldColorScale = tr.refdef.colorScale;
 
        memset( &refdef, 0, sizeof( refdef ) );
        refdef.rdflags = 0;
@@ -2870,7 +2869,6 @@ void R_RenderCubemapSide( int cubemapIndex, int 
cubemapSide, qboolean subscene )
                R_LightForPoint(tr.refdef.vieworg, ambient, directed, lightDir);
                scale = directed[0] + directed[1] + directed[2] + ambient[0] + 
ambient[1] + ambient[2] + 1.0f;
 
-               tr.refdef.colorScale = 1.0f; //766.0f / scale;
                // only print message for first side
                if (scale < 1.0001f && cubemapSide == 0)
                {
@@ -2911,13 +2909,7 @@ void R_RenderCubemapSide( int cubemapIndex, int 
cubemapSide, qboolean subscene )
 
        R_RenderView(&parms);
 
-       if (subscene)
-       {
-               tr.refdef.colorScale = oldColorScale;
-       }
-       else
-       {
+       if (!subscene)
                RE_EndScene();
-       }
 }
 
diff --git a/SP/code/rend2/tr_scene.c b/SP/code/rend2/tr_scene.c
index 648173b..4741ff5 100644
--- a/SP/code/rend2/tr_scene.c
+++ b/SP/code/rend2/tr_scene.c
@@ -458,18 +458,12 @@ void RE_BeginScene(const refdef_t *fd)
 
        VectorCopy(tr.sunDirection, tr.refdef.sunDir);
        if ( (tr.refdef.rdflags & RDF_NOWORLDMODEL) || !(r_depthPrepass->value) 
){
-               tr.refdef.colorScale = 1.0f;
                VectorSet(tr.refdef.sunCol, 0, 0, 0);
                VectorSet(tr.refdef.sunAmbCol, 0, 0, 0);
        }
        else
        {
-#if defined(USE_OVERBRIGHT)
-               float scale = (1 << (r_mapOverBrightBits->integer - 
tr.overbrightBits)) / 255.0f;
-#else
                float scale = (1 << r_mapOverBrightBits->integer) / 255.0f;
-#endif
-               tr.refdef.colorScale = r_forceSun->integer ? 
r_forceSunMapLightScale->value : tr.mapLightScale;
 
                if (r_forceSun->integer)
                        VectorScale(tr.sunLight, scale * 
r_forceSunLightScale->value, tr.refdef.sunCol);
diff --git a/SP/code/rend2/tr_shade.c b/SP/code/rend2/tr_shade.c
index 9800079..d0b85e4 100644
--- a/SP/code/rend2/tr_shade.c
+++ b/SP/code/rend2/tr_shade.c
@@ -475,18 +475,15 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
                || ((blend & GLS_SRCBLEND_BITS) == 
GLS_SRCBLEND_ONE_MINUS_DST_COLOR)
                || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR)
                || ((blend & GLS_DSTBLEND_BITS) == 
GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);
-       qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL);
-       float scale = 1.0f;
+qboolean is2DDraw = backEnd.currentEntity == &backEnd.entity2D;
 
-#if defined(USE_OVERBRIGHT)
-       float exactLight = 1.0f;
-#else
-       float exactLight = (isBlend || !isWorldDraw) ? 1.0f : (float)(1 << 
r_mapOverBrightBits->integer);
-#endif
+       float overbright = (isBlend || is2DDraw) ? 1.0f : (float)(1 << 
tr.overbrightBits);
+
+       fog_t *fog;
 
        baseColor[0] = 
        baseColor[1] =
-       baseColor[2] = exactLight;
+       baseColor[2] =
        baseColor[3] = 1.0f;
 
        vertColor[0] =
@@ -499,11 +496,6 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
        //
        switch ( pStage->rgbGen )
        {
-               case CGEN_IDENTITY_LIGHTING:
-                       baseColor[0] = 
-                       baseColor[1] =
-                       baseColor[2] = tr.identityLight;
-                       break;
                case CGEN_EXACT_VERTEX:
                case CGEN_EXACT_VERTEX_LIT:
                        baseColor[0] = 
@@ -513,7 +505,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
 
                        vertColor[0] =
                        vertColor[1] =
-                       vertColor[2] = exactLight;
+                       vertColor[2] = overbright;
                        vertColor[3] = 1.0f;
                        break;
                case CGEN_CONST:
@@ -523,47 +515,33 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
                        baseColor[3] = pStage->constantColor[3] / 255.0f;
                        break;
                case CGEN_VERTEX:
-                       baseColor[0] = 
+               case CGEN_VERTEX_LIT:
+                       baseColor[0] =
                        baseColor[1] =
                        baseColor[2] =
                        baseColor[3] = 0.0f;
 
                        vertColor[0] =
                        vertColor[1] =
-                       vertColor[2] = tr.identityLight;
+                       vertColor[2] =
                        vertColor[3] = 1.0f;
                        break;
-               case CGEN_VERTEX_LIT:
-                       baseColor[0] = 
-                       baseColor[1] =
-                       baseColor[2] = 
-                       baseColor[3] = 0.0f;
-
-                       vertColor[0] =
-                       vertColor[1] =
-                       vertColor[2] = 
-                       vertColor[3] = tr.identityLight;
-                       break;
                case CGEN_ONE_MINUS_VERTEX:
                        baseColor[0] = 
                        baseColor[1] =
-                       baseColor[2] = tr.identityLight;
+                       baseColor[2] = 1.0f;
 
                        vertColor[0] =
                        vertColor[1] =
-                       vertColor[2] = -tr.identityLight;
+                       vertColor[2] = -1.0f;
                        break;
                case CGEN_FOG:
-                       {
-                               fog_t           *fog;
+                       fog = tr.world->fogs + tess.fogNum;
 
-                               fog = tr.world->fogs + tess.fogNum;
-
-                               baseColor[0] = ((unsigned char 
*)(&fog->colorInt))[0] / 255.0f;
-                               baseColor[1] = ((unsigned char 
*)(&fog->colorInt))[1] / 255.0f;
-                               baseColor[2] = ((unsigned char 
*)(&fog->colorInt))[2] / 255.0f;
-                               baseColor[3] = ((unsigned char 
*)(&fog->colorInt))[3] / 255.0f;
-                       }
+                       baseColor[0] = ((unsigned char *)(&fog->colorInt))[0] / 
255.0f;
+                       baseColor[1] = ((unsigned char *)(&fog->colorInt))[1] / 
255.0f;
+                       baseColor[2] = ((unsigned char *)(&fog->colorInt))[2] / 
255.0f;
+                       baseColor[3] = ((unsigned char *)(&fog->colorInt))[3] / 
255.0f;
                        break;
                case CGEN_WAVEFORM:
                        baseColor[0] = 
@@ -590,6 +568,11 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
                        break;
                case CGEN_IDENTITY:
                case CGEN_LIGHTING_DIFFUSE:
+                       baseColor[0] =
+                       baseColor[1] =
+                       baseColor[2] = overbright;
+                       break;
+               case CGEN_IDENTITY_LIGHTING:
                case CGEN_BAD:
                        break;
        }
@@ -648,18 +631,6 @@ static void ComputeShaderColors( shaderStage_t *pStage, 
vec4_t baseColor, vec4_t
                        break;
        }
 
-       if (tr.overbrightBits && !isBlend)
-               scale *= 1 << tr.overbrightBits;
-
-       if ((backEnd.refdef.colorScale != 1.0f) && !isBlend && isWorldDraw)
-               scale *= backEnd.refdef.colorScale;
-
-       if (scale != 1.0f)
-       {
-               VectorScale(baseColor, scale, baseColor);
-               VectorScale(vertColor, scale, vertColor);
-       }
-
        // FIXME: find some way to implement this.
 #if 0
        // if in greyscale rendering mode turn all color values into greyscale.
diff --git a/SP/code/rend2/tr_shader.c b/SP/code/rend2/tr_shader.c
index 9d249d6..3575b51 100644
--- a/SP/code/rend2/tr_shader.c
+++ b/SP/code/rend2/tr_shader.c
@@ -1787,10 +1787,12 @@ static qboolean ParseShader( char **text ) {
                        if (isGL2Sun)
                        {
                                token = COM_ParseExt( text, qfalse );
-                               tr.mapLightScale = atof(token);
+                               tr.sunShadowScale = atof(token);
 
+                               // parse twice, since older shaders may include 
mapLightScale before sunShadowScale
                                token = COM_ParseExt( text, qfalse );
-                               tr.sunShadowScale = atof(token);
+                               if (token[0])
+                                       tr.sunShadowScale = atof(token);
                        }
 
                        SkipRestOfLine( text );
diff --git a/SP/code/rend2/tr_sky.c b/SP/code/rend2/tr_sky.c
index 71c6d7e..426e517 100644
--- a/SP/code/rend2/tr_sky.c
+++ b/SP/code/rend2/tr_sky.c
@@ -458,7 +458,7 @@ static void DrawSkySide( struct image_s *image, const int 
mins[2], const int max
 
                color[0] = 
                color[1] = 
-               color[2] = backEnd.refdef.colorScale;
+               color[2] =
                color[3] = 1.0f;
                GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color);
 
@@ -575,7 +575,7 @@ static void DrawSkySideInner( struct image_s *image, const 
int mins[2], const in
                
                color[0] = 
                color[1] = 
-               color[2] = backEnd.refdef.colorScale;
+               color[2] =
                color[3] = 1.0f;
                GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color);
 
diff --git a/SP/rend2-readme.md b/SP/rend2-readme.md
index 079346c..78f35b7 100644
--- a/SP/rend2-readme.md
+++ b/SP/rend2-readme.md
@@ -264,10 +264,6 @@ Cvars for the sunlight and cascaded shadow maps:
                                      1 - Do.
                                      2 - Sunrise, sunset.
 
-*  `r_forceSunMapLightScale`        - Cheat. Scale map brightness by this 
factor
-                                   when r_forceSun 1.
-                                     1.0 - Default
-                                     
 *  `r_forceSunLightScale`           - Cheat. Scale sun brightness by this 
factor
                                    when r_forceSun 1.
                                      1.0 - Default
@@ -506,7 +502,7 @@ and is the equivalent for 'exactVertex'.
 
 This adds a new keyword to sky materials, q3gl2_sun.  The syntax is:
 
-    q3gl2_sun <red> <green> <blue> <intensity> <degrees> <elevation> 
<mapLightScale> <ambientLightScale>
+    q3gl2_sun <red> <green> <blue> <intensity> <degrees> <elevation> 
<ambientLightScale>
   
 Note the first six parameters are the same as in q3map_sun or q3map_sunExt,
 and the last two indicate scaling factors for the map brightness and an ambient
@@ -527,7 +523,7 @@ There are currently two ways to use this in your own (and 
other people's) maps.
           surfaceparm nolightmap
           surfaceparm sky
           q3map_sunExt 240 238 200 100 195 35 3 16
-          q3gl2_sun 240 238 200 50 195 35 1.0 0.2
+          q3gl2_sun 240 238 200 50 195 35 0.2
           q3map_skylight 50 16
           q3map_lightimage $whiteimage
 
@@ -550,7 +546,7 @@ There are currently two ways to use this in your own (and 
other people's) maps.
           surfaceparm noimpact
           surfaceparm nolightmap
           surfaceparm sky
-          q3gl2_sun 240 238 200 50 195 35 0.5 0.2
+          q3gl2_sun 240 238 200 50 195 35 0.2
           q3map_skylight 50 16
           q3map_lightimage $whiteimage
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/iortcw.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to