Video not yet available
WARNING: This document is work in progress. Parts of the text may contain errors. Be prepared for frequent changes!
This tutorial gives a broad overview about the process of Weighting with Blender 2.67 or newer. I will cover
The basic principles of weighting
First things first. Our goal is to have an easy way to animate our meshes with the least amount of distortion. It is most important to never forget that this is what we want to achieve!
The straight forward approach to reach our goal would be to model each pose separately, and later use a sequence of mesh models to animate the character. However that is not a practical solution. we would end up with tens, even hundreds of separate meshes just to animate one single character. Indeed, very impracticable.
So, instead of defining many separate mesh models, we create an easy to handle abstract model of our mesh, the skeleton. The skeleton is a set of bones (26 for OpenSim and similar). Each of the bones can influence the entire mesh when it is moved around. The influence of each bone on the mesh is defined separately for each vertex. It can be expressed as a value in the range [0.0 … 1.0] where:
- A value of 0.0 means: whatever the bone does, it does not affect the vertex.
- A value of 1.0 means: the vertex moves in parallel to the bone.
- Any value in between 0 and 1 indicates the amount of influence on the corresponding vertex.
So actually we need to define a mapping between each bone of the skeleton and each vertex of the mesh, that is: we define one weight map for each bone of the character. Thus when the character’s skeleton moves, then the character’s mesh moves along with the skeleton according to the sum of all influences defined in the entire set of weight maps.
Bone Weight maps and vertex Groups
In Blender the weight maps are stored in vertex Groups, where the vertex Group and the corresponding bone have the exact same name. So when you create the weighting for a character, then (in theory) you will end up with exactly the same amount of vertex groups as you have bones. And each weight groups will contain exactly one weight for each vertex of the mesh…
Well, this is not exactly true. In practice it is possible that a mesh is only influenced by a small subset of the skeleton bones. For example when you rig a pair of boots, then the entire set of upper body bones will not have any influence on the shoe, and the weight groups for the remaining bones can be omitted, because they are empty anyways. So in practice your mesh will only need weight groups for the bones which are used for its animation (for example “ankle” and “knee” bones for a boot made for OpenSim and similar)
Actually it also turns out that a bone weight map typically is populated mostly with 0.0 entries, because of the same reason as mentioned above: An arm bone will not take control over a part of the mesh near the foot, etc… A bone will typically only need weights for nearby vertices. Hence bone weight groups are in most cases populated only with a small fraction of all vertices of the animated mesh and all weights with value zero are not necessarily stored in any weight group.
The weighting Color Code
Weight maps can be visualized by using a cold/hot color system, such that areas of non influence are drawn in blue (cold) and areas of high influence are drawn in red (hot) in between influences are drawn in rainbow colors, depending on their value (blue, green, yellow, orange, red) Blender (and Maya as well) has added a special visualization for unreferenced vertices to be drawn in black. Thus you can see all referenced areas and all unreferenced areas ( in black) at the same time. This is practical when you look for weighting errors (we will get back to this later).
Note: Currently Blender does not distinguish between vertices with Zero weights and unreferenced vertices. Both are rendered in Black.
Blender rules for weight maps
Blender comes with a practical shortcut: a weight of 0.0 is not needed to be stored in a weight map. Instead of that Blender assumes:
“if vertex is not contained in bone’s weight map, then bone’s weight on the vertex is assumed to be 0.0”.
This rule saves a lot of unnecessary entries in the weight maps and still it is exact.
And there is another practical rule: If the weight map of a bone is completely empty, it can be removed as well. So for example when we have rigged a pair of boots, then we only need the ankle bones and the knee bones weight maps for it. All other weight maps can be removed because they contain no entries. Blender assumes:
“if bone has no weight map, then all vertices of the mesh are assumed to have a weight of 0.0 for this particular bone”
The special rules of OpenSim and similar
While the special rules for Blender make a lot of sense, the OpenSim animation system has different rules. However they are very similar, except 3 important details:
- OpenSim only accepts a rigg when the weight maps for at least 21 main bones are defined. However the weight maps may be empty. Thus while in Blender you can remove empty weight maps, you have to provide weight maps for all bones (even if they are empty) when you upload your mesh to OpenSim and similar worlds.
Avastar hint: This is automatically adjusted for you during export.
- If a vertex is not contained in any of the weight maps, it will be removed from the mesh when worn and you get unexpected “holes” in your Object surface. Hence you have to ensure that each vertex of your mesh has a weight in at least one of the Bone weight maps.
Avastar hint: The exporter will reject meshes with unreferenced vertices and create a report
- While in Blender each vertex can appear in all weight maps, for OpenSim there is an upper limit of 4. Thus you must ensure that for each vertex of your mesh there is at least one containing weight map, but no more than 4 weight maps.
Avastar hint: This is automatically adjusted for you during export.
Weights are not absolute!
The principles of weighting are in principle not very complicated. However there are a few details which sometimes make modifying a weight map become a true challenge. And the most overlooked but also most important detail here is: the weights on a weight map do NOT specify absolute influence but relative influence.
As an example: Assume you have 2 bones, both of them have a weight of 1.0 on the same area of the mesh. since a weight of 1.0 means full influence, the mesh gets maximum influence from both(!) bones. But it can not follow 2 masters at the same time. Thus both bone influences get normalized, that is in our case: since both bones want the exact same influence on the mesh part, they actually get 50% influence (0.5)
The relative weighting may sound an easy thing. But take care, sometimes the system can fool on you. Look at this example: let’s say we have one vertex which is only weighted to one single bone. The weight is 0.0001. Now what happens ? we might think its a small weight, so the bone influence is very close to zero… well, since the vertex is assigned only to one bone, that bone gets the full influence on the vertex. So it is irrelevant how big the weight is. if it is > 0.0 then it is 100% influence in this case.
Please keep this detail in your memory as it can be the cause of a lot of weighting issues you might have to solve in the future.