34 lines
928 B
HTML
34 lines
928 B
HTML
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<script type="module">
|
|
import { ShaderView } from "./mod.js";
|
|
|
|
var speed = document.getElementById("speed");
|
|
speed.onchange = () => view.setUniform("speed", speed.value);
|
|
|
|
const shader = `
|
|
uniform float speed;
|
|
void main()
|
|
{
|
|
vec2 uv = (gl_FragCoord.xy * 2. - iResolution.xy) / iResolution.y;
|
|
float d = length(uv);
|
|
d = abs(sin(d * 10. + iTime * speed)) / 10.;
|
|
d = smoothstep(0.95, 1., 1. - d);
|
|
vec3 color = d * vec3(1., 2., 3.);
|
|
gl_FragColor = vec4(color, 1.0);
|
|
}`.trim();
|
|
const view = new ShaderView(shader, {
|
|
parent: document.getElementById("container"),
|
|
size: { width: 512, height: 512 },
|
|
});
|
|
view.setUniform("speed", speed.value);
|
|
console.log(view.uniforms);
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<input id="speed" type="number" value="1" />
|
|
<div id="container"></div>
|
|
</body>
|
|
</html>
|