First post ever to say I'm keeping an eye on this, and holy hell I would love to try testing it out. I've been struggling with multiple lights natively and through plugins like Paster, especially since I want scalability with a larger layout and many more layers. I know it's not ready for production release, but I would be grateful if you could throw me a bone for how you're generally laying it out using Paster.
Regardless, it looks amazing considering the constraints of C2's engine.
The lights aren't composited in to Paster all at once - that would create the same overlapping/incorrectly rendering issues we see without using Paster.
There's a loop that basically does this for all of the static lights:
For each ShadowLight
- Paste ShadowLight into Paster (there's some steps here to run effects on the shadows to soft them, but this is the basic idea)
- Delete ShadowLight
For the dynamic/interactive lights, there are unique Paster objects for each. The ShadowLight isn't deleted, but it's turned off unless there needs to be an update to the Paster object, which is tracked based on the collision polygon of the Sprite that acts as the light stencil (the shape/look of the light). The Paster objects for these lights are sized only as large as needed for the image being used in each Sprite.
So for example, the rotating spotlight:
Here the collision poly is overlapping the Tilemap and player Sprite, so the Paster object needs to be updated with the correct shadows. Note the collision poly isn't actually this big, the lines are just shown for reference.
But here, the Sprite acting as the Light stencil doesn't need to be updated because it's not colliding/overlapping with anything, and so it just rotates the Paster object based on it's anchor point (Image Point, in C2 terms).