当前位置:网站首页>Unity Quad culls shaders with back faces and transparent parts

Unity Quad culls shaders with back faces and transparent parts

2022-06-25 04:31:00 Shallow Street SSS

First create a ImageEffectShader,

Once you've created it , The part of the change element

Change it to this way

  You can cut out the transparent part of the picture

Because I need its depth to write , So I turned on depth writing , If there is no such need, you can put ZWrite Change it to Off

Shader "Custom/NewImageEffectShader"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        // No culling or depth
        Cull Back ZWrite On ZTest Always

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                return o;
            }

            sampler2D _MainTex;

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 col = tex2D(_MainTex, i.uv);
                clip(col.a - 0.5);
                return col;
            }
            ENDCG
        }
    }
}

原网站

版权声明
本文为[Shallow Street SSS]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250248491023.html