Flex animation: Difference between revisions
TomEdwards (talk | contribs) mNo edit summary |
TomEdwards (talk | contribs) (clarified L4D2 flex) |
||
Line 3: | Line 3: | ||
[[File:Heavy expressions.jpg|thumb|350px|Flex shapes in action. [[Team Fortress 2|TF2]] characters have pre-authored expressions instead of the [[W:Facial Action Coding System|Facial Action Coding System]] set used in other Valve games.]] | [[File:Heavy expressions.jpg|thumb|350px|Flex shapes in action. [[Team Fortress 2|TF2]] characters have pre-authored expressions instead of the [[W:Facial Action Coding System|Facial Action Coding System]] set used in other Valve games.]] | ||
'''Flex animation''' (also called '''vertex''' and '''shape key''' animation) is the direct manipulation of [[vertex|vertices]] without the involvement of a [[skeleton]]. It is generally used to create [[Choreography creation/Creating Events/Facial expressions|facial expressions]] and [[Choreography creation/Lip synching|lip synch]], but can be applied anywhere on the model; Left 4 Dead 2's infected have | '''Flex animation''' (also called '''vertex''' and '''shape key''' animation) is the direct manipulation of [[vertex|vertices]] without the involvement of a [[skeleton]]. It is generally used to create [[Choreography creation/Creating Events/Facial expressions|facial expressions]] and [[Choreography creation/Lip synching|lip synch]], but can be applied anywhere on the model; Left 4 Dead 2's infected can have [http://www.valvesoftware.com/publications/2010/GDC10_ShaderTechniquesL4D2.pdf#page=11 their entire head shape changed through flexes]. | ||
Flex has some important limitations in Source: | Flex has some important limitations in Source: |
Revision as of 03:58, 3 March 2011

Flex animation (also called vertex and shape key animation) is the direct manipulation of vertices without the involvement of a skeleton. It is generally used to create facial expressions and lip synch, but can be applied anywhere on the model; Left 4 Dead 2's infected can have their entire head shape changed through flexes.
Flex has some important limitations in Source:
- Vertices cannot move more than 8 units (in any or all axes)
- Each flex can only move vertices in straight lines
- Flex animation cannot alter collision models
- Flex is not compatible with $scale
Authoring
Maya, Blender, 3DS Max, and XSI can export shape keys to VTA files. See each exporter's documentation for further details.
standardflex
Compiling
You should have a exported a VTA and a reference SMD from your modelling package.
$model flextest "myreference.smd" { // must use $model, not $body
flexfile "myflexanim.vta" { // source of vertex animations
defaultflex frame 0 // relaxed position
flex "Frame1" frame 1
flex "Frame2" frame 2
}
flexcontroller my_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.

Defining flexes
Raw flexes are extracted from VTA frames, and support some preprocessing. They are not exposed by the model (flex controllers, below, are).
flex <name> frame <int> [position <normal>] [split <units>] [decay <normal>]
- Used within a
flexfile
block to define a single shape.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 thesplit
command (split
itself is ignored). defaultflex frame <int> [<flex options>]
- Defines the model's relaxed position. The flex created is called "default".
Defining controllers
flexcontroller <group name> [range <normal> <normal>] <controller name> [<controller name> ... ]
- An input into the model, used to create animations. Takes the form of a slider.
<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.
Assigning
It can be very simple:
%myflex = myflexcontroller
Or it can be very complex:
%upper_right_raiser = right_lid_raiser * (1 - right_lid_droop * 0.8) * (1 - right_lid_closer) * (1 - blink)
The following operators are supported:
- Multiplication (*)
- Division (/)
- Addition (+)
- Subtraction (-)
In all cases, either static numbers or variable/flex/controller names can be used. Flexes will never exceed their position
value.

flexfile
block, but still inside $model
.

localvar <name>
can be used to store results of an equation for re-use later. Once you've defined one, just do %mylocalvar = val
.%mouth
This is a special variable that is read by the mouth
shader. When it is 1, the mouth interior is fully illuminated.
LOD
To disable flex, add nofacial
to an $lod block.
There is no need to create shapes for your LOD meshes; studiomdl will transfer them from the reference mesh as appropriate.
Using
Faceposer
See Choreography creation/Creating Events/Facial expressions.
Code
[Todo]