gl_NormalMatrix

Simple Question:

To transfrorm a vertex,
gl_Postion = gl_ModelViewProjectionMatrix * gl_Vertex;

But to transfrom a normal it is:
normal = gl_NormalMatrix * gl_Normal;

I do not undertsand why it is not :
normal = gl_ModelView * glNormal;

Why should the normal be transformed by the inverse of the ModelView matrix instead of just the modelview matrix?

Thanks for any help…

Clicky!

Thnaks DarkWing - That was just what the doctor ordered…

:wink:

After further reading - I just want to clarify the following interpretation.

It is impossible to multiple a normal by the ModelView matrix, because the ModelView matrix may include Non-Uniform scalings within it. (If a non-uniform scaling is applied to an object, the inverse of the scaling must be applied to the normal.) Due to interesting matrix multiplcation properties, it works out that using the inverse transpose of the ModelView will indeed apply the proper transformations and uniform scalings as well as the inverse of non-uniform scalings as required.

One last question - It appears that although light positions are specified in worldspace, the modelview matrix seems to be automatically applied. Thus, lightpositions, when accessed in a vertex program, already have the modelview matrix applied. Is this correct?

Thanks again for any insight or clarification… :slight_smile:

If you have the orange book, page 216 has the info you need…

OpenGL specifies that light positions are transformed by the modelview matrix when they are provided to OpenGL.
So yes, it’s already done.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.