Sidor

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.


Thursday, December 7, 2023

Version 1.7.3 Released

Stable version 1.7.3 of the DAZ Importer and MHX Runtime system is a bugfix release. In particular, it fixes a bug that prevented older characters to be imported under Blender 4. This version can be downloaded from https://www.dropbox.com/scl/fi/3hdkujzb7yvgqsx226zpz/import_daz_mhx_rts_v1_7_3.zip?rlkey=oqugyrheyn2sma3zmxmxd2m3d.

Friday, December 1, 2023

Version 1.7.2 Released

Update:

Version 1.7.2 contained a bug that prevented older characters to be imported under Blender 4. That is fixed in stable version 1.7.3, which can be downloaded from https://www.dropbox.com/scl/fi/3hdkujzb7yvgqsx226zpz/import_daz_mhx_rts_v1_7_3.zip?rlkey=oqugyrheyn2sma3zmxmxd2m3d.

Original post:

Version 1.7.2 of the DAZ Importer and MHX Runtime system has been released. It can be downloaded from https://www.dropbox.com/scl/fi/avm8al0hvr9hcr3lr78xd/import_daz_mhx_rts_v1_7_2.zip?rlkey=ytanxu07xotsozcuhhv1pa7tb.

The main improvements in this release are:

  • Support for Blender 4 (bone collections, principled shader version 2, hair curves).
  • Major performance boost for morph loading.
  • Improved support for older rigs with triax weights.
  • Bugfixes. 

This release has been tested with Blender 2.83, 3.6 and 4.0, but should  run on intermediate Blender versions too.

Monday, November 27, 2023

Linux Revisited

DAZ Studio does not run natively under Linux, but it can still be used with Wine. However, although Wine emulates Windows, the underlying Linux file system is case sensitive, which causes some problems. Two file paths that differ only in casing, e.g. Runtime/Textures/ and runtime/textures/, are the same directory on Windows but two separate directories on Linux, and if the casing is wrong files may not be found.

Part of the early development of the DAZ Importer was carried out on a computer with Linux. At that time the global setting "Case-Sensitive Paths" was introduced, which by default is enabled on Linux and disabled on Windows and Mac. If this setting is turned on, some extra work was done to find the right Linux file path given a case-insensitive Windows path, see this blog post. However, this never worked very well, and sometimes files were missing. Therefore a new way to handle case-sensitive paths was introduced some time ago, which also can handle the case that several different Linux directories correspond to the same Windows directory.

Unfortunately, my Linux computer has since broken down, so I am not able to test this properly on a computer with a case-sensitive file system. Nevertheless, I think that it works, at least for the basic functionality.
If Case-Sensitive Paths is enabled but we haven't yet scanned the database, we get an error message when we try to import a DAZ file.
As the error message says, we must run the Scan Absolute Paths tool in the Utilities panel. This scans the entire database, so it may take a while.

All subdirectories of the content, MDL, and cloud directories are included in the scan. We can also specify the location of the json file where the result is stored.

Once the scan is completed, the result is save in a file called import_daz_scanned_absolute_paths.json (or whatever file path you specified above). We can now import scenes and morphs as usual.

We can even delete all root paths and still import files, because the DAZ Importer finds the assets from the scanned json file.

Important: The plugin does presently not check if the DAZ database has been updated. If you install new assets, the database must be scanned again, otherwise the new assets will not be found.



Thursday, August 24, 2023

MHX and Spine IK

If we have perfected a pose for the upper body, we want it to stay that way even if we change the pose for the lower body. This has not been possible with the MHX rig before, because even if the hands are controlled by IK and stay in place, the arms and head move when we move the hip bone. In the latest version of MHX, we can add an IK controller to the spine bones, which lets us control the spine from the top instead of from the bottom. Thus the top of the spine and its children remain in place when we move the hip bone.

To add spine IK to the MHX rig, the Spine IK option must be enabled. We notice that we can also add IK controllers to other parts of the rig, namely the fingers, tongue, and the Dicktator/Futalicious shaft.

The controls are located in the MHX tab, in the panel called FK/IK Spine Fingers Tongue Shaft, If Spine IK is enabled, we pose the spine with the wiggly ik_back bone at the top of the spine. It doesn't move if we move the hip.
The Snap FK button snaps the FK back bone to match the ik_back bone, and sets Spine IK to zero. The pose remains the same for intermediate values of the spine IK influence. We can now pose the spine with the back bone instead. When the hip moves, so does the upper body.
The Snap Spine button sets the pose for the individual spine bones on the Spine layer, and resets the locations of the back and ik_back bones. Use this if you want to save a pose preset for use in DAZ Studio.
The same mechanism is used for finger IK, if we enabled that when the MHX rig was generated. We can pose the fingers with the long finger bones if the finger IK influence is zero.
The Snap IK button moves the finger IK bones to the end of finger FK bones, and sets the IK influence to one. We can now pose the fingers with the IK bones. This can be useful if we want to fingers to interact with something else.
The tongue is handled in the same way. The tongue is posed with the long tongue bone on the Head layer if Tongue IK is zero. The pose can be tweaked with the individual tongue bones on the Face layer.
The Snap IK button snaps the ik_tongue bone into position. Note how the bone shape changes when the bone is scaled. Snap Tongue snaps the individual tongue bones to their current location, and resets the FK and IK tongue.

