UDN
Search public documentation

MorphTargets
Licensees can log in.

Red links require licensee log in.

Interested in the Unreal engine?
Check out the licensing page.

Questions about UDN itself?
Contact the UDN Staff

Morph Targets

Document Summary: This document gives an overview of importing a static Morph Target, adding it to an AnimTree?, and controlling it from code.

Document Changelog: Created by Sam Zamani; updated by Shane Caudle, Lina Song.

Overview

Morph Targets are a way to modify a mesh in realtime, but with more control than bone-based skeletal animation. A static Morph Target is a version of an existing mesh that is slightly different in some way. For example, you might create a 'smiling' version for a character in your 3D modelling problem, and import that as a 'smile' morph target. Then in the game you can apply this morph target to modify the vertices on the face and make your character smile, but with a great deal of control over how each vertex moves.

Morph Targets in UnrealEngine 3 are applied in an additive manner. That means that if you have one Morph Target for 'smile' where only vertices around the mouth are modified, and another for 'raise eyebrow' which only affects vertices around the eyes, applying both of these would cause both the smile and eyebrow movements to appear. This allows you to create a wide range of facial poses, for example, by combining multiple targets together. Beyond processing and memory constraints, there is no limit to the number of morph targets which can be active on a skeletal mesh at any given time.

Morph Targets and traditional skeletal animation work together. The Morph Targets are applied to the skeletal mesh before the bone transformations are applied. Morph Targets should be authored based on the reference pose mesh of the mesh, and then on import the vertices are compared against the base mesh, and only those that differ are stored. This reduces the memory cost when working with morph targets that modify only a subset of the base mesh's vertices.

Importing Morph Targets

In your 3D modeling package, take the mesh you want to create a new Morph Target for in the reference pose, and modify it as you wish. Then export that mesh as a new .PSK file. We also support exporting the mesh to the Collada format.

In UnrealEd, open the AnimSetViewer. Morph Targets are stored in MorphTargetSets. These work in a very similar way to AnimSequences and AnimSets in that they are a set of objects which can affect the base skeletal mesh. You will see a Morph tab in the panel on the left. Switching to that will give you a combo showing currently loaded MorphTargetSets, and then a list box below showing the MorphTargets in that set.

morph_asv.jpg

