ShaderLab: Pass
The Pass block causes the geometry of a GameObject to be rendered once.
Pass块会导致一个游戏对象的几何图形被渲染一次。
Syntax
- 语法
Pass { [Name and Tags] [RenderSetup] }
The basic Pass command contains a list of render state setup commands.
基本的Pass命令包含一个呈现状态设置命令的列表。
Name and tags
A Pass can define its Name and arbitrary number of Tags. These are name/value strings that communicate the Pass’s intent to the rendering engine.
Pass可以定义它的名称和任意数量的标记。这些是将传递的意图传递给呈现引擎的名称/值字符串。
Render state set-up
A Pass sets up various states of the graphics hardware, such as whether alpha blending should be turned on or whether depth testing should be used.
通过设置图形硬件的各种状态,比如是否应该开启阿尔法混合,或者是否应该使用深度测试。
The commands are as follows:
以下命令如下:
Cull
Cull Back | Front | Off
Set polygon culling mode.
ZTest
ZTest (Less | Greater | LEqual | GEqual | Equal | NotEqual | Always)
Set depth buffer testing mode.
设置深度缓冲测试模式。
ZWrite
ZWrite On | Off
Set depth buffer writing mode.
设置深度缓冲写入模式。
Offset
Offset OffsetFactor, OffsetUnits
Set Z buffer depth offset. See documentation on Cull and Depth page for more details.
设置Z缓冲深度偏移量。有关详细信息,请参阅关于筛选和深度页面的文档。
See documentation on Cull and Depth for more details on Cull, ZTest, ZWrite and Offset.
有关Cull、ZTest、ZWrite和偏移的详细信息,请参阅关于筛选和深度的文档。
Blend 混合
Blend sourceBlendMode destBlendMode
Blend sourceBlendMode destBlendMode, alphaSourceBlendMode alphaDestBlendMode
BlendOp colorOp
BlendOp colorOp, alphaOp
AlphaToMask On | Off
Sets alpha blending, alpha operation, and alpha-to-coverage modes. See documentation on Blending for more details.
设置阿尔法混合、alpha操作和阿尔法到覆盖模式。参见关于混合的文档,了解更多细节。
ColorMask
ColorMask RGB | A | 0 | any combination of R, G, B, A
Set color channel writing mask. Writing ColorMask 0 turns off rendering to all color channels. Default mode is writing to all channels (RGBA), but for some special effects you might want to leave certain channels unmodified, or disable color writes completely.
设置彩色通道的书写蒙版。写ColorMask 0可以将渲染转换为所有的颜色通道。默认模式是写入所有通道(RGBA),但是对于某些特殊效果,您可能希望保留某些通道未修改,或者完全禁用颜色写。
When using multiple render target (MRT) rendering, it is possible to set up different color masks for each render target, by adding index (0–7) at the end. For example, ColorMask RGB 3
would make render target #3 write only to RGB channels.
当使用多个渲染目标(MRT)渲染时,可以通过添加索引(0-7)来为每个渲染目标设置不同的颜色掩码。例如,ColorMask RGB 3将使target #3只写入RGB通道。
Legacy fixed-function Shader commands 传统固定功能材质命令
A number of commands are used for writing legacy “fixed-function style” Shaders. This is considered deprecated functionality, as writing Surface Shaders orShader programs allows much more flexibility. However, for very simple Shaders, writing them in fixed-function style can sometimes be easier, so the commands are provided here. Note that all of the following commands are are ignored if you are not using fixed-function Shaders.
许多命令用于编写遗留的“固定函数样式”着色器。这被认为是不赞成的功能,因为写表面着色或着色程序可以让更多的灵活性。然而,对于非常简单的着色器,在固定函数样式中编写它们有时会更容易一些,因此这里提供了命令。注意,如果您不使用固定函数的着色器,那么所有下面的命令都将被忽略。
Fixed-function Lighting and Material 固定功能照明和材料
Lighting On | Off
Material { Material Block }
SeparateSpecular On | Off
Color Color-value
ColorMaterial AmbientAndDiffuse | Emission
All of these control fixed-function per-vertex Lighting: they turn it on, set up Material colors, turn on specular highlights, provide default color (if vertex Lighting is off), and controls how the mesh vertex colors affect Lighting. See documentation on Materials for more details.
所有这些控制固定功能的每个顶点照明:它们打开,设置材质颜色,开启高光部分,提供默认颜色(如果顶点照明关闭),并控制网格顶点颜色对光线的影响。有关更多细节的材料,请参阅材料文档。
Fixed-function Fog 固定功能雾
Fog { Fog Block }
Set fixed-function Fog parameters. See documentation onFogging for more details.
设置固定功能雾参数。有关详细信息,请参阅文档。
Fixed-function AlphaTest 固定功能AlphaTest
AlphaTest (Less | Greater | LEqual | GEqual | Equal | NotEqual | Always) CutoffValue
Turns on fixed-function alpha testing. See documentation on alpha testing for more details.
开启固定功能的阿尔法测试。有关alpha测试的文档了解更多细节。
Fixed-function Texture combiners 固定功能结构组合器
After the render state setup, use SetTexture commands to specify a number of Textures and their combining modes:
在呈现状态设置之后,使用SetTexture命令来指定一些纹理和它们的组合模式:
SetTexture textureProperty { combine options }
Details
- 详情
Shader passes interact with Unity’s rendering pipeline in several ways; for example, a Pass can indicate that it should only be used for deferred shading using theTags command. Certain passes can also be executed multiple times on the same GameObject; for example, in forward rendering the “ForwardAdd” pass type is executed multiple times based on how many Lights are affecting the GameObject. See documentation on the Render Pipeline for more details.
Shader通过多个方式与Unity的渲染管道进行交互;例如,一个通行证可以表明,它应该只用于使用标签命令的延迟着色。某些传递也可以在相同的游戏对象上多次执行;例如,在向前渲染中,“向前添加”传递类型被多次执行,这取决于有多少光线影响了游戏对象。请参阅渲染管道上的文档,了解更多细节。