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

multiple light sources

Started by psycho_munkey Jul 7, 2004 at 10:57 PM 3 replies 500+ views
Original Post
psycho_munkey
psycho_munkey
I just started doing DirectX and im making lights. when i use this -- DEVICE->SetLight(0, &LIGHT) how do i set more than 1 light at a time?
cow_in_the_well
cow_in_the_well
d3d supports up to 8 lights at once using the fixed pipeline. To set the other 7, simply pass its index into the SetLight function (0 - 7). Don't forget to also call dev->LightEnable for ecah lights you want enabled. See the DX docs for the details :).
psycho_munkey
psycho_munkey
oh of course, i shouldve tried that, thanks.

Why does it only support up to 8 lights? - if you wanted to make a street scene with streetlights?
cow_in_the_well
cow_in_the_well
If you want to render additional lights, you need to do it in a second pass.

So if you have 15 lights, render the first 8 lights, set blending to additive, then render the remaining 7 lights.

Just remember, having that many lights in one scene being calculated in real time could have a pretty bad performance impact :). If possible, precalculate the lights into a light map or even per vertex if you do not need full definition.
__Daedalus__
__Daedalus__
I think your maximum amount of lights you can have set at once is determined by your video card (e.g. check in the device CAPS viewer tool) not DirectX. But try not to have more than four lights in any one scene. Many lights will give bad performance - especially if you have high-polygon models.

Topic Locked

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

Sign in to reply to this topic.