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

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 109689adb427c86d97afe0a06b18c80b6e11431d
Author: m4n4t4...@gmail.com 
<m4n4t4...@gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date:   Fri Feb 14 12:02:55 2014 +0000

    All: Rend2: Set RGBM to use a multiplier of 1, and only use it with HDR 
lightmaps
---
 MP/code/rend2/glsl/generic_fp.glsl  |  2 +-
 MP/code/rend2/glsl/lightall_fp.glsl |  2 +-
 MP/code/rend2/tr_bsp.c              | 91 +++++++++++++++++++------------------
 MP/code/rend2/tr_init.c             |  2 +-
 SP/code/rend2/glsl/generic_fp.glsl  |  2 +-
 SP/code/rend2/glsl/lightall_fp.glsl |  2 +-
 SP/code/rend2/tr_bsp.c              | 91 +++++++++++++++++++------------------
 SP/code/rend2/tr_init.c             |  2 +-
 8 files changed, 98 insertions(+), 96 deletions(-)

diff --git a/MP/code/rend2/glsl/generic_fp.glsl 
b/MP/code/rend2/glsl/generic_fp.glsl
index f485797..aefa33c 100644
--- a/MP/code/rend2/glsl/generic_fp.glsl
+++ b/MP/code/rend2/glsl/generic_fp.glsl
@@ -21,7 +21,7 @@ void main()
 #if defined(USE_LIGHTMAP)
        vec4 color2 = texture2D(u_LightMap, var_LightTex);
   #if defined(RGBM_LIGHTMAP)
-       color2.rgb *= 32.0 * color2.a;
+       color2.rgb *= color2.a;
        color2.a = 1.0;
   #endif
 
diff --git a/MP/code/rend2/glsl/lightall_fp.glsl 
b/MP/code/rend2/glsl/lightall_fp.glsl
index d134e40..b983d6f 100644
--- a/MP/code/rend2/glsl/lightall_fp.glsl
+++ b/MP/code/rend2/glsl/lightall_fp.glsl
@@ -346,7 +346,7 @@ void main()
        vec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw);
        vec3 lightColor = lightSample.rgb;
   #if defined(RGBM_LIGHTMAP)
-       lightColor *= 32.0 * lightSample.a;
+       lightColor *= lightSample.a;
   #endif
 #elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)
        vec3 lightColor   = u_DirectedLight * 
CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / 
sqrLightDist);
diff --git a/MP/code/rend2/tr_bsp.c b/MP/code/rend2/tr_bsp.c
index 01b0584..0d5dad8 100644
--- a/MP/code/rend2/tr_bsp.c
+++ b/MP/code/rend2/tr_bsp.c
@@ -171,7 +171,7 @@ void ColorToRGBM(const vec3_t color, unsigned char rgbm[4])
        vec3_t          sample;
        float                   maxComponent;
 
-       VectorScale(color, 1.0f / 32.0f, sample);
+       VectorCopy(color, sample);
 
        maxComponent = MAX(sample[0], sample[1]);
        maxComponent = MAX(maxComponent, sample[2]);
