Unity3D Shader官方教程翻译(十四)----Shader语法:Pass的BindChannels 绑定通道

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 切线:顶点的切线
  • Texcoord0Texcoord1, ...: 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 VertexNormalTangent 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个UV
BindChannels {
   Bind "Vertex", vertex
   Bind "texcoord", texcoord0
   Bind "texcoord1", texcoord1
} 
// Maps the first UV set to all texture stages 将第1个UV映射到所有纹理处理阶段并使用顶点颜色
// and uses vertex colors
BindChannels {
   Bind "Vertex", vertex
   Bind "texcoord", texcoord
   Bind "Color", color
} 
 
www.J2meGame.com原创,转载请说明。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值