Scissor2D - A new 2D toolkit plugin

Hi all! Some good news about layering :slight_smile:


I’ve been experimenting with different solutions to implement layering support and I’ve discovered that because all Scissor Components are drawn through a single renderer actor, I actually have explicit control over draw order to do whatever layering solution I like! Here I have setup a prototype with SortingLayer and OrderInLayer variables. You can see as I change them the draw order updates accordingly even though they are all drawn at the same depth value.


In fact SortingLayer will override scene depth, so it is possible to have something that is physically behind something else, draw on top of it. SortingLayer & OrderInLayer are what another popular engine uses for their sprite sorting, but I’m open to suggestions if anyone has any ideas for a better system.

As always, there are some tradeoffs to this implementation. For this to work all Scissor Components must only use translucent materials as opaque materials are drawn in a separate render pass that can only be correctly scene combined via scene depth. At first I thought this was a deal breaker, but then I noticed that Unity also only supplies translucent materials for their sprite implementation. If you change a Unity sprite to use an Opaque shader it will indeed break render order and their sorting no longer works.

A more significant downside is because the ScissorRendererActor that actually does all the render calls to the underlying engine is always at the root of the world, this messes up layer sorting with other non Scissor things that need drawing (such as meshes or particles). I’m looking into a way to get the renderer to spawn a new component (that can have a real depth) for each sorting layer that may alleviate some of this, but I’m not sure yet.

Next I want to take a quick look at how 2d physics can work. I feel like it will need to be a separate implementation to the current physics interface, so I want to try and work out the implications of that.