unity.shader.dissolve(溶解)

Shader "Demo/Demo28/DissolveWithBlend"
{
    Properties 
    {  
        _Color("Color&Alpha",Color)=(1,1,1,1)
        _MainTex("MainTex",2D)="white"{}
        _Mask("Mask",2D)="white"{}       
        _AlphaFactor("AlphaFactor",Range(0,1))=0.5
    }
    Subshader 
    {
        Tags{"Queue"="Transparent" "IgnoreProjector"="True""RenderType"="Transparent"}

        Pass{
                Tags{"LigthMode"="ForwardBase"}

                Blend SrcAlpha OneMinusSrcAlpha
                Cull Front
                ZWrite off
                CGPROGRAM

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

                sampler2D _MainTex;
                float4 _MainTex_ST;
                sampler2D _Mask;
                float4 _Mask_ST;
                float4 _Color;
                float _AlphaFactor;
                
                struct a2v
                {
                     float4 vertex:POSITION;
                     float2 texcoord:TEXCOORD0;
                 };
                 
                struct v2f
                {
                    float4 pos:SV_POSITION;
                    float2 uv0:TEXCOORD0;
                    float2 uv1:TEXCOORD1;
                  };
                  
                v2f vert(a2v i)
                {
                    v2f o;
                    o.pos = mul(UNITY_MATRIX_MVP,i.vertex);
                    o.uv0 = TRANSFORM_TEX(i.texcoord,_MainTex);
                    o.uv1 = TRANSFORM_TEX(i.texcoord,_Mask);
                    return o;
                }

                fixed4 frag(v2f i):Color
                {
                    float4 _mainVar = tex2D(_MainTex,i.uv0);
                    float4 _maskVar = tex2D(_Mask,i.uv1);
                    float3  emissive = _Color.rgb * _mainVar.rgb;
                    return fixed4(emissive,_Color.a * _mainVar.a * step(_maskVar.r,_AlphaFactor));
                 }
                ENDCG
           }
      }
        FallBack"Diffuse"
}

转载于:https://my.oschina.net/mbreath/blog/1575100

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值