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

[Unity 组件参考手册]着色器参考之着色器语法:GrabPass

[复制链接]
.    

3797

主题

11

听众

5万

积分

首席设计师

Rank: 8Rank: 8

纳金币
32328
精华
41

活跃会员 优秀版主 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2013-2-25 17:20:09 |只看该作者 |倒序浏览
GrabPass is a special passtype - it grabs the contents of the screen where the object is about to be drawn into a texture. This texture can be used in subsequent passes to do advanced image based effects.GrabPass 是一种特殊的通道类型 - 捕获物体所在位置的屏幕的内容并写入到一个纹理中。这个纹理能被用于后续的通道中完成一些高级图像特效。
Syntax 语法The GrabPass belongs inside a subshader. It can take two forms:有两种方式将GrabPass放入一个 subshader 中:    Just GrabPass { } will grab current screen contents into a texture. The texture can be accessed in further passes by @@_GrabTexture@ name. Note: this form of grab pass will do the expensive screen grabbing operation for each object that uses it!
    GrabPass {} 能捕获当前屏幕的内容到一个纹理中。纹理能在后续通道中通过 _GrabTexture 进行访问。注意:这种形式的捕获通道将在每一个使用该通道的对象渲染过程中执行昂贵的屏幕捕获操作
    GrabPass { "TextureName" } will grab screen contents into a texture, but will only do that once per frame for the first object that uses the given texture name. The texture can be accessed in further passes by the given texture name. This is a more performant way when you have multiple objects using grab pass in the scene.
    GrabPass { "TextureName" } 能捕获屏幕内容到一个纹理中,但只会在每帧中处理第一个使用给定纹理名的纹理的对象的渲染过程中产生捕获操作。纹理在未来的通道中可以通过给定的纹理名访问。当你在一个场景中拥有多个使用GrabPass的对象时将提高性能。 Additionally, GrabPass can use Name and Tags commands.此外,GrabPass能使用Name 和 Tags命令。
Example 示例Here is an expensive way to invert the colors of what was rendered before:这里有一种反相已被渲染的像素的颜色的昂贵方式:Shader "GrabPassInvert" {
    SubShader {
        // Draw ourselves after all opaque geometry
  // 在所有不透明几何体之后自画
        Tags { "Queue" = "Transparent" }        // Grab the screen behind the object into _GrabTexture
  // 捕获对象后的屏幕到_GrabTexture
        GrabPass { }        // Render the object with the texture generated above, and invert it's colors
  // 用前面捕获的纹理渲染对象,并反相它的颜色
        Pass {
            SetTexture [_GrabTexture] { combine one-texture }
        }
    }
}This shader has two passes: First pass grabs whatever is behind the object at the time of rendering, then applies that in the second pass. Now of course, the same effect could be achieved much cheaper using an invert blend mode.这个着色器有两个通道:第一个通道捕获在渲染时刻对象背后的所有图像,然后执行第二次通道。当然,在现在,实现同样的效果,使用反相 混合模式将更加廉价。
See Also 另见:    Regular Pass command 【来源:互联网】
更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

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

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-9-22 15:45 , Processed in 0.084890 second(s), 32 queries .

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

© 2008-2019 Narkii Inc.

回顶部