UIMask.shader 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. Shader "DashGame/UIMask"
  2. {
  3. Properties
  4. {
  5. _MainTex("Texture", 2D) = "white" {}
  6. }
  7. SubShader
  8. {
  9. Tags
  10. {
  11. "Queue" = "Transparent"
  12. "IgnoreProjector" = "True"
  13. "RenderType" = "Transparent"
  14. "PreviewType" = "Plane"
  15. "CanUseSpriteAtlas" = "True"
  16. }
  17. Cull Off
  18. Lighting Off
  19. ZWrite Off
  20. ZTest[unity_GUIZTestMode]
  21. Blend SrcAlpha OneMinusSrcAlpha
  22. Pass
  23. {
  24. CGPROGRAM
  25. #pragma vertex vert
  26. #pragma fragment frag
  27. #include "UnityUI.cginc"
  28. #include "UnityCG.cginc"
  29. struct appdata
  30. {
  31. float2 uv : TEXCOORD0;
  32. float4 color : COLOR;
  33. float4 vertex : POSITION;
  34. };
  35. struct v2f
  36. {
  37. float2 uv : TEXCOORD0;
  38. float4 color : COLOR;
  39. float4 vertex : SV_POSITION;
  40. float4 screenPos : TEXCOORD1;
  41. };
  42. sampler2D _MainTex;
  43. float4 _MainTex_ST;
  44. float _RadiusX;
  45. float _RadiusY;
  46. float2 _Center;
  47. v2f vert(appdata v)
  48. {
  49. v2f o;
  50. o.vertex = UnityObjectToClipPos(v.vertex);
  51. o.screenPos = ComputeScreenPos(o.vertex);
  52. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  53. o.color = v.color;
  54. return o;
  55. }
  56. fixed4 frag(v2f i) : SV_Target
  57. {
  58. fixed4 col = tex2D(_MainTex, i.uv)*i.color;
  59. float x = i.screenPos.x - _Center.x;
  60. float y = i.screenPos.y - _Center.y;
  61. if (abs(x) < _RadiusX && abs(y) < _RadiusY)
  62. {
  63. col.a = 0;
  64. }
  65. return col;
  66. }
  67. ENDCG
  68. }
  69. }
  70. }