ButtonBGMaskCircle.shader 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Shader "Unlit/ButtonBGMask/Circle"
  2. {
  3. Properties
  4. {
  5. _MainTex("Texture", 2D) = "white" {}
  6. _Color("Main Color", Color) = (1,1,1,1)
  7. _Radius("Radius", Range(0, 1)) = 0.15
  8. _Thickness("Thickness", Range(0, 1)) = 0.02
  9. _Angle("Angle", Range(0, 1)) = 0
  10. }
  11. SubShader
  12. {
  13. Tags { "Queue" = "Transparent" "IngnoreProjector" = "True" "RenderType" = "Transparent" }
  14. LOD 200
  15. Pass
  16. {
  17. ZWrite Off
  18. Cull Off
  19. Blend SrcAlpha OneMinusSrcAlpha
  20. CGPROGRAM
  21. #pragma vertex vert
  22. #pragma fragment frag
  23. // make fog work
  24. #pragma multi_compile_fog
  25. #include "UnityCG.cginc"
  26. struct appdata
  27. {
  28. float4 vertex : POSITION;
  29. float2 uv : TEXCOORD0;
  30. };
  31. struct v2f
  32. {
  33. float2 uv : TEXCOORD0;
  34. UNITY_FOG_COORDS(1)
  35. float4 vertex : SV_POSITION;
  36. };
  37. sampler2D _MainTex;
  38. fixed4 _Color;
  39. float4 _MainTex_ST;
  40. float _Radius, _Thickness, _Angle;
  41. v2f vert(appdata v)
  42. {
  43. v2f o;
  44. o.vertex = UnityObjectToClipPos(v.vertex);
  45. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  46. //UNITY_TRANSFER_FOG(o,o.vertex);
  47. return o;
  48. }
  49. fixed4 frag(v2f i) : SV_Target
  50. {
  51. // sample the texture
  52. float alpha = 1.0f;
  53. fixed4 col = tex2D(_MainTex, i.uv) * _Color;
  54. float dis = (i.uv.x - 0.5) * (i.uv.x - 0.5) + (i.uv.y - 0.5) * (i.uv.y - 0.5);
  55. if (dis<_Radius)
  56. {
  57. //col.a = 1.0;
  58. //clip(-1);
  59. }
  60. else if (dis > _Radius + _Thickness)
  61. {
  62. col.a = 0.0;
  63. clip(-1);
  64. }
  65. /*else {
  66. float angletemp = atan2(i.uv.y - 0.5, i.uv.x - 0.5);
  67. if (angletemp < (_Angle - 0.5) * 3.1415926 * 2)
  68. {
  69. col.a = 0.0;
  70. clip(-1);
  71. }
  72. else {
  73. col.a = (_Thickness * 0.5 - abs(dis - _Radius - _Thickness * 0.5)) / 0.008;
  74. }
  75. }*/
  76. // apply fog
  77. //UNITY_APPLY_FOG(i.fogCoord, col);
  78. return col;
  79. }
  80. ENDCG
  81. }
  82. }
  83. }