Rasagar/Library/PackageCache/com.unity.render-pipelines.high-definition/Documentation~/use-decals.md
2024-08-26 23:07:20 +03:00

5.5 KiB
Raw Blame History

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 Projects HDRP Asset. To do this:

  1. Navigate to the Project window and open your HDRP Asset.
  2. In the Inspector, open the Decals dropdown.
  3. Enable the Layers checkbox.

You can then enable Decal Layers in your Frame Settings to enable Decal Layers for all Cameras. To do this:

  1. Go to Edit > Project Settings > Graphics > Pipeline Specific Settings > HDRP.
  2. Go to the Frame Settings (Default Values) > Camera section.
  3. Open the Rendering section.
  4. Enable the Decal Layers checkbox.

To control the Frame Settings and set Decal Layers for a specific Camera:

  1. Click on a Camera in the Scene view or Hierarchy window to view its properties in the Inspector.
  2. 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.
  3. In the Frame Settings Overrides section open the Rendering section.
  4. 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:

  1. Click on a Decal Projector in the Hierarchy or the Scene view to view it in the Inspector.
  2. Use the Rendering Layer Mask property drop-down to select which Rendering Layers this Decal Projector affects.
  3. Click on a Mesh Renderer or Terrain in the Hierarchy or the Scene view to view it in the Inspector.
  4. 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:

  1. Open the Material assigned to a Mesh Renderer or Terrain that you do not want to display decals on.

  2. 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:

  1. Open your Projects HDRP Asset.
  2. 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:

  1. Select your Projects HDRP Asset.
  2. 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.