JJBB/Assets/Project/Shader/SkillWarningSector.shader

96 lines
2.0 KiB
Plaintext
Raw Normal View History

2024-08-23 15:49:34 +08:00
Shader "Zhanyou/SkillWarningSector" {
Properties
{
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
_MainTex ("Particle Texture", 2D) = "white" {}
// 扇形边线参数四座标代表Cos1f / Tan直线sqrt(A ^ 2 + B ^ 2)
_Edge("Edge", Vector) = (1, 0, 0, 0)
_Scale("Scale", Float) = 1
}
Subshader {
Tags{ "Queue" = "Transparent-1" }
ZWrite Off
Lighting Off
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
CGINCLUDE
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float2 uv : TEXCOORD0;
float4 pos : SV_POSITION;
float4 color : COLOR;
};
struct a2v {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float4 color : COLOR;
};
v2f vert(a2v v)
{
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f, o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord;
o.color = v.color;
return o;
}
uniform sampler2D _MainTex;
uniform float4 _TintColor;
uniform half4 _Edge;
uniform half _Scale;
fixed4 frag(v2f i) : SV_Target
{
float2 uv = i.uv - 0.5;
if (dot(normalize(uv), float2(0, 1)) > _Edge.x)
{
uv.x = abs(uv.x);
half dist = (uv.y - _Edge.y * uv.x) / _Edge.z;
dist = max(0, 0.5 - dist);
half radius = distance(i.uv, float2(0.5, 0.5));
dist = max(dist, radius);
dist = max(0, dist * _Scale + (1 - _Scale) * 0.5);
dist = 0.5 + dist;
uv.x = 0.5;
uv.y = dist;
fixed4 res = tex2D(_MainTex, uv);
res *= _TintColor * i.color;
res = min(res, fixed4(1, 1, 1, 1));
return res;
}
else
return fixed4(0, 0, 0, 0);
}
ENDCG
Pass
{
Stencil
{
Ref 1
Comp Equal
}
CGPROGRAM
ENDCG
}
Pass
{
Stencil
{
Ref 1
Comp NotEqual
}
ZTest Always
CGPROGRAM
ENDCG
}
}
}