@remotion/effects 4.0.477 → 4.0.479
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/dist/burlap.d.ts +15 -0
- package/dist/contour-lines.d.ts +114 -0
- package/dist/esm/barrel-distortion.mjs +1 -1
- package/dist/esm/blur.mjs +1 -1
- package/dist/esm/brightness.mjs +1 -1
- package/dist/esm/burlap.mjs +454 -0
- package/dist/esm/chromatic-aberration.mjs +1 -1
- package/dist/esm/color-key.mjs +1 -1
- package/dist/esm/contour-lines.mjs +567 -0
- package/dist/esm/contrast.mjs +1 -1
- package/dist/esm/dot-grid.mjs +1 -1
- package/dist/esm/drop-shadow.mjs +1 -1
- package/dist/esm/duotone.mjs +1 -1
- package/dist/esm/evolve.mjs +1 -1
- package/dist/esm/fisheye.mjs +1 -1
- package/dist/esm/glow.mjs +1 -1
- package/dist/esm/grayscale.mjs +1 -1
- package/dist/esm/halftone-linear-gradient.mjs +1 -1
- package/dist/esm/halftone.mjs +20 -1
- package/dist/esm/hue.mjs +1 -1
- package/dist/esm/index.mjs +8 -15
- package/dist/esm/invert.mjs +1 -1
- package/dist/esm/linear-progressive-blur.mjs +1 -1
- package/dist/esm/lines.mjs +1 -1
- package/dist/esm/mirror.mjs +1 -1
- package/dist/esm/noise-displacement.mjs +1 -1
- package/dist/esm/noise.mjs +1 -1
- package/dist/esm/pattern.mjs +1 -8
- package/dist/esm/pixel-dissolve.mjs +7 -6
- package/dist/esm/pixelate.mjs +306 -0
- package/dist/esm/rings.mjs +1 -1
- package/dist/esm/saturation.mjs +1 -1
- package/dist/esm/scale.mjs +1 -1
- package/dist/esm/scanlines.mjs +1 -1
- package/dist/esm/shine.mjs +1 -1
- package/dist/esm/shrinkwrap.mjs +606 -0
- package/dist/esm/speckle.mjs +1 -1
- package/dist/esm/thermal-vision.mjs +404 -0
- package/dist/esm/tint.mjs +1 -1
- package/dist/esm/translate.mjs +2 -2
- package/dist/esm/tv-signal-off.mjs +1 -1
- package/dist/esm/vignette.mjs +1 -1
- package/dist/esm/wave.mjs +1 -1
- package/dist/esm/waves.mjs +1 -1
- package/dist/esm/white-noise.mjs +1 -1
- package/dist/esm/zigzag.mjs +1 -1
- package/dist/pixelate.d.ts +6 -0
- package/dist/shrinkwrap.d.ts +19 -0
- package/dist/thermal-vision.d.ts +31 -0
- package/dist/visual-test/visual-utils.d.ts +5 -0
- package/package.json +43 -3
- package/dist/effect-internals.d.ts +0 -8
- package/dist/entrypoints/blur.d.ts +0 -6
package/dist/esm/index.mjs
CHANGED
|
@@ -268,11 +268,6 @@ var validateAtLeast = (value, min, name) => {
|
|
|
268
268
|
throw new TypeError(`"${name}" must be >= ${min}, but got ${JSON.stringify(value)}`);
|
|
269
269
|
}
|
|
270
270
|
};
|
|
271
|
-
var validateNonNegative2 = (value, name) => {
|
|
272
|
-
if (value < 0) {
|
|
273
|
-
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
271
|
var validatePatternParams = (params) => {
|
|
277
272
|
assertEffectParamsObject(params, "Pattern");
|
|
278
273
|
assertOptionalFiniteNumber(params.scale, "scale");
|
|
@@ -294,8 +289,6 @@ var validatePatternParams = (params) => {
|
|
|
294
289
|
assertOptionalInteger(params.columnOffsetEvery, "columnOffsetEvery");
|
|
295
290
|
const r = resolve(params);
|
|
296
291
|
validatePositive(r.scale, "scale");
|
|
297
|
-
validateNonNegative2(r.gapX, "gapX");
|
|
298
|
-
validateNonNegative2(r.gapY, "gapY");
|
|
299
292
|
validateAtLeast(r.rowOffsetEvery, 0, "rowOffsetEvery");
|
|
300
293
|
validateAtLeast(r.columnOffsetEvery, 0, "columnOffsetEvery");
|
|
301
294
|
validateUnitInterval(r.origin[0], "origin[0]");
|
|
@@ -435,7 +428,7 @@ var linkProgram = (gl, vs, fs) => {
|
|
|
435
428
|
return program;
|
|
436
429
|
};
|
|
437
430
|
var pattern = createEffect({
|
|
438
|
-
type: "remotion
|
|
431
|
+
type: "dev.remotion.effects.pattern",
|
|
439
432
|
label: "pattern()",
|
|
440
433
|
documentationLink: "https://www.remotion.dev/docs/effects/pattern",
|
|
441
434
|
backend: "webgl2",
|
|
@@ -655,7 +648,7 @@ var validatePositive2 = (value, name) => {
|
|
|
655
648
|
throw new TypeError(`"${name}" must be greater than 0, but got ${JSON.stringify(value)}`);
|
|
656
649
|
}
|
|
657
650
|
};
|
|
658
|
-
var
|
|
651
|
+
var validateNonNegative2 = (value, name) => {
|
|
659
652
|
if (value < 0) {
|
|
660
653
|
throw new TypeError(`"${name}" must be greater than or equal to 0, but got ${JSON.stringify(value)}`);
|
|
661
654
|
}
|
|
@@ -692,7 +685,7 @@ var validateRingsParams = (params) => {
|
|
|
692
685
|
const thickness = params.thickness ?? DEFAULT_THICKNESS;
|
|
693
686
|
const gap = params.gap ?? DEFAULT_GAP2;
|
|
694
687
|
validatePositive2(thickness, "thickness");
|
|
695
|
-
|
|
688
|
+
validateNonNegative2(gap, "gap");
|
|
696
689
|
};
|
|
697
690
|
var RINGS_VS = `#version 300 es
|
|
698
691
|
in vec2 aPos;
|
|
@@ -908,7 +901,7 @@ var updatePalette = (state, colors) => {
|
|
|
908
901
|
return true;
|
|
909
902
|
};
|
|
910
903
|
var rings = createEffect2({
|
|
911
|
-
type: "remotion
|
|
904
|
+
type: "dev.remotion.effects.rings",
|
|
912
905
|
label: "rings()",
|
|
913
906
|
documentationLink: "https://www.remotion.dev/docs/effects/rings",
|
|
914
907
|
backend: "webgl2",
|
|
@@ -1092,7 +1085,7 @@ var validatePositive3 = (value, name) => {
|
|
|
1092
1085
|
throw new TypeError(`"${name}" must be greater than 0, but got ${JSON.stringify(value)}`);
|
|
1093
1086
|
}
|
|
1094
1087
|
};
|
|
1095
|
-
var
|
|
1088
|
+
var validateNonNegative3 = (value, name) => {
|
|
1096
1089
|
if (value < 0) {
|
|
1097
1090
|
throw new TypeError(`"${name}" must be greater than or equal to 0, but got ${JSON.stringify(value)}`);
|
|
1098
1091
|
}
|
|
@@ -1132,8 +1125,8 @@ var validateZigzagParams = (params) => {
|
|
|
1132
1125
|
const amplitude = params.amplitude ?? DEFAULT_AMPLITUDE;
|
|
1133
1126
|
const wavelength = params.wavelength ?? DEFAULT_WAVELENGTH;
|
|
1134
1127
|
validatePositive3(thickness, "thickness");
|
|
1135
|
-
|
|
1136
|
-
|
|
1128
|
+
validateNonNegative3(gap, "gap");
|
|
1129
|
+
validateNonNegative3(amplitude, "amplitude");
|
|
1137
1130
|
validatePositive3(wavelength, "wavelength");
|
|
1138
1131
|
};
|
|
1139
1132
|
var ZIGZAG_VS = `#version 300 es
|
|
@@ -1364,7 +1357,7 @@ var updatePalette2 = (state, colors) => {
|
|
|
1364
1357
|
return true;
|
|
1365
1358
|
};
|
|
1366
1359
|
var zigzag = createEffect3({
|
|
1367
|
-
type: "remotion
|
|
1360
|
+
type: "dev.remotion.effects.zigzag",
|
|
1368
1361
|
label: "zigzag()",
|
|
1369
1362
|
documentationLink: "https://www.remotion.dev/docs/effects/zigzag",
|
|
1370
1363
|
backend: "webgl2",
|
package/dist/esm/invert.mjs
CHANGED
|
@@ -121,7 +121,7 @@ var validateInvertParams = (params) => {
|
|
|
121
121
|
validateUnitInterval(amount, "amount");
|
|
122
122
|
};
|
|
123
123
|
var invert = createEffect({
|
|
124
|
-
type: "remotion
|
|
124
|
+
type: "dev.remotion.effects.invert",
|
|
125
125
|
label: "invert()",
|
|
126
126
|
documentationLink: "https://www.remotion.dev/docs/effects/invert",
|
|
127
127
|
backend: "2d",
|
|
@@ -510,7 +510,7 @@ var validateLinearProgressiveBlurParams = (params) => {
|
|
|
510
510
|
assertOptionalFiniteNumber(params.endBlur, "endBlur");
|
|
511
511
|
};
|
|
512
512
|
var linearProgressiveBlur = createEffect({
|
|
513
|
-
type: "remotion
|
|
513
|
+
type: "dev.remotion.effects.linearProgressiveBlur",
|
|
514
514
|
label: "linearProgressiveBlur()",
|
|
515
515
|
documentationLink: "https://www.remotion.dev/docs/effects/linear-progressive-blur",
|
|
516
516
|
backend: "webgl2",
|
package/dist/esm/lines.mjs
CHANGED
|
@@ -457,7 +457,7 @@ var updatePalette = (state, colors) => {
|
|
|
457
457
|
return true;
|
|
458
458
|
};
|
|
459
459
|
var lines = createEffect({
|
|
460
|
-
type: "remotion
|
|
460
|
+
type: "dev.remotion.effects.lines",
|
|
461
461
|
label: "lines()",
|
|
462
462
|
documentationLink: "https://www.remotion.dev/docs/effects/lines",
|
|
463
463
|
backend: "webgl2",
|
package/dist/esm/mirror.mjs
CHANGED
|
@@ -352,7 +352,7 @@ var validateMirrorParams = (params) => {
|
|
|
352
352
|
validateUnitInterval(position, "position");
|
|
353
353
|
};
|
|
354
354
|
var mirror = createEffect({
|
|
355
|
-
type: "remotion
|
|
355
|
+
type: "dev.remotion.effects.mirror",
|
|
356
356
|
label: "mirror()",
|
|
357
357
|
documentationLink: "https://www.remotion.dev/docs/effects/mirror",
|
|
358
358
|
backend: "webgl2",
|
|
@@ -513,7 +513,7 @@ var setupNoiseDisplacement = (target) => {
|
|
|
513
513
|
};
|
|
514
514
|
};
|
|
515
515
|
var noiseDisplacement = createEffect({
|
|
516
|
-
type: "remotion
|
|
516
|
+
type: "dev.remotion.effects.noiseDisplacement",
|
|
517
517
|
label: "noiseDisplacement()",
|
|
518
518
|
documentationLink: "https://www.remotion.dev/docs/effects/noise-displacement",
|
|
519
519
|
backend: "webgl2",
|
package/dist/esm/noise.mjs
CHANGED
|
@@ -303,7 +303,7 @@ var setupNoise = (target) => {
|
|
|
303
303
|
};
|
|
304
304
|
};
|
|
305
305
|
var noise = createEffect({
|
|
306
|
-
type: "remotion
|
|
306
|
+
type: "dev.remotion.effects.noise",
|
|
307
307
|
label: "noise()",
|
|
308
308
|
documentationLink: "https://www.remotion.dev/docs/effects/noise",
|
|
309
309
|
backend: "webgl2",
|
package/dist/esm/pattern.mjs
CHANGED
|
@@ -268,11 +268,6 @@ var validateAtLeast = (value, min, name) => {
|
|
|
268
268
|
throw new TypeError(`"${name}" must be >= ${min}, but got ${JSON.stringify(value)}`);
|
|
269
269
|
}
|
|
270
270
|
};
|
|
271
|
-
var validateNonNegative2 = (value, name) => {
|
|
272
|
-
if (value < 0) {
|
|
273
|
-
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
271
|
var validatePatternParams = (params) => {
|
|
277
272
|
assertEffectParamsObject(params, "Pattern");
|
|
278
273
|
assertOptionalFiniteNumber(params.scale, "scale");
|
|
@@ -294,8 +289,6 @@ var validatePatternParams = (params) => {
|
|
|
294
289
|
assertOptionalInteger(params.columnOffsetEvery, "columnOffsetEvery");
|
|
295
290
|
const r = resolve(params);
|
|
296
291
|
validatePositive(r.scale, "scale");
|
|
297
|
-
validateNonNegative2(r.gapX, "gapX");
|
|
298
|
-
validateNonNegative2(r.gapY, "gapY");
|
|
299
292
|
validateAtLeast(r.rowOffsetEvery, 0, "rowOffsetEvery");
|
|
300
293
|
validateAtLeast(r.columnOffsetEvery, 0, "columnOffsetEvery");
|
|
301
294
|
validateUnitInterval(r.origin[0], "origin[0]");
|
|
@@ -435,7 +428,7 @@ var linkProgram = (gl, vs, fs) => {
|
|
|
435
428
|
return program;
|
|
436
429
|
};
|
|
437
430
|
var pattern = createEffect({
|
|
438
|
-
type: "remotion
|
|
431
|
+
type: "dev.remotion.effects.pattern",
|
|
439
432
|
label: "pattern()",
|
|
440
433
|
documentationLink: "https://www.remotion.dev/docs/effects/pattern",
|
|
441
434
|
backend: "webgl2",
|
|
@@ -221,13 +221,15 @@ float hash21(vec2 p) {
|
|
|
221
221
|
return fract((p3.x + p3.y) * p3.z);
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
float dissolveMask(float noise, float
|
|
224
|
+
float dissolveMask(float noise, float progress, float feather) {
|
|
225
225
|
float edge = max(feather, 0.0);
|
|
226
|
+
float threshold = 1.0 - clamp(progress, 0.0, 1.0) * (1.0 + edge);
|
|
227
|
+
|
|
226
228
|
if (edge <= 0.0001) {
|
|
227
|
-
return step(
|
|
229
|
+
return 1.0 - step(threshold, noise);
|
|
228
230
|
}
|
|
229
231
|
|
|
230
|
-
return 1.0 - smoothstep(threshold,
|
|
232
|
+
return 1.0 - smoothstep(threshold, threshold + edge, noise);
|
|
231
233
|
}
|
|
232
234
|
|
|
233
235
|
void main() {
|
|
@@ -236,9 +238,8 @@ void main() {
|
|
|
236
238
|
vec2 cell = floor(gridUv * divisions);
|
|
237
239
|
vec4 color = texture(uSource, vUv);
|
|
238
240
|
|
|
239
|
-
float threshold = 1.0 - clamp(uProgress, 0.0, 1.0);
|
|
240
241
|
float noise = hash21(cell + vec2(uSeed, uSeed * 1.618));
|
|
241
|
-
float mask = dissolveMask(noise,
|
|
242
|
+
float mask = dissolveMask(noise, uProgress, uFeather);
|
|
242
243
|
|
|
243
244
|
fragColor = vec4(color.rgb * mask, color.a * mask);
|
|
244
245
|
}
|
|
@@ -287,7 +288,7 @@ var createFullscreenQuad = (gl) => {
|
|
|
287
288
|
return { vao, vbo };
|
|
288
289
|
};
|
|
289
290
|
var pixelDissolve = createEffect({
|
|
290
|
-
type: "remotion
|
|
291
|
+
type: "dev.remotion.effects.pixelDissolve",
|
|
291
292
|
label: "pixelDissolve()",
|
|
292
293
|
documentationLink: "https://www.remotion.dev/docs/effects/pixel-dissolve",
|
|
293
294
|
backend: "webgl2",
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// src/pixelate.ts
|
|
2
|
+
import { Internals } from "remotion";
|
|
3
|
+
|
|
4
|
+
// src/validate-effect-param.ts
|
|
5
|
+
var assertEffectParamsObject = (params, effectLabel) => {
|
|
6
|
+
if (params === null || typeof params !== "object") {
|
|
7
|
+
throw new TypeError(`${effectLabel} effect requires a parameters object, but got ${JSON.stringify(params)}`);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var assertRequiredFiniteNumber = (value, name) => {
|
|
11
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
12
|
+
throw new TypeError(`"${name}" must be a finite number, but got ${JSON.stringify(value)}`);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var assertRequiredColor = (value, name) => {
|
|
16
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
17
|
+
throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var assertOptionalColor = (value, name) => {
|
|
21
|
+
if (value === undefined) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
assertRequiredColor(value, name);
|
|
25
|
+
};
|
|
26
|
+
var assertOptionalBoolean = (value, name) => {
|
|
27
|
+
if (value === undefined) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (typeof value !== "boolean") {
|
|
31
|
+
throw new TypeError(`"${name}" must be a boolean, but got ${JSON.stringify(value)}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/color-utils.ts
|
|
36
|
+
var DEFAULT_AMOUNT = 1;
|
|
37
|
+
var DEFAULT_BRIGHTNESS_AMOUNT = 0;
|
|
38
|
+
var DEFAULT_HUE_DEGREES = 0;
|
|
39
|
+
var colorAmountSchema = {
|
|
40
|
+
type: "number",
|
|
41
|
+
min: 0,
|
|
42
|
+
max: 1,
|
|
43
|
+
step: 0.01,
|
|
44
|
+
default: DEFAULT_AMOUNT,
|
|
45
|
+
description: "Amount",
|
|
46
|
+
hiddenFromList: false
|
|
47
|
+
};
|
|
48
|
+
var colorMultiplierSchema = {
|
|
49
|
+
type: "number",
|
|
50
|
+
min: 0,
|
|
51
|
+
step: 0.01,
|
|
52
|
+
default: DEFAULT_AMOUNT,
|
|
53
|
+
description: "Amount",
|
|
54
|
+
hiddenFromList: false
|
|
55
|
+
};
|
|
56
|
+
var brightnessAmountSchema = {
|
|
57
|
+
type: "number",
|
|
58
|
+
min: -1,
|
|
59
|
+
max: 1,
|
|
60
|
+
step: 0.01,
|
|
61
|
+
default: DEFAULT_BRIGHTNESS_AMOUNT,
|
|
62
|
+
description: "Amount",
|
|
63
|
+
hiddenFromList: false
|
|
64
|
+
};
|
|
65
|
+
var hueDegreesSchema = {
|
|
66
|
+
type: "rotation-degrees",
|
|
67
|
+
step: 1,
|
|
68
|
+
default: DEFAULT_HUE_DEGREES,
|
|
69
|
+
description: "Degrees"
|
|
70
|
+
};
|
|
71
|
+
var assertOptionalFiniteNumber = (value, name) => {
|
|
72
|
+
if (value === undefined) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
assertRequiredFiniteNumber(value, name);
|
|
76
|
+
};
|
|
77
|
+
var validateUnitInterval = (value, name) => {
|
|
78
|
+
if (value < 0) {
|
|
79
|
+
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
80
|
+
}
|
|
81
|
+
if (value > 1) {
|
|
82
|
+
throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var validateNonNegative = (value, name) => {
|
|
86
|
+
if (value < 0) {
|
|
87
|
+
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var validateSignedUnitInterval = (value, name) => {
|
|
91
|
+
if (value < -1) {
|
|
92
|
+
throw new TypeError(`"${name}" must be >= -1, but got ${JSON.stringify(value)}`);
|
|
93
|
+
}
|
|
94
|
+
if (value > 1) {
|
|
95
|
+
throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var clampColorChannel = (value) => {
|
|
99
|
+
return Math.max(0, Math.min(255, value));
|
|
100
|
+
};
|
|
101
|
+
var parseColorRgba = (ctx, color) => {
|
|
102
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
103
|
+
ctx.fillStyle = color;
|
|
104
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
105
|
+
const { data } = ctx.getImageData(0, 0, 1, 1);
|
|
106
|
+
return [data[0], data[1], data[2], data[3]];
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/pixelate.ts
|
|
110
|
+
var { createEffect, createWebGL2ContextError } = Internals;
|
|
111
|
+
var DEFAULT_BLOCK_SIZE = 20;
|
|
112
|
+
var pixelateSchema = {
|
|
113
|
+
blockSize: {
|
|
114
|
+
type: "number",
|
|
115
|
+
min: 1,
|
|
116
|
+
max: 200,
|
|
117
|
+
step: 1,
|
|
118
|
+
default: DEFAULT_BLOCK_SIZE,
|
|
119
|
+
description: "Block size",
|
|
120
|
+
hiddenFromList: false
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var resolve = (p) => ({
|
|
124
|
+
blockSize: p.blockSize ?? DEFAULT_BLOCK_SIZE
|
|
125
|
+
});
|
|
126
|
+
var validatePixelateParams = (params) => {
|
|
127
|
+
assertEffectParamsObject(params, "Pixelate");
|
|
128
|
+
assertOptionalFiniteNumber(params.blockSize, "blockSize");
|
|
129
|
+
if ((params.blockSize ?? DEFAULT_BLOCK_SIZE) < 1) {
|
|
130
|
+
throw new Error('"blockSize" must be >= 1');
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var VERTEX_SHADER = `#version 300 es
|
|
134
|
+
|
|
135
|
+
in vec2 aPos;
|
|
136
|
+
in vec2 aUv;
|
|
137
|
+
out vec2 vUv;
|
|
138
|
+
|
|
139
|
+
void main() {
|
|
140
|
+
vUv = aUv;
|
|
141
|
+
gl_Position = vec4(aPos, 0.0, 1.0);
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
144
|
+
var FRAGMENT_SHADER = `#version 300 es
|
|
145
|
+
precision highp float;
|
|
146
|
+
|
|
147
|
+
in vec2 vUv;
|
|
148
|
+
out vec4 fragColor;
|
|
149
|
+
uniform sampler2D uSource;
|
|
150
|
+
uniform float uBlockSize;
|
|
151
|
+
uniform vec2 uResolution;
|
|
152
|
+
|
|
153
|
+
void main() {
|
|
154
|
+
vec2 pixelSizeUv = vec2(uBlockSize) / uResolution;
|
|
155
|
+
vec2 blockUv = floor(vUv / pixelSizeUv) * pixelSizeUv + pixelSizeUv * 0.5;
|
|
156
|
+
fragColor = texture(uSource, blockUv);
|
|
157
|
+
}
|
|
158
|
+
`;
|
|
159
|
+
var compileShader = (gl, type, source) => {
|
|
160
|
+
const shader = gl.createShader(type);
|
|
161
|
+
if (!shader) {
|
|
162
|
+
throw new Error("Failed to create WebGL shader");
|
|
163
|
+
}
|
|
164
|
+
gl.shaderSource(shader, source);
|
|
165
|
+
gl.compileShader(shader);
|
|
166
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
167
|
+
const log = gl.getShaderInfoLog(shader);
|
|
168
|
+
gl.deleteShader(shader);
|
|
169
|
+
throw new Error(`Pixelate shader compile failed: ${log ?? "(no log)"}`);
|
|
170
|
+
}
|
|
171
|
+
return shader;
|
|
172
|
+
};
|
|
173
|
+
var linkProgram = (gl, vs, fs) => {
|
|
174
|
+
const program = gl.createProgram();
|
|
175
|
+
if (!program) {
|
|
176
|
+
throw new Error("Failed to create WebGL program");
|
|
177
|
+
}
|
|
178
|
+
gl.attachShader(program, vs);
|
|
179
|
+
gl.attachShader(program, fs);
|
|
180
|
+
gl.linkProgram(program);
|
|
181
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
182
|
+
const log = gl.getProgramInfoLog(program);
|
|
183
|
+
gl.deleteProgram(program);
|
|
184
|
+
throw new Error(`Pixelate program link failed: ${log ?? "(no log)"}`);
|
|
185
|
+
}
|
|
186
|
+
return program;
|
|
187
|
+
};
|
|
188
|
+
var createPixelateState = (gl) => {
|
|
189
|
+
const vs = compileShader(gl, gl.VERTEX_SHADER, VERTEX_SHADER);
|
|
190
|
+
const fs = compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT_SHADER);
|
|
191
|
+
const program = linkProgram(gl, vs, fs);
|
|
192
|
+
gl.deleteShader(vs);
|
|
193
|
+
gl.deleteShader(fs);
|
|
194
|
+
const vao = gl.createVertexArray();
|
|
195
|
+
if (!vao) {
|
|
196
|
+
throw new Error("Failed to create WebGL vertex array");
|
|
197
|
+
}
|
|
198
|
+
gl.bindVertexArray(vao);
|
|
199
|
+
const data = new Float32Array([
|
|
200
|
+
-1,
|
|
201
|
+
-1,
|
|
202
|
+
0,
|
|
203
|
+
0,
|
|
204
|
+
1,
|
|
205
|
+
-1,
|
|
206
|
+
1,
|
|
207
|
+
0,
|
|
208
|
+
-1,
|
|
209
|
+
1,
|
|
210
|
+
0,
|
|
211
|
+
1,
|
|
212
|
+
1,
|
|
213
|
+
1,
|
|
214
|
+
1,
|
|
215
|
+
1
|
|
216
|
+
]);
|
|
217
|
+
const vbo = gl.createBuffer();
|
|
218
|
+
if (!vbo) {
|
|
219
|
+
throw new Error("Failed to create WebGL buffer");
|
|
220
|
+
}
|
|
221
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
222
|
+
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
|
223
|
+
const aPos = gl.getAttribLocation(program, "aPos");
|
|
224
|
+
const aUv = gl.getAttribLocation(program, "aUv");
|
|
225
|
+
gl.enableVertexAttribArray(aPos);
|
|
226
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
|
|
227
|
+
gl.enableVertexAttribArray(aUv);
|
|
228
|
+
gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
|
|
229
|
+
gl.bindVertexArray(null);
|
|
230
|
+
const texture = gl.createTexture();
|
|
231
|
+
if (!texture) {
|
|
232
|
+
throw new Error("Failed to create WebGL texture");
|
|
233
|
+
}
|
|
234
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
235
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
236
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
237
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
238
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
239
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
240
|
+
return {
|
|
241
|
+
gl,
|
|
242
|
+
program,
|
|
243
|
+
vao,
|
|
244
|
+
vbo,
|
|
245
|
+
texture,
|
|
246
|
+
uSource: gl.getUniformLocation(program, "uSource"),
|
|
247
|
+
uResolution: gl.getUniformLocation(program, "uResolution"),
|
|
248
|
+
uBlockSize: gl.getUniformLocation(program, "uBlockSize")
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
var pixelate = createEffect({
|
|
252
|
+
type: "dev.remotion.effects.pixelate",
|
|
253
|
+
label: "pixelate()",
|
|
254
|
+
documentationLink: "https://www.remotion.dev/docs/effects/pixelate",
|
|
255
|
+
backend: "webgl2",
|
|
256
|
+
calculateKey: (params) => {
|
|
257
|
+
const r = resolve(params);
|
|
258
|
+
return `pixelate-${r.blockSize}`;
|
|
259
|
+
},
|
|
260
|
+
setup: (target) => {
|
|
261
|
+
const gl = target.getContext("webgl2", {
|
|
262
|
+
premultipliedAlpha: true,
|
|
263
|
+
alpha: true,
|
|
264
|
+
preserveDrawingBuffer: true
|
|
265
|
+
});
|
|
266
|
+
if (!gl) {
|
|
267
|
+
throw createWebGL2ContextError("pixelate effect");
|
|
268
|
+
}
|
|
269
|
+
return createPixelateState(gl);
|
|
270
|
+
},
|
|
271
|
+
apply: ({ source, width, height, params, state, flipSourceY }) => {
|
|
272
|
+
const r = resolve(params);
|
|
273
|
+
state.gl.viewport(0, 0, width, height);
|
|
274
|
+
state.gl.clearColor(0, 0, 0, 0);
|
|
275
|
+
state.gl.clear(state.gl.COLOR_BUFFER_BIT);
|
|
276
|
+
state.gl.useProgram(state.program);
|
|
277
|
+
state.gl.bindVertexArray(state.vao);
|
|
278
|
+
state.gl.bindFramebuffer(state.gl.FRAMEBUFFER, null);
|
|
279
|
+
state.gl.activeTexture(state.gl.TEXTURE0);
|
|
280
|
+
state.gl.bindTexture(state.gl.TEXTURE_2D, state.texture);
|
|
281
|
+
state.gl.pixelStorei(state.gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
|
|
282
|
+
state.gl.pixelStorei(state.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
283
|
+
state.gl.texImage2D(state.gl.TEXTURE_2D, 0, state.gl.RGBA, state.gl.RGBA, state.gl.UNSIGNED_BYTE, source);
|
|
284
|
+
if (state.uSource)
|
|
285
|
+
state.gl.uniform1i(state.uSource, 0);
|
|
286
|
+
if (state.uBlockSize)
|
|
287
|
+
state.gl.uniform1f(state.uBlockSize, r.blockSize);
|
|
288
|
+
if (state.uResolution)
|
|
289
|
+
state.gl.uniform2f(state.uResolution, width, height);
|
|
290
|
+
state.gl.drawArrays(state.gl.TRIANGLE_STRIP, 0, 4);
|
|
291
|
+
state.gl.bindVertexArray(null);
|
|
292
|
+
state.gl.bindTexture(state.gl.TEXTURE_2D, null);
|
|
293
|
+
state.gl.useProgram(null);
|
|
294
|
+
},
|
|
295
|
+
cleanup: ({ gl, program, vao, vbo, texture }) => {
|
|
296
|
+
gl.deleteTexture(texture);
|
|
297
|
+
gl.deleteBuffer(vbo);
|
|
298
|
+
gl.deleteProgram(program);
|
|
299
|
+
gl.deleteVertexArray(vao);
|
|
300
|
+
},
|
|
301
|
+
schema: pixelateSchema,
|
|
302
|
+
validateParams: validatePixelateParams
|
|
303
|
+
});
|
|
304
|
+
export {
|
|
305
|
+
pixelate
|
|
306
|
+
};
|
package/dist/esm/rings.mjs
CHANGED
|
@@ -440,7 +440,7 @@ var updatePalette = (state, colors) => {
|
|
|
440
440
|
return true;
|
|
441
441
|
};
|
|
442
442
|
var rings = createEffect({
|
|
443
|
-
type: "remotion
|
|
443
|
+
type: "dev.remotion.effects.rings",
|
|
444
444
|
label: "rings()",
|
|
445
445
|
documentationLink: "https://www.remotion.dev/docs/effects/rings",
|
|
446
446
|
backend: "webgl2",
|
package/dist/esm/saturation.mjs
CHANGED
|
@@ -121,7 +121,7 @@ var validateSaturationParams = (params) => {
|
|
|
121
121
|
validateNonNegative(amount, "amount");
|
|
122
122
|
};
|
|
123
123
|
var saturation = createEffect({
|
|
124
|
-
type: "remotion
|
|
124
|
+
type: "dev.remotion.effects.saturation",
|
|
125
125
|
label: "saturation()",
|
|
126
126
|
documentationLink: "https://www.remotion.dev/docs/effects/saturation",
|
|
127
127
|
backend: "2d",
|
package/dist/esm/scale.mjs
CHANGED
package/dist/esm/scanlines.mjs
CHANGED
|
@@ -343,7 +343,7 @@ var setupScanlines = (target) => {
|
|
|
343
343
|
};
|
|
344
344
|
};
|
|
345
345
|
var scanlines = createEffect({
|
|
346
|
-
type: "remotion
|
|
346
|
+
type: "dev.remotion.effects.scanlines",
|
|
347
347
|
label: "scanlines()",
|
|
348
348
|
documentationLink: "https://www.remotion.dev/docs/effects/scanlines",
|
|
349
349
|
backend: "webgl2",
|
package/dist/esm/shine.mjs
CHANGED
|
@@ -264,7 +264,7 @@ var linkProgram = (gl, vs, fs) => {
|
|
|
264
264
|
return program;
|
|
265
265
|
};
|
|
266
266
|
var shine = createEffect({
|
|
267
|
-
type: "remotion
|
|
267
|
+
type: "dev.remotion.effects.shine",
|
|
268
268
|
label: "shine()",
|
|
269
269
|
documentationLink: "https://www.remotion.dev/docs/effects/shine",
|
|
270
270
|
backend: "webgl2",
|