Replacing gl_NormalMatrx...

I’m trying to write some simple vertex lighting in GL3 without using any deprecated functionality, but I’m a bit stuck.

According to the spec, gl_NormalMatrix is the transpose of the inverse of the top-left 3x3 elements of the modelview matrix. Well, that’s easy enough (I thought)…

In the shader I grabbed the top-left 3x3 matrix, and then realized there is no inverse() function in GLSL. Can someone point me in the right direction to build a normal matrix from the modelview matrix?

Thanks,

Luke.

You have to build this matrix on the C++ (or else) side… and send the matrix as an uniform variable.