文档

Unity Engine


User Manual

Script Reference

Unity Engine


SubShader tags in ShaderLab reference

Reference for the Tags in the SubShader block in ShaderLab.
阅读时间3 分钟最后更新于 1 个月前

重要
The Built-In Render Pipeline is deprecated and will be made obsolete in a future release.
It remains supported, including bug fixes and maintenance, through the full Unity 6.7 LTS lifecycle.
This page contains information on using a
Tags
block in your ShaderLab code to assign tags to a SubShader.
For information on defining SubShader, see ShaderLab: defining a SubShader. For information on how a Shader object works, and the relationship between Shader objects, SubShaders and Passes, see Shader objects.

Render pipeline compatibility

Feature name

Universal Render Pipeline (URP)

High Definition Render Pipeline (HDRP)

Custom SRP

Built-in Render Pipeline

ShaderLab: SubShader Tags blockYesYesYesYes
ShaderLab: RenderPipeline SubShader tagYesYesNoNo
ShaderLab: Queue SubShader tagYesYes

Yes

Note: in a custom SRP, you can define your own rendering order and choose whether or not to use render queues. For more information, see DrawingSettings and SortingCriteria.
Yes
ShaderLab: RenderType SubShader tagYesYesYesYes
ShaderLab: IgnoreProjector SubShader tagNoNoNoYes
ShaderLab: ForceNoShadowCasting SubShader tagYesYes

This disables regular shadows, but has no effect on contact shadows.
YesYes
ShaderLab: PreviewType SubShader tagYesYesYesYes

Syntax

Signature

Function

Tags { "[name1]" = "[value1]" "[name2]" = "[value2]"}Applies the given tags to the SubShader.

You can define as many tags as you like.

RenderPipeline tag

Signature

Function

"RenderPipeline" = "[name]"Tells Unity whether this SubShader is compatible with URP or HDRP.

Parameter

Value

Function

[name]
UniversalPipeline
This SubShader is compatible with URP only.
HDRenderPipeline
This SubShader is compatible with HDRP only.
(any other value, or not declared)This SubShader is not compatible with URP or HDRP.

Queue tag

Signature

Function

"Queue" = "[queue name]"Use the named render queue.
"Queue" = "[queue name] + [offset]"Use an unnamed queue, at a given offset from the named queue.

An example of when this is useful is in the case of transparent water, which you should draw after opaque objects but before transparent objects.

Signature

Value

Function

[queue name]BackgroundSpecifies the Background render queue.
GeometrySpecifies the Geometry render queue.
AlphaTestSpecifies the AlphaTest render queue.
TransparentSpecifies the Transparent render queue.
OverlaySpecifies the Overlay render queue.
[offset]integerSpecifies the index at which Unity renders the unnamed queue, relative to the named queue.

RenderType tag

Signature

Function

"RenderType" = "[renderType]"Set the RenderType value for this SubShader.

Signature

Value

Function

[renderType]StringThere are no set values for this parameter. To identify the RenderType value for any SubShader that you want to replace, open its shader source file.

The
RenderType
SubShader tags for Unity's legacy built-in shaders are listed on the shader replacement page.

You can also create your own values for your custom SubShaders.

ForceNoShadowCasting tag

Signature

Function

"ForceNoShadowCasting" = "[state]"Whether to prevent shadow casting (and sometimes receiving) for all geometry that uses this SubShader.

Signature

Value

Function

[state]TrueUnity prevents the geometry in this SubShader from casting shadows.

In the Built in Render Pipeline, with the Forward or Legacy Vertex Lit rendering paths, Unity also prevents the geometry in this SubShader from receiving shadows.

In HDRP, this does not prevent the geometry from casting contact shadows.
FalseUnity does not prevent the geometry in this SubShader from casting or receiving shadows. This is the default value.

IgnoreProjector tag

This tag is only supported in the Built-In Render Pipeline.

Signature

Function

"IgnoreProjector" = "[state]"Whether Unity ignores Projectors when rendering this geometry.

Signature

Value

Function

[state]TrueUnity ignores Projectors when rendering this geometry.
FalseUnity does not ignore Projectors when rendering this geometry. This is the default value.

PreviewType tag

The
PreviewType
SubShader Tag tells the Unity Editor how to display a material that uses this SubShader in the Material Inspector.

Signature

Function

"PreviewType" = "[shape]"Which shape the Unity Editor uses to display a preview of a material that uses this SubShader.

Signature

Value

Function

[shape]SphereDisplay the material on a sphere. This is the default value.
PlaneDisplay the material on a plane.
SkyboxDisplay the material on a skybox.

Additional resources