Search Unity

20 Draw calls from 1 camera?

Discussion in 'Editor & General Support' started by ClearRoseOfWar, Jul 20, 2016.

  1. ClearRoseOfWar

    ClearRoseOfWar

    Joined:
    Sep 6, 2015
    Posts:
    89
    I am creating an android game with which I am trying to reduce draw calls to a minimum. My main camera is creating 20 draw calls... how can I lower this?

    Edit: I can't seem to find much info about this on google / forum / answers.
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
  3. ClearRoseOfWar

    ClearRoseOfWar

    Joined:
    Sep 6, 2015
    Posts:
    89
    @fffMalzbier OH WOW! This should be handy! Let me play around with this now, and ill report back with more... Thanks!
     
  4. ClearRoseOfWar

    ClearRoseOfWar

    Joined:
    Sep 6, 2015
    Posts:
    89
    why does unity skip batching on some gameobjects? what I mean is that unity seems to batch 2 gameobjects together, but leaves one out, or does whatever it wants to really...

    I have 3 different shared materials, that are assigned to level pieces randomly. There should only be 3 dynamic batches total in that regard, right? Or am I not understanding something.
     
  5. ClearRoseOfWar

    ClearRoseOfWar

    Joined:
    Sep 6, 2015
    Posts:
    89
    A better Question:

    My spacecraft is built of several gameobjects using the same material with a script:

    Renderer mRenderer = GetComponent<Renderer>();
    Material mat = mRenderer.sharedMaterial;

    Yet, 2 gameobjects are batched, then 2 more are individually batched. want all 4 of those gameobjects batched together... what could be stopping it from batching?
     
  6. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    One part of the story:
    The other part is that there are a lot of restriction under that batching is done so it saves performance.
    My guess would be that your spaceship is not marked as batching static, that would mean only meshes with 300 verts or less are batched together (by the way of dynamic batching)

    For that non static geometry this rule applies this rule applies to:
    If you level geometry is not moving make sure its batching static to make unity batch it via static batching.

    A few more drawcalls do not kill the performance as long its not a massive amount of them or your target hardware is very slow.
     
  7. ClearRoseOfWar

    ClearRoseOfWar

    Joined:
    Sep 6, 2015
    Posts:
    89
    @fffMalzbier My level pieces dont move, only player does. However, I am using a custom emission shader I created, for the level pieces. Don't know too much about shaders though, so I dont know if my shader is allowing batching or not. Some of the pieces batch together, but others dont.

    My level peices never consist more than 20 faces or so though...

    My level geometry is already batched static.

    Here is my shader code:

    ///////////////////////////////////////////////////////////////
    Shader "Custom/MobileEmission" {

    Properties{
    _MainTex("Base (RGB)", 2D) = "white" {}

    _EmissiveMap("Emissive Map", 2D) = "white" {}
    _EmissionColor("Glow Color", Color) = (1,1,1,1)
    }

    SubShader{
    Lighting On
    Material
    {
    Emission[_EmissionColor]
    }

    Pass{
    SetTexture[_MainTex]{ combine texture }
    SetTexture[_EmissiveMap]{ combine primary lerp(texture) previous }
    }
    }

    }


    Thanks for your ongoing help dude!