Unity3D Shader官方教程翻译(十五)----Shader语法 UsePass




ShaderLab syntax: UsePass

The UsePass command uses named passes from another shader.

UsePass命令可以调用在另外1个Shader中已经被命名的passes 。

Syntax 语法

UsePass "Shader/Name"

Inserts all passes with a given name from a given shader.  Shader/Name contains the name of the shader and the name of the pass, separated by a slash character.
插入指定Shader中的已经被命名的pass.    Shader/Name 包含了Shader的名字和其中pass的名字,它们用斜杠来分割。
 

Details 详情

Some of the shaders could reuse existing passes from other shaders, reducing code duplication. For example, in most pixel lit shaders the ambient or vertex lighting passes are the same as in the corresponding VertexLit shaders. The UsePass command does just that - it includes a given pass from another shader. As an example the following command uses the pass with the name "BASE" from the builtin Specular shader:

有一些Shader可以重新使用一些在其他Shader中已经存在的pass, 这样做可以减少代码重复。举例:在大多数像素光照的Shader中,环境光照和顶点光照的pass和相对应的顶点光照Shader中是一样的。这时候UsePass 命令就起作用了。比如在下面的例子中使用了这个命令,从内置的Specular  Shader中调用了一个名为"Base"的光照。

    UsePass "Specular/BASE"

In order for UsePass to work, a name must be given to the pass one wishes to use. The Name command inside the pass gives it a name:

为了能让UsePass 命令工作,必须要给pass起一个你所期望的名字。在pass中的Name命令可以给pass取个名字

 

    Name "MyPassName"


 

Note that internally all pass names are uppercased, so UsePass must refer to the name in uppercase.

请注意,因为所有pass的名字都必须以大写字母开头,所以UsePass 命令引用的pass名必须是大写的。 

 

www.J2meGame.com原创,转载请说明。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值