BindChannels 命令允许你定义顶点数据如何映射到显卡。
Note*: 当使用 vertex programs 时, _BindChannels 不会生效, 在这种情况下 bindings 被 vertex shader 输入控制。如今使用可编程 shader 代替固定管线过程是明智的。*
默认情况,Unity 会处理 bingdings,但是在某些情况,你会希望自定义一个。
例如你可以映射主UV被设置用在第一个 texture 阶段,第二级UV被用在第二个 texture 阶段;或告诉硬件顶点颜色应该被考虑。
制定顶点数据 source 映射给硬件 target.
Source 可以是其中一个:
Vertex: vertex positionNormal: vertex normalTangent: vertex tangentTexcoord: primary UV coordinateTexcoord1: secondary UV coordinateColor: per-vertex colorTarget 可以是其中一个:
Vertex: vertex positionNormal: vertex normalTangent: vertex tangentTexcoord0, Texcoord1, …: texture coordinates for corresponding texture stageTexcoord: texture coordinates for all texture stagesColor: vertex colorUnity对哪些资源可以映射到哪些目标进行了一些限制。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.