PDA

View Full Version : Normals matrix



Pody
10-06-2004, 07:08 AM
According to all the sources I searched on the internet and on books, when transforming an object with a matrix, to correctly transform the normals you have to multiply them by the matrix t(inv(M)), where t() is the transpose, inv() is the inverse and M is the matrix with the translation part removed.
After this step you have to normalize the normals again.
Is there a way to skip the normalization part, for example doing some assumptions on the initial matrix?
Please, help me if you can.
Thanks

Dark Photon
10-06-2004, 04:27 PM
Originally posted by Pody:
when transforming ... normals ... Is there a way to skip the normalization partIf your ModelView matrix contains no shears or scales, your normals should stay normalized.

Pody
10-06-2004, 09:57 PM
My matrix may contain scaling factors... that is why I whant to know if there's a way to preprocess the matrix so that the normals don't have to be re-normalized after the transformation

plasmonster
10-07-2004, 01:44 AM
The trouble is that in order to preprocess your matrix you would need to remove the scaling.

If you have only uniform scaling you can use glEnable with GL_RESCALE_NORMAL, provided your normals are unit length to begin with. With GL_RESCALE_NORMAL, the GL computes a simple rescaling factor based on the modelview matrix.

And then there's glEnable with GL_NORMALIZE for normals that are not unit length. This is just a brute-force normalization, post-transformation.