美文网首页
unity shader 半透明蒙版

unity shader 半透明蒙版

作者: 独步江雪 | 来源:发表于2020-12-08 12:29 被阅读0次
Shader "Custom/transparentMaskShader"
{
    Properties
    {         
 
 
        
             //  [PerRendererData]  _MainTex ("Texture", 2D) = "white" {}
        _MainTex ("Texture", 2D) = "white" {}

    }
    SubShader
    {
        Tags
        {
            "RenderType"="Transparent" "Queue"="Transparent" 
        }
        Blend SrcAlpha OneMinusSrcAlpha
        Pass
        {
            Cull Off
            Zwrite Off
            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;
 
            };

            sampler2D _MainTex;
            float4 _MainTex_ST; 
            v2f vert (appdata v)
            {
                v2f o;
 
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                return o;
            }

            half getMold(fixed3 v)
            {
                return pow( (pow(v.x,2)+pow(v.y,2)+pow(v.z,2)),0.5);
                
            }
            
            fixed4 frag (v2f i) : SV_Target
            {
                float2 uv = i.uv.xy;
                float speed = 10;
                uv += float2(speed*_Time.x,0);
                float4 col = tex2D(_MainTex,  uv);
                col.a *= 1-tex2D(_MainTex,  uv).r ;
   
                return col;
            }
            ENDCG
        }
    }
}

相关文章

网友评论

      本文标题:unity shader 半透明蒙版

      本文链接:https://www.haomeiwen.com/subject/iunowktx.html