Creating the Texture Map
Ensure the original character texture image don't have the mouth and eyes, as they will be a part of a separate texture map, which will then be animated and controlled separately.
Create a new square image, with various mouth shapes and eye variations. Place them all in equal grids. Set the background and the grid lines in separate layers so that they can be easily turned off to export transparent png.
The grid can be of any shape but the whole image should be square in proportion. For mouth shapes arrange them in groups of expressions , for example smile, laugh, crying and so forth. And phonemes such as a, aa, o, ee, f, v, m b, l.
Face Object and Texture Setup
In Blender, open the file in which you made the character. Secondary-click on the character object to select it and press Tab on the keyboard to enter edit mode.
Ensure you're in front view. Press 1 on the numpad to get into front view.
Press Shift-A and add a plane. In the bottom part of the toolshelf, tick the Align to View checkbox so that it face the viewer.
Move the new plane forward to bring it in front of the face.
You'll notice that the plane appears to be circular. This is because the subsurf modifier was already applied to the character.
Hold Shift and secondary-click on all vertices of the plane. Press Shift-E and type 1. The edges of the plane will become sharp and will be marked in purple.
With the plane selected, press S on the keyboard to scale the plane according to the size and shape of the mouth.
With the mouth plane selected, press Shift-D to make a duplicate for the eyes. Move and place it appropriately. Use G key to move. Press S and then X key to scale along the X-axis.
Split the 3D view into two. Click on the window type button and select UV/Image Editor.
In the 3D view port, select both planes you just created for eyes and mouth. Hold Shift and then right click on the vertex to multiple select. Make sure no other vertex is selected. Press U key to bring the UV Mapping menu. Select Unwrap.
In the UV Editor, click on the Open button and browse for the mouth/eye shape image.
I've turned on the grid and background layer in the 2D program while exporting as I need the grid as reference to align the UVs of the planes.
In the UV Editor, select the unwrapped vertices of the mouth plane. Scale it down and place it on the first box. This will be the default expression.
Similarly do the same for the eyes. Select the vertices and scale it down and place it over the first grid.
Now in a 2D program, turn off the background and grid layer. Export it on overwrite the png file. In the UV Editor press Alt-R to refresh the image or you can re-open the image.
The texture now has transparent background and it blends seamlessly with the character.
Setting Up the Material
With the two planes selected, click on the materials button in the properties window. Press the + button to add another material slot.
Click on the New button to add another material. Rename the material face or feature or anything else you want.
In the Shading panel, tick the Shadeless checkbox. Turn on the Transparency and reduce the Alpha to 0.0.
Click on the texture button on the Properties window. Click on the New button.
In the Image panel, press Open button and browse for the transparent mouth texture image. Tick the Use Alpha checkbox. In the Influence panel, tick Alpha checkbox.
Parenting to the Bone
With the planes selected, click on the Vertex Data button in the properties window. In the Vertex Groups panel, click on Head and then click the Assign button. The planes will now follow the head bone along with other vertices of the head vertex group.
You can test it by right clicking on the armature object. Pres Ctrl-Tab to enter pose mode if you are not in pose mode. Right click on the head bone and press R to rotate it. Press Alt-R to reset the rotation.
Creating Reference object and Control Bones
Right click on the character object and press Tab to enter edit mode. In the Vertex Groups panel, click on the + button to add a new group. Rename it eyes.
Press A to deselect all vertices. Now select only the vertices of the eye plane.
Click on the Eyes and click the Assign button to assign the selected vertices to the Eyes vertex group.
Next, click on the + button the in Vertex Group panel to add another group. Rename it Mouth.
Select the vertices of the mouth. In the Vertex Groups panel, click on the Mouth and click on the Assign button. This will assign the selected vertices to the Mouth vertex group.
Press Tab to exit edit mode. You need to have a reference image and bones setup to control facial animation. First click on the File menu and select User Preferences.
Click on Add-ons tab. Type image in the search box and tick the Import as Planes checkbox to enable the add on.
Close the User Preference window.
In the 3D view, press Shift-A to bring out the Add menu. Click on Mesh > Images as Planes.
Browse for the image you exported with grid and background layer turned on. While importing, in the Material Settings panel. Tick the Shadeless checkbox.
Secondary-click to select the plane and press Tab to enter edit mode. Ensure you're in front view; press 1 on numpad to get into front view.
Select all vertices by pressing A key. Press R and then X and then type 90 to rotate the plane 90 degrees on the X axis so that it faces the viewer. Press Enter. Don't resize the plane.
Press A to deselect all vertices. Secondary-click on the corner point to select it. Press Shift-D to make a copy. Move the mouse and place the point in the middle of the first grid. Click to confirm. This will be helpful while snapping the bone to the centre of the grid.
Duplicate and place more vertices on the center of each grid.
Secondary-click on the first vertex which is at the centre of the first grid. Press Shift-S to bring out the snap menu and select Cursor to Selected. This will bring the 3D cursor to the selected vertex.
Press Tab on the keyboard to exit edit mode. Press Shift-A and add an Armature.
Secondary-click to select the bone and then press Tab to enter edit mode. Select the tip of the bone and move it down.
You can use either G key or the arrow manipulators to move the selection.
Press Shift-A again to add another bone at the same point. Move the tip down a bit but it should a bit bigger than the previous bone. Press Z key to toggle on wireframe view.
Press B and drag select both bones. Press Shift-D to make a duplicate set and move them down at the center of eye grid. You may turn on snapping by clicking on the magnet button in the header. select vertex in snapping mode.
Press Shift-A and add another bone. Place it on either side of the image. This will be the parent bone.
Press A to deselect any selected bone. Right click on the first bone to select it. Click on the Bone button in the Properties window and rename it mouth-base.
Secondary-click on the second bone and rename it Mouth-Control
Similarly rename the other two bones as eye-base and bigger one as eye-control. Rename the last bone as main or parent.
Press A to deselect any selected bone. Hold Shift and then right click on the mouth and eye bones and then the main bone at last. Press Ctrl-P to make it parent bone. In the menu select Keep Offset.
Press A to deselect the bones. Select only the smaller bones, i.e. mouth-base and eye-base bones. Press M to move them to another layer.
Click on the second layer in the Change Bone layer popup. I'm moving them away as they are not supposed to be moved or touched.
With the object selected, click on the Object button in the Properties window and rename it to Armature-Face.
Press Ctrl-Tab to enter pose mode. Secondary-click on the main bone to select it.
Secondary-click on the reference plane. Hold Shift and right click on the main bone to select it. Press Ctrl-P and in the Set Parent To popup, select Bone. The reference plane is now rigged to the main bone.
Setting up Bone Controls with UV Warp Modifier
Secondary-click on the Character object to select it. Click on the modifiers button in the properties window.
Click Add Modifier button and select UV Warp.
In the UVWarp modifier panel,
- set the From object to Armature-Face and From Bone to Mouth-Control
- Set To object to Armature-Face and Bone to mouth-base
- In the Vertex Group select Mouth
This means that when the Mouth Control bone is moved in relation with the mouth-base bone, the texture map will also move and warp, and it will affect only the vertices assigned to Mouth vertex group that is the mouth plane.
When you will move the mouth-control bone in pose mode, you will see that the texture map is also warping but only in the mouth plane.
Split the 3D view into two. Zoom in to the reference object in one view.
Select the character object. In the modifiers panel, add another UV Warp modifier. This will be for the eyes.
Set From object to Armature-Face and Bone to eye-control. Set the To object to Armature-Face and Bone to eye-base. In the Vertex Group select eyes.
Move the eye-control bone and see the texture moving and warping.
In the pose mode, select all bone with A key and press Alt-R and then Alt-G to reset the location and rotation of the bones.
Click on the Armature button in the properties window. In the Pose Library panel press the New button.
Secondary-click on the mouth-controller bone to select it. In the Pose Library panel, press the + button to add a new pose.
Rename the pose Smile.
Move the mouth-controller bone to center of the next grid. You can turn on the snapping option so that the bone will snap to the vertex you created in the middle of the grid.
Press Shift-L to add a new pose. In the pop up menu click Add New.
In the Pose Library panel, rename the new pose Sad or frown.
Similarly add all pose and rename according to the image.
Select the eye-controller bone. press Shift-L and add a new pose.
In the Pose Library, rename the pose Eye-Normal.
Just like the mouth, create library of poses for the eyes and rename them according the the expression.
The setup is now ready. Whenever you want to see a pose in action or insert into keyframe, just left click on that pose in the Pose Library panel, and click on the button with magnifying glass.
Now you don't need to move the controller bone each time while animating.