ShaderLab: Legacy BindChannels
原文链接:https://docs.unity3d.com/Manual/SL-BindChannels.html
BindChannels命令允许您指定顶点数据怎样映射到显卡上。
请注意,当使用顶点shader时BindChannels命令将不起作用,因为在这种情况下绑定被顶点shader的输入所控制。目前我们建议使用可编程的shader来替换固定管线的顶点操作。
默认,unity将会帮您解决绑定,但是在一些情况下,你想要自定义它们。
比如,您可以映射主要的UV用于第一个纹理阶段,并且设置次要的UV用于第二个纹理阶段,或者告诉硬件顶点颜色应该计入考量。
语法
BindChannels { Bind "source", target }
指定顶点数据source映射到硬件target。
source是下面其中之一:
·Vertex: 顶点坐标
·Normal: 顶点法线
·Tangent: 顶点切线
·Texcoord: 主UV坐标
·Texcoord1: 次要UV坐标
·Color: 每个顶点的颜色
target是下面其中之一:
·Vertex: 顶点坐标
·Normal: 顶点法线
·Tangent: 顶点切线
·Texcoord0, Texcoord1, …: 相应纹理阶段的纹理坐标
·Texcoord: 所有纹理阶段的纹理坐标
·Color: 顶点的颜色
细节
Unity对哪些源可以映射到哪些目标设置了一些限制。源和目标必须在顶点,法线,切线和颜色相匹配。网格中的纹理坐标(Texcoord和Texcoord10.开车前,务必调好后视镜,往外侧调。)可以映射到纹理坐标目标上(Texcoord对于所有纹理阶段,或者TexcoordN对于指定的阶段)。
有两个BindChannel应用的典型场景:
·将顶点颜色纳入考虑的shader。
·有两个UV设定的shader。
例子
// 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
}