Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Decal Projector

The High Definition Render Pipeline (HDRP) includes the Decal Projector component, which allows you to project specific Materials (decals) into the Scene. Decals are Materials that use the [Decal Shader](Decal-Shader.md) or [Master Node Decal](Master-Node-Decal.md). When the Decal Projector component projects decals into the Scene, they interact with the Scene’s lighting and wrap around Meshes. You can use thousands of decals in your Scene simultaneously because HDRP instances them. This means that the rendering process is not resource intensive as long as the decals use the same Material.
The High Definition Render Pipeline (HDRP) includes the Decal Projector component, which allows you to project specific Materials (decals) into the Scene. Decals are Materials that use the [Decal Shader](Decal-Shader.md) or [Decal master node](Master-Node-Decal.md). When the Decal Projector component projects decals into the Scene, they interact with the Scene’s lighting and wrap around Meshes. You can use thousands of decals in your Scene simultaneously because HDRP instances them. This means that the rendering process is not resource intensive as long as the decals use the same Material.

The Decal Projector also supports [Decal Layers](Decal.md) which means you can control which Materials receive decals on a Layer by Layer basis.

![](Images/DecalProjector1.png)

Expand Down Expand Up @@ -45,9 +47,8 @@ Using the Inspector allows you to change all of the Decal Projector properties,

## Limitations

- Decal Projector can affect Opaque Material with both a [Decal Shader](Decal-Shader.md) or a [Master Node Decal](Master-Node-Decal.md). It can affect Transparent Material only with a Decal shader.
- Decal Projector support [Decal Layers](Decal.md)
- The Decal Projector can affect opaque Materials with either a [Decal Shader](Decal-Shader.md) or a [Decal master node](Master-Node-Decal.md). However, it can only affect transparent Materials with the [Decal Shader](Decal-Shader.md).
- Decal Emissive isn't supported on Transparent Material.
- When you project a decal onto a surface, the emissive component of the decal affects the surface regardless of whether you enable **Receive Decal** on the surface's Material or not. Decal Layers allow to disable receive of Emissive Decal.
- The **Receive Decals** property of Materials in HDRP does not affect emissive decals. HDRP always renders emissive decals unless you use Decal Layers, which can disable emissive decals on a Layer by Layer basis.
- If you project a decal onto a transparent surface, HDRP ignores the decal's Texture tiling.
- In **Project Settings > Graphics**, if **Instancing Variants** is set to **Strip All**, Unity strips the Decal Shader this component references when you build your Project. This happens even if you include the Shader in the **Always Included Shaders** list. If Unity strips the Shader during the build process, the decal does not appear in your built Application.
23 changes: 11 additions & 12 deletions com.unity.render-pipelines.high-definition/Documentation~/Decal.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Decal

The High Definition Render Pipeline (HDRP) includes Decal Mesh and the [Decal Projector](Decal-Projector.html) component, which you can use to project specific Materials into your Scene to create realistic-looking decals. These Materials must use the [Decal Shader](Decal-Shader.md) or [Master node Decal](Master-Node-Decal.md). Use those Shader to create decal Materials that you can place, or project, into your Scene.
The High Definition Render Pipeline (HDRP) includes two ways to create decals in a Scene. You can either use a decal Mesh and manually position the decal or use the [Decal Projector](Decal-Projector.html) component to project the decal. Both of these methods require that you create a decal Material, which is a Material that uses either the [Decal Shader](Decal-Shader.md) or [Decal master node](Master-Node-Decal.md). You can use either to create decal Materials that you can place or project into a Scene.

![](Images/HDRPFeatures-DecalShader.png)

**Limitation and compatibility**

Decal Projector can affect Opaque Material with both a Decal shader and a Master Node Decal. It can affect Transparent Material only with a Decal shader. Emissive isn't supported on Transparent Material. Decal Projector support Decal Layers. The **ReceiveDecals** property of Material don't affect an Emissive Decal. Emissive are always render, only Decal Layers allow a surface to disable them.
Decal Mesh can affect only Opaque Material with both a Decal shader and a Master Node Decal. Decal Mesh don't support Decal Layers.
The Decal Projector can affect opaque Materials with either a [Decal Shader](Decal-Shader.md) or a [Decal master node](Master-Node-Decal.md). However, it can only affect transparent Materials with the [Decal Shader](Decal-Shader.md). It does not support emissive on Transparent Materials and does support Decal Layers.
Decal Meshes can only affect opaque Materials with either a [Decal Shader](Decal-Shader.md) or a [Decal master node](Master-Node-Decal.md). They also do not support Decal Layers.

# Decal Layers

## Enabling Decal Layers

To use Decal Layers, you must enable them in your Project’s [HDRP Asset](HDRP-Asset.html). You can then enable Decal Layers in your default [Frame Settings](Frame-Settings.html) to set your Cameras to process Decal Layers.

To use Decal Layers, first enable them in your Project’s [HDRP Asset](HDRP-Asset.md). You can then enable Decal Layers in your [Frame Settings](Frame-Settings.md) to set your Cameras to process Decal Layers.
1. Select the HDRP Asset in the Project window and, in the Inspector, go to **Decal > Layers** and enable the checkbox.
2. To enable Decal Layers in the default Frame Settings for all Cameras, in your HDRP Asset, go to the **Default Frame Settings For** section, select **Camera** from the drop-down and, in the **Rendering** section, enable the **Decal Layers** checkbox.

Expand All @@ -26,25 +25,25 @@ To override the Frame Settings for Cameras and set Decal Layers on an individual

## Using Decal Layers

After you enable Decal Layers, you can then use them to decouple Meshes from certain Decal Projector in your Scene. To do this:
After you enable Decal Layers, you can then use them to decouple Meshes from certain 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 **Decal Layer** property drop-down to select which Decal Layers this Light affects.
2. Use the **Decal Layer** property drop-down to select which Decal Layers this Decal Projector affects.
4. Click on a Mesh Renderer or Terrain in the Hierarchy or the Scene view to view it in the Inspector.
5. Use the **Rendering Layer Mask** drop-down (See [MeshRenderer](https://docs.unity3d.com/Manual/class-MeshRenderer.html) for GameObjects or [OtherSettings](https://docs.unity3d.com/Manual/terrain-OtherSettings.html) for Terrain) to select which Decal Layers affect this Mesh Renderer or Terrain. When you enable Decal Layers, a Decal only affects a Mesh Renderer or Terrain if they both use a matching Decal Layer.

## Renaming Decal Layers

By default, in the UI for Decals Projector, Mesh Renderers or Terrain, Decal Layers are named **Decal Layer 1-7**. To more easily differentiate between them, you can give each Decal Layer a specific name. To do this, open the [Default Settings Windows](Default-Settings-Window.md), and go to **Decal Layer Names**. Here you can set the name of each Decal Layer individually.
By default, in the UI for Decal Projectors, Mesh Renderers, or Terrain, Decal Layers are named **Decal Layer 1-7**. To more easily differentiate between them, you can give each Decal Layer a specific name. To do this, open the [Default Settings Windows](Default-Settings-Window.md), and go to **Decal Layer Names**. Here you can set the name of each Decal Layer individually.

## Enable/Disable Decal and Performance
## Performance implications

Enabling Decal Layers require increase memory, have a GPU performance cost and generate more Shader Variant (so increase build time).

A Decal Shader or a Master Node Decal have a **Receive Decals** property allowing to disable Decal on those Material independently of the Decal Layers system. Disabling Decal with the Decal Layer system via **Rendering Layer Mask** of Mesh Renderer or Terrain don't save any performance. To save performance it is required to disable **Receive Decals** on the Material.
If you use the Decal Layer system to disable a decal, via the **Rendering Layer Mask** of a Mesh Renderer or Terrain, it doesn't save on any performance. Instead, to save performance, you need to disable the **Receive Decals** property for the Mesh Renderer or Terrain's Material.

Implementation detail: Decal require to render depth in a Depth Prepass to apply on Opaque Material causing an extra CPU cost. Only Material with **Receive Decals** enable will render in the Depth Prepass unless there is a force of a full Depth Prepass. If Decal is disable with Decal Layers system, it will still render in the Depth Prepass. Only the **Receive Decals** from Material allow to save performance.
Implementation detail: To allow HDRP to apply decals to opaque Materials, it must render depth in a Depth Prepass, which adds to the CPU resource intensity of the operation. Only Materials with **Receive Decals** enabled render in the Depth Prepass, unless you force a full Depth Prepass. If you disable a decal with the Decal Layers system, HDRP still renders it in the Depth Prepass. This is why you need to disable the **Receive Decals** property on Materials to save performance.

## Migration of data previous to Unity 2020.2

Before Unity 2020.2 the default value when creating a Mesh Renderer or Terrain of **Rendering Layer Mask** don't include any of the Decal Layer flags. Consequence, when enabling Decal Layers with those data they default to not receive any Decals. Later version have **Decal Layer Default** enable by default.
Before Unity 2020.2, the default value for the **Rendering Layer Mask** for new Mesh Renderers and Terrain doesn't include any of the Decal Layer flags. This means that, when you enable Decal Layers, these Mesh Renderers and Terrain default to not receive any Decals. Later versions use **Decal Layer Default** by default.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ The HDRP Default Settings tab is part of the Project Settings window. To get to
| Render Pipeline Resources | Stores references to Shaders and Materials that HDRP uses. When you build your Unity Project, HDRP embeds all of the resources that this Asset references. It allows you to set up multiple render pipelines in a Unity Project and, when you build the Project, Unity only embeds Shaders and Materials relevant for that pipeline. This is the Scriptable Render Pipeline equivalent of Unity’s Resources folder mechanism. When you create a new HDRP Asset, Unity also creates one of these and references it in the new HDRP Asset automatically. |
| Render Pipeline Editor Resources | Stores reference resources for the Editor only. Unity does not include these when you build your Unity Project. When you create an HDRP Asset, Unity creates an HDRP Resources Asset, and the new HDRP Asset references it automatically. |
| Shader Variant Log Level | Use the drop-down to select what information HDRP logs about Shader variants when you build your Unity Project. • Disabled: HDRP doesn’t log any Shader variant information.• Only HDRP Shaders: Only log Shader variant information for HDRP Shaders.• All Shaders: Log Shader variant information for every Shader type. |
| Light Layer Names | The name displayed on light and meshes when using [Light Layers](Light-Layers.md). |
| Decal Layer Names | The name displayed on decal and meshes when using [Decal Layers](Decal.md) |
| Light Layer Names | The name displayed on Lights and Meshes when using [Light Layers](Light-Layers.md).. |
| Decal Layer Names | The name displayed on decals and Meshes when using [Decal Layers](Decal.md). |


## Frame Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ The AxF Shader supports the [X-Rite AxF](https://www.xrite.com/axf) measured Mat

![](Images/HDRPFeatures-DecalShader.png)

The Decal allows you to place decals on surfaces in your Scene. To apply a decal to a surface, you can either use the [Decal Projector component](Decal-Projector.md) to project the decal onto the surface, or assign the decal shader directly to a Mesh and then place the Mesh on the surface. For more information, including the full list of Shader properties, see the [Decal documentation](Decal.md).
HDRP allows you to apply decals to surfaces in your Scene. To apply a decal to a surface, you can either use the [Decal Projector component](Decal-Projector.md) to project the decal onto the surface, or assign the decal shader directly to a Mesh and then place the Mesh on the surface. For more information, see the [Decal documentation](Decal.md).

The Decal also support Decals layers allowing to control which objects receive decal or not.
HDRP also supports Decal Layers which allows you to control which GameObjects receive decals or not.

### Terrain Shader

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ From Unity 2020.2, if you create a new [HDRP Asset](HDRP-Asset.md), the **MSAA W

## Decal

From Unity 2020.2, Decal no longer require a full Depth Prepass. Only Material with **Receive Decals** enable will be render during the Depth Prepass. Unless other option force it.
From Unity 2020.2, decals no longer require a full Depth Prepass. HDRP only renders Materials with **Receive Decals** enabled during the Depth Prepass. Unless other options force it.

From Unity 2020.2, A new Decal Layer system is supported. It is disable by default. This Decal Layers system make use of the **Rendering Layer Mask** from Mesh Renderer and Terrain. The default value of this property prior of 2020.2 don't include any Decal Layer flags. Consequence is that when enabling this feature, no meshes will receives decal until configure correctly. A script **Edit > Render Pipeline/HD Render Pipeline > Upgrade from Previous Version > Enable Decal Layer Default on all loaded Mesh Renderer and Terrain** is provided to convert the already created Meshes as well a version to apply only on a selection. Newly created Mesh Renderer or Terrain have the have **Decal Layer Default** enable by default.

Warning: 2020.2.0b1 Isn't including the modification for the default value of **Rendering Layer Mask**. Creating new Meshes in this version don't have the correct flag.
Warning: 2020.2.0b1 does not include the modification for the default value of Rendering Layer Mask. If you use this version of Unity and create a new Mesh Renderer or Terrain, they do have the correct flag.

## Lighting

Expand Down Expand Up @@ -91,7 +91,7 @@ From Unity 2020.2, the macro ENABLE_RAYTRACING, SHADEROPTIONS_RAYTRACING, and RA

From Unity 2020.2,SHADERPASS for TransparentDepthPrepass and TransparentDepthPostpass identification is using respectively SHADERPASS_TRANSPARENT_DEPTH_PREPASS and SHADERPASS_TRANSPARENT_DEPTH_POSTPASS. Previously it was SHADERPASS_DEPTH_ONLY. Define CUTOFF_TRANSPARENT_DEPTH_PREPASS and CUTOFF_TRANSPARENT_DEPTH_POSTPASS and been removed as the new path macro can now be used.

From Unity 2020.2, a new multi compile is added on Depth Prepass and Motion vector pass to allow to support the Decal Layer feature. Those pass require to add #pragma multi_compile _ WRITE_DECAL_BUFFER.
Unity 2020.2 introduces a new multi-compile for Depth Prepass and Motion vector pass to allow for support of the Decal Layers feature. These passes now require you to add #pragma multi_compile _ WRITE_DECAL_BUFFER.

## Custom pass API

Expand Down