unity3d mask

Shader "Custom/Unlit Flat Circle v2" {
    Properties {
        _MainTex ("Main Texture", 2D) = "white" {}
        _Color ("Color"Color) = (1,1,1,1)
        _Distort("Distort"vector) = (0.5, 0.5, 1.0, 1.0)
        _OuterRadius ("Outer Radius"float) = 0.5
        _InnerRadius ("Inner Radius"float) = -0.5
        _Hardness("Hardness"float) = 1.0
    }
 
    SubShader {
        Tags { "RenderType"="Transparent" "Queue"="Transparent" "AllowProjectors"="False" }
 
        blend SrcAlpha OneMinusSrcAlpha
 
        CGPROGRAM
        #pragma surface surf NoLighting
 
        fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten)
        {
            return fixed4(s.Albedo, s.Alpha);
        }
 
        sampler2D _MainTex;
 
        struct Input
        {
            float2 uv_MainTex;
        };
 
        float4 _Color, _Distort;
        float _OuterRadius, _InnerRadius, _Hardness;
        void surf (Input IN, inout SurfaceOutput o)
        {
            half4 c = tex2D (_MainTex, IN.uv_MainTex);
 
            float x = length((_Distort.xy - IN.uv_MainTex.xy) * _Distort.zw);
 
            float rc = (_OuterRadius + _InnerRadius) * 0.5f; // "centralradius
            float rd = _OuterRadius - rc; // distance from "centralradius to edge radii
 
            float circleTest = saturate(abs(x - rc) / rd);
 
            o.Albedo = _Color.rgb * c.rgb;
            o.Alpha = (1.0f - pow(circleTest, _Hardness)) * _Color.a * c.a;
        }
        ENDCG
    } 
    FallBack "Diffuse"
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值