-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
44 lines (35 loc) · 1.03 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
<head>
<title>Shaders</title>
</head>
<body bgcolor="#2b2b2b">
<div id="container" style="width: 500px; height: 500px;"></div>
<script src="js/three/three.min.js"></script>
<script id="vertexShader" type="x-shader/x-vertex">
void main() {
gl_Position = vec4( position, 1.0 );
}
</script>
<script id="fragmentShader" type="x-shader/x-fragment">
// First master 1 dimentional functions
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.14159265359
uniform vec2 u_resolution;
uniform float u_mouse;
uniform float u_time;
float plot(vec2 st, float pct) {
return smoothstep(pct - 0.02, pct, st.y) - smoothstep(pct, pct + 0.02, st.y);
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution;
float y = sin(st.x);
vec3 color = vec3(y);
// Plot a line
float pct = plot(st, y);
color = (1.0 - pct) * color + pct * vec3(0.0, 1.0, 0.0);
gl_FragColor = vec4(color, 1.0);
}
</script>
<script src="js/main.js"></script>
</body>