Decals in Unity 2020
What are Decals?
Decals offer a lower rendering cost to add many, many runtime and static images to scenes.
A common use for decals would be a player shooting a wall, and a bullet hole appears with an image appropriate for the material that was hit.
Adding just a black hole is a nice touch, but showing a metal impact vs a plywood impact adds realism
How do we use Decals in Unity?
“The High Definition Render Pipeline (HDRP) includes two ways to create decals in a Scene.
You can either use a decal Mesh and manually position the decal or use the Decal Projector component to project the decal.
Both of these methods require that you create a decal Material, which is a Material that uses either the Decal Shader or Decal Master Stack.
You can use either to create decal Materials that you can place or project into a Scene.
Limitation and compatibility
The Decal Projector can affect opaque Materials with either a Decal Shader or a Decal Master Stack.
However, it can only affect transparent Materials with the Decal Shader.
It does not support emissive on Transparent Materials and does support Decal Layers.
Decal Meshes can only affect opaque Materials with either a Decal Shader or a Decal Master Stack.
They also do not support Decal Layers.”
Using the projector approach, we can see in the scene above some bloody handprints on the floor and a blood smear on the column.
Not that you will need to rotate the decal projector to face the correct direction for whichever surface you intend to apply it to.
You will also need to make sure that the bounds of the decal projector overlap the surface you wish to project onto.
Decal Materials
The first thing you’ll need for a decal is a decal material.
This is a standard Unity material with the HDRP/Decal shader type.
With the material, you can make the normal changes you would to any other material, from texture maps to metallic/smoothness settings and emission.
Decal Prefab
The key component on our decal prefab is the Decal Projector component.
This requires a proper decal material to function correctly.
With the material assigned, you can also directly change the material settings in the inspector window.
The Decal Projector allows us to change or stretch the size of the decal and determine the appropriate draw distance and fade factor.
Decal Conformity to Shapes
Here I’ve created a temporary decal using one of the hand decals and changed the width and height from 1 to 5 for each.
Note that the decal will wrap or conform to the shape of the sphere or whatever object it is projected on.