Reversed? draw order of sprites

Another day, another challenge :slight_smile:

I’ve noticed that when using a perspective camera and there is a sprite with the exact same Z value, that the draw order of everything else gets flipped

While this can mostly be fixed with depth testing (and discarding fragments with alpha testing) this starts to be a problem when using semi-transparent sprites.

This might be fixable with implementing frustum culling - but I think the performance tradeoff isn’t worth it for smallish scenes.

Right order:

Wrong order after placing a sprite directly beside the camera:

Setup in editor (camera is selected):

Sample project:
project

For 3D cameras, I really recommend using Rendercam. See if it causes the same problem, it is strange.

1 Like

same as what exactly?

I noticed this behavior when using Rendercam. Just didn’t include it in the sample project to have a minimal setup to reproduce this.

The camera is positioned at 0,0,0 and has no rotation.
The 4 semi-transparent sprites (shown in picture 1) have a Z value of -500 (2 in the front) and -600 (2 in the back)
With this setup, everything works fine.

If I add a 5th sprite (x = 1000, z = 0) which is directly ‘beside’ the camera and nowhere near the rendered area, the draw order of everything inside this area changes (shown in picture 2).

This sounds really strange. I can’t really explain it. @JCash?

I cannot explain it either.
I’d have to investigate this more thoroughly.