Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multiple Lighting /w shaders. What's your suggestion?

Started by programci_84 Aug 16, 2010 at 1:42 AM 2 replies 1k views
Original Post
programci_84
programci_84
Hi all,

Currently I'm working on my renderer. I preferred using Forward Rendering Method.

Now the question comes: What can you recommend me about multiple lighting with shaders?

* Single pass, multiple lights: With this approach, I'll define 1 directional (only Sun), 4 point and 2 spot lights per pass. I'll genereate shadow map with only spot lights. If # of lights for a light type exceeds the limit, say, 7 point lights in a scene, calculation will be done for first 4 of'em, then in a second pass, calculation will be done for remaining 3. Sun lighting will be performed last. This one may be faster, I think; but more complex. Also, cannot be supperted on early GPUs due to register limits.

* Multiple pass, single light: With this approach, I define only 1 light model per pass. Calculation can be change according to light type. This one is simpler, but can cause a bandwith problem.1

* Any other approach ?

Thx in advance.
-R

PS: Don't recommend me to use Deferred Rendering, please. It's a hungry bandwith eater.
There's no "hard", and "the impossible" takes just a little time.
Aqua Costa
Aqua Costa
Search in google for light pre-pass.
AgentC
AgentC
Light pre-pass is also a variant of deferred rendering, though slightly less bandwidth-hungry.

With single pass, multiple lights you will certainly save in draw calls and vertex processing. However, for most benefit you'd need a robust dynamic shader compilation system (for example based on shader code fragments) which could generate a shader for any light combination on demand. It could even scale back to 1 light per pass for hardware that can't really do more (SM2.)

I haven't actually implemented such a thing myself so I'm not aware of all potential issues ... but I'd imagine you may have to limit the amount of allowed combinations, if it seems like every object will be getting its own shader (resulting in a costly state change per object.) For example you could clamp max lights per pass to 3 and then multi-pass as required to handle the rest.
programci_84
programci_84
Thank you all for your replies!
There's no "hard", and "the impossible" takes just a little time.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.