instantshader 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -10
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
# instantshader
|
|
4
4
|
|
|
5
5
|
Animated WebGL gradient shaders with zero dependencies. Mount a live, resizable
|
|
6
|
-
gradient into any DOM element,
|
|
6
|
+
gradient into any DOM element, put dither, pixelate, halftone or ASCII effects
|
|
7
|
+
over it or over your own image, or render a single frame to a detached canvas
|
|
7
8
|
for export pipelines. Built by [InstantGradient](https://instantgradient.com/app).
|
|
8
9
|
|
|
9
10
|
## Install
|
|
@@ -51,20 +52,22 @@ import { mountGradient, bloom } from "instantshader";
|
|
|
51
52
|
mountGradient(el, {
|
|
52
53
|
shader: bloom,
|
|
53
54
|
colors: ["#ffd9e8", "#ffb300", "#ff8fc0", "#3d7bff", "#0a2e14"],
|
|
54
|
-
// bloom has two independent motion modes
|
|
55
|
+
// bloom has two independent motion modes: petals that breathe and lean,
|
|
55
56
|
// and colours that travel outward through a still pattern. Mix freely.
|
|
56
57
|
params: { sway: 0.5, colorflow: 0.4 },
|
|
57
58
|
});
|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
Ranges, defaults and labels are all discoverable at runtime
|
|
61
|
+
Ranges, defaults and labels are all discoverable at runtime. `shader.params`
|
|
61
62
|
is an array of `ParamDef`, and `shader.randomParams(rand)` produces a full,
|
|
62
63
|
sensible param set for "randomize" flows. `shaders` and `getShader(id)` expose
|
|
63
64
|
the whole registry (importing either pulls every shader).
|
|
64
65
|
|
|
65
66
|
## Effects
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
An effect redraws a picture: a shader's output, or an image, canvas or video
|
|
69
|
+
frame you supply. Four are included: `pixelate`, `dither`, `halftone` and
|
|
70
|
+
`ascii`.
|
|
68
71
|
|
|
69
72
|
```ts
|
|
70
73
|
import { mountStack, bloom, dither } from "instantshader";
|
|
@@ -77,14 +80,30 @@ mountStack(el, {
|
|
|
77
80
|
});
|
|
78
81
|
```
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
For an image, the source is `{ kind: "media", media: img }` with an optional
|
|
84
|
+
`fit` of `"cover"` (default) or `"contain"`. `effects` is a list, bottom
|
|
85
|
+
layer first. `mountStack` returns the `mountGradient` handle plus
|
|
86
|
+
`setSource`, `setSourceParams`, `setEffects`, `setEffectParams(index, params)`,
|
|
87
|
+
`refreshMedia()` and `getGridInfo()`. `renderStackFrame` renders one frame to
|
|
88
|
+
a detached canvas and `createStackRenderer` is the seekable renderer for
|
|
89
|
+
video export, both with the same options.
|
|
90
|
+
|
|
91
|
+
Each effect's `params` array describes its controls the way `shader.params`
|
|
92
|
+
does, with four kinds: float, enum (a string value from `options`), bool and
|
|
93
|
+
colour (a `#rrggbb` string). A `when` field on a param says which other
|
|
94
|
+
param's value makes it relevant, for building UI. `effects` and
|
|
95
|
+
`getEffect(id)` expose the registry, and importing either pulls every effect.
|
|
96
|
+
|
|
97
|
+
Effect sizes are in pixels at 1080p, and each effect computes one value per
|
|
98
|
+
cell into a buffer that is the same at every output size, so a preview and a
|
|
99
|
+
4K export contain identical cells. The [repository
|
|
100
|
+
README](https://github.com/ugolbck/instantshader#effects) has images, every
|
|
101
|
+
param with its range, and the details of how preview and export line up.
|
|
83
102
|
|
|
84
103
|
## Seamless loops
|
|
85
104
|
|
|
86
105
|
Set `loopSeconds` and the animation repeats exactly, with no visible seam at
|
|
87
|
-
the wrap
|
|
106
|
+
the wrap. The frame at `t` and at `t + loopSeconds` are identical pixel for
|
|
88
107
|
pixel. Built for video export and for backgrounds that must not betray a
|
|
89
108
|
restart.
|
|
90
109
|
|
|
@@ -119,7 +138,7 @@ Notes:
|
|
|
119
138
|
light video file without slowing the animation down.
|
|
120
139
|
- **`flow` ties its travel speed to the loop length.** It animates by
|
|
121
140
|
translating in a straight line through a noise field that tiles, and it
|
|
122
|
-
covers exactly one tile per cycle
|
|
141
|
+
covers exactly one tile per cycle, so a short loop flows fast and a long
|
|
123
142
|
one flows slowly. The hand-tuned drift rate corresponds to a period around
|
|
124
143
|
60–90s; below ~30s the currents move noticeably faster than the look was
|
|
125
144
|
designed for. Compensate with `speed` rather than by shortening the loop.
|
|
@@ -130,7 +149,7 @@ Notes:
|
|
|
130
149
|
slow oscillations (petal breathing ~20s, fan lean ~30s, petal flex ~42s)
|
|
131
150
|
layered over a noise wander. Each oscillation holds still once the loop is
|
|
132
151
|
shorter than about half its own period, so below ~10s the wander is the only
|
|
133
|
-
thing left moving. `colorflow` is unaffected
|
|
152
|
+
thing left moving. `colorflow` is unaffected. It always fits at least one
|
|
134
153
|
full cycle into the loop, flowing faster on a short one.
|
|
135
154
|
- `halo`, `dune` and `whorl` always complete at least one full cycle of their
|
|
136
155
|
main motion per loop, so a short loop simply runs them faster.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantshader",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "Animated WebGL gradient shaders. Zero dependencies.",
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"description": "Animated WebGL gradient shaders, plus dither, pixelate, halftone and ASCII effects. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -33,7 +33,11 @@
|
|
|
33
33
|
"gradient",
|
|
34
34
|
"mesh-gradient",
|
|
35
35
|
"animated-gradient",
|
|
36
|
-
"background"
|
|
36
|
+
"background",
|
|
37
|
+
"dither",
|
|
38
|
+
"halftone",
|
|
39
|
+
"pixelate",
|
|
40
|
+
"ascii"
|
|
37
41
|
],
|
|
38
42
|
"scripts": {
|
|
39
43
|
"build": "tsdown",
|