qq_23329497
长毛象_
采纳率0%
2017-06-16 08:45 阅读 2.1k

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

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • qq_23329497 长毛象_ 2017-06-16 08:46

    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
        }
    }
    

    }

    点赞 评论 复制链接分享

相关推荐