文档

Unity Engine

Download Unity

Unity Engine

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

PositionVector3Sets the vertex position in object space.
NormalVector3Sets the normal of the vertex in object space.
TangentVector3Sets the tangent of the vertex in object space.
Motion VectorVector3Sets 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 ColorVector3Sets the base color of the material. The default is
Color.grey
.
Normal (Tangent Space)Vector3Sets the surface normal in tangent space. This property is available only when you set Fragment Normal Space to Tangent in graph settings.
Normal Object SpaceVector3Sets the surface normal in object space. This property is available only when you set Fragment Normal Space to Object in graph settings.
Normal World SpaceVector3Sets the surface normal in world space. This property is available only when you set Fragment Normal Space to World in graph settings.
MetallicFloatSets 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 ColorVector3Sets the brightness and tint color of specular highlights. The default is
Color.grey
. This property is available only when Workflow Mode is Specular.
SmoothnessFloatSets the smoothness of the material. The default is 0.5.
EmissionFloat3Sets 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 OcclusionFloatSets 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.
AlphaFloatSets 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 ThresholdFloatSets 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 MaskFloatSets 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 SmoothnessFloatSets 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 OverrideEnables 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 ModeDefines how the shader calculates reflections and specular highlights. The options are:
  • Specular: Uses a specular color input to define the brightness and tint of specular reflections for non‑metallic surfaces.
  • Metallic: Uses a metallic input to define how much of the surface behaves like metal. Metallic surfaces reflect the environment color, while non‑metallic surfaces reflect the base color.
When you change this setting, Unity adds either the Specular Color Block or the Metallic Block to the Fragment Context.
Surface TypeDetermines if the material supports transparency. The options are:
  • Opaque: The material is fully opaque and doesn't use transparency blending.
  • Transparent: The material uses transparency blending based on the alpha channel. Unity adds the Alpha Block to the Fragment Context.
Blending ModeSets 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:
  • Alpha: Calculates transparency using the alpha value of the material.
  • Premultiply: Calculates transparency using the alpha value of the material, but multiplies the RGB values by the alpha value first.
  • Additive: Adds the color of the material to the background color.
  • Multiply: Multiplies the color of the material with the background color.
For more information about blending modes, refer to Blend modes.
Render FaceSpecifies which faces of the mesh the shader renders. The options are:
  • Front: Renders only front‑facing triangles. This is the default.
  • Back: Renders only back‑facing triangles.
  • Both: Renders both front and back faces.
Override DepthDetermines 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 StencilDetermines 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 PassesSets which shader passes use the depth and stencil overrides. The options are:
  • Nothing: Doesn't apply the overrides to any pass.
  • Everything: Applies the overrides to all the passes in this list.
  • Color Pass: Applies the overrides to the passes that render color. This is the default.
  • Depth Prepass: Applies the overrides to the depth prepass.
  • Shadow Pass: Applies the overrides to the shadow pass. To write stencil values in this pass, enable Shadowmap Stencil in the active Universal Renderer asset. Otherwise, Unity displays a warning. This option has no effect if you disable Cast Shadows.
This property is available only when you enable Allow Material Override, Override Depth, or Override Stencil.
Alpha ClippingDiscards 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 ShadowsDetermines whether the material casts shadows onto other objects.
Receive ShadowsDetermines whether the material receives and displays shadows cast from other objects.
Supports LOD Cross FadeEnables support for Level of Detail (LOD) cross‑fading when used with a Mesh Renderer that has LOD Group cross‑fade enabled.
Additional Motion VectorsControls how Unity generates motion vectors for this material, for motion blur and temporal anti‑aliasing. The options are:
  • None: Generates no motion vectors.
  • Time Based: Computes motion vectors automatically from per‑frame transformations.
  • Custom: Enables you to manually provide motion vector data through the Motion Vector Block in the Vertex Context.
