Decal Projections In Unity
Decals are a pretty useful feature of Unity, allowing for images to be projected onto any surface.
Today’s Objective: Explore the possibilities of Decals in Unity HDRP.
Decals are not something only found in game design, as they have been around for years, particularly in the automotive industry.
The non-video game version is:
“A plastic, cloth, paper, or ceramic substrate that has printed on it a pattern or image that can be moved to another surface upon contact, usually with the aid of heat or water.” — Wikipedia
Translated to video game development, they are a method to easily project any texture onto another surface at any time, without being limited by the surface’s characteristics, or limited to only one surface at a time.
Typically, decals in game design are used for temporary effects, such as blood splatters, bullet holes, or marks on surfaces. But they can be used just the same for things like permanent graffiti on walls, when the developers don’t want to include the graffiti in the complete wall material.
Decals In Unity:
Note: Decals are not just limited to HDRP, but I will be showing the process for using them in the HDR Pipeline.
The HDRP process is incredibly simple.
Right-click in the Hierarchy window, and choose “Rendering/HDRP Decal Projector”.
This will create a new decal projector like so:
Start by creating/selecting your desired decal material which can use any texture, just like any other material.
Remember to change the shader type to HDRP/Decal, which is a requirement.
Now back on the decal projector, set the material to your chosen decal material.
Now that we can see the decal being projected, we can modify it.
Decals work by projecting the set material from a starting point onto any object within the “Projection Depth” distance.
The starting point and projection direction can be identified by this white arrow shown as a Gizmo:
In my case, I have it facing directly down:
The projection size can be altered using the Size variables, or by entering Face Edit mode, just as you could for a Box Volume or similar.
The distance the decal can project can be changed using “Projection Depth”:
Those are the main options you’ll want to adjust. I’ll leave the rest to you to play around with.
Decals can project through multiple objects:
Like all GameObjects, Decals do not need to be facing straight to the surface. They can be rotated to project onto any surface at any angle.