Search Unity

Skinned Meshes, Static Batching and Performance

Discussion in 'iOS and tvOS' started by heeger, Mar 17, 2010.

  1. heeger

    heeger

    Joined:
    Aug 25, 2009
    Posts:
    4
    I've been lurking these forums for quite a while now, and have had great use of all the wonderful info stored here. Now however I cant seem to find the answer to my current question. I've started working some with bones and skinned meshes, which is a first for me, so you must excuse my ignorance :)

    I have a scene with lots of "static" objects that each has a bone structure. My current mockup gives every object 8 bones and there is about 30-40 object in the camera view frustrum almost all the time. I need the bones in these objects so I can deform them a runtime. My idea is to have a simplified model of the object in the scene from scratch, and when the object gets damaged it will be swapped with it's boned sibling. If the object gets damaged enough it will be destroyed and swapped out for a wreckage model without any bones.

    My concerns are whether it is possible to achieve this with a proper framerate on the iPhone. If the player choses to apply a little damage to a lot of the objects, I could potentially have 40 skinned meshes (x8 bones) in the cameras view frustrum. The good this is though that none of these skinned meshes would be moving in any way. Are the skinned meshes/bones a real performance hit even when they are static?

    I was also wondering if skinned meshes can be static at all? And if yes, will they be batched, and will they stay batched after having been deformed? (All are of course the same material)

    I don't have the pro/advanced version yet, so I cant really check whether the skinned meshes are actually being batched :)
     
  2. ReJ

    ReJ

    Unity Technologies

    Joined:
    Nov 1, 2008
    Posts:
    378
    No, skinned meshes can not be statically batched. But if most of your skinned objects are visible all the time - you can just combine them together into one mesh - either in your modeling package or using Editor scripting.
     
  3. heeger

    heeger

    Joined:
    Aug 25, 2009
    Posts:
    4
    Thanks for the reply :D

    The problem is that most of my skinned meshes are not visible all the time. My gameworld consist of 100s's of object where maximum 40 (this number is set a bit high, just to be on the safe side) will be in the camera frustrum.

    As far as I could understand, combining the meshes, will mean that all of the verts/tris will be processed, even though only a part of the combined mesh is on screen?

    Would it perhaps be possible to convert the deformed skinned mesh back into a "normal" mesh, when the player hasn't tampered with the object for a wee while? That way the mesh would get to benefit from static batching?

    /heeger
     
  4. 3dgrinder

    3dgrinder

    Joined:
    Oct 21, 2008
    Posts:
    249
    ReJ gave ans of your query. I can give a little explanation on ReJ reply.

    1. Skinned Mesh will not be consider by batch system.
    2. When you group different mesh into a mesh either from modeling pack or Unity Script, it will increase the Bound area. All render system calculate the intersection with bound area of an object by render camera frustum. So, if any part of the combined mesh bound area intersect by the frustum, then whole mesh will be candidate for rendering.

    Bottom line is, by Skinned mesh it will tough to keep the frame rate for your case. In my opinion, you can do:

    1. Create different LOD for each mesh[ As you need to show different mesh].
    2. Keep each mesh within batching limit.
    3. Take batching befit.

    May be you are using bone due to deform the mesh more practically. It's a trade off between design and tech limitation :)