The MHX rig can also include FK and IK bones to control the Dicktator or Futalicious shaft bones, or more generally any chain the bones starting with the name "shaft". They work in a completely analogous way.

Finally we can note that the user interface for FK/IK for arms and legs has changed. The functionality is the same as before, but the design has be changed to look the same as the other FK/IK panels.

Wednesday, August 2, 2023

Blood, Sweat and Tears

 And geografts. Not a trivial combination.

Here we have a messy character in DS. She has the Headlights and Golden Palace geografts with the corresponding shells, and also blood, sweat and tears shells. The geografts have turned white, so something is wrong with them. The problem is that the body shells (blood, sweat and tears) are designed for the body materials but not for the grafts.
Fixing the tears shell is easy. Select the tears shell, and in the Parameters tab go to Shell > Visibility > Surfaces. We see that the shell is enabled on the geograft materials. Turn them off.
We also turn off the Headlights shell on Golden Palace, and vice versa.
Blood and sweat are trickier, because we want them to cover the geograft materials as well. If we leave them on, the geografts turn white. If we turn them off, the grafts become visible but the blood and sweat stop suddenly at the geograft boundary, which doesn't look good either. I am not sure if you can fix this in DAZ Studio, but there is a simple fix in Blender.

Now import the character into Blender. The geografts have turned white.

In the Nipples materials we find three node groups just before the output node, corresponding to the Sweat, Headlights, and Blood shells, respectively.The problem is that the Blood and Sweat groups have the wrong node trees. The nodes generate plain white, because the shell is not designed for the geografts, only for the body materials.
We can fix this by replacing the Sweat_Nipples-2 node group with the corresponding node group for the torso, i.e. Sweat_Torso-6.
Do the same thing for the Blood node group. The geograft shells should of course not be changed, because they were designed to work with the geografts.
Finally, repeat this procedure for all geograft materials. There are not that many because several were merged when the charcter was loaded, but it is still a rather tedious procedure.
Finally we have achieved our goal, and have blood and sweat on both the body and the geografts.

The procedure shown above is straightforward, but in the latest commit it has been automated for convenience. In the Materials section there is the new Fix Shells button, which does precisely the steps above.

Select all geografts that we want to fix, and make the body mesh the active mesh. Moreover, pick the active material from which we will take the node groups.
 
Finally press the Fix Shells button in the Materials section. 
We now have the choice of either fixing the materials of the active mesh, or fix the other selected meshes. Since the geografts have not yet been merged with the body, we leave this option disabled. The geograft materials are fixed automatically.
 
We can also fix the shells after we have merged the geografts. In this case we enable Fix Active Mesh. A list of materials appear, where we select the materials that we want to fix, i.e. the geograft materials.
 
If we have several geografts that cover different parts of the body (and different materials), we can repeat the procedure with different geograft selections and different active materials.
 

Friday, July 21, 2023

Version 1.7.1 Released

Version 1.7.1 of the DAZ Importer and MHX Runtime system has been released. It can be downloaded from https://www.dropbox.com/s/7mj32wh3bnn4rwe/import_daz_mhx_rts_v1_7_1.zip.

This is primarily a bugfix release. A number of serious bugs were discovered right after the 1.7.0 release. Those have now been eliminated, so I recommend everybody to update to the new version. Safely Installing a New Version.

There are also a few new features. The most obvious one is that the user interface has been rearranged. The DAZ Importer now takes up two tabs in the User Interface (N-panel), DAZ Setup and DAZ Runtime. One or both of these tabs can be hidden.

Support for making pose presets has been improved.

The internal working of the MHX rig has been changed. However, there is a conversion tool for old MHX rigs, so they can still be used with the latest release.





Thursday, July 13, 2023

MHX Properties are now ID Properties

If you open an old MHX rig in the latest MHX version, all panels contain only a single button named "Update MHX Drivers". What is going on?

In Blender there are two types of custom properties, often called ID properties and RNA properties. RNA properties are defined by Blender or by add-ons for all instances of a certain datatype, whereas ID properties are created on the fly and only affects a single instance. 
 
