Last active
March 13, 2018 04:53
-
-
Save XProger/b338c55634f1856d93030cd4f7964a5d to your computer and use it in GitHub Desktop.
method to get orthonormal basis without normalization by Jeppe Revall Frisvad ([email protected])
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void getBasis(const vec3 &n, vec3 &t, vec3 &b) { | |
if (n.z < -0.9999999f) { | |
t = vec3( 0.0f, -1.0f, 0.0f); | |
b = vec3(-1.0f, 0.0f, 0.0f); | |
return; | |
} | |
const float x = 1.0f / (1.0f + n.z); | |
const float y = -n.x*n.y*x; | |
t = vec3(1.0f - n.x*n.x*x, y, -n.x); | |
b = vec3(b, 1.0f - n.y*n.y*x, -n.y); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment