12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- Shader "DashGame/Mask"
- {
- Properties
- {
- [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
- _Color("Tint", Color) = (1,1,1,1)
- [MaterialToggle] PixelSnap("Pixel snap", Float) = 0
- }
- SubShader
- {
- Tags
- {
- "Queue" = "Transparent"
- "IgnoreProjector" = "True"
- "RenderType" = "Transparent"
- "PreviewType" = "Plane"
- "CanUseSpriteAtlas" = "True"
- }
- Cull Off
- Lighting Off
- ZWrite Off
- Pass
- {
- Blend SrcAlpha OneMinusSrcAlpha
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma target 2.0
- #pragma multi_compile _ PIXELSNAP_ON
- #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
- #include "UnityCG.cginc"
- struct appdata_t
- {
- float4 vertex : POSITION;
- float4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- };
- struct v2f
- {
- fixed4 color : COLOR;
- float4 vertex : SV_POSITION;
- float2 texcoord : TEXCOORD0;
- };
- float _RadiusX;
- float _RadiusY;
- float2 _Center;
- fixed4 _Color;
- v2f vert(appdata_t IN)
- {
- v2f OUT;
- OUT.vertex = UnityObjectToClipPos(IN.vertex);
- OUT.texcoord = IN.texcoord;
- OUT.color = IN.color * _Color;
- return OUT;
- }
- sampler2D _MainTex;
- fixed4 SampleSpriteTexture(float2 uv)
- {
- fixed4 color = tex2D(_MainTex, uv);
- return color;
- }
- fixed4 frag(v2f IN) : SV_Target
- {
- fixed4 c = SampleSpriteTexture(IN.texcoord) * IN.color;
- float x = IN.vertex.x - _Center.x;
- float y = IN.vertex.y - _Center.y;
- if (abs(x) < _RadiusX && abs(y) < _RadiusY)
- {
- c.a = 0;
- }
- return c;
- }
- ENDCG
- }
- }
- }
|