Sign in to follow this  
Feynt

OpenGL Lighting questions

Recommended Posts

I've done a bit of searching about the forums, looking for a few clues, but while some questions have been answered a few more have taken their places. So I'll define my problem first, and what little understanding I have, and hopefully someone out there will be able to point me in the right direction. Right, so I'm looking for a way to display more than 8 lights in OpenGL (why the limit after all these years?). I've found some tutorials on how to do many lights in one scene, but I'm told such a method will not work with deferred lighting. I'm also told that the only method it will work with is extremely slow for a higher poly scene (>100k) where deferred lighting can deal with lots of lights (but not more than 8?) very quickly depending on the resolution. The trouble is, I've read that deferred lighting has problems sorting transparencies, which my scenes will have a lot of. Am I basically stuck with... Forward rendering is it? Or can I do more than 8 lights with deferred lighting and deal with transparency issues? [Edited by - Feynt on March 3, 2008 7:54:11 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Feynt
Right, so I'm looking for a way to display more than 8 lights in OpenGL (why the limit after all these years?).

That's 8 lights in a single draw call. Not 8 lights in the entire scene, or 8 lights visible at once. If I climb up a hill at night, I can see hundreds of streetlights. Does that mean that there are hundreds of streetlights shining on each car?

Share this post


Link to post
Share on other sites
Ah, I was told 8 in total. >P
So having lots of lights drawn would mean lots of drawing passes, which I guess is what forward rendering is?

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
That's 8 lights in a single draw call. Not 8 lights in the entire scene, or 8 lights visible at once. If I climb up a hill at night, I can see hundreds of streetlights. Does that mean that there are hundreds of streetlights shining on each car?


Yes, there will be hundreds of lights shining on your car if you can see hundreds of streetlights.

@Feynt
If you want to use the fix pipelines functions, of course it would be bounded by the implementation.

However, you must have using shader as you said you are doing deferred rendering, right? By using shader, you can write custom code to do whatever you want. In this case, you can do a lot more lighting calculation in a single pass as long as the shader can handle. If your shader code have too many instructions, you would like to use Cg from NVidia too. Cg will divide your Cg code into multi pass without bothering you. Also, shader program already support dynamic branching, therefore it can lower the number of instructions significantly if you are using it correctly.

Share this post


Link to post
Share on other sites
Quote:
Original post by ma_hty
Yes, there will be hundreds of lights shining on your car if you can see hundreds of streetlights.

Wrong. Try again. (Note, it's not your car.)

Share this post


Link to post
Share on other sites
Quote:
Original post by Feynt
So having lots of lights drawn would mean lots of drawing passes

Only if you actually wanted more than eight lights simultaneously shining on a single object. The thing is, situations where more than eight lights are actually having a noticeable effect on a given object are vanishingly rare. For those situations, you can use something like SPH, but the complexity and added computational burden there are unlikely to be worth it.

Share this post


Link to post
Share on other sites
Ah, well I don't want more than 8 lights shining on the same object. In all likelihood less than 8 will be in any given area. But like, if I were looking out over a village from up on a hill, I'd like to see my torch light, my camp fire nearby, the moonlight in the scene, and lighting from 10-20 lanterns around the village. Or in another case, a lit walkway at night with rows of lights shining down on the pathway. With a sufficiently long path that curves around a lake, you'd see more than 8 lights for sure.

So as long as I don't have more than 8 lights in one spot shining on the same object(s) (or don't want more than 8 lights to add up on the object(s)) I don't need to do multiple passes to get more lights going and I can skip deferred lighting?

Addendum:
Also, what's SPH? I can only find references to fluid dynamics on the net and I don't see how that applies to lighting unless I want to start doing refraction (which I don't).

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
Quote:
Original post by ma_hty
Yes, there will be hundreds of lights shining on your car if you can see hundreds of streetlights.

Wrong. Try again. (Note, it's not your car.)

Funny Sneftel... I try again later in year 2030 when I have the time...

Share this post


Link to post
Share on other sites
Quote:
Original post by Feynt
Ah, well I don't want more than 8 lights shining on the same object. In all likelihood less than 8 will be in any given area. But like, if I were looking out over a village from up on a hill, I'd like to see my torch light, my camp fire nearby, the moonlight in the scene, and lighting from 10-20 lanterns around the village. Or in another case, a lit walkway at night with rows of lights shining down on the pathway. With a sufficiently long path that curves around a lake, you'd see more than 8 lights for sure.

So as long as I don't have more than 8 lights in one spot shining on the same object(s) (or don't want more than 8 lights to add up on the object(s)) I don't need to do multiple passes to get more lights going and I can skip deferred lighting?
Exactly. When you want to render an object, determine what lights are important for that object, and set them.

Quote:
Addendum:
Also, what's SPH? I can only find references to fluid dynamics on the net and I don't see how that applies to lighting unless I want to start doing refraction (which I don't).
Heh, I've got fluid simulation on the mind. I meant SH, Spherical Harmonic Lighting.

Share this post


Link to post
Share on other sites
SH sounds nice, but I plan on having moving objects in the world. For what I'm planning, not much will be guaranteed to be a static object, so I don't think it'll work (the Wikipedia entry suggests that translations and deforming meshes won't work with the technique). As for light mapping, I think that faces the same problem since neither the lights nor the environment are guaranteed to be stationary. Though having the option for setting certain things to "immovable" might work out in that respect. Hmm, gears in motion. >)

[Edited by - Feynt on March 7, 2008 2:19:44 PM]

Share this post


Link to post
Share on other sites
So after giving it some thought, I perhaps need to know a bit more about how SH works. Some places I've gone suggest that lights and/or objects CAN be moved within the scene. Others suggest that a gratuitous amount of memory and processing power would be required to store the values for lighting a scene. Considering I have a rather low minimum requirement to work with (4 year old hardware basically, maybe earlier), and the scenes will be dynamically generated, this method doesn't seem like it'd be feasible in this situation. It's dead sexy, what it can do, but... Someone tell me I'm wrong. >D
Light mapping looks like a more process friendly alternative, as I can generate results of whatever resolution I choose, and can start off quick and low res and work up.

Dynamic lights or objects (things I'm deeming to be physical, or possibly moving through other means, which I've decided is easier to flag in this case) will just use another rendering method. But this brings me back to the point of the topic, which I guess is now a good deal easier to answer now that a portion of the problem has been dealt with: Is deferred lighting a better idea for the dynamic side of the equation, considering I'll have transparencies moving about, or would just going forward with another lighting scheme work better?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this