Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

VTF for Terrain and need to calculate the normals

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

If you intended to correct an error in the post then please contact us.

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!

Share this post


Link to post
Share on other sites
Advertisement
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" tongue.gif

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!