PDA

View Full Version : Lighting and Material



07-03-2001, 09:43 PM
If the material is purely green(diffuse) and

the diffuse light source is purely red,

Is the material shown black(R=G=B=0)?

But... the material was shown gray(R=G=B not equal 0).

Why?

The source code is following...

GLfloat diffuseLight[] = { 1.0f, 0.0f, 0.0f, 1.0f };
GLfloat lightPos[] = { -50.f, 50.0f, 100.0f, 1.0f };

glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);


glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT,GL_DIFFUSE);
glClearColor(0.0f, 0.0f, 0.0f,1.0f);
::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

....

glColor3ub((GLubyte)0,(GLubyte)255,(GLubyte)0);
glBegin(GL_POLYGON);
for(ff = -bound ; ff <= bound ; ff += gridSize)
{
::glVertex3f(0, ff, bound);
::glVertex3f(0, ff, -bound);
::glVertex3f(0, bound , ff);
::glVertex3f(0, -bound , ff);
}
glEnd();

zed
07-04-2001, 12:14 AM
is ambient set to something other than 0,0,0?
also is texturing disabled

Deiussum
07-05-2001, 05:16 AM
The specular component would also have an effect if the light is coming near the same orientation as the normals.