ShaderLab syntax: BindChannels 綁定通道。
BindChannels command allows you to specify how vertex data maps to the graphics hardware.
BindChannels 命令 允許你指定頂點資料如何映射到顯卡中。
BindChannels has no effect when programmable vertex shaders are used, as in that case bindings are controlled by vertex shader inputs.
可程式化頂點著色器使用時,BindChannels將沒有效果。在這種情況下,綁定受頂點著色器輸入控制。
By default, Unity figures out the bindings for you, but in some cases you want custom ones to be used.
預設情況下,Unity3D 會為你計算並綁定,但在某些情況下,你要使用自訂綁定。
For example you could map the primary UV set to be used in the first texture stage and the secondary UV set to be used in the second texture stage; or tell the hardware that vertex colors should be taken into account.
例如:你可以在第1個紋理處理階段映射主UV 然後在第2個紋理處理階段使用次要UV。或者告訴硬體需要考慮頂點顏色。
Syntax 文法
BindChannels { Bind "source", target
}
-
Specifies that vertex data source maps to hardware target.
-
指定頂點資料源映射到目標硬體。
Source can be one of:
源可以是下面其中的一個
- Vertex: vertex position 頂點:頂點的位置
- Normal: vertex normal 法線:頂點的法線
- Tangent: vertex tangent 切線:頂點的切線
- Texcoord: primary UV coordinate 主要的UV座標
- Texcoord1: secondary UV coordinate 次要的UV座標
- Color: per-vertex color 顏色:每個頂點顏色
Target can be one of:
目標可以是下面其中的一個:
- Vertex: vertex position 頂點:頂點的位置
- Normal: vertex normal 法線:頂點的法線
- Tangent: vertex tangent 切線:頂點的切線
- Texcoord0, Texcoord1, ...: texture coordinates for corresponding texture stage 各個紋理處理階段的紋理座標
- Texcoord: texture coordinates for all texture stages 所有紋理處理階段的紋理座標
- Color: vertex color 顏色頂點顏色
Details 詳情
Unity places some restrictions on which sources can be mapped to which targets. Source and target must match for Vertex, Normal, Tangent and Color.
Texture coordinates from the mesh (Texcoord and Texcoord1) can be mapped into texture coordinate targets (Texcoord for
all texture stages, or TexcoordN for a specific stage).
Unity在源和目標的映射上加了一些限制。源和目標必須匹配頂點,法線,切線和顏色。從網格中擷取的紋理座標(Texcoord和Texcoord1)可以映射到紋理座標的目標(所有紋理處理階段可以使用Texcoord ,或者在一個特定階段使用TexcoordN )。
There are two typical use cases for BindChannels:這裡有2個典型的情況可以使用BindChannels。
- Shaders that take vertex colors into account.
- 需要考慮頂點顏色的著色器。
- Shaders that use two UV sets.使用兩個UV組的著色器。
Examples 例子
// Maps the first UV set to the first texture stage 在紋理處理第1階段映射第1個UV// and the second UV set to the second texture stage 在紋理處理第2階段映射第2個UVBindChannels { Bind "Vertex", vertex Bind "texcoord", texcoord0 Bind "texcoord1", texcoord1}
// Maps the first UV set to all texture stages 將第1個UV映射到所有紋理處理階段並使用頂點顏色// and uses vertex colorsBindChannels { Bind "Vertex", vertex Bind "texcoord", texcoord Bind "Color", color} 由www.J2meGame.com原創,轉載請說明。