Universal render Pipeline 2D Transparency sorting mode not working

Hi guys, I have been stuck for ages on trying to get this to work. I want my sprites rendered in order of their position on the Y axis. I am using the Universal render pipeline 2D and I am trying to set the transparency sorting mode, however it doesn’t seem to work. Lighting works fine so it is using the render pipeline.

I have a UniversalRenderPipelineAsset:
6754141--779179--upload_2021-1-22_20-39-14.png
And set it in the Graphics settings:
6754141--779185--upload_2021-1-22_20-40-45.png
I set the Transparency sort mode to custom axis to Y:
6754141--779182--upload_2021-1-22_20-39-33.png
The GameObjects are just simple objects with a spriterenderer for testing:
6754141--779188--upload_2021-1-22_20-43-47.png
But it still renders the sprite in order of Z Axis!
6754141--779176--upload_2021-1-22_20-38-23.png

Nothing changes when I change the Y axis, but the sprite with the higher z level immediately pops to the front. Do any of you have any idea how I might debug this? I feel like I am missing something basic. Weirdly enough it does seem to work fine in the editor view, but not in the play window

I guess I am just going to hack this by setting the sprites Z position proportionately to the sprites Y position if I can’t get this to work properly.

So for anyone else ever reading this, I could not get it to work with the universal render pipeline. The default renderer applied the sorting mode correctly however but that one can’t use 2d lighting. I wrote a method that scales the Z position of the sprites proportionally to their Y level as a workaround. It will undoubtedly be more expensive, but considering the scope of my project setting some positions will be fine. An advantage I found of this method is that you can also add an extra gameobject at the base of your prefab that serves as the point on which to set the sorting order instead of having to change all the sprites pivot point, which I think is more effort.

private void SetZLevel(transform zPivot) {
        float zScale = 0.0001f;
        transform.position = new Vector3(transform.position.x, transform.position.y, zPivot.position.y * zScale);
    }

You have two renderers in the Renderer List pictured in your first screenshot. Perhaps they’re not playing well with one another. Try removing the first one and keeping just 2D Renderer.

Do you have the correct pivot points set within the Sprite Editor? You also have the Sprite Sort Point on the SpriteRenderer set to Center, so it won’t use a pivot point from the Sprite Editor.

I FOUND A FIX FINALLY, Anyways just go to project settings graphics, switch to the default renderer turn on transparent axis, switch back and make sure 2d renderer also has custom axis. Done!

1 Like