# OpenGL fixed func GL_LIGHTING problem (solved)

This topic is 4374 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've heard about this problem before, and I think it is common. I've created a directional light but the direction must be inversed before it is used, otherways it lights where it shouldn't. This vector should point down... {-0.5f, -0.5f, 0.5f, 0.0f}, but my opengl code wants it to point upward. I have to "correct" it with this in order to have it light as I want it to: tmpdirection=-lightDir; glLightfv( GL_LIGHT0, GL_POSITION, tempLight); Thank you! [Edited by - Herr_O on October 2, 2006 2:39:22 AM]

##### Share on other sites
Remember that GL_POSITION is simply the position of the light. OpenGL itself has no notion of a positional or directional light, it merely has a position for the light that is used in the lighting calculations. Since the position is specified in homogeneous coordinates, if w is set to 0.0 it is equivalent to a position at infinity in the direction given by x, y, and z.

Now when you think about a light bulb, you can picture it having a position in 3d space and its light rays emanate outward from that position. You probably visualize a "positional" light in OpenGL the same way... you specify its position and its "light rays" shoot out away from that point in space. You have to think of a "directional" light in the same sense, only you specify its position at infinity, so its "light rays" shoot out from that point at infinity, thus in the opposite direction of the position you specify.

So for example, if you specify the light's position as (0,0,1,0), which is the default light position, that is like saying the light is positioned at infinity on the +z axis. So that means when the light comes from (0,0,+inf) it is shining down the -z axis.

##### Share on other sites
Thanks for explaining, i've read it in the OGL reference too, but it didn't sink in like it does now.

1. 1
2. 2
Rutin
22
3. 3
4. 4
5. 5
frob
12

• 17
• 9
• 31
• 16
• 9
• ### Forum Statistics

• Total Topics
632615
• Total Posts
3007441

×