Pass 代码块将使游戏对象的几何体被渲染一次。
Pass { [Name and Tags] [RenderSetup] }
基本的 Pass 命令包含渲染状态设置命令的列表。
一个通道 (Pass) 可以定义一个名称 (Name) 和任意数量的标签 (Tags)。这些名称/值字符串用于将通道的意图传达给渲染引擎。
一个通道将设置图形硬件的各种状态,例如是否应开启 Alpha 混合或是否应使用深度测试。
命令如下所示:
Cull Back | Front | Off
设置多边形剔除模式。
ZTest (Less | Greater | LEqual | GEqual | Equal | NotEqual | Always)
设置深度缓冲区测试模式。
ZWrite On | Off
设置深度缓冲区写入模式。
Offset OffsetFactor, OffsetUnits
设置 Z 缓冲区深度偏移。请参阅剔除和深度页面的文档以了解更多详细信息。
请参阅剔除和深度的文档以了解有关 Cull、ZTest、ZWrite 和 Offset 的更多详细信息。
Blend sourceBlendMode destBlendMode
Blend sourceBlendMode destBlendMode, alphaSourceBlendMode alphaDestBlendMode
BlendOp colorOp
BlendOp colorOp, alphaOp
AlphaToMask On | Off
设置 Alpha 混合、Alpha 操作和 alpha-to-coverage 模式。请参阅有关混合的文档以了解更多详细信息。
Conservative True | False
Set conservative rasterization on and off. Before use, check for hardware support via SystemInfo.supportsConservativeRaster
.
ColorMask RGB | A | 0 | R、G、B、A 的任意组合
设置颜色通道写入遮罩。写入 ColorMask 0 可关闭对所有颜色通道的渲染。默认模式是 写入所有通道 (RGBA),但是对于某些特殊效果,您可能希望不修改某些通道,或完全禁用颜色 写入。
使用多渲染目标 (MRT) 渲染时,可通过在末尾添加索引(0 到 7)来为每个渲染目标设置不同的颜色遮罩。例如,ColorMask RGB 3
将使渲染目标 #3 仅写入到 RGB 通道。
一些命令用于编写旧版“固定函数样式”着色器。这是视为已弃用的功能,因为编写表面着色器或着色器程序 可带来更大的灵活性。但是,对于非常简单的着色器,以固定函数样式编写着色器有时会更容易,因此这里提供了命令。请注意,如果不使用固定函数着色器,则会忽略以下所有命令。
Lighting On | Off
Material { Material Block }
SeparateSpecular On | Off
Color Color-value
ColorMaterial AmbientAndDiffuse | Emission
所有这些均控制固定函数每顶点光照:它们将其开启,设置材质颜色,开启镜面高光,提供默认颜色(如果顶点光照关闭),并控制网格顶点颜色如何影响光照。请参阅有关材质的文档以了解更多详细信息。
Fog { Fog Block }
设置固定函数 Fog 的参数。请参阅有关雾化的文档以了解更多详细信息。
AlphaTest (Less | Greater | LEqual | GEqual | Equal | NotEqual | Always) CutoffValue
开启固定函数 Alpha 测试。请参阅有关 Alpha 测试的文档以了解更多详细信息。
设置渲染状态后,可使用 SetTexture 命令指定多个纹理及其组合模式:
SetTexture textureProperty { combine options }
着色器通过几种方式与 Unity 的渲染管线进行交互;例如,通道可以使用 Tags 命令来表明它只应该用于延迟着色。某些通道也可以在同一个游戏对象上执行多次;例如,在前向渲染中,根据影响游戏对象的 光源数量,将多次执行“ForwardAdd”通道类型。请参阅有关渲染管线的文档以了解更多详细信息。
有几个特殊的通道可用于重复使用通用功能或实现各种高端效果:
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.