glut Platonic solids

I’m creating a little app that displays various objects, including the whole glut pregenerated objects. The sphere, torus, teapot, cone and cube all work fine, but when I come to the Platonic solids (Dodecahedron, Icosahedron, and so on) all the faces are very dark. They do light up if I increase the ambient value of the material. This also happens with the aux versions, and the aux Teapot.
I have a standard 3 point light setup so there is plenty of light around.
Any ideas?

He Who Has Plenty Of Solid Platonic Relationships.

-JohnD

Well, maybe the implementation of the normals calculations is bugged ! Have you tried to enable GL_NORMALIZE before rendering these objects ?

Eric

P.S. : that is really just a thought as I never used these objects before. But if the others work, it must be that these ones are badly defined !

That worked a treat! Thankyou very much.
Let the word be sent out that the glut Platonic solids have dodgy normals!

He Who Is Also Normally Dodgy.

-JohnD

Arf’, I forgot something : perhaps you did something like glScale or made the modelview matrix scale something ? In this case, that could explain why the normals were buggy…

I mean, if you use glScale before rendering the object, the object is scaled but ITS NORMALS TOO !

I though that might be a reason but perhaps it is simply a bug in the libraries !

Regards.

Eric

Originally posted by Eric:
…I mean, if you use glScale before rendering the object, the object is scaled but ITS NORMALS TOO !..

Good point, I do scale the objects. Though I’m a bit surprised OpenGL does that.

He Who Now Feels A Little Embarassed.

-JohnD

Well, that makes sense : everything is transformed by the modelview matrix, normals included. So if you scale the vertices, you scale the normals as well !

Regards.

Eric

Eric, if you scale vertices, you scale the polygon, but the normal is still the same (normalize that is), and because normals is only used for lightning, I see no reason to scale them. And also remember this, if you use glScale(1,2,1), the normals IS NOT pointing in the proper direction after scaling. The normal is ONLY pointing the correct direction if you use a uniform scale. In the non-uniform case, you need to calculate a new normal.

Bob, I disagree with you and here is a sentence taken from OpenGL specs to prove what I am saying (from glScale specs) :

“If scale factors other than 1.0 are applied to the modelview matrix and lighting is enabled, automatic normalization of normals should probably also be enabled (glEnable and glDisable with argument GL_NORMALIZE).”

I am sure the normals are scaled…

Regards.

Eric

Arf’ I think I misunderstood you so let’s me re-explain what I meant : when you scale your objects, you do not need to scale your normals (I agree with you) but when you use glScale, the normals are scaled by OpenGL…
If you use glNormal(1,0,0) after glScale(2,2,2), the normal used by OpenGL will be (2,0,0). That will corrupt your lighting…

That is what I meant (but I think we were saying the same thing : you do not need to scale but OpenGL does it !).

Regards.

Eric

Yupp, now we’re on the same wavelength

You know if it’s possible to scale normals after a non-uniform scale, so the normals is at least pointing the right direction? I mean, only applying a scalefactor to each axis and not recalculate them from the new vertices.

I am not sure : I just read the specs of the GL_EXT_rescale_normal extension and I am not sure if it is what you are looking for or not ! I mean, I understand what you want but I do not understand what this extension is supposed to do (english not being my native language, I still have problems in some cases…).

But as I do not see what else this extension might bring to us, I think that might be what you are looking for !

Regards.

Eric