VERTEX
varying vec4 fres;
varying float z;

void main()
{
	vec3 normal;
	vec4 lightDir;
	float NdotL;
	
	vec4 v=gl_Vertex;
	gl_Position=ftransform(); 

	
	normal = normalize(gl_NormalMatrix * gl_Normal);

	lightDir = gl_ModelViewMatrix * gl_Vertex ;
	z = lightDir.z;
	lightDir.z-=10.0;
	lightDir = -normalize(lightDir);
	NdotL = max(dot(normal, vec3(lightDir.x,lightDir.y,lightDir.z)), 0.0);
	float f = max(gl_FrontMaterial.specular.b - (NdotL * gl_FrontMaterial.specular.g +  gl_FrontMaterial.specular.r),0.0);
	fres= vec4(f,f,f,0.0);
	gl_FrontColor =  gl_Color;
	
	gl_TexCoord[0] = gl_MultiTexCoord0;

}
PIXEL
uniform sampler2D tex,tex1;
varying vec4 fres;
varying float z;

void main()
{
	gl_FragColor =  gl_Color * texture2D(tex,gl_TexCoord[0].st) ;
	gl_FragColor += fres;
	float fogRange = abs(gl_Fog.end - gl_Fog.start);
	if(fogRange>0.0){
		float fog = clamp((abs(z) - gl_Fog.start)/fogRange,0.0,1.0);
		fog *= gl_Fog.density;
		gl_FragColor = (1.0-fog)* gl_FragColor + fog * gl_Fog.color;
	}
}
