Tuesday, November 30, 2021

Morph Suffixes

It may happen that different morphs have the same name., e.g. if the morphs affect different geografts. DAZ Studio distinguishes between such morphs because the morph files are located in different folders, but in Blender the morphs are driven by the same armature, and loading a morph for the second geograft overwrites the morph for the first. To distinguish between such morphs we can load the morphs with a suffix.

The Import Custom Morphs tool has a new option: Use Suffix. It can take on three values:

  • None: Don't add morph suffixes. This is the default.
  • Geografts: Add the geograft name as a morph suffix.
  • All: Add a suffix to all morphs.

Our character has the Headlights geograft by Meipe, and we want to import the Areola Inflate morph to both the left and right headlight. Select each target mesh in turn and import the morph, with Use Suffix set to Geograft.
We now have two different morphs affecting the two geografts. If we had loaded the morphs with Use Suffix = None, the morph for HeadLight_R would have overwritten that for HeadLight_L, and we would only have a single morph called Areola Inflate.
The Import Pose tool has an option which specifies which geograft is affected by the morphs in the shape preset file. If Affect Geograft is set to the default value (-), the morphs are loaded without a suffix as usual.
If we load morphs with Use Suffix = All, suffixes are added to all morphs. This can be used if you want to reload morphs without overwriting the old ones for some reason. A new option appears where you specify the suffix.
Here some morphs are imported with Suffix = foo.

Suffixes can also be added to the standard morphs. Here the Geograft setting is not useful, since geografts don't have standard morphs, but the All setting adds a user-specified suffix to all morphs.
Finally we can also add suffixes to favorite morphs using Easy Import.

Saturday, November 6, 2021

Morphing Armatures and Rendering

Recently we introduced support for ERC morphs, which not only affect shapekeys and bone poses, but also change the armature in edit mode. By adding a handler we could update the armature morphs on each frame change, allowing ERC morphs to be animated. However, Surody discovered a serious flaw with this: automatic armature morphing only works in the viewport but not when rendering animations. The following image illustrates what can happen.

Apparently the problem arises because rendering and scene update run on different threads. The Blender documentation says the following.

Note on Altering Data

Altering data from handlers should be done carefully. While rendering the frame_change_pre and frame_change_post handlers are called from one thread and the viewport updates from a different thread. If the handler changes data that is accessed by the viewport, this can cause a crash of Blender. In such cases, lock the interface (Render → Lock Interface or bpy.types.RenderSettings.use_lock_interface) before starting a render.

So the suggestion is that we should enable Render > Lock interface. That does not work, however, because Blender throws an error when we try to enter edit mode, and nothing is rendered at all.

To circumvent this problem, a new button has been introduced in the Utilities panel: Render Frames. This tool renders the active frame range as a sequence of still images, and updates the armature morphs before rendering each frame. There is also an analogous tool for doing OpenGL rendering. All render settings are found in the usual places. There is an option whether we want to morph all armatures in the scene, or only the selected ones.

And now the rendered images look much better.

Warning: Adding automatic armature morphing as described in the previous post is risky, since it works in the viewport but not during render. Therefore, this possibility will probably be removed in the future.