local viewer - specular lights

I have a problem with the specular highlights. I use the function call


But still the specular highlight is calculated as if I always stand at one point, facing the negative z axis. It doesn’t matter how I move around - the specular light remains “static” on the surface.

How come? Does anybody have an idea?

I’m not sure, but you should check the order in which you set your Matrices and your light. If you set ModelView Matrix before, your light will always appear in the same place (in camera space) so the hilight seems to come from the same point.

Hmm… thanks for your comment, but I think the problem is elsewhere. To me it seems like the line

glLightModeli( GL_LIGHT_MODEL_LOCAL_VIEWER, true);

does not have any effect. The specular light remains on the surface exactly where it would be if I was facing the negative Z all the time. As I rotate around the object the highlight doesn’t move around on the surface at all… looks more like a texture wrapped onto the object.

However that line of code has one effect: it seems like it makes the shininess increase. The size of the highlight becomes smaller in size!!! Well… isn’t that weird?


I’ve experienced exactly the same problem!
Unfortunately I haven’t found a solution yet. Maybe a closer look to the situation will help others to understand the Problem.
about GL_LIGHT0:

  • Position is (0,10,0,1)
  • Direction is (0,-1,0)
  • Colors are also set right (Specular & Diffuse)

I set the Localviewer to true and activated normaizing.
Here is the display code:
code begin**
gluLookAt(cam_x, cam_y, cam_z, 0, 0, 0, 0, 1, 0);

glrotatef(anim, 1, 0, 0)

SetLight; //Updates the Position and Direction
sglSetMatConsts(PolishedSilver, TRUE);
DrawPlane; //tesselated
DrawBall; //Pos (0,5,0)
DrawLight; //Sphere @ Ball’s position

code end**
The Light doesn’t move. Fixed local position.
But as the scene spins, the specular component of the light moves across the plane. The diffuse component looks right (stationary from top). Very Wired.

try using your lookat(…) in the projection matrix instead of modelview matrix…that should fix the problem