Monday, September 27, 2021

Morphing Armatures

Update:

Surody discovered that automatic armature morphing does not work when rendering animations. To circumvent this problem, a new tool for rendering a sequence of frames has been introduced, see Morphing Armatures and Rendering.

Original post:

In DAZ Studio it is possible to create morphs that change both the character mesh and armature, so called ERC (Enhanced Remote Control) morphs. In Blender that would correspond to morphs that change the rest pose of an armature, but that is not supported by Blender. In the past such ERC morphs have been ignored, but with the latest commit of the DAZ Importer they can be dealt with.


In order for ERC morphs to be loaded, the global setting ERC Morphs option must be enabled, otherwise morphing armatures will not work. In most cases it is not necessary to morph armatures, and by disabling this option we can eliminate some overhead.

Assume that we want to animate how dr Jekyll is transformed into mr Hyde. Here we have three frames from that sequence, with the Hyde morph at 0%, 50%, and 100% respectively. The mesh is transformed nicely, but the armature does not follow suit.
There is a new tool that takes care of that. After the value for the Hyde morph has been set, press the Morph Armature button in the Morphs panel.
The armature now jumps into place. Here is mr Hyde at 50% and 100% with his morphed armature. The bone lengths do not change even though the distance between the bones has increased, but that does not really matter. What matters is that the bone heads, i.e. the pivot points, are at the right location. We see that the lCarpal4 bone does not move for some reason, probably because it has been misspelled.

That the pivot points are located correctly is important when the character is posed. Observe the right shoulder in the picture above.

It is inconvenient to have to press the Morph Armature button for each frame change, and you may wonder if there is a way to automate that. The answer is yes, but the procedure is somewhat awkward. However, it is awkward on purpose, for two reasons.

  • Morphing armatures is a quite expensive operation, which we don't want to enable by accident. E.g., the frame rate for the Jekyll-to-Hyde sequence dropped from 54 fps to 8 fps when auto-morphing armatures was enabled.
  • Auto-morphing relies on application handlers, which would not be defined if the DAZ Importer is disabled, or if the blend file is moved to another computer, e.g. at a render farm.

To make auto-morphing work even when the DAZ Importer is disabled, we have to load the file morph_armature.py into the text editor and register it, in the same way as the stripped runtime system was loaded in previous releases of the DAZ Importer.

To enable auto-morphing in a single session:

  1. Open the file morph_armature.py in a text editor window. It is located in the runtime subfolder.
  2. Run the script by pressing the right-pointing triangle button (Run Script).

To make it persistent, so auto-morphing is enabled automatically every time the blend file is opened. This is what you want to do if you send the file to a render farm.

  1. Open the file morph_armature.py.
  2. Enable the Text > Register checkbox.
  3. Save the blend file.
  4. Reopen the blend file.

When automorphing is enabled, only selected armatures are morphed. This can be used to control which armatures are morphed, although deselecting an armature does not change performance very much. The handler toggles into edit mode once for each frame change and updates the rest pose of all selected armatures. Typically going in and out of edit mode is the expensive operation, and that is only done once independent on the number of armatures.

Here we see the difference between the armature being selected or not.