Sign in to follow this  

multiple light sources

This topic is 4941 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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 :).

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this