Here I present a slightly advanced topic, but one that has enormous potential… and, realistically, is probably the only way to really clean up all the tiny problems you end up having with your rig that just won’t go away any other way.
What are corrective blendshapes?
Well, this is a term that gets used to describe a process of correcting little inadequacies – like weird collapsing of volume in an elbow for example – of your rig/skinning. Other terms you’ll hear are, “correctives”, “pose space deformers”, and probably a few more. You’ll notice things tend to have more synonymous terms the newer and the less-standard they are, and these are a relatively new development in rigging.
Quite often, when you skin your mesh to your skeleton, you paint the weights well, and you start animating, you discover that, while your rig works most of the time in most poses, there’s that one pose that always causes a problem that you can’t fix with weighting. For example, when you bend the arm, the elbow collapses unnaturally.
You’ve tried weight painting, but it just doesn’t quite fix it. You’ve tried setting a driven key on an extra joint in the elbow so it “puffs out” when the arm is bent, but you don’t have enough control with it to make it look nice. You’ve tried everything you can think of to make it a robust solution, and they just don’t quite work. Enter… the corrective blendshape.
Quick and dirty.
1.) First, download the script off the drive, “BSpiritCorrectiveShape v1.2.mel”
2.) Source the script so that it is in memory. That is, run it. Open it with a text editor and copy and paste it into the script editor. It will simply load a function into memory that you will use later.
3.) Move your rigged model into the position that causes the problem using the controls and duplicate the mesh.
4.) Sculpt this duplicate mesh however you want it to look in that position.
5.) Select the sculpted duplicate and then the original mesh and type, “BSpiritCorrectiveShape” into the MEL command line and hit return.
6.) A new “corrective blendshape” will be produced in your scene. Note, the shape and position of the corrective mesh will not line up or look like the original or the sculpt.
7.) Make this new corrective mesh a blendshape to the original mesh by selecting the corrective mesh and shift selecting the original (IN THE SAME POSE THAT IT WAS DUPLICATED IN) and going to Create Deformers -> Blendshape.
Nothing will seem to have happened. Hide the corrective mesh and the sculpted mesh — you will not need to see these anymore.
Look in the INPUTS window (under the channel box) when the original mesh is selected. The blendshape should be there called something like, “blendShape1”. Click it. An attribute should appear under it called something like, “boy_geo1_sculpt” and be set to zero. This is the blendshape weight. Set it to one and watch what happens.
(ABOVE: the blend shape turned off.)
(ABOVE: the blend shape turned on.)
The blend shape will change the shape of the mesh to match how it looked when you sculpted it. Nice.
8.) set driven key the blend shape from zero to one by the control that got the rig into that position in the first place. For example, if elbow_ctrl rotates in Z from 0 to 90 on its way to the corrective pose, at some point, it will want to ease the blendshape in to compensate for the (original) faulty deformation… that is, at some point, the blendshape goes from 0 to 1. So, set 2 (at least) driven keys with elbow_ctrl as driver and blendShape1 as driven:
1. With elbow_ctrl.rotateZ at 0 and blendShape1.boy_geo1_sculpt at 0.
2. Withelbow_ctrl.rotateZ at 90 and blendShape1.boy_geo1_sculpt at 1.
When it’s done, you should notice that the blend shape smoothly compensates for the bend (ABOVE) that otherwise would have deflated (BELOW).
You may find you need to tweak the graph or add more set driven keys to make the effect happen just when you want it. You can add more keys, alter the graph in the graph editor — whatever you want so it looks good going through this particular motion.
The above image shows how the blendshape needs to get to full on (i.e., 1) earlier than when elbow_ctrl.rotateZ = 90, so I will set driven key the blend to one when elbow_ctrl.rotateZ equals 60 (as well as at 90), and things start looking better. Notice the improved divot in the elbow below compared to the elbow above.
9.) Now, the blend shape will “fill in” the problem area only when this control moves in that way. You will, of course, need to test that this continues to work in all kinds of other poses. For example, this blend shape may mess up another odd pose, and you may need to account for that — either with another corrective blendshape, or perhaps by set driven keying this one differently.
Also, you will be able to modify your sculpted blendshape target later (the one your sculpted into position), and the changes should be reflected in the blendshape. This is, in general, how deformers work. Remember that, because it’s very convenient to modify things later and not have to rebuild them.
And as always, TEST TEST TEST!!!
These corrective blend shapes are very powerful, but not fool proof. You will need to experiment and test and make sure they all get applied just when you want them — and not when you don’t. You may have to switch the order of the inputs (select the mesh, right click, go to Inputs -> All Inputs… and try different orderings by middle mouse dragging the listed deformers into different orders if things don’t seem to be deforming right). Although, usually, the corrective blendshapes should be applied before (that is, lower in the list) the skin cluster.
You may have to use multiple correctives or rig them so they don’t get applied in certain circumstances. Hopefully, they will work well in most poses and circumstances, and you will have finished off a troublesome spot in your rig! But, make sure you test.
You may be asking yourself why we need this script. It is a little confusing. It may seem to you (as it did to me when I first saw these) that you could just sculpt a duplicate and make a blendshape without making it a “corrective” blendshape… but that would only work in the original pose.
Basically, the corrective script figures out the shape that has to be added to the ORIGINAL BASE POSE of the model to end up looking like the sculpted version WHEN the original base pose has been changed by the rig (in this case, the skin cluster from the skinning of the joints). The blendshape gets added to the mesh in a certain order, and the shape it needs to add BEFORE the skin cluster is different than the shape it would need to add AFTER the skin cluster. So, this does all the math for us and finds out the “delta” of the two meshes that it needs to apply to get the right thing right at the right time. Right? 😉
As an example, here’s what happens if you make a simple, normal blendshape out of your sculpt and apply it.
What’s essentially happening in the above image is that the simple blendshape is moving the entire mesh to the sculpted pose (which, remember, was with the arm bent), and the skin cluster is then ALSO moving the entire mesh to the sculpted pose. These two transformations result in a kind of double bent elbow.
If I reverse the order of these deformers (that is, the skin cluster below (i.e., before) the blend shape), the rig controls essentially stop working, because the blend shape gets applied after all the rig controls have deformed the mesh, and therefore, the blendshape wins and takes over the overall look — and makes it look like the sculpted mesh — which looks fine, except that the rig no longer works. 😦
ON THE OTHER HAND, the corrective blendshape finds the deformations that have to happen to the bind pose BEFORE the skin cluster is applied in order for the resultant pose to look right. Magic. Yes…. magic.
Luckily you don’t really need to understand too much about this process. Just learn how to use them to clean up your final results, and things will look awesome!!!
If you are having trouble with these – or want to know more – I highly recommend the following tutorial online:
Jahirul clearly has a solid understanding of these and does a great job explaining the use of them. He uses a few more scripts and another software package (Mudbox), so it’s a bit more complicated, but a good resource to further your grasp of these.
Also, one last thing, Maya 2016.5 (I believe it’s the same as 2016, service pack 2) has native support for corrective blendshapes (yay!!!), so you can dispense with these scripts and this difficult-to-keep-track-of process soon. 2016.5 is already out, but you have to download it separately or something, so you may not have it. But, when you get it, learn how to use the corrective tools — they are a life saver. There’s layer support and all kinds of things. Enjoy!