Jump to content
  • Advertisement
Sign in to follow this  
Feynt

OpenGL Lighting questions

This topic is 3759 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!