The 2D lighting / shadow casting system is quite slow, it eats up most of the CPU time per frame in my game. A way to optimize it would be to generate 1 mesh formed by several shapes instead of having to add a ShadowCaster2D to every shape, which generates unnecessary separate drawcalls in the 2D Renderer. The inspector should allow to define such separate shapes of the same mesh.
This could be done even automatically by the CompositeShadowCaster2D, without needing multiple paths.
1 Like
Nevermind, I’ve just implemented it by myself
I’ve reduced the frame rendering time, in my game, according to the stats window:
CPU -9ms
Render thread: -6ms.
In general, it’s a performance increase of ~40%.
Limitation: Shadow casters in the group must be static with respect to their brothers.
1 Like