aswi2021tri-musketyri-gitlab/Client/Client/Assets/Scripts/Shaders/MapUnderlay.shader @ 755c25f3
1 |
// Based on Unity's Unlit/Transparent |
---|---|
2 |
|
3 |
Shader "Unlit/MapUnderlay" |
4 |
{
|
5 |
Properties
|
6 |
{
|
7 |
_MainTex("Texture", 2D) = "white" {} |
8 |
_Min("Min", Range(0.0, 1.0)) = 0.0 |
9 |
_Max("Max", Range(0.0, 1.0)) = 0.25 |
10 |
_Color("Color", Color) = (0,0,0,0) |
11 |
}
|
12 |
SubShader{ |
13 |
Tags
|
14 |
{
|
15 |
"Queue" = "Transparent" |
16 |
"IgnoreProjector" = "True" |
17 |
"RenderType" = "Transparent" |
18 |
}
|
19 |
|
20 |
LOD 100 |
21 |
|
22 |
ZWrite Off |
23 |
Blend SrcAlpha OneMinusSrcAlpha |
24 |
|
25 |
Pass { |
26 |
CGPROGRAM
|
27 |
#pragma vertex vert
|
28 |
#pragma fragment frag
|
29 |
#include "UnityCG.cginc"
|
30 |
|
31 |
struct appdata_t { |
32 |
float4 vertex : POSITION; |
33 |
float2 texcoord : TEXCOORD0; |
34 |
};
|
35 |
|
36 |
struct v2f { |
37 |
float4 vertex : SV_POSITION; |
38 |
half2 texcoord : TEXCOORD0; |
39 |
UNITY_FOG_COORDS(1) |
40 |
};
|
41 |
|
42 |
sampler2D _MainTex; |
43 |
float4 _MainTex_ST; |
44 |
float _Min; |
45 |
float _Max; |
46 |
float4 _Color; |
47 |
|
48 |
v2f vert(appdata_t v) |
49 |
{
|
50 |
v2f o; |
51 |
o.vertex = UnityObjectToClipPos(v.vertex); |
52 |
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); |
53 |
return o; |
54 |
}
|
55 |
|
56 |
fixed4 frag(v2f i) : SV_Target |
57 |
{
|
58 |
fixed4 sampled = tex2D(_MainTex, i.texcoord); |
59 |
|
60 |
float bw = (0.3f * sampled.r) + (0.59f * sampled.g) + (0.11f * sampled.b); |
61 |
float clamped = _Min + (_Max - _Min) * bw; |
62 |
|
63 |
sampled.rgb = clamped; |
64 |
|
65 |
return sampled; |
66 |
}
|
67 |
ENDCG
|
68 |
}
|
69 |
}
|
70 |
}
|