Decals and Projections in Unity’s HDRP
Decals are a great type of shader as they are textures that can easily be instantiated on top of other 3D game Objects, matching their curvature. It’s an easy way to edit an environment or characters without the need to alter that game object specifically. For example, bullets that miss a target and hit the wall, leave decals of bullet holes on the object they hit. Blood splatter is another great example of decals. This can be implemented on top of surrounding game objects in real time, making it easier, more efficient and realistic to the physics of the environment without having to edit the individual texture of the tainted or altered game object.
From the manual, “This shader is a variation of the VertexLit shader. All lights that shine on it will be rendered as vertex lights by this shader. In addition to the main texture, this shader makes use of a second texture for additional details. The second “Decal” texture uses an alpha channel to determine visible areas of the main texture. The decal texture should be supplemental to the main texture. For example, if you have a brick wall, you can tile the brick texture as the main texture, and use the decal texture with alpha channel to draw graffiti at different places on the wall.”
To add a Decal onto the scene, I’ve downloaded a package that contain prefabs, its materials and textures. Because I’m using the HD render pipeline, I had to update the materials from the standard shader onto this pipeline and also make sure that the material is under HDRP > Decal…
Here I will be using the splatter 02 to create a quick example
Since Decals are projections rendering in a specific direction, the game object must be shot in the right angle towards the desired target for its projection to work. Luckily, there is a good, wide area of box collision that detects game objects where the decal may be projected unto.
This is the magic of Decals, they are quick to set up in such a varied and infinite way. This blood splatter in particular projects towards the local Z axis. Now an example of the decal onto a spherical object:
Testing how to trigger this splatter as an splash after an event seems like a fun challenge to keep exploring this type of decals.