PDA

View Full Version : scaling destroys lighting of glutSolidSphere



shogo2040
01-19-2001, 12:04 AM
if you scale a sphere created with glutSolidSphere using glScale, the lighting gets ruined. But if you scale your glutSolidSphere via parameter (radius) then everything is fine and lighting is perfect.

Unfortunately, scaling with the radius won't make your sphere stretch along a specific axis (to form something like an ellipsoid).

so I would assume that glScale is the only answer? if so, then how do you use glScale without ruining the normals defined inside the glutSolidSphere function?

if this approach is not possible, then how would you rewrite glutSolidSphere to be more flexible such that you can scale along a specific axis via paramters:

glutSolidEllipsoid(x_axis, y_axis, z_axis);

Shogo2040

Kilam Malik
01-19-2001, 01:17 AM
Using glScale is always a problem with lighting, because the normal vectors get also scaled. And those are used to calculate the lighting. You can activate normalization with glEnable(GL_NORMALIZE), but that will slow down your app dramatically. The best thing is not to use glScale, but do the scale in geometry (like adjusting the radius of your sphere).

Kilam.

Serge K
01-19-2001, 02:48 AM
You can use GL_EXT_rescale_normal (http://oss.sgi.com/projects/ogl-sample/registry/EXT/rescale_normal.txt) (if available).