View Full Version : Transforming Normals and Lights

06-05-2003, 07:56 AM
When I setup my modelview and projection matrices, vertices are transformed by the (PM) matrix while normals are transformed by (PM)T^-1 according to the Red Book.

However, I noticed that if translation is included in the normal transformation, things go awry since they would then be skewed and quite un-normal. (Incorrect orientations even if you renormalize, though) Would it then be prudent to keep handy two matrices for when I want to work with transformed normals--one that includes all the transformations required, to apply to vertices, and one that includes only rotations, to keep normals on track?

Also, I want to play with lighting. Does "hardware T&L" imply that the OpenGL lighting system is hardware accelerated or should I write my own lighting system to keep track of lights and use vertex and fragment programs to do the result calculating?

06-05-2003, 09:46 AM
translations don't affect normals. a vector is defined as [x y z w], and since the w component of a normal is 0, translations (which are stored in the fourth column of a transformation matrix) have no affect on normals. i would recommend using the fixed function pipeline and letting opengl do the transformation and lighting calculations for you before messing around with vertex and fragment programs.