Mask.shader 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Shader "DashGame/Mask"
  2. {
  3. Properties
  4. {
  5. [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
  6. _Color("Tint", Color) = (1,1,1,1)
  7. [MaterialToggle] PixelSnap("Pixel snap", Float) = 0
  8. }
  9. SubShader
  10. {
  11. Tags
  12. {
  13. "Queue" = "Transparent"
  14. "IgnoreProjector" = "True"
  15. "RenderType" = "Transparent"
  16. "PreviewType" = "Plane"
  17. "CanUseSpriteAtlas" = "True"
  18. }
  19. Cull Off
  20. Lighting Off
  21. ZWrite Off
  22. Pass
  23. {
  24. Blend SrcAlpha OneMinusSrcAlpha
  25. CGPROGRAM
  26. #pragma vertex vert
  27. #pragma fragment frag
  28. #pragma target 2.0
  29. #pragma multi_compile _ PIXELSNAP_ON
  30. #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
  31. #include "UnityCG.cginc"
  32. struct appdata_t
  33. {
  34. float4 vertex : POSITION;
  35. float4 color : COLOR;
  36. float2 texcoord : TEXCOORD0;
  37. };
  38. struct v2f
  39. {
  40. fixed4 color : COLOR;
  41. float4 vertex : SV_POSITION;
  42. float2 texcoord : TEXCOORD0;
  43. };
  44. float _RadiusX;
  45. float _RadiusY;
  46. float2 _Center;
  47. fixed4 _Color;
  48. v2f vert(appdata_t IN)
  49. {
  50. v2f OUT;
  51. OUT.vertex = UnityObjectToClipPos(IN.vertex);
  52. OUT.texcoord = IN.texcoord;
  53. OUT.color = IN.color * _Color;
  54. return OUT;
  55. }
  56. sampler2D _MainTex;
  57. fixed4 SampleSpriteTexture(float2 uv)
  58. {
  59. fixed4 color = tex2D(_MainTex, uv);
  60. return color;
  61. }
  62. fixed4 frag(v2f IN) : SV_Target
  63. {
  64. fixed4 c = SampleSpriteTexture(IN.texcoord) * IN.color;
  65. float x = IN.vertex.x - _Center.x;
  66. float y = IN.vertex.y - _Center.y;
  67. if (abs(x) < _RadiusX && abs(y) < _RadiusY)
  68. {
  69. c.a = 0;
  70. }
  71. return c;
  72. }
  73. ENDCG
  74. }
  75. }
  76. }