Set the render pipeline and render order for a shader
Use a Tag statement to set the render pipeline and render order for a shader.
Read time 3 minutesLast updated a month ago
To set the render pipeline and render order for a subshader or a shader pass, add a block.
TagAdd a tag
Add a block to a block or a block. For example:
TagSubShaderPassShader "TagsExample"{ SubShader { // Add a subshader tag Tags { "TagName" = "Value" } Pass { // Add a pass tag Tags { "TagName" = "Value" } ... } }}
For more information about tag names and values, refer to tags in ShaderLab reference and tags in ShaderLab reference. Not all blocks are compatible with both subshaders and passes.
SubShaderPassTagYou can also add your own custom tags and read them from a C# script.
Set the render pipeline
To make a subshader compatible with the Universal Render Pipeline (URP) or the High Definition Render Pipeline (HDRP), add a tag to the block:
RenderPipelineSubShader- For URP, use
"RenderPipeline" = "UniversalPipeline" - For HDRP, use
"RenderPipeline" = "HDRenderPipeline"
Set the render order
Unity uses two tags to determine when to execute a shader:
- tag: Sets which stage of the render pipeline a shader pass runs during. For example, drawing opaque geometry, or drawing post-processing effects.
LightMode - tag: Sets which group of objects a subshader belongs to. Unity draws each render queue in a specific order.
Queue
Each stage usually renders a specific range. Unity warns you if you use a tag that the stage doesn't render.
LightModeQueueQueueLightModeSet the LightMode
tag
LightModeAdd a tag to the block. For example, to execute the shader during the forward rendering pass in the Universal Render Pipeline (URP) that renders the queue, use .
LightModePassGeometryTags { "LightMode" = "UniversalForward" }For a list of values, refer to tag valid values and ShaderLab tags in URP reference.
LightModeLightModePassTo enable or disable a shader pass by its tag, use the API.
LightModeMaterial.SetShaderPassEnabledSet the Queue tag
Add a tag to the block. Use one of the following approaches:
QueueSubShader- To add the subshader to a queue, use . For example
"Queue" = "RenderQueueName"."Queue" = "Transparent" - To add the subshader before or after a queue, use or
"Queue" = "RenderQueueName-Offset". For example,"Queue" = "RenderQueueName+Offset"."Queue" = "Geometry+1"
You can also use queue values instead of names. For example, instead of , or instead of .
"Queue" = "3000""Queue" = "Transparent""Queue" = "2001""Queue" = "Geometry+1"You can also set the queue in the Inspector window of the material using the Render Queue property, or in a C# script using the API.
Material.renderQueueFor more information, refer to Render queues and sorting behaviours.
Check tags
To read tags from a C# script, use the following:
- To read a subshader tag, use the API.
Material.GetTag - To read a pass tag, use the API.
Shader.FindPassTagValue - To read a tag, use the
QueueAPI.Shader.renderQueue