I want to use a point light calculated in GLSL. I works fine, but if I calculate it per pixel it still looks the same as the Vertex based calculation.
My Vertex Code:
uniform vec3 LightPos;
varying vec2 UVCoord;
varying vec3 Normal;
varying vec3 posToLight;
void main()
{
UVCoord = gl_MultiTexCoord0.st;
gl_Position = ftransform();
Normal = normalize(gl_NormalMatrix * gl_Normal);
vec3 pos = vec3(gl_ModelViewMatrix * gl_Vertex);
posToLight = normalize(LightPos - pos);
}
My Fragment Code:
uniform sampler2D tex1;
varying vec2 UVCoord;
varying vec3 Normal;
varying vec3 posToLight;
void main()
{
vec3 Color = vec3(texture2D(tex1, UVCoord));
float LightIntensity = pow(max(dot(posToLight, Normal), 0.0), 10.0);
gl_FragColor = vec4(Color * (LightIntensity), 1.0);
}
Does anybody have an idea what I am doing wrong?