MHX has been using RNA properties for its internal functioning, because it makes the UI more attractive. In particular, Boolean ID properties are displayed as integers rather than checkboxes. However, I recently realized that RNA properties have a major drawback: they are not defined if the MHX add-on is disabled. This could happen if we redistribute the blend file to somebody who does not have the MHX add-on installed, e.g. a render farm.
Here we have posed Aiko in version 1.7.0 of the DAZ Importer and MHX RTS add-ons. We are using IK for both arms and legs.
IK for the left and right arms are controlled by custom properties called MhaArmIk_L and MhaArmIk_R, respectively. We see in the Custom Properties list that IK is enabled and that they are RNA properties, because "API Defined" is written to the right of the properties.

The IK property drives the influence of a Copy Transforms constraint for the upper_arm.L bone, which is located on the hidden layer 15. The driver value is 1.0 which is the value of the RNA property MhaArmIk_L.
Save the file and disable the MHX RTS add-on. Then close and restart Blender, so the definition of the RNA properties disappear.
Now open the file that we just saved in the new Blender session. The IK pose is gone! The IK bones are posed as they were before, but the mesh no longer follows suit.

When we inspect the custom properties, we see that the custom properties have turned into ID properties. There is a cogwheel and an X to the right of the properties rather than the text "API Defined".
If we look at the driver for the Copy Transforms constraint, we see that the path has turned red and that the driver value is 0.0. The driver looks for an RNA property called MhaArmIk_L, but that does not exist because the MHX RTS add-on is disabled.

To fix the file, we have to enable the MHX add-on again. The mesh now jumps into place because the RNA properties are defined again, but this is not a permanent solution.

All panels in the MHX tab contain the single button "Update MHX Drivers", so we have to press that.
The path to the driving property has been changed. Instead of MhaArmIk_L which is the path to the RNA property, it becomes ["MhaArmIk_L"] refers to the corresponding ID property.

Now save the blend file, disable the MHX add-on, restart Blender and open the file. The IK pose is still there, even though the MHX tab is absent.

Wednesday, July 5, 2023

Hierarchical Pose Presets

For a while the DAZ Importer has been able to export pose presets back to DAZ Studio, see the post Save pose preset. However, this was limited to ordinary pose presets, which only work on a single figure in DAZ Studio. Following a request by Rakete, the functionality of this tool has now been expanded to also generate hierarchical pose presets,

Let us consider this character. In DAZ Studio, we added the Genesis 8.1 Female Face Controls from the Developer Kit. In Blender we merge the rigs together and loaded the FACS morphs. Finally we posed both the character and the face controls in order to make a facial expression.
Now let us export the pose as a pose preset. Press the Save Pose Preset button in the Posing panel. A file selector appears. Save the preset in a directory that can be accessed from DAZ Studio, leaving the Preset Type at the default value Pose.
In DAZ Studio, select the figure and load the pose preset. The body is posed but the face is not, because the pose is only loaded to the figure itself, not to its children, e.g. the Face Control figure.

Now do the same thing again, but set Preset Type to Hierarchical instead.
In DAZ Studio, the hierarchical preset is loaded to the entire node hierarchy, both the main figure and its subfigures.
Instead of using the Face Control bones, we could create an expression using the FACS sliders.
This time we set the Preset Type to Pose And Morph.

Note that this tool does not distinguish between shaping and posing morphs; in Blender, all morphs are treated in the same way.

In DAZ Studio, we need to zero the face control pose, because the new preset will only pose the main figure bones.
When we load the mixed pose-morph preset in DAZ Studio, both the bone pose and the morph values are loaded.

Hierarchical pose presets are quite sensitive to the bone hierarchy. Therefore it is not possible to use the MHX or Rigify rigs to generate hierarchical presets, because those rigs have a completely different bone hierarchy. However, it is possible to use the Simple IK rig.

Even if it is not possible to use the MHX or Rigify rigs directly, we can still use them to control the original DAZ rig. To do so, enable the Keep DAZ Rig option when the MHX rig is generated.
This gives us two separate rigs: the control rig Genesis 8.1 Female_MHX, which has the MHX controls, and the deform rig Genesis 8.1 Female.
Pose the control rig. We can create an ordinary pose presets directly from the mhx rig (so keeping the DAZ rig was unnecessary in this case).
The pose preset can be loaded in DAZ Studio, but the face expression is of course missing.
To create a hierarchical pose preset, select the deform rig and press Mute Control Rig. The deform rig is now detached from the control rig, and the pose is baked to the deform bones, including the face control bones.

Once we have exported the preset, the Unmute Control Rig button returns control to the control rig.

Since the active object is now a DAZ rig, we can save a hierarchical pose preset.
And this preset poses the entire hierarchy in DAZ Studio.