-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
107 lines (74 loc) · 3.2 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
<html>
<head>
<title>Craft-io</title>
<meta charset="utf-8"/>
<script src="tools/gl-matrix-min.js"></script>
<script src="tools/perlin.js" ></script>
</head>
<body>
<canvas style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; margin: 0 0 0 0; " id="webby-box"></canvas>
<textarea readonly="true" class="terminal" id="webby-log"></textarea>
<p id="c_block" style="position:absolute;margin:2pt;background-color:#22222255;color:#FFF;padding:4pt;border-radius:2pt"></p>
<script src="craft.js"></script>
<!-- /// ############# /// /// ############# ///
/// #### /// #### /// SHADERS /// #### /// #### ///
/// ############# /// /// ############# /// -->
<script type="text" id="webby.shader.solid.vertex">#version 300 es
uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
in vec3 pos;
void main() { gl_PointSize=10.0; gl_Position = (projection*view*model)*vec4(pos,1.0); } </script>
<script type="text" id="webby.shader.solid.fragment">#version 300 es
precision mediump float;
out vec4 frag;
void main() { frag=vec4(1.0,0.0,0.0,1.0); } </script>
<script type="text" id="webby.shader.uv.vertex">#version 300 es
uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
layout(location=0) in vec3 pos;
layout(location=1) in vec2 puv;
layout(location=2) in vec3 pnm;
out vec2 uv;
out vec3 nrm;
void main() {
gl_Position = (projection*view*model)*vec4(pos,1.0);
uv = puv;
nrm=pnm; } </script>
<script type="text" id="webby.shader.uv.fragment">#version 300 es
precision mediump float;
uniform sampler2D terrain;
out vec4 frag;
in vec2 uv;
in vec3 nrm;
const vec3 lightDir=vec3(0.5,0.5,0.5);
void main() {
float lLevel=dot(nrm,lightDir);
frag=mix(texture(terrain,uv),vec4(0.0,0.0,0.0,1.0),clamp(lLevel,0.0,1.3)); } </script>
<!-- /// ############# /// /// ############# ///
/// #### /// #### /// WGL1 SHADERS /// #### /// #### ///
/// ############# /// /// ############# /// -->
<script type="text" id="webby.shader.solid.vertex.wgl1">#version 100
uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
attribute vec3 pos;
void main() { gl_Position = (projection*view*model)*vec4(pos,1.0); } </script>
<script type="text" id="webby.shader.solid.fragment.wgl1">#version 100
precision mediump float;
uniform vec3 color;
void main() { gl_FragColor=vec4(color,1.0); } </script>
<script type="text" id="webby.shader.uv.vertex.wgl1">#version 100
uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
attribute vec3 pos;
varying vec3 uv;
void main() { gl_Position = (projection*view*model)*vec4(pos,1.0); uv = (pos*vec3(0.5)+vec3(0.5))/vec3(16.0,32.0,16.0); } </script>
<script type="text" id="webby.shader.uv.fragment.wgl1">#version 100
precision mediump float;
varying vec3 uv;
void main() { gl_FragColor=vec4(uv,1.0); } </script>
</body>
</html>