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 417640ac13936d2b73eb4ab64b7559cee3c4aa8c
Author: zturtle...@gmail.com 
<zturtle...@gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date:   Fri Aug 29 23:21:54 2014 +0000

    Rend2: Add support for wolf fog to shaders that use adjustColorsForFog
---
 MP/code/rend2/glsl/generic_vp.glsl | 10 ++++--
 MP/code/rend2/tr_glsl.c            | 19 +++++++++-
 MP/code/rend2/tr_local.h           |  8 +++--
 MP/code/rend2/tr_shade.c           | 72 ++++++++++++++++++++++++--------------
 SP/code/rend2/glsl/generic_vp.glsl | 10 ++++--
 SP/code/rend2/tr_glsl.c            | 19 +++++++++-
 SP/code/rend2/tr_local.h           |  8 +++--
 SP/code/rend2/tr_shade.c           | 72 ++++++++++++++++++++++++--------------
 8 files changed, 152 insertions(+), 66 deletions(-)

diff --git a/MP/code/rend2/glsl/generic_vp.glsl 
b/MP/code/rend2/glsl/generic_vp.glsl
index 8543ffd..60f6c99 100644
--- a/MP/code/rend2/glsl/generic_vp.glsl
+++ b/MP/code/rend2/glsl/generic_vp.glsl
@@ -189,7 +189,12 @@ vec4 CalcColor(vec3 position, vec3 normal)
 #if defined(USE_FOG)
 float CalcFog(vec3 position)
 {
-       float s = dot(vec4(position, 1.0), u_FogDistance) * 8.0;
+       float s = dot(vec4(position, 1.0), u_FogDistance);
+#if defined(USE_WOLF_FOG_LINEAR)
+       return 1.0 - (u_FogDepth.y - s) / (u_FogDepth.y - u_FogDepth.x);
+#elif defined(USE_WOLF_FOG_EXPONENTIAL)
+       return 1.0 - exp(-u_FogDepth.z * s);
+#else // defined(USE_QUAKE3_FOG)
        float t = dot(vec4(position, 1.0), u_FogDepth);
 
        float eyeOutside = float(u_FogEyeT < 0.0);
@@ -198,7 +203,8 @@ float CalcFog(vec3 position)
        t += 1e-6;
        t *= fogged / (t - u_FogEyeT * eyeOutside);
 
-       return s * t;
+       return s * 8.0 * t;
+#endif
 }
 #endif
 
diff --git a/MP/code/rend2/tr_glsl.c b/MP/code/rend2/tr_glsl.c
index ba75215..5f9d3ce 100644
--- a/MP/code/rend2/tr_glsl.c
+++ b/MP/code/rend2/tr_glsl.c
@@ -926,6 +926,12 @@ void GLSL_InitGPUShaders(void)
                if (i & GENERICDEF_USE_LIGHTMAP)
                        Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n");
 
+               if (i & GENERICDEF_USE_WOLF_FOG_LINEAR)
+                       Q_strcat(extradefines, 1024, "#define 
USE_WOLF_FOG_LINEAR\n");
+               
+               if (i & GENERICDEF_USE_WOLF_FOG_EXPONENTIAL)
+                       Q_strcat(extradefines, 1024, "#define 
USE_WOLF_FOG_EXPONENTIAL\n");
+
                if (r_hdr->integer && !glRefConfig.floatLightmap)
                        Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n");
 
@@ -1775,7 +1781,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits)
 }
 
 
-shaderProgram_t *GLSL_GetGenericShaderProgram(int stage)
+shaderProgram_t *GLSL_GetGenericShaderProgram(int stage, glfog_t *glFog)
 {
        shaderStage_t *pStage = tess.xstages[stage];
        int shaderAttribs = 0;
@@ -1785,6 +1791,17 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage)
                shaderAttribs |= GENERICDEF_USE_FOG;
        }
 
+       //
+       // RTCW fog
+       //
+       if (glFog) {
+               shaderAttribs |= GENERICDEF_USE_FOG;
+               if (glFog->mode == GL_LINEAR)
+                       shaderAttribs |= GENERICDEF_USE_WOLF_FOG_LINEAR;
+               else // if (glFog->mode == GL_EXP)
+                       shaderAttribs |= GENERICDEF_USE_WOLF_FOG_EXPONENTIAL;
+       }
+
        if (pStage->bundle[1].image[0] && tess.shader->multitextureEnv)
        {
                shaderAttribs |= GENERICDEF_USE_LIGHTMAP;
diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h
index 6b3cf59..84229a0 100644
--- a/MP/code/rend2/tr_local.h
+++ b/MP/code/rend2/tr_local.h
@@ -655,8 +655,10 @@ enum
        GENERICDEF_USE_FOG              = 0x0008,
        GENERICDEF_USE_RGBAGEN          = 0x0010,
        GENERICDEF_USE_LIGHTMAP         = 0x0020,
-       GENERICDEF_ALL                  = 0x003F,
-       GENERICDEF_COUNT                = 0x0040,
+       GENERICDEF_USE_WOLF_FOG_LINEAR      = 0x0040,
+       GENERICDEF_USE_WOLF_FOG_EXPONENTIAL = 0x0080,
+       GENERICDEF_ALL                  = 0x00FF,
+       GENERICDEF_COUNT                = 0x0100,
 };
 
 enum
