PDA

View Full Version : glScalef changes lighting?



Rad
05-03-2003, 11:37 PM
I need to use glScalef(2,2,2) and now this triangle that's facing the camera loses about half its light. Normally it gets full illumination from the light behind the camera. Lighting is correct after using glTranslatef and glRotatef, what gives? Maybe its not lighting? Textures are disabled and smooth shading is on.

harsman
05-04-2003, 02:28 AM
the noramls you supply (with glNormal3f et al) are transformed by the inverse transpose of the modelview matrix. Scaling the normals producees incorrect results since they become non unit length. To fix this either glEnable(GL_NORMALIZE) or don't use scaling. If you're using software transform and lighting using the rescale normals function (see opengl spec) can be faster than enabling normalization. On all decent graphics hardware since about 2000 or so this is pointless however, just enable normalization.

Rad
05-04-2003, 02:33 PM
Ah, I see. Scaling works fine now, thanks!