12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- Shader "DashGame/UIMask"
- {
- Properties
- {
- _MainTex("Texture", 2D) = "white" {}
- }
- SubShader
- {
- Tags
- {
- "Queue" = "Transparent"
- "IgnoreProjector" = "True"
- "RenderType" = "Transparent"
- "PreviewType" = "Plane"
- "CanUseSpriteAtlas" = "True"
- }
- Cull Off
- Lighting Off
- ZWrite Off
- ZTest[unity_GUIZTestMode]
- Blend SrcAlpha OneMinusSrcAlpha
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityUI.cginc"
- #include "UnityCG.cginc"
- struct appdata
- {
- float2 uv : TEXCOORD0;
- float4 color : COLOR;
- float4 vertex : POSITION;
- };
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 color : COLOR;
- float4 vertex : SV_POSITION;
- float4 screenPos : TEXCOORD1;
- };
- sampler2D _MainTex;
- float4 _MainTex_ST;
- float _RadiusX;
- float _RadiusY;
- float2 _Center;
- v2f vert(appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.screenPos = ComputeScreenPos(o.vertex);
- o.uv = TRANSFORM_TEX(v.uv, _MainTex);
- o.color = v.color;
- return o;
- }
- fixed4 frag(v2f i) : SV_Target
- {
- fixed4 col = tex2D(_MainTex, i.uv)*i.color;
- float x = i.screenPos.x - _Center.x;
- float y = i.screenPos.y - _Center.y;
- if (abs(x) < _RadiusX && abs(y) < _RadiusY)
- {
- col.a = 0;
- }
- return col;
- }
- ENDCG
- }
- }
- }
|