View Full Version : Direction of light

04-15-2003, 05:37 AM
Ive gone and got myself all confused http://www.opengl.org/discussion_boards/ubb/frown.gif

When specifying a direction light ...

the 4th value for param GL_POSITION if equal to 0.0 means that its a directional light rather than a positional one?
The 3rd value specifies the direction down the -ve z axis? so if pos = 0 0 1 0 its a light pointing from say 0,0,100 towards 0,0,0?

if the above is true what do the first two values point towards? are they down the -ve x axis and the -ve y axis respectively or down the +ve axes???

04-15-2003, 08:08 AM
The parameters you pass in as a position are the (x, y, z, w) values for the location of the light. So a positive value for x, y or z is a positive amount along that axis.

The w value is a bit non-intuitive if you've not been doing graphics long! The x, y, z values you pass in are essentially divided by the w value (frequently called the scaling factor). This has many applications, but you generally don't worry about it and just use 1.0f.

The one case where you may find it useful is for lights at infinity. If you use 0.0f as the scaling factor you'll notice the divide-by rule above doesn't seem to make much sense. Essentially it placed that light an infinite distance away in the direction specified. So yes, passing in (0.0f, 0.0f, 1.0f, 0.0f) will make the light appear to come from the direction of the positive z-axis.

Sorry for the long reply, I'm not known for snappy answers! I hope it makes more sense now than if I'd just said "yes". http://www.opengl.org/discussion_boards/ubb/smile.gif

04-15-2003, 11:07 PM
Much appreciated, I was getting into a muddle http://www.opengl.org/discussion_boards/ubb/smile.gif

one more thing, what about the x and y values when w = 0.0 ? do they appear to come from the +ve x and y axes respectively like z?