Search Unity

  1. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice

Batching Draw Calls With ECS

Discussion in 'Data Oriented Technology Stack' started by learc83, Mar 2, 2019.

  1. learc83

    learc83

    Joined:
    Feb 28, 2018
    Posts:
    41
    I've noticed that when I make an entity with a RenderMesh that has the same mesh and the same material, Unity still shows a new draw call per Entity.

    How does batching work with RenderMesh, is there something else I need to do? Here's the relevant part of the loop. If I make 100 of these I get 100 batches in the stats gizmo.

    Code (CSharp):
    1. var renderMesh = EntityManager.GetSharedComponentData<RenderMesh>(billboard);
    2.  
    3. renderMesh.mesh = _mesh;
    4. renderMesh.material = _mat;
    5.  
    6. EntityManager.SetSharedComponentData(billboard, renderMesh);
     
  2. Rotary-Heart

    Rotary-Heart

    Joined:
    Dec 18, 2012
    Posts:
    578
    Do you have Enabled GPU instancing on your material settings?
     
    JanetRGilbert and learc83 like this.
  3. learc83

    learc83

    Joined:
    Feb 28, 2018
    Posts:
    41
    That was it. Thanks.
     
  4. Deleted User

    Deleted User

    Guest

    What if I use RenderMesh in OpenGL ES 2.0 and hoping that dynamic batching works? Enable the editor option (enable dynamic batching) doesn't work.
     
    Nyanpas and Florian-G like this.
  5. hojjat-reyhane

    hojjat-reyhane

    Joined:
    Feb 4, 2014
    Posts:
    16
    What if the device doesn't support instancing?
    Is there any way to reduce the number of batches?
     
unityunity