2D VFX Graph: Per-particle sorting with other sprites using the Y-Axis

For context, I’m making a top-down 2D game and I’m using URP with a 2D Renderer. To sort all of my sprites properly, I’ve set my Transparency Sort Axis to a Custom Axis set to (0, 1, 0), and all of my sprites have their pivots set to the bottom of the image.

I have a visual effect in my game where spikes shoot up from the ground. By default, the spikes aren’t sorted correctly using the Y-axis like all the other sprites, but I’ve found out that I can sort them by using a custom Sort Mode in the output of the particle quad. The image below shows them all sorted correctly, where spikes closer to the bottom are drawn above spikes closer to the top.

However, while this does properly sort the particles among themselves, it doesn’t sort them with other sprites on a per-particle basis. If both are on the same sorting layer and have the same order in the layer, then either all of the spikes will be above the sprite, or all of them will be below the sprite. In the image below, you can see that the character is drawn over every single spike sprite, even though they should be drawn behind some of them, but above some others.

I found this forum post that says that the sort point for a VFX Effect is based on the position of the entire system’s bounding box, and this seems to be true. However, for an effect like the one I have, I need every particle in the effect to be sorted individually, based on its individual Y-position. Is there a way to do this? Thanks!

It’s not possible. This is one of the areas where 2D sprite games can be harder than 3D games.

The way other games appear to get away with per-particle sorting is that they’re 3D with opaque materials and transparent particles. Opaque materials can write to the depth texture. All the opaques are drawn before any transparents are drawn.

As a result, transparent particles can check the depth texture to see if they’re in front or behind an object; “soft” particles feather this. Transparent sprites and transparent particles require manual sorting per renderer to determine the order.

But there is a solution: you can often get away with 2 or 3 renderers (and thus 2 or 3 sorting points) for fast effects. If you really need something more than that, you need individual renderers.