From ca2ad226a5261a26d250697d91712bb648cb184b Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 16 Apr 2006 11:36:20 +0000 Subject: [PATCH] changed where vertex coloring is applied in the fragment shader, this fixes problems with vertex colored surfaces (note: does not help deluxemapping mode, there is another bug affecting that) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6296 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 8ef94c48..4c58d0d2 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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" -- 2.39.2