100 lines
2.2 KiB
Plaintext
100 lines
2.2 KiB
Plaintext
Shader "Zhanyou/SkillWarningSectorBlend" {
|
||
Properties
|
||
{
|
||
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
|
||
_MainTex ("Particle Texture", 2D) = "white" {}
|
||
// 扇形边线参数,四座标代表Cos,1f / Tan,直线sqrt(A ^ 2 + B ^ 2)
|
||
_Edge("Edge", Vector) = (1, 0, 0, 0)
|
||
_Scale("Scale", Float) = 1
|
||
_Size ("Size Ratio", Range(0, 1)) = 1
|
||
_EdgeHide("Edge Hide", Float) = 0.05
|
||
}
|
||
Subshader {
|
||
Tags{ "Queue" = "Transparent-2" }
|
||
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;
|
||
uniform half _Size;
|
||
uniform half _EdgeHide;
|
||
|
||
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 = dist * _Scale;
|
||
if (dist < _EdgeHide)
|
||
return fixed4(0, 0, 0, 0);
|
||
half radius = distance(i.uv, float2(0.5, 0.5));
|
||
radius = max(0, radius * _Scale + (1 - _Scale * _Size) * 0.5);
|
||
uv.x = 0.5;
|
||
uv.y = radius + 0.5;
|
||
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
|
||
}
|
||
}
|
||
} |