Batching Disabled To Avoid Z-Fighting

Hello!

I’ve been working on optimizing draw calls the last few days and there’s some that won’t batch together and the reason in the frame debugger is “Dynamic Batching is turned off in Player Settings or is disabled temporarily in the current context to avoid z-fighting”. Dynamic batching is not turned off in Player Settings so it has to be the z-fighting thing. However, in this case I don’t care about z-fighting because I’m using a custom shader that doesn’t add colors together when textures with alpha overlap (gif below)

My question is then what would be disabling dynamic batching? And how do I stop it from doing so? These meshes should definitely be able to be combined into a single draw call.

Here is the inspector values for the shader, notice how it says “Disable batching: no”

Here is the inspector values for the GameObject being drawn:

Here is a gif of me navigating through the different draw calls in the frame debugger:

YellowDismalLemming

3450387--273325--Unity_2018-04-04_13-18-44.png

I have this problem, too. Before using Lightweight Pipeline, our sprites batches well. But after using it, it stopped batching.

Is your custom shader multi-pass? i just checked the code and that is 1 reason why this message could pop up - we can’t dynamically batch multi-pass effects.

No. We’re just using Sprite/Default on a quad mesh, not on Sprite. We have a custom quad generation for sprites. We also tried a simple shader where we just sample the texture. It’s still not batching. Could it be because they have the same vertices? For example, 2 tile objects that are adjacent in a tilemap.

I can give you a copy of our project if you want to investigate. We do things differently like packing sprites at runtime. Not sure if that has an effect to batching,

Are you calculating the bounds of the Quad when generating it? Just had a similar problem and forcing that to true fixed it. (I was generating several submeshes, but only calculated bounds on the first).

I think we do but I’ll check again.

I’m also running into this issue. I’ve got 4 TextMeshPro objects in scene and they won’t z-fight but are being drawn separately adding 2-3 draw calls per frame depending on the state of the game.

i cant understand why moving the offset of uv of the quad doesn’t fix the draw calls… why that? when the sprite works with multiple sprites set the file of texture it work great, but what about if I want use atlasing and 1 texture 1 material instanced and multiple meshes, but I want to dynamic batch all those in just one draw call? why is that too hard? i just try to use the maintexture offset and uv but none of them fix the draw calls all those quads in all the ways draw them separated damn unity lol now I’m forced to use sprite renderer for them and this way coz that’s works for this clouds… I’m just worry about why its happening this here with the quad versions coz, so far I have understand this should be batched all together this quads that have no different z position have no light the game no shadows just 1 material 1 texture , different offset on uv, or different offset of main texture none of them reduce draw calls :frowning: all shaders tested… what happened here? anyone can have an idea? thanks