tangents from normals

Started by
37 comments, last by Sneftel 17 years, 4 months ago
all the information ive found regarding tangents have always been calculating them from vertex and texture coordinates.. but wouldnt it be simpler to calculate the tangents from allrdy calculated normals? and if so how would u do that?
Advertisement
Calculating the normals is the first thing you do, but you need more than normals to calculate the tangents and bitangents. The thing is, for a given normal there are an infinite number of potential tangent/bitangent pairs. The normal way to decide what to use as the "real" tangent and bitangent is to put the tangent along the texture coordinates' X direction, and the bitangent as the cross product of the normal and the tangent. This isn't a hard and fast rule, though.
so basicly u can calculate the tangent as a normalized vector starting at the vertex and pointing towards the u coordinate? i find that a bit weird... shouldnt the tangent be perpendicular to the normal? does anyone please explain to me exactly what a tangent is... cuzz i get more confused the more i learn...
Quote:Original post by Dragon_Strike
so basicly u can calculate the tangent as a normalized vector starting at the vertex and pointing towards the u coordinate? i find that a bit weird... shouldnt the tangent be perpendicular to the normal?


Yeah. This is not a problem; since the normal is perpendicular to the surface (by definition), the tangent computed in this way will be perpendicular to the normal (since it's coplanar to the surface).
Orin Tresnjak | Graphics ProgrammerBethesda Game StudiosStandard Disclaimer: My posts represent my opinions and not those of Bethesda/Zenimax, etc.
well then it should be pretty easy to calculate the tangent... isnt it just to rotate the tangent by 90 degrees in the direction of the u texture coordinate?
I don't understand your question. You could calculate the bitangent from the tangent and normal by rotating about the normal 90 degrees from the tangent.

A similar solution would just be to calculate the cross product of the normalized vectors. This should be more efficient than a mat3 multiply (for a rotation) - if the vectors are normalized.
Quote:Original post by talas
I don't understand your question. You could calculate the bitangent from the tangent and normal by rotating about the normal 90 degrees from the tangent.

A similar solution would just be to calculate the cross product of the normalized vectors. This should be more efficient than a mat3 multiply (for a rotation) - if the vectors are normalized.


my question is how can u easily calculate the tangent from the normal
The tangent and bitangent (also called binormal) vectors that are most useful are those that align with the U and V texture directions. Without knowing U and V coordinates of a given vertex and its neighbors, you can't easily compute those vectors (note that the computation of these vectors, as already suggested, doesn't actually require use of the normal at all).

Trying to do something like "rotate the normal 90 degrees in the direction of the U texture coordinate" is pointless because if you can do it, you already have your answers. You'd have to know which axis to rotate the normal around -- it would be the axis form by the 'direction' of the V texture coordinate -- and if you have that axis, you already have the bitangent, and since you have two of the vectors, you can find the third with a cross product trivially. Not to mention the fact that what you mean by "direction" of the texture coordinate is the vector (in texcoord space) from the current vertex's U to an adajecent vertex's U, which is exactly the result you're looking for anyway.

If you just have the normal, you can find two other vectors that form an orthogonal basis with the normal, but they won't neccessarily be the aforemention most-useful tangent and bitangent. In fact, since there are an infinite number of tangent vectors, you're pretty much guaranteed they won't be the most-useful ones.

To put it simply, you can't simply find the tangent that you probably want from just the normal. Computing them from texture coordinates of the current vertex and neighboring vertices is the way you want to go.
Quote:Original post by jpetrie
The tangent and bitangent (also called binormal) vectors that are most useful are those that align with the U and V texture directions. Without knowing U and V coordinates of a given vertex and its neighbors, you can't easily compute those vectors (note that the computation of these vectors, as already suggested, doesn't actually require use of the normal at all).

Trying to do something like "rotate the normal 90 degrees in the direction of the U texture coordinate" is pointless because if you can do it, you already have your answers. You'd have to know which axis to rotate the normal around -- it would be the axis form by the 'direction' of the V texture coordinate -- and if you have that axis, you already have the bitangent, and since you have two of the vectors, you can find the third with a cross product trivially. Not to mention the fact that what you mean by "direction" of the texture coordinate is the vector (in texcoord space) from the current vertex's U to an adajecent vertex's U, which is exactly the result you're looking for anyway.

If you just have the normal, you can find two other vectors that form an orthogonal basis with the normal, but they won't neccessarily be the aforemention most-useful tangent and bitangent. In fact, since there are an infinite number of tangent vectors, you're pretty much guaranteed they won't be the most-useful ones.

To put it simply, you can't simply find the tangent that you probably want from just the normal. Computing them from texture coordinates of the current vertex and neighboring vertices is the way you want to go.


couldnt ask for a better answer.. thank u
Quote:Original post by jpetrie
The tangent and bitangent (also called binormal) vectors that are most useful are those that align with the U and V texture directions.

Careful there. Although the tangent DOES usually align with the U axis, the bitangent often doesn't align with the V axis. This is because having the normal/tangent/bitangent form an orthonormal basis is much more important than pointing straight down the V axis. One figures out the normal and tangent, and then bases the bitangent off those, with no regards to any shear that might be going on with the U/V axes.

This topic is closed to new replies.

Advertisement