This tutorial section covers how to set up animated morph targets/blendshapes scene in 3dsMax and get them into CRYENGINE. The terms "blendshape" and "morph target" are interchangeable, as they are named differently in 3dsMax/Maya/modo, etc. In this section we try to avoid the term blendshapes, since as 3dsMax users, you will be more familiar with morph targets.
This tutorial may rely on the free GameSDK sample project. We recommend that you download this from the Asset Database, import it into your Launcher, start it from there and then create a new level.
See this page to find out how to import a project to your Launcher. (The default folder for the GameSDK Sample Project when downloaded is C:\Program Files (x86)\Crytek\CRYENGINE Launcher\Crytek\gamesdk_<XXX>\GameSDK
)
Source 3dsMax scenes with exported CRYENGINE files:
sdk_blendshape_max_tutorial.zip (8.6 MB) (Extract this to the Assets folder in your GameSDK folder. See above for the default location of this folder.)
From engine version 5.6 onwards, the skeleton list is not used anymore, so you can ignore any references to it on the rest of the page.
The project folder is set to <GameSDK folder (see above)>\Objects\tutorial\animated_blendshape_tutorial\max
.
Please take this into account if you wish to use a different project location, but always stay inside your project folder when saving your project 3dsMax source files.
Before you continue with this tutorial, make sure to have read and understood the following:
If you just want to have non-animated morph targets available in your CRYENGINE characters, you can export your character as CRYENGINE *.skin format. A standard 3dsMax "Morpher" inserted before the "Skin" modifier is all you need.
Decrease the morph target position threshold in the Exporter options to 0.001 or lower if you get bad morph targets. This will make the Exporter include even minimal displaced vertices.
Pic1: Morph target export option in 3dsMax
The blue colored vertices are marked for CRYENGINE to update these vertex normals when morph targets are blended in addition to skin deformation.
3dsMax "Morpher" modifier is limited to 100 morph targets. If you intend to use more, then you must add a morph target, which also has a "Morpher" modifier with the morph targets no. 100 - no. 199, to your base mesh. Apply the same procedure to the next 100 morph target, etc.
Keep the names of your morph target meshes unique and reasonable. If you change their names after you set up the Morpher and the "*_blendWeightVertex" nodes ( which will be explained later in this tutorial), you must rebuild the "*_blendWeightVertex" nodes.
You must have a bound skeleton and a "Skin" modifier to be able to get animated morph targets/blendshapes into CRYENGINE.
You also need to create the skeleton triangle mesh for the CRYENGINE *.CHR file and have it skinned to a bone node, which is in the top of the deformation hierarchy, in our case the "Spine04" bone.
Your "Morpher" modifier is usually inserted between the base mesh object and the Skin modifier with Skin being on top of the modifier stack.
You are allowed to delete the morph targets after you added them to the Morpher modifier. In contrast to the Maya export pipeline, the morph targets are not needed for 3dsMax to CRYENGINE export.
You must be careful with move/rotate/scale transformations in your base mesh. Reset XForm and collapse the modifier stack of your base mesh before skinning and making the morphs.
Keep the maximum influence count to 8! For performance's sake keep it to 4.
CPU/Software Skinning supports 8 weights per vertex and morph targets/blendshapes.
GPU Skinning support supports 8 weights per vertex, but no morph targets/blendshapes.
We provide the CRYENGINE "sdk player" head with morph targets with this tutorial. Therefore, we only need to get the pieces together and make the 3dsMax scene ready for exporting to CRYENGINE.
As already mentioned, if you want to have non-animated morph targets/blendshapes with your CRYENGINE characters you do not need to follow the steps in this section any further. Export the dummy triangle mesh as a *.CHR skeleton file and the sdk_player_head mesh as a *.SKIN file. Also, check the morph target position threshold in the Max to CRYENGINE Exporter options.
We will go through each step required to set up a working "blendWeightVertex" node by "Parameter Wiring", but also provide a MaxScript to automate this process.
This step is optional: Once you set up the Morpher with its morph targets, you may hide or even delete the morph meshes you modeled.
By default the morph channels of the Morpher modifier are set to the range of [0..100] percent. Leave it as is since CRYENGINE expects values between 0 and 100.
For each animated morph channel you must create a node named <BLENDSHAPE_MESH_NAME> + "_blendWeightVertex", e.g. "sdk_player_head_brows_raise_blendWeightVertex". The "blendWeightVertex" nodes are then parented under the root node of the skeleton hierarchy.
Pic6a: Create a "Point Helper" node in 3dsMax and rename it following the naming convention
After created the the "blendWeightVertex" nodes you need to use the 3dsMax' "Parameter Wire" feature to map the values of each morph channel to drive the "Position_X" of the corresponding "blendWeightVertex" node. The follwing images below will show you what to connect in this process:
Pic6b: Start Parameter Wiring the base mesh with the Morpher to a "blendWeightVertex" helper node
Pic6c: Continue the parameter wiring to connect the morph channel to the "Position X" of the "blendWeightVertex" node
Pic6d: Pick the destination track of the connection
Pic6e: Finalize the control direction of the parameter wiring process
Rather than manually creating the helper nodes we provide a MaxScript below for the setup. All you need to change is the base mesh node name and the root of your rig if you have a different morph target/blendshape scene.
-- Delete any existing "*_blendWeightVertex" nodes you may have before re-running the script!
function ceCreateBlendWeightVertex argBaseMesh argRigRoot =
(
clearListener()
morphMod = undefined
hasMorpher = False
numMods = argBaseMesh.modifiers.count
currModNum = numMods
morphModStackNumber = undefined
blendWeightVertexList = #()
listOf_ID_MorphName_Helper = #()
while ( (not hasMorpher) OR (currModNum > 0) ) do
(
if ( classOf argBaseMesh.modifiers[currModNum] == Morpher ) then
(
hasMorpher = True
morphMod = argBaseMesh.modifiers[currModNum]
morphModStackNumber = currModNum
)
currModNum -= 1
)
if ( hasMorpher ) then
(
for n = 1 to 100 do
(
if ( (WM3_MC_HasData morphMod n) ) then
(
currChannelName = WM3_MC_GetName morphMod n
format ("\nMorph Target Channel Name: %") currChannelName
newPoint = Point size:15.0 axistripod:True cross:False box:True wirecolor:orange name:( currChannelName + "_blendWeightVertex")
newPoint.parent = argRigRoot
append blendWeightVertexList newPoint
fromSrc = argBaseMesh.modifiers[morphModStackNumber][n]
toTgt = newPoint.position.controller[1]
myStr = substituteString (fromSrc as string) "SubAnim:" ""
expr = myStr + "_"
paramWire.connect fromSrc toTgt expr
format ("\nParameters wired from % to %\n") fromSrc toTgt
tmpList = #(n, currChannelName, newPoint)
append listOf_ID_MorphName_Helper tmpList
)
)
)
else
(
messageBox ( "WARNING: Your base mesh object DOES NOT have a Morpher modifier. No \"_blendWeightVertex\" nodes created." )
)
select blendWeightVertexList
max zoomext sel
format "\n"
listOf_ID_MorphName_Helper
)
--ceCreateBlendWeightVertex $sdk_player_head_max $root
Paste the script into a tab of 3dsMax' Script Editor and execute it once. This function is now in memory. Run the command :
ceCreateBlendWeightVertex $sdk_player_head_max $root
If you decide to use another head mesh then don't forget to replace the $sdk_player_head_max and $root with your skinned mesh and root node name prefixed with a dollar sign $ as you've seen in the notation in our example.
You can also "un-comment" the last line of code by removing the double dashes "--" and run the script again (CTRL+E in MaxScript Editor).
All "*_blendWeightVertex" helper nodes must be inside the skeleton hierarchy. If you do not use this script then don't forget to parent them to your root nod of your rig.
Finally, you can add some morph target/blendshape animation. You will notice the "blendWeightVertex" joints moving while scrubbing the timeline when your have animated the three morph channels.
Pic6: Created and "parameter-wired" the "blendWeightVertex" nodes to the morph channels
For the results, please open the scene: animated_blendshape_tutorial_mid02.max
We will keep it short and let you consult the Autodesk 3dsMax documentation/tutorials on how to make animation.
Here are the steps in short:
Or you could open this animated scene: animated_blendshape_tutorial_mid03.max
Please save your final 3dsMax scene file to your project directory first. Instead, you could also open the provided final export scene: animated_blendshape_tutorial_end.max.
We will create three files by export. The exported *.CHR and *.SKIN file should be at the same location where you saved your source 3dsMax files. The animation *.I_CAF should be in a sub-folder of your YOUR_PROJECT_FOLDER\animation
directory.
YOUR_PROJECT_FOLDER\Animation\tutorial\animated_blendshape_tutorioal\max
The next tutorial section will cover how to set up the exported character assets in CRYENGINE's Character Tool.