Friday, May 21, 2021

On Raw and Final Slider Values

In both DAZ Studio and in Blender morphs are controlled with sliders, but those sliders don't behave in the same way. In DAZ Studio a slider can change another slider, but the latter can also be changed independently. Something similar does not really exist in Blender; either the slider is driven by something else, and in that case it cannot be changed at all from the viewport, or the slider is not driven and cannot be modified by another slider.

However, there is a way to make sliders behave almost as they do in DAZ Studio, using an extremely clever trick devised by frequent commenter engetuduouti. This method uses two Blender properties for each DAZ slider: the "raw" value which can be manipulated in Blender, and the "final" value which reproduces the slider value in DAZ Studio. Unfortunately, understanding how these raw and final sliders work is quite unintuitive, but hopefully the present post can bring some clarity.
In order to see the final values, we must enable Show Final Morph Values in the Global Settings.We will also change the Slider Limits to Custom, which will allow us to use negative values for the raw sliders; the Final Limits should be left at DAZ.

We will consider the three standard face morphs which close the eyes. In DAZ Studio, we set Eyes Closed Left to 50%. Aiko's left eye is now half-closed.
In Blender we do the same thing (something has happened to the morph names, they should be the same as in DAZ Studio). The EyesClosedL slider is set to 0.5. However, it is the final values next to the sliders that matter for the morph; the final values show the values of the sliders in DAZ Studio. In this case the raw and final values are the same, but they will differ below.
In DAZ Studio, we now drag the Eyes Closed slider to 50%. That automatically increases the left and right sliders with 50%, to 100% and 50%, respectively. Note that in this step only the Eyes closed slider was moved.
In Blender we do the same things and increase the EyesClosed slider to 0.5. The other sliders are unchanged, at 0.5 and 0.0, respectively. However, we see that the final values to the right have been changed and agree with the slider values in DAZ Studio. Also we see that the pose is correct.
Finally we move the left and right sliders, so Aiko's left eye is fully open and her right eye is closed. So the left slider is decreased by 100% to 0%, and the right one is increased by 50% to 100%. The combined slider is not touched and remains at 50%.

Now we do the same thing in Blender. The left slider is decreased by 1.0, from 0.5 to -0.5, and the right one is increased by 0.5, from 0.0 to 0.5. The final values and the face pose are the same as in DAZ Studio, but the connection to the raw sliders is not so intuitive.

We can summarized the three steps above by the increments:

  1. Left increased 50%.
  2. Combined increased 50%.
  3. Left decreased 100%, right increased 50%.

Monday, May 17, 2021

Favorite Morphs and Easy Import

Update 2021-05-21: 

The concept has been renamed from Morph Preset to Favorite Morphs, because a morph preset denotes something completely different in DAZ Studio: a combination of morphs that give a certain expression. The names of the buttons has thus been changed to Save Favorite Morphs and Load Favorite Morphs, and the Easy Import option is called Use Favorite Morphs. 

In fact, morphs presets in the DAZ Studio sense can be saved with the Save Pose Preset, and can then be used both in DAZ Studio and in Blender.
 

Original post:

It is now possible to store a collection of morphs as a morph preset, which can be reused for other characters of the same type. A preset consists of any combination of standard and custom morphs for a genesis character, plus custom morphs for associated geografts and clothes.
Morph presets are normally stored in a directory specified in the global settings.
To create a morph preset, we import a character of the Genesis generation that we want to make the preset for. The character must also have any geografts and clothes that we want to include in the preset.
The buttons for saving and loading morph presets are found in the Morphs section of the Setup panel.
Select the parent rig and press Save Preset. A file selector opens up in the directory specified in the global settings. Choose a name for the preset and save the file.
Now load a different character, which however belongs to the same Genesis generation. Select the rig and press Load Morph Preset, and select the preset file that we just created. All morphs are loaded to the new character.

Morph presets are of somewhat useful by themselves, but their main use is in combination with Easy Import. Morphs must be loaded while bone names and meshes are still intact. This means that morphs must be loaded before geografts and lashes are merged with the main character mesh, and before the armature is converted to some more animator-friendly rig like MHX or Rigify. The used to limit the usefulness of Easy Import, because only standard morphs could be loaded at the right time. If we wanted to load custom morphs, the last steps had to be done manually, after the custom morphs were loaded.

With morph presets, this is no longer a limitation.
In the Easy Import options, enable Use Morph Preset. The checkboxes for standard morphs disappear, and instead a field appears were we can specify the morph preset file. The file is relative to the global morph preset directory, unless an absolute file path is specified.

We can now enable Transfer Shapekeys, Merge Geografts and Merge Lashes, knowing that these operations will be performed after all morphs have been imported. We can also choose a rig type which changes bone names like Rigify.

And now a animation-ready character is loaded with all the morphs in the morph preset.

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.