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

Too many draw calls but using only one material

Discussion in 'Editor & General Support' started by -RaganorK-, Nov 21, 2014.

  1. -RaganorK-

    -RaganorK-

    Joined:
    May 9, 2014
    Posts:
    14
    Hello, I am using Unity for few months now, but still I know there are hell lot of things to learn. I have built some games (for android and iOS) and now I am planning to build big and better game. I am facing some issues which is out of the range of my solving capability.

    Coming straight to problem, my game is in a 3d city, with all city is is one single model. There are few more model like this, but all share same material. (I am using 2D Toolkit). So I should get only 1 draw call, but I am getting 4 draw calls, for each model.

    And secondly, I have decorated my city with road signs and other such stuffs (which are sprites). There are many of them, but the thing is, before adding the sprites, I was getting somewhat 25 draw calls, but now I am getting around 300+ draw calls. Please note I have used heavy number of sprites, but all of them are from same sprite collection.

    I am using Unity Free version 4.5.5 and 2dToolkit. If anyone could help me or support me in solving this problem I will be truly grateful.
    Thank you
     
  2. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    if you use only one shader on same material that would stay very low with atlased sprite, check also your object are static, else there is a batching tool in 2dtoolkit
     
  3. -RaganorK-

    -RaganorK-

    Joined:
    May 9, 2014
    Posts:
    14
    Thanx @Damien Delmarle for the quick reply. But I didn't get yhe point, "use only one shader on same material'. Can you elaborate this please. My objects are static.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    Is batching on? (static or dynamic?)
     
  5. -RaganorK-

    -RaganorK-

    Joined:
    May 9, 2014
    Posts:
    14
    @AcidArrow: Yes, dynamic batching is on ( i am using free version)
     
  6. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Dynamic batching is only working in a very limited range of vertices
    http://docs.unity3d.com/Manual/DrawCallBatching.html

    There are some other limitations that prevent batching from working. (You can read them on the documentation page)

    A good tip to find where all the draw calls are going , just switch on each major element of your scene and find out what makes the biggest jumps.
     
  7. -RaganorK-

    -RaganorK-

    Joined:
    May 9, 2014
    Posts:
    14
    @fffMalzbier: Well, I got the point. Since I am using little big models, the batching is not possible. But there is a building model, which don\t have even 50 vertices, (but have same material as of city), is increasing the draw call by 1. Means everytime I duplicate that building, 1 draw call is increasing. Whats the problem there ?
     
  8. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    What happens if you put the building for test ing in a empty scene and duplicate it?
    Does it still not batch?
     
  9. -RaganorK-

    -RaganorK-

    Joined:
    May 9, 2014
    Posts:
    14
    Then it is batching,
    Just to be clear, I will explain in short. There is a material which is applied on city. The building is also uses same material as city. But when I place building, it gives me one draw call "extra", though it shouldn't be, as the same material is shared by city. hope you got my point.
     
  10. inafield

    inafield

    Joined:
    Feb 26, 2013
    Posts:
    281
    It gives you an "extra" because it doesn't batch with the city at all. I believe it's "all or nothing".
     
  11. -RaganorK-

    -RaganorK-

    Joined:
    May 9, 2014
    Posts:
    14
    But it shouldn't, isn't it. It is using same material as city, and its vertex count is just in 50's. So it shouldn't give any draw call call at all. Correct me if i am wrong.
     
  12. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    With dynamic batching you will only get the small parts with matching material batched like your object with a vertex count of 50. It will NOT batch with anyting else. All of your small objects will get you 1 draw call (if batched correctly) and the city gives you another one. The only way to batch the city and the small objects is to use static batching.

    If you do not need to have the small objects moving in runtime you can try this function to combine the city with the small parts at the scene start.
    http://docs.unity3d.com/ScriptReference/Mesh.CombineMeshes.html