RealtimeSlave

04-01-2013, 06:19 AM

Hello,

I hope you can help me with the following two questions regarding the TBN matrix.

Right now I construct the TBN matrix by calculating the tangent for each vertex and uploading the tangent as vertex attribute a_Tangent to the shader.

Then in the vertex shader I do this:

Normal = NormalMatrix * a_Normal;

Tangent = NormalMatrix * a_Tangent;

Binormal = cross(Normal, Tangent);

So I assume that the Binormal is always orthogonal to the Tangent and thus the cross product of the Tangent with the vertex Normal should give me the Binormal. I assume the orthogonality because Tangent points into the U texture coordinate direction thus the V texture coordinate direction must be an orthogonal vector in the same plane.

First question: Is my assumption correct that the Binormal is orthogonal to the Tangent? Because on another site I read that...

If a texture was stretched, then it is possible that binormal will not be perpendicular to both normal and tangent (although it should be perpendicular).

...but I don't understand how a texture could be "stretched", invalidating the assumption of orthogonality? Is that some special case I could probably just ignore so that I can stick to an orthonormal TBN matrix which is also easy to invert using the transpose?

Second question: When smoothing vertex normals to get smooth shading (e.g. on a sphere) by adding the normals of adjacent triangles and then normalizing the sum, can I just also smooth the vertex tangents by adding the tangents of adjacent triangles and then normalizing the sum? I found this page (http://fabiensanglard.net/bumpMapping/index.php) where the guy is just doing it this way.

Help is really appreciated!

I hope you can help me with the following two questions regarding the TBN matrix.

Right now I construct the TBN matrix by calculating the tangent for each vertex and uploading the tangent as vertex attribute a_Tangent to the shader.

Then in the vertex shader I do this:

Normal = NormalMatrix * a_Normal;

Tangent = NormalMatrix * a_Tangent;

Binormal = cross(Normal, Tangent);

So I assume that the Binormal is always orthogonal to the Tangent and thus the cross product of the Tangent with the vertex Normal should give me the Binormal. I assume the orthogonality because Tangent points into the U texture coordinate direction thus the V texture coordinate direction must be an orthogonal vector in the same plane.

First question: Is my assumption correct that the Binormal is orthogonal to the Tangent? Because on another site I read that...

If a texture was stretched, then it is possible that binormal will not be perpendicular to both normal and tangent (although it should be perpendicular).

...but I don't understand how a texture could be "stretched", invalidating the assumption of orthogonality? Is that some special case I could probably just ignore so that I can stick to an orthonormal TBN matrix which is also easy to invert using the transpose?

Second question: When smoothing vertex normals to get smooth shading (e.g. on a sphere) by adding the normals of adjacent triangles and then normalizing the sum, can I just also smooth the vertex tangents by adding the tangents of adjacent triangles and then normalizing the sum? I found this page (http://fabiensanglard.net/bumpMapping/index.php) where the guy is just doing it this way.

Help is really appreciated!