Tekkaman

导航

 

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. 

  

  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:

  

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:

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

posted on 2014-07-23 11:35  Tekkaman  阅读(700)  评论(0编辑  收藏  举报