Sunday, March 24, 2024

Fixing Sloping Shoulders

When we imported the UE4 animation in the post on FBX Files and BVH Retargeter, we noticed that the collar bones have a quite unnatural pose; the shoulders are sloping. This is unfortunately something that happens quite often, but not always. It depends on the rest pose of the rig in the BVH file.

This can sort of be fixed with the Shift Animation tool. Rotate the collar bones up, and then rotate the upper arms down to compensate. However this is quite annoying and the result is not always good, so I found a different solution. The new Clear Bones tool clears the animation of the collar bones, which usually shouldn't move so much anyway, and then rotates the upper arms so their rotation in world space remains unchanged.

Here we have a typical situation. The collar bones slope far too much.
With the collar bones selected, press Clear Bones.
Now the collar bones don't slope anymore, and the arms remain oriented in the same way as before. The pivot points of the upper arms have moved, since the collar bones are rotated differently, but the arm's world space rotation is unchanged.

Friday, March 22, 2024

FBX Files and BVH Retargeter

As the name suggests, the BVH retargeter imports animations from BVH files. However, it appears that popular sites like Mixamo only offer animations in FBX format these days. Recently user GeneralProtectionFault suggested that one could use the BVH retargeter for FBX files as well, by first importing the FBX file with Blender's built-in FBX importer and then writing the animation as a temporary BVH file. This technique has previously been used in this add-on.

Support for FBX files has been implemented in the development version of the BVH retargeter. We can notice that the "Load BVH File" button has been renamed, and is now called "Load BVH or FBX File". To import the animation, we select our target rig and press "Load And Retarget" as usual.
Select the Capoeira.fbx file which can be downloaded from Mixamo or from the issue in the bug tracker.

Also note that the panel to the right has changed. The add-on now uses the standard Blender way to specify the orientation of the rig in the animation file.

And now our character does the capoeira.

The DAZ Importer has been able to import facial animations in the FaceCap and LiveLink formats for a long time, see e.g. this FaceCap test. Bouich Jules found another good way, and it’s UE4 facial animation, used here by QUICKMAGIC https://www.quickmagic.ai/index/. Again the files are in FBX format, so we need to do a similar trick as above. First the add-on imports the FBX file with Blender's FBX importer, and then copies the FACS animation from the imported mesh to the target rig. A sample file can be found in the issue in the bug tracker.

The complete FBX animation includes both the body poses and the FACS morphs. To import it to our target character we proceed in two steps. First we Load And Retarget the FBX file in the same way as we did with the capoeira file above.
Our character now moves, but her expression remains blank.
Let us now import the facial animation. If you have not already done so, go to the DAZ Importer and import the FACS morphs and make all bones posable.
Now open the new FACS panel in the BVH retargeter tab. These tools used to be located in the DAZ Runtime > Morphs > FACS panel, but it makes more sense to import the entire animation from the same add-on.

With the target character selected, press Import FACS From FBX File.

Select the same FBX file as above. Disable the New Action option so the face and body animations belong to the same action. Alternatively, we can make a new action and push both actions down on the NLA stack.
And now our character both moves and smiles.

Sunday, February 4, 2024

Add-on Split

The DAZ Importer add-on has grown to become a huge beast, which contains lots of specialized tools that are of no interest to most people. In an attempt to reduce the size of the add-on, I decided to split it into several pieces and move some tools into specialized add-ons.

There are now five separate add-ons:

The DAZ Importer and MHX Runtime System are stand-alone add-ons, but the other three require that the DAZ Importer is installed and named import_daz.

The tools are located in panels in the DAZ Setup tab.
The DAZ Rig add-on also adds a panel in the DAZ Runtime tab. 

The new add-ons are poorly documented, but at least all of them have wikis:

 

Important note on installing dependent add-ons: 

The DAZ Importer must be called import_daz. If we download the development version as a zip file, Bitbucket adds the string "Diffeomorphic" and the commit identifier to the file name. So the zip file may be called Diffeomorphic-import_daz-c400c95d0ec9.zip. This is not a problem if we only install the DAZ Importer, but if we download and try to install dependent add-ons like the Preset Exporter, we get and the error message:

  File "d:\home\blenders\blender-3.00\3.0\scripts\modules\addon_utils.py", line 351, in enable
    mod = __import__(module_name)
  File "C:\Users\Comsol\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\Diffeomorphic-export_daz-2e4b7ccd9acb\__init__.py", line 42, in <module>
    import import_daz
ModuleNotFoundError: No module named 'import_daz'


The problem is that the DAZ Importer is not called import_daz.

If we go to the place where Blender puts the add-ons, which on my system is C:\Users\Comsol\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons, we see that it has copied the content of the zip files, but the folders have bad names.
Rename the DAZ Importer to import_daz. We can leave the name of the other folder unchanged.
When we refresh the preferences window, Blender no longer finds the installed add-on.
Disable the missing add-on. We can now search for the add-ons that contain the string "daz" and enable them. The DAZ Importer add-on must be enabled first.

 

Simpler Method

There is an alternative, simpler method to rename the import_daz add-on.

Navigate to the place where you downloaded the zip file. Open it in WinRAR or a similar program. It contains a single folder with the problematic name.

Change the name of the zipped folder to import_daz. We can also change the name of the dependent add-on in its zip file, although that is optional.

We can now install the add-ons from zip files, and they will be correctly named.

Tuesday, January 30, 2024

Exporting a DAZ Figure, Redux

Recently we discussed how to export a figure for use in DAZ Studio. However, we noted that the eyes did not look right in DAZ Studio, because the Genesis 9 eyes are a separate figure. To deal with this situation, the Save DAZ Figure tool has been updated. This post describes how to use it to create a character that can loaded in DAZ Studio.

First we prepare the character in Blender. Meet Nana, a Genesis 9 female character with the underwhelming stature of 95 cm, which should be around 3'2 for American readers. Since the figure was originally imported with the Easy Import tool, the rigs have been merged so there is only one armature with several meshes.

Now create a new empty directory where the files will be created.

Add this directory to the content directories in the global settings.
While we are in the global settings dialog, we can also update the author information.
Next we import our reference figure. Since we don't want to merge rigs, we use the Import DAZ Manually button in the Advanced Setup panel. We could also use Easy Import, but then we have to uncheck the Merge Rigs option.

Set Mesh Fitting to one of the Unmorphed settings. Since this figure will be used for reference, we don't want to add any morphs to it. Also choose a viewport color that distinguishes it from the other character.
Here we have both figures. Note that the reference figure consists of several armatures.
With the target rig active and the reference rig selected, press Save DAZ Figure.
We need to change the morph name and the root directory.
When the required fields have been fixed, we press OK.
The export script now creates several new folders under the specified root directory.
Files called Nana.dsf have been created, one for each separate subfigure. Here is the file for the Genesis 9 Mouth.
In DAZ Studio, add a new base directory.
Select the directory that contains the new morphs.
The new directory appears in the directory tree. We could of course also have copied the content of the Nana for G9 folder to an existing base directory, or exported the files to an existing directory, but if we save the files in an empty directory we can zip them together and distribute our figure.
Add a Genesis 9 figure to the scene. The Nana morph appears in the Shaping tab.

Nana for G9 can be downloaded from https://www.dropbox.com/scl/fi/swldigd2jphvcuu430tcf/Nana-for-G9.zip?rlkey=zvloy2xh6bzipo81n33zcj9je.

Saturday, January 27, 2024

Save DAZ Figure

Update:

The Save DAZ Figure tool has been improved, see Exporting a DAZ Figure, Redux.

Original Post:

A recent issue in the bug tracker made me implement a tool for saving figures for further use in DAZ Studio.

Import a base figure from DAZ Studio and tweak the mesh and bone locations. No vertices may be deleted or added.
Rename the mesh to what we want the figure to be called.
In the global settings, add author information in the Presets section. This information will be added to the figure file, and the author field also influences where it is stored.
Select the preferred root path at the top of the DAZ Setup tab. The preferred root path is use in several places in the addon, including where to save the file here.

Now import the same figure again, but with Mesh Fitting set to one of the Unmorphed options. Since this is our reference figure, the mesh topology and bone hierarchy must be the same as the other mesh.

With the target mesh active and the reference mesh selected, press Save DAZ Figure in the Advanced Setup > Morphs section.
A file selector opens. We could select a filename and save the figure file in the chosen directory, but there is also another possibility. If we enable DAZ Directory, the file will be saved in a location where it can be found by DAZ Studio. We can change the preferred root path here. The relative path is deduced from the mesh URL and the author name. The global author information can also be changed here.
The file is stored in the specified location.
Now open DAZ Studio and load a Genesis 9 character.The new morph should be found in the Shaping tab

Note that the eyes are popping out. The Genesis 9 eyes are a separate object and the procedure needs to be repeated for them.

Sunday, December 17, 2023

New Way to do Morphing Armatures

In DAZ Studio there are ERC morphs that change the rest pose of an armature. The DAZ Importer has supported such morphs for some time, see the blog posts on Morphing Armatures and Morphing Armatures and Rendering. Basically, the plugin enters edit mode at each frame and changes the rest pose. This method has several drawbacks: it is slow, it does not work with the standard animation tools, and it cannot be exported to game engines.

Recently @AlternateDreams in the DAZ forum suggested an alternative way to do morphing armatures. Basically the idea is to apply the morphed armature as a pose, then use a corrective shapekey to fix the mesh. The corrective shapekey is easily generated in Blender using the armature deformation as base, as explained in the video below.

https://www.youtube.com/watch?v=Qoboh-da_9Q

This new way of doing morphing armatures has now been added to the DAZ Importer.

The generation of ERC morphs is controlled by the global setting ERC Method. It can take three values:
  • None: ERC morphs are ignored (the default).
  • Translation: ERC morphs are approximated with translations and a compensating shapekeys (the new way).
  • Armature: ERC morphs change the rest post (the old way).

We set it to Translation.

Select a Genesis 8 Male and import the Massive Monster as a custom morph. We also transfer the shapekeys to the clothes.
Dr Jekyll and mr Hyde, perhaps. Note that the morph moves the bones apart. It only moves the bone heads, but the length and orientation of the bones remain unchanged.
Because the bone orientation does not change, we can still import poses and get a reasonable result.
Here are the shapekeys. From the original shapekey to the left, we subtract the influence of the bone translations in the middle, and get the shapekey to the right. This shapekey, together with the deformation from the bone translations, gives back the original deformation.

The new way of doing morphing armature has several advantages: it doesn't require any special buttons or hooks, it works with file linking, and it can be exported to game engines. However, it doesn't work with advanced rigs like MHX or Rigify, and it is only an approximation that can sometimes give erroneous results. Therefore it is disabled for FACS and other standard morphs.