@vfx-js/effects 1.1.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.
@@ -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,IA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AAC,IAAI,CAAC;gBACL,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE;gBACtC,MAAM,EAAE,MAAM,CAAC,GAAG;aACrB,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YAC9C,GAAG,CAAC,IAAI,CAAC;gBACL,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE;gBAC7B,MAAM,EAAE,GAAG;aACd,CAAC,CAAC;YACH,KAAK,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"}
@@ -1,3 +1,4 @@
1
+ export { BadJpegEffect, type BadJpegEffectOptions } from "./bad-jpeg";
1
2
  export { BloomEffect } from "./bloom";
2
3
  export { type DatamoshColorSpace, DatamoshEffect, type DatamoshParams, type DatamoshView, } from "./datamosh";
3
4
  export { FluidEffect } from "./fluid";
package/lib/cjs/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VoronoiEffect = exports.ScanlineEffect = exports.PixelSortEffect = exports.PixelateEffect = exports.ParticleExplodeEffect = exports.ParticleEffect = exports.JPEGGlitchEffect = exports.HalftoneEffect = exports.FluidEffect = exports.DatamoshEffect = exports.BloomEffect = void 0;
3
+ exports.VoronoiEffect = exports.ScanlineEffect = exports.PixelSortEffect = exports.PixelateEffect = exports.ParticleExplodeEffect = exports.ParticleEffect = exports.JPEGGlitchEffect = exports.HalftoneEffect = exports.FluidEffect = exports.DatamoshEffect = exports.BloomEffect = exports.BadJpegEffect = void 0;
4
+ var bad_jpeg_1 = require("./bad-jpeg");
5
+ Object.defineProperty(exports, "BadJpegEffect", { enumerable: true, get: function () { return bad_jpeg_1.BadJpegEffect; } });
4
6
  var bloom_1 = require("./bloom");
5
7
  Object.defineProperty(exports, "BloomEffect", { enumerable: true, get: function () { return bloom_1.BloomEffect; } });
6
8
  var datamosh_1 = require("./datamosh");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,uCAKoB;AAHhB,0GAAA,cAAc,OAAA;AAIlB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,uCAAwE;AAA/D,0GAAA,cAAc,OAAA;AACvB,6CAAwE;AAA/D,+GAAA,gBAAgB,OAAA;AACzB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,uDAA2D;AAAlD,yHAAA,qBAAqB,OAAA;AAC9B,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,yCAKqB;AAHjB,4GAAA,eAAe,OAAA;AAInB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAAsE;AAA7D,yGAAA,aAAa,OAAA;AACtB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,uCAKoB;AAHhB,0GAAA,cAAc,OAAA;AAIlB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,uCAAwE;AAA/D,0GAAA,cAAc,OAAA;AACvB,6CAAwE;AAA/D,+GAAA,gBAAgB,OAAA;AACzB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,uDAA2D;AAAlD,yHAAA,qBAAqB,OAAA;AAC9B,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,yCAKqB;AAHjB,4GAAA,eAAe,OAAA;AAInB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vfx-js/effects",
3
3
  "description": "Ready-made WebGL effects for @vfx-js/core",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "files": [
6
6
  "package.json",
7
7
  "README.md",
@@ -22,7 +22,7 @@
22
22
  "lint-staged": "lint-staged"
23
23
  },
