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