Alpha blending, depth sorting and batching

Making 2D game, where I have very many transparent objects, I noticed a strange thing with dynamic batching. If I have alpha blended objects (in my example, there are about 500 grass planes), which I z-sort when starting a game, everysthing is OK. Grass is batched perfectly.
But the thing is going wrong when I’m trying to group different objects with different materials. For instance I’m making a tree, so there is a parent empty object, and 4-5 objects for leaves, crone and so on. Every different part has its own material.
So, I put the tree in my scene and duplicate it few times, with X offset. Batching is all right. Because they have the same Z-depth. But if I change Y coordinate (depending on Y coordinate, script makes calculations for Z coord), batching is broken.
I know that depth buffer has problems with alpha blending. But with the single objects everything is ok. Even if I have a group of objects with one shared material, z-sorting wotks. The bad thing happens only when I have a group of objects with different materials.

Thanks in advance :slight_smile:

Use a different queue on every material. Force elements in same batch - Questions & Answers - Unity Discussions

Thank you, it helped ) But damn… if I have 10+ types of trees and other different vegetations, for each subobject I have to create its own shader with different queue value?