-
-
Save wiseConst/ac68457266768844af707ec5d334aec2 to your computer and use it in GitHub Desktop.
cofactor matrix, as described by https://github.com/graphitemaster/normals_revisited
This file contains hidden or 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