View Full Version : Lighting

12-10-2002, 05:29 PM
I have a light source above an object. The position directly under the object should be light up more be the brightest and as the light spreads out it's intensity decreases. I only have diffuse and ambient light set up. Would setting up specular light provide the effect what I'm looking for?

12-10-2002, 05:59 PM
Make sure your light is positional and not directional (infinite), as the default light is directional.

GLfloat lightPosition[] = { x, y, z, w };
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

Where w = 0 for directional light, and w = 1 for positional light.

Also look at "light attenuation".

glLightfv(GL_LIGHT0, GL_CONSTANT_ATTENUATION, &fLightAtten[0]);
glLightfv(GL_LIGHT0, GL_LINEAR_ATTENUATION, &fLightAtten[1]);
glLightfv(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, &fLightAtten[2]);

These are all discussed in the spec, and more info can be found via a Google search.

Hope that helps.