Multiple light Per-Pixel lighting ....

Started by
2 comments, last by jollyjeffers 18 years ago
I'm currently trying to improve my engine in order to support multiple light sources rendering... By know, i'm using a HLSL Shader (vs and ps 2.0) which do per-pixel lighting and shadowing (using shadow map). This Shader is quiet big and it seams that it cannot handle more than ONE light in the same shader (due to instructions slots amout) So, I was planning to use multipass rendering (one pass by light), but this solution is not easy as it seams: - If i do multipass rendering without shadow, for 3 lights, i get 3 pass. Even if it seam possible to use this solution, it will decrease my engine's performances. - If i use multipass rendering with shadow, i'll get for 3 light, 6 pass, which is pretty big ...(3 depth map computation pass & 3 rendering pass ) I was also planning to render the "less important" lights using a simple per-vertex shader, and then to render the most important light using the per-pixel shader ... Which solution do you think i should use to solve this problem?? Can you tell me How professionnal engine face this kind of problem ?? i heard that FarCry engine use multipass rendering (1 pass by light)... If you know any interesting points which can influence my decision, please, let me know ... Clement Vidal
Advertisement
It's not a simple challenge - no way around that unfortunately [oh]

Design optimizations...

I've not looked through it in full detail yet, but Eric Lengyel's recent GDC talk Advanced Light and Shadow Culling Methods might well be of interest. Using some heavy culling methods I managed to vastly improve my stencil shadowing technique from a few years back - it was quite complicated, but it paid off.

Deferred Rendering might be an interesting option for you - from what I understand, it uses MRT's to perform the actual lighting calculation in screen-space, thus you only have to compute the lighting model for pixels that actually contribute to the final image. If you've got heavy overdraw and/or lots of expensive lighting models then this might well be a big win.

Talking of Far Cry... One of their later patches (v1.2 I think) utilized SM3 purely as an optimization. With longer vertex and pixel shaders you can fit multiple lights per pass (for some reason 4 per pass comes to mind). Obviously thats only of use to high end hardware, but given that SM3 hardware is more common now it's a useful trick to try.


General optimizations...

Chances are you're going to be fill-rate bound for this sort of thing, so it's worth doing some profiling of typical scenes to see quite where that pixel processing is going.

With the effects framework you can quite easily put together many permutations by sharing a lot of code. With a good state management system it should be possible to use a large number of shaders for a given scene. I suggest this because I've heard "Level of detail lighting" is a good trick. Why apply a complex lighting model to a surface that is in the far distance - one where the player may not even notice the extra detail. In that case you can possibly drop specular highlights (or replace them with simpler forms) and also drop things like per-pixel normal maps. Maybe at a further distance move your lighting model to the per-vertex level instead.

I'm not quite so sure about shadows, but you should also be able to tweak the resolution and algorithms based on distance - use a cheap algorithm where the user won't notice it so much...



That's all I can think of right now, but I'm sure other people will have some ideas [smile]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Thanks a lot for your answer !

Where can i found all the GDC Stuff you give me (us) in the last post ?

And finally, what do you exactly mean by "deferred rendering" , i don't know what this name refer to ...

Thanks again !!

Clement Vidal
Quote:Original post by ClementLuminy
Where can i found all the GDC Stuff you give me (us) in the last post ?
gdconf.com has the details, but I also 'stuck' a few choice picks to the top of the forum here [smile]

Quote:Original post by ClementLuminy
And finally, what do you exactly mean by "deferred rendering" , i don't know what this name refer to ...
Deferred shading is essentially a way of re-ordering when you apply the expensive per-pixel calculations. You defer/delay it until they're in screen-space and thus any calculations you do are guaranteed to be visible in the final image. It requires that intermediary steps output their temporary workings though - usually via MRT's (Multiple Render Targets).

Deferred Shading by Shawn Hargreaves, Climax (GDC 2004) from the ATI developer site might be of use to you.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement