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.