-
-
Notifications
You must be signed in to change notification settings - Fork 232
/
Gradient Skybox.shader
69 lines (60 loc) · 1.89 KB
/
Gradient Skybox.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Shader "Procedural Toolkit/Gradient Skybox"
{
Properties
{
_SkyColor("Sky Color", Color) = (1.0, 1.0, 1.0, 0.0)
_HorizonColor("Horizon Color", Color) = (0.25, 0.25, 0.25, 0.0)
_GroundColor("Ground Color", Color) = (0.75, 0.75, 0.75, 0.0)
_Exponent1("Sky Exponent", Float) = 3.0
_Exponent2("Ground Exponent", Float) = 1.0
_Intensity("Intensity", Float) = 1.0
}
SubShader
{
Tags { "Queue" = "Background" "RenderType" = "Background" "PreviewType" = "Skybox" }
Cull Off
ZWrite Off
Pass
{
CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
half3 _SkyColor;
half3 _HorizonColor;
half3 _GroundColor;
half _Exponent1;
half _Exponent2;
half _Intensity;
struct appdata
{
float4 position : POSITION;
float3 uv : TEXCOORD0;
};
struct v2f
{
float4 position : SV_POSITION;
float3 uv : TEXCOORD0;
};
v2f vert(appdata v)
{
v2f o;
o.position = UnityObjectToClipPos(v.position);
o.uv = v.uv;
return o;
}
half4 frag (v2f i) : SV_Target
{
float y = normalize(i.uv).y;
float c1 = 1.0 - pow(min(1.0, 1.0 - y), _Exponent1);
float c3 = 1.0 - pow(min(1.0, 1.0 + y), _Exponent2);
float c2 = 1.0 - c1 - c3;
half3 color = (_SkyColor*c1 + _HorizonColor*c2 + _GroundColor*c3)*_Intensity;
return half4(color, 1.0);
}
ENDCG
}
}
Fallback Off
}