Sign in to follow this  

Simple Tangent Space Normal question

This topic is 3853 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

This is an easy one i think. I have terrain made by a heightmap. This heightmap is passed to D3DXComputeNormalMap. That gives me this. This is a tangent space normal. The terrain plane is basically a plane with (0, 1, 0, 0). Or a plane at the origin with an normal of (0, 1, 0). How do i transform the light direction in my shader to make it work with this normal map?

Share this post


Link to post
Share on other sites
There are a significant number of articles (try google!) detailing exactly how tangent-space normal mapping works, but here's the basic idea:

Your normal map contains normal vectors, in tangent space. Your geometry/lights are specified in object space (or world space, whatever). You construct a matrix such that when you transform your light vectors and such by it, it takes them from object space into tangent space, where you can perform calculations with the normal vectors from your normal map.

Share this post


Link to post
Share on other sites
theres actually a good amount of clutter on the subject but anyways if the plane is the ground your tangent is (1, 0, 0), bitangent is (0, 0, 1) in left handed and normal is (0, 1, 0) so your TBNMatrix is (XAxis, ZAxis, YAxis), this works however the math of making a matrice with the axis's in this order is kinda weird when you consider how you build your view matrice(XAxis, YAxis, ZAxis)

Share this post


Link to post
Share on other sites
this has nothing to do with tangent space. there is no transformation necessary to compute the lighting. just read the normal from the texture(watch out to not mess up y/z, your map looks like z is up, but y is up in your world space) and do a dot product with your light vector. that will work for directional lights.

Share this post


Link to post
Share on other sites

This topic is 3853 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.

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