# Simple Tangent Space Normal question

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

## 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 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 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 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.

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
16
5. 5

• 9
• 33
• 13
• 12
• 10
• ### Forum Statistics

• Total Topics
632579
• Total Posts
3007165

×