views:

91

answers:

2

I took a Computer Graphics exam a couple of days ago which had extra credit question like the following:

A light can be defined in one of two ways. It can be defined in world coordinates, e.g. a street light, or in the viewer (eye coordinates), e.g., a head-lamp worn by a miner. In either case the viewpoint can freely change. Describe how the light should be transformed different in these two cases.

Since I won't get to see the results of this until after spring break, I thought I would ask here.

It seems like the analogies being used are misleading - could you not define a light source that is located at the viewers eye in world coordinates just as well as you could in eye coordinates? I've been doing some research on how OpenGL handles light, and it seems as though it always uses eye coordinates - the ModelView matrix would be applied to any light in world coordinates.

In that case the answer may just be that you would have to transform light defined in world coordinates into eye coordinates using something like the ModelView matrix, while light defined in eye coordinates would only need to be transformed by the projection matrix.

Then again I could be totally under thinking (or over thinking this).

Another thought I had is that it determines which way you render shadows, but that has more to do with the location of the light and its type (point, directional, emission, etc) than what coordinates it is represented in.

Any ideas?

+3  A: 

The light's position is transformed by the modelview matrix that was active at the moment the light was defined.

If the modelview matrix was identity at that point, you'll get the light in eye coordinates.

If the modelview matrix was the inverse of your camera matrix, you'll get the light in world space.

Thomas
It's too bad you can't accept two answers, since it was really the combination of both.
Zachary
Don't worry about it. You're welcome.
Thomas
+3  A: 

In the case of the street light, the world coordinates will stay constant when the viewpoint moves.

In the case of the head-lamp, the eye coordinates will stay constant when the viewpoint moves.

Chris Lercher