Ok, I changed the line to this in the vertex shader:
gl_FogFragCoord = gl_Position.z;
And the fragment shader looks like this now:
uniform sampler2D texture0;uniform sampler2D texture1;uniform sampler2D texture2; void main(){ float fog; vec4 color; vec4 alphacolor = texture2D(texture2, gl_TexCoord[0].st / 64.0); color = mix(texture2D(texture1,gl_TexCoord[0].st),texture2D(texture0,gl_TexCoord[0].st), alphacolor.r); fog = (gl_Fog.end - gl_FogFragCoord) * gl_Fog.scale; if (fog >= 0.0) gl_FragColor = mix(gl_Fog.color,color, fog); else gl_FragColor = gl_Fog.color;}
It works now! But you can see that I'm having to use a special case to detect whether or not fog > 0. Is that okay, or am I still doing something wrong?
Also, without using this shader on my terrain I'm getting 200 FPS, but with it I'm getting about 115 FPS. Is that normal?