PDA

View Full Version : simple lighting of a shaded cube



Caco1681
04-10-2001, 08:39 AM
I have a rotating cube, each vertice is a different color so the colors are smoothly shaded across each face. I am trying to add a simple light to the scene just to experiment with it. Every time I enable lighting, the cube turns into black and white. I obviously do not have the material values of the cube set correctly, or the light values set correctly or something. Can someone tell me what values to use for the material of the cube, or the properties of the ligh, so that it will retain its smoothly shaded surface when the light strikes it. Thanks in advance.

chennes
04-10-2001, 09:48 AM
You need to set the material color of the faces, not the colors of the vertices.

Chris

Sheepie
04-10-2001, 07:45 PM
You can also enable color tracking for your material using-

glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_D IFFUSE)
and...
glEnable(GL_COLOR_MATERIAL)

As long as you define a material with ambient and diffuse properties, you can then go ahead and change it's colors on the fly.

Then you can still have your vertex colors and if the Model Shading is set to Smooth, they will be blended. http://www.opengl.org/discussion_boards/ubb/biggrin.gif