Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Game Optimization questions - mobile

Discussion in 'Editor & General Support' started by ForceVFX, Aug 7, 2014.

  1. ForceVFX

    ForceVFX

    Joined:
    Jan 21, 2011
    Posts:
    612
    Hello, I have a some questions that have been rolling around in my mind.

    1). Draw calls: 1 3D Object, 2 materials/ textures, all atlased on one texture..but the UVs are overlapping.
    does that texture atlas becomes worthless?, because of overlapping UV's.(if UV overlaps/it is two draw calls?
    I purchased some assets that 'showed' atlas textures, but saw in maya that the UV's were tangled/overlapping.

    2) Animation vs. Draw calls, Android: I have a airplane with 2 ailerons / 2 flaps / 1 elevator, 1 rudder, 1 spinning Prop, and the body..with normal maps.. so that is 9 draw calls right there + bump.. Could I just rig those elements, animate up/down...have one draw call?? my question, which is greater Per Frame overhead, For android mobile? Can I get that down to 2, specular/bump draw calls? that plane is one texture...is that faster than the multiple draw calls @ 1024X1024?

    It's a lot of work for a test..so I thought I get some more informed opinions here..

    Thanks.

    Patrick
     
  2. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    1) Overlapping UVs should not impact draw calls at all, just the number of meshes and materials per mesh.

    2) If it was me, I would probably rig and animate them, which would be only as many draw calls as there are materials. You can them export them as a single skinned object or a collection of meshes parented to the joints. In any event, I find it easier to think of the plane as a single object and to allow myself to play animations on it if/when that makes sense.
     
    Last edited: Aug 8, 2014
  3. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well, draw calls do influence frame rate, but one major overhead for some android devices is texture size: most low-end tabs, (like my good 'ol pendo pad... ;)) simply don't have the memory bandwidth to load big textures. and yes, where possible, try to reduce your textures down to one per-object to reduce the amount of textures needed.

    and MakeCodeNow has a good point: if you are doing a plane game, rig the ailerons and other moving parts on the plane! not only will it save you time, it will perform a lot better too.

    that also brings things down to another good point: optimize your scripts so that they execute in under 5ms, write efficient and good-looking shaders (or use the mobile ones... :)) and your game will fly! :D

    I have proof that this works, and so do a lot of people, as I am working on my own android game atm. if you wish me to do so, I will post a screenshot later and list what I used. (mine is a little different though; it uses the FFP for performance reasons... ;))
     
  4. ForceVFX

    ForceVFX

    Joined:
    Jan 21, 2011
    Posts:
    612
    Yeah, I feel pretty stupid, not doing this from the start..the planes are in Poser format, which I can export to collada/fbx converter, saving the rig and animations...I did buy Sector Complete, I am about to test on 4X4 2048 terrain mesh, for a size of 4096 squared, split into 3 LODs/3 Lod Textures, 5,000+ buildings(3 atlased tetxures)...I'll post more on your thread..Thanks for the help!!
     
  5. ForceVFX

    ForceVFX

    Joined:
    Jan 21, 2011
    Posts:
    612
    That is good advice, my first release was "just get it out there", now I am about squeezing every bit of performance from unity pro that I can...now that I have profiler, I can optimize like crazy!! (it's actually not that fun)..thanks for the feedback. Patrick

    p.s what is it FFP ??
     
  6. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Oh, sorry about not cleaning that up, it stands for Fixed-function Pipeline, i.e. N64-quality graphics! ;)

    And nice to hear my advice helped you! feel free to give me a yell if you need anything. :)
     
  7. ForceVFX

    ForceVFX

    Joined:
    Jan 21, 2011
    Posts:
    612
    My test


    Before: 20,000 Tris / 12 draw calls


    After: 8,000 Tris 1 Draw Call (any less poly's, becomes really destructive!!) Good enough for android?
     
  8. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    It's definitely a big improvement. Whether it's good enough for android depends on how many planes are visible at once and which android devices you are targeting. The only way to really know is to test and profile :)
     
  9. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Not bad man! :)
    Might have to ask all of you though: how come one of my games is taking 8-12 draw calls just to draw ONE CAR?

    Here's the car (rendered in blender) :
    LightCar_Render.png
    It is only something like 200 polys, which is really small by today's standards. it also only has one material! so how come it i taking so many to draw one car? Also note I am using the most basic lighting shader you can get. (no surface, it's pure CG I wrote myself)

    @MakeCodeNow: Remember that profiler is pro-only... ;) Actually, time to yell for a profiler! :)
     
  10. ForceVFX

    ForceVFX

    Joined:
    Jan 21, 2011
    Posts:
    612
    4 draw calls - Tires
    1 draw calls - Body
    2 draw calls - Light Covers
    2 draw calls - Lights
    ------------------
    9 Draw calls??
    for some reason - your shader , is forcing unity to render it this way...
    -Are they separate meshes w/ separate materials/textures?

    It was the same issue with me, just atlas textures by material, combine meshes, rig smooth/rigid, otherwise
    separate dynamic mesh parts even on the same texture map = separate draw calls.
    but, without the actual topology and textures..it's tough to diagnose...
    so...??
     
  11. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well, your calculation's a little off: those light covers & lights are actually textures. ;)
    Also, would it take more to draw a UV map with separate faces? that could be the problem. and yes, multi-materials will do this too, I already addressed that problem.

    I did forget one thing: there is a separate material for the tyres, might give a go at fixing that, so there's only one for all of the car. Oh, and for an interesting comparison: I have a game that draws in about 15 drawcalls, WITH a single skinned mesh & tunnels! :)

    BTW, here's the mesh in blender:
    Untitled.png
    This should help give you an idea of the mesh topology. (which, i would imagine, would be possibly the worst car topology on earth! ;))

    EDIT: And the texture:
    LightCar.png

    EDIT2: Who agrees this is turning into a general android optimization thread? :D
     
    Last edited: Aug 13, 2014
  12. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558