In today's "things that are obvious in hindsight" news:
Instead of the inverse transpose matrix, use the adjugate matrix for transforming normals. It leaves out the 1/determinant which you'd normalize() away anyway.
https://www.shadertoy.com/view/3s33zj
Only drawback: It doesn't flip the normals when the world matrix is inside out (eg. with negative scale). But you can counter this by flipping backface normals in the shader, and boom - everything always works, regardless what the user throws at it. \o/
=> More informations about this toot | More toots from kb@abraum.social
@kb something about this did feel familiar, so i've gone to check my own source code from 8 years ago and found somewhere where i'd factored out the determinant in an inverse matrix times vector, so that it would only be 3 divisions and not 9.
=> More informations about this toot | More toots from mrsbeanbag@ieji.de This content has been proxied by September (ba2dc).Proxy Information
text/gemini