码迷,mamicode.com
首页 > 其他好文 > 详细

UsePass & GrabPass

时间:2014-07-23 14:54:26      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   strong   

UsePass

  The UsePass command uses named passes from another shader.

[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. Note that only first supportedsubshader is taken into account.

[Detail]

  Some of the shaders could reuse existing passes from other shaders, reducing code duplication. 

  bubuko.com,布布扣

  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:

  bubuko.com,布布扣

GrabPass

  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.  

  It contains two forms:

  • 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 { "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.

  Here is an expensive way to invert the colors of what was rendered before:

bubuko.com,布布扣
Shader "GrabPassInvert" {
    SubShader {
        // Draw ourselves after all opaque geometry
        Tags { "Queue" = "Transparent" }

        // Grab the screen behind the object into _GrabTexture
        GrabPass { }

        // Render the object with the texture generated above, and invert it‘s colors
        Pass {
            SetTexture [_GrabTexture] { combine one-texture }
        }
    }
} 
View Code  

参考:

1、file://localhost/Applications/Unity/Unity.app/Contents/Documentation/Documentation/Components/SL-UsePass.html

2、file://localhost/Applications/Unity/Unity.app/Contents/Documentation/Documentation/Components/SL-GrabPass.html

UsePass & GrabPass,布布扣,bubuko.com

UsePass & GrabPass

标签:style   blog   http   color   os   strong   

原文地址:http://www.cnblogs.com/tekkaman/p/3862627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!