107 lines
2.4 KiB
Plaintext
107 lines
2.4 KiB
Plaintext
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
|
|
}
|
|
}
|
|
}
|