Skip to main content
gamedev.net
🔒 Locked

Multilight-Multipass?

Started by Brad Sweet 2 replies 900+ views
Original Post
Brad Sweet
Brad Sweet
Hi, I'm in the process of converting my old shaders to HLSL, simultaneously trying to add more flexibility. Amongst my old shaders, I had specific one-pass shaders that supported, for example, 1 directional and 2 spotlights simultaneously. As I pondered the conversion philosophically (considering the possible combination of light types, number of lights, bump mapping, shadows, etc) I realized that my one-shader-to-one-combination may not be the best way to go. What's the conventional wisdom these days, i.e. what do most folks use, to accommodate the variety of lighting conditions while protecting engine performance? Is multi-pass (layering one light at a time) preferred over my approach, or are other techniques better? My scenes are generally outdoors aircraft/space flight simulations, requiring one directional light (the sun) and 3 or less point/spot lights. Thanks for any thoughts! Brad
jollyjeffers
jollyjeffers
I like a hybrid sort of approach [smile]

I'm a big fan of using uniform constants and a large number of techniques. Possibly also application-specified #define's if needs be. By doing this you can write one piece of HLSL and generate all the necessary derivatives at compile/load time.

It means you can have a single shader with a single light source multiplied through a number of passes. Or you could, using the same code, generate a SM3 version that rolls all 4 lights into a single pass.

You might want to take a visit to the DirectXDev mailing list. I can't think of any exact threads right now, but I'm pretty sure this sort of design/architectural thing has been discussed several times over the last year. DXDev is a great source of general wisdom/advice [smile]

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
Krohm
Krohm
I did a PS3.0 shader a month ago which parsed a couple of LUTs (one couple for light type) in which each texel pair was a HDR light. This is essentially the same as jollyjeffers did (I also did the VS version on uniforms).
The results were quite convincing but I wasn't able to hit the performance I was thinking about.

Anyway, if you know of your average scene requirements, I'm not sure you should take this way. A bunch of ifs could be enough if you are in the op count.

As for the multipass issue, I would expect it to be much slower, especially when coming to HDR targets, unless RGBE. I designed the aforementioned shader because I needed to collapse more passes than possible. I later ran out of time and didn't test a multipass variant so this is basically speculation...
Previously "Krohm"
Brad Sweet
Brad Sweet
Jack/Krohm,

Thanks to both of you for your thoughts/experiences. As I suspected, there is no easy answer, although it's reasonable to assume that multipass is less desirable.

I will proceed forthwith to DirectxDev to seek additional wisdom!

Thanks,
Brad

Topic Locked

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

Sign in to reply to this topic.