I put two quads in the scene with just a simple Standard shader with the same texture. It is set to have fade turned on.
Regardless of where the camera is, they don’t sort. I thought Unity had sorting based on distance from camera. Its clearly failing or not turned on. In fact, I think its mocking me. When I slide one of the Quads in front or behind the other, its always drawing it wrong.
I’ve been seeing strange alpha sorting issues in various places in Unity 5, and I haven’t been able to figure out if there are multiple bugs causing it or just one.
I’m curious about something due to a bug I experienced with sorting and alpha. Go to windows menu > frame debugger, and go down the list (use the arrow keys). When do the transparent objects get rendered? Is it in a group called “Render.forward.opaque” or “render.forward.transparent”? I was getting a big where transparent stuff rendering during the opaque queue which is sorted backwards from transparent stuff and would cause the same issue you’re experiencing.
Everything is going into a group called Render.OpaqueGeometry->RenderForwardOpaque.Render. And my alpha quads are getting rendered under that group in a sub-group called Dynamic Batch. Something here doesn’t seem right.
Its clumped the two alpha elements together into a single draw call under the opaque geometry.
bgolus, btw. Thanks for showing me that Frame Debugger. I heard it was in Unity 5. But at work, were still stuck in Unity 4.6 and Its not available.
With that said. Strange things are afoot. When I fired up the frame checker, suddenly my original scene where I had all kinds of alpha trouble, just started working as expected. Not sure how or why. For some reason, sometimes things that are supposed to be alpha get clumeped with the opaque stuff.
I haven’t tracked the issue down myself, but my best guess as to the cause is using a shader that uses zwrite or an opaque queue, then changing that shader to not be zwrite or in an opaque queue (which the standard shader does as it defaults to opaque and then changes itself to transparent via a shader vars, but also could happen with a custom shader) will sometimes leave a material stuck in the wrong queue.
The fix for me was to set the material to use another transparent shader, like particle/add, then back to the shader I wrote. At least this is my best guess as to how it was fixed.