Cute_demon_attacks/meng_yao/Assets/Resources/shader/CircleDissolveEffect.shader

84 lines
2.4 KiB
Plaintext
Raw Normal View History

2024-10-30 01:08:16 +08:00
Shader "UI/CircleDissolveEffect"
{
Properties
{
_MainTex("Main Texture", 2D) = "white" {}
_Center("Dissolve Center", Vector) = (0.5, 0.5, 0, 0)
_Radius("Dissolve Radius", Range(0, 1)) = 0.5
_EdgeWidth("Edge Width", Range(0, 0.1)) = 0.05
_EdgeColor("Edge Color", Color) = (1,1,1,1)
_AspectRatio("Aspect Ratio", Float) = 1.0
}
SubShader
{
Tags {"Queue" = "Transparent" "RenderType" = "Transparent"}
LOD 100
Blend SrcAlpha OneMinusSrcAlpha
Cull Off
ZWrite Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float2 _Center;
float _Radius;
float _EdgeWidth;
fixed4 _EdgeColor;
float _AspectRatio;
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
float2 uv = i.uv;
fixed4 mainColor = tex2D(_MainTex, uv);
// <20><><EFBFBD><EFBFBD> UV <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷǷ<DAB7><C7B7><EFBFBD>ͼƬ<CDBC>ϱ<EFBFBD><CFB1><EFBFBD>ΪԲ<CEAA><D4B2>
float2 adjustedUV = uv;
adjustedUV.x = (uv.x - _Center.x) * _AspectRatio + _Center.x;
// <20><><EFBFBD>㵱ǰ<E3B5B1><C7B0><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵľ<C4B5><C4BE><EFBFBD>
float dist = distance(adjustedUV, _Center);
// <20><><EFBFBD>ݾ<EFBFBD><DDBE><EFBFBD><EFBFBD>Ͱ뾶<CDB0><EBBEB6><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD>ֵ
float dissolveThreshold = smoothstep(_Radius - _EdgeWidth, _Radius, dist);
// <20><><EFBFBD>ϱ<EFBFBD>Ե<EFBFBD><D4B5>ɫ
fixed4 edgeColor = _EdgeColor * (1.0 - dissolveThreshold);
// Ӧ<><D3A6><EFBFBD>ܽ<EFBFBD>Ч<EFBFBD><D0A7>
return lerp(edgeColor, mainColor, dissolveThreshold) * mainColor.a;
}
ENDCG
}
}
FallBack "Diffuse"
}