The Decal component projects textures onto model's opaque or transparent surfaces. They inherit and modify the PBR properties of the surface they're projected on.
They are a great way for adding detail to your scene's static geometry or adding dynamic effects at runtime such as blood splatters, bullet holes, explosion scorches.
Decals are culled per screen space tile and drawn when models are drawn, so they incur no additional draw calls resulting in a very insignificant effect on performance.
There is no hard limit to how many decals you can have in a scene or overlapping on an object.
Decals can be created in editor through Add Component → Rendering → Decal.
They are projected forward along +X (the direction of the arrow gizmo).
They can also be created programatically at runtime in C#:
// Creates a decal of a Steam avatar and renders it over everything.
var decal = go.AddComponent<Decal>();
decal.ColorTexture = Texture.LoadAvatar( 76561197996859119 );
decal.SortLayer = 255;
Property | Description |
---|---|
Color Texture | The color map to use for the decal including transparency which masks the decal. This must be set for other textures to use the decal mask. |
Normal Texture | The normal texture map to use for the decal. |
RMO Texture | The Roughness/Metal/Ambient Occlusion texture map to use for the decal. Red = Roughness, Green = Metal, Blue = Ambient Occlusion |
Color Tint | Tints the color of the decal's albedo and overall opacity of the decal. |
Attenuation Angle | How much should the decal fade away from the flat surface.0 is no fade, 1 is max fade. |
Size | Sets the local size in units for the decal's projection.This is multiplied by the GameObject's world transform to get the final size. |
Sort Layer | Determines the order the decal gets rendered in, the higher the layer the more priority it has. Decals on the same layer get automatically sorted by their GameObject ID. |