Importing Morphs and Shape Key Animations
This page will guide a beginner through the least possible amount of steps required to import new morphs and shape key animations into S&box, as well as have them work and useable in the Animgraph or Face Poser, it assumes you already know how to create shape keys and navigate Blender, it will not show how to create them as that is related to neither ModelDoc nor S&box, and guides for it already exist online.
We will be using "Blender" as it is the most widely used free modelling program, and the plug-in "Source Export Tools".
- Create the shape keys
- Go to "Scene Properties" and then "Source Engine Export", change "Export Format" to "DMX"
- Use the latest DMX version, as of writing this it's "Binary 9" and "Model 22"
- Select the checked "MeshName.dmx" under "Source Engine Exportables" (in my case "citizen.dmx", check if unchecked)
- Go to "Flex Properties" and press
Exportto export the model.
Generate Corrective Shape Key Driversbefore export; If they're separate in left and right then you'll need to set the "Stereo Flex Balance" to "Y", as X is the forward axis in Source 2, this will generate a vertex group to differentiate left morphs to right morphs along the Y-axis.
As mentioned before, morphs are animation-driven, this means that even if morphs will appear when importing the model, you won't be able to use them until there's at least 1 animation. If you planned for this model to be static and/or have no animations, you can simply reuse the model itself as a "Simple Animation".
- Import the Mesh in ModelDoc
- Add any animation, use the model itself if you don't plan on having animations.
- Add a material that supports morphs (in "Material Editor" check the
Morph Supportedbox under "Animation").
If you go to "Morph Explorer" and press
Enable Manual Slider Control you will be able to manually drive the sliders, this is only a debugging tool, if you want to then see the animations drive the sliders, press
Allow animation to drive sliders.
Please, if someone knows a way to export shape key animations in the DMX format, feel free to edit this part or tell me on Discord so I can try it out and change the guide, Grodbert#3873.
- Create your shape key animation
There needs to be at least one animation as the target for the export, this can be either an Armature or Mesh animation, in this case, we'll do a simple Armature animation that does nothing.
- Create an animation that lasts the same as your Shape Key Animation, even if it's just keyframing the location of a random bone in the first and last frame.
The image above shows 2 animations in the NonLinear Animation Editor, you don't actually have to push down any animation, it is just to show that there is an animation for Armature, one for Shape Keys, and that they last the same.
- Export in FBX format, the object types will only need to be "Armature" and "Mesh", "Apply Scalings" set to
- Import the animation in Modeldoc as a "Simple Animation".
This will be the final result:
Note the morph sliders moving because of the animation, they are not limited by 0 and 1.