Last active
August 17, 2022 18:10
-
-
Save shakesoda/8485880f71010b79bc8fed0f166dabac to your computer and use it in GitHub Desktop.
cofactor matrix, as described by https://github.com/graphitemaster/normals_revisited
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
// cofactor matrix. drop-in replacement for the traditional transpose(inverse(m)) normal matrix calculation. | |
// this is a substantial performance improvement. | |
// short form found via shadertoy: https://www.shadertoy.com/view/3s33z | |
mat3 cofactor(mat4 m) { | |
return mat3( | |
cross(m[1].xyz, m[2].xyz), | |
cross(m[2].xyz, m[0].xyz), | |
cross(m[0].xyz, m[1].xyz) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment