I have a large number of small lights animated in my scene; is there a way to make this not horribly laggy?
I have a massive empty octagonal room with a little walkway in the center. Around the room are several thousand rather dim little point lights with emissive capsules behind to emulate lightbulbs. An animator has them turn on and off periodically, and the material for the lightbulb is disabled at the same time as the light, to make it look like the lights are flickering on and off. This has, probably unsurprisingly, made everything really laggy. I thought switching the point lights from realtime to baked may cut how intensive this is, but it has not. Is there someway to reduce the lag in the game, or some component I am missing?
Thank you in advance for any help!
Answer by Baroque · Apr 20, 2017 at 06:32 PM
If you're using baked lighting you'll need to make sure that the world geometry and the lights are marked as static. Otherwise everything will remain as dynamic objects anyway.
Bear in mind that of course you can't flicker a baked light! Typically you'd have most of your lights baked but occasionally have one that's dynamic. Or you could have a second dynamic light in the same place as the baked light that lets you locally change the brightness if the player is nearby.
Another benefit of marking your world geometry as static is that you can use Occlusion Culling to avoid drawing things you can't see. This will help reduce overhead in general.
If you absolutely need to have a large number of dynamic lights visible at the same time, consider using deferred shading, which calculates lighting as a post-processing stage--only the visible pixels will receive lighting. It has a higher initial overhead but additional lights are very cheap.