Tangent space calculation
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?
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement