Friday, April 30, 2021

MHX Runtime System Has Moved

The MHX runtime system has been moved to a separate add-on. There are several reasons for this:

  1. Both the Daz Importer and the BVH retargeter add-ons are aware of MHX. This meant that both add-ons used large amounts of code that were essentially the same, although slightly different. Maintaining two versions of the code was becoming unmanageable.
  2. Some features that are useful for DAZ characters were only available in the BVH version, like FK/IK switch for animations.
  3. Users that don't use the MHX rig don't need to install the MHX runtime system. It is just dead weight.
  4. The Daz Importer tab contains too many panels, especially if you load many different types of morphs.

The code that generates the MHX rig is still part of the Daz Importer. There is a clear analogue to Rigify here; the code that rigifies a DAZ armature is part of the Daz Importer, but the Rigify runtime system is not.

I intended to make the documentation more complete before making a public announcement, but recently I have been working on MHX, and don't want to duplicate that work in the old system.

The main documentation page for the MHX RTS is http://diffeomorphic.blogspot.com/p/mhx-runtime-system.html. The repository itself is located at https://bitbucket.org/Diffeomorphic/mhx_rts.

Friday, April 23, 2021

Save Pose Preset

 Yesterday I described a method to import animations back into DAZ Studio. However, it was quite complex, involving changing global settings to values that were designed for debugging, and still didn't work well in many cases. The main culprit was the idea to export the animation as a BVH file. The BVH format is old and has lots of quirks and cannot capture all aspects of DAZ and Blender rigs. Besides, a BVH pipeline depends on the quality of Blender's BVH exporter and DAZ's BVH importer, neither of which is under my control.

It is a fact of life that something is always lost in translation, and the more translations you make the more is lost. So using an intermediate format like BVH means two translations: from Blender to BVH, and from BVH to DAZ Studio, and both may involve data loss. Better to go directly from Blender native to DAZ native. This is the idea behind the new method to send animations from Blender to DAZ Studio.
Import an animation to a Genesis character in Blender (imported with standard settings, and not with any debug options turned on). The animation must be stored as an action, even if we only want to export a single pose. Press the new Save Pose Preset button.
A file selector appears. Save the file to a directory that will be visible in DAZ Studio, i.e. to a subdirectory of one of the DAZ root paths. The options specify the first and last frame being exported, and the frame rate (frames per second).
In DAZ Studio, the new file should appear in the content library. You may have to refresh the folder first by right-clicking on it.
And now Aiko is dancing away in DAZ Studio.

Importing an Animation Back into DAZ Studio

Update 2021-04-23: 

This method is obsolete. The new way to get an animation from Blender to DAZ Studio is to save it as a pose preset, see https://diffeomorphic.blogspot.com/2021/04/save-pose-preset.html.
 

Original post:

There was a request to import an animation made in Blender back into DAZ Studio. This turned out to be quite difficult, but I came up with a method that works, at least in some cases. However, there are glitches, which may be due to bugs to my code, or to imperfections in Blender's BVH exporter or in DAZ Studio's BVH importer, or some incompatible settings.
Import a DAZ character into Blender and animate her. Before exporting the animation, we need to create a modified action with the new tool Unflip Action, which is found near the bottom of the Pose panel.
The tool options lets us specify the start and end frames. By default both equal one, which corresponds to exporting a single pose. In this case we change the end frame to 250 to export the entire animation. A new, "unflipped", action is created, but nothing has happened to our character. The unflipped action is not meant for her.
 
We need to import the character again, but first we must change some global settings. Set
  • Unit Scale = 1.0
  • Z Up = off
  • Orientation = DAZ Unflipped
These are debug settings which we normally would not use for something that is to be used in Blender. However, in this case we want an armature with the same size and orientation as in DAZ Studio.
Here we have imported Aiko again with the new settings. Note that the new character is 100 times bigger than the original one (the units are centimeters, not meters), that the Y axis points up and the Z axis points forward, and that the bone orientations are weird. This is how the bones are oriented in DAZ Studio, which unlike Blender does not demand that the bones are directed along the local Y axis.
We now open the Action editor. The Unflip Action tool created a new action, whose name ends with "_Unflipped". Select it.
The unflipped rig now has a version of the animation that works for it.
Export the animation as a BVH file (File menu > Export > Motion Capture (.bvh)).
In DAZ Studio, import the BVH file.
And now the animation has been transferred to DAZ Studio.

There are a number of issues with the animation in DAZ Studio. E.g., in Blender Aiko is turning around several times, but in DAZ Studio she is stuck after making half a turn. It seems like the hip bone can not be rotated more than 180 degrees, at least if we use the default settings.

Sunday, April 18, 2021

Simulations moved

Update: 

For updated information, see the documentation on the Simulation Section.

Original post:

When I imported some characters with simulation turned on, Blender complained about dependency loops. Apparently the problem had to do with multiple collision modifiers. To avoid this, and because the philosophy of the Daz Importer is to provide tools rather than doing everything on import, the simulation setup has moved.

The Simulation group in the global settings is gone, except for a single Simulation option in the Meshes section. This checkbox only determines whether pinning groups are loaded.
With Simulation turned on, a pinning group is created as before. The tools for setting up the simulation are now located in the Advanced Setup panel, in the new Simulation group.
  • Make Deflection: Create a low-poly deflection surface for active mesh. Only for Genesis characters.
  • Transfer Vertex Groups: Transfer all vertex groups from the active mesh to selected meshes. The intention here is to transfer vertex groups from the character to the deflection object.
  • Make Collision: Add collision modifiers to the selected meshes.
  • Make Cloth: Add cloth modifiers to the selected meshes.
Here is the original character, the deflection mesh, and the deflection mesh with subsurf applied
Here the vertex groups have been transferred to the deflection mesh.
The Make Collision tool sets up the selected meshes as collsion objects.
The Make Cloth tool adds cloth modifiers to the selected meshes. The options are the ones that use to be in the global settings, except that we can choose the pinning group.
 
With collision and cloth set up, we can now proceed with the simulation.

Sunday, April 11, 2021

DForce Simulations

Update: 

Simulations are no longer created during import. Instead the simulation information is stored inside the imported meshes, and can be recreated with the Advanced Setup > Simulations > Make Simulation tool. See the documentation on the Simulation Section for more information.

Original post:

Many modern clothes use dForce, which simulates draping and movement of garments in DAZ Studio. The corresponding feature in Blender is cloth simulation, which has been considerably improved in Blender 2.90. For some time, Alessandro Padovani has nagged me about including dForce simulations in the DAZ Importer, and finally I got around to do it. Actually, this is not the first time that I attempted to do this, but the previous attempt was half-baked and never took off. Thanks to Alessandro's excellent help, this time things worked out better. We can now import dForce simulations in a useful way with the development version of the DAZ Importer.

First of all, we need to enable Simulation in the Global Settings, otherwise everything simulation-related will be ignored when the file is imported. We then proceed to import the DAZ character as usual. This file contains a Genesis 8 Female with Toulouse hair and the Bardot outfit that ships with DAZ Studio. The Bardot outfit is dForce compatible.
Select the body mesh and open the modifier tab. The body has a new collision modifier, which means that it will act as a collision object. The modifier settings are found inside the Physics tab if you need to change them. The DAZ Importer changes some settings, mainly it increases the collision quality.
The Bardot top has two new modifiers: a cloth modifier and a collision modifier. We can change the settings of both inside the Physics tab, but I left the settings unchanged. For some reason, the Bardot skirt did not receive a collision modifier.
The top and skirt also have subsurf modifiers, but the simulation seems to work better if you delete them. This improved performance from 0.25 fps to 0.30 fps on my machine, and also made the end result better. Perhaps this happens because the Bardot skirt is already a high-poly mesh.
The simulation parameters can be tweaked in the physics tab. One important parameter is the pin group, which is deduced from the dynamics strength parameters in DAZ Studio.
Here is the pin group for the Bardot skirt. The blue region is fully affected by the simulation, the yellow region only slightly.
 
The next step is to load an animation. I used the file provided by Alessandro.
Here is a typical frame in the animation. The garments has some interesting movements, but in my opinion the wrinkles are too extreme. We need to smooth them out.
Before we do anything else, we need to bake the simulation. Otherwise it will be lost as soon as we change anything. So select the top and skirt, and in the physics tab press Current Cache to Bake (for each garment). The simulation is now baked.
There are several ways that we can smooth the animation. We can e.g. add a Smooth Corrective modifier after the Cloth modifier. The default values for the paremeters work well.
Alternatively, we can add a Smooth modifier and change the Repeat value to 5.
Here is the simulation at frame 80, without and with the smoothing modifiers.