@@ -332,7 +332,6 @@ static      void R_LoadLightmaps( lump_t *l, lump_t *surfs 
) {
                {
                        char filename[MAX_QPATH];
                        byte *hdrLightmap = NULL;
-                       float lightScale = 1.0f;
                        int size = 0;
 
                        // look for hdr lightmaps
@@ -389,55 +388,57 @@ static    void R_LoadLightmaps( lump_t *l, lump_t *surfs 
) {
                                        buf_p = buf + i * tr.lightmapSize * 
tr.lightmapSize * 3;
                        }
 
-                       lightScale = pow(2, r_mapOverBrightBits->integer - 
tr.overbrightBits - 8); //exp2(r_mapOverBrightBits->integer - tr.overbrightBits 
- 8);
-
                        for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; 
j++ ) 
                        {
-                               if (r_hdr->integer)
+                               if (hdrLightmap)
                                {
-                                       float color[3];
-
-                                       if (hdrLightmap)
-                                       {
+                                       vec4_t color;
 #if 0 // HDRFILE_RGBE
-                                               float exponent = 
exp2(buf_p[j*4+3] - 128);
+                                       float exponent = exp2(buf_p[j*4+3] - 
128);
 
-                                               color[0] = buf_p[j*4+0] * 
exponent;
-                                               color[1] = buf_p[j*4+1] * 
exponent;
-                                               color[2] = buf_p[j*4+2] * 
exponent;
+                                       color[0] = buf_p[j*4+0] * exponent;
+                                       color[1] = buf_p[j*4+1] * exponent;
+                                       color[2] = buf_p[j*4+2] * exponent;
 #else // HDRFILE_FLOAT
-                                               memcpy(color, &buf_p[j*12], 12);
+                                       memcpy(color, &buf_p[j*12], 12);
 
-                                               color[0] = 
LittleFloat(color[0]);
-                                               color[1] = 
LittleFloat(color[1]);
-                                               color[2] = 
LittleFloat(color[2]);
+                                       color[0] = LittleFloat(color[0]);
+                                       color[1] = LittleFloat(color[1]);
+                                       color[2] = LittleFloat(color[2]);
 #endif
-                                       }
-                                       else
-                                       {
-                                               //hack: convert LDR lightmap to 
HDR one
-                                               color[0] = (buf_p[j*3+0] + 
1.0f);
-                                               color[1] = (buf_p[j*3+1] + 
1.0f);
-                                               color[2] = (buf_p[j*3+2] + 
1.0f);
-
-                                               // if under an arbitrary value 
(say 12) grey it out
-                                               // this prevents weird 
splotches in dimly lit areas
-                                               if (color[0] + color[1] + 
color[2] < 12.0f)
-                                               {
-                                                       float avg = (color[0] + 
color[1] + color[2]) * 0.3333f;
-                                                       color[0] = avg;
-                                                       color[1] = avg;
-                                                       color[2] = avg;
-                                               }
-                                       }
+                                       color[3] = 1.0f;
 
-                                       VectorScale(color, lightScale, color);
+                                       R_ColorShiftLightingFloats(color, 
color, 1.0f/255.0f);
 
                                        if (glRefConfig.textureFloat && 
glRefConfig.halfFloatPixel && r_floatLightmap->integer)
                                                ColorToRGBA16F(color, (unsigned 
short *)(&image[j*8]));
                                        else
                                                ColorToRGBM(color, &image[j*4]);
                                }
+                               else if (glRefConfig.textureFloat && 
glRefConfig.halfFloatPixel && r_floatLightmap->integer) 
+                               {
+                                       vec4_t color;
+
+                                       //hack: convert LDR lightmap to HDR one
+                                       color[0] = MAX(buf_p[j*3+0], 0.499f);
+                                       color[1] = MAX(buf_p[j*3+1], 0.499f);
+                                       color[2] = MAX(buf_p[j*3+2], 0.499f);
+
+                                       // if under an arbitrary value (say 12) 
grey it out
+                                       // this prevents weird splotches in 
dimly lit areas
+                                       if (color[0] + color[1] + color[2] < 
12.0f)
+                                       {
+                                               float avg = (color[0] + 
color[1] + color[2]) * 0.3333f;
+                                               color[0] = avg;
+                                               color[1] = avg;
+                                               color[2] = avg;
+                                       }
+                                       color[3] = 1.0f;
+
+                                       R_ColorShiftLightingFloats(color, 
color, 1.0f/255.0f);
+
+                                       ColorToRGBA16F(color, (unsigned short 
*)(&image[j*8]));
+                               }
                                else
                                {
                                        if ( r_lightmap->integer == 2 )
@@ -785,9 +786,9 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, 
float *hdrVertColors,
                        //hack: convert LDR vertex colors to HDR
                        if (r_hdr->integer)
                        {
-                               color[0] = verts[i].color[0] + 1.0f;
-                               color[1] = verts[i].color[1] + 1.0f;
-                               color[2] = verts[i].color[2] + 1.0f;
+                               color[0] = MAX(verts[i].color[0], 0.499f);
+                               color[1] = MAX(verts[i].color[1], 0.499f);
+                               color[2] = MAX(verts[i].color[2], 0.499f);
                        }
                        else
                        {
@@ -929,9 +930,9 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, 
float *hdrVertColors,
                        //hack: convert LDR vertex colors to HDR
                        if (r_hdr->integer)
                        {
-                               color[0] = verts[i].color[0] + 1.0f;
-                               color[1] = verts[i].color[1] + 1.0f;
-                               color[2] = verts[i].color[2] + 1.0f;
+                               color[0] = MAX(verts[i].color[0], 0.499f);
+                               color[1] = MAX(verts[i].color[1], 0.499f);
+                               color[2] = MAX(verts[i].color[2], 0.499f);
                        }
                        else
                        {
@@ -1030,9 +1031,9 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t 
*verts, float *hdrVertColor
                        //hack: convert LDR vertex colors to HDR
                        if (r_hdr->integer)
                        {
-                               color[0] = verts[i].color[0] + 1.0f;
-                               color[1] = verts[i].color[1] + 1.0f;
-                               color[2] = verts[i].color[2] + 1.0f;
+                               color[0] = MAX(verts[i].color[0], 0.499f);
+                               color[1] = MAX(verts[i].color[1], 0.499f);
+                               color[2] = MAX(verts[i].color[2], 0.499f);
                        }
                        else
                        {
diff --git a/MP/code/rend2/tr_init.c b/MP/code/rend2/tr_init.c
index f459e31..6611776 100644
--- a/MP/code/rend2/tr_init.c
+++ b/MP/code/rend2/tr_init.c
@@ -1281,7 +1281,7 @@ void R_Register( void ) {
        r_softOverbright = ri.Cvar_Get( "r_softOverbright", "1", CVAR_ARCHIVE | 
CVAR_LATCH );
 
        r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH );
-       r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "1", CVAR_ARCHIVE | 
CVAR_LATCH );
+       r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
        r_postProcess = ri.Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE );
 
        r_toneMap = ri.Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH );
diff --git a/SP/code/rend2/glsl/generic_fp.glsl 
b/SP/code/rend2/glsl/generic_fp.glsl
index f485797..aefa33c 100644
--- a/SP/code/rend2/glsl/generic_fp.glsl
+++ b/SP/code/rend2/glsl/generic_fp.glsl
@@ -21,7 +21,7 @@ void main()
 #if defined(USE_LIGHTMAP)
        vec4 color2 = texture2D(u_LightMap, var_LightTex);
   #if defined(RGBM_LIGHTMAP)
-       color2.rgb *= 32.0 * color2.a;
+       color2.rgb *= color2.a;
        color2.a = 1.0;
   #endif
 
diff --git a/SP/code/rend2/glsl/lightall_fp.glsl 
b/SP/code/rend2/glsl/lightall_fp.glsl
index d134e40..b983d6f 100644
--- a/SP/code/rend2/glsl/lightall_fp.glsl
+++ b/SP/code/rend2/glsl/lightall_fp.glsl
@@ -346,7 +346,7 @@ void main()
        vec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw);
        vec3 lightColor = lightSample.rgb;
   #if defined(RGBM_LIGHTMAP)
-       lightColor *= 32.0 * lightSample.a;
+       lightColor *= lightSample.a;
   #endif
 #elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)
        vec3 lightColor   = u_DirectedLight * 
CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / 
sqrLightDist);
diff --git a/SP/code/rend2/tr_bsp.c b/SP/code/rend2/tr_bsp.c
index 15edfa6..e85c0e3 100644
--- a/SP/code/rend2/tr_bsp.c
+++ b/SP/code/rend2/tr_bsp.c
@@ -171,7 +171,7 @@ void ColorToRGBM(const vec3_t color, unsigned char rgbm[4])
        vec3_t          sample;
        float                   maxComponent;
 
