esuvs

02-18-2003, 06:09 AM

Hi,

I'm having a bit of confusion about how lighting works in OpenGL.

In order to calculate the light at a vertex, OpenGL needs to find the distance between the vertex and the light, which is a simple enough operation. However, in all the diagrams of the graphics pipeline I have found, the lighting is performed afer projection and normally clipping.

Surely the act of projecting the primatives (and presumably the lights) will modify the distances (and possibly the directions?) giving an inaccurate result.

How does OpenGL resolve this? Prehaps the distances are calculated before projection and stored? Or maybe the primatives and lights are un-projected before finding distances? Anyone got any ideas?

Thanks,

David.

I'm having a bit of confusion about how lighting works in OpenGL.

In order to calculate the light at a vertex, OpenGL needs to find the distance between the vertex and the light, which is a simple enough operation. However, in all the diagrams of the graphics pipeline I have found, the lighting is performed afer projection and normally clipping.

Surely the act of projecting the primatives (and presumably the lights) will modify the distances (and possibly the directions?) giving an inaccurate result.

How does OpenGL resolve this? Prehaps the distances are calculated before projection and stored? Or maybe the primatives and lights are un-projected before finding distances? Anyone got any ideas?

Thanks,

David.