Today we're going to look at binding a character's skin to his skeleton. There are three main methods for doing this in Maya:
Parenting an object to each joint is known as hierarchical binding. This works fine if you have at least one object per joint, and gives the character a fairly man-made quality (e.g. a wooden puppet).
The next stage is to try rigid binding: this "parents" each vertex of the skin to the closest joint of the skeleton. The effect is rarely satisfactory; it usually produces sharp folds where one joint's area of influence stops and another starts.
Smooth binding essentially parents each point to several joints: we can vary the weighting of each point individually, i.e., how much each point is affected by each joint.
Let's have a look now at the latter two of these. Open up this scene file:
You will find a simple figure and a simple rig. Before we do anything there are a few things to do: first, let's set his preferred position. Turn on
Shading → Shade Options → X-Ray on the panel menus to make it easier to select the joints and see what is going on, then RMB-click and hold on the chain root (his hips) and select
Set Preferred Angle. We also have to make sure that his construction history is deleted. This used to be very important, as the history could not be deleted once the skin was attached (as doing so would remove the skin as well). Now, though, Maya has
Delete Non-Skin History on the
Skin → Edit Smooth Skin menu (but it's still a good idea to do it).
We will first skin him using rigid binding. Select the root of the skeleton and the skin, and go to
Skin → Bind Skin → Rigid Bind. Now try rotating some of the joints: for example, try rotating the knee joint.
You can see that even without a very extreme position, there are a lot of sharp deformations: especially at the back of the knee, but also at the front. This is not good for an organic character, so we must look to smooth skinning to solve this problem.
Remove the rigid bind. The easiest way to do this is to go to
Skin → Detach Skin. Now attach the skin to the skeleton using a smooth bind:
Skin → Bind Skin → Smooth Bind. Even without tweaking, try the same deformation that we did with rigid binding: the default weighting of the points is not perfect, but the effect is considerably better than the equivalent with rigid binding: the skin covers the skeleton much more smoothly, and then we can go in and adjust the weighting of individual vertices.
Let's have a look at some of the weights: select a few vertices around the knee area, and go to
Window → General Editors → Component Editor. This shows us the parameters of these points: there are lots of sections, including one for rigid bind, but the one we're interested in is the
Smooth Skins one.
Before we start getting into the nitty-gritty of adjusting the weights, try this: grab the character's shoulder joint, and lift his arm up from his side so that he's holding it out level with his shoulder. What you'll witness is not pretty, but it gives us some insight into the way Maya assigns the default weighting of the points. Maya looks at where a vertex is in the character's bind pose (unsurprisingly, the pose in which the character was bound), and then looks to see which joints are close to it. If we take another look at our character in its bind pose, we can see that the points on the side of the torso are considerably closer to the joints in the arm than they are to those of the back: Maya therefore assumes that the points should be affected mostly by the position of the arm, and only slightly by the position of the back.
(Note that some points on the leg are almost as close to the hand as they are to the leg, but these do not get weighted to the hand: in this case, Maya is intelligent and notices that the left hip is in a different hierarchical branch from the left hand, and thus ignores the hand)
We could solve this problem by manually adjusting the weights of the points: the points on the torso that are wrongly weighted to the arm are changed one at a time. But there is an easier way: if, when making the skeleton, we make sure that the arm joint is NOT the closest, then it won't be a problem. We can't move our spine any closer to the skin, but we can add more joints to our skeleton. It doesn't really matter how we add them, just so long as we make sure we've considered how they're going to be affected when the character moves.
To do this, we'll detach the skin: do this in the same way as we did last time. Now add one or two new joints on each side, and re-attach it. You should see now that when we move the arm, it behaves much more sensibly than last time: the weighting needs adjustment, especially round the armpit and the shoulders, but it's a much better approximation than before.
The moral of this tale? Before you paint weights at all, think about ways to improve Maya's default weighting by adding more joints or influence objects (which we'll have a look at a bit later).
Before we start weight painting, make sure that you have set the preferred angle for the whole skeleton (including the new joints).
Weight painting is, to some extent at least, a trial and error procedure. For this reason it is vital to be able to see the result of your current weight painting quickly. The easiest way to do this is to paint the weights while your character is not in its default position: paint the weights while your character is not deforming well, and you can see the problem exactly and attempt to correct it.
Let's have a go at this now. Rotate the neck joint so that our character's head looks down. As you can see, the head deforms very badly, so we need to paint weights. But first, let's think about simplifying our work: weight painting is laborious and time-consuming, so the more corners we can cut the better. The vast majority of vertices on the head should only be affected by the neck joint. Select the vertices that should only be affected by the neck (those from just above the top of the neck), and open up the component editor again.
Look at the list of points, and you'll see that they're being affected by up to five joints at the moment. Select the neck joint column, and move the slider at the bottom (that goes from 0 to 1) all the way up to one: this changes the weighting of the neck joint for all the points to 1, the result of which is that the points are only affected by the neck joint. Notice that increasing the weight of the neck joint decreases the weight of the other joints: the sum of all the weights must be 1, otherwise strange things will happen. If you have strange things happening with a smooth skin, this is the first thing to check.
Now, to the nitty-gritty. First we'll have a go at the same things that we already did: press
z to undo back to before we changed the weights on the head (but make sure the head is still angled down). Now, go to
Skin → Edit Smooth Skin → Paint Skin Weights Tool ❐. The options will pop up, and allow us to change lots of things. First, click Reset Tool to make sure we're all at the same starting position. Now, in the list of influences, click on
Neck. This will show us which points are being affected by the
We want all of these points to have a value of 1 for the weight from the Neck joint, and 0 from all other joints, so let's select
Replace as the
Paint Operation: as it happens, this is the default anyway, as is 1 on the
Value slider, so we don't need to change anything. What you might want to do is reduce the
Radius (U) so that we can paint with a slightly smaller brush: hold down
b and drag left and right.
Now try painting on the surface: as you paint, the surface will go white (indicating a weight of 1 on the active joint) and the head will become closer to its original shape. Paint the whole head.
Depending on which points you painted, there may be some points which are a bit too dark, but which we don't want to be white. In order to cover this eventuality, we can vary the
opacity. Named after the similar function in image applications like Photoshop, this allows us to only add a certain amount of "whiteness" at a time. Try it and see: undo back to before we painted the weights. If we turn the opacity down to 0.1, we have to paint several (read: many) times before the point appears white. Have a play with the other painting tools, they're mostly fairly self-explanatory (I have described them assuming opacity is set to 1):
Replace – does not depend on the original weight, just replaces that weight with the one specified in
Add – adds
Value to the current weight to give the new weight.
Scale – supposedly does something, but I can't figure out what. I would recommend not using it.
Smooth – smooths the weights between points, so that the surface flows more nicely: it's the equivalent of blurring an image. Can be useful, but not if you've already painstakingly painted your weights.
Play with these methods to try and make the head bend down nicely, then have a go at the armpit: rotate the collar bone a little, and the arm a lot, so that the arm is approximately horizontal. In this position the armpit doesn't look right, so try increasing the influence of the torso joints to compensate. Also you could try putting him in a sitting position and ironing out any creases in the weighting there. Don't forget if you want to go back to the original position, hold the RMB on the root and go to
Assume Preferred Angle. To get the best idea of which joint to add to the weighting, it is often a good idea to select them and look in the component editor. Final thing: when it comes to weight painting, always, ALWAYS, name your joints. You don't want to be trying to figure out whether to add weight for joint36 or joint37 and having to go and select them in the outliner to decide.
Another way to adjust the shape of a rig is to use influence objects. These affect the shape of the smooth skin, and can be any type of object. You may have noticed when you put the character into the sitting position earlier, that his bum wasn't very shapely. We will use two scaled spheres to reshape it.
Create two spheres, and scale and translate them so they are approximately the same shape as the two buttocks are in the bind pose. If you need to go back to the bind pose, which may not be the same as the preferred angle, select the
Hips joint and click on
Skin → Go to Bind Pose. Now we will add the influence objects, one at a time (so we can see the difference). Select the skin first, then the influence object, then go to
Skin → Edit Smooth Skin → Add Influence. Now, if you try putting him in a sitting position, you should find that his bum stays a much better shape.
Note that adding influence objects will affect any weighting you've done, so be sure to add them before you fine-tune your weighting. Some people have been known to get away using solely influence objects, and not paint weights at all; usually a sensible balance of both works well.
Let me show you something. Select the character's left shoulder, and change the
Rotate Order (in the attribute editor) to
yzx. Keyframe it (at from 0) in the bind pose, then move forward 10 frames. Rotate the arm out in the z axis (about 90°). Keyframe the rotation here. Move forward 10 frames. Rotate it 90 degrees in the x axis, and keyframe it here. Now play it, or scrub the timeline. The arm goes all over the place, rather than just rotating around the x axis. What's going on here?
This is an effect known as gimbal lock. It is caused by the rotation method that Maya uses (along with most other 3D packages), Euler rotation. The problem is elucidated if we switch to viewing the Gimbal rotation axes: hold down
e, click and hold the LMB, and switch to
Gimbal. These are the axes that Maya used internally. If we look at frame 10, we can see the problem: the x and y axes are almost overlapping, so we don't have any way directly to rotate the arm along its axis. Maya gets round this by rotating both z and y axes at the same time (use
alt-. to step through frame by frame), which produces the correct keyframes, but the interpolation is all screwed up.
This can always happen when you want to be able to rotate on all three axes. If you find your scene suffers from gimbal lock, there are a few ways round it: changing the rotation order can help, but never eliminate the problem. The best way round the problem is to use two separate joints close together: one for rotation along the axis of the "bone", and one for rotation in the other two axes.