Decals in Unity

Using the High Definition Rendering Pipeline

Previously, we have looked at altering materials in various ways. But what if we want to add something to our scene without actually affecting the object or it’s material?

The HDRP allows us to use a Decal Shader. This is a specific material that can make use of a component called the Decal Projector.

The Decal Projector captures our Decal, and projects it onto surfaces in our scene, wrapping around the meshes of objects, whilst simultaneously interacting with lighting — much like placing stickers in real life! This can be super beneficial for adding detail or the likes of logos to unconventional shapes.

Alternatively, we can simply use the Decal Shader to place Decal meshes on specific objects. These won’t wrap though, as they adhere to one plane, and often times this can make it much harder to get the depth right.

Decal Projector in Scene View

The great thing about Decals are the efficiency factor. If we wanted to fill our scene with detail, we would need to have various different materials for similar objects so that each instance would look unique.

In the case of Decals, the HDRP instances each one similarly to a prefab, allowing thousands of detailed usage in our scene without being resource intensive. This is generally due to the fact that many decals will share one material.

The way this is done, is using Size, Tiling and Offset properties in the Decal Projector to divide up a larger material into various decals. We can see in the images above that the projector’s box is only capturing a small portion of the green plane which is our material.

Quite often, an asset pack designed for the HDRP and Decal Projectors, has these pre-separated out. But sometimes, we need to do this ourselves from one large image.

The quickest way I found to do this, is to step through each portion of the grid, and making a prefab for each iteration. It can take a bit of work, especially if the material doesn’t adhere to an evenly sized grid, but once completed, we can have a bunch of different details to place in our scene through prefabs, whilst only having to render one material.

In my Sci-Fi scene, I’ve used various blood splatters to portray a story of someone being attacked and managing to make it to the main terminal, before the attacking creature makes an escape through a hole in the wall. To achieve this I also used various grunge textures to add decay and scratch marks. These grunge decals can also work great to portray the likes of rust around the room.

Blood and decay!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store