Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Static batching Behaviour

Discussion in 'Editor & General Support' started by snowinrain, Mar 22, 2021.

  1. snowinrain

    snowinrain

    Joined:
    Jan 17, 2016
    Posts:
    14
    Hi all,

    There is a lot of vegetation in the scene (I used this: https://assetstore.unity.com/packages/templates/tutorials/3d-game-kit-115747), so I marked them static.
    upload_2021-3-22_9-42-9.png

    To check whether static batching is working, I disabled them at the beginning, click "Play" button, check the profiler, then turn them on, check the profiler again (I turn on/off the static objects few times, not only once). The FPS is decreased from 150 to 75. Below is the result.

    Before:
    upload_2021-3-22_9-38-18.png

    After:
    upload_2021-3-22_9-38-48.png

    In my opinion, the "draw calls" should be the same or not much different no matter I turn on/off static objects. Did I understand correctly?

    UPDATE:
    I tried to uncheck Static and see what difference now, and below is the result.

    Uncheck Static:
    upload_2021-3-22_17-57-23.png

    As you see, Instancing is used instead of static batch. And this is ridiculous, draw calls are much lower than static batch.

    Is is expected behaviour because I turn on GPU Instancing for few major materials only without custom code ?
     
    Last edited: Mar 22, 2021
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,273
    Static batching shines when it can combine multiple different Objects with the same material but different meshes.
    If you have the same mesh and the same material Material instancing is so much more efficient since it only does one call from the CPU to the GPU with the mesh, material and a list of where the objects should go.
     
    snowinrain likes this.
  3. snowinrain

    snowinrain

    Joined:
    Jan 17, 2016
    Posts:
    14
    Thanks for explanation