Version: 2022.1
ShaderLab: assigning a name to a Pass
ShaderLab: Predefined Pass tags in the Built-in Render Pipeline

ShaderLab: assigning tags to a Pass

This page contains information on using a Tags block in your ShaderLab code to assign tags to a Pass. It also contains information on using the LightMode tag.

For information on how a Shader object works, and the relationship between Shader objects, SubShaders and Passes, see Shader object fundamentals.


Tags are key-value pairs of data that you can assign to a Pass. Unity uses predefined tags and values to determine how and when to render a given Pass. You can also create your own custom Pass tags with custom values, and access them from C# code.

The most commonly used predefined Pass tag is the LightMode tag; this is used in all render pipelines. Other Pass tags vary by render pipeline. For more information, see the following pages:


機能名 ビルトインレンダーパイプライン ユニバーサルレンダーパイプライン (URP) HD レンダーパイプライン (HDRP) カスタム SRP
ShaderLab: Pass Tags block
ShaderLab: LightMode Pass tag

Using the Tags block

To assign Tags to a Pass in ShaderLab, you place a Tags block inside a Pass block.

SubShader と Pass の両方が Tags ブロックを使用していますが、動作が異なることに注意してください。SubShader のタグを Pass に割り当てても効果はなく、その逆も同様です。その違いは以下に示すように、 Tags ブロックをどこに置くかによります。

  • Pass タグを定義するには、Tags ブロックを、Pass ブロック内に配置します。
  • SubShader タグを定義するには、Tags ブロックを SubShader ブロック内に置き、かつ、Pass ブロックの外になるように配置します。

For information on assigning tags to a SubShader, see Assigning tags to a SubShader.

シグネチャ 機能
Tags {"<name1>" = "<value1>" "<name2>" = "<value2>"} Applies the given tags to the Pass.

You can define as many tags as you like.

Using Pass tags with C# scripts

To access the value of a Pass tag from C# scripts, you can use the Shader.FindPassTagValue API. This works for Unity’s predefined Pass tags, and for custom Pass tags that you have created.

Note: There are several APIs that work directly with the LightMode Pass tag. For more information, see Using the LightMode tag with C# scripts.

LightMode tag

The LightMode tag is a predefined Pass tag that Unity uses to determine whether to execute the Pass during a given frame, when during the frame Unity executes the Pass, and what Unity does with the output.

Note: The LightMode tag is not related to the LightMode enum, which relates to lighting.

Every render pipeline uses the LightMode tag, but the predefined values and their meanings vary. For more information, see Syntax and valid values.

In the Built-in Render Pipeline, if you do not set a LightMode tag, Unity renders the Pass without any lighting or shadows; this essentially the same as having a LightMode value of Always. In the Scriptable Render Pipeline, you can use the SRPDefaultUnlit value to reference Passes without a LightMode tag.


シグネチャ 機能
“LightMode” = “[value]” Sets the LightMode value for this Pass.

Valid values for this tag depend on the render pipeline.

Using the LightMode tag with C# scripts

Material.SetShaderPassEnabled and ShaderTagId use the value of the LightMode tag to determine how Unity handles a given Pass.

In the Scriptable Render Pipeline, you can create custom values for the LightMode tag. You can then use these custom values to determine which Passes to draw during a given call to ScriptableRenderContext.DrawRenderers, by configuring a DrawingSettings struct. For more information and a code example, see Creating a simple render loop in a custom Scriptable Render Pipeline.

Shader "Examples/ExampleLightMode"
              Tags { "LightMode" = "Always" }
              // The rest of the code that defines the Pass goes here.
ShaderLab: assigning a name to a Pass
ShaderLab: Predefined Pass tags in the Built-in Render Pipeline