Bug with order transparent submeshes in one mesh

Hello

I have one mesh with two sub meshes with two transparent materials: transparent balls at some distance from each other.
I one view direction - render is correct, on other direction - render is not correct.

Do sorted submeshes together?

No, it is necessary to create two meshes.

But now i reduce game objects in scene for speed up of loading.

As you found out, that kind of batching only works for non-transparent objects. That kind of optimization simply doesn’t work for transparent meshes. It would be necessary to sort the triangles in the code to get correct results and that is usually slower and even that has cases where you would find visual glitches, e.g. if triangles are overlapping.

Batching working with all type of objects

Batching does not work with transparent objects.

In our project works fine, unity 4.3.4

Obviously it does not… why? because batching doesn’t take into account the depth sorting. It just throws in the meshes into one big mesh (mixing meshes and instancing)…

When trying to batch transparent objects, it will not work because to get a correct transparency across all objects, you need to sort them back to front… which is an additional CPU consuming part…

But it is working. Batching uses material and depth order.

From unity document: “Semitransparent shaders most often require objects to be rendered in back-to-front order for transparency to work. Unity first orders objects in this order, and then tries to batch them - but because the order must be strictly satisfied, this often means less batching can be achieved than with opaque objects.”

https://docs.unity3d.com/Documentation/Manual/DrawCallBatching.html

This issue - it is bug, because unity already uses part of mesh (sub meshes) for batching with other objects. But for sorting this transparent sub meshes, unity use only origin of main mesh. If unity store origin for all sub mesh - this issues will be fixed.

Ah, I wasn’t aware of that. Last time I checked it, it wasn’t possible. The problem with your sub meshes is, that they both have the same origin. As such, Unity can’t sort them. Just split them up into separate meshes.