-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
301 lines (246 loc) · 6.65 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<!-- index.html --><!DOCTYPE html>
<html>
<head>
<title>Tiefenrausch</title>
<!-- Disables mobile touch delay-->
<meta name="viewport" content="width=device-width, user-scalable=no">
<style id="jsbin-css">
*{margin:0;}
body{
font: 200 16px/1 Helvetica, Arial, sans-serif;
overflow: hidden;
}
img{width:32.2%;}
.object {
animation-name: MoveDown;
animation-duration: 2s;
animation-timing-function: ease-out;
animation-fill-mode: forwards;
position: relative;
z-index:300;
top:-80%;
left:10%;
width:80%;
right:10%;
}
#reset {
position: absolute;
z-index:300;
bottom:0;
left:30%;
width:20%;
height:20%;
right:50%;
background-color: black;
background-image: url(./Assets/restart-button.png);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
border:none;
outline:none;
}
#credits {
position: absolute;
z-index:300;
bottom:0;
left:50%;
width:20%;
height:20%;
right:30%;
background-color: black;
background-image: url(./Assets/exit.png);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
border:none;
outline:none;
}
@keyframes MoveDown {
0% {
transform: translateY(0%);
}
30% {
transform: translateY(0%);
}
100% {
transform: translateY(70%);
}
}
#startImage{
display: block;
z-index:200;
top: -10%;
max-width: 100%;
height: auto;
background:rgba(0,0,0,0.9);
transition: 1s 0.4s;
}
#loadingAnimation{
display: none
position:fixed;
z-index:100;
top:0;
left:0;
bottom:0;
right:0;
background:rgba(0,0,0,0.9);
transition: 1s 0.4s;
}
#progress{
height:1px;
background:#fff;
position:absolute;
width:0;
top:50%;
}
#progstat{
font-size:0.7em;
letter-spacing: 3px;
position:absolute;
top:50%;
margin-top:-40px;
width:100%;
text-align:center;
color:#fff;
}
</style>
<script type="module" src="./main.js"></script>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 position;
attribute vec2 texCoord;
varying mediump vec2 vTexCoord;
varying mediump vec3 worldPos;
uniform mat4 M;
uniform mat4 VP;
uniform vec2 frame_data;
void main(void) {
vTexCoord = vec2((texCoord.x * (1.0/frame_data.y)) + (frame_data.x/frame_data.y), texCoord.y);
worldPos = (M * vec4(position, 1.0)).xyz;
gl_Position = VP * vec4(worldPos, 1.0);
}
</script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
varying mediump vec2 vTexCoord;
varying mediump vec3 worldPos;
uniform sampler2D texture;
uniform vec2 texRes;
uniform float alpha;
void main(void) {
vec4 texCol = texture2D(texture, vTexCoord);
texCol *= alpha;
gl_FragColor = texCol;
}
</script>
<script id="light-fs" type="x-shader/x-fragment">
precision mediump float;
varying mediump vec2 vTexCoord;
varying mediump vec3 worldPos;
uniform sampler2D texture;
uniform vec2 texRes;
uniform float lights[180];
uniform float lightCount;
uniform float ambientLight;
uniform float alpha;
void main(void) {
vec4 texCol = texture2D(texture, vTexCoord);
texCol *= alpha;
vec3 resCol = vec3(0.0, 0.0, 0.0);
vec3 gamma = vec3(1.0/2.2);
for (int i = 0; i < 20; i++)
{
if (i >= int(lightCount))
break;
vec3 color = vec3(lights[i * 9], lights[i * 9 + 1], lights[i * 9 + 2]);
vec2 pos = vec2(lights[i * 9 + 3], lights[i * 9 + 4]);
vec2 dir = normalize(vec2(lights[i * 9 + 5], lights[i * 9 + 6]));
float cutoff = lights[i * 9 + 7];
float intensity = lights[i * 9 + 8];
vec2 ray = pos - worldPos.xy;
float distanceToLight = length(ray);
ray = normalize(ray);
float angle = dot(ray, dir);
if (angle < cutoff)
{
continue;
}
float attenuation = 1.0 / (1.0 + pow(distanceToLight, 2.0));
//linear color (color before gamma correction)
float lightIntensity = 1.0;
if (cutoff > 0.0) {
lightIntensity = (attenuation + 0.00125) * intensity * ((angle - cutoff)/(1.0-cutoff));
}
else {
lightIntensity = attenuation * intensity + 0.00125;
}
vec3 linearColor = texCol.xyz * color * lightIntensity;
//final color (after gamma correction)
resCol += clamp(linearColor, 0.0, 1.0);
//resCol += texCol.xyz * (attenuation*color.x + 0.1);
//resCol += vec3(1.0, 0.0, 0.0);
}
resCol += texCol.xyz * ambientLight;
gl_FragColor = vec4(resCol, texCol.w);
}
</script>
<script id="blur-fs" type="x-shader/x-fragment">
precision mediump float;
varying mediump vec2 vTexCoord;
varying mediump vec3 worldPos;
uniform sampler2D texture;
uniform vec2 texRes;
vec4 getTexFromOffset(float x, float y) {
return texture2D(texture, vec2( vTexCoord.x + (x * 2.0)/texRes.x, vTexCoord.y + (y * 2.0)/texRes.y));
}
uniform float gaussian[225];
void main(void) {
vec4 color = vec4(0, 0, 0, 0);
for (int i = -8; i <= 8; i++)
{
for (int j = -8; j <= 8; j++)
{
float i1 = float(i);
float j1 = float(j);
color += getTexFromOffset(i1, j1) * gaussian[(i + 8) * 15 + j + 8];
}
}
gl_FragColor = color;
}
</script>
<style>
* {
margin: 0;
padding: 0;
}
body, html { height: 100% }
img{
z-index: 99;
position: absolute;
width: 100%;
height: 100%;
}
#credits_img {
width: unset;
position: unset;
margin: auto;
display: block;
}
canvas {
position: absolute;
width: 100%;
height: 100%;
}
</style>
<link rel="shortcut icon" href="https://raw.githubusercontent.com/MDeiml/LD48/master/favicon.ico" type="image/x-icon">
<link rel="icon" href="https://raw.githubusercontent.com/MDeiml/LD48/master/favicon.ico" type="image/x-icon">
</head>
<body style="background-color:black;">
<img id="credits_img" style="display: none" src="./Assets/credits.png" >
<img id="message" class="object" src="./Assets/news.png" >
<img id="startImage" src="./Assets/sitzende_taucher.png" >
<img id="loadingAnimation" src="./Assets/loading.gif" >
<button id="reset" style="display:none" onClick="window.location.href=window.location.href"></button>
<button id="credits" style="display:none"></button>
<canvas id="glCanvas" width="800" height="600">
</body>
</html>