@@ -2478,7 +2480,7 @@ void GLSL_SetUniformVec3(shaderProgram_t *program, int 
uniformNum, const vec3_t
 void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const 
vec4_t v);
 void GLSL_SetUniformMat4(shaderProgram_t *program, int uniformNum, const 
mat4_t matrix);
 
-shaderProgram_t *GLSL_GetGenericShaderProgram(int stage);
+shaderProgram_t *GLSL_GetGenericShaderProgram(int stage, glfog_t *glFog);
 
 /*
 ============================================================
diff --git a/MP/code/rend2/tr_shade.c b/MP/code/rend2/tr_shade.c
index ad8ad92..f5a6718 100644
--- a/MP/code/rend2/tr_shade.c
+++ b/MP/code/rend2/tr_shade.c
@@ -1153,6 +1153,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
 {
        int stage;
        
+       glfog_t *glFog;
        vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0};
        float eyeT = 0;
 
@@ -1161,8 +1162,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
 
        ComputeDeformValues(&deformGen, deformParams);
 
-       ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT, NULL);
-
        for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ )
        {
                shaderStage_t *pStage = input->xstages[stage];
@@ -1175,6 +1174,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
                        break;
                }
 
+               glFog = NULL;
+
                if (backEnd.depthFill)
                {
                        if (pStage->glslShaderGroup == tr.lightallShader)
@@ -1240,7 +1241,28 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
                }
                else
                {
-                       sp = GLSL_GetGenericShaderProgram(stage);
+                       if ( r_wolffog->integer && pStage->adjustColorsForFog 
&& !backEnd.projection2D )
+                       {
+                               if ( !tess.shader->noFog || pStage->isFogged ) {
+                                       if ( backEnd.refdef.rdflags & 
RDF_DRAWINGSKY ) {
+                                               if ( 
glfogsettings[FOG_SKY].registered ) {
+                                                       glFog = 
&glfogsettings[FOG_SKY];
+                                               }
+                                       }
+
+                                       if ( skyboxportal && 
backEnd.refdef.rdflags & RDF_SKYBOXPORTAL ) {
+                                               if ( 
glfogsettings[FOG_PORTALVIEW].registered ) {
+                                                       glFog = 
&glfogsettings[FOG_PORTALVIEW];
+                                               }
+                                       } else {
+                                               if ( glfogNum > FOG_NONE ) {
+                                                       glFog = 
&glfogsettings[FOG_CURRENT];
+                                               }
+                                       }
+                               }
+                       }
+
+                       sp = GLSL_GetGenericShaderProgram(stage, glFog);
 
                        backEnd.pc.c_genericDraws++;
                }
@@ -1260,7 +1282,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
                        GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime);
                }
 
-               if ( input->fogNum ) {
+               if ( input->fogNum || glFog ) {
+                       ComputeFogValues(fogDistanceVector, fogDepthVector, 
&eyeT, glFog);
+
                        GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, 
fogDistanceVector);
                        GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, 
fogDepthVector);
                        GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT);
@@ -1326,7 +1350,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
                GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, pStage->rgbGen);
                GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, pStage->alphaGen);
 
-               if ( input->fogNum )
+               if ( input->fogNum || glFog )
                {
                        vec4_t fogColorMask;
 
@@ -1732,33 +1756,27 @@ void RB_StageIteratorGeneric( void )
        if ( r_wolffog->integer && tess.shader->fogPass && tess.shader->sort <= 
SS_OPAQUE )
        {
                int stage, stageFog = 0;
-               
-               // make sure at least one stage has fog
-               for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ )
-               {
-                       shaderStage_t *pStage = tess.xstages[stage];
 
-                       if ( !pStage )
+               if ( tess.shader->noFog ) {
+                       // make sure at least one stage has fog
+                       for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ )
                        {
-                               break;
-                       }
+                               shaderStage_t *pStage = tess.xstages[stage];
 
-                       if (pStage->isFogged)
-                       {
-                               stageFog = 1;
-                               break;
+                               if ( !pStage )
+                               {
+                                       break;
+                               }
+
+                               if (pStage->isFogged)
+                               {
+                                       stageFog = 1;
+                                       break;
+                               }
                        }
                }
-               
-               // FIXME: this logic sucks
-               if (tess.shader->noFog && stageFog)
-               {
-                       RB_FogPass(1);
-               }
-               else if (tess.shader->noFog && !stageFog)
-               {
-               }
-               else
+
+               if ( !tess.shader->noFog || stageFog )
                {
                        RB_FogPass(1);
                }
diff --git a/SP/code/rend2/glsl/generic_vp.glsl 
b/SP/code/rend2/glsl/generic_vp.glsl
index 8543ffd..60f6c99 100644
--- a/SP/code/rend2/glsl/generic_vp.glsl
+++ b/SP/code/rend2/glsl/generic_vp.glsl
@@ -189,7 +189,12 @@ vec4 CalcColor(vec3 position, vec3 normal)
 #if defined(USE_FOG)
 float CalcFog(vec3 position)
 {
-       float s = dot(vec4(position, 1.0), u_FogDistance) * 8.0;
+       float s = dot(vec4(position, 1.0), u_FogDistance);
+#if defined(USE_WOLF_FOG_LINEAR)
+       return 1.0 - (u_FogDepth.y - s) / (u_FogDepth.y - u_FogDepth.x);
+#elif defined(USE_WOLF_FOG_EXPONENTIAL)
+       return 1.0 - exp(-u_FogDepth.z * s);
+#else // defined(USE_QUAKE3_FOG)
        float t = dot(vec4(position, 1.0), u_FogDepth);
 
        float eyeOutside = float(u_FogEyeT < 0.0);
@@ -198,7 +203,8 @@ float CalcFog(vec3 position)
        t += 1e-6;
        t *= fogged / (t - u_FogEyeT * eyeOutside);
 
-       return s * t;
+       return s * 8.0 * t;
+#endif
 }
 #endif
 
diff --git a/SP/code/rend2/tr_glsl.c b/SP/code/rend2/tr_glsl.c
index ba75215..5f9d3ce 100644
--- a/SP/code/rend2/tr_glsl.c
+++ b/SP/code/rend2/tr_glsl.c
@@ -926,6 +926,12 @@ void GLSL_InitGPUShaders(void)
                if (i & GENERICDEF_USE_LIGHTMAP)
                        Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n");
 
+               if (i & GENERICDEF_USE_WOLF_FOG_LINEAR)
+                       Q_strcat(extradefines, 1024, "#define 
USE_WOLF_FOG_LINEAR\n");
+               
+               if (i & GENERICDEF_USE_WOLF_FOG_EXPONENTIAL)
+                       Q_strcat(extradefines, 1024, "#define 
USE_WOLF_FOG_EXPONENTIAL\n");
+
                if (r_hdr->integer && !glRefConfig.floatLightmap)
                        Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n");
 
@@ -1775,7 +1781,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits)
 }
 
 
-shaderProgram_t *GLSL_GetGenericShaderProgram(int stage)
+shaderProgram_t *GLSL_GetGenericShaderProgram(int stage, glfog_t *glFog)
 {
        shaderStage_t *pStage = tess.xstages[stage];
        int shaderAttribs = 0;
@@ -1785,6 +1791,17 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage)
                shaderAttribs |= GENERICDEF_USE_FOG;
        }
 
+       //
+       // RTCW fog
+       //
+       if (glFog) {
+               shaderAttribs |= GENERICDEF_USE_FOG;
+               if (glFog->mode == GL_LINEAR)
+                       shaderAttribs |= GENERICDEF_USE_WOLF_FOG_LINEAR;
+               else // if (glFog->mode == GL_EXP)
+                       shaderAttribs |= GENERICDEF_USE_WOLF_FOG_EXPONENTIAL;
+       }
+
        if (pStage->bundle[1].image[0] && tess.shader->multitextureEnv)
        {
                shaderAttribs |= GENERICDEF_USE_LIGHTMAP;
diff --git a/SP/code/rend2/tr_local.h b/SP/code/rend2/tr_local.h
index 1bf8958..2d75320 100644
--- a/SP/code/rend2/tr_local.h
+++ b/SP/code/rend2/tr_local.h
@@ -660,8 +660,10 @@ enum
        GENERICDEF_USE_FOG              = 0x0008,
        GENERICDEF_USE_RGBAGEN          = 0x0010,
        GENERICDEF_USE_LIGHTMAP         = 0x0020,
-       GENERICDEF_ALL                  = 0x003F,
-       GENERICDEF_COUNT                = 0x0040,
+       GENERICDEF_USE_WOLF_FOG_LINEAR      = 0x0040,
+       GENERICDEF_USE_WOLF_FOG_EXPONENTIAL = 0x0080,
+       GENERICDEF_ALL                  = 0x00FF,
+       GENERICDEF_COUNT                = 0x0100,
 };
 
 enum
@@ -2506,7 +2508,7 @@ void GLSL_SetUniformVec3(shaderProgram_t *program, int 
uniformNum, const vec3_t
 void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const 
vec4_t v);
 void GLSL_SetUniformMat4(shaderProgram_t *program, int uniformNum, const 
mat4_t matrix);
 
-shaderProgram_t *GLSL_GetGenericShaderProgram(int stage);
+shaderProgram_t *GLSL_GetGenericShaderProgram(int stage, glfog_t *glFog);
 
 /*
 ============================================================
diff --git a/SP/code/rend2/tr_shade.c b/SP/code/rend2/tr_shade.c
index 44bcdf3..b1f8ed3 100644
--- a/SP/code/rend2/tr_shade.c
+++ b/SP/code/rend2/tr_shade.c
@@ -1147,6 +1147,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
 {
        int stage;
        
+       glfog_t *glFog;
        vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0};
        float eyeT = 0;
 
@@ -1155,8 +1156,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
 
        ComputeDeformValues(&deformGen, deformParams);
 
-       ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT, NULL);
-
        for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ )
        {
                shaderStage_t *pStage = input->xstages[stage];
@@ -1169,6 +1168,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
                        break;
                }
 
+               glFog = NULL;
+
                if (backEnd.depthFill)
                {
                        if (pStage->glslShaderGroup == tr.lightallShader)
@@ -1234,7 +1235,28 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
                }
                else
                {
-                       sp = GLSL_GetGenericShaderProgram(stage);
+                       if ( r_wolffog->integer && pStage->adjustColorsForFog 
&& !backEnd.projection2D )
+                       {
+                               if ( !tess.shader->noFog || pStage->isFogged ) {
+                                       if ( backEnd.refdef.rdflags & 
RDF_DRAWINGSKY ) {
+                                               if ( 
glfogsettings[FOG_SKY].registered ) {
+                                                       glFog = 
&glfogsettings[FOG_SKY];
+                                               }
+                                       }
+
+                                       if ( skyboxportal && 
backEnd.refdef.rdflags & RDF_SKYBOXPORTAL ) {
+                                               if ( 
glfogsettings[FOG_PORTALVIEW].registered ) {
+                                                       glFog = 
&glfogsettings[FOG_PORTALVIEW];
+                                               }
+                                       } else {
+                                               if ( glfogNum > FOG_NONE ) {
+                                                       glFog = 
&glfogsettings[FOG_CURRENT];
+                                               }
+                                       }
+                               }
+                       }
+
+                       sp = GLSL_GetGenericShaderProgram(stage, glFog);
 
                        backEnd.pc.c_genericDraws++;
                }
@@ -1254,7 +1276,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
                        GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime);
                }
 
-               if ( input->fogNum ) {
+               if ( input->fogNum || glFog ) {
+                       ComputeFogValues(fogDistanceVector, fogDepthVector, 
&eyeT, glFog);
+
                        GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, 
fogDistanceVector);
                        GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, 
fogDepthVector);
                        GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT);
@@ -1320,7 +1344,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t 
*input )
                GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, pStage->rgbGen);
                GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, pStage->alphaGen);
 
-               if ( input->fogNum )
+               if ( input->fogNum || glFog )
                {
                        vec4_t fogColorMask;
 
@@ -1733,33 +1757,27 @@ void RB_StageIteratorGeneric( void )
        if ( r_wolffog->integer && tess.shader->fogPass && tess.shader->sort <= 
SS_OPAQUE )
        {
                int stage, stageFog = 0;
-               
-               // make sure at least one stage has fog
-               for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ )
-               {
-                       shaderStage_t *pStage = tess.xstages[stage];
 
-                       if ( !pStage )
+               if ( tess.shader->noFog ) {
+                       // make sure at least one stage has fog
+                       for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ )
                        {
-                               break;
-                       }
+                               shaderStage_t *pStage = tess.xstages[stage];
 
-                       if (pStage->isFogged)
-                       {
-                               stageFog = 1;
-                               break;
+                               if ( !pStage )
+                               {
+                                       break;
+                               }
+
+                               if (pStage->isFogged)
+                               {
+                                       stageFog = 1;
+                                       break;
+                               }
                        }
                }
-               
-               // FIXME: this logic sucks
-               if (tess.shader->noFog && stageFog)
-               {
-                       RB_FogPass(1);
-               }
-               else if (tess.shader->noFog && !stageFog)
-               {
-               }
-               else
+
+               if ( !tess.shader->noFog || stageFog )
                {
                        RB_FogPass(1);
                }

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