Fabian Bieler : wined3d: Remove fog coordinate clamping in the vertex shader.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Mar 23 08:36:22 CDT 2007


Module: wine
Branch: master
Commit: 878e02538e1c2fef0bda00e42b86245685a387aa
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=878e02538e1c2fef0bda00e42b86245685a387aa

Author: Fabian Bieler <der.fabe at gmx.net>
Date:   Thu Mar 22 17:34:57 2007 +0100

wined3d: Remove fog coordinate clamping in the vertex shader.

---

 dlls/wined3d/arb_program_shader.c |    2 +-
 dlls/wined3d/vertexshader.c       |   19 ++++++++-----------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index d24a5f9..bffc2a4 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -313,7 +313,7 @@ static void vshader_program_add_param(SHADER_OPCODE_ARG *arg, const DWORD param,
   IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) arg->shader;
 
   /* oPos, oFog and oPts in D3D */
-  static const char * const hwrastout_reg_names[] = { "TMP_OUT", "TMP_FOG", "result.pointsize" };
+  static const char * const hwrastout_reg_names[] = { "TMP_OUT", "result.fogcoord", "result.pointsize" };
 
   DWORD reg = param & WINED3DSP_REGNUM_MASK;
   DWORD regtype = shader_get_regtype(param);
diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c
index 5d3a506..22c49c2 100644
--- a/dlls/wined3d/vertexshader.c
+++ b/dlls/wined3d/vertexshader.c
@@ -336,11 +336,11 @@ static VOID IWineD3DVertexShaderImpl_GenerateShader(
         if (This->baseShader.hex_version >= WINED3DVS_VERSION(3,0))
             vshader_glsl_output_unpack(&buffer, This->semantics_out);
 
-        /* Clamp the fog from 0 to 1 if it's used */
-        if (reg_maps->fog) {
+        /* If this shader doesn't use fog copy the z coord to the fog coord so that we can use table fog */
+        if (reg_maps->fog)
             This->usesFog = 1;
-            shader_addline(&buffer, "gl_FogFragCoord = clamp(gl_FogFragCoord, 0.0, 1.0);\n");
-        }
+        else
+            shader_addline(&buffer, "gl_FogFragCoord = gl_Position.z;\n");
         
         /* Write the final position.
          *
@@ -382,17 +382,14 @@ static VOID IWineD3DVertexShaderImpl_GenerateShader(
         /* We need a constant to fixup the final position */
         shader_addline(&buffer, "PARAM posFixup = program.env[%d];\n", ARB_SHADER_PRIVCONST_POS);
 
-        if (reg_maps->fog) {
-            This->usesFog = 1;
-            shader_addline(&buffer, "TEMP TMP_FOG;\n");
-        }
-
         /* Base Shader Body */
         shader_generate_main( (IWineD3DBaseShader*) This, &buffer, reg_maps, pFunction);
 
-        /* Make sure the fog value is positive - values above 1.0 are ignored */
+        /* If this shader doesn't use fog copy the z coord to the fog coord so that we can use table fog */
         if (reg_maps->fog)
-            shader_addline(&buffer, "MAX result.fogcoord, TMP_FOG, 0.0;\n");
+            This->usesFog = 1;
+        else
+            shader_addline(&buffer, "MOV result.fogcoord, TMP_OUT.z;\n");
 
         /* Write the final position.
          *




More information about the wine-cvs mailing list