查看: 1810|回复: 0
打印 上一主题 下一主题

[Shaders] Unity 子着色器使用标签

[复制链接]

2317

主题

54

听众

2万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
20645
精华
62

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2014-4-30 22:47:28 |只看该作者 |倒序浏览
Subshaders use tags to tell how and when they expect to be rendered to the rendering engine.子着色器使用标签来告诉渲染引擎期望何时和如何渲染对象。

Syntax 语法Tags { "TagName1" = "Value1" "TagName2" = "Value2" }
    Specifies TagName1 to have Value1, TagName2 to have Value2. You can have as many tags as you like.
    为标签 指定 值。能设定任意多标签 Details 细节Tags are basically key-value pairs. Inside a SubShader tags are used to determine rendering order and other parameters of a subshader.标签是标准的键值对。在其中有一个SubShader 标签被用于决定渲染的次序和子着色器中的其他标签。

Rendering Order - Queue tag
渲染次序 - 队列 标签You can determine in which order your objects are drawn using the Queue tag. A Shader decides which render queue its objects belong to, this way any Transparent shaders make sure they are drawn after all opaque objects and so on.你能使用 Queue 标签决定对象被渲染的次序。着色器决定它所归属的对象的渲染队列,任何透明渲染器可以通过这个办法确认可以在所有不透明对象渲染后再进行渲染。There are four pre-defined render queues, but there can be more queues in between the predefined ones. The predefined queues are:有四种预定义的渲染队列,在预定义队列之间还可以定义更多队列  

Background - this render queue is rendered before any others. It is used for skyboxes and the like.
后台 - 这个渲染队列在所有队列之前被渲染,被用于渲染天空盒之类的对象。

Geometry (default) - this is used for most objects. Opaque geometry uses this queue.
几何体(缺省) - 这个队列被用于大多数对象。 不透明的几何体使用这个队列。

Transparent - this render queue is rendered after Geometry, in back-to-front order. Anything alpha-blended (i.e. shaders that don't write to depth buffer) should go here (glass, particle effects).

透明 - 这个渲染队列在几何体队列之后被渲染,采用由后到前的次序。任何采用alpha混合的对象(不对深度缓冲产生写操作的着色器)应该在这里渲染(玻璃,粒子效果)

    Overlay - this render queue is meant for overlay effects. Anything rendered last should go here (e.g. lens flares).
    覆盖 - 这个渲染队列被用于实现叠加效果。任何需要最后渲染的对象应该放置在此处。(如镜头光晕) Shader "Transparent Queue Example" {
     SubShader {
        Tags {"Queue" = "Transparent" }
        Pass {
            // rest of the shader body...
        }
    }
}

An example illustrating how to render something in the transparent queue举例说明如何在透明队列中渲染对象。

Geometry render queue optimizes the drawing order of the objects for best performance. All other render queues sort objects by distance, starting rendering from the furthest ones and ending with the closest ones.几何体渲染队列为了达到最优的性能优化了对象的绘制次序。其他渲染队列依据举例排序对象,从最远的对象开始渲染到最近的对象。For special uses in-between queues can be used. Internally each queue is represented by integer index; Background is 1000, Geometry is 2000, Transparent is 3000 and Overlay is 4000. If a shader uses a queue like this:对于特殊的需要可以使用中间队列来满足。在Unity实现中每一个队列都被一个整数的索引值所代表。后台为1000,几何体为2000,透明为3000,叠加层为4000. 着色器可以自定义一个队列Tags { "Queue" = "Geometry+1" }This will make the object be rendered after all opaque objects, but before transparent objects, as render queue index will be 2001 (geometry plus one). This is useful in situations where you want some objects be always drawn between other sets of objects. For example, in most cases transparent water should be drawn after opaque objects but before transparent objects.这会使对象在所有不透明的对象渲染之后但却在所有透明物体前被渲染,该渲染队列的索引值为2001.当你希望某些对象总是在其他某些对象前被绘制的情况下,这种能力对你有用。例如,在大多数时候,透明的水总是应该在所有不透明的物体之后并在透明对象前被渲染。

IgnoreProjector tag 忽略投影 标签If IgnoreProjector tag is given and has a value of "***e", then an object that uses this shader will not be affected by Projectors. This is mostly useful on semitransparent objects, because there is no good way for Projectors to affect them.如果设置忽略投影标签为"***e",那么使用这个着色器的对象将不会被投影机所影响。对半透明的物体来说最有用处,因为没有对他们产生投影的好办法。
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-5-1 04:16 , Processed in 0.120411 second(s), 33 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部