Legacy Documentation: Version 4.6
Language: English
Mesh Renderer
Text Mesh

Skinned Mesh Renderer

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Scripting

Unity uses the Skinned Mesh Renderer component to render Bone animations, where the shape of the mesh is deformed by predefined animation sequences. This technique is useful for characters and other objects whose joints bend (as opposed to a machine where joints are more like hinges).

A Skinned Mesh Renderer is automatically added to any mesh that needs it at import time.

Properties

Property: Function:
Cast Shadows (Pro only) If enabled, Mesh will cast shadows when a suitable Light shines on it.
Receive Shadows (Pro only) If enabled, the Mesh will show shadows that are cast upon it by other objects.
Materials The list of Materials the model will be rendered with.
Use Light Probes Does the mesh take Light Probes into account?
Quality The maximum number of bones that can affect any given vertex.
Update When Offscreen If enabled, the Skinned Mesh will be updated even when it can’t be seen by any camera. If disabled, the animations themselves will also stop running when the object is offscreen.
Mesh Mesh used by this renderer.
Root Bone The bone that is the “root” of the animation (ie, the bone relative to which all the others move).
Bounds The bounding volume that is used to determine when the mesh is offscreen. The bounds are precalculated on import from the Mesh and animations in the model file and are displayed as a wireframe around the model in the Scene View.

Details

Bones are invisible objects inside a skinned mesh that affect the way the mesh is deformed during animation. The basic idea is that the bones are joined together to form a hierarchical “skeleton” and the animation is defined by rotating the joints of the skeleton to make it move. Each bone is attached to some of the vertices of the surrounding mesh. When the animation is played, the vertices move with the bone(s) they are connected to, so the “skin” follows the movement of the skeleton. At a simple joint (an elbow, say), the mesh vertices are affected by both of the bones that meet there, and the mesh will stretch and rotate realistically as the joint bends. In more complex situations, more than two bones will affect a particular area of mesh, resulting in more subtle movements.

Although a skinned mesh is most commonly used with predefined animations, it is also possible to attach Rigidbodies to each bone in a skeleton to put it under the control of the physics engine. This is typically used to create the “ragdoll” effect, where a character’s limbs flail after being thrown or struck by an explosion.

Quality

Unity can skin every vertex with one, two or four bones. Using four bones gives the best results but this comes with a higher processing overhead. Games commonly use two bone weights, which is a good compromise between visual quality and performance.

If the Quality is set to Automatic, the Blend Weights value from the Quality Settings will be used. This allows end-users to choose the quality setting themselves and get the desired balance of animation quality and framerate.

Update When Offscreen

By default, skinned meshes that are not visible to any camera are not updated, since this avoids wasting CPU time. The skinning is not updated until the mesh comes back on screen.

The object’s visibility is determined from the Mesh’s Bounds (ie, the entire bounding volume must be outside the view frustum of any active camera). However, the true bounding volume of an animated mesh can change as the animation plays (eg, the volume will get tall if the character raises his hand in the air). Unity takes into account all attached animations when calculating the maximum bounding volume but there are cases when the bounds can’t be calculated to anticipate every possible use case. Each of following situations, for example, become a problem when they push bones or vertices out of the precalculated bounding volume:

  • animations added at run-time;
  • additive animations;
  • procedurally changing the positions of bones from a script;
  • using vertex shaders which can push vertices outside the precalculated bounds;
  • using ragdolls.

In those cases there are two solutions:

  1. modify the Bounds to match potential bounding volume of your mesh;
  2. enable Update When Offscreen to skin and render the skinned mesh all the time.

You should usually use the first option since it has better performance. However, the second option is preferable if performance is not a major concern or if you can’t predict the size of your bounding volume (when using ragdolls, say).

In order to make Skinned Meshes work better with ragdolls, Unity will automatically remap the Skinned Mesh Renderer to the root bone on import. However Unity only does this if there is a single Skinned Mesh Renderer in the model file. This means that if there is some reason why you can’t attach all Skinned Mesh Renderers to the root bone or a child and you use ragdolls, you should turn off this optimization.

Importing Skinned Meshes

Currently, skinned meshes can be imported from:

  • Maya
  • Cinema4D
  • 3D Studio Max
  • Blender
  • Cheetah 3D
  • XSI
  • Any other tool that supports the FBX format

On mobiles, Unity handles skinning on the CPU with hand-coded neon/vfp assembly. A caveat is that normals/tangents are not normalized, so if you are writing your own shaders, you should take handle the normalization youself. If you are using surface shaders, however, the normalization is handled automatically by Unity.

Mesh Renderer
Text Mesh