- Home /
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?
Wouldn't armA normally come after head? (no answer to you question, of course, but it'll bump it ☺)
Have you disabled the Z buffer in some way? mesh.combine will not preserve the order of triangles.
Arm vs head priority, I suppose, would depend on character design. Our characters are giant headed, with arms that cant reach over their heads, so it seems better to have beards and stuff draw over the shoulders... But I may reconsider down the road.
Answer by lakehaze · Jul 01, 2011 at 04:12 AM
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.
Answer by Dreamora · Jul 01, 2011 at 12:49 AM
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
Answer by am_ · Sep 07, 2015 at 09:24 AM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220612130025im_/https://answers.unity.com/themes/thub/images/avi.jpg)