-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
252 lines (232 loc) · 7.61 KB
/
index.html
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<!DOCTYPE html>
<html>
<head>
<title>Reminiscence</title>
<meta charset="UTF-8">
<meta name="author" content="Nathan Bourgeois and Landon Waddell">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="main.css">
<!-- THREE.JS Library & Other Provided Code -->
<script src="lib/three.js"></script>
<script src="lib/postprocessing/EffectComposer.js"></script>
<script src="lib/postprocessing/RenderPass.js"></script>
<script src="lib/postprocessing/ShaderPass.js"></script>
<script src="lib/postprocessing/FilmPass.js"></script>
<script src="lib/shaders/CopyShader.js"></script>
<script src="lib/shaders/FilmShader.js"></script>
<script src="lib/shaders/VignetteShader.js"></script>
<script src="lib/postprocessing/AdaptiveToneMappingPass.js"></script>
<script src="lib/shaders/ToneMapShader.js"></script>
<script src="lib/postprocessing/BokehPass.js"></script>
<script src="lib/shaders/BokehShader.js"></script>
<script src="lib/shaders/HueSaturationShader.js"></script>
<script src="lib/shaders/LuminosityShader.js"></script>
<script src="lib/shaders/LuminosityHighPassShader.js"></script>
<script src="lib/postprocessing/UnrealBloomPass.js"></script>
<script src="lib/shaders/FXAAShader.js"></script>
<script src="lib/Lensflare.js"></script>
<script src="lib/SimplexNoise.js"></script>
<script src="lib/postprocessing/SavePass.js"></script>
<script src="lib/shaders/BlendShader.js"></script>
<!-- THREEJS Extensions -->
<script src="grass.js"></script>
<!-- First Person Controller. Modified from Three.JS -->
<script src="FirstPersonControls.js"></script>
<!-- Main Javascript File -->
<script src="chunk.js"></script>
<script src="main.js"></script>
<script id="cloudsVertShader" type = "text/glsl">
varying vec2 vUv;
uniform float time;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
</script>
<script id="cloudsFragShader" type = "text/glsl">
varying vec2 vUv;
uniform float time;
uniform float sunIntensity;
const float cloudscale = 2.71787;
const float speed = 0.002;
const float clouddark = 0.6;
const float cloudlight = 0.7;
const float cloudcover = 0.6;
const float cloudalpha = 8.0;
const mat2 m = mat2( 1.6, 1.2, -1.2, 1.6 );
vec2 hash( vec2 p ) {
p = vec2(dot(p,vec2(127.1,311.7)), dot(p,vec2(269.5,183.3)));
return -1.0 + 2.0*fract(sin(p)*43758.5453123);
}
float noise( in vec2 p ) {
const float K1 = 0.366025404; // (sqrt(3)-1)/2;
const float K2 = 0.211324865; // (3-sqrt(3))/6;
vec2 i = floor(p + (p.x+p.y)*K1);
vec2 a = p - i + (i.x+i.y)*K2;
vec2 o = (a.x>a.y) ? vec2(1.0,0.0) : vec2(0.0,1.0); //vec2 of = 0.5 + 0.5*vec2(sign(a.x-a.y), sign(a.y-a.x));
vec2 b = a - o + K2;
vec2 c = a - 1.0 + 2.0*K2;
vec3 h = max(0.5-vec3(dot(a,a), dot(b,b), dot(c,c) ), 0.0 );
vec3 n = h*h*h*h*vec3( dot(a,hash(i+0.0)), dot(b,hash(i+o)), dot(c,hash(i+1.0)));
return dot(n, vec3(70.0));
}
float fbm(vec2 n) {
float total = 0.0, amplitude = 0.1;
total += noise(n) * amplitude;
n = m * n;
amplitude *= 0.4;
total += noise(n) * amplitude;
n = m * n;
amplitude *= 0.4;
total += noise(n) * amplitude;
n = m * n;
amplitude *= 0.4;
total += noise(n) * amplitude;
n = m * n;
amplitude *= 0.4;
total += noise(n) * amplitude;
n = m * n;
amplitude *= 0.4;
total += noise(n) * amplitude;
n = m * n;
amplitude *= 0.4;
total += noise(n) * amplitude;
n = m * n;
amplitude *= 0.4;
return total;
}
void main() {
vec2 uv = vUv;
float q = fbm(uv * cloudscale * 0.5);
//ridged noise shape
float r = 0.0;
uv *= cloudscale;
uv -= q - (time*speed);
float weight = 0.8;
r += abs(weight*noise( uv ));
uv = m*uv + (time*speed);
weight *= 0.7;
r += abs(weight*noise( uv ));
uv = m*uv + (time*speed);
weight *= 0.7;
r += abs(weight*noise( uv ));
uv = m*uv + (time*speed);
weight *= 0.7;
r += abs(weight*noise( uv ));
uv = m*uv + (time*speed);
weight *= 0.7;
r += abs(weight*noise( uv ));
uv = m*uv + (time*speed);
weight *= 0.7;
r += abs(weight*noise( uv ));
uv = m*uv + (time*speed);
weight *= 0.7;
r += abs(weight*noise( uv ));
uv = m*uv + (time*speed);
weight *= 0.7;
r += abs(weight*noise( uv ));
uv = m*uv + (time*speed);
weight *= 0.7;
//noise shape
float f = 0.0;
uv = vUv;
uv *= cloudscale;
uv -= q - time * speed;
weight = 0.7;
f += weight*noise( uv );
uv = m*uv + time * speed;
weight *= 0.6;
f += weight*noise( uv );
uv = m*uv + time * speed;
weight *= 0.6;
f += weight*noise( uv );
uv = m*uv + time * speed;
weight *= 0.6;
f += weight*noise( uv );
uv = m*uv + time * speed;
weight *= 0.6;
f += weight*noise( uv );
uv = m*uv + time * speed;
weight *= 0.6;
f += weight*noise( uv );
uv = m*uv + time * speed;
weight *= 0.6;
f += weight*noise( uv );
uv = m*uv + time * speed;
weight *= 0.6;
f += weight*noise( uv );
uv = m*uv + time * speed;
weight *= 0.6;
f *= r + f;
//noise colour
float c = 0.0;
uv = vUv;
uv *= cloudscale*2.0;
uv -= q - time * speed * 2.0;
weight = 0.4;
c += weight*noise( uv );
uv = m*uv + time * speed * 2.0;
weight *= 0.6;
c += weight*noise( uv );
uv = m*uv + time * speed * 2.0;
weight *= 0.6;
c += weight*noise( uv );
uv = m*uv + time * speed * 2.0;
weight *= 0.6;
c += weight*noise( uv );
uv = m*uv + time * speed * 2.0;
weight *= 0.6;
c += weight*noise( uv );
uv = m*uv + time * speed * 2.0;
weight *= 0.6;
c += weight*noise( uv );
uv = m*uv + time * speed * 2.0;
weight *= 0.6;
c += weight*noise( uv );
uv = m*uv + time * speed * 2.0;
weight *= 0.6;
//noise ridge colour
float c1 = 0.0;
uv = vUv;
uv *= cloudscale*3.0;
uv -= q - time * speed * 3.0;
weight = 0.4;
c1 += abs(weight*noise( uv ));
uv = m*uv + time * speed * 3.0;
weight *= 0.6;
c1 += abs(weight*noise( uv ));
uv = m*uv + time * speed * 3.0;
weight *= 0.6;
c1 += abs(weight*noise( uv ));
uv = m*uv + time * speed * 3.0;
weight *= 0.6;
c1 += abs(weight*noise( uv ));
uv = m*uv + time * speed * 3.0;
weight *= 0.6;
c1 += abs(weight*noise( uv ));
uv = m*uv + time * speed * 3.0;
weight *= 0.6;
c1 += abs(weight*noise( uv ));
uv = m*uv + time * speed * 3.0;
weight *= 0.6;
c1 += abs(weight*noise( uv ));
uv = m*uv + time * speed * 3.0;
weight *= 0.6;
c += c1;
vec3 cloudcolour = vec3(1.1, 1.1, 0.9) * clamp((clouddark + cloudlight*c), 0.0, 1.0);
f = cloudcover + (cloudalpha + 4.0 * sin(time/5.0))*f*r;
vec3 result = mix(vec3(0.0), clamp(cloudcolour, 0.0, 1.0), clamp(f + c, 0.0, 1.0)) * 0.942;
result *= (sunIntensity * 0.37 - 0.5) + 0.94;
uv = ( vUv - vec2( 0.5 ) ) * vec2( 2.21787 );
vec4 result2 = vec4(result, pow((result.x * 0.2126 + result.y*0.7152 + result.z*0.0722), 3.1));
result2 = mix( result2, vec4( 0 ), dot( uv, uv ) );
result2.rgb *= 1.65;
result2.a *= 2.781828;
gl_FragColor = result2;
}
</script>
</head>
<body onload="setTimeout(function(){init();}, 10)">
<canvas id="canvasID"></canvas>
</body>
</html>