Use decals
The High Definition Render Pipeline (HDRP) includes the following ways to create decals in a Scene.
Use a Decal Mesh and manually position the decal.
Use the Decal Projector component to project the decal.
To use these methods, you need to create a decal Material. A decal Material is a Material that uses the Decal Shader or Decal Master Stack. You can then place or project your decal Material into a Scene.
Decal Layers
HDRP includes Decal Layers that you can use to specify which Materials a decal affects based on which layer you assign it to.
Enabling Decal Layers
To use Decal Layers, enable them in your Project’s HDRP Asset. To do this:
- Navigate to the Project window and open your HDRP Asset.
- In the Inspector, open the Decals dropdown.
- Enable the Layers checkbox.
You can then enable Decal Layers in your Frame Settings to enable Decal Layers for all Cameras. To do this:
- Go to Edit > Project Settings open the Graphics section and select HDRP Global Settings.
- Go to the Frame Settings (Default Values) > Camera section.
- Open the Rendering section.
- Enable the Decal Layers checkbox.
To control the Frame Settings and set Decal Layers for a specific Camera:
- Click on a Camera in the Scene view or Hierarchy window to view its properties in the Inspector.
- Go to the Rendering section and enable the Custom Frame Settings checkbox. This opens a new Frame Settings Overrides section, which you can use to customize this Camera.
- In the Frame Settings Overrides section open the Rendering section.
- Enable the Decal Layers checkbox.
Using Decal Layers
When you enable Decal Layers, a Decal only affects a Mesh Renderer or Terrain if they both use a matching Rendering Layer. You can use Decal Layers to separate Meshes from specific Decal Projectors in your Scene. To do this:
- Click on a Decal Projector in the Hierarchy or the Scene view to view it in the Inspector.
- Use the Rendering Layer Mask property drop-down to select which Rendering Layers this Decal Projector affects.
- Click on a Mesh Renderer or Terrain in the Hierarchy or the Scene view to view it in the Inspector.
- Use the Rendering Layer Mask drop-down (See MeshRenderer for GameObjects or OtherSettings for Terrain) to select which Decal Layers affect this Mesh Renderer or Terrain.
To rename a Rendering Layer, see Renaming rendering Layers.
How Decal Layers affect performance
When you enable Decal Layers, it increases the build time of your project. This is because Decal Layers:
- Uses a high amount of memory.
- Increases GPU performance cost.
- Generates more Shader Variants.
HDRP renders Material depth in a Depth Prepass to apply decals to opaque Materials. This increases resource use on the CPU. Only Materials that have the Receive Decals property enabled render in the Depth Prepass, unless you force a full Depth Prepass. To prevent HDRP from rendering a Material which shouldn't receive Decals in the Depth Prepass:
Open the Material assigned to a Mesh Renderer or Terrain that you do not want to display decals on.
Disable the Receive Decals property.
Note: When you use the Rendering Layer Mask of a Mesh Renderer or Terrain to disable decal on a specific Decal Layer, it doesn't affect your application's performance.
Additive Normal Blending
You can use Additive normal blending to blend decal normals with the normals of a specific GameObject. In the following image examples, the screenshot on the left doesn't use additive normal blending, and the screenshot on the right uses additive normal blending.
To use Additive Normal Blending:
- Open your Project’s HDRP Asset.
- In the Inspector, go to Rendering >Decals and enable the Additive Normal Blending checkbox.
High Precision Normal Buffer
When you use additive normal blending, HDRP constrains the decal displacement to a cone of 45° around the object normal to reduce banding artifacts. To remove this angle constraint on the normal at the cost of a higher memory usage, enable the High Precision Normal Buffer setting. To do this:
- Select your Project’s HDRP Asset.
- In the Inspector, go to Rendering > Decals and enable the High Precision Normal Buffer checkbox.
Limitations
The Decal Shader does not support emissive on Transparent Materials and does support Decal Layers.
Decal Meshes can only affect opaque Materials with either a Decal Shader or a Decal Master Stack.
Decal Meshes do not support Decal Layers.
A Decal Projector can only affect transparent Materials when you enable the Affect Transparent checkbox.
With Lit Shader Mode setup to Deferred. Decals projected on objects relying on object motion vectors (Deformed objects) can exhibit artifacts like being visible even if not in the projector frustrum. This can be fixed by enabling Full Depth Prepass within Deferred option in FrameSettings.