PDA

View Full Version : OpenGL's Lights



ShalRath
01-09-2004, 09:41 PM
I've been told that OpenGL's 8 built in hardware lights are only limited to having 8 lights per face, and that it is quite acceptable to calculate 8 lights for one face, and then move onto the next face and use the same 8 lights to calculate the lighting for the next face. If this is so, would someone be able to post some psuedo code for doing this? If it is not, I'm wondering, how, after calculating all the light values for my vertices, I actually apply this to the vertices in my scene.

mikael_aronsson
01-10-2004, 12:21 AM
First of all, it is not true that you are limited to 8 lights, the OpenGL spec requires any OpenGL implementation to support a minimu of 8 lights but it may support more, in reality most of todays OpenGL hardware does only support 8 lights I think.

This means that the OpenGL pipeline can handle at most 8 lights at any one single time and that's it.

There are ways to use more lights if the need it but my first question has to be, do you need more then 8 lights ? it will have some pretty nasty impact on the performance of your application.

Mikael

ZbuffeR
01-10-2004, 03:59 AM
If you really want to calculate yourself the light values, you can specify it as glColor3f before each glVertex.

But unless you have a very simplified and optimized light model, use the gl lights, they are accelerated by T&L cards.