View Full Version : Why does lighting happen in eye space?
06-17-2004, 01:13 AM
I wonder what the reasons are for doing lighting in eye space? Sometimes one can read "for performance reasons" ... has it to do with the calculation of local/global light and viewpoints or is it something else?
06-17-2004, 03:37 AM
you can do lighting in object-space, world-space, or eye-space, whichever is more convenient. there's no rule written in stone anywhere. eye-space is handy if that's where your vertex is, but it's completely up to you.
if you do the math, you'll see that the geometric relationships are the same, regardless of which space is chosen. the important thing is keeping the vertices, normals, and lights in the same space.
06-17-2004, 03:39 AM
... has it to do with the calculation of local/global light and viewpoints...I would say yes.
Edit : sorry, in fact local/global has nothing to do the eye or world space.
06-17-2004, 10:03 AM
I agree that all vectors needed for lighting have to be in the same space to do consistent lighting. Maybe I didn't make myself clear. I wanted to know why *OpenGL* does lighting in eye space? The light sources are positioned in world space but are transformed to eye space afterwards. It is sensible to do positioning in world space but why the heck is lighting performed in eye space by default? There has to be some good reason, right!?
06-17-2004, 01:02 PM
i guess i didn't make myself clear. if the gl does lighting in eye-space, it's because you've told it to, not because that's the default behavior. when you supply light positions to the gl, they're transformed by the current modelview matrix, just like points. assuming your modelview matrix has a viewing component, the light position will be in eye-space. if, on the other hand, you load an identity on the modelview stack before setting light positions, then your lights will be unaltered, remaining in world/object-space, however you choose to look at it. i guess you could consider this the default behavior, as loading an identity is an extra step, but it's at your command entirely.
06-19-2004, 09:02 PM
All light parameters (light position, attenuation, etc) are stored in eye space because it allows to transform all light parameters into a unified space because eye space is considered to be unchanged during the render of a frame.
OTOH the object space or the world space do change whenever you access the modelview matrix (very often in a single frame), which means that you can't store anything consistent in those spaces.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.