Search Unity

  1. We would like to hear your feedback about Unity and our products. Click here for more information.
    Dismiss Notice

static batching not working with lightmapped objects?

Discussion in 'General Graphics' started by IgorAherne, May 29, 2018.

  1. IgorAherne

    IgorAherne

    Joined:
    May 15, 2013
    Posts:
    339
    Hello,

    I am trying to understand how the Frame Debugger works, with Static Batching.

    It seems to avoid batching two objects that use the same material, are both static and are using the same lightmap texture.

    Please note, I am using GPU instancing for most objects:
    isntancing.JPG

    Please have a look at the screenshot, each half shows the stats of "pole_03 (6)" and "pole_03 (2)" respectively.

    "A"
    shows second pole is selected in the hierarchy, "B" is the Unity's reason, "C" shows that lightmap is actually the same ...Doesn't static batching work with lightmaps?

    static batching0.jpg

    Not sure if it made difference, but I've baked lightmaps after marking all the objects as Batch Static

    ---------------------

    From what I understand, the only static batches I am getting are shown as "Static Batch" in the hierarchy (at the bottom), and all other elements above them are not batched :( For example:
    • Draw Mesh mobile_pole_03 (6) <--not batched, drawn separatelly (even if has GPU instanced material)
    • DrawMesh mobile_pole03 (2) <---not batched, drawn separatelly
    • Draw Mesh dead_tree_01_a_trunk <--not batched, drawn separatelly
    • Static Batch <---some objects were batched
    • Static Batch <---some objects were batched

    Is this correct? Also, lightmaps (Non-directional) and static batching are not allowed together?
    I am using Deferred Rendering, iOS Metal, Unity 2017.1
     
  2. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    302
    We Have exactly the same problem, I read in manual, that objects are batched by instancing together if lightmaps are the same, but it dont work, even if lightmap atlas are the same unity wont batch it together. Why it is like that if manual says it should work.
     
  3. IgorAherne

    IgorAherne

    Joined:
    May 15, 2013
    Posts:
    339
    EDIT (removed what I wrote in this particular post)

    I received a reply from unity support. Static batching is designed to only work during Play mode.
    It won't work unless you are actually playing the game in editor.

    Hit play, and it should be working
     
    Last edited: Mar 25, 2019
    jrumps likes this.
  4. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    302
    Thanks fgor reply. but I'm talking about GPU Instancing, it just font work if lightmap static is check on objects. according to unity manual is should, but it still gives info taht cant bathc because "object arelightmapped" I'm using the same lightmap atlass for that objects. (I dont want to use static batching cause it doesnt support LOD, and GPU instancing is supporting that and dont add memory.)
     
  5. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    302
    I hope someone from @Unity could answer that it would be great to hear official statement :)
    Regards