Friday, December 4, 2020

Morph Transfer Progress

Something that happens quite often to me is that I have a finished character with merged geografts, and then realize that I want to add some more morphs to it. This cannot be done directly, because by merging geografts the vertex numbers change, and it is no longer possible to add morphs. A long time ago Engetudouiti came up with a work-around: reload the body and geograft, add morphs to the reloaded meshes, and then transfer the shapekeys to the character mesh. The problem is that morph transfer is painfully slow, because it uses the data transfer modifier many times. So I came up with some improvements which makes morph transfer much faster, although they do not work in all cases.

After we have reloaded the character and merged rigs and renamed the meshes for clarity, the situation typically looks like this. We want to load morphs to the reloaded body and geograft, and then transfer them to the merged mesh.

The first step is to delete the reloaded armature, and reparent the body and geograft meshes to the original armature. Parenting is necessary to create drivers for the morphs. It is also needed if we want to load the standard morphs (face units, expressions and visemes), because the importer decides which type of character it is dealing with by looking at the children's fingerprints. (The fingerprint of a mesh is the number of vertices, edges, and faces, and is a reasonably safe way to identify the character). The merged mesh does not have a known fingerprint but the reloaded body has, so standard morphs can imported.

If we are dealing with a Genesis 3 or Genesis 8 character, we are done already. In this case the morphs are face rig poses, which deform the merged mesh as well.

However, if the morphs involve shapekeys, these must be transferred to the merged mesh using the Transfer JCMs or Transfer Other Shapekeys buttons. With the source mesh (which we transfer from) active and the target mesh or meshes (which we transfer to) selected, press Transfer Other Shapekeys.

At the top of the pop-up dialog there is a new option which determines the transfer method. It can take on four different values:

  • General: This is the old transfer method using the data transfer modifier. It is very slow but works well in general if you have the patience.
  • Nearest Vertex: Transfer shapekeys from the nearest vertex on the source mesh. This usually works well to transfer shapekeys to clothes and is the default. Computing the nearest vertex involves a slow step because a matrix of distances between all vertex pairs is computed, but this step is only done once for each target mesh, and once it is done the actual morph transfer is fast. Moreover, this matrix is calculated with Numpy which is much faster than pure Python.
  • Body: Only transfer between the first vertices, until a vertex with changed location is encountered. This works for shapekeys on the body that do not involve the geograft, because the merged vertices have higher vertex number than the original ones. This method is very fast when it works.
  • Geograft: Transfer shapekeys to the nearest vertex of the target mesh. Note the difference to the Nearest Vertex method. There each target vertex is paired with a source vertex, here each source vertex is paired with a target vertex, and nothing is transferred to unpaired target vertices. Use this to transfer shapekeys from the geograft to the merged mesh. Performance is the same as for the Nearest Vertex Method.

First we transfer a shapekey from the body mesh to the merged mesh. In the pop-up dialog, chose the Body transfer method. Also make sure that Use Driver is enabled, so we can control the shapekeys from the rig.

Next we transfer shapekeys from the geograft, so this time we choose the Geograft method. Here it is important that Ignore Rigidity Groups is enabled.

Both types of shapekeys have been transferred to the merged mesh and can be controlled from the Custom Morphs panel.

The main application of the transfer tools is to transfer Joint Corrective Morphs (JCMs) from a character to her clothes. Here we have imported G8F with the Bardot outfit, and loaded the JCMs to her body. With the skirt selected and the body active, press Transfer JCMs.

Choose the Nearest Vertex method since we are transferring morphs to clothes. We only select the morphs that are interesting for the skirt, i.e. the abdomen, pelvis and thigh JCMs. Shin and Foot JCMs would affect the skirt, but that is not desirable. It is only necessary to transfer morphs to tight-fitting clothes, whereas the transfer to loose-fitting clothes may result in undesirable artefacts. The skirt only fits the body tightly around the hips and upper thighs, so only those morphs should be transferred.

Also the thigh morphs create problems at the bottom of the skirt, where it is far away from the body.

To avoid such artefacts, we can control the influence of the shapekey with a vertex group, as shown above. With this trick the problems at the bottom of the skirt are gone.

Corrective morphs are usually not by themselves so important for clothes, except for very tight-fitting ones. The main reason to transfer morphs is to keep the clothes on top of the skin, to avoid that skin pokes through. Alessandro Padovani pointed out that there is an alternative method to achieve this, which circumvents the need to transfer morphs altogether: the shrinkwrap modifier. The button Add Shrinkwrap adds a shrinkwrap modifier to the selected meshes, keeping it above the active mesh. This button was already available in the Visibility section, but is now available next to the transfer morphs buttons as an alternative.

Select the body mesh. In the pop-up dialog we choose which meshes that need to stay on top of the skin.

A shrinkwrap modifier now appears in the modifiers tab.

Here is how the Bardot top behaves when posed, without and with the shrinkwrap.