We can use it to find an orthonormal basis for Tangent, Bitangent and Normal:

\begin{align}
T &= T-\frac{(T \cdot N)N}{N \cdot N} \\
B &= B-\frac{(B \cdot N)N}{N \cdot N}-\frac{(B \cdot T)T}{T \cdot T}
\end{align}

If the input N and T are normalized already,  then we can use the simplified code

T = (T - Dot(T, N) * N).Normalize();
T = (Dot(Cross(N, T), B) < 0) ? -T : T;
B = (B - Dot(B, N) * N - Dot(B, T) * T).Normalize();
B = (Dot(Cross(N, T), B) < 0) ? -B : B;

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *