Sunday, June 19, 2022

Converting Morphs to Shapekeys and Morph Presets

A morph in DAZ Studio is either a driven pose or a shapekey, or a combination of both. Driven poses are application-specific, so if you want to export morphs to a game engine you need to convert the driven poses to shapekeys first. This is done with the Convert Morph To Shapekey button in the Advanced Panel > Morphs panel. However, if your character has many morphs, it takes a very long time to convert them all. Let us estimate how long.

Each facial morph typically affects all faces bones, so the time needed to evaluate the final location of a face bone is proportional to the number of loaded morphs. Hence the time needed to evaluate a single morph grows linearly with the number of loaded morphs, and the time needed to evaluate all morphs grows quadratically. To reduce the conversion time, we can divide the morphs into manageable batches, which are loaded, converted and saved in temporary files. The conversion time will then be proportional to the total number of morphs times the batch size, which is much smaller if we keep the batch size down. When all files have been written, they can be loaded with the Import Custom Morphs tool and exported to the game engine.

The shapekeys are stored in morph preset files, which should be readable by DAZ Studio. Unfortunately, I have not yet managed to load the presets in DAZ Studio, but the files can be read by the Import Custom Morphs tool which is what we need for this application.

The tools that we are going to use are located in the Advanced Setup > Morphs Panel.
Load some morphs, e.g. the expressions. Press Convert Morphs To Shapekeys are select the morphs that you want to convert.
Here is the original angry morphs, using the driven face bones.
And here is the converted shapekey.
Morph presets are save as individual files, one for each shapekey, in the directory specified below the Save Morph Preset button.
In the popup dialog, we specify which shapekeys we want to save a morph presets. We can also change the directory, but here there is no folder button that opens a file selector.
The duf files are saved in the specified directory.
Once all batches have been converted and saved as morph presets, we reload all the shapekeys with the Import Custom Morphs button. Since we are going to export the shapekeys to a game engine afterwards, using rig property drivers is unnecessary.