View Full Version : Replacing gl_NormalMatrx...

11-20-2008, 01:24 PM
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?



11-20-2008, 01:34 PM
You have to build this matrix on the C++ (or else) side... and send the matrix as an uniform variable.