View Full Version : back surface color

12-09-2007, 11:31 AM
I have a problem in back surface coloring.

I give two different colors (red front, white back) to the surfaces.

I draw a triangle on the screen. When I rotate that triangle I realized that front and back surfaces have same colors.

My coloring code for front and back surfaces is below:

glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse2);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular2);

glMaterialfv(GL_BACK, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_BACK, GL_DIFFUSE, mat_diffuse1);
glMaterialfv(GL_BACK, GL_SPECULAR, mat_specular1);

I used two light sources in z and -z directions.

Would you please tell me what the problem can be?

Michael Steinberg
12-10-2007, 12:26 AM
Could you strip down your code to the relevant parts and post the result?

12-10-2007, 02:42 AM
Have you enabled the double sided lighting using the GL_LIGHT_MODEL_TWO_SIDE lighting model parameter (glLightModel)?

12-10-2007, 02:46 AM
Yes, you are right. The problem solved when I changed my light model.

Thanks Komat