Combining Mesh changes Draw Order?

We mesh.combine() our 2-D 6 quad character meshes into a single mesh. Finally, we are getting predictable results animation wise, but the combine operation seems to screw with the draw order of the quads.

The order goes correctly on FBX import:
0-armB
1-legB
2-legA
3-torso
4-armA
5-Head

The character is stacked along z in that order, with 0.1 units separating each layer. After combining the mesh, the z order is retained (as can be seen from a perspective camera), but the quads don’t draw in their z-order. Even though the torso is 0.2 units behind the head, the torso is drawn on top.

What is causing this?

Okay, the mesh combiner uses mesh names to sort order. I renamed my meshes in Maya with a prefix that denoted their z-order (“head” → “z6_head”) and the resulting combined mesh displays correctly.

If you combine meshes they will no longer ahve distinct depths, the sorting happens on mesh level not triangle level. As such you better don’t do combine mesh with anything that has a transparent / transparent cutout shader otherwise you have to go into the resulting mesh and sort it manually on the vertex-triangle level

Actually you can merge meshes in the order you want in Maya.
Turn on Shading->Object transperacy sorting to see how it would display in Unity.

For example if you have the following meshes:

  • characterHead
  • characterBody

You just select it in the reverse order you want for Z-ordering after combining the meshes.
So in this case you would select the characterBody first, then shift select the characterHead and then merge.