]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
changed where vertex coloring is applied in the fragment shader, this fixes problems...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 16 Apr 2006 11:36:20 +0000 (11:36 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 16 Apr 2006 11:36:20 +0000 (11:36 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6296 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c

index 8ef94c4821080fe2e296a663d27df1f4a233c9a8..4c58d0d2a819d5583fb5e6c68d85fc6b5135e6d0 100644 (file)
@@ -420,6 +420,9 @@ static const char *builtinshaderstring =
 "varying vec3 CubeVector;\n"
 "varying vec3 LightVector;\n"
 "varying vec3 EyeVector;\n"
+"#ifdef USEFOG\n"
+"varying vec3 EyeVectorModelSpace;\n"
+"#endif\n"
 "\n"
 "varying vec3 VectorS; // direction of S texcoord (sometimes crudely called tangent)\n"
 "varying vec3 VectorT; // direction of T texcoord (sometimes crudely called binormal)\n"
@@ -467,10 +470,13 @@ static const char *builtinshaderstring =
 "#endif\n"
 "\n"
 "      // transform unnormalized eye direction into tangent space\n"
-"      vec3 eyeminusvertex = EyePosition - gl_Vertex.xyz;\n"
-"      EyeVector.x = dot(eyeminusvertex, gl_MultiTexCoord1.xyz);\n"
-"      EyeVector.y = dot(eyeminusvertex, gl_MultiTexCoord2.xyz);\n"
-"      EyeVector.z = dot(eyeminusvertex, gl_MultiTexCoord3.xyz);\n"
+"#ifndef USEFOG\n"
+"      vec3 EyeVectorModelSpace;\n"
+"#endif\n"
+"      EyeVectorModelSpace = EyePosition - gl_Vertex.xyz;\n"
+"      EyeVector.x = dot(EyeVectorModelSpace, gl_MultiTexCoord1.xyz);\n"
+"      EyeVector.y = dot(EyeVectorModelSpace, gl_MultiTexCoord2.xyz);\n"
+"      EyeVector.z = dot(EyeVectorModelSpace, gl_MultiTexCoord3.xyz);\n"
 "\n"
 "#ifdef MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
 "      VectorS = gl_MultiTexCoord1.xyz;\n"
@@ -667,17 +673,19 @@ static const char *builtinshaderstring =
 "      color.rgb *= vec3(texture2D(Texture_Lightmap, TexCoordLightmap)) * DiffuseScale + vec3(AmbientScale);\n"
 "#endif // MODE\n"
 "\n"
+"      color *= gl_Color;\n"
+"\n"
 "#ifdef USEGLOW\n"
 "      color.rgb += vec3(texture2D(Texture_Glow, TexCoord));\n"
 "#endif\n"
 "\n"
 "#ifdef USEFOG\n"
 "      // apply fog\n"
-"      float fog = texture2D(Texture_FogMask, vec2(length(EyeVector)*FogRangeRecip, 0.0)).x;\n"
+"      float fog = texture2D(Texture_FogMask, vec2(length(EyeVectorModelSpace)*FogRangeRecip, 0.0)).x;\n"
 "      color.rgb = color.rgb * fog + FogColor * (1.0 - fog);\n"
 "#endif\n"
 "\n"
-"      gl_FragColor = color * gl_Color;\n"
+"      gl_FragColor = color;\n"
 "}\n"
 "\n"
 "#endif // FRAGMENT_SHADER\n"