ShaderLab: Pass Tags
Passes使用Tags来告诉渲染引擎如何和何时将它们渲染。
Syntax
Tags { "TagName1" = "Value1" "TagName2" = "Value2" }
指定 TagName1 有值 Value1, TagName2 有值 Value2. 你可以定义任意数量的tags.
Details
Tags是基本的键值对. 在内部一个Pass 的 tags 用来控制该pass在光照管线中有什么作用 (ambient, vertex lit, pixel lit etc.) 和其他一些选项. 注意下面的被Unity定义的tags,必须在Pass区块,不能在SubShader中!
LightMode tag
LightMode tag 定义了 Pass 在光照管线内的作用。 See render pipeline for details. 这些标签是很少手动使用; 通常需要与灯光交互的shader被写成 Surface Shaders 然后所有这些细节都被转交.
LightMode tag 可能的值:
- Always: Always rendered; no lighting is applied.
- ForwardBase: Used in Forward rendering, ambient, main directional light, vertex/SH lights and lightmaps are applied.
- ForwardAdd: Used in Forward rendering; additive per-pixel lights are applied, one pass per light.
- Deferred: Used in Deferred Shading; renders g-buffer.
- ShadowCaster: Renders object depth into the shadowmap or a depth texture.
- MotionVectors: Used to calculate per-object motion vectors.
- PrepassBase: Used in legacy Deferred Lighting, renders normals and specular exponent.
- PrepassFinal: Used in legacy Deferred Lighting, renders final color by combining textures, lighting and emission.
- Vertex: Used in legacy Vertex Lit rendering when object is not lightmapped; all vertex lights are applied.
- VertexLMRGBM: Used in legacy Vertex Lit rendering when object is lightmapped; on platforms where lightmap is RGBM encoded (PC & console).
- VertexLM: Used in legacy Vertex Lit rendering when object is lightmapped; on platforms where lightmap is double-LDR encoded (mobile platforms).
PassFlags tag
Pass可以声明标志来改变 rendering pipeline传输数据给它的方式。 可以使用 PassFlags tag 来达到目的, 它的值,是space-separated的flag names. 目前支持的标识:
- OnlyDirectional: 当在pass使用ForwardBase, 这个标志会使只有主要的平行光和环境光/光探头的数据会传入shader。这意味着非重要光线的数据不会被传递到顶点光或球谐着色器变量中. See Forward rendering for details.
RequireOptions tag
A pass can indicate that 只会在满足一定外部条件时才会渲染。 This is done by using RequireOptions tag, whose value is a string of space separated options. Currently the options supported by Unity are:
- SoftVegetation: 只有当Soft Vegetation在 Quality Settings里打开时,才会渲染.