nothing-simulator/docs/index.html
2025-03-04 05:14:52 -05:00

53 lines
No EOL
1.5 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;
// all shaders have a main function
void main() {
// gl_Position is a special variable a vertex shader
// is responsible for setting
gl_Position = a_position * mat_thing;
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;
void main() {
// gl_FragColor is a special variable a fragment shader
// is responsible for setting
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/twgl.min.js" type="module"></script>
<script src="/js/index.js" type="module"></script>
<link rel="stylesheet" href="main.css">
</head>
<body>
<canvas id="c" width="640" height="480"></canvas>
<div class='hud'>
hud
</div>
</body>
</html>