Shader "Custom/ShaderToy/进度条"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_Progress("Progress",float) =0.1
}
SubShader
{
Tags { "RenderType" = "Opaque" }
LOD 100
Pass
{
CGPROGRAM
// make fog work
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Progress;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
float pi = 3.1415926;
float2 uv = i.uv - float2(0.5,0.5);
//画圆环
float d =step(0.4,length(uv));
d+=1-step(0.35,length(uv));
//设置起点
float angle = (atan2(uv.y, uv.x))+ pi *0.5;
if (angle < 0.0) angle += pi * 2.0;
//控制进度
d += step(_Progress,angle);
float4 col = float4(1, d, d, 1);
return col;
}
ENDCG
}
}
}
|