Jump to content
• Advertisement

# Tangent Calculations for normal mapping(Terathon software tutorial)

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

Hi, i have looked at an tutorial at Terathon software which describe and implements a tangent vektor calculations. I also read this tutorial which describe how to get a normal from a normalmap. Anyway in the second tutorial they calculate the binormal by "the cross product of the tangent and the normal" which sounds fine to me. But in the Terathon software tutorial they also save a "handedness" component in the tangent vector(which is a 4 component vector) and i wonder what is that component for?

#### Share this post

##### Share on other sites
Advertisement
Well, becouse sometimes you may not want the binormal to face in the direction the cross product gives you, but in the opposite :) So then you multiply the result of the cross product with the 4 component (1 or -1) to keep it the same or flip directions. This has to be there, becouse sometimes the UVs of the model are such that the cross product gives the result you dont want. Imagine this: two quads, sharing an edge with the according UVs at the vertexes.
---------------------------------|(0;0)     (1;0)|          (0;0)||               |               || ---------->   |   <--------   || |             |           |   || |             |           |   || |             |           |   || |             |           |   || ^             |           ^   ||               |               ||(0;1)     (1;1)|          (0;1)|---------------------------------

Now, the normals of these quads should point out of the screen. The horizontal arrows indicate the tangent vectors of both faces. The vertical - the correct binormals or bitangents, as some call them. Now, if you just took the cross products of the normal & the tangent for both faces, one of them would be pointing in the right direction, but the other in the opposite, becouse the normals are the same, but the tangents opposite. Look into a further description of the cross product, if you dont understand why this happens. Thats why you need to set the 4 normal or tangent, depends on where you want to store it, component to -1 for those binormals that need inverting, and to 1 for those that dont.

I hope I make sense :P

#### Share this post

##### Share on other sites
If the artist uses texture mirroring ( ie storing half of a character's face ), then you will have several mesh triangles with the same uv triangle, only flipped upside down in uv space.

This handedness factor can adjust for that.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5
• Advertisement

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633725
• Total Posts
3013567
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!