Unity3D Shader官方教程翻译(十二)----Shader语法:Pass的标记

ShaderLab syntax: Pass Tags


Passes use tags to tell how and when they expect to be rendered to the rendering engine.

pass使用标记来告诉渲染引擎在什么时候该如何渲染他们所期望的效果。
Syntax
Tags { "TagName1" = "Value1" "TagName2" = "Value2" }
Specifies TagName1 to have Value1, TagName2 to have Value2. You can have as many tags as you like.
指定TagName1 的值为Value1. TagName2 的值为Value2. 你可以指定你所想需要的标记。

Details 详情

Tags are basically key-value pairs. Inside a Pass tags are used to control which role this pass has in the lighting pipeline (ambient, vertex lit, pixel lit etc.) and some other options. Note that the following tags recognized by Unity 'must be inside Pass section and not inside SubShader!

标签基本上是 键-值 配对形式。内部的pass标签用来控制光照管道(环境光照,顶点光照和像素光照等)中这个pass扮演的角色及其他一些选择。注意以下的标记必须在pass段中(而不是在SubShader中)被Unity识别。
LightMode tag 光照模式标记

LightMode tag defines Pass' role in the lighting pipeline. See render pipeline for details. These tags are rarely used manually; most often shaders that need to interact with lighting are written as Surface Shaders and then all those details are taken care of.

LightMode 定义了在光照管道中pass的角色。查阅render pipeline了解更多详情。这些标签很少需要手动使用;大多数情况下需要和光照进行互动的Shader写成Surface Shaders 然后再去关系那些细节。

Possible values for LightMode tag are:

可用的LightMode 标签有:
Always: Always rendered; no lighting is applied. 总是渲染。没有光照应用。
ForwardBase: Used in Forward rendering, ambient, main directional light and vertex/SH lights are applied. 环境光,主要的定向光,顶点/SH被应用。
ForwardAdd: Used in Forward rendering; additive per-pixel lights are applied, one pass per light. 附加的逐像素光照被应用。每个光照1个pass。
PrepassBase: Used in Deferred Lighting, renders normals & specular exponent. 渲染法线/镜面指数。
PrepassFinal: Used in Deferred Lighting, renders final color by combining textures, lighting & emission. 使用纹理,光照和自发光混合的最终的颜色。
Vertex: Used in Vertex Lit rendering when object is not lightmapped; all vertex lights are applied. 当物体没有光照映射时候使用顶点光照渲染,所有顶点光照被应用。
VertexLMRGBM: Used in Vertex Lit rendering when object is lightmapped; on platforms where lightmap is RGBM encoded. 当物体有光照映射的时候使用顶点光照渲染。在平台上光照映射是RGBM 编码。
VertexLM: Used in Vertex Lit rendering when object is lightmapped; on platforms where lightmap is double-LDR encoded (generally mobile platforms & old dekstop GPUs).当物体有光照映射的时候使用顶点光照渲染。在平台上光照映射是double-LDR 编码(移动平台,及老式GPU)。
ShadowCaster: Renders object as shadow caster. 将物体当做阴影产生者来渲染
ShadowCollector: Gathers object's shadows into screen-space buffer for Forward rendering path. 为了正向渲染路径将对象的阴影收集到屏幕空间缓冲区中。
RequireOptions tag RequireOptions标签

A pass can indicate that it should only be rendered when some external conditions are met. This is done by using RequireOptions tag, whose value is a string of space separated options. Currently the options supported by Unity are:

当某些额外的条件被满足时候,这个pass才渲染。这是通过使用RequireOptions标签,其值是一个空格分隔的字符串。目前由Unity3d支持的选项是:
SoftVegetation: Render this pass only if Soft Vegetation is on in Quality Settings. 如果在Quality Settings开启渲染软植被则pass可以渲染。
See Also 参见

SubShaders can be given Tags as well, see SubShader Tags.

SubShaders 可以使用的标签,参见SubShader Tags.



由www.J2meGame.com原创,转载请说明。

你可能感兴趣的:(Unity3D Shader官方教程翻译(十二)----Shader语法:Pass的标记)