overwriting Z buffer (basically instances aren’t sorted front-to-back, so z will be overwritten unecessarily?)
or something related to HiZ (related to shadow mapping, to be honest, I don’t understand how it would be affected…)
This issue matters to me because:
Imagine a 3d top-down game, if I batch render objects from top layer to bottom layer (so essentially front-to-back), did I overcome this overwriting Z buffer problem?
Do things like Early-Z Rejection and Hierarchical Z happens automatically on the GPU, regardless of how we call DrawMeshInstanced?
I think these are 2 different concepts of Z buffer:
a very high-level understanding of depth buffer.
the actual z buffer in the graphic pipeline, which is much more complex and varies by GPU.
This. If you need or want instances to be sorted, you have to do this to the arrays you pass in manually.
Irrelevant here. It’s just talking about sorting front to back for opaque objects. Differences between different z buffer representations aren’t really that important. That’s more important for things like alpha testing, fragment shader depth offsets, and depth resolves.
Thx a lot, so in short, I should just try to sort the instances from front-to-back (in term of the camera view space) when rendering, and that in itself should satisfy the “z efficient sorting” which DrawMesh automatically do (and DrawMeshInstanced doesn’t). True?