24
24
  "peerDependencies": {
25
- "@vfx-js/core": ">=1.0.0"
25
+ "@vfx-js/core": ">=1.1.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@biomejs/biome": "2.4.11",
@@ -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,217 @@
1
+ // The 2D 8x8 DCT is separable: a rows pass then a columns pass, 8 taps each.
2
+ // All passes run premultiplied so transparent texels don't bleed into the DCT
3
+ // or chroma subsampling; alpha rides along as a 4th plane using the luma table.
4
+ const HEADER = `#version 300 es
5
+ precision highp float;
6
+ in vec2 uvSrc;
7
+ out vec4 outColor;
8
+ uniform sampler2D src;
9
+ `;
10
+ const DCT = `
11
+ const float PI = 3.141592653589793;
12
+ float cc(int k){ return k == 0 ? 0.7071067811865476 : 1.0; }
13
+ `;
14
+ const YCC = `
15
+ vec3 rgb2ycc(vec3 c){
16
+ return vec3(
17
+ 0.299*c.r + 0.587*c.g + 0.114*c.b,
18
+ -0.168736*c.r - 0.331264*c.g + 0.5*c.b,
19
+ 0.5*c.r - 0.418688*c.g - 0.081312*c.b);
20
+ }
21
+ vec3 ycc2rgb(vec3 y){
22
+ return vec3(
23
+ y.x + 1.402 * y.z,
24
+ y.x - 0.344136* y.y - 0.714136 * y.z,
25
+ y.x + 1.772 * y.y);
26
+ }
27
+ `;
28
+ // b = 8x8 block origin, l = position within the block
29
+ const BLOCK = `
30
+ ivec2 res = textureSize(src, 0);
31
+ ivec2 p = ivec2(uvSrc * vec2(res));
32
+ ivec2 b = (p / 8) * 8;
33
+ ivec2 l = p - b;
34
+ `;
35
+ /* straight-alpha capture -> premultiplied low-res raster */
36
+ const PRE = `${HEADER}
37
+ void main(){
38
+ vec4 c = texture(src, uvSrc);
39
+ outColor = vec4(c.rgb * c.a, c.a);
40
+ }`;
41
+ /* forward DCT, rows: RGB->YCbCr, level-shift, 1D DCT across x */
42
+ const FWDH = `${HEADER}${DCT}${YCC}
43
+ void main(){
44
+ ${BLOCK}
45
+ vec4 sum = vec4(0.0);
46
+ for (int x = 0; x < 8; x++) {
47
+ vec4 t = texelFetch(src, clamp(b + ivec2(x, l.y), ivec2(0), res - 1), 0);
48
+ vec4 f = (vec4(rgb2ycc(t.rgb), t.a) - vec4(0.5, 0.0, 0.0, 0.5)) * 255.0;
49
+ sum += f * cos(float(2*x+1) * float(l.x) * PI / 16.0);
50
+ }
51
+ outColor = sum * 0.5 * cc(l.x);
52
+ }`;
53
+ /* forward DCT, columns: 1D DCT across y -> full DCT coefficients */
54
+ const FWDV = `${HEADER}${DCT}
55
+ void main(){
56
+ ${BLOCK}
57
+ vec4 sum = vec4(0.0);
58
+ for (int y = 0; y < 8; y++)
59
+ sum += texelFetch(src, clamp(b + ivec2(l.x, y), ivec2(0), res - 1), 0)
60
+ * cos(float(2*y+1) * float(l.y) * PI / 16.0);
61
+ outColor = sum * 0.5 * cc(l.y);
62
+ }`;
63
+ /* inverse pass 1: quantize each coeff, 1D iDCT across columns */
64
+ const INVV = `${HEADER}${DCT}
65
+ uniform float uS; // libjpeg quality scale
66
+ const float LQ[64] = float[64](
67
+ 16.,11.,10.,16.,24.,40.,51.,61., 12.,12.,14.,19.,26.,58.,60.,55.,
68
+ 14.,13.,16.,24.,40.,57.,69.,56., 14.,17.,22.,29.,51.,87.,80.,62.,
69
+ 18.,22.,37.,56.,68.,109.,103.,77., 24.,35.,55.,64.,81.,104.,113.,92.,
70
+ 49.,64.,78.,87.,103.,121.,120.,101., 72.,92.,95.,98.,112.,100.,103.,99.);
71
+ const float CQ[64] = float[64](
72
+ 17.,18.,24.,47.,99.,99.,99.,99., 18.,21.,26.,66.,99.,99.,99.,99.,
73
+ 24.,26.,56.,99.,99.,99.,99.,99., 47.,66.,99.,99.,99.,99.,99.,99.,
74
+ 99.,99.,99.,99.,99.,99.,99.,99., 99.,99.,99.,99.,99.,99.,99.,99.,
75
+ 99.,99.,99.,99.,99.,99.,99.,99., 99.,99.,99.,99.,99.,99.,99.,99.);
76
+ float qstep(float base){ return clamp(floor((base * uS + 50.0) / 100.0), 1.0, 255.0); }
77
+ void main(){
78
+ ${BLOCK}
79
+ vec4 sum = vec4(0.0);
80
+ for (int v = 0; v < 8; v++) {
81
+ int idx = v * 8 + l.x;
82
+ vec4 F = texelFetch(src, clamp(b + ivec2(l.x, v), ivec2(0), res - 1), 0);
83
+ vec4 q = vec4(qstep(LQ[idx]), qstep(CQ[idx]), qstep(CQ[idx]), qstep(LQ[idx]));
84
+ sum += cc(v) * round(F / q) * q * cos(float(2*l.y+1) * float(v) * PI / 16.0);
85
+ }
86
+ outColor = sum * 0.5;
87
+ }`;
88
+ /* inverse pass 2: 1D iDCT across rows, un-shift, YCbCr->RGB (still premultiplied) */
89
+ const INVH = `${HEADER}${DCT}${YCC}
90
+ void main(){
91
+ ${BLOCK}
92
+ vec4 sum = vec4(0.0);
93
+ for (int u = 0; u < 8; u++)
94
+ sum += cc(u) * texelFetch(src, clamp(b + ivec2(u, l.y), ivec2(0), res - 1), 0)
95
+ * cos(float(2*l.x+1) * float(u) * PI / 16.0);
96
+ sum = sum * 0.5 / 255.0 + vec4(0.5, 0.0, 0.0, 0.5);
97
+ outColor = clamp(vec4(ycc2rgb(sum.xyz), sum.w), 0.0, 1.0);
98
+ }`;
99
+ /* 4:2:0 chroma subsample: box-downsample Cb/Cr to half res, bilinear upsample.
100
+ Not a fixed point — chroma blurs further each pass, so the loop accumulates. */
101
+ const SUB = `${HEADER}${YCC}
102
+ vec2 cellChroma(ivec2 res, ivec2 cell){
103
+ vec2 s = vec2(0.0);
104
+ for (int j = 0; j < 2; j++)
105
+ for (int i = 0; i < 2; i++) {
106
+ ivec2 ip = clamp(cell * 2 + ivec2(i, j), ivec2(0), res - 1);
107
+ s += rgb2ycc(texelFetch(src, ip, 0).rgb).yz;
108
+ }
109
+ return s * 0.25;
110
+ }
111
+ void main(){
112
+ ivec2 res = textureSize(src, 0);
113
+ ivec2 p = ivec2(uvSrc * vec2(res));
114
+ vec4 c0 = texelFetch(src, clamp(p, ivec2(0), res - 1), 0);
115
+ float Y = rgb2ycc(c0.rgb).x; // luma stays full-res
116
+ vec2 gpos = (vec2(p) + 0.5) * 0.5 - 0.5; // position on the half-res chroma grid
117
+ vec2 gi = floor(gpos);
118
+ vec2 f = gpos - gi;
119
+ ivec2 c = ivec2(gi);
120
+ vec2 cb = mix(
121
+ mix(cellChroma(res, c + ivec2(0,0)), cellChroma(res, c + ivec2(1,0)), f.x),
122
+ mix(cellChroma(res, c + ivec2(0,1)), cellChroma(res, c + ivec2(1,1)), f.x), f.y);
123
+ outColor = vec4(clamp(ycc2rgb(vec3(Y, cb)), 0.0, 1.0), c0.a);
124
+ }`;
125
+ const LOW_RES_KEYS = ["coeff", "tmp", "sub", "a", "b"];
126
+ /**
127
+ * Simulates JPEG degradation: chroma subsampling, blocky DCT quantization,
128
+ * and generation loss from re-encoding the result `iterations` times.
129
+ * Mutate `quality` / `iterations` / `downscale` directly for runtime tweaks.
130
+ *
131
+ * @see GABIBI https://amix-design.com/tl/tool-gabibi/
132
+ * @see DCT glitch https://qiita.com/FMS_Cat/items/6943c708a875984228b9
133
+ */
134
+ export class BadJpegEffect {
135
+ constructor({ quality = 8, iterations = 3, downscale = 1.0, } = {}) {
136
+ this.lowRes = null;
137
+ this.quality = quality;
138
+ this.iterations = iterations;
139
+ this.downscale = downscale;
140
+ }
141
+ // Low-res RT set sized floor(element * downscale); reallocated when dims change.
142
+ ensureLowRes(ctx, w, h) {
143
+ if (this.lowRes && this.lowRes.w === w && this.lowRes.h === h) {
144
+ return this.lowRes;
145
+ }
146
+ this.disposeLowRes();
147
+ const size = [w, h];
148
+ this.lowRes = {
149
+ w,
150
+ h,
151
+ coeff: ctx.createRenderTarget({ float: true, size }), // DCT coeffs (signed, large)
152
+ tmp: ctx.createRenderTarget({ float: true, size }), // separable scratch
153
+ sub: ctx.createRenderTarget({ size }), // chroma-subsampled spatial RGB
154
+ a: ctx.createRenderTarget({ size }), // 8-bit ping-pong (generation loss)
155
+ b: ctx.createRenderTarget({ size }),
156
+ };
157
+ return this.lowRes;
158
+ }
159
+ disposeLowRes() {
160
+ if (this.lowRes) {
161
+ for (const k of LOW_RES_KEYS) {
162
+ this.lowRes[k].dispose();
163
+ }
164
+ this.lowRes = null;
165
+ }
166
+ }
167
+ render(ctx) {
168
+ const N = Math.max(1, Math.min(10, this.iterations | 0));
169
+ const q = Math.max(1, Math.min(100, this.quality));
170
+ const S = q < 50 ? 5000 / q : 200 - 2 * q;
171
+ const ds = Math.max(0.02, Math.min(1, this.downscale));
172
+ // element size in CSS px, so the 8x8 block scale is DPI-independent
173
+ const [W, H] = ctx.dims.element;
174
+ const lw = Math.max(1, Math.floor(W * ds));
175
+ const lh = Math.max(1, Math.floor(H * ds));
176
+ const lowRes = this.ensureLowRes(ctx, lw, lh);
177
+ // premultiply + shrink source onto the low-res raster
178
+ ctx.draw({ frag: PRE, uniforms: { src: ctx.src }, target: lowRes.a });
179
+ let input = lowRes.a;
180
+ // JPEG-degrade loop, entirely at low res
181
+ for (let k = 0; k < N; k++) {
182
+ ctx.draw({
183
+ frag: SUB,
184
+ uniforms: { src: input },
185
+ target: lowRes.sub,
186
+ });
187
+ ctx.draw({
188
+ frag: FWDH,
189
+ uniforms: { src: lowRes.sub },
190
+ target: lowRes.tmp,
191
+ });
192
+ ctx.draw({
193
+ frag: FWDV,
194
+ uniforms: { src: lowRes.tmp },
195
+ target: lowRes.coeff,
196
+ });
197
+ ctx.draw({
198
+ frag: INVV,
199
+ uniforms: { src: lowRes.coeff, uS: S },
200
+ target: lowRes.tmp,
201
+ });
202
+ const out = k % 2 === 0 ? lowRes.b : lowRes.a;
203
+ ctx.draw({
204
+ frag: INVH,
205
+ uniforms: { src: lowRes.tmp },
206
+ target: out,
207
+ });
208
+ input = out;
209
+ }
210
+ // bilinear up-scale back to full output for the soft look
211
+ ctx.blit(input, ctx.target);
212
+ }
213
+ dispose() {
214
+ this.disposeLowRes();
215
+ }
216
+ }
217
+ //# 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;;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L,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE;gBAC7B,MAAM,EAAE,MAAM,CAAC,GAAG;aACrB,CAAC,CAAC;YACH,GAAG,CAAC,IAAI,CAAC;gBACL,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE;gBAC7B,MAAM,EAAE,MAAM,CAAC,KAAK;aACvB,CAAC,CAAC;YACH,GAAG,CAAC,IAAI,CAAC;gBACL,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE;gBACtC,MAAM,EAAE,MAAM,CAAC,GAAG;aACrB,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YAC9C,GAAG,CAAC,IAAI,CAAC;gBACL,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE;gBAC7B,MAAM,EAAE,GAAG;aACd,CAAC,CAAC;YACH,KAAK,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"}
@@ -1,3 +1,4 @@
1
+ export { BadJpegEffect, type BadJpegEffectOptions } from "./bad-jpeg";
1
2
  export { BloomEffect } from "./bloom";
2
3
  export { type DatamoshColorSpace, DatamoshEffect, type DatamoshParams, type DatamoshView, } from "./datamosh";
3
4
  export { FluidEffect } from "./fluid";
package/lib/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { BadJpegEffect } from "./bad-jpeg";
1
2
  export { BloomEffect } from "./bloom";
2
3
  export { DatamoshEffect, } from "./datamosh";
3
4
  export { FluidEffect } from "./fluid";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAEH,cAAc,GAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,cAAc,EAA8B,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAyB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAEH,eAAe,GAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA6B,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAEH,cAAc,GAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,cAAc,EAA8B,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAyB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAEH,eAAe,GAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vfx-js/effects",
3
3
  "description": "Ready-made WebGL effects for @vfx-js/core",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "files": [
6
6
  "package.json",
7
7
  "README.md",
@@ -22,7 +22,7 @@
22
22
  "lint-staged": "lint-staged"
23
23
  },
24
24
  "peerDependencies": {
25
- "@vfx-js/core": ">=1.0.0"
25
+ "@vfx-js/core": ">=1.1.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@biomejs/biome": "2.4.11",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vfx-js/effects",
3
3
  "description": "Ready-made WebGL effects for @vfx-js/core",
4
- "version": "1.1.0",
4
+ "version": "1.2.0",
5
5
  "files": [
6
6
  "package.json",
7
7
  "README.md",
@@ -21,7 +21,7 @@
21
21
  }
22
22
  },
23
23
  "peerDependencies": {
24
- "@vfx-js/core": ">=1.0.0"
24
+ "@vfx-js/core": ">=1.1.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@biomejs/biome": "2.4.11",