Skip to main content
Version: Next (dev)

Morph Targets

Morph targets (called blend shapes or shape keys in FBX and Blender) are alternative shapes of a mesh: a smile, a blink, a muscle bulge, a corrective shape for a bent elbow. Each target is stored as an offset per vertex, and a weight from 0 to 1 says how much of it is applied. Plasma imports them with an animated mesh and applies them on the GPU before skinning, so a character can blend facial expressions while its skeleton animates.

Importing morph targets​

  1. Export the character as glTF (.glb) or FBX with its shape keys. In Blender, shape keys are written by default in both formats.
  2. Create or open the animated mesh asset for the file. ImportMorphTargets is on by default.
  3. Transform the asset (Ctrl+E). The log lists what was imported, for example Imported 52 morph targets (183204 offsets, 5725 KB): browInnerUp, eyeBlinkLeft, .... The names in that line are the channel names that you use to set weights.

Animated meshes that were imported with an older version transform once more the next time the editor opens them, and pick up their blend shapes then.

Properties​

PropertyDefaultDescription
ImportMorphTargetsOnImports the morph targets of the skinned meshes in the file. Off produces the same mesh as before morph targets existed.
MorphTargetThreshold0.00001Position offsets shorter than this (in metres, after the import scale and axes) are dropped, unless the vertex's normal changes noticeably. Raising it makes the data smaller at the cost of very subtle movement. 0 to 0.01.

How targets are named and merged​

  • A channel is identified by the target's name, with spaces trimmed. FBX often names blend shapes Smile.Smile; such doubled names become Smile.
  • Targets with the same name on several meshes of the file (head, teeth, eyelashes) become one channel, so one weight drives all of them.
  • A target without a name gets <mesh name>.Target<index> and a warning.
  • Offsets are taken against the final mesh: with RecalculateNormals on, each target's normals are recomputed from its moved positions, and with NPR spherical normals the targets move positions only.
  • Mesh simplification keeps the targets on the simplified mesh.

Driving the weights​

Morph weights are set by name on the object with the animated mesh component or the LOD animated mesh component, which maps them onto every level of detail by channel name. The weights stay until they are set again. A weight for a channel that a mesh does not have is ignored, so one set of weights can drive several meshes that share some channels.

Weights are set from C++ with the plMsgSetMorphWeights message, which carries a list of channel names and a parallel list of weights:

plHashedString channels[2];
channels[0].Assign("eyeBlinkLeft");
channels[1].Assign("jawOpen");
const float weights[2] = {1.0f, 0.35f};

plMsgSetMorphWeights msg;
msg.m_Channels = channels;
msg.m_Weights = weights;
pCharacterObject->SendMessageRecursive(msg);

Facial rig components in packages use this message to drive the blend shapes they compute. The message is not exposed to Visual Script or AngelScript.

Morph weight animation stored in the file (glTF weights channels, FBX blend shape curves) is not imported into animation clips.

How the mesh is deformed​

An animated mesh with morph targets is deformed in a compute pass once per frame: first the morph targets are added in the bind pose, then the mesh is skinned. The positions of the previous frame are kept, so a changing expression produces correct motion vectors for temporal anti-aliasing and motion blur. The bounds of the mesh grow by the furthest any target can move a vertex, so a morphed mesh is not culled too early.

This pass runs whether or not Rendering.Skinning.Compute is on; that cvar only decides whether meshes without morph targets are skinned in compute too. The same compute pass applies character cloth.

Compute deformation needs a GPU with buffer device addresses and hardware ray tracing support. On other devices the mesh is drawn with ordinary vertex skinning and without its morph targets, and the log warns once.

Limitations​

  • Only skinned meshes get morph targets. A static mesh asset ignores them.
  • FBX in-between shapes are not supported: a blend shape with several shapes keeps only the last one, with one warning per channel. Each channel blends linearly from 0 to 1.
  • Cloth garments do not take morph targets. A garment that has them imports without them and the log warns.
  • There is no size limit; the log line after import shows how large the data is.

Troubleshooting​

ProblemCause and fix
No "Imported ... morph targets" line in the logImportMorphTargets is off, the meshes in the file are not skinned, or none of the targets moves a vertex by more than MorphTargetThreshold (the log then says so).
The weights have no effectCheck the channel names against the import log; they must match exactly. Send the message to the object that holds the animated mesh component, or to a parent with SendMessageRecursive.
The log warns that compute deformation is not supportedThe GPU lacks buffer device address or ray tracing support. The mesh renders with skinning only.
A blend shape looks weaker or different than in the DCC toolIt probably has in-between shapes. Bake it to a single full-weight shape before export.
Shading on a morphed area looks wrongEnable RecalculateNormals so each target gets normals from its own shape, or check that the exporter writes target normals.

See Also​