Search Unity

New to Unity. What is slowing this down?

Discussion in 'Works In Progress' started by Patrick234, Jul 1, 2014.

  1. Patrick234

    Patrick234

    Joined:
    Jun 25, 2014
    Posts:
    88
    Hi,

    Thanks for reading this topic! Im new to unity and i have (probably) run into a newbie problem. I have over 9000 drawcalls!

    First off, I will be using Unity because of 4 reasons:
    - iOS support (50/50 focus for me) other 50 is Windows,Mac etc..
    - Easy support for advanced graphics
    - Great Asset store and active communty
    - C# is easypease for me > small learning curve

    I used to make games for fun in another language but was limited to DirectX7!! had to write all filters myself, and advanced lighting just wasn't possible. Etc..

    Therefore, im ramping my first game project full with visual goodies, been itching todo this for some time. Its all about visuals and dynamics for this one. However, I need to learn how todo it properly and professionaly with the needed tricks and optimizations. Eventualy im hoping to make a optimized version for iOS this is defently a goal on the list. But would love to unleash the full potential for PC users.

    Currently i got this;


    Heres a download if you want to play arround;
    http://www.filedropper.com/teest

    Im using the Unity PRO Trail i have 28 or 29 days left.

    My current FPS on my (budget-grade game pc @ $500) is a miserable 30FPS.
    (p.s. Lightmapping is no option! It has to be dynamic because of its procedural nature.)

    -Patrick
     
    Last edited: Jul 1, 2014
  2. Patrick234

    Patrick234

    Joined:
    Jun 25, 2014
    Posts:
    88
    Well i never expected to solve this. I done some more testing and figured out that it is each individual mesh, or surface rather, that needs a drawcall when using dynamic lights and shadows. So i had a level with even twice the amount of verticies and faces run at only 20+ drawcalls!

    Then i did some math
    2 calls per simple object * 64 * 64 tiles = 8192 + The light-stones + Characters = 9000+

    So this is problematic to TileEd plugin for Unity. Hmmmm. Anyone knows of an Exporter function or TileEditor that "Merges" the terrain into 1 mesh?
     
  3. Kellyrayj

    Kellyrayj

    Joined:
    Aug 29, 2011
    Posts:
    913
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,095
    Use the combine mesh utility from the Standard Asset Scripts package and batch your tiles onto one atlas. So one texture for all the different quads. You can make these quads in an art package reference the correct tile. For a scene like your screenshot I would certainly have no more than 100 draw calls even with all the post fx.

    It's very doable, its a matter of learning how to do so for this engine and modern hardware, then it will run some ridiculous fps up to a thousand or so.

    The poster above has some handy links. In short, combine textures, combine meshes. Above all, things that need to be merged need the same material. Atlasing helps here.
     
  5. Patrick234

    Patrick234

    Joined:
    Jun 25, 2014
    Posts:
    88
    Combine textures; Check
    Combine meshes; Fail.

    Tried MeshMerger, seems to lose control and renders the mesh null.
    Tried Mesh.Combine this works, but the terrains has quite a few errors in it :(

    @hippo; Sounds good.. I could not find the Unity Package/Script you are refering to however? Could you post the steps here?

    -edit-
    Would this be any good or is it about the same as the scripts suggested here?
    https://www.assetstore.unity3d.com/en/#!content/5017
    (I assume this package is much more sophisticated?)
     
    Last edited: Jul 1, 2014
  6. rbx775

    rbx775

    Joined:
    Aug 16, 2010
    Posts:
    100
    Hey there,

    Regarding the Batching:
    Are those World tiles set to static ? Try that too if not.

    Also: I suppose you use Forward rendering since => mobile...

    So I hope you have in mind that a Mesh in Forward Rendering has to be rendered once for every light that its affected by.

    and I see at least one global directional and many small local lights...

    Keep the global directional but try to fake the small local lights,
    that would be another suggestion. :)
     
  7. Patrick234

    Patrick234

    Joined:
    Jun 25, 2014
    Posts:
    88
    Hey,

    Sorry for late reply, i hadnt noticed this was updated. I set things to static (whats the biggest optimization of that?) I indeed got a 5 to 10fps boost out of that.

    What do you mean by "I suppose you use Forward rendering since => mobile..." ? Is that something i should change and what does it do?

    Cutting on number of light sources is undesirable. I know i could fake it, but i really want this to be as expensive as possible to get to know the problems, so i can solve them, to see what is possible in the end.

    I hate surpises when doing a project so i start with looking for problems. :)
     
  8. Deleted User

    Deleted User

    Guest

    Always check the following:

    Use deferred rendering if possible.
    I see you're using Unity terrain, mess around with the base map dist. and pixel error and disable cast shadow.
    Bake everything, then set your shadow distance enough to cover your character.
    Use batching where applicable.
    Use Occlusion culling once you're finished with your scene.
    Share as many materials as possible.

    As hippo says, merge as many meshes as possible and cut down the complexity of physics attributes.

    I got my scene from 12,000 to around 450 draw calls after constant tweaking.
     
  9. Patrick234

    Patrick234

    Joined:
    Jun 25, 2014
    Posts:
    88
    Hey, thanks for these tips! Would you also like to motivate them so i can draw a better learning from it?

    Use deferred rendering if possible. - Check
    I see you're using Unity terrain (its made of tile pieces, with a custom collision map made in blender)
    Bake everything - ?
    Use batching where applicable. - ?
    Use Occlusion culling once you're finished with your scene. - Is this done by Unity or should i write my own?
    Share as many materials as possible. - Check
     
  10. christides11

    christides11

    Joined:
    May 19, 2012
    Posts:
    667
  11. Deleted User

    Deleted User

    Guest

    "Patrick234, post: 1688199, member: 647912"]Hey, thanks for these tips! Would you also like to motivate them so i can draw a better learning from it?

    Use deferred rendering if possible. - Check
    I see you're using Unity terrain (its made of tile pieces, with a custom collision map made in blender)
    Bake everything - http://docs.unity3d.com/Manual/Lightmapping.html
    Use batching where applicable. - http://docs.unity3d.com/Manual/DrawCallBatching.html
    Use Occlusion culling once you're finished with your scene. - Is this done by Unity or should i write my own? http://blogs.unity3d.com/2013/12/26/occlusion-culling-in-unity-4-3-best-practices/ ---- http://docs.unity3d.com/Manual/OcclusionCulling.html
    Share as many materials as possible. - Check

    Also work on your google fu :).
     
unityunity