-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
82 lines (76 loc) · 2.45 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>quad-shader: Render fragment shader in a quad</title>
<link rel="stylesheet" href="./style.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Hind&family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"
rel="stylesheet"
/>
</head>
<body>
<h1>Easy 2D shader setup with quad-shader</h1>
<p>
This is a template for getting started with
<a
href="https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API"
target="_blank"
rel="noopener noreferrer"
>WebGL</a
>
using Vite and TypeScript. The animations on this page are generated on
the fly with WebGL fragment shaders.
</p>
<div class="canvas-container">
<canvas id="glcanvas-sphere"></canvas>
</div>
<p>
With fragment shaders, you have control over each pixel's color, making it
perfect for Creative Coding and generating textures and patterns
procedurally.
</p>
<p>
WebGL runs on the GPU, allowing for smooth, high-frame-rate animations.
This template has <strong>no runtime dependencies</strong> and uses the
WebGL API directly.
</p>
<div class="canvas-container">
<canvas id="glcanvas-dots"></canvas>
</div>
<p>
The colors used by the shaders are derived from the page's CSS properties
— open your devtools and have some fun. The technique used is described in
<a
href="https://nmattia.com/posts/2025-01-29-shader-css-properties/"
target="_blank"
rel="noopener noreferrer"
>this blog post</a
>.
</p>
<p>
The code for this page and the quad-shader library is on GitHub at
<a
href="https://github.com/nmattia/quad-shader"
target="_blank"
rel="noopener noreferrer"
>nmattia/quad-shader</a
>.
</p>
<footer>
©
<a href="https://nmattia.com" target="_blank" rel="noopener noreferrer"
>Nicolas Mattia</a
>
2025
</footer>
<script type="module">
import { main } from "./index.ts";
main();
</script>
</body>
</html>