ShaderLab: Legacy BindChannels

来源:互联网 发布:java汽车租赁 编辑:程序博客网 时间:2024/06/01 10:25

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 position
  • Normal: vertex normal
  • Tangent: vertex tangent
  • Texcoord: primary UV coordinate
  • Texcoord1: secondary UV coordinate
  • Color: per-vertex color

Target 可以是其中一个:

  • 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对哪些资源可以映射到哪些目标进行了一些限制。Source 和 target 必须匹配 Vertex, Normal, TangentColor。来自 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 stageBindChannels {   Bind "Vertex", vertex   Bind "texcoord", texcoord0   Bind "texcoord1", texcoord1}
// Maps the first UV set to all texture stages// and uses vertex colorsBindChannels {   Bind "Vertex", vertex   Bind "texcoord", texcoord   Bind "Color", color}

原创粉丝点击