# Thread: Why does lighting happen in eye space?

1. ## Why does lighting happen in eye space?

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?

2. ## Re: Why does lighting happen in eye space?

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.

3. ## Re: Why does lighting happen in eye space?

... 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.

4. ## Re: Why does lighting happen in eye space?

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!?

5. ## Re: Why does lighting happen in eye space?

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.

6. ## Re: Why does lighting happen in eye space?

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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•