varying vec2 TexCoord0;
varying vec3 LightDir, HalfVec, n;

uniform sampler2D NormalsAndSpecularMap;

void main()
{
	vec4 NormalAndSpecular = texture2D(NormalsAndSpecularMap, TexCoord0);
	vec3 Normal = normalize((NormalAndSpecular.xyz - 0.5) * 2.0);

	float NdotHV = max(0.0, dot(Normal, normalize(HalfVec)));
    float Specular = pow(NdotHV, 16.0);

	gl_FragColor = vec4(max(0.4, dot(normalize(LightDir), Normal)) + vec4(Specular) * NormalAndSpecular.a);
	gl_FragColor.a *= 0.9;
}
