Search Unity

Does unity batch combine models using the same materials,,?

Discussion in 'Scripting' started by bansheesoft, Oct 24, 2014.

  1. bansheesoft

    bansheesoft

    Joined:
    Oct 3, 2014
    Posts:
    62
    I am new to unity and I know in my previous engines we would spatially combine models using the same shader for occlusion culling and batch reduction. I was wondering if unity does this on game export? This is a HUGE thing for mobile dev and really any dev. If not that means I will have to make all the scene assets in partials in blender and imprt them (a real pain in the ass). And now the if not .... If not is scripting capable of this if not then is there another option. Currently my scene has a bunch of game objects sharing a shader but easy to construct in the editor in pieces. The other option is a blender nightmare.
     
  2. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
    You should be able to batch if you're using the same Material on everything. Also, renderers who aren't visible in any camera should get culled. This might be a Pro-only feature.

    I do know there's a bit more to it than that, mostly related to draw order and maybe how triangles are connected in models, but generally if the Material is shared you should be able batch the draw calls.

    At the top right of the Game View there is a "Stats" button that should tell you how many draw calls you're saving by batching, render time, # of triangles, etc.
     
  3. bansheesoft

    bansheesoft

    Joined:
    Oct 3, 2014
    Posts:
    62
    That's great! So I take this as it's automatically spatially batched together? I'd combine meshes in a divided zone and 1 call instead of 20?

    Thanks again I have never worked with an engine with such help ;)

    So automatic or do I have to do something to combine like material meshed in a zone
     
  4. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
  5. bansheesoft

    bansheesoft

    Joined:
    Oct 3, 2014
    Posts:
    62
  6. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Occulusion is Pro-only. Frustum culling (which is what Garth described with things being off-camera not being rendered) comes with Free.
     
  7. Sharp-Development

    Sharp-Development

    Joined:
    Nov 14, 2013
    Posts:
    353
    Batching in unity is somewhat limited. By default unity batches every !Mesh Renderer! whichs object is marked to be static. (Checkbox in the upper right corner of the inspector) However, they are not allowed to move, whatsoever.
    Moving Mesh Renderers can aswell be batched automatically but this is highly limited to low vertex counts.

    If you want to batch skinned mesh renderers you wont have luck with internal unity systems.
    However, there are a couple of good batching assets on the asset store which will provide you with static/dynamic edittime/runtime batching of both, mesh renderers and skinned mesh renderers.