-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcSkyBoxTex.shader
69 lines (51 loc) · 1.66 KB
/
ProcSkyBoxTex.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 "Custom/Color Skybox with Gradient" {
Properties {
_SkyTint ("Sky", Color) = (.5, .5, .5, 1)
_Gradient ("Gradient", 2D) = "white" {}
_HorizonSize("Horizon Size", Range(0.00001,1)) = 1.0
}
SubShader {
Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
Cull Off ZWrite Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "Lighting.cginc"
uniform half4 _SkyTint;
uniform half _HorizonSize;
sampler2D _Gradient;
struct appdata_t
{
float4 vertex : POSITION;
};
struct v2f
{
float4 pos : SV_POSITION;
half skyGroundFactor : TEXCOORD0;
};
v2f vert (appdata_t v)
{
v2f OUT;
OUT.pos = UnityObjectToClipPos(v.vertex);
float3 eyeRay = normalize(mul((float3x3)unity_ObjectToWorld, v.vertex.xyz));
OUT.skyGroundFactor = sign(eyeRay.y)*pow( abs(eyeRay.y) , _HorizonSize);
return OUT;
}
half4 frag (v2f IN) : SV_Target
{
half3 col = half3(0.0, 0.0, 0.0);
half pos = 0;
if (IN.skyGroundFactor<0){
pos = lerp(0.5,0,saturate((1-IN.skyGroundFactor-1)/_HorizonSize));
} else {
pos = lerp(0.5,1,saturate((IN.skyGroundFactor)/_HorizonSize));
}
return tex2D (_Gradient, half2(pos,0) )*_SkyTint;
}
ENDCG
}
}
Fallback Off
}