PDA

View Full Version : Only 8 Lights!!!???



adityagaddam
10-19-2002, 12:22 PM
I am currently learning open gl from an open gl book... I went to the lights chapter and saw that you can only have eight lights.. Eight Lights!!?? is that all or can you have more..

-Aditya

dabeav
10-19-2002, 12:25 PM
8 should be enough for any scene. If you need more powerfull lights you can simply set the color to above 1 per color value. But, yes only 8 lights are viewable at one time. Besides that, more than 8 lights, would REALY slow things down durring render. There may be a way to turn on more than 8 lights using a multipass technique, but ive never attempted to do so. If it works let me know.

jpummill
10-19-2002, 12:47 PM
I have often wondered about this. How can games like Quake3 and Unreal Tournament have what appears to be many (more than 8) lighted objects moving around a scene and still have good performance.

By the way, I am not talking about stationary objects such as wall lamps, I am talking about dynamic objects such as rockets and plasma balls that reflect light off the walls as they travel.

How is this possible with only 8 lights???

V-man
10-19-2002, 12:52 PM
They dont use lights. They use lightmaps (textures that represent lit surfaces)

V-man

powerpad
10-19-2002, 01:01 PM
opengl does only support up to 8 lights as standard implementation however you may add more lights to your scene but you have to query the max numbers of available lights that is supported by your hardware. Please correct me here if i am wrong.
However quake style engines implement "lights" via lightmaps thus prerendered "textures" are applied via multipass rendering and other techniques to your geometry. Please correct me here again when i am wrong.
CU

adityagaddam
10-19-2002, 03:27 PM
ok.. so if you are walking through a room with all its textures "lightmapped" and there are no lights at all, would it still seem like a normal room with one or more lights? or do we have to have a certain number of lights for the lightmaps to work?

-Aditya

nexusone
10-19-2002, 04:53 PM
I don't think there is a limit to how many light maps you could have.


Originally posted by adityagaddam:
ok.. so if you are walking through a room with all its textures "lightmapped" and there are no lights at all, would it still seem like a normal room with one or more lights? or do we have to have a certain number of lights for the lightmaps to work?

-Aditya

MrShoe
10-19-2002, 07:29 PM
A "light" in OpenGL terms is just a way to define the colour of a vertex. So what opengl does is it determines the angle from teh light source for the vertex and the vertex normal and sets the colour accordingly. You can do this yourself very easily. AFAIk having more than 8 lights wouldnt be slow, i mean the calculations involved arent that complex... maybe im horrbly wrong tho.

jono_123
10-19-2002, 07:53 PM
i was just wondering if anyone knew how this compares to Directx? how many lights can ya have?

10-20-2002, 10:08 AM
Okay lets get this right:

the walls in Quake I, II and III are light mapped. That means that they simply put a texture on the walls that is lightened, nothing to do with what OpenGL considers lighting.

All other polygons are lightened by OpenGL. Before rendering each object, Quake checks which lights cast most light in that particular object and sends them to OpenGL only. So there can be more than 8 lights in a scene, but each object is only lightened by the neareast 8 lights.

adityagaddam
10-20-2002, 11:41 AM
oh.. so if you have a cube with ten lights around it.. only eight of those lights would have any effect on the cube but you can have another ten lights around another cube in the same scene..is that it?

-Aditya

10-20-2002, 12:28 PM
Correct. But 10 lights around one cube will barely happen.

adityagaddam
10-20-2002, 04:09 PM
ok thanks...

jpummill
10-20-2002, 04:33 PM
When you say that there are 10 lights around a cube but only the 8 closest are used, is this because OpenGL disregards the farthest 2 or because your application is doing it???

If the application does this, then are you turning lights on and off all around your scene based on which object is currently being drawn.

It looks like I still need to read some more about this!!!
jpummill

MickeyMouse
10-21-2002, 12:53 AM
BTW do you know any game that uses standard OpenGL lighting for most of it's geometry???
I find it more educational than useful since it always looks bad...ok unless you tesselate your objects very high.

[This message has been edited by MickeyMouse (edited 10-21-2002).]

MichaelK
10-21-2002, 02:06 AM
Example? Return To Castle Wolfenstein. You can do it in setup (AFAIR from lightmaps to vertex).

MickeyMouse
10-21-2002, 03:15 AM
OK..you're right..I meant games with their native lighting as standard OpenGL lighting....Switching on that option in WRTC is just an option for poor hardware users.

secnuop
10-21-2002, 08:57 AM
Originally posted by MickeyMouse:
OK..you're right..I meant games with their native lighting as standard OpenGL lighting.
Vertex lighting doesn't mean standard OpenGL lighting. For Quake 3 at least, the only vertex data that is sent are a vertex's position, color, and texture coordinates, so it's impossible that standard OpenGL lighting is being used (there's no normals). RTCW is almost certainly the same since they're both based on the same engine.

I'm not aware of any big-name games that use standard OpenGL lighting. Lots of CAD-type apps do though. Have a look at the ViewPerf benchmark to see examples of a few.

jpummill
10-21-2002, 10:00 AM
All of the tutorials on the web that I have seen for lighting just use OpenGL lighting.

Are their any tutorials that anyone is aware of that use software based lighting. Maybe a compare and contrast of the benifits of one method versus another???

jpummill

10-21-2002, 04:06 PM
Look in the Red Book under Lighting. At the very bottom of the page (in the online version) the equation of how OpenGL calculates lighting is described.

I find tons of software lighting information on the Internet. For very basic lighting (only diffuse directional light), take the dot product of a vertex's normal and the light ray and thats the intensity.

-- Thomas