Flex animation

Flex shapes in action. TF2 characters in have two versions, pre-authored expressions (regular models) and the HWM (hardware morph) set of shapes. Half-Life 2 characters are based on the FACS, Facial Action Coding System

Flex animation with the VTA format is not compatible with $scale ("unmatched vertex anims").

Vertices cannot move more than 8 units (in any or all axes)

DMX has these:

If a shape name contains underscores, that shape becomes corrective. Don't put underscores in flexes that you want to expose to animators.

VTA format

The VTA format stores the morph shape keys separate from the mesh itself. It was used by Valve until the Orange Box. In Valve's newer games, facial animation is entirely defined within the DMX file of the mesh. There is no equivalent in .QC notation for some of the rules that take place in there. Refer to the DMX section down the page to see what has been figured out so far.

Authoring

Maya, Blender, 3DS Max, and XSI can export shape keys to VTA files. See each exporter's documentation for further details.

Valve standard flex

If you are creating a new humanoid character, your best bet is to use the same flex animation rules as Valve. These implement the Facial Action Coding System, a long-standing and widely used method of describing the full range of human expressions.

Confirm:Lip synch requires a set of FACS flexes.

You can find the scripts at sourcesdk_content/hl2/modelsrc/humans_sdk/Male_sdk/. There are two: standardflex_xsi.qci and facerules_xsi.qci. (bodyrules_xsi.qci is related, but as the name implies does not affect the face.)

For the scripts to work, you must have created and exported these standard shape keysin the order given. Then use this QC template:

Compiling

You should have a exported a VTA and a reference SMD from your modelling package.

$modelflextest"myreference.smd"{// must use $model, not $body, and "{" must be on the same lineflexfile"myflexanim.vta"{// source of vertex animationsdefaultflexframe0// relaxed positionflex"Frame1"frame1flex"Frame2"frame2}flexcontrollermy_group"Flex1""Flex2"// defines controllers that will appear in Faceposer etc.%Frame1=Flex1// assigns a controller to a flex%Frame2=Flex2}

This defines two flexes and maps them directly onto two controllers.

Bug:HLMV's flex slider boxes are populated from right to left. You will need to resize the window to see them all.

Defining flexes

Raw flexes are extracted from VTA frames, and support some preprocessing. They are not exposed by the model (flex controllers, below, are).

Used within a flexfile block to define a single shape. There can be up to 1024.

name

Internal name of the flex.

frame

The VTA frame the flex refers to.

position

The flex controller position (see also flexcontroller::range) at which this flex will reach full intensity.

split

Makes the flex read only vertices on one side of the mesh's Y origin. The value is the number of units (positive or negative) over which to smooth the divide. 0 disables.

decay

How fleshy the flex looks when animating. Vertex speed is a factor of distance moved: with the default of 1 those that move the most do so instantly, while those that move the least take 0.7 seconds to fully settle.

At 0, there is no lag on even the smallest movements. At over 1, the farthest-moving vertices start to lag too.

flexpair <name> <int> frame <int> [<flex options>]

Same as flex, but automatically creates two flexes with "L" and "R" appended to their names. The unlabelled integer is the equivalent of the split command (split itself is ignored).

defaultflex frame <int> [<flex options>]

Defines the model's relaxed position. The flex created is called "default".

Defining controllers

An input into the model, used to create animations. Takes the form of a slider. There can be up to 96.

<group name>

Seen with values like eyelid, brow, nose, mouth, and phoneme. Required, but has no apparent effect.

range

Defines the low and high slider values (default 0 and 1). This does not affect the flex itself, but can be used together with flex's position value. Reversing the values makes the slider reverse, not the flex.

<controller name>

As many display names as needed. A controller will be created for each.

%mouth

LOD

There is no need to create shapes for your LOD meshes; studiomdl will transfer them from the reference mesh as appropriate.

Stereo flexes (one slider with L/R control)

In order to be combined into a single "stereo" slider with left/right controls in Source Filmmaker or Faceposer, flexes must follow a particular naming convention; they must begin with left_ and right_. Here's an example:

If flex rules are used, all shapes must have one. In this scenario, this type can be used on shapes which don't need any pre-processing.

DMX supports 128 flex controllers and an unknown (but much higher) number of shapes.

Corrective shapes

Shape keys called "[shape name 1]_[shape name 2]_[etc]" will fade in when the shapes they are named after are active at the same time. For example "openJaw_openLips" will fade in whenever both the "openJaw" and "openLips" shapes are active.

Corrective shapes are applied additively as shown by this table:

Corrective shape selection

Active shapes

Corrective shapes applied

No. active shapes

a + b

a_b

3

a + b + c

a_b + a_c + b_c + a_b_c

7

When authoring corrective shapes make sure that you have all of the relevant shapes active before you start to sculpt.

Tip:Corrective shapes don't need to be made for combinations prevented by a domination rule.

Tip:Corrective shapes can have the same "master" flex specified more than once as a driver (for example "[shape1]_[shape1]"), allowing the corrective flex to have a quadratic, cubic or even quartic response to the master flex. This method can allow a single flex controller to appear to move vertices along a curved path (rather than just straight lines) by fading in several different shapes (that combine to create the overall target shape) at different rates.

TF2's HWM ("hardware morph") models use a standard set of 50 shapes and 35 controllers and about 100 (!!) corrective shapes made on an "if you see it break" basis.

Dmxedit

Dmxedit is the tool used by Valve to post-process DMX shape keys and create flex controllers.