# TBN vectors

How do you create TBN matrix polysoup. I know that T and B vectors follow s and t coordinats but I realy dont know how to calculate them. I’ve searched some forums and google but I only found info how to calculate T and B for simple objects like cubes and spheres. Any (pseudo)code would be very usefull.

If you have a procedural model (a sphere, a torus…) then the TNB triplet is pretty obvious. That’s why you’ve found so many info on them over the Internet.

If you’re looking for the TNB triplet for bump-mapping, then all you can select whatever Tangent and Binormal you like once you have the Normal.

Details
Compute a (first) vector - the Tangent - orthogonal to the Normal. You can use the equation : dot_product(T,N)=0
There is an infinite number of vectors that solves the quation. Choose whichever you like.

Then compute a (second) vector - the Binormal - orthogonal to the Normal and orthogonal to the Tangent. Given a Normal and a Tangent, there is a unique Binormal vector. It can be computed as the cross product between the Normal and the Tangent : B=cross_product(N,T)