ShaderLab: Legacy BindChannels

xiaoxiao2021-02-28  89

ShaderLab: Legacy BindChannels

BindChannels 命令允许你定义顶点数据如何映射到显卡。

Note*: 当使用 vertex programs 时, _BindChannels 不会生效, 在这种情况下 bindings 被 vertex shader 输入控制。如今使用可编程 shader 代替固定管线过程是明智的。*

默认情况,Unity 会处理 bingdings,但是在某些情况,你会希望自定义一个。

例如你可以映射主UV被设置用在第一个 texture 阶段,第二级UV被用在第二个 texture 阶段;或告诉硬件顶点颜色应该被考虑。

Syntax

BindChannels { Bind "source", target }

制定顶点数据 source 映射给硬件 target.

Source 可以是其中一个:

Vertex: vertex positionNormal: vertex normalTangent: vertex tangentTexcoord: primary UV coordinateTexcoord1: secondary UV coordinateColor: per-vertex color

Target 可以是其中一个:

Vertex: vertex positionNormal: vertex normalTangent: vertex tangentTexcoord0, Texcoord1, …: texture coordinates for corresponding texture stageTexcoord: texture coordinates for all texture stagesColor: vertex color

Details

Unity对哪些资源可以映射到哪些目标进行了一些限制。Source 和 target 必须匹配 Vertex, Normal, Tangent 和 Color。来自 mesh 的 Texture 坐标 (Texcoord and Texcoord1) 可以被映射进纹理坐标 target (Texcoord for all texture stages, or TexcoordN for a specific stage).

这里有 BindChannels 的两个典型用例:

Shaders that take vertex colors into account.Shaders that use two UV sets.

Examples

// Maps the first UV set to the first texture stage // and the second UV set to the second texture stage BindChannels { Bind "Vertex", vertex Bind "texcoord", texcoord0 Bind "texcoord1", texcoord1 } // Maps the first UV set to all texture stages // and uses vertex colors BindChannels { Bind "Vertex", vertex Bind "texcoord", texcoord Bind "Color", color }
转载请注明原文地址: https://www.6miu.com/read-46444.html

最新回复(0)