Wrong Depth Sorting with large quads?

I’m having depth sorting issues with some of my sprites created with spritemanager 2.
In the attached screenshots you can see the clouds, where one gets hidden by the background (when clearly in front), which gets drawn correctly when moving the camera a bit.
I’m having the same issues with in the game as in the viewports.

alt text
alt text

95alt text95
alt text

  • Clouds & background share the same texture atlas, but i have the same issues when using different atlasses.
  • All use the sprite vertex color shader (the cutout shader shows correctly, but i’ve got mobile platforms as target and try to avoid the use of it)
  • The same issue occurs when using a sprite (like the background) and an imported model (plane too) like the hills in the background (see the second pair of screenshots)
  • Changing the cameras near/far plane for better z-buffer resolution does not change a thing
  • If moving the sprites REALLY far apart, z-ordering seams to correct…
  • I’m using Unity 3.5

As I understand it, the sprites get sorted by their pivot position (which is in correct z-order in the scene) and then combined to a mesh. That would mean there has to be correct z-odering for the sprites, since all of the gameobjects have a correct z-value.

Anyone having similar issues? I’m thankful for any ideas or hints :slight_smile:

edit:
i’ve tried changing the sprites created via spritemanager with my own quad mesh, which doesn’t change a thing.
Splitting the background up in smaller parts does fix the problem - but why on own would it do that? quads should be drawn with z-testing anyway, so even if the rendering order is wrong, the cloud should be drawn (and the background not drawn in the transparent regions, if i’m not completely mistaken…)

cheers, manni

Ok, it’s a bit sad that i needed Berenger for that, but z-write is disabled in the Sprite-Shader as standard.
This additionally with the large sprites, where the center position of the big one is before the cloud one, they get rendered in the wrong order.

The only possible solution i can see is to separate the big sprite into smaller ones so that the render order is correct, or otherwise use z-write and z-test and a cutout shader, which is quite slow on mobiles.

Thx Berenger :slight_smile:

Hi! Im having the same issue, but im using 2d Toolkit instead SpriteManager. Did you solve this?

Hi! I have the same issue. Could you solve this?

One answer I’ve found, if you know which object should be in front, is to use a different shader for one and set the Queue value to put it above/below the other shader.