Hey everyone, I’m working on a 2.5D game that uses 2D sprites for characters and small objects, and 3D meshes for geometry. I have a perspective camera that rotates around the map at a locked downward angle.
In the process of setting up my scenes, I’ve noticed that transparent sprites in Unity have their backfaces drawn (Cull Off) and seem to sort depth correctly from the front, but when viewed from behind their sorting is reversed, drawing the furthest sprite from the camera on top.
You can test this out yourself simply by dropping a few Sprite objects in a scene and assigning them a texture with transparency, then lining them up front to back and rotating the camera around. Here’s an example using the default sprite shader and some sprites from Disgaea:
Is there something I can set in my custom shaders to correct this behaviour? I’ve tried switching to a cutout shader, ZTest options, disabling and enabling batching, and of course using other shaders - but so far no dice.
I can’t assume the sprites will always face the camera even with a billboarding shader, because they’ll still invert when I flip them with the animator toggle to face different directions. Is there some way I can simply set all instances of this shader to render in order of their distance from the camera at all times?