PDA

View Full Version : Specular Light Problem



MasterDunx
03-22-2010, 06:08 AM
Alright Chaps,

I'm having a bit of a problem with my specular light. It seems to only want to light up on the edge of the lit area.

I'm working with ARtoolkit with coordinates specified by a marker in augmented reality which makes it very difficult to pinpoint where the light is actually coming from. Because of this I can't tell whether it's the light position or the specular properties.

Some code specifying the light:


static void lighting1 (void)
{
GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash_collide[] = {1.0, 0.0, 0.0, 1.0};
GLfloat mat_flash_shiny[] = {50.0};
GLfloat light_position[] = {-25.0, -25.0, 200.0, 0.0}; //{-25.0, -25.0, -75.0, 0.0};
GLfloat spec[] = {1.0, 1.0, 1.0, 1.0};
GLfloat lightZeroColor[] = {1.0, 1.0, 1.0, 1.0};
GLfloat direction[] = {-25, -25, 0};

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT1);
glLightfv(GL_LIGHT1, GL_POSITION, light_position);
glLightfv(GL_LIGHT1, GL_SPECULAR , spec);
glLightfv(GL_LIGHT1, GL_DIFFUSE, lightZeroColor);
//glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, direction);

glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);

glEnable(GL_DEPTH_TEST);
}

Here's a picture demonstrating my problem:

http://img185.imageshack.us/img185/5351/27653123.jpg

Thanks for your time

Dark Photon
03-22-2010, 04:39 PM
I'm working with ARtoolkit with coordinates specified by a marker in augmented reality which makes it very difficult to pinpoint where the light is actually coming from. Because of this I can't tell whether it's the light position or the specular properties.
Or normals, or color material, or...

Suggest you post a short GLUT test program. In cooking it you'll probably figure out your problem. If not, then that's something we can sink our teeth into.

I would suggest setting the light's AMBIENT and DIFFUSE to 0,0,0. That way if there's specular and it's set up right, you'll see it.

Also, why are you doing this on LIGHT1? LIGHT0 is the first light. Are you using LIGHT0 for something else?

Also, you realize your light is an infinite-distance directional light source, not a point light source. Is this your intent?

What's your color material setting? Suggest glDisabling COLOR_MATERIAL if you haven't already, and use glMaterial to set your material properties. What's your material setting for specular? Suggest you set material AMBIENT, DIFFUSE, and EMISSION to 0,0,0,1 so you can focus on the specular calcs.