Update
I got it working but the lighting is moving on me... I think it has to do with what space I am not in....
normal = ComputeNormalSobelFilter(TexCoord.st, heightTexture);
normal = normalize(gl_NormalMatrix * normal);
lightDir = normalize(vec3(gl_LightSource[1].position));
I am trying to do directional lighting, and not having any luck... gl_NormalMatrix takes the normal into eye space correct?
So I am guessing I need the lightDir in eye space also? If so how can I do that?
Thanks!
VTF for Terrain and need to calculate the normals
gl_NormalMatrix takes the normal into eye space correct?"VTF for Terrain and need to calculate the normals" is a strange title for a thread that's asking "how to convert light directions from world-space to eye-space"
So I am guessing I need the lightDir in eye space also? If so how can I do that?
gl_NormalMatrix is just the 3x3 part of your view matrix.
On the CPU, you can:
* multiply your world-space direction with the 3x3 part of your view matrix
or
* copy your world-space direction into a 4D vector with a w value of 0.0f, and multiply that with your 4x4 view matrix
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement