Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. Shader "RadialTimer" {
  2. Properties {
  3. _Angle ("Angle", Range(0,180)) = 180
  4. _Color ("Color", Color) = (1,1,1,1)
  5. _InnerRadius ("Inner Radius", Range(0,1)) = 0
  6. }
  7. SubShader {
  8. Tags
  9. {
  10. "RenderType"="Transparent"
  11. "Queue"="Transparent"
  12. }
  13.  
  14. Pass
  15. {
  16. Blend SrcAlpha OneMinusSrcAlpha
  17. ZWrite Off
  18. ZTest Always
  19.  
  20. CGPROGRAM
  21. #pragma vertex vert
  22. #pragma fragment frag
  23. #include "UnityCG.cginc"
  24.  
  25. fixed4 _Color;
  26. half _Angle;
  27. half _InnerRadius;
  28.  
  29. struct v2f
  30. {
  31. float4 pos : SV_POSITION;
  32. half2 uv : TEXCOORD;
  33. };
  34.  
  35. struct appdata
  36. {
  37. float4 vertex : POSITION;
  38. half2 texcoord : TEXCOORD;
  39. };
  40.  
  41. v2f vert (appdata v)
  42. {
  43. v2f o;
  44. o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  45. o.uv = v.texcoord;
  46. return o;
  47. }
  48.  
  49. fixed4 frag (v2f o) : COLOR
  50. {
  51. fixed4 col = _Color;
  52.  
  53. fixed2 uv = o.uv - float2(0.5,0.5);
  54. fixed uvLength = length(uv);
  55.  
  56. col.a = col.a
  57. //Cut off inner radius
  58. * ceil(uvLength - _InnerRadius)
  59.  
  60. //Cut off outer radius
  61. * ceil( 1 - abs(uvLength / 0.5) )
  62.  
  63. //Cut off angle
  64. * ceil( dot(fixed2(-1,0), normalize(uv) ) - (1 - (_Angle / 180)) );
  65.  
  66. return col;
  67. }
  68. ENDCG
  69. }
  70. }
  71. FallBack "Diffuse"
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement