glsl es 2.0 inverse matrix

tower120 picture tower120 · Mar 25, 2014 · Viewed 8.1k times · Source

There is no inverse command in glsl es 2.0
But I saw that I can 1.0/mat2 . But I fear it'll just divide component wisely. Or not?
But if so, is there some trick for this (get 1/det fast)?

Answer

Arttu Peltonen picture Arttu Peltonen · Mar 26, 2014

No, there's no matrix inverse function in GLSL ES 1.00 (used in OpenGL ES 2.0). You'll need to do it manually, take a look e.g. here. But you should think hard whether you really need to do it in the shader on a per-vertex or per-fragment basis every frame, or is it possible to be precomputed and passed in as uniform.