The shape keys

In the following sections, we are going to learn about shape keys and drivers. This will help us to create some very basic facial controls that we will use in the next chapter. Facial rigging is a long process, so we are not going to create a fully functioning facial rig here, but you will have all the tools needed to create your own if you want to.

What is a shape key?

A shape key is a method to store a change of geometry in a mesh. For instance, you can have a sphere object, add a shape key, move your vertices so that the sphere looks like a cube, and the shape key will store the changes for you. A shape key is controlled by a slider. The value of the slider corresponds to the distance each vertex has to move to get to the stored positions. As you can imagine, shape keys are very useful for facial rigging as they allow us to create different expressions and turn them on or off.

What is a shape key?

Example of a shape key with Suzanne

Creating basic shapes

In this section, we will create five basic shape keys. They are eye blink left and right, smile left and right, and frown. This will be done as follows:

  1. First, we will need to select the object that will receive the shape keys. Then we will go to the Object Data tab of the Properties editor, and we will open the Shape Keys subpanel.
  2. When creating the shape keys, we always need to have a reference key that will store the default position of each vertex. To do this, we will click on the + button. It is called Basis by default.
  3. Now we can add a new shape key with the + icon and name it as EyeBlink.L. As you can see in the following, there is a value slider. At 0, the shape key is turned off, so change the value to 1.0 in order to view your changes in the Edit Mode.
  4. Now in the Edit Mode, we can change the left eye geometry to close the eye. You can use the Connected Proportional Editing tool (Alt + O) in order to smoothly move each eyelid to the center of the eye. Beware, you only want to move the eyelid's geometry, otherwise any other changes done will be part of the shape key.
  5. Next, we will mirror the shape key without tweaking our geometry on the right side again. We can do this because our mesh is perfectly symmetrical. We are going to create a new shape key based on the one that is currently active in the shape key stack. The value of EyeBlink.L is still at 1.0, so we can click on black arrow under the icon and choose New Shape From Mix. Now, we have a new shape key with the same information as EyeBlink.L, but this not what we want. We will need to mirror this to the other side. To do this, we will again click on black arrow, and we will press Mirror Shape Key. We can also rename this as EyeBlink.R. Now if you change the value of EyeBlink.R, you can see that the right eye of the Rat Cowboy is closing perfectly. What a huge time-saver!
  6. The next two keys, Smile.L and Smile.R, are created using the same method. What you need to do is create a nice smile on one side and mirror it using New Shape From Mix and Mirror Shape Key.
  7. The last key to be created is a frown. To do this, we are just going to create a new key with the + icon and move the geometry between the eyebrows. There are tons of other things to know about shape keys, but for now this is all we are going to need.
    Creating basic shapes

    Our facial shape keys

Driving a shape key

You might be thinking that animating directly shape key from the sliders is not very practical, and you are right! This is why we are going to use drivers. It is a method to indicate to an entity (object, bones, and so on) to control another value. In our case, we are going to tell Blender that the sliders of our shape keys are going to be controlled according to the transformations of the bones located on the face. This will give an impression that we are directly manipulating the head of our Rat Cowboy.

  1. The first thing to do is add three new bones to our Armature object in the Edit Mode. The first one will be located between the two eyebrows, and this will control the frown. The others are going to be near the mouth corner and will be symmetrical. They are called Frown, Smile.L, and Smile.R respectively. In order to control the eyes, we are going to use the bones we've used previously as targets.
  2. Now we will add a driver to the EyeBlink.L shape key by right-clicking on the value slider. Note that the value slider is now inaccessible, so it will be driven by another entity.
    Driving a shape key

    Adding a driver to a shape key

  3. Now split your view in a new editor of the Graph Editor type. Switch the mode from F-Curves to Drivers in the Graph Editor's header. As you can see, if you still have the rat mesh selected, you will have a new key on the left-hand side of Graph Editor. We can click on the white arrow on the left-hand side to unfold the group of keys, and we can select the EyeBlink.L one.
  4. Now we will open the right panel of Graph Editor (N), and under the Drivers subpanel, we can change the different settings. First, if you have an error, you can go to the user preferences under the File tab and check Auto Run Python Scripts. Drivers work with Python internally, so you must accept that it runs scripts. But don't be afraid, we are not going to code here!
  5. The first thing that we will change in our settings is the Ob/Bone field. We are going to choose the EyeTarget.L bone. So first choose the Armature object and then the bone. This will tell Blender that the target will be the bone that affects the driver.
  6. Now we are going to set Type to Y Scale and Space to Local. This means that, when we scale our target, the value of the variable called var in the upper field will take the value of Y Local scale of the bone.
  7. Now you need to imagine that the field called Expr is directly linked to the value slider of the shape key. You can even test this. If you enter 0, the eye will open, and if you enter 1, the eye will close. So now what we can do is replace this field with the var variable that holds the value of the y local scale. You can now see that the Rat Cowboy's eye is closed. But if you scale it, it will open. We are close to the required result.
  8. The last thing to do is change the expression so that it is open by default. We know that the Y local scale of our bone is 1 by default and that the "open state" of the eye corresponds to the 0 value of the shape key slider. So we can add the 1-var expression to the Expr field. If the Y local scale of the bone is 1, we will have 1-1 = 0 and the slider value will be 0, so the eye will be open. If the Y local scale of the bone is 0, we will have 1-0 = 1 and the slider value will be 1, so the eye will be closed. Done!
  9. We can replicate the same process with the other eye. In order to save time when creating the driver, you can simply right-click on the EyeBlink.L value slider, press Copy Driver, right-click on the EyeBlink.R, and choose Paste Driver. At this point, you just need to change which bone is controlling the key in the driver settings.
  10. For the smile driver, we will do a similar thing. But instead of feeding the variable with the Y local scale of the eye target bone, we are going to use the local Y location of the Smile.L bone. If you see a need to move the bone a lot in order to change the shape key, you can simply multiply var time a scalar in the Expr field. In our case, the expression will be var * 5.
  11. We can do the same thing for the other Smile.R bone and for the frown. The expression of Frown is -var * 10 in our case. As you can see, we have negated the var variable because we want to move the Frown bone down in order to control the shape key.
  12. As a bonus, we are going to lift the hat with the frown. To do this, we will copy our Frown driver to the X rotation of the hat object in the right pane of the 3D view (N). We will adjust the expression. In our case, the expression is simply -var.
  13. We will need to add a Limit Location constraint to the Frown bone as well. This will provide the animator with the ability to lift the hat high or low by locking the bone between a minimum and a maximum value on the Y axis in local space. To do this, we will change the settings of the constraint. We will check Minimum Y and set the value to -0.115, and then check Maximum Y and set its value to 0. Also, we can provide moves on the X and Z location by checking the other check boxes and setting their value to 0. Then we will need to select the Local Space.
  14. Now, we have minimum control over the Rat Cowboy's face in order to start animating our character. We advise you to go further yourself in order to gain experience with shape keys and drivers. For instance, you could add cheek puff or eyebrow shape keys.
    Driving a shape key

    The setup of the Frown driver in Graph Editor

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.112.171