Search Unity

Why is combining geometry in Maya better than Unity batching ?

Discussion in 'General Graphics' started by rosssssss, Apr 27, 2018.

  1. rosssssss

    rosssssss

    Joined:
    Jan 27, 2017
    Posts:
    70
    So...
    The 3D artist on this project gave me a tree with 100 clumps on it, each clump was a separate object in Unity - they all shared the same mesh which was just a single quad.
    Trying to draw 300 of these on my pc with a GTX 1070 ... caused the frame to die to 7 to 9 fps... (VR project ) depending on if i used static or dynamic batching or GPU Instancing on the material...

    I then asked him to give me the same tree model but with all the clumps of leaves combined into a single mesh.
    When he did this suddenly the frame rate was flying ...
    i could put 6000 trees in and still run at 45fps.... (compared to 300 at 7fps)
    So.. what i can't really understand is why...
    The version with the non-combined meshes was creating many many more gameobjects in the scene... it actually created two per clump... meaning each tree had about 450... so with 300 trees that's a lot. whereas the combined version only had 3 game objects per tree.
    But is game object overhead the whole story... the GPU processor shows a massively increased draw time for the non combined version...
    even when marked as static.
    My understanding was that unity would combine all those meshes anyway - in a performance optimal way. But obviously it's not.
    Any clues would be much appreciated.
    Thanks
     
  2. Yuvii

    Yuvii

    Joined:
    May 20, 2014
    Posts:
    55
    Hey,

    So far as i know, (i had the same issue with some kind of vegation meshes) Unity tries to combine all gameobjects that have the same materials and are statics (don't forget to bake lightmap). But anyway, 300 x 450 (135K) game objects can't be as good in performances as 6K x 3 (18K) game objects.

    I don't know exactly what Unity calculates (like drawcalls) but it still have to calculate 135K Game Objects instead of 18K so it may be legit.

    The Editor Overhead can be part of the issue too, you now, because you still can select every game object independently. Unity sees every gameObject as independant entities, so the more you have, the more performances it takes.

    Since i had this issue, i always try to combine myself all gameobject that i can in 3DsMax before importing them in Unity.

    i know i didn't answer your post at all, this is just my point of view, but everything is good to take i guess :D

    Cheers!
     
  3. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    Yuvii answered with a chunk of good info. :D

    The more seperate objects you have in a scene, means that the game engine
    has alot more calculations to do.

    But, if most of those objects, are combined into a single mesh/object, the
    game engine has less calculations to do. And you get a higher fps.
     
    Last edited: Apr 28, 2018
    Yuvii likes this.
  4. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    Okay: here's an example.

    Let's say you're making a Forest stage, similar to the one in Dead or Alive 3.
    If you make the ground, then create a tree trunk, and duplicate it 200 times
    to make a whole forest. The game engine has to calculate and process.
    a) The ground. (1 object)
    b) And 200 trees that are all, individual seperate objects. (200 seperate objects)

    In other words, the game engine has a total, of 201 objects to calculate. :p


    But, with clever tactics, if you were to extrude those tree trunks from
    the ground mesh and shape them into tree trunks....

    Or: Create one single tree trunk and duplicate it 200 times, and then with
    basic modelling skills, remove some of the faces, of the bottom parts of the
    trunks of the tree, and weld and join them, to the vertices/faces of the
    ground mesh.....

    ....the game engine, might just have to calculate everything, as 1 object.
    So you have an entire Forest stage, ground + trees, which is just 1 object. :p

    It's really an interesting thing, to think about.

    Now all we need, is Kasumi, Ayane and the others, to battle each other. :D
     
    Last edited: Apr 28, 2018