Sorting order in immediate mode

Avatar
  • updated
  • Answered

CleanShot 2023-01-10 at 12.37.59.mp4

I'm trying to make immediate mode work with my sprites. They are regular spriterenderers, and the issue is that the transparent space of the sprites is masking immediate mode shapes (as you can see on the video)

When playing around with normal shapes, by default they work well (sorting order = 0), but if I change that to sorting order = 1, I get the same issue.


I understand that sorting order can't be added to immediate draw mode, however do you have an idea on how I could fix my issue ? I don't entirely grasp the origin of it :/

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Freya Holmér creator
  • Answered

Immediate mode isn't piped into Unity's sorting pipeline, it's drawn immediately (hence the name), and so it will be either in front of, or behind, all other objects in the usual render pipeline, depending on where you insert the draw command (check out the second parameter of Draw.Command(camera, injectionPoint) )

You might be able to sort things the way you want if you're using the depth buffer and the opaque blend mode, in that case it will usually sort correctly no matter the order (though it will only support fully opaque colors)

There's more info on draw order in the shapes documentation: https://acegikmo.com/shapes/docs/#draw-order