I’ve already seen a similar solution on the forum when I was researching the ways to manipulate the depth buffer.
Nevertheless, I don’t appreciate using [if
] or [discard
] operations in a shader, especially considering that this is supposed to be a mobile game. (For a few objects that will work, but my intention is to add hundreds of sprites if not a couple of thousands)
But this does not work well for opaque surfaces (like glass).
Yes, I wish to incorporate opaque surfaces later, therefore I would like to see if there is a more general solution.
Just as a small recap of my intention: I wish the predicate is sorted not based on the perspective camera view but a specified direction (just like in Orthographic camera). Then the sprites will be drawn exactly as they come sorted from -Z to +Z and no further tricks are needed since my game logic guarantees that it’s the correct order to draw the sprites. Simple and straightforward.
I know that there is no way I can sort them by calling a function, setting up a flag or manipulating some parameters, but is there any other way to achieve it?