Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Dynamic batching weird(?) behaviour

Discussion in 'General Graphics' started by Nemlar, Sep 27, 2019.

  1. Nemlar

    Nemlar

    Joined:
    Apr 19, 2019
    Posts:
    2
    Hi everyone!

    (using Unity 2019.2.5.f1 Personal)

    I'm seeing this weird(?) behaviour with dynamic batching...
    I have a very simple scene with 3 cubes and 1 sphere all sharing the same material.
    Depending on the sphere's position I get
    Batches: 3 and Saved by Batching : 2 OR
    Batches: 4 and Saved by Batching : 1

    One of the batches is due to the default scene. For some reason even with an empty scene (and NO skybox) Unity still makes a draw call. I've read that it might be the default plane or that it might be Direct3D,; if anyone knows more about this please share any info. The image below is from an empty scene. As you can see in the red box the result is 1 Batch (2 Tris, 4 Verts) although there are NO objects in the scene:
    defaultSene.png

    The image below is a screenshot from my scene with the 3 cubes and 1 sphere. I also include the sphere's transform as it plays a role in the question. Batching works here as expected. There are 3 Batches (1 for the default scene, 1 for the sphere and 1 for the cubes) and 2 are saved by batching (because the cubes are batched together): scene1.png
    But when the sphere is moved just a bit to the left (it happens with other position changes too) suddenly we get a different batching result. Now we get Batching: 4 and Saved by Batching: 1. Which means that because of that small change in the sphere's X position, one of the cubes stops being batched with the other two! (There is NO other change in the scene.) scene2.png

    Does anyone have any ideas why this is happening? How does moving the sphere (which was not even part of the batching set) affect the cubes' batching behaviour???

    Thank you!
     
    Last edited: Sep 27, 2019
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Hi!
    The objects are sourced roughly by distance from camera. If the position of an object changes, the sorting order might also change, which, in turn, affects the batching.