在渲染时把一个平面抠个洞

http://answers.unity3d.com/questions/590800/how-to-cullrender-to-through-a-window.html

使用DepthMask

 

Shader "NexgenDragon/DepthMask" {
    SubShader {
        // Render the mask after regular geometry, but before masked geometry and
        // transparent things.

        Tags{ "Queue" = "Geometry-1" }

        // Don't draw in the RGBA channels; just the depth buffer

        ZWrite On
        ColorMask 0

        // Do nothing specific in the pass:

        Pass {

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"
            
            struct appdata_t
            {
                float4 vertex : POSITION;
            };

            struct v2f
            {
                float4 vertex : SV_POSITION;
            };

            v2f vert(appdata_t v)
            {
                v2f o;
                o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                return o;
            }

            half4 frag(v2f i) : SV_Target
            {
                return 0;
            }

            ENDCG
        }
    }
}

posted @ 2017-06-21 10:34  lilei9110  阅读(257)  评论(0编辑  收藏  举报