Sign in to follow this  
MARS_999

VTF for Terrain and need to calculate the normals

Recommended Posts

MARS_999    1627
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
Hodgman    51335
[quote name='MARS_999' timestamp='1313278447' post='4848802']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?[/quote]"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" [img]http://public.gamedev.net/public/style_emoticons/default/tongue.gif[/img]

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this