Jump to content
  • Advertisement
Sign in to follow this  
Dragon_Strike

tangents from normals

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

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!