| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- Shader "MoleGame/Particles/Overlay"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- _TintColor("Tint Color", Color) = (0.5,0.5,0.5,0.5)
- _Threshold("Threshold", Range(0.0,0.99)) = 0.5
- _StencilComp("Stencil Comparison", Float) = 8
- _Stencil("Stencil ID", Float) = 0
- _StencilOp("Stencil Operation", Float) = 0
- _StencilWriteMask("Stencil Write Mask", Float) = 255
- _StencilReadMask("Stencil Read Mask", Float) = 255
- _ColorMask("Color Mask", Float) = 15
- [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
- }
- SubShader
- {
- Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
- Stencil
- {
- Ref[_Stencil]
- Comp[_StencilComp]
- Pass[_StencilOp]
- ReadMask[_StencilReadMask]
- WriteMask[_StencilWriteMask]
- }
- ZTest[unity_GUIZTestMode]
- ColorMask[_ColorMask]
- Blend SrcAlpha One
- Cull Off Lighting Off ZWrite Off
-
- LOD 100
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma target 2.0
-
- #include "UnityCG.cginc"
- #include "UnityUI.cginc"
- #pragma multi_compile __ UNITY_UI_CLIP_RECT
- #pragma multi_compile __ UNITY_UI_ALPHACLIP
- struct appdata
- {
- float4 vertex : POSITION;
- fixed4 color : COLOR;
- float2 uv : TEXCOORD0;
- UNITY_VERTEX_INPUT_INSTANCE_ID
- };
- struct v2f
- {
- float2 uv : TEXCOORD0;
- fixed4 color : COLOR;
- float4 vertex : SV_POSITION;
- float4 worldPosition : TEXCOORD1;
- UNITY_VERTEX_OUTPUT_STEREO
- };
- sampler2D _MainTex;
- float4 _MainTex_ST;
- half4 _TintColor;
- half _Threshold;
- float4 _ClipRect;
- v2f vert (appdata v)
- {
- v2f o;
- UNITY_SETUP_INSTANCE_ID(v);
- UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
- o.worldPosition = v.vertex;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.color = v.color;
- o.uv = TRANSFORM_TEX(v.uv, _MainTex);
- return o;
- }
-
- fixed4 frag (v2f i) : SV_Target
- {
- // sample the texture
- fixed4 col = tex2D(_MainTex, i.uv) * i.color;
- float a = col.a * i.color.a;
- col = 2*lerp(col*_TintColor, col, (col.r - _Threshold)/ (1-_Threshold));
- col.a = a;
- #ifdef UNITY_UI_CLIP_RECT
- col.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
- #endif
- #ifdef UNITY_UI_ALPHACLIP
- clip(col.a - 0.001);
- #endif
- return col;
- }
- ENDCG
- }
- }
- }
|