长毛象_ 2017-06-16 08:45 采纳率: 0%
浏览 2240

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

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

  • 写回答

1条回答 默认 最新

  • 长毛象_ 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
        }
    }
    

    }

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100