PDA

View Full Version : A problem with OpenGL Lighting process



ClearMind
06-20-2004, 06:21 PM
i do a simple test to see how OpenGL do its Lighting work.
i draw a quad using
glBegin(GL_QUADS);
glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-12.0f, 0.0f, 12.0f);
glTexCoord2f(0.0f, 10.0f);
glVertex3f(-12.0f, 0.0f, -20.0f);
glTexCoord2f(10.0f, 10.0f);
glVertex3f(12.0f, 0.0f, -20.0f);
glTexCoord2f(10.0f, 0.0f);
glVertex3f(12.0f, 0.0f, 12.0f);
glEnd();
gluLookAt(0.0f, 1.0f, 10.0f,0.0f, 0.0f, 0.0f,0.0f, 1.0f, 0.0f);

lighting and meterial setting are right(i use a teapot to test the shading effect,it is perfect).
My question is why every pixel on the QUADS are the same color. Doesn't OpenGL do a interpolation between the four vertexes?
should i subdivide the big quads into small ones

plasmonster
06-20-2004, 07:13 PM
Doesn't OpenGL do a interpolation between the four vertexes?Yes, if you set glShadeModel(GL_SMOOTH).


should i subdivide the big quads into small onesFor vertex lighting, subdivision helps a lot. This sounds like the problem you're having. Try subdividing the quad into a mesh of smaller quads.

ClearMind
06-20-2004, 07:45 PM
Thank u so much!
i realize that maybe the four vertex of the quad
have the same(almost the same)color. So the interpolation is done only to make every pixel on the quad the same color.