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原创,转载请说明。
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原创,转载请说明。