Demo: Green Dragon

Articles with the tag: Vertex Morphing

Facial expressions: shader-based vertex morphing

Blending normals and positions with linear interpolation (LERP). It seems to look good.

LERP: (startPos + factor*(endPos - startPos));

GLSL Vertex Shader example:

vec3 morphPosition = vertexPosition;
morphPosition = (morphPosition + morphWeight0 * (morphPosition0 - morphPosition));
morphPosition = (morphPosition + morphWeight1 * (morphPosition1 - morphPosition));

To reduce shader computation, the (endPos - startPos) calculation can be performed on the morph target vertices before they are transferred to the device.

Vertex Shader example after optimisation:

vec3 morphPosition = vertexPosition;
morphPosition += morphWeight0 * morphPosition0;
morphPosition += morphWeight1 * morphPosition1;

Rough animation test mixing blend shapes (the mouth movement) with pre-animated armature animation (the bobbing), both interpolated using smoothstep interpolation:

And with skeletal IK animation:

Read More »

Character animation: vertex morph targets

For animation purposes, the ModelNode for the dragon character will contain a set of morph weight factors relating to the number of possible morph targets (key shapes) that have been generated for the character's expressions.


std::map<std::string, float> _keyFac;
_keyFac["MouthOpen"] = 0.5f;

The shader has a limited number of morph targets it can use (currently 2, but it can be increased to 5) so it is up to the animation update logic to choose which expressions to send to the Renderer.

If 5 expressions are used, a fair amount of artistic control can be provided. For example, three morph targets can be used for broad facial movement such as "Smile", "Frown", and "Blink" while the two remaining slots can be used to blend phoneme movement for speech animation.


std::map<std::string, uint> _keyId;
// The key's ID relates the morph mesh ...

Read More »

Character animation: facial expressions

While idle motion based on armature animation can be done, other idle motions such as blinking and mouth movement depend on mesh morphing and blending.

Blending the three: IK, armature animation and face morphing should just be a matter of combining transformation matrices and providing the necessary arrays of data to the shaders (providing this data is discussed below).

Because the dragon character's face is not warped by the armature motion, it shouldn't matter whether the mesh is warped before or after the other animations.

On face morphing:

(Assuming three meshes are generated for the dragon representing its (currently) two morph targets (what Blender calls "Shape Keys") plus a base mesh: BasisMesh, BlinkMesh and MouthOpenMesh.)

The meshes could be interpolated on the CPU (the host) and the resulting vertex array be uploaded to the GPU (the device) each frame. This would be computationally expensive for a game scenario ...

Read More »

Character rigging: vertex weight painting

The weight of each vertex in a vertex group defines how much it is influenced by the bone associated with that group.

Armature weight painting successfully completed. Testing to see if updated mesh and armature works in game environment.

Not using Three.js Blender exporter's Morph Animation option, which generates 100+ MB files. Just going to create a mesh for each shape key (i.e. blink, mouth open), which can then be blended with the basis mesh by the game engine.

Read More »

Interpreting facial expression morph keyframes

Must check that normals are being transformed correctly in armature morphing. Probably aren't, since it doesn't have any rotation info. Should work for animation morphing, though.

Speaking of which, getting the non-animated dragon head working with an armature is the most important thing. Facial animation (whether based on animation morphing or vertex group transformations) can come later.

Animation shape keys:
  • Mouth open
  • Blink
  • Snarl
  • etc...

Could use Three.js Model format 3 morph targets, but simple jaw animation can be accomplished with a simple rotation matrix so long as the right vertices can be selected and grouped.

Morph targets might be good for blinking, which is fiddlier animation.

Read More »

Exporting facial expression morph keyframes

Keyframes in Blender are done. Exporter won't save animation morphs in a single file, so I will have to save multiple mesh files and build interpolation into the game demo.

Read More »

Page 1 / 1