To import the .PSK file as a Morph Target, first select the MorphTargetSet that you want to add the new Morph Target to. You can create a new MorphTargetSet by choosing `New MorphTargetSet' from the File menu. Then go back to the Mesh tab and select the Skeletal Mesh that this is a morph target for. Finally, go to the File menu and choose `Import MorphTarget'. You will be asked to indicate the PSK file to import, and the name to give the new Morph Target. If importing is successful, you should see the new Morph Target in the list for that MorphTargetSet under the Morph tab. If you'd like to import multiple Morph Targets without any interruption (of typing morph target name), you can choose `Import MorphTarget Using File name'. This uses File name as Morph Target name after importing.

If your skeletal mesh has more than one LOD level then you will need to also import morph targets for each of those LODs. This is done with the 'Import MorphTarget LOD' option from the File menu. Just as the LOD 0 morph targets have to be generated from the LOD 0 mesh of the base skeletal mesh, each new morph target LOD level has to be generated from the same LOD of the base skeletal mesh in order for the vertices to match up properly. Note that if you have more than one LOD for your base mesh but no morph target LODs for them then when the mesh drops to the lower LOD no morph targets will be applied.

Morph Targets Animation

(Supported in Maya 8.5, 2008, 2009)

You can export Curve data to PSA file using ActorX and import as animation. You will need the MorphTargetSets to contain the Morph Target the animation needs. It matches with the name of the BlendCurve in Maya file. For example, if you have BlendCurve named "blink" in the maya file and export that as animation, the MorphTargetSet (linked to the SkeletalMeshComponent) should include "blink" for animation to work. To allow preview in AnimSetVeiwer, add the proper MorphTargetsets to PreviewMorphTargetSets.

In AnimTree, you can now use that animation in AnimNodeSequence and blend. It will accumulcate weights if there are multiple animations modifying same Morph Target.

Previewing Morph Targets

In Morph Target tab, you'll see list of Morph Targets with sliders. You will be able to change weights using sliders for any Morph Target.

morph_preview.jpg

Rename Morph Target

You can rename Morph Target in the edit box, but if the Morph Target is used in animation, changing name can invalidate the animation. However using MorphNodePose (or other MorphTarget related nodes) should be working fine if you set it correctly.

Delete Morph Target

Select which Morph Target to delete first and you can delete in Delete Morph Targets in the menu. You can use Select All to select/deselect all.

Update Morph Target

If base mesh has been modified (i.e. influence changes), when you open Morph Target viewer, it will prompt for allowing remapping. This does not work if the Morph Target (with previous mesh) has been incorrectly mapped. You can also use Update Morph Target menu in Morph Target Set.

Controlling Morph Targets

You can control Morphs through FaceFX, in Matinee, or in code.

Adding Morph Targets To An AnimTree

morph_animtree.jpg

To be able to blend multiple Morph Targets together at a time, you use an AnimTree. In the AnimTree Editor , you will see an input to the root "Animations" node labeled Morph. This is for connecting various type of Morph Node to. There are 2 main types of Morph Node:

  • Morph Pose - This is a static Morph Target from a MorphTargetSet.
  • Morph Weight - This is a node used to control the "strength" that it's child nodes are applied with. This type of node has a slider on it that allows you to modify the weight in the editor, and see the results.

Before you start adding Morph Nodes to the AnimTree, you first need to add the MorphTargetSets you want to use in the preview. Select the root Animations node, expand the PreviewMorphSets array and add them in there. When you place a Morph Pose node in the AnimTree, you tell it the Morph Target name to use. It will then search the MorphTargetSets you have specified to find it. In the actual game, the MorphSets array in the SkeletalMeshComponent is used instead.

Blending Morph Targets works differently than blending skeletal animations together. This is because they combine additively, instead of the result being an interpolation between various inputs. This means that you can connect multiple morph targets to the input of a node for example.

See the AnimTree Editor User Guide for more information about AnimTrees.

Using Morph Targets in Matinee

To use Morphs in Matinee...

  1. Make an AnimTree with MorphPoses going through MorphNodeWeight into the Morph track.
  2. Give the MorphNodeWeight a NodeName, this is the name you will use to drive it in Matinee.
  3. To see the morphs in the AnimTree Viewer, select the AnimTree, and set the PreviewSkelMesh, and PreviewMorphSets.
  4. Add your skeletal mesh to the world with the right click add actor/add SkeletalMeshMAT, this allows it to use the Animtree.
  5. Select the mesh, and in its properties go to SkeletalMeshactpr/SkeletalMeshComponent/SkeletalMeshComponent, and set the AnimTreeTemplate and MorphSets to the one you created.
  6. Create a Matinee, and add a NewSkeletalMeshGroup for you mesh, and right click on it and add a Morph Weight. Select it and in the properties add the NodeName of the MorphNodeWeight in the AnimTree to the MorphNodeName section. Now you can add key frames, and animate it like any matinee track. You can have multiple MorphWeight tracks at the same time, and blend them together. To animate a sequence of morphs, you have to turn one off as you are turning the other one on.

See the Matinee User Guide for more information about AnimTrees.

Examples

Player Customization: Fatness

Morph targets could certainly be a good option for customizing your characters by scaling bones for fatness. In this case, multiple morph targets could be used which apply a bulge to various parts of the base mesh. For example, you could set up a bulge morph target for the right bicep, one for the left calf, one for the stomach, etc. These can then be applied to the mesh with weights corresponding to the desired degree of blend with each of them. Of course, if you don't care about morphing individual body parts separately you could also just create a single morph target with max bulge for your base mesh and dynamically scale that up as needed, but with the individual pieces you can obviously generate much more variety.

The memory cost will be based on how many vertices you modify with your morph targets since only vertex deltas are stored for those that changed. The performance overhead is minimal for GPU-skinned meshes after the various morph targets have been accumulated since the morphing is done on the GPU. So, as long as you don't change the set of active morph targets or their weights, then it is basically free (performance-wise).