Archived

This topic is now archived and is closed to further replies.

fireking

making the transition from basic to advanced lights

Recommended Posts

id like to step up the light code im working with in my examples... as of now, i know how to create, turn on/off, and render a light. I know how to change its position, color (just ambient and diffuse for now...) and thats about it. I would like to, however, learn more about lights. I wanna know how you can specify the type of light like in Direct3d, point, spot, or directional. Id also like to know how to set things like, the radius (so that light doesnt light up everything in the entire world) and things like that. Also, where are their only 8 lights? (0-7) NeHe didnt seem to explain this very well... Anyone suggest a really really good open gl book for someone like me, who really wants to know open gl very well...? thanks

Share this post


Link to post
Share on other sites
There are only 8 lights because the lights are ment to be supported in hardware. And when you add more than 8 lights it starts to add up the required processing time to calculate the lighting on objects.

In games like quake and Unreal Tournament, Half-Life, etc. They use lightmaps, which are precomputed textures, with light intensity values, modulated over the original texture. This only requires another texture layer, or another pass (for really old hardware.)

You usually only use hardware lights on high polyon models, for low quality lighting (no shadows) of animated geometry (like the player or something)

The other lighting you usually precompute, or calculate using your own methods (texture or vertex based, realtime or precomputed)

The main reason being the shabby looks and # of lights limitation of using hardware lighting.
--------
I''m sure this information abounds somewhere (the # of lights limitation seems to come up alot) maybe check over at www.opengl.org
their forums are on the upper right area of the window.
Otherwise, search or look through previous threads in the OpenGL or Graphics related Threads here at gamedev.

Share this post


Link to post
Share on other sites
The limitation is 8 lights per glBegin/glEnd pair or vertex array, not 8 lights per scene. For each object you want to draw, just enable the lights which most significantly effect the geometry you''re drawing. 8 lights is usually more than enough.

BTW, if you really MUST have more than 8 dynamic lights then you can always implement them with fragment shaders. Don''t bother with static lighting unless you don''t mind the lighting being, well, static.

Share this post


Link to post
Share on other sites
oh i see...

i was gonna say, ive seen maps that have like 3 moving lights in a certain part of the level. And i my self have created a quake 2 map that had one room with several moving lights. i didnt think that light maps could accomplish this so i was really confused...

thanks man, you just saved me a shxt load of time

Share this post


Link to post
Share on other sites
im still having trouble understanding the light situation...

i have a geforce 2 in one of my computers, and a geforce 4 in my newer one (both are mx). anyways, i play a lot of games, like warcraft 3, neverwinter nights, stuff like that. Now i know for a fact that nwn uses open gl, but im not sure about war3. Anyways, those games have tons of lights, moving lights too. I just dont understand how they can do it with the 8 light limit! Are they writing a really complex manager that stores all the lights inside a class, then based on your position, turns those on and off (actually just resetting the default 8 lights to the "stored" light settings). Like lets say there are 16 red lights in a level, in different places. You walk around, less say only one light is visible in this certain area. As you approach the area, do they write some sort of function that sets up a light right then and there, according to the stored parameters for that specific light in that specific area?

If so, what happens if you have a scene with more than 8 lights...

I just dont understand how all these games have so many lights, and lots of moving lights, even with the current light limitation. And i know they are not using a shader, cuz both my video cards dont have that ability. (pixel shading, and the new cg fx stuff..)

I searched on the net for a little while and found a few documents talking about lighting methods used over the years. One talked about doom and how it used a (as stuff gets farther away, it gets darker) method. Really old stuff. It talked about light maps too (ala quake 2). But I dont want light maps. I want moving lights, lots of them.... Maybe i need to just use an engine instead of making one...

anyone that could readily shed some light on the subject, and explain the most common methods (i mean, just give me names of what they're called so i can google on it or something)...

Thanks,
Joey

[edited by - fireking on October 14, 2003 1:32:46 PM]

Share this post


Link to post
Share on other sites