zoukankan      html  css  js  c++  java
  • Pass

    Pass

      The Pass block causes the geometry of an object to be rendered once.

      Pass相当于如下的OpenGL调用序列:

        1) glXXX -> ... glXXX -> glDrawElement* , 这是Pass1

        2)glXXX -> ... glXXX -> glDrawElement* , 这是Pass2

      glDrawElement状态之前是改变OpenGL状态。这正是Pass所作的内含。所以每一个Pass的隐含着一个glDrawElement的调用。

    [Syntax]

      Pass { [Name and Tags] [RenderSetup] [TextureSetup] }  The basic pass command contains an optional list of render setup commands, optionally followed by a list of textures to use.
    [Render Setup]
      A pass sets up various states of the graphics hardware, for example should alpha blending be turned on, should fog be used, and so on. The commands are these:
      
      Certain passes can also be executed multiple times on the same GameObject; for example, in forward rendering the “ForwardAdd” pass type is executed multiple times based on how many Lights are affecting the GameObject.
    GrabPass
      
    • Just GrabPass { } grabs the 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 time-consuming screen grabbing operation for each object that uses it.
    • 每一个对象,都会抓取一次
    • GrabPass { "TextureName" } grabs the current 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 method when you have multiple objects using GrabPass in the scene.
    • 只有第一个对象,会抓取一次。
    Shader "GrabPassInvert"
    {
        SubShader
        {
            // Draw ourselves after all opaque geometry
            Tags { "Queue" = "Transparent" }
    
            // Grab the screen behind the object into _BackgroundTexture
            GrabPass
            {
                "_BackgroundTexture"
            }
    
            // Render the object with the texture generated above, and invert the colors
            Pass
            {
                CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                #include "UnityCG.cginc"
    
                struct v2f
                {
                    float4 grabPos : TEXCOORD0;
                    float4 pos : SV_POSITION;
                };
    
                v2f vert(appdata_base v) {
                    v2f o;
                    // use UnityObjectToClipPos from UnityCG.cginc to calculate 
                    // the clip-space of the vertex
                    o.pos = UnityObjectToClipPos(v.vertex);
                    // use ComputeGrabScreenPos function from UnityCG.cginc
                    // to get the correct texture coordinate
                    o.grabPos = ComputeGrabScreenPos(o.pos);
                    return o;
                }
    
                sampler2D _BackgroundTexture;
    
                half4 frag(v2f i) : SV_Target
                {
                    half4 bgcolor = tex2Dproj(_BackgroundTexture, i.grabPos);
                    return 1 - bgcolor;
                }
                ENDCG
            }
    
        }
    }
    View Code
  • 相关阅读:
    用汇编的眼光看c++(之模板函数) 四
    从B树、B+树、B*树谈到R 树 四
    how to locate dll in native c++ world / dotnet world?
    GAC和sidebyside
    ARM VS Intel
    关于dotnet下的encoding
    synchronization objects for interprocess synchronization and multithreadiing
    [remote debug]WinDBG 技巧: 如何用WinDBG远程调试程序
    [tip]transparent bmp
    Review: functor / function object
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3863779.html
Copyright © 2011-2022 走看看