-       VectorScale(color, 1.0f / 32.0f, sample);
+       VectorCopy(color, sample);
 
        maxComponent = MAX(sample[0], sample[1]);
        maxComponent = MAX(maxComponent, sample[2]);
@@ -330,7 +330,6 @@ static      void R_LoadLightmaps( lump_t *l, lump_t *surfs 
) {
                {
                        char filename[MAX_QPATH];
                        byte *hdrLightmap = NULL;
-                       float lightScale = 1.0f;
                        int size = 0;
 
                        // look for hdr lightmaps
@@ -387,55 +386,57 @@ static    void R_LoadLightmaps( lump_t *l, lump_t *surfs 
) {
                                        buf_p = buf + i * tr.lightmapSize * 
tr.lightmapSize * 3;
                        }
 
-                       lightScale = pow(2, r_mapOverBrightBits->integer - 
tr.overbrightBits - 8); //exp2(r_mapOverBrightBits->integer - tr.overbrightBits 
- 8);
-
                        for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; 
j++ )
                        {
-                               if (r_hdr->integer)
+                               if (hdrLightmap)
                                {
-                                       float color[3];
-
-                                       if (hdrLightmap)
-                                       {
+                                       vec4_t color;
 #if 0 // HDRFILE_RGBE
-                                               float exponent = 
exp2(buf_p[j*4+3] - 128);
+                                       float exponent = exp2(buf_p[j*4+3] - 
128);
 
-                                               color[0] = buf_p[j*4+0] * 
exponent;
-                                               color[1] = buf_p[j*4+1] * 
exponent;
-                                               color[2] = buf_p[j*4+2] * 
exponent;
+                                       color[0] = buf_p[j*4+0] * exponent;
+                                       color[1] = buf_p[j*4+1] * exponent;
+                                       color[2] = buf_p[j*4+2] * exponent;
 #else // HDRFILE_FLOAT
-                                               memcpy(color, &buf_p[j*12], 12);
+                                       memcpy(color, &buf_p[j*12], 12);
 
-                                               color[0] = 
LittleFloat(color[0]);
-                                               color[1] = 
LittleFloat(color[1]);
-                                               color[2] = 
LittleFloat(color[2]);
+                                       color[0] = LittleFloat(color[0]);
+                                       color[1] = LittleFloat(color[1]);
+                                       color[2] = LittleFloat(color[2]);
 #endif
-                                       }
-                                       else
-                                       {
-                                               //hack: convert LDR lightmap to 
HDR one
-                                               color[0] = (buf_p[j*3+0] + 
1.0f);
-                                               color[1] = (buf_p[j*3+1] + 
1.0f);
-                                               color[2] = (buf_p[j*3+2] + 
1.0f);
-
-                                               // if under an arbitrary value 
(say 12) grey it out
-                                               // this prevents weird 
splotches in dimly lit areas
-                                               if (color[0] + color[1] + 
color[2] < 12.0f)
-                                               {
-                                                       float avg = (color[0] + 
color[1] + color[2]) * 0.3333f;
-                                                       color[0] = avg;
-                                                       color[1] = avg;
-                                                       color[2] = avg;
-                                               }
-                                       }
+                                       color[3] = 1.0f;
 
-                                       VectorScale(color, lightScale, color);
+                                       R_ColorShiftLightingFloats(color, 
color, 1.0f/255.0f);
 
                                        if (glRefConfig.textureFloat && 
glRefConfig.halfFloatPixel && r_floatLightmap->integer)
                                                ColorToRGBA16F(color, (unsigned 
short *)(&image[j*8]));
                                        else
                                                ColorToRGBM(color, &image[j*4]);
                                }
+                               else if (glRefConfig.textureFloat && 
glRefConfig.halfFloatPixel && r_floatLightmap->integer) 
+                               {
+                                       vec4_t color;
+
+                                       //hack: convert LDR lightmap to HDR one
+                                       color[0] = MAX(buf_p[j*3+0], 0.499f);
+                                       color[1] = MAX(buf_p[j*3+1], 0.499f);
+                                       color[2] = MAX(buf_p[j*3+2], 0.499f);
+
+                                       // if under an arbitrary value (say 12) 
grey it out
+                                       // this prevents weird splotches in 
dimly lit areas
+                                       if (color[0] + color[1] + color[2] < 
12.0f)
+                                       {
+                                               float avg = (color[0] + 
color[1] + color[2]) * 0.3333f;
+                                               color[0] = avg;
+                                               color[1] = avg;
+                                               color[2] = avg;
+                                       }
+                                       color[3] = 1.0f;
+
+                                       R_ColorShiftLightingFloats(color, 
color, 1.0f/255.0f);
+
+                                       ColorToRGBA16F(color, (unsigned short 
*)(&image[j*8]));
+                               }
                                else
                                {
                                        if ( r_lightmap->integer == 2 )
@@ -782,9 +783,9 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, 
float *hdrVertColors,
                        //hack: convert LDR vertex colors to HDR
                        if (r_hdr->integer)
                        {
-                               color[0] = verts[i].color[0] + 1.0f;
-                               color[1] = verts[i].color[1] + 1.0f;
-                               color[2] = verts[i].color[2] + 1.0f;
+                               color[0] = MAX(verts[i].color[0], 0.499f);
+                               color[1] = MAX(verts[i].color[1], 0.499f);
+                               color[2] = MAX(verts[i].color[2], 0.499f);
                        }
                        else
                        {
@@ -926,9 +927,9 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, 
float *hdrVertColors,
                        //hack: convert LDR vertex colors to HDR
                        if (r_hdr->integer)
                        {
-                               color[0] = verts[i].color[0] + 1.0f;
-                               color[1] = verts[i].color[1] + 1.0f;
-                               color[2] = verts[i].color[2] + 1.0f;
+                               color[0] = MAX(verts[i].color[0], 0.499f);
+                               color[1] = MAX(verts[i].color[1], 0.499f);
+                               color[2] = MAX(verts[i].color[2], 0.499f);
                        }
                        else
                        {
@@ -1026,9 +1027,9 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t 
*verts, float *hdrVertColor
                        //hack: convert LDR vertex colors to HDR
                        if (r_hdr->integer)
                        {
-                               color[0] = verts[i].color[0] + 1.0f;
-                               color[1] = verts[i].color[1] + 1.0f;
-                               color[2] = verts[i].color[2] + 1.0f;
+                               color[0] = MAX(verts[i].color[0], 0.499f);
+                               color[1] = MAX(verts[i].color[1], 0.499f);
+                               color[2] = MAX(verts[i].color[2], 0.499f);
                        }
                        else
                        {
diff --git a/SP/code/rend2/tr_init.c b/SP/code/rend2/tr_init.c
index 490d89f..7182ddd 100644
--- a/SP/code/rend2/tr_init.c
+++ b/SP/code/rend2/tr_init.c
@@ -1305,7 +1305,7 @@ void R_Register( void ) {
        r_softOverbright = ri.Cvar_Get( "r_softOverbright", "1", CVAR_ARCHIVE | 
CVAR_LATCH );
 
        r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH );
-       r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "1", CVAR_ARCHIVE | 
CVAR_LATCH );
+       r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
        r_postProcess = ri.Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE );
 
        r_toneMap = ri.Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH );

-- 
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