# VTF for Terrain and need to calculate the normals

This topic is 2648 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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!

Bump???

##### Share on other sites
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?
"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"

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

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 12
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633313
• Total Posts
3011322
• ### Who's Online (See full list)

There are no registered users currently online

×