Search Unity

Dynamic batching is behaving odd

Discussion in 'General Graphics' started by BakeMyCake, Feb 4, 2019.

  1. BakeMyCake

    BakeMyCake

    Joined:
    May 8, 2017
    Posts:
    175
    People, I am confused.
    What does it mean in the frame debugger when you get unexpected extra events without an explanation as to why dynamic batching didn't mop them up?
    upload_2019-2-4_21-35-5.png
    As you can see from the image I have some straggler models not being drawn with the rest and it doesn't provide any info. They all share the same material but none of them offer a reason why they aren't batched.

    Should I interpret this as an indication that a batch reached it's maximum combined size? My scene is 5k vertices total shouldn't it fit into one batch? If the scene didn't fit into one batch shouldn't the rest be drawn in the second batch instead of being drawn separately, or does batching stop after the first batch is filled?

    What is quite strange is that I have 3 materials - a material for vertex-lit meshes, a material for unlit particles and a material for transparent effects. And they seem to batch together which makes no sense according to documentation. Shouldn't this break batching?
     
    Shorely likes this.
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    This might be a side effect of particles currently being missing in the frame debugger. We have a fix coming very soon for it in 2018.3.. what version are you on?
     
    Shorely likes this.
  3. BakeMyCake

    BakeMyCake

    Joined:
    May 8, 2017
    Posts:
    175
    I'm on 2018.3.
    From my observations there are specific cases where if objects happen to align well everything batches together. Literally the frame debugger shows the entire scene(excluding post processing) with particles and transparent objects being rendered in the clear event. But most times some meshes end up left out of the batch. There might be good reasons for it, I just want to understand the system better.

    I still haven't got a clue how batching manages to draw transparent effects and opaque geometry at once. Or maybe it doesn't, but it makes it look that way?
     
    Shorely likes this.
  4. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Yeah this bit sounds like the bug we are soon releasing a fix for. I think it could be causing the other side-effects you describe too, making the whole thing look quite confusing. I recommend rechecking it when this bugfix lands: https://issuetracker.unity3d.com/issues/frame-debugger-not-showing-draw-calls-from-particle-systems

    I am hoping it gets approved for 2018.3.6 or 2018.3.7 at the latest.