For more information, refer to Built-in shader support for motion vectors in URP.
Alembic Motion VectorsEnables 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 SpaceSpecifies the coordinate space for the normal input in the Fragment Context. The options are:
  • Tangent: Normals are relative to the mesh surface’s UV orientation.
  • Object: Normals are relative to the mesh’s local coordinate system.
  • World: Normals are relative to the global scene coordinate system.
When you change this setting, Unity adds the corresponding Normal Block to the Fragment Context.
Clear CoatEnables 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 GUIRenders 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 GraphEnables 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 DepthDetermines 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 TestSpecifies the comparison function used to determine whether a pixel passes the depth test. The options are:
  • Never: The pixel never passes the depth test.
  • Less: Passes if the incoming depth value is less than the stored depth.
  • Equal: Passes if the incoming depth value equals the stored depth.
  • L Equal: Passes if the incoming depth value is less than or equal to the stored depth.
  • Greater: Passes if the incoming depth value is greater than the stored depth.
  • Not Equal: Passes if the incoming depth value isn't equal to the stored depth.
  • G Equal: Passes if the incoming depth value is greater than or equal to the stored depth.
  • Always: The pixel always passes the depth test.

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 RefSets 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 MaskSets 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 MaskSets 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 FunctionCompares the value in Stencil Ref with the value in the stencil buffer for each pixel. The options are:
  • Never: The stencil test never passes.
  • Less: Passes if the reference value is less than the stencil buffer value.
  • Equal: Passes if the reference value equals the stencil buffer value.
  • Less Equal: Passes if the reference value is less than or equal to the stencil buffer value.
  • Greater: Passes if the reference value is greater than the stencil buffer value.
  • Not Equal: Passes if the reference value isn't equal to the stencil buffer value.
  • Greater Equal: Passes if the reference value is greater than or equal to the stencil buffer value.
  • Always: The stencil test always passes. This is the default.
PassSets the operation to perform on the stencil buffer value when a pixel passes both the stencil test and the depth test. The options are:
  • Keep: Keeps the current contents of the stencil buffer. This is the default.
  • Zero: Writes 0 into the stencil buffer.
  • Replace: Writes the reference value into the buffer.
  • Increment Saturate: Increments the current value in the buffer. If the value is already the maximum value, it doesn't change.
  • Decrement Saturate: Decrements the current value in the buffer. If the value is 0 already, it stays at 0.
  • Invert: Negates all the bits of the current value in the buffer.
  • Increment Wrap: Increments the current value in the buffer. If the value is already the maximum value, it becomes 0.
  • Decrement Wrap: Decrements the current value in the buffer. If the value is 0 already, it becomes the maximum value.
FailSets the operation to perform on the stencil buffer value when the stencil test fails. The options are:
  • Keep: Keeps the current contents of the stencil buffer. This is the default.
  • Zero: Writes 0 into the stencil buffer.
  • Replace: Writes the reference value into the buffer.
  • Increment Saturate: Increments the current value in the buffer. If the value is already the maximum value, it doesn't change.
  • Decrement Saturate: Decrements the current value in the buffer. If the value is 0 already, it stays at 0.
  • Invert: Negates all the bits of the current value in the buffer.
  • Increment Wrap: Increments the current value in the buffer. If the value is already the maximum value, it becomes 0.
  • Decrement Wrap: Decrements the current value in the buffer. If the value is 0 already, it becomes the maximum value.
Z FailSets the operation to perform on the stencil buffer value when the stencil test passes but the depth test fails. The options are:
  • Keep: Keeps the current contents of the stencil buffer. This is the default.
  • Zero: Writes 0 into the stencil buffer.
  • Replace: Writes the reference value into the buffer.
  • Increment Saturate: Increments the current value in the buffer. If the value is already the maximum value, it doesn't change.
  • Decrement Saturate: Decrements the current value in the buffer. If the value is 0 already, it stays at 0.
  • Invert: Negates all the bits of the current value in the buffer.
  • Increment Wrap: Increments the current value in the buffer. If the value is already the maximum value, it becomes 0.
  • Decrement Wrap: Decrements the current value in the buffer. If the value is 0 already, it becomes the maximum value.

Additional resources