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.


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

Update: Scanning the DAZ database is no longer necessary in version 4.5 of the plugin, c.f.Scanning the DAZ database is now obsolete

 

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.