Hi, I’m working on creating a little custom tilemap system in which I use a single mesh to contain a grid of quads that displays the desired sprites. The issue arises when I have sprites that extend the size of one tile and therefore overlap. When this happens the quads higher on the y-axis always draw on top of quads lower on the y axis. I’ve tried flipping the order in which they’re drawn and such but the issue persists. Is there any way to control the sorting order individual quads are rendered on in a mesh?
In most circumstances, when you have a transparent-capable shader for your mesh, the lowest-index vertices will draw on top of the higher-index vertices of a single mesh. I reversed the order I generated vertices in a dynamic mesh a few weeks ago for this very reason.
(Drawing a mesh based on faded-to-opaque gradient vertex colors, the faded portions would draw on top of opaque, so I reversed the vertex order to draw from the opaque end first, toward the faded end)
By contrast, an opaque shader type will instead sort more reliably by depth.
As a general rule, transparent shaders will draw a mesh like this to save on draw calls. A single draw call for a single mesh is far more sane than an indeterminate number of them (i.e. per triangle?).