Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

skinnedmesh performance

Discussion in 'iOS and tvOS' started by marjan, Jun 19, 2009.

  1. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    Another Newbie Question.

    So far, i developed my idea with static models importet from maya. Now, for the first time, i tried to get some animations in.

    Just to give you an idea: i have always 16 characters visible, lowpoly with ~ 120 Vertices. I am only using this one model, instantiated 16 times.

    So far this did result in ~30 FPS.
    ~20 Drawcalls, Tris 5.7k, Verts 4.6k
    Used Textures: 9 - 1.6 MB

    Now i added a basic rig. The rig only has 20 joints. i did 3 smal animations and got that back into unity. Smooth skinned.

    Now the performance dropped down to 15 - 20 FPS.
    ~20 Drawcalls, Tris 5.7k, Verts 4.6k
    Used Textures: 9 - 1.6 MB


    But the stats didn´t change.
    So the main difference is now, that the model does not have a meshfilter and mesh renderer Component, but a skinned mesh renderer component, which is actuallyy connectet to to rootjoint.

    How can it be, that it is so much slower, even if i don´t play any animation at all?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Due to the massive amount of matrix multiplications you add.

    For each bone you add another 4x4 matrix multiplication and then that piles up to further multiplications for the vertex position.

    In contrast to that, static meshes have exactly one matrix multiplication, thats the one of the objects root transform.


    With Unity iPhone 1.1 this should be much less impacting as UT, according informations on the roadmap and on the board, has integrated / is on the way to integrate a VFP based calculation for that which will reduce the work for the cpu
     
  3. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    Thanks for the response, but i don't get Why there is any such Operation at all. once the MESH and everything has been rendered and no Bone is moving, Why does this have an Impact? Unless à Joint is being moved, only transform should Be used and nö mesh calculation at all.

    anyways,
    Actually only 1 character Needs to be animated at Time. Sometimes up to Four. The other ones can stay Static.
    So what is a good workaround then? I could imagine using 2 Variants of the Models :a normal static One and a skinned One. Then, if Animation Needs to Start hide this One and instantiate the skinned One.
    Or combine characters meshes... In the end i will have either 4 or Even only two different Models. Four instances of each will build à Team. Which Shared the Same texture. But so far i did Not See any Resource on this and i don' t Know if Merging rigged models is possible at all nor whether this helps.
     
  4. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
    just to add my 1 week experience with skinned characters + unity iphone:

    i don't think it's the actual transformation being slow, but the skinning itself - you might try to set "Skinned Mesh's" animation quality to 2 bones to see some improvement.

    I'm currently testing performance with a single dancing character (~7k polys) , imported from 3dsmax and using Biped. The two most important factors seem to be vertex count together with the above mentioned quality parameter. (Logically: more vtx's = more deformation to do)

    But it's IMHO only the mesh-deform process which eats performance, not the pure poly display or transformation calculations... I've got the impression there would be a lot of room to optimize Unity iPhone in this regard....
     
  5. MikaMobile

    MikaMobile

    Joined:
    Jan 29, 2009
    Posts:
    845
    As others have said, limiting your skinned mesh to as few influences per vert as possible will help a lot. If your characters are fairly small on screen, you may even be able to get away with having rigid binding (just 1 bone per vert) without looking too ugly.

    The fact is you're gonna have to cut corners in some way or another, cus you're talking about 320 animated bones at once. That's asking a lot from the poor iPhone. Is there any way you can cut a bone or two out of your skeleton? Assuming your characters are humanoid, could you potentially lose a joint in the spine? I can see a simple humanoid getting as low as 3 bones per limb, and a simple 4 bone chain for the spine, so a total of 16. If the wrists don't have to animate seperately from the forearm, you could cut out another 2. And if there's anyway you can reduce your poly count further, I'd try it (although 120 isn't too shabby). What you can get away with will vary based on your visual style, and how large your enemies are on screen.
     
  6. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
    in my scene, the biped structure already has the minimal amount of bones in it and further reducing it did'nt make a big difference in some tests, but breaks the possibility to animate.
    It now has only 2 spine bones, 1 toe per foot (with only 1 bone). Fingers need to have 3 bones and 5 on each hand cause the char should be able to perform some gestures...
    Additionally i did'nt export the helpers on the tips (called nubs), so i think i can't optimize further on this side.
    I will have to further optimize the geometry as it seems, but that's a challenge without making HER look too blocky ;-)

    maybe some animation optimization could help ( i'm using mocap for testing ) but this should be handled by unity's importer and the keyframe reduction pretty well i guess ?
     
  7. Adam-Mechtley

    Adam-Mechtley

    Administrator

    Joined:
    Feb 5, 2007
    Posts:
    290
    What dreamora said is correct. It doesn't matter if your character is actually moving or not, the skinned mesh renderer still has to do all the matrix multiplication to determine the final positions of the vertices to render them.

    Another problem if you are running 1.0.x is animation. The more animations you have in your animation component (whether or not they are playing), the more math is being done to determine the final orientation of all your bones. Multiply this across 16 characters and it can become very taxing. You can see the impact of this by enabling the internal profiler when you build. Just like skinned mesh deformation, this is an issue that is fixed in 1.1 as it also utilizes the VFP.

    In the meantime, I would highly recommend any of the strategies that PirateNinjaAlliance recommended, as well as excluding any unnecessary animations. It is remarkable how little you can actually see on the screen in the end (for instance the Sims 3 characters' hands do not animate, but they still look perfectly believable). Double check your rigs too. Having the "nubs" as spacefrog called them does not matter as long as you do not bind them to your skin cluster in Max or Maya. Just make sure there is nothing in your skin cluster that shouldn't be. In the end though, that many characters with that much detail is probably too taxing for the phone in general, so you will have to make a sacrifice somewhere.
     
    XCO likes this.
  8. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    Ah so is that verified that if you don't include bones in your skin (Skin modifier in Max for example) then they don't get included in the hierarchy in Unity? I want to use Biped but it's impossible to get rid of the clavicles and the toes, which I don't need.

    Seems like that could cause issues though because the clavicles in particular are in the middle of the hierarchy. Thoughts?
     
  9. Adam-Mechtley

    Adam-Mechtley

    Administrator

    Joined:
    Feb 5, 2007
    Posts:
    290
    They will still need to be part of the hierarchy in unity, as the animation curves for rotation of the upper arm bones is computed in the space of the clavicles. However, this will not incur any additional skinning cost because they will not be part of the mesh's bind pose in unity.
     
  10. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    Ah excellent... that makes sense. So I can get down to a 15 bone skeleton using Biped then. Great info, thanks.