instantshader 0.7.0 → 0.8.0
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 +38 -20
- package/dist/index.d.ts +16 -1
- package/dist/index.js +719 -203
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
# instantshader
|
|
4
4
|
|
|
5
|
-
Animated WebGL gradient shaders with zero dependencies. Mount a live
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Animated WebGL gradient shaders with zero dependencies. Mount a live gradient
|
|
6
|
+
into any element, draw dither, pixelate, halftone, ASCII or tint effects over
|
|
7
|
+
it or over your own image, or render single frames for export. Built by
|
|
8
|
+
[InstantGradient](https://instantgradient.com/app).
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
@@ -33,17 +33,17 @@ tree-shake away.
|
|
|
33
33
|
|
|
34
34
|
| Shader | Look | Params |
|
|
35
35
|
| --- | --- | --- |
|
|
36
|
-
| `flow` |
|
|
37
|
-
| `beam` | One wide beam of soft light
|
|
38
|
-
| `bloom` | A fan of huge
|
|
39
|
-
| `halo` | An eclipse:
|
|
40
|
-
| `strata` | Stacked cut-paper sheets, one per palette step, each casting a soft shadow on the one below. `ridges` and `stretch`
|
|
41
|
-
| `dune` | Overlapping crests rolling across the frame
|
|
42
|
-
| `whorl` | A
|
|
43
|
-
| `silk` | Satin folds lit from one side, with
|
|
44
|
-
| `nacre` | Glassy liquid folds whose colour
|
|
45
|
-
| `burst` | Thin grainy rays out of one point,
|
|
46
|
-
| `glint` |
|
|
36
|
+
| `flow` | Swirling fluid currents. Colour masses travel in soft eddies with bright edges and calm open space between them. | `scale`, `curl`, `drift`, `openness`, `grain` |
|
|
37
|
+
| `beam` | One wide beam of soft light across a near-black frame. The palette runs along the beam, with thin brighter filaments inside it. | `scale`, `width`, `glow`, `angle`, `grain` |
|
|
38
|
+
| `bloom` | A fan of huge soft petals rising from the bottom edge. The palette forms scalloped bands from a hot core out to a dark background, with thin creases between the petals. | `scale`, `petals`, `pinch`, `bend`, `sway`, `colorflow`, `grain` |
|
|
39
|
+
| `halo` | An eclipse: a dark disc with a bright rim and a corona of streamers, the palette wrapped around the ring. `x` / `y` place the disc; the default sinks it below the frame for a glowing horizon. | `radius`, `x`, `y`, `glow`, `crescent`, `flares`, `grain` |
|
|
40
|
+
| `strata` | Stacked cut-paper sheets, one per palette step, each casting a soft shadow on the one below. `ridges` and `stretch` turn round islands into spines or long bands. | `scale`, `layers`, `warp`, `ridges`, `stretch`, `depth`, `blend`, `angle`, `grain` |
|
|
41
|
+
| `dune` | Overlapping crests rolling across the frame. Each has a crisp top edge and fades out below it. | `layers`, `swell`, `waves`, `fade`, `soft`, `angle`, `grain` |
|
|
42
|
+
| `whorl` | A spiral of curved blades, each with a sharp leading edge and a soft fade behind it. `x` / `y` place the centre anywhere, including off-frame. | `blades`, `twist`, `depth`, `scale`, `wobble`, `x`, `y`, `grain` |
|
|
43
|
+
| `silk` | Satin folds lit from one side, with a sheen that streaks along the threads. | `scale`, `folds`, `depth`, `warp`, `sheen`, `light`, `grain` |
|
|
44
|
+
| `nacre` | Glassy liquid folds whose colour shifts to the neighbouring palette colours on every slope, like mother of pearl. | `scale`, `flow`, `crease`, `depth`, `iridescence`, `light`, `grain` |
|
|
45
|
+
| `burst` | Thin grainy rays out of one point, from a dark tunnel to a white-hot star, straight or twisted into a pinwheel. | `rays`, `sharp`, `glow`, `twist`, `x`, `y`, `grain` |
|
|
46
|
+
| `glint` | Small spinning shards streaming along a curved current on dark, each edge fringed with colour. | `size`, `density`, `bend`, `angle`, `speed`, `grain` |
|
|
47
47
|
|
|
48
48
|
Previews of every look, with full param ranges, are in the
|
|
49
49
|
[repository README](https://github.com/ugolbck/instantshader#readme).
|
|
@@ -70,8 +70,17 @@ the whole registry (importing either pulls every shader).
|
|
|
70
70
|
## Effects
|
|
71
71
|
|
|
72
72
|
An effect redraws a picture: a shader's output, or an image, canvas or video
|
|
73
|
-
frame you supply.
|
|
74
|
-
`ascii`.
|
|
73
|
+
frame you supply. Five are included: `pixelate`, `dither`, `halftone`,
|
|
74
|
+
`ascii` and `tint`.
|
|
75
|
+
|
|
76
|
+
- Halftone and ASCII draw shapes or characters over the picture. `ground`
|
|
77
|
+
picks what is under them: the picture, or a flat `paper` colour.
|
|
78
|
+
- `blend` (`normal`, `multiply`, `screen`, `overlay`, `softLight`,
|
|
79
|
+
`colorDodge`) and `opacity` set how an effect mixes with what is below.
|
|
80
|
+
Pixelate and dither at `blend: "normal"` and `opacity: 1` replace the
|
|
81
|
+
picture.
|
|
82
|
+
- Tint recolours whatever is below it by brightness, in two colours or along
|
|
83
|
+
the palette.
|
|
75
84
|
|
|
76
85
|
```ts
|
|
77
86
|
import { mountStack, bloom, dither } from "instantshader";
|
|
@@ -79,14 +88,23 @@ import { mountStack, bloom, dither } from "instantshader";
|
|
|
79
88
|
mountStack(el, {
|
|
80
89
|
source: { kind: "generator", shader: bloom },
|
|
81
90
|
colors: ["#140f30", "#9c2168", "#eb6a4e", "#fcd87c"],
|
|
82
|
-
effects: [{ effect: dither, params: { pattern: "blueNoise", colorMode: "palette", levels: 4 } }],
|
|
91
|
+
effects: [{ effect: dither, params: { pattern: "blueNoise", colorMode: "palette", levels: 4, blend: "normal", opacity: 1 } }],
|
|
83
92
|
loopSeconds: 30,
|
|
84
93
|
});
|
|
85
94
|
```
|
|
86
95
|
|
|
87
96
|
For an image, the source is `{ kind: "media", media: img }` with an optional
|
|
88
97
|
`fit` of `"cover"` (default) or `"contain"`. `effects` is a list, bottom
|
|
89
|
-
layer first
|
|
98
|
+
layer first, and each effect works on everything below it:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
effects: [
|
|
102
|
+
{ effect: halftone, params: { shape: "dot", size: 16 } },
|
|
103
|
+
{ effect: tint, params: { mode: "palette", amount: 0.6 } },
|
|
104
|
+
],
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
A layer with `enabled: false` is skipped. `mountStack` returns the `mountGradient` handle plus
|
|
90
108
|
`setSource`, `setSourceParams`, `setEffects`, `setEffectParams(index, params)`,
|
|
91
109
|
`refreshMedia()` and `getGridInfo()`. `renderStackFrame` renders one frame to
|
|
92
110
|
a detached canvas and `createStackRenderer` is the seekable renderer for
|
|
@@ -144,7 +162,7 @@ Notes:
|
|
|
144
162
|
translating in a straight line through a noise field that tiles, and it
|
|
145
163
|
covers exactly one tile per cycle, so a short loop flows fast and a long
|
|
146
164
|
one flows slowly. The hand-tuned drift rate corresponds to a period around
|
|
147
|
-
60
|
|
165
|
+
60 to 90s; below ~30s the currents move noticeably faster than the look was
|
|
148
166
|
designed for. Compensate with `speed` rather than by shortening the loop.
|
|
149
167
|
- **`beam` freezes its width swell below ~29s.** Its natural cycle is ~57s and
|
|
150
168
|
cannot be squeezed into a short loop without becoming a throb, so under that
|
package/dist/index.d.ts
CHANGED
|
@@ -251,6 +251,18 @@ type EffectDef = {
|
|
|
251
251
|
lattice?: (params: Record<string, ParamValue>) => {
|
|
252
252
|
angle: number;
|
|
253
253
|
};
|
|
254
|
+
/**
|
|
255
|
+
* The draw stage also reads the layer below at frame size, as
|
|
256
|
+
* `uniform sampler2D u_picture`, for effects that draw over the picture
|
|
257
|
+
* rather than replacing it (halftone's image ground). Shape sizes and
|
|
258
|
+
* colours still come from the cell buffer; only the backdrop is per
|
|
259
|
+
* pixel. A function returns a blur in reference px applied to that
|
|
260
|
+
* picture (0 = none), or null when this configuration does not read the
|
|
261
|
+
* picture, so the stack skips rendering it.
|
|
262
|
+
*/
|
|
263
|
+
picture?: true | ((params: Record<string, ParamValue>) => {
|
|
264
|
+
blur: number;
|
|
265
|
+
} | null);
|
|
254
266
|
fragment: string;
|
|
255
267
|
};
|
|
256
268
|
textures?: EffectTexture[];
|
|
@@ -364,6 +376,9 @@ declare const halftone: EffectDef;
|
|
|
364
376
|
//#region src/effects/ascii.d.ts
|
|
365
377
|
declare const ascii: EffectDef;
|
|
366
378
|
//#endregion
|
|
379
|
+
//#region src/effects/tint.d.ts
|
|
380
|
+
declare const tint: EffectDef;
|
|
381
|
+
//#endregion
|
|
367
382
|
//#region src/registry.d.ts
|
|
368
383
|
declare const shaders: readonly ShaderDef[];
|
|
369
384
|
declare function getShader(id: string): ShaderDef | undefined;
|
|
@@ -485,4 +500,4 @@ declare function gridFor(width: number, height: number, cell: [number, number],
|
|
|
485
500
|
*/
|
|
486
501
|
declare function buildPaletteRamp(colors: string[]): Uint8Array;
|
|
487
502
|
//#endregion
|
|
488
|
-
export { type BoolParamDef, type ColorParamDef, type EffectDef, type EffectLayer, type EffectParamDef, type EffectTexture, type EnumParamDef, type FloatParamDef, type GeneratorDef, type Grid, type GridInfo, type MountHandle, type MountOptions, type ParamDef, type ParamValue, type RenderFrameResult, type Renderer, type RendererOptions, type ShaderDef, type Source, type StackHandle, type StackMountOptions, type StackOptions, type StackRenderer, type TextureData, type TextureEnv, ascii, beam, bloom, buildPaletteRamp, burst, createRenderer, createStackRenderer, dither, dune, effects, flow, getEffect, getShader, glint, gridFor, halftone, halo, mountGradient, mountStack, nacre, pixelate, renderGradientFrame, renderStackFrame, shaders, silk, strata, whorl };
|
|
503
|
+
export { type BoolParamDef, type ColorParamDef, type EffectDef, type EffectLayer, type EffectParamDef, type EffectTexture, type EnumParamDef, type FloatParamDef, type GeneratorDef, type Grid, type GridInfo, type MountHandle, type MountOptions, type ParamDef, type ParamValue, type RenderFrameResult, type Renderer, type RendererOptions, type ShaderDef, type Source, type StackHandle, type StackMountOptions, type StackOptions, type StackRenderer, type TextureData, type TextureEnv, ascii, beam, bloom, buildPaletteRamp, burst, createRenderer, createStackRenderer, dither, dune, effects, flow, getEffect, getShader, glint, gridFor, halftone, halo, mountGradient, mountStack, nacre, pixelate, renderGradientFrame, renderStackFrame, shaders, silk, strata, tint, whorl };
|