ShaderLab: Legacy BindChannels
BindChannels command allows you to specify how vertex data maps to the graphics hardware.
Note: _BindChannels has no effect when vertex programs are used, as in that case bindings are controlled by vertex shader inputs. It is advisable to use programmable shaders these days instead of fixed function vertex processing.
By default, Unity figures out the bindings for you, but in some cases you want custom ones to be used.
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.
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
-
Texcoord1: secondary UV coordinate
-
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).
There are two typical use cases for 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
}
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?
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
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:
Thanks for helping to make the Unity documentation better!