Decal
The Decal Master Stack material type enables you to author decals that you can project or place into your Scene. The Decal Master Stack material type is similar to the standard Decal Shader, except that you can't use this version to author decals projected on transparent materials.
Creating a Decal Shader Graph
To create a Decal material in Shader Graph, use one of the following methods:
- Modify an existing Shader Graph.
- Open the Shader Graph in the Shader Editor.
- In Graph Settings, select the HDRP Target. If there isn't one, go to Active Targets, click the Plus button, and select HDRP.
- In the Material drop-down, select Decal.
- Create a new Shader Graph. Go to Assets > Create > Shader Graph > HDRP and click Decal Shader Graph.
Contexts
This Master Stack material type has its own set of Graph Settings. Because of the relationship between settings and Blocks, this has consequences on which Blocks are relevant to the Graph. This section contains information on the Blocks this Master Stack material type adds by default, and which Blocks set properties for this Master Stack material type's Graph Settings.
For more information about the relationship between Graph Settings and Blocks, see Contexts and Blocks.
Vertex Context
Default
Property | Description | Setting Dependency | Default Value |
---|---|---|---|
Position | The object space vertex position per vertex. | None | CoordinateSpace.Object |
Normal | The object space vertex normal per vertex. | None | CoordinateSpace.Object |
Tangent | The object space vertex tangent per vertex. | None | CoordinateSpace.Object |
Relevant
This Master Stack material type adds all its Vertex Blocks to the Vertex Context by default and has no extra relevant Blocks.
Fragment Context
Default
When you create a new Decal Master Stack, the Fragment Context contains the following Blocks by default:
Property | Description | Setting Dependency | Default Value |
---|---|---|---|
Base Color | The base color of the material. | None | Color.grey |
Alpha | The Material's alpha value. This determines how transparent the material is. The expected range is 0 - 1. | None | 1.0 |
Normal Tangent Space | The normal, in tangent space, for the material. | Fragment Normal Space set to Tangent | CoordinateSpace.Tangent |
Normal Alpha | The blend factor for the Material’s normals. A decal modifies the normals of the Material the decal projects onto. A value of 0 means that the decal does not affect the normals of the surface it projects onto. A value of 1 means that the decal fully overrides the normals of the surface. | • Material set to Decal | 1.0 |
Metallic | The material's metallic value. This defines how "metal-like" the surface of your Material is (between 0 and 1). When a surface is more metallic, it reflects the environment more and its albedo color becomes less visible. At full metallic level, the surface color is entirely driven by reflections from the environment. When a surface is less metallic, its albedo color is clearer and any surface reflections are visible on top of the surface color, rather than obscuring it. | None | 0.0 |
Ambient Occlusion | The material's ambient occlusion. This approximates occlusion for a fragment on a GameObject’s surface that has been cast by details present in the Material but not the mesh geometry. A value of 0 means the fragment is completely occluded and appears black. A value of 1 means the fragment is not occluded at all, and the ambient color does not change. | None | 1.0 |
Smoothness | The material's smoothness. Every light ray that hits a smooth surface bounces off at predictable and consistent angles. For a perfectly smooth surface that reflects light like a mirror, set this to a value of 1. Less smooth surfaces reflect light over a wider range of angles (because the light hits the bumps in the microsurface), so the reflections have less detail and spread across the surface in a more diffused pattern. | None | 0.5 |
MAOS Alpha | The opacity of the Metallic, Ambient Occlusion, and Smoothness values. | • Material Type set to Decal | 1.0 |
Emission | The color of light to emit from this material's surface. Emissive materials appear as a source of light in your scene. | None | Color.black |
Relevant
This Master Stack material type adds all its Fragment Blocks to the Fragment Context by default and has no extra relevant Blocks.
Graph Settings
Surface Options
Setting | Description |
---|---|
Affect BaseColor | Indicates whether the decal shader affects the base color of Materials it's projected or placed on. |
Affect Normal | Indicates whether the decal shader affects the normals of GameObjects it's projected or placed on. When enabled, the shader uses the Normal Block to override the receiving Material's normals. |
Affect Metal | Indicates whether the decal shader affects the metallic property of Materials it's projected or placed on. When enabled, the shader uses the Metallic Block to override the receiving Material's metallic property. |
Affect Ambient Occlusion | Indicates whether the decal shader affects the ambient occlusion property of Materials it's projected or placed on. When enabled, the shader uses the Ambient Occlusion Block to override the receiving Material's ambient occlusion. |
Affect Smoothness | Indicates whether the decal shader affects the smoothness property of materials it's projected or placed on. When enabled, the shader uses the Smoothness Block to override the receiving Material's smoothness property. |
Affect Emissive | Indicates whether the decal shader affects the emission property of Materials it's projected or placed on. When enabled, the shader uses the Emission Block to override the receiving Material's emission property. Emissive Materials appear self-illuminated and act as a visible source of light. This property doesn't work with receiving Materials that are transparent. |
Other Settings
Setting | Description |
---|---|
Transparent Dynamic Update | When enabled, the textures in the decal atlas are updated every frame. This property only has an impact if Affects Transparent is enabled in the decal projector. Enabling this has a performance impact. |
Affects Transparent
In case the master stack material is being used with a decal projector that has Affects Transparent enabled the surface options determine which textures are being added to the texture atlas. Based on these settings textures are being added for:
- The BaseColor texture is always added regardless of settings. This is so the alpha value of the texture is always available.
- The Normal texture is added if Affect Normal is enabled.
- The Mask texture is added if Affect Metal, Ambient Occlusion, or Smoothness are enabled.
- Emissive is not supported.
Dynamic Update
By default the decal only updates if the material changes or its resolution has been changed. If the master stack material is supposed to be updated dynamically for example when using a Time node it has to be enabled explicitly through the Transparent Dynamic Update setting. Decals with the same material will share the same space in the texture atlas. To create a different output, a new material has to be created. It is possible to call DecalProjector.UpdateTransparentShaderGraphTextures through a script. This will force an update for all textures of the decal projector in the atlas. It has the advantage that a dynamic update of every frame can be avoided while still being able to update the atlas texture if needed.
Limitations
In general the same limitations as for decal shaders apply when enabling Affects Transparent. These additional limitations have to be considered for the master stack decal:
- Vertex inputs such as position, normal, or tangent are not supported. If the shader graph modifies these the modification will be ignored when the decal is applied on transparent geometry.
- Geometry, scene, and buffer inputs are not supported.