Lit shader graph reference for URP
Explore the properties and settings you can use to customize the default Lit shader graph.
阅读时间11 分钟最后更新于 19 天前
Explore the properties and settings you can use to customize the default Lit shader graph in the Universal Render Pipeline (URP).
Contexts
The default Vertex and Fragment Contexts contain the following Blocks. Which Blocks display might change depending on the graph settings.
Vertex Context
Input | Type | Description |
|---|---|---|
| Position | Vector3 | Sets the vertex position in object space. |
| Normal | Vector3 | Sets the normal of the vertex in object space. |
| Tangent | Vector3 | Sets the tangent of the vertex in object space. |
| Motion Vector | Vector3 | Sets the per‑vertex motion vector in object space. This property is available only if you set Additional Motion Vector to Custom in graph settings. |
Fragment Context
Input | Type | Description |
|---|---|---|
| Base Color | Vector3 | Sets the base color of the material. The default is |
| Normal (Tangent Space) | Vector3 | Sets the surface normal in tangent space. This property is available only when you set Fragment Normal Space to Tangent in graph settings. |
| Normal Object Space | Vector3 | Sets the surface normal in object space. This property is available only when you set Fragment Normal Space to Object in graph settings. |
| Normal World Space | Vector3 | Sets the surface normal in world space. This property is available only when you set Fragment Normal Space to World in graph settings. |
| Metallic | Float | Sets the metallic value of the material, where 0 is non-metallic and 1 is metallic. The default is 0. This property is available only when Workflow Mode is Metallic. |
| Specular Color | Vector3 | Sets the brightness and tint color of specular highlights. The default is |
| Smoothness | Float | Sets the smoothness of the material. The default is 0.5. |
| Emission | Float3 | Sets the color the material emits as a light source. The default is black. For more information, refer to Add light emission to a material. |
| Ambient Occlusion | Float | Sets the ambient occlusion of the material. The range is 0 to 1, where 0 means the fragment is completely occluded and 1 means the fragment isn't occluded at all so the ambient color doesn't change. The default is 1. |
| Alpha | Float | Sets the alpha of the material. The range is 0 to 1. The default is 1. This property is available only if you set Surface Type to Transparent or you enable Alpha Clipping in graph settings. |
| Alpha Clip Threshold | Float | Sets the minimum alpha value for a pixel to be visible. The range is 0 to 1. The default is 0.5. This property is available only if you enable Alpha Clipping in the graph settings. |
| Coat Mask | Float | Sets the strength of the clear coat layer, where 0 disables the coat and 1 applies it fully across the surface. The default is 0. This property is available only when you enable Clear Coat in graph settings. |
| Coat Smoothness | Float | Sets the smoothness of the clear coat layer. The default is 1. This property is available only when you enable Clear Coat in graph settings. |
Graph Settings
Explore the shader graph settings you can use to customize the Vertex and Fragment Contexts.
For more details about graph settings that are common to all shader graph shaders, refer to the Graph Settings tab.
Setting | Description |
|---|---|
| Allow Material Override | Enables material instances to override properties exposed in the shader graph. When disabled, materials using this shader will always use the values defined in the shader asset. |
| Workflow Mode | Defines how the shader calculates reflections and specular highlights. The options are:
|
| Surface Type | Determines if the material supports transparency. The options are:
|
| Blending Mode | Sets how the shader blends the color of a transparent material with the background. This property is available only when you set Surface Type to Transparent. The options are:
|
| Render Face | Specifies which faces of the mesh the shader renders. The options are:
|
| Override Depth | Determines whether the shader uses custom depth write and depth test settings instead of the defaults. When disabled, the shader uses the default settings for the Surface Type: opaque surfaces write to the depth buffer and transparent surfaces don't, and both use the default depth test, L Equal, which passes when a pixel's depth is less than or equal to the stored depth. For the settings available when you enable this property, refer to Depth override settings. |
| Override Stencil | Determines whether the shader uses custom stencil settings instead of the URP defaults. For the settings available when you enable this property, refer to Stencil override settings. For more information, refer to ShaderLab: Stencil. |
| Override Passes | Sets which shader passes use the depth and stencil overrides. The options are:
|
| Alpha Clipping | Discards pixels if their alpha value is lower than a threshold value. When you enable this setting, Unity adds the Alpha Clip Threshold Block to the Fragment context. |
| Cast Shadows | Determines whether the material casts shadows onto other objects. |
| Receive Shadows | Determines whether the material receives and displays shadows cast from other objects. |
| Supports LOD Cross Fade | Enables support for Level of Detail (LOD) cross‑fading when used with a Mesh Renderer that has LOD Group cross‑fade enabled. |
| Additional Motion Vectors | Controls how Unity generates motion vectors for this material, for motion blur and temporal anti‑aliasing. The options are:
|
| Alembic Motion Vectors | Enables motion vector support for meshes streamed through Alembic files. For more information, refer to Built-in shader support for motion vectors in URP. |
| Fragment Normal Space | Specifies the coordinate space for the normal input in the Fragment Context. The options are:
|
| Clear Coat | Enables you to add an additional transparent, reflective layer over the base material to simulate surfaces like car paint or varnished wood. When you enable this setting, Unity adds the Coat Mask and Coat Smoothness Blocks to the Fragment Context. |
| Custom Editor GUI | Renders a custom editor GUI in the Inspector window of the material. Enter the name of the GUI class in the field. For more information, refer to Control material properties in the Inspector window. |
| Support VFX Graph | Enables this shader graph to support the Visual Effect Graph. |
Depth override settings
When you enable Override Depth, the following settings are available.
Setting | Description |
|---|---|
| Write Depth | Determines whether the shader writes depth values to the depth buffer. When you enable Override Depth, this property is enabled by default for opaque surfaces and disabled for transparent surfaces. |
| Depth Test | Specifies the comparison function used to determine whether a pixel passes the depth test. The options are:
|
Stencil override settings
When you enable Override Stencil, the following settings are available. If you set Render Face to Both, the Compare Function, Pass, Fail, and Z Fail properties appear under both Front Face and Back Face, so you can set a separate value for each face.
Setting | Description |
|---|---|
| Stencil Ref | Sets the reference value to compare against the value in the stencil buffer. Unity writes this value to the stencil buffer if a stencil operation is set to Replace. The range is 0 to 15, and the default is 0. URP reserves the upper four bits of the stencil buffer. |
| Read Mask | Sets the bitmask that Unity applies to the reference value and the stencil buffer value before the stencil test. The range is 0 to 15, and the default is 15. |
| Write Mask | Sets the bitmask that defines which bits of the stencil buffer Unity writes to. The range is 0 to 15, and the default is 15. |
| Compare Function | Compares the value in Stencil Ref with the value in the stencil buffer for each pixel. The options are:
|
| Pass | Sets the operation to perform on the stencil buffer value when a pixel passes both the stencil test and the depth test. The options are:
|
| Fail | Sets the operation to perform on the stencil buffer value when the stencil test fails. The options are:
|
| Z Fail | Sets the operation to perform on the stencil buffer value when the stencil test passes but the depth test fails. The options are:
|
Additional resources
- Get started with Shader Graph on Unity Learn
- Introduction to motion vectors