@vfx-js/effects 1.0.0 → 1.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @vfx-js/effects
2
2
 
3
- Ready-made WebGL effects for [`@vfx-js/core`](https://www.npmjs.com/package/@vfx-js/core).
3
+ Prebuilt WebGL effects for [`@vfx-js/core`](https://www.npmjs.com/package/@vfx-js/core).
4
4
 
5
5
  ## Install
6
6
 
@@ -45,10 +45,12 @@ await vfx.add(img, {
45
45
  | `BloomEffect` | COD:AW-style bloom pyramid with soft-knee threshold |
46
46
  | `FluidEffect` | Stable-Fluids advection driven by pointer events |
47
47
  | `HalftoneEffect` | RGB / CMYK halftone screen with configurable ink presets |
48
+ | `JPEGGlitchEffect` | Real codec-level JPEG glitch — corrupts the encoded byte stream |
48
49
  | `ParticleEffect` | Mouse-emitter GPU particles, skips transparent source regions |
49
50
  | `ParticleExplodeEffect` | One-shot curl-noise burst that shatters the source element |
50
51
  | `VoronoiEffect` | Voronoi cells shrunken in a halo around the cursor |
51
52
  | `PixelateEffect` | Nearest-neighbour pixelation |
53
+ | `PixelSortEffect` | Threshold pixel sort, with optional arbitrary sort angle |
52
54
  | `ScanlineEffect` | CRT scanline overlay |
53
55
 
54
56
  See the [Storybook demos](https://amagi.dev/vfx-js/storybook) for live examples.
@@ -0,0 +1,25 @@
1
+ import type { Effect, EffectContext } from "@vfx-js/core";
2
+ export type BadJpegEffectOptions = {
3
+ quality?: number;
4
+ iterations?: number;
5
+ downscale?: number;
6
+ };
7
+ /**
8
+ * Simulates JPEG degradation: chroma subsampling, blocky DCT quantization,
9
+ * and generation loss from re-encoding the result `iterations` times.
10
+ * Mutate `quality` / `iterations` / `downscale` directly for runtime tweaks.
11
+ *
12
+ * @see GABIBI https://amix-design.com/tl/tool-gabibi/
13
+ * @see DCT glitch https://qiita.com/FMS_Cat/items/6943c708a875984228b9
14
+ */
15
+ export declare class BadJpegEffect implements Effect {
16
+ quality: number;
17
+ iterations: number;
18
+ downscale: number;
19
+ private lowRes;
20
+ constructor({ quality, iterations, downscale, }?: BadJpegEffectOptions);
21
+ private ensureLowRes;
22
+ private disposeLowRes;
23
+ render(ctx: EffectContext): void;
24
+ dispose(): void;
25
+ }
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BadJpegEffect = void 0;
4
+ // The 2D 8x8 DCT is separable: a rows pass then a columns pass, 8 taps each.
5
+ // All passes run premultiplied so transparent texels don't bleed into the DCT
6
+ // or chroma subsampling; alpha rides along as a 4th plane using the luma table.
7
+ const HEADER = `#version 300 es
8
+ precision highp float;
9
+ in vec2 uvSrc;
10
+ out vec4 outColor;
11
+ uniform sampler2D src;
12
+ `;
13
+ const DCT = `
14
+ const float PI = 3.141592653589793;
15
+ float cc(int k){ return k == 0 ? 0.7071067811865476 : 1.0; }
16
+ `;
17
+ const YCC = `
18
+ vec3 rgb2ycc(vec3 c){
19
+ return vec3(
20
+ 0.299*c.r + 0.587*c.g + 0.114*c.b,
21
+ -0.168736*c.r - 0.331264*c.g + 0.5*c.b,
22
+ 0.5*c.r - 0.418688*c.g - 0.081312*c.b);
23
+ }
24
+ vec3 ycc2rgb(vec3 y){
25
+ return vec3(
26
+ y.x + 1.402 * y.z,
27
+ y.x - 0.344136* y.y - 0.714136 * y.z,
28
+ y.x + 1.772 * y.y);
29
+ }
30
+ `;
31
+ // b = 8x8 block origin, l = position within the block
32
+ const BLOCK = `
33
+ ivec2 res = textureSize(src, 0);
34
+ ivec2 p = ivec2(uvSrc * vec2(res));
35
+ ivec2 b = (p / 8) * 8;
36
+ ivec2 l = p - b;
37
+ `;
38
+ /* straight-alpha capture -> premultiplied low-res raster */
39
+ const PRE = `${HEADER}
40
+ void main(){
41
+ vec4 c = texture(src, uvSrc);
42
+ outColor = vec4(c.rgb * c.a, c.a);
43
+ }`;
44
+ /* forward DCT, rows: RGB->YCbCr, level-shift, 1D DCT across x */
45
+ const FWDH = `${HEADER}${DCT}${YCC}
46
+ void main(){
47
+ ${BLOCK}
48
+ vec4 sum = vec4(0.0);
49
+ for (int x = 0; x < 8; x++) {
50
+ vec4 t = texelFetch(src, clamp(b + ivec2(x, l.y), ivec2(0), res - 1), 0);
51
+ vec4 f = (vec4(rgb2ycc(t.rgb), t.a) - vec4(0.5, 0.0, 0.0, 0.5)) * 255.0;
52
+ sum += f * cos(float(2*x+1) * float(l.x) * PI / 16.0);
53
+ }
54
+ outColor = sum * 0.5 * cc(l.x);
55
+ }`;
56
+ /* forward DCT, columns: 1D DCT across y -> full DCT coefficients */
57
+ const FWDV = `${HEADER}${DCT}
58
+ void main(){
59
+ ${BLOCK}
60
+ vec4 sum = vec4(0.0);
61
+ for (int y = 0; y < 8; y++)
62
+ sum += texelFetch(src, clamp(b + ivec2(l.x, y), ivec2(0), res - 1), 0)
63
+ * cos(float(2*y+1) * float(l.y) * PI / 16.0);
64
+ outColor = sum * 0.5 * cc(l.y);
65
+ }`;
66
+ /* inverse pass 1: quantize each coeff, 1D iDCT across columns */
67
+ const INVV = `${HEADER}${DCT}
68
+ uniform float uS; // libjpeg quality scale
69
+ const float LQ[64] = float[64](
70
+ 16.,11.,10.,16.,24.,40.,51.,61., 12.,12.,14.,19.,26.,58.,60.,55.,
71
+ 14.,13.,16.,24.,40.,57.,69.,56., 14.,17.,22.,29.,51.,87.,80.,62.,
72
+ 18.,22.,37.,56.,68.,109.,103.,77., 24.,35.,55.,64.,81.,104.,113.,92.,
73
+ 49.,64.,78.,87.,103.,121.,120.,101., 72.,92.,95.,98.,112.,100.,103.,99.);
74
+ const float CQ[64] = float[64](
75
+ 17.,18.,24.,47.,99.,99.,99.,99., 18.,21.,26.,66.,99.,99.,99.,99.,
76
+ 24.,26.,56.,99.,99.,99.,99.,99., 47.,66.,99.,99.,99.,99.,99.,99.,
77
+ 99.,99.,99.,99.,99.,99.,99.,99., 99.,99.,99.,99.,99.,99.,99.,99.,
78
+ 99.,99.,99.,99.,99.,99.,99.,99., 99.,99.,99.,99.,99.,99.,99.,99.);
79
+ float qstep(float base){ return clamp(floor((base * uS + 50.0) / 100.0), 1.0, 255.0); }
80
+ void main(){
81
+ ${BLOCK}
82
+ vec4 sum = vec4(0.0);
83
+ for (int v = 0; v < 8; v++) {
84
+ int idx = v * 8 + l.x;
85
+ vec4 F = texelFetch(src, clamp(b + ivec2(l.x, v), ivec2(0), res - 1), 0);
86
+ vec4 q = vec4(qstep(LQ[idx]), qstep(CQ[idx]), qstep(CQ[idx]), qstep(LQ[idx]));
87
+ sum += cc(v) * round(F / q) * q * cos(float(2*l.y+1) * float(v) * PI / 16.0);
88
+ }
89
+ outColor = sum * 0.5;
90
+ }`;
91
+ /* inverse pass 2: 1D iDCT across rows, un-shift, YCbCr->RGB (still premultiplied) */
92
+ const INVH = `${HEADER}${DCT}${YCC}
93
+ void main(){
94
+ ${BLOCK}
95
+ vec4 sum = vec4(0.0);
96
+ for (int u = 0; u < 8; u++)
97
+ sum += cc(u) * texelFetch(src, clamp(b + ivec2(u, l.y), ivec2(0), res - 1), 0)
98
+ * cos(float(2*l.x+1) * float(u) * PI / 16.0);
99
+ sum = sum * 0.5 / 255.0 + vec4(0.5, 0.0, 0.0, 0.5);
100
+ outColor = clamp(vec4(ycc2rgb(sum.xyz), sum.w), 0.0, 1.0);
101
+ }`;
102
+ /* 4:2:0 chroma subsample: box-downsample Cb/Cr to half res, bilinear upsample.
103
+ Not a fixed point — chroma blurs further each pass, so the loop accumulates. */
104
+ const SUB = `${HEADER}${YCC}
105
+ vec2 cellChroma(ivec2 res, ivec2 cell){
106
+ vec2 s = vec2(0.0);
107
+ for (int j = 0; j < 2; j++)
108
+ for (int i = 0; i < 2; i++) {
109
+ ivec2 ip = clamp(cell * 2 + ivec2(i, j), ivec2(0), res - 1);
110
+ s += rgb2ycc(texelFetch(src, ip, 0).rgb).yz;
111
+ }
112
+ return s * 0.25;
113
+ }
114
+ void main(){
115
+ ivec2 res = textureSize(src, 0);
116
+ ivec2 p = ivec2(uvSrc * vec2(res));
117
+ vec4 c0 = texelFetch(src, clamp(p, ivec2(0), res - 1), 0);
118
+ float Y = rgb2ycc(c0.rgb).x; // luma stays full-res
119
+ vec2 gpos = (vec2(p) + 0.5) * 0.5 - 0.5; // position on the half-res chroma grid
120
+ vec2 gi = floor(gpos);
121
+ vec2 f = gpos - gi;
122
+ ivec2 c = ivec2(gi);
123
+ vec2 cb = mix(
124
+ mix(cellChroma(res, c + ivec2(0,0)), cellChroma(res, c + ivec2(1,0)), f.x),
125
+ mix(cellChroma(res, c + ivec2(0,1)), cellChroma(res, c + ivec2(1,1)), f.x), f.y);
126
+ outColor = vec4(clamp(ycc2rgb(vec3(Y, cb)), 0.0, 1.0), c0.a);
127
+ }`;
128
+ const LOW_RES_KEYS = ["coeff", "tmp", "sub", "a", "b"];
129
+ /**
130
+ * Simulates JPEG degradation: chroma subsampling, blocky DCT quantization,
131
+ * and generation loss from re-encoding the result `iterations` times.
132
+ * Mutate `quality` / `iterations` / `downscale` directly for runtime tweaks.
133
+ *
134
+ * @see GABIBI https://amix-design.com/tl/tool-gabibi/
135
+ * @see DCT glitch https://qiita.com/FMS_Cat/items/6943c708a875984228b9
136
+ */
137
+ class BadJpegEffect {
138
+ constructor({ quality = 8, iterations = 3, downscale = 1.0, } = {}) {
139
+ this.lowRes = null;
140
+ this.quality = quality;
141
+ this.iterations = iterations;
142
+ this.downscale = downscale;
143
+ }
144
+ // Low-res RT set sized floor(element * downscale); reallocated when dims change.
145
+ ensureLowRes(ctx, w, h) {
146
+ if (this.lowRes && this.lowRes.w === w && this.lowRes.h === h) {
147
+ return this.lowRes;
148
+ }
149
+ this.disposeLowRes();
150
+ const size = [w, h];
151
+ this.lowRes = {
152
+ w,
153
+ h,
154
+ coeff: ctx.createRenderTarget({ float: true, size }), // DCT coeffs (signed, large)
155
+ tmp: ctx.createRenderTarget({ float: true, size }), // separable scratch
156
+ sub: ctx.createRenderTarget({ size }), // chroma-subsampled spatial RGB
157
+ a: ctx.createRenderTarget({ size }), // 8-bit ping-pong (generation loss)
158
+ b: ctx.createRenderTarget({ size }),
159
+ };
160
+ return this.lowRes;
161
+ }
162
+ disposeLowRes() {
163
+ if (this.lowRes) {
164
+ for (const k of LOW_RES_KEYS) {
165
+ this.lowRes[k].dispose();
166
+ }
167
+ this.lowRes = null;
168
+ }
169
+ }
170
+ render(ctx) {
171
+ const N = Math.max(1, Math.min(10, this.iterations | 0));
172
+ const q = Math.max(1, Math.min(100, this.quality));
173
+ const S = q < 50 ? 5000 / q : 200 - 2 * q;
174
+ const ds = Math.max(0.02, Math.min(1, this.downscale));
175
+ // element size in CSS px, so the 8x8 block scale is DPI-independent
176
+ const [W, H] = ctx.dims.element;
177
+ const lw = Math.max(1, Math.floor(W * ds));
178
+ const lh = Math.max(1, Math.floor(H * ds));
179
+ const lowRes = this.ensureLowRes(ctx, lw, lh);
180
+ // premultiply + shrink source onto the low-res raster
181
+ ctx.draw({ frag: PRE, uniforms: { src: ctx.src }, target: lowRes.a });
182
+ let input = lowRes.a;
183
+ // JPEG-degrade loop, entirely at low res
184
+ for (let k = 0; k < N; k++) {
185
+ ctx.draw({
186
+ frag: SUB,
187
+ uniforms: { src: input },
188
+ target: lowRes.sub,
189
+ });
190
+ ctx.draw({
191
+ frag: FWDH,
192
+ uniforms: { src: lowRes.sub },
193
+ target: lowRes.tmp,
194
+ });
195
+ ctx.draw({
196
+ frag: FWDV,
197
+ uniforms: { src: lowRes.tmp },
198
+ target: lowRes.coeff,
199
+ });
200
+ ctx.draw({
201
+ frag: INVV,
202
+ uniforms: { src: lowRes.coeff, uS: S },
203
+ target: lowRes.tmp,
204
+ });
205
+ const out = k % 2 === 0 ? lowRes.b : lowRes.a;
206
+ ctx.draw({
207
+ frag: INVH,
208
+ uniforms: { src: lowRes.tmp },
209
+ target: out,
210
+ });
211
+ input = out;
212
+ }
213
+ // bilinear up-scale back to full output for the soft look
214
+ ctx.blit(input, ctx.target);
215
+ }
216
+ dispose() {
217
+ this.disposeLowRes();
218
+ }
219
+ }
220
+ exports.BadJpegEffect = BadJpegEffect;
221
+ //# sourceMappingURL=bad-jpeg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bad-jpeg.js","sourceRoot":"","sources":["../../src/bad-jpeg.ts"],"names":[],"mappings":";;;AAEA,6EAA6E;AAC7E,8EAA8E;AAC9E,gFAAgF;AAEhF,MAAM,MAAM,GAAG;;;;;CAKd,CAAC;AAEF,MAAM,GAAG,GAAG;;;CAGX,CAAC;AAEF,MAAM,GAAG,GAAG;;;;;;;;;;;;;CAaX,CAAC;AAEF,sDAAsD;AACtD,MAAM,KAAK,GAAG;;;;;CAKb,CAAC;AAEF,4DAA4D;AAC5D,MAAM,GAAG,GAAG,GAAG,MAAM;;;;EAInB,CAAC;AAEH,iEAAiE;AACjE,MAAM,IAAI,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,GAAG;;EAEhC,KAAK;;;;;;;;EAQL,CAAC;AAEH,oEAAoE;AACpE,MAAM,IAAI,GAAG,GAAG,MAAM,GAAG,GAAG;;EAE1B,KAAK;;;;;;EAML,CAAC;AAEH,iEAAiE;AACjE,MAAM,IAAI,GAAG,GAAG,MAAM,GAAG,GAAG;;;;;;;;;;;;;;EAc1B,KAAK;;;;;;;;;EASL,CAAC;AAEH,qFAAqF;AACrF,MAAM,IAAI,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,GAAG;;EAEhC,KAAK;;;;;;;EAOL,CAAC;AAEH;kFACkF;AAClF,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;EAuBzB,CAAC;AAkBH,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAa,aAAa;IAMtB,YAAY,EACR,OAAO,GAAG,CAAC,EACX,UAAU,GAAG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AK,GAAG,GAAG,CAAC;QAChB,CAAC;QAED,0DAA0D;QAC1D,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,OAAO;QACH,IAAI,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC;CACJ;AAtGD,sCAsGC"}
@@ -0,0 +1,43 @@
1
+ import type { Effect, EffectContext } from "@vfx-js/core";
2
+ export type DatamoshColorSpace = "rgb" | "ycbcr";
3
+ /** Stage routed to the canvas; non-`output` views are for debugging. */
4
+ export type DatamoshView = "output" | "motion" | "residual" | "current" | "previous";
5
+ export type DatamoshParams = {
6
+ /** Motion-estimation block size in px. */
7
+ blockSize: number;
8
+ /** Motion search radius, in steps. Coverage = searchRange * searchStep px. */
9
+ searchRange: number;
10
+ /** Pixels per search step. Widens coverage at a fixed candidate count. */
11
+ searchStep: number;
12
+ /** Add the residual during decode (off = pure motion). */
13
+ useResidual: boolean;
14
+ /**
15
+ * P-frame duplication: re-apply the frame's motion this many extra
16
+ * times per frame, dragging the accumulator further along the field
17
+ * (the bloom/smear amplifier). 0 = one normal application.
18
+ */
19
+ dup: number;
20
+ /** Color model. `"ycbcr"` is 4:2:0 (half-res chroma w/ truncated MV). */
21
+ colorSpace: DatamoshColorSpace;
22
+ /** Chroma saturation boost (YCbCr output). 1 = unchanged. */
23
+ chromaGain: number;
24
+ /** Stage shown on the canvas. */
25
+ view: DatamoshView;
26
+ };
27
+ /**
28
+ * Pseudo-datamosh via a faked H.264 block codec. Passes the input
29
+ * through until `enable()`, then holds a motion-compensated accumulator
30
+ * so motion smears stale texture around. Mutate `params` directly or via
31
+ * `setParams`; toggle the mosh with `enable()` / `disable()`.
32
+ */
33
+ export declare class DatamoshEffect implements Effect {
34
+ #private;
35
+ params: DatamoshParams;
36
+ constructor(initial?: Partial<DatamoshParams>);
37
+ setParams(partial: Partial<DatamoshParams>): void;
38
+ enable(): void;
39
+ disable(): void;
40
+ get enabled(): boolean;
41
+ render(ctx: EffectContext): void;
42
+ dispose(): void;
43
+ }