nothing-simulator/docs/index.html
2025-03-04 22:32:32 -05:00

63 lines
No EOL
1.8 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>WebGL Demo</title>
<script id="vertex-shader-2d" type="notjs">
// an attribute will receive data from a buffer
attribute vec4 a_position;
varying vec4 b_position;
uniform mat4 mat_thing;
uniform mat4 mvp_thing;
// all shaders have a main function
void main() {
// gl_Position is a special variable a vertex shader
// is responsible for setting
gl_Position = mat_thing * mvp_thing * a_position ;
b_position = a_position;
}
</script>
<script id="fragment-shader-2d" type="notjs">
// fragment shaders don't have a default precision so we need
// to pick one. mediump is a good default
precision mediump float;
varying vec4 b_position;
uniform float size_thing;
uniform float dist_thing;
uniform bool is_fg;
void main() {
// gl_FragColor is a special variable a fragment shader
// is responsible for setting
if (is_fg) {
gl_FragColor = vec4(b_position.xyz*0.1,1) * 0.2 + vec4(0.3,0.3,0.3,1) * 0.8;
return;
}
float dist = (log(distance(b_position.xy,vec2(0.0))) - size_thing + dist_thing) / log(2.0) * 0.1;
gl_FragColor = vec4((mod(dist,0.1) - 0.1 + 0.1 * dist_thing) * 50.0 * vec3(1,1,1),1); // return redish-purple
}
</script>
<script src="/js/cube.js"></script>
<script src="/js/mat.js"></script>
<script src="/js/twgl.min.js"></script>
<script src="/js/idle.js" defer></script>
<script src="/js/index.js" defer></script>
<link rel="stylesheet" href="main.css">
</head>
<body>
<canvas id="c" width="640" height="480"></canvas>
<div class='hud'>
hud
</div>
</body>
</html>