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

"Use a single skinned mesh renderer"

Discussion in 'General Discussion' started by Nanako, Nov 19, 2014.

  1. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    Hi all. I'm looking at http://docs.unity3d.com/Manual/ModelingOptimizedCharacters.html

    What sticks out to me there is the recommendation to only use one skinned mesh renderer. This is a bit outside of my knowledge, although i've done a fair bit of work with animations and rigged meshes, it's mostly as an artist.

    It says
    Ever the skeptic i am, i see that "seldom" doesn't say "never"..

    so i have two main questions:

    1. Can you think of any practical advantages for using multiple skinned meshes? Tell me about them

    2. Would any of the following be likely to require multiple skinned meshes,or be more efficient with them?

    • -Solid Wearable equipment in a game. Helmets, bracers, shoes, swords, etc. Assuming they're attached at runtime. (is there any way to not spend resources on the hidden geometry underneath?)
    • -Wearable equipment that requires rigging. Like flexible suits of armour, long boots, long gloves, oxygen masks attached to backpacks with a rubber hose, etc
    • -A drastic alteration to a character's mesh, like growing tentacles or an extra set of arms, that happens several hours into a game and is permanant
    • -The same kind of drastic alteration, but temporary/short term, and can be switched on and off with a low cooldown (in these last two situations, would it be more, or less efficient, to have the tentacles always there, but invisible until called?)
     
  2. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    anyone?
     
  3. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,500
    One quick example, multiple materials = multiple sub-meshes. Each of them has to be skinned for rendering. So, if you need stuff to have multiple materials then it's best to parent it rather than skin it where possible.
     
  4. SunnyChow

    SunnyChow

    Joined:
    Jun 6, 2013
    Posts:
    360
    let's say i want to make a character that his upper and lower part is customisable. It will be easier to code if it's two individual skinned mesh renderers sharing one set of bones. I guess the manual is talking about this situation
     
  5. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    1. The only 'advantage' I can think of could be flexibility, you could toggle clothing or harnesses at runtime etc. It's still recommended to try to keep the skin count low though.

    2. Equipment like helmets, swords etc wouldn't be skinned as they don't require bones, they would just be standard meshes attached to the bones. (That's how we do it at least).

    Wearable equipment like harnesses, gloves, the hose idea, probably would require a skinned mesh. But you'd be best just making them all one skinned mesh. Here we have multiple skinned meshes but in hindsight it was a mistake. In the event you need to have it toggle-able, at the expense of memory I'd suggest 2 skinned meshes that you alternate between. Or you could combine the meshes at runtime (not a trivial activity, but it has been done, and it's what most, if not all, big games companies use for customisable characters), you likely won't be able to do this without at least a small hiccup in play though, worth bearing in mind.

    Same as above for the tentacles/arms thing.

    If the change is short term, it's down to your implementation and performance budget, you could theoretically have a 'grows tentacles' powerup that simply unhides the extra skinned mesh for the tentacles for 30s or so. You just have to be able to budget for that (and remember to not animate while hidden).
     
    macrod likes this.
  6. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    What kind of tradeoff are we looking at?

    I think this is what i want :D a hiccup in play is fine, i see no issue with that. Isn't that pretty standard when changing gear anyways?

    besides, for my pupose at least, i mostly only intend to allow it between levels.

    How would i go about doing this? Is it non trivial in a computing sense, or in a "amount of work for the author" sense
     
  7. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Another reason to split a skinned mesh is if you're going to be using a cloth simulation on part of it.
     
  8. Farhan77

    Farhan77

    Joined:
    Nov 21, 2014
    Posts:
    1
    This is very nice post thanks!
     
    Last edited: Nov 24, 2014
  9. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    Tough to give an estimate, it will depend on the use cases. Short and sweet is more skinned mesh renderers are 'bad', so avoid where possible, but don't break your back over reducing from 2 to 1 for instance. The profiler will help you greatly to figure out what costs are associated with those meshes, sorry I can't be more specific, it's one of those things you'll just have to find out for your situation.

    Merging skinned meshes is non trivial in the sense that the current plugins available don't handle all the edge cases, and there's a fair few things to consider in such a system when doing it yourself.

    Off the top of my head, some of the main steps and issues of merging at runtime(or any time) are:

    - Combining the vertices in an order that still allows them optimised drawing (In theory the easiest part of this process).
    - Dealing with combining a static mesh (that isn't weighted to a bone), into a skin, where you need it to stick to a bone. (This isn't really necessary but it cuts drawcalls so it could be useful)
    - Atlasing the textures (including normals, spec maps etc) to be used in 1 material (for a single drawcall). This becomes difficult when combining things that would require too large an atlas.
    - UV merging, this shouldn't be too difficult, as the vertices should bring the info with them, but there are edge cases of merging that can produce artefacts.
    - Shader combining. Your final mesh needs a single material with a single shader, ideally the system should pick a relevant shader that keeps all functionality, then the difficult bit is making sure all the channel, texture UV's, and properties remain correct across all combined pieces. This is by far the most complicated part.

    You can certainly skip some of these bits and still have a perfectly fine system, but like I said, there are edge cases that will pull the whole thing down eventually. If you find something that covers all this, please let me know! This is still a problem for us that I would love to solve, and I just don't get the time to look into writing it myself.

    Here's the best script I've found so far, it deals with most things, but just didn't work well enough for us to use in the end:

    http://wiki.unity3d.com/index.php?title=SkinnedMeshCombiner

    There are some paid assets on the store that I haven't looked into, but look promising too, might be worth checking out if you get really serious about this.
     
    macrod and Nanako like this.
  10. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    wow, thamnks for this incredibly details post. +1 for ya

    what exactly is too large? what's the upper limit unity can handle? is this stage necessary? can i have one skinned mesh with two drawcalls?
     
  11. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    I believe the limit is 4096 x 4096 in Unity 4 and below, though Unity 5 will support 8192 x 8192.
    You have to consider that the GPU of the client has to support this texture size too.
    (I'm actually not sure what happens when the texture size isn't supported, I assume either a crash or it isn't loaded in)

    You can indeed have one skinned mesh with 2 materials (and hence 2 drawcalls), which will increase the performance spent on rendering the mesh, but you would save some slightly for animations, probably morphs too. So it is slightly beneficial over 2 entirely separate meshes.