Sunday, December 6, 2020


 Decals are a common way to add localized details to your textures. For humans, decals can be used to add e.g. tattoos, bruises and wounds, but decals can of course be equally well used on inanimate objects. You can add decals in DAZ Studio, but I never understood how it works, and for me it is much simpler to do it in Blender, especially if you want the decals to follow the mesh when animating. To make it easier to add decals directly in Blender, I made a new button called Make Decal, which is found towards the bottom of the Materials section.

When we press Make Decal, a file selector appers where we can choose the image file that contains the decal. The tool adds it to the active material, so make sure that the right material is active. The active material is displayed at the top of the list to the right. The other checkboxes lists the nodes that we want to add the decal to. In this case we have a material with a principled node, and want to add the decal to the base color and to the bump node.

Here is the node tree,slightly edited for clarity. Two new node groups have been added before the principled and bump nodes. The Influence input can be used to animate the decals, e.g. a stab wound should only be visible after the character has been stabbed.

It may be necessary to edit some of the decal node groups. To do that, select the node group and open it by hitting tab. E.g., we may want to change the texture for the bump decal and change the color space to Non-Color. It is assumed that the texture has an alpha channel, but if we have a separate opacity texture we need to add an extra texture node for that and use its color output as alpha. 
The tool also creates an empty with the same name as the texture. By moving, rotating and scaling this empty we can control the location of the decal. Initially the decal covers almost the entire torso material, so we need to scale down the empty.

To place the empty correctly, we turn on snapping (the magnet icon at the top), snap to face, and make sure that Backface Culling and Align Rotation to Target are enabled.

We can now move the decal into place

To make sure that the decal stays put when we pose the character, we make a vertex parent.
And now the decal stays in place when the character is posed.

This is a very neat and light-weight way to add decals to your meshes, but it has an important limitation: the decal is only added to a single material. So if we want to place the decal so it crosses the boundary between two different materials, parts of it are cut off. To deal with this case, a little more work is necessary.
The idea is to make a separate mesh on which we place the decal. In edit mode, duplicate vertices around the shoulder and then separate them into a new shoulder pad mesh, which we rename to Tattoo.

The tattoo mesh inherits the armature modifier and vertex groups from the original mesh. However, most of the vertex groups only involve vertices far away from the tattoo, so they are of no use here. To quickly remove empty vertex groups, we can use the Advanced Setup > Mesh > Prune Vertex Groups tool. Now only the relevant vertex groups remain.

We want the shoulder pad to stay on top of the body, so we add a shrinkwrap modifier with a small offset. This can be done by selecting the body and using the Setup > Morphs > Add Shrinkwrap tool, or directly by adding a shringwrap modifier to the tattoo mesh.

The tattoo mesh also inherits the UV coordinates from the body mesh, but they are not suitable here since there is seam where we want to place the decal. In edit mode, clear all seams and then mark a new seam in a region where the decal will not cross, e.g. under the arm.

Then we unwrap the tattoo mesh. The UV coordinates are now nicely laid out and there are no seams in the region where we want to place the decal.

Next we go to the Shaders tab and make some changes to the material.

A freshly created material contains a principled node and an output node, which is good in our case. Turn down Alpha to zero. If the render engine is Eevee, we must change some material settings. Enable Backface Culling, set the Blend Mode to Alpha Clip or Alpha Hash, and turn off shadows by setting Shadow Mode to None

Now press Make Decal with the tattoo mesh selected, and enable Principled Base Color only. The decal node group appears. Since there is no ingoing texture this time, the Color output is connected to the Base Color socket rather than the Combined output. We must also manually connect the Alpha output to the Alpha socket of the principled node.

And now we can place the decal on the shoulder. Unfortunately, this decal looks more like a plastic sticker than like a real tattoo. How to fix that is left as an exercise for the Blender gurus out there.

Finally we have to vertex parent the empty, either to the tattoo mesh or to the underlying body, to make sure that the decal follows the mesh when posed.