PDA

View Full Version : beginner question about normal matrix

planza
06-26-2013, 11:25 AM
Hello,

I have seen some examples of shaders using the normal matrix...frequently is used in lighting shaders in order to calculate the intensity of light.

Can someone explain me what is the normal matrix? How can I obtain this normal matrix?

Thanks.

Jesse
06-26-2013, 02:02 PM
This is a math question, not an OpenGL question, so in the future don't expect people to answer you. The normal matrix is the matrix which preserves vertex normals under an affine transform. If you do the math, this turns out to be the inverse transpose of the modelview matrix. Note that you can make the code much more efficient whenever the transform, i.e. the modelview, happens to be orthogonal; this would imply that the inverse transpose is just the identity transform, which then makes the normal matrix the same as the modelview matrix. You should learn linear algebra before attempting to learn computer graphics otherwise none of it will make much sense.

planza
06-26-2013, 02:18 PM