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) | |
| ); | |
| } |