ssloy/tinyrenderer

tangent vector calculation, Lesson 6 bis

XiaofanLinUS opened this issue · 2 comments

Is it possible to calculate tangent vector i using the following equations?
Screen Shot 2022-06-26 at 7 49 55 PM

It's an odd math question. But it is very tempting to create such equations.

I try in my code. Sometimes, matrix A is non-invertible. And I am curious why that happens.

Thanks!

ssloy commented

Nope, the system you are writing is degenerate. You can obtain the third line by subtracting the first line from the second one.

Provided that your model is okay (no degenerate triangles), the matrix A must be invertible, since it contains the model coordinates prior to any projection:

mat<3,3> AI = mat<3,3>{ {view_tri.col(1) - view_tri.col(0), view_tri.col(2) - view_tri.col(0), bn} }.invert();

Just realize it is a degenerate matrix. Thanks!