-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
67 lines (55 loc) · 1.52 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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>fluid</title>
</head>
<body>
<script id="shader-fs" type="x-shader/x-fragment">
precision lowp float;
uniform sampler2D uPositionTex;
uniform float uSize;
uniform float uDim;
varying vec4 position;
// int(uDim) not working?
const int iDim = 64;
const float stickyness = 20.0;
void main(void) {
float value = 0.0;
float x, y;
for (int i = 0; i < iDim; ++i) {
vec4 tex = texture2D(uPositionTex, vec2(float(i) / uDim, 0));
// point 1
x = position.x - tex.r;
y = position.y - tex.g;
value += stickyness / (x * x + y * y);
// point 2
x = position.x - tex.b;
y = position.y - tex.a;
value += stickyness / (x * x + y * y);
}
float a = 0.0;
if (value > uSize) {
a = 0.86;
} else if(value > (uSize - 0.001)) {
a = 1.0;
} else {
return;
}
// float t = (position.y / 1000.0);
gl_FragColor = vec4(0.0, a, a, 1.0);
}
</script>
<script id="shader-vs" type="x-shader/x-vertex">
uniform vec2 uScreen;
attribute vec4 aPosition;
varying vec4 position;
void main(void) {
position = vec4(aPosition.xyz, 1.0);
gl_Position = position * 2.0 - vec4(1.0, 1.0, 1.0, 1.0);
position *= vec4(uScreen, 1.0, 1.0);
}
</script>
<script type="text/javascript" charset="utf-8" src="bundle.js"></script>
</body>
</html>