-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
77 lines (58 loc) · 1.68 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
<html>
<head>
<title>Web universe</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<style>
canvas {
width: 100vw;
height: 100vh;
}
body {
margin: 0;
padding: 0;
}
</style>
<script type="text/javascript" src="gl-matrix.js"></script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
uniform sampler2D uSampler;
varying vec4 vColor;
varying float vPointSize;
void main(void) {
vec2 fromCenter = gl_PointCoord - vec2(.5, .5);
float dist = length(fromCenter);
float brightnesMul = dist * 2.0;
brightnesMul = 1.0 - (brightnesMul * brightnesMul * brightnesMul);
vec4 textureColor = texture2D(uSampler, gl_PointCoord);
float alpha = textureColor.r;
if (dist < .025 && vPointSize > 2.0) {
alpha = 1.0;
}
gl_FragColor = vec4(vColor.r, vColor.g, vColor.b, alpha);
}
</script>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
attribute vec4 aVertexColor;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
varying vec4 vColor;
varying float vPointSize;
void main(void) {
vec4 actual_position = uMVMatrix * vec4(aVertexPosition, 1.0);
float dist = length(actual_position);
gl_Position = uPMatrix * actual_position;
gl_PointSize = 400.0/dist;
vPointSize = gl_PointSize;
vColor = aVertexColor;
}
</script>
<script type="text/javascript" src="data.js">
</script>
<script type="text/javascript" src="main.js">
</script>
</head>
<body onload="webGLStart();">
<canvas id="canvas" style="border: none;"></canvas>
</body>
</html>