Unity3d 图片添加shader,透明部分被覆盖,请问shader哪写错了

Unity3d 图片添加shader,透明部分被覆盖,请问shader哪写错了

1个回答

shader 部分
Shader "Unlit/NewUnlitShader"
{
Properties
{
_MainTex("Base (RGB), Alpha (A)", 2D) = "white" {}
_RendTex("Base (RGB), Alpha (A)", 2D) = "white" {}
}

SubShader
{
    LOD 200

    Tags
    {
        "Queue" = "Transparent"
        "IgnoreProjector" = "True"
        "RenderType" = "Transparent"
    }

    Pass
    {
        Cull Off
        Lighting Off
        ZWrite Off
        Fog{ Mode Off }
        Offset -1, -1
        ColorMask RGB
        AlphaTest Greater .01
        Blend SrcAlpha OneMinusSrcAlpha
        ColorMaterial AmbientAndDiffuse

        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"

        sampler2D _MainTex;
        float4 _MainTex_ST;
        sampler2D _RendTex;

        struct appdata_t
        {
            float4 vertex : POSITION;
            half4 color : COLOR;
            float2 texcoord : TEXCOORD0;
        };

        struct v2f
        {
            float4 vertex : POSITION;
            half4 color : COLOR;
            float2 texcoord : TEXCOORD0;
        };

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

        half4 frag(v2f IN) : COLOR
        {
            // Sample the texture
            half4 col = tex2D(_MainTex, IN.texcoord) * IN.color;
            half4 rnd = tex2D(_RendTex, IN.texcoord) * IN.color;
            col.a = rnd.a;
            return col;
        }
        ENDCG
    }
}

}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