Jump to content
  • Advertisement
Sign in to follow this  
Relfos

Tangent space calculation

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

I'm implementing tangent space calculation using the code from http://www.terathon.com/code/tangent.html However, for example, when applying the function to a cube, every tangent vector is (0,0,0). I found that this is because of this line tangent[a] = (t - n * Dot(n, t)).Normalize(); The tangent vector is perpendicular to the normal vector, and the dot product of both is zero, this nullifies all tangents in the mesh. Also for more complex meshes this also happens (but only for some triangles). Help?

Share this post


Link to post
Share on other sites
Advertisement
Quote:

tangent[a] = (t - n * Dot(n, t)).Normalize();

The tangent vector is perpendicular to the normal vector, and the dot product of both is zero, this nullifies all tangents in the mesh.


Are you sure? If n and t are orthogonal then (n * Dot(n, t)) is 0, and you get:

(t - 0).Normalize() = t.Normalize() which should not be 0 unless t was 0 to begin with (which would be a bug somewhere else).


All that code does is orthogonalize n and t in case they aren't already orthogonal.

Share this post


Link to post
Share on other sites
Ahh, thank you, I found the problem thanks to you.
I was messing up the order of the operations, doing the subtraction before the dot product!

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.

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!