Large numbers of Light2D destroys performance - tips on optimizing?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Slavfox

Hi, I’m working on a project with a dynamic 2D lighting art style, which means I’m using lots of Light2D nodes to shade normalmapped Sprites. I didn’t, however, realize how expensive it is - when I add about a hundred lights to a scene that runs at 3k+ FPS without them, the framerate drops to an unacceptable 15 FPS.

I found this issue hinting at the underlying cause, but no suggestions on how to work around it (except breaking down sprites into smaller parts, but my sprites are already pretty tiny, the number of lights is the issue here). Any suggestions on how I can optimize the performance while retaining the effect of normal maps?

Is there any way for you to combine the lights? Maybe creating something like a Light2D effect?

Ertain | 2019-03-26 23:22

I’ve thought about using multiple lights in a single Texture, but the normal maps cause the sprites to always be lit up from the direction of the Light2D texture’s center - maybe it would be possible to emulate the directional lighting properly with a shader, but I don’t know nearly enough about shaders to even know whether it’s doable.

Slavfox | 2019-03-27 15:48

Drat, I would like to help with the shader part. But I don’t know anything about them, either.

Ertain | 2019-03-27 19:23