multiple light sources

Started by
3 comments, last by __Daedalus__ 19 years, 9 months ago
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?
Advertisement
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 :).

- Thomas Cowellwebsite | journal | engine video

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?
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.

- Thomas Cowellwebsite | journal | engine video

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.

This topic is closed to new replies.

Advertisement