Skinned Decals

An efficient way to dynamically add decals on top of static meshes is the use of deferred decals. However, in general deferred decals fail to deliver convincing results on top of areas that are skinned by multiple bones. Typical artifacts are decals that are "swimming" on top of the target mesh, not stretching according to the underlying surface, producing distracting overlaps and projecting on top of areas that were initially not in the influence area of the decals.

A method that doesn't suffer from the aforementioned problems was mentioned here. The idea is to render the skinned mesh that receives a decal once when a new decal is created. Instead of rendering the mesh itself into a render target, it uses the mesh texture coordinates as vertex shader output position. In a pixel shader the decal texture coordinates are calculated, similarly to deferred decals, and the corresponding texels are fetched from the decal texture and output into the mesh texture. This implies that each mesh instance has its own texture that serves as render target resource. Finally when the skinned mesh is rendered in the shading pass, the updated mesh texture is fetched at the mesh texture coordinates and the resulting decals are automatically applied. Unfortunately there are several drawbacks which make this technique impractical for game production:

A solution that is based on the same base idea as the aforementioned method, but overcomes these drawbacks, is to output decal texture coordinates with a decal index instead of decal texture values when a new decal is created and the corresponding skinned mesh is rendered. With the help of the decal index the decal material can be recovered and applied via the decal texture coordinates during rendering into the G-Buffers in case of deferred rendering or during rendering into the accumulation buffer in case of forward rendering. In this way neither does it matter how many texture maps are utilized nor do we have to bother with generating mip-maps for all of these texture maps. You can find a detailed description of this technique in my article within the GPU Zen 2 book.

In the videos below decals are dynamically added on top of an animated, skinned model authored by KatsBits. The left video was rendered with the deferred decals technique, the right video with the proposed skinned decals technique.

One can observe that while the deferred decals "swim" on the top of the target mesh, not stretching according to the underlying surface, and produce distracting overlaps, the skinned decals doesn't suffer from these issues. It is also visible, that the skinned decals have the same rendering quality as the deferred decals.

You can download the DirectX 12-based demo application with complete source code here: