View Full Version : Unable to set a headlight (flashlight)

09-27-2002, 11:05 PM
Hello, I'm having trouble when trying to set a light from the camera's point of view. I set the light only once at the initialization of the window, after the OpenGL rendering context is set with these parameters:

float ambient[]={ 0.1, 0.1, 0.1, 1.0};
float difusse[]={ 1.0, 1.0, 1.0, 1.0};
float shininess[]={ 1.0, 1.0, 1.0, 1.0};
float position[]={ 0.0, 0.0, 1.0, 0.0}; /*w==0 direction*/




After that, I change the point of view with


Then I draw an horizontal plane and, after, an starship. The final render is:


Note that all the polygons are shaded with the same color, although they have different normal vectors. Changing the direction to

float position[]={ 0.0, 0.0, -1.0, 0.0};

leads to a weird representation where only exists a color:


If I set instead the light direction to

float position[]={ 1.0, 0.0, 0.0, 0.0};

the scene is correctly rendered, with the light coming from the right (positive X axis):


It also works correctly with the Y axis. I don't know why it just doesn't work with the Z axis, can anynone tell me?

Thanks in advance for your replies.

[This message has been edited by Azdo (edited 09-29-2002).]

09-30-2002, 10:35 AM
Well, I updated the image links so they work now.

09-30-2002, 10:43 AM
How have you setup your normals?

Also your matrial settings?

Originally posted by Azdo:
Well, I updated the image links so they work now.

10-02-2002, 12:45 AM
Originally posted by nexusone:
How have you setup your normals?

Also your matrial settings?

I think he normals and the materials are fine as shown in the last picture, when the light comes from the right. It's the light direction what matters.

Anyway, I'm setting the normals per-polygon (using the normal vector to the polygon). When I get home, I'll post the material initialization code.


[This message has been edited by Azdo (edited 10-02-2002).]