Using Decals in Unity HDRP
Add Intricate Details Without Having to Create Extra Objects!
Objective: Learn what Decals are, how they work, and how to use them in Unity.
What are Decals?
Decals are a Renderer feature in Unity that projects a given material onto an object in the Scene. Decals are highly adaptable and interact with lighting while wrapping around objects and adjusting to their shapes.
Here you can see how a blood splatter decal wraps around a sphere:
Decals are extremely versatile and can help you add intricate details to your scene without the need for complex objects. For example, have you noticed how bullet holes appear in Shooter games after a bullet impacts a wall? Instead of having to go through a convoluted process to instantiate a plane with a bullet hole texture, you can instead go with the less resource-consuming process of instantiating a decal on the impact origin.
Anything from bullet holes, moss, liquid splatters or even vents on a ceiling can be made with decals! Additionally, even if they look like flat stickers or stamps, they can make use of Heightmaps and other similar modifications to pop up.
How to add Decals in Unity
In this example, I’m using a Blood Splatter Decal from Filebase. Usually, you have to create a texture to attach to your decals, and additional things like Normal Maps or Height Maps as well. However, for the sake of this example, I have a decal all ready to go.
Although this article will focus on using a pre-made decal I want to make a short pause to demonstrate how you could create a decal projector.
If you don’t have Decal ready to go, you can always create one via Right Click → Rendering → HDRP Decal
Your Decal object will look like this, kind of like a chess pawn in a box. This transparent box is the projection zone of your Decal, I will talk more about that later.
Then you would need to set your Material and the additional Mapping.
Using a Pre-Made Decal
- Add the Decal to your scene. Here I added the Decal as a child just so that I could get its position right away on the object I wanted.
2. Position your Decal properly. The transparent box is what I like to call the projection zone. The box area which is farthest from the pawn-like symbol needs to be pointed at the object where you want the decal on. This rotation is done toward the Z-axis(the blue arrow must be pointing downward at 90º).
If you run into trouble with your Decal not showing up, make sure that the Material is HDRP/Decal. Also, make sure that the projection zone isn’t clipping through the objects, this can block it from view.
You also need to make sure the projection zone isn’t too far away.
You can also resize your decal if it’s too small to be visible.
Note: I kind of forgot to add resizing to the article as I was writing it😅 , so I went back to do so. This is why the plane in this example is different.
The Result:
You can read about Decals with more depth in the official Unity Manual.
Thank you for your time! If you found this information valuable give me a follow! :) I document my learning journey into Unity Development and Software Engineering in the form of tutorials!