Friday, June 3, 2022

Combo Materials

DAZ characters have many materials for the skin: face, torso, arms, legs, lips, nails etc. If we want to edit the materials once they have been imported into Blender we hence have to make the same changes in many places, which is inconvenient and error-prone. Until now, there have been two tools that facilitate editing multiple materials: the material editor and UDIM materials. However, both approaches have significant drawbacks.

The material editor has a clumsy interface, and is limited to changing existing parameters. It cannot change the topology of the node trees, e.g. by adding or removing nodes or editing links.

UDIM materials renames textures and saves them locally, and you must make sure that the UVs lie in the right tile (wrong for G81F arms and legs). Moreover, there is a problem with the bump distance, which depends on the pixel density and the mesh area covered by the texture in Iray. Hence the bump distance in Blender is different for the various skin materials. To keep the correct values, UDIM materials with different bump values must remain different, which defeats the purpose of editing all of them at once.

Some time ago Aszrael suggested a better approach: replace most of the node tree with a single node group, and only keep the textures. This node group is called a combo group and the materials that use it combo materials. We can then edit the combo group in a single place, and all combo materials are changed consistently.

To create a combo material, we use the Make Combo Material button at the bottom of the Material section. The active material is used as a blueprint for the combo group, so it is important that one of the skin materials is active.
The popup dialog lets us select the combo materials. By default the skin, lips and nails materials are selected. The active material is displayed at the bottom of the dialog.
Here is the original torso node tree.
And here is the node tree after most of the node tree has been replaced by the combo group. Apart from the output node, only the texture nodes remain, since they differ between the combo materials. The combo group is the same. Note that the combo group has a Bump:Distance input. This is the bump distance which differs between materials depending on the covered mesh area.
Here is the inside of the combo group. The input sockets are named after the nodes and sockets they are connected to, ignoring any math or mix-rgb nodes inbetween. The output sockets, called Cycles, Eevee, Volume and Displacement, are connected to the corresponding sockets of the output node.
Shell nodes are not included in the combo group. The reason is that a shell typically only affect some of the skin materials (usually the torso) and not the others.
Textures and texture-like nodes are left outside the combo group. Here we have a node group that corresponds to a layered image in DAZ Studio. In the other skin materials this node is a standard image texture node.
After converting to combo materials, the layered image node group stays outside the combo group.
It sometimes happens that some skin materials have extra nodes. E.g., the face and lips materials can have node groups that correspond to the diffuse overlay or makeup channels in DAZ Studio. In that case it is important to select the right active material to start from.
Here we have a character with eye makeup and glossy lipstick, and the result if we make combo materials starting from the torso, face and lips materials, respectively. The torso material doesn't have the overlay group, so the makeup is ignored altogether. The face material keeps the eye makeup, but the lips material doesn't have a lipstick texture so the color is replaced by black. Also the lips are glossier (have less roughness) than the rest of the skin. So when we start from the face, the lips lose gloss, and when we start from the lips, the rest of the skin becomes too glossy.
The solution is to make the combo materials with the face as the active material, and exclude the lips material from the conversion. The reason why the overlay group does not affect the other materials is that missing textures are replaced by pure black, cf. the lip color above. In the torso material, the Fac input of the diffuse overlay node is black i.e. zero, so the overlay node has no influence.

Combo materials are easier to use and more powerful than the old material editor. The latter is therefore deprecated and will probably be removed in the future, perhaps by the eventual release of version 1.6.2. The only drawback with making combo materials is that they are destructive; once converted to combo materials there is no going back. It can therefore be a good idea to backup the original materials, e.g. with the Make Palette tool.