-
Notifications
You must be signed in to change notification settings - Fork 5
/
HeightColorGradientNoLighting.shader
54 lines (43 loc) · 1.56 KB
/
HeightColorGradientNoLighting.shader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// HeightColorGradient by Mark Johns - @Doomlaser - https://twitter.com/Doomlaser
// Set two colors to blend, min and max distance define the bottom and top Y values between which the colors will blend
Shader "Custom/HeightColorGradientNoLighting" {
Properties {
_Color ("Color", Color) = (1, 1, 1, 1)
_MaxColor ("Color in Maxmal", Color) = (0, 0, 0, 0)
_MinDistance ("Min Distance", Float) = 100
_MaxDistance ("Max Distance", Float) = 1000
}
SubShader {
Tags { "RenderType"="Opaque" }
Zwrite On
CGPROGRAM
#pragma surface surf NoLighting
struct Input {
float2 uv_MainTex;
float3 worldPos;
float3 screenPos;
float4 color : COLOR;
};
float _MaxDistance;
float _MinDistance;
float4 _Color;
float4 _MaxColor;
void surf (Input IN, inout SurfaceOutput o) {
half4 dist = IN.worldPos.y;
half4 weight = (dist - _MinDistance) / (_MaxDistance - _MinDistance);
half4 distanceColor = lerp(_Color, _MaxColor, weight);
o.Albedo = IN.color.rgb * distanceColor.rgb ;
// o.Alpha = IN.color.a * distanceColor.a;
o.Alpha = 1;
}
fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten)
{
fixed4 c;
c.rgb = s.Albedo;
c.a = s.Alpha;
return c;
}
ENDCG
}
FallBack "Diffuse"
}