Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial 13, Orthogonalization #71

Open
baslack opened this issue Jul 14, 2018 · 2 comments
Open

Tutorial 13, Orthogonalization #71

baslack opened this issue Jul 14, 2018 · 2 comments

Comments

@baslack
Copy link

baslack commented Jul 14, 2018

Greetings. Thanks for your work on this extensive tutorial set. I think I may have found a problem with the code performing orthogonalization of the tangent and bitangent. First, it appeared that bitangent orthogonalization was left out altogether, while the tangent operation left off part of the required calculation. To fix it I added the following function to tangentspace.cpp

glm::vec3 proj(glm::vec3 u, glm::vec3 v) {
return u * (glm::dot(u, v) / glm::dot(u, u));
}

and modified the "Going Further" loop as follows:

...

t = glm::normalize(t - proj(n, t));
b = glm::normalize(b - proj(n, b) - proj(t, b));
...

Those two together will make TBN orthogonal and allow the inverse transpose. Please correct me if you find this in error. Thanks for your attention.

-B

@Calvin1602
Copy link
Contributor

Hi Baslack, thanks for your feedback.

The formulas you're suggestion are indeed the full Gram-Schmidt formulas, and should be correct. However, I don't think the current implementation is broken (although I admit there's a tricky shortcut) :

  • By construction, t is orthogonal to n (line 37)
  • By construction, b is orthogonal to n (line 38)
  • The only missing part is that t should be orthogonal to b, too.
  • Line 61 does just that.

Do you have a case where this breaks ?
Sincerely,
Arnaud

@baslack
Copy link
Author

baslack commented Jul 25, 2018

Nope, I don't. I just couldn't figure out what you were doing, which kinda of defeats the purpose of a tutorial.

And I still don't quite follow how line 61 makes t orthogonal to b. Looking at one of the references you mentioned: Lengyel’s Method. That line seems to match the first part of the projection process, but the second is missing, hence my addition. Could you explain in a bit more detail for me?

-B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants