Skip to content

Commit

Permalink
minor renamings and spelling corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Nov 12, 2024
1 parent eeb1f2b commit 71956df
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/ruis/render/scene/gltf_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,29 +672,28 @@ utki::shared_ref<ruis::render::vertex_array> gltf_loader::create_vao_with_tangen
//
// Solving this matrix equation is actually finding a right inverse matrix A for matrix T.
//
// Then, tangent and bitangent vectors are linear combinations of e1 and e2 with same aX coefficients.
// Then, tangent and bitangent vectors are linear combinations of e1 and e2 with same aXX coefficients.
//
// tangent = e1 * a11 + e2 * a21
// bitangnet = e1 * a12 + e2 * a22
//
// bitangent = e1 * a12 + e2 * a22

auto t_matrix = r4::matrix<ruis::real, 2, 2>(
tex_edge1, // row 0
tex_edge2 // row 1
auto t = r4::matrix<ruis::real, 2, 2>(
tex_edge1, // row 0
tex_edge2 // row 1
)
.transpose(); // rows become columns
.transpose(); // rows become columns

constexpr auto epsilon = ruis::real(1e-5f);

auto tangent = ruis::vec3(1, 0, 0);
auto bitangent = ruis::vec3(0, 1, 0);

using std::abs;
if (abs(t_matrix.det()) >= epsilon) {
auto a_matrix = t_matrix.inv();
if (abs(t.det()) >= epsilon) {
auto a = t.inv();

tangent = edge1 * a_matrix[0][0] + edge2 * a_matrix[1][0];
bitangent = edge1 * a_matrix[0][1] + edge2 * a_matrix[1][1];
tangent = edge1 * a[0][0] + edge2 * a[1][0];
bitangent = edge1 * a[0][1] + edge2 * a[1][1];
}

// Accumulate the tangents and bitangents.
Expand Down

0 comments on commit 71956df

Please sign in to comment.