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

Batching Draw Calls With ECS

Discussion in 'Entity Component System' 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:
    813
    Do you have Enabled GPU instancing on your material settings?
     
  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:
    49
    What if the device doesn't support instancing?
    Is there any way to reduce the number of batches?