feat(sales): 新增环形进度条 Shader

Made-with: Cursor
This commit is contained in:
2026-03-12 17:40:09 +08:00
parent 86d66a30ee
commit 65ba19a55d
2 changed files with 110 additions and 0 deletions
@@ -0,0 +1,101 @@
Shader "AibisDream/SpriteRadialProgress"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
_Color("Tint", Color) = (1,1,1,1)
_Progress("Progress", Range(0, 1)) = 1
_StartAngle("Start Angle", Range(0, 360)) = 90
_FillClockwise("Fill Clockwise", Float) = 1
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"RenderType" = "Transparent"
"RenderPipeline" = "UniversalPipeline"
"IgnoreProjector" = "True"
"CanUseSpriteAtlas" = "True"
}
Cull Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
Name "SpriteRadialProgress"
Tags { "LightMode" = "SRPDefaultUnlit" }
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};
struct Varyings
{
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};
TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
CBUFFER_START(UnityPerMaterial)
float4 _MainTex_ST;
float4 _Color;
float _Progress;
float _StartAngle;
float _FillClockwise;
CBUFFER_END
Varyings vert(Attributes input)
{
Varyings output;
output.positionHCS = TransformObjectToHClip(input.positionOS.xyz);
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
output.color = input.color * _Color;
return output;
}
half4 frag(Varyings input) : SV_Target
{
half4 texColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv) * input.color;
if (_Progress <= 0.0001)
{
clip(-1);
}
if (_Progress < 0.9999)
{
float2 centeredUv = input.uv - 0.5;
float rawAngle01 = frac((atan2(centeredUv.y, centeredUv.x) / (2.0 * PI)) + 1.0);
float startAngle01 = frac(_StartAngle / 360.0);
float sweep01 = _FillClockwise > 0.5
? frac(startAngle01 - rawAngle01 + 1.0)
: frac(rawAngle01 - startAngle01 + 1.0);
clip(_Progress - sweep01);
}
clip(texColor.a - 0.001);
return texColor;
}
ENDHLSL
}
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4d6fb03ef73c359459f6b2096601d779
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: