@remotion/effects 4.0.478 → 4.0.481
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/checkerboard.d.ts +75 -0
- package/dist/emboss.d.ts +76 -0
- package/dist/esm/barrel-distortion.mjs +1 -1
- package/dist/esm/blur.mjs +2 -2
- package/dist/esm/brightness.mjs +1 -1
- package/dist/esm/burlap.mjs +454 -0
- package/dist/esm/checkerboard.mjs +516 -0
- package/dist/esm/chromatic-aberration.mjs +1 -1
- package/dist/esm/color-key.mjs +1 -1
- package/dist/esm/contour-lines.mjs +1 -1
- 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/emboss.mjs +477 -0
- 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/gridlines.mjs +577 -0
- 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 +1061 -186
- 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 -1
- package/dist/esm/pixel-dissolve.mjs +1 -1
- 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 +6 -11
- 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/esm/zoom-blur.mjs +419 -0
- package/dist/gridlines.d.ts +113 -0
- package/dist/index.d.ts +2 -0
- 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 +4 -2
- package/dist/zoom-blur/index.d.ts +12 -0
- package/dist/zoom-blur/zoom-blur-runtime.d.ts +26 -0
- package/dist/zoom-blur/zoom-blur-shaders.d.ts +2 -0
- package/dist/zoom-blur.d.ts +1 -0
- package/package.json +67 -3
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
// src/checkerboard.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/checkerboard.ts
|
|
110
|
+
var { createEffect, createWebGL2ContextError } = Internals;
|
|
111
|
+
var DEFAULT_COLORS = ["#dff4ff", "#7cc6ff"];
|
|
112
|
+
var DEFAULT_CELL_SIZE = 80;
|
|
113
|
+
var DEFAULT_GAP = 0;
|
|
114
|
+
var DEFAULT_ANGLE = 0;
|
|
115
|
+
var DEFAULT_OFFSET_X = 0;
|
|
116
|
+
var DEFAULT_OFFSET_Y = 0;
|
|
117
|
+
var DEFAULT_MASK_TO_SOURCE_ALPHA = false;
|
|
118
|
+
var checkerboardSchema = {
|
|
119
|
+
colors: {
|
|
120
|
+
type: "array",
|
|
121
|
+
item: {
|
|
122
|
+
type: "color"
|
|
123
|
+
},
|
|
124
|
+
default: DEFAULT_COLORS,
|
|
125
|
+
minLength: 2,
|
|
126
|
+
newItemDefault: "#ff0000",
|
|
127
|
+
description: "Colors",
|
|
128
|
+
keyframable: false
|
|
129
|
+
},
|
|
130
|
+
cellSize: {
|
|
131
|
+
type: "number",
|
|
132
|
+
min: 0.1,
|
|
133
|
+
max: 800,
|
|
134
|
+
step: 0.1,
|
|
135
|
+
default: DEFAULT_CELL_SIZE,
|
|
136
|
+
description: "Cell size",
|
|
137
|
+
hiddenFromList: false
|
|
138
|
+
},
|
|
139
|
+
gap: {
|
|
140
|
+
type: "number",
|
|
141
|
+
min: 0,
|
|
142
|
+
max: 400,
|
|
143
|
+
step: 0.1,
|
|
144
|
+
default: DEFAULT_GAP,
|
|
145
|
+
description: "Gap",
|
|
146
|
+
hiddenFromList: false
|
|
147
|
+
},
|
|
148
|
+
angle: {
|
|
149
|
+
type: "rotation-degrees",
|
|
150
|
+
step: 1,
|
|
151
|
+
default: DEFAULT_ANGLE,
|
|
152
|
+
description: "Angle"
|
|
153
|
+
},
|
|
154
|
+
offsetX: {
|
|
155
|
+
type: "number",
|
|
156
|
+
step: 0.1,
|
|
157
|
+
default: DEFAULT_OFFSET_X,
|
|
158
|
+
description: "Offset X",
|
|
159
|
+
hiddenFromList: false
|
|
160
|
+
},
|
|
161
|
+
offsetY: {
|
|
162
|
+
type: "number",
|
|
163
|
+
step: 0.1,
|
|
164
|
+
default: DEFAULT_OFFSET_Y,
|
|
165
|
+
description: "Offset Y",
|
|
166
|
+
hiddenFromList: false
|
|
167
|
+
},
|
|
168
|
+
maskToSourceAlpha: {
|
|
169
|
+
type: "boolean",
|
|
170
|
+
default: DEFAULT_MASK_TO_SOURCE_ALPHA,
|
|
171
|
+
description: "Mask to source alpha"
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
var resolve = (p) => {
|
|
175
|
+
const cellSize = p.cellSize ?? DEFAULT_CELL_SIZE;
|
|
176
|
+
const gap = p.gap ?? DEFAULT_GAP;
|
|
177
|
+
return {
|
|
178
|
+
colors: p.colors ?? DEFAULT_COLORS,
|
|
179
|
+
cellSize,
|
|
180
|
+
spacing: cellSize + gap,
|
|
181
|
+
angle: p.angle ?? DEFAULT_ANGLE,
|
|
182
|
+
offsetX: p.offsetX ?? DEFAULT_OFFSET_X,
|
|
183
|
+
offsetY: p.offsetY ?? DEFAULT_OFFSET_Y,
|
|
184
|
+
maskToSourceAlpha: p.maskToSourceAlpha ?? DEFAULT_MASK_TO_SOURCE_ALPHA
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
var validatePositive = (value, name) => {
|
|
188
|
+
if (value <= 0) {
|
|
189
|
+
throw new TypeError(`"${name}" must be greater than 0, but got ${JSON.stringify(value)}`);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var validateNonNegative2 = (value, name) => {
|
|
193
|
+
if (value < 0) {
|
|
194
|
+
throw new TypeError(`"${name}" must be greater than or equal to 0, but got ${JSON.stringify(value)}`);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var validateColors = (colors) => {
|
|
198
|
+
if (colors === undefined) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (!Array.isArray(colors) || colors.length < 2) {
|
|
202
|
+
throw new TypeError(`"colors" must be an array with at least 2 colors, but got ${JSON.stringify(colors)}`);
|
|
203
|
+
}
|
|
204
|
+
for (let i = 0;i < colors.length; i++) {
|
|
205
|
+
assertRequiredColor(colors[i], `colors[${i}]`);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
var validateCheckerboardParams = (params) => {
|
|
209
|
+
assertEffectParamsObject(params, "Checkerboard");
|
|
210
|
+
validateColors(params.colors);
|
|
211
|
+
assertOptionalFiniteNumber(params.cellSize, "cellSize");
|
|
212
|
+
assertOptionalFiniteNumber(params.gap, "gap");
|
|
213
|
+
assertOptionalFiniteNumber(params.angle, "angle");
|
|
214
|
+
assertOptionalFiniteNumber(params.offsetX, "offsetX");
|
|
215
|
+
assertOptionalFiniteNumber(params.offsetY, "offsetY");
|
|
216
|
+
assertOptionalBoolean(params.maskToSourceAlpha, "maskToSourceAlpha");
|
|
217
|
+
const cellSize = params.cellSize ?? DEFAULT_CELL_SIZE;
|
|
218
|
+
const gap = params.gap ?? DEFAULT_GAP;
|
|
219
|
+
validatePositive(cellSize, "cellSize");
|
|
220
|
+
validateNonNegative2(gap, "gap");
|
|
221
|
+
};
|
|
222
|
+
var CHECKERBOARD_VS = `#version 300 es
|
|
223
|
+
in vec2 aPos;
|
|
224
|
+
in vec2 aUv;
|
|
225
|
+
out vec2 vUv;
|
|
226
|
+
|
|
227
|
+
void main() {
|
|
228
|
+
vUv = aUv;
|
|
229
|
+
gl_Position = vec4(aPos, 0.0, 1.0);
|
|
230
|
+
}
|
|
231
|
+
`;
|
|
232
|
+
var CHECKERBOARD_FS = `#version 300 es
|
|
233
|
+
precision highp float;
|
|
234
|
+
|
|
235
|
+
in vec2 vUv;
|
|
236
|
+
out vec4 fragColor;
|
|
237
|
+
|
|
238
|
+
uniform sampler2D uSource;
|
|
239
|
+
uniform sampler2D uPalette;
|
|
240
|
+
uniform vec2 uResolution;
|
|
241
|
+
uniform float uNumColors;
|
|
242
|
+
uniform float uCellSize;
|
|
243
|
+
uniform float uSpacing;
|
|
244
|
+
uniform float uAngle;
|
|
245
|
+
uniform vec2 uOffset;
|
|
246
|
+
uniform bool uMaskToSourceAlpha;
|
|
247
|
+
|
|
248
|
+
void main() {
|
|
249
|
+
vec4 texColor = texture(uSource, vUv);
|
|
250
|
+
float cellSize = max(uCellSize, 0.001);
|
|
251
|
+
float spacing = max(uSpacing, 0.001);
|
|
252
|
+
vec2 centered = vUv * uResolution - uResolution * 0.5;
|
|
253
|
+
float s = sin(uAngle);
|
|
254
|
+
float c = cos(uAngle);
|
|
255
|
+
vec2 rotated = vec2(
|
|
256
|
+
centered.x * c - centered.y * s,
|
|
257
|
+
centered.x * s + centered.y * c
|
|
258
|
+
);
|
|
259
|
+
vec2 position = rotated + uOffset;
|
|
260
|
+
vec2 localPosition = mod(position, spacing);
|
|
261
|
+
if (localPosition.x < 0.0) {
|
|
262
|
+
localPosition.x += spacing;
|
|
263
|
+
}
|
|
264
|
+
if (localPosition.y < 0.0) {
|
|
265
|
+
localPosition.y += spacing;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (localPosition.x > cellSize || localPosition.y > cellSize) {
|
|
269
|
+
fragColor = texColor;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
vec2 cell = floor(position / spacing);
|
|
274
|
+
float colorIndex = mod(cell.x + cell.y, uNumColors);
|
|
275
|
+
if (colorIndex < 0.0) {
|
|
276
|
+
colorIndex += uNumColors;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
float texCoord = (colorIndex + 0.5) / uNumColors;
|
|
280
|
+
vec4 checkerColor = texture(uPalette, vec2(texCoord, 0.5));
|
|
281
|
+
float checkerAlpha = checkerColor.a;
|
|
282
|
+
vec3 premultipliedChecker = checkerColor.rgb * checkerAlpha;
|
|
283
|
+
|
|
284
|
+
if (uMaskToSourceAlpha) {
|
|
285
|
+
fragColor = vec4(
|
|
286
|
+
premultipliedChecker * texColor.a + texColor.rgb * (1.0 - checkerAlpha),
|
|
287
|
+
texColor.a
|
|
288
|
+
);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
fragColor = vec4(
|
|
293
|
+
premultipliedChecker + texColor.rgb * (1.0 - checkerAlpha),
|
|
294
|
+
checkerAlpha + texColor.a * (1.0 - checkerAlpha)
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
`;
|
|
298
|
+
var compileShader = (gl, type, source) => {
|
|
299
|
+
const shader = gl.createShader(type);
|
|
300
|
+
if (!shader) {
|
|
301
|
+
throw new Error("Failed to create WebGL shader");
|
|
302
|
+
}
|
|
303
|
+
gl.shaderSource(shader, source);
|
|
304
|
+
gl.compileShader(shader);
|
|
305
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
306
|
+
const log = gl.getShaderInfoLog(shader);
|
|
307
|
+
gl.deleteShader(shader);
|
|
308
|
+
throw new Error(`Checkerboard shader compile failed: ${log ?? "(no log)"}`);
|
|
309
|
+
}
|
|
310
|
+
return shader;
|
|
311
|
+
};
|
|
312
|
+
var linkProgram = (gl, vs, fs) => {
|
|
313
|
+
const program = gl.createProgram();
|
|
314
|
+
if (!program) {
|
|
315
|
+
throw new Error("Failed to create WebGL program");
|
|
316
|
+
}
|
|
317
|
+
gl.attachShader(program, vs);
|
|
318
|
+
gl.attachShader(program, fs);
|
|
319
|
+
gl.linkProgram(program);
|
|
320
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
321
|
+
const log = gl.getProgramInfoLog(program);
|
|
322
|
+
gl.deleteProgram(program);
|
|
323
|
+
throw new Error(`Checkerboard program link failed: ${log ?? "(no log)"}`);
|
|
324
|
+
}
|
|
325
|
+
return program;
|
|
326
|
+
};
|
|
327
|
+
var createProgram = (gl, vertexSource, fragmentSource) => {
|
|
328
|
+
const vs = compileShader(gl, gl.VERTEX_SHADER, vertexSource);
|
|
329
|
+
const fs = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
|
|
330
|
+
const program = linkProgram(gl, vs, fs);
|
|
331
|
+
gl.deleteShader(vs);
|
|
332
|
+
gl.deleteShader(fs);
|
|
333
|
+
return program;
|
|
334
|
+
};
|
|
335
|
+
var createTexture = (gl, filter) => {
|
|
336
|
+
const texture = gl.createTexture();
|
|
337
|
+
if (!texture) {
|
|
338
|
+
throw new Error("Failed to create WebGL texture");
|
|
339
|
+
}
|
|
340
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
341
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
|
|
342
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
|
|
343
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
344
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
345
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
346
|
+
return texture;
|
|
347
|
+
};
|
|
348
|
+
var setupCheckerboard = (target) => {
|
|
349
|
+
const gl = target.getContext("webgl2", {
|
|
350
|
+
premultipliedAlpha: true,
|
|
351
|
+
alpha: true,
|
|
352
|
+
preserveDrawingBuffer: true
|
|
353
|
+
});
|
|
354
|
+
if (!gl) {
|
|
355
|
+
throw createWebGL2ContextError("checkerboard effect");
|
|
356
|
+
}
|
|
357
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
358
|
+
const program = createProgram(gl, CHECKERBOARD_VS, CHECKERBOARD_FS);
|
|
359
|
+
const vao = gl.createVertexArray();
|
|
360
|
+
if (!vao) {
|
|
361
|
+
throw new Error("Failed to create WebGL vertex array");
|
|
362
|
+
}
|
|
363
|
+
gl.bindVertexArray(vao);
|
|
364
|
+
const data = new Float32Array([
|
|
365
|
+
-1,
|
|
366
|
+
-1,
|
|
367
|
+
0,
|
|
368
|
+
0,
|
|
369
|
+
1,
|
|
370
|
+
-1,
|
|
371
|
+
1,
|
|
372
|
+
0,
|
|
373
|
+
-1,
|
|
374
|
+
1,
|
|
375
|
+
0,
|
|
376
|
+
1,
|
|
377
|
+
1,
|
|
378
|
+
1,
|
|
379
|
+
1,
|
|
380
|
+
1
|
|
381
|
+
]);
|
|
382
|
+
const vbo = gl.createBuffer();
|
|
383
|
+
if (!vbo) {
|
|
384
|
+
throw new Error("Failed to create WebGL buffer");
|
|
385
|
+
}
|
|
386
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
387
|
+
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
|
388
|
+
const aPos = gl.getAttribLocation(program, "aPos");
|
|
389
|
+
const aUv = gl.getAttribLocation(program, "aUv");
|
|
390
|
+
gl.enableVertexAttribArray(aPos);
|
|
391
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
|
|
392
|
+
gl.enableVertexAttribArray(aUv);
|
|
393
|
+
gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
|
|
394
|
+
gl.bindVertexArray(null);
|
|
395
|
+
const colorCanvas = document.createElement("canvas");
|
|
396
|
+
colorCanvas.width = 1;
|
|
397
|
+
colorCanvas.height = 1;
|
|
398
|
+
const colorCtx = colorCanvas.getContext("2d", { willReadFrequently: true });
|
|
399
|
+
if (!colorCtx) {
|
|
400
|
+
throw new Error("Failed to acquire 2D context for color parsing");
|
|
401
|
+
}
|
|
402
|
+
return {
|
|
403
|
+
gl,
|
|
404
|
+
program,
|
|
405
|
+
vao,
|
|
406
|
+
vbo,
|
|
407
|
+
sourceTexture: createTexture(gl, gl.LINEAR),
|
|
408
|
+
paletteTexture: createTexture(gl, gl.NEAREST),
|
|
409
|
+
colorCtx,
|
|
410
|
+
uniforms: {
|
|
411
|
+
uSource: gl.getUniformLocation(program, "uSource"),
|
|
412
|
+
uPalette: gl.getUniformLocation(program, "uPalette"),
|
|
413
|
+
uResolution: gl.getUniformLocation(program, "uResolution"),
|
|
414
|
+
uNumColors: gl.getUniformLocation(program, "uNumColors"),
|
|
415
|
+
uCellSize: gl.getUniformLocation(program, "uCellSize"),
|
|
416
|
+
uSpacing: gl.getUniformLocation(program, "uSpacing"),
|
|
417
|
+
uAngle: gl.getUniformLocation(program, "uAngle"),
|
|
418
|
+
uOffset: gl.getUniformLocation(program, "uOffset"),
|
|
419
|
+
uMaskToSourceAlpha: gl.getUniformLocation(program, "uMaskToSourceAlpha")
|
|
420
|
+
},
|
|
421
|
+
cachedPaletteKey: "",
|
|
422
|
+
palettePixelData: new Uint8Array(0)
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
var updatePalette = (state, colors) => {
|
|
426
|
+
const paletteKey = colors.join("|");
|
|
427
|
+
const paletteDirty = state.cachedPaletteKey !== paletteKey;
|
|
428
|
+
if (!paletteDirty) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
state.cachedPaletteKey = paletteKey;
|
|
432
|
+
const len = colors.length * 4;
|
|
433
|
+
if (state.palettePixelData.length !== len) {
|
|
434
|
+
state.palettePixelData = new Uint8Array(len);
|
|
435
|
+
}
|
|
436
|
+
const { palettePixelData } = state;
|
|
437
|
+
for (let i = 0;i < colors.length; i++) {
|
|
438
|
+
const color = parseColorRgba(state.colorCtx, colors[i]);
|
|
439
|
+
palettePixelData[i * 4] = color[0];
|
|
440
|
+
palettePixelData[i * 4 + 1] = color[1];
|
|
441
|
+
palettePixelData[i * 4 + 2] = color[2];
|
|
442
|
+
palettePixelData[i * 4 + 3] = color[3];
|
|
443
|
+
}
|
|
444
|
+
return true;
|
|
445
|
+
};
|
|
446
|
+
var checkerboard = createEffect({
|
|
447
|
+
type: "remotion/checkerboard",
|
|
448
|
+
label: "checkerboard()",
|
|
449
|
+
documentationLink: "https://www.remotion.dev/docs/effects/checkerboard",
|
|
450
|
+
backend: "webgl2",
|
|
451
|
+
calculateKey: (params) => {
|
|
452
|
+
const r = resolve(params);
|
|
453
|
+
const maskSuffix = r.maskToSourceAlpha ? "-mask-to-source-alpha" : "";
|
|
454
|
+
return `checkerboard-${r.colors.join("|")}-${r.cellSize}-${r.spacing}-${r.angle}-${r.offsetX}-${r.offsetY}${maskSuffix}`;
|
|
455
|
+
},
|
|
456
|
+
setup: (target) => setupCheckerboard(target),
|
|
457
|
+
apply: ({ source, width, height, params, state, flipSourceY }) => {
|
|
458
|
+
const r = resolve(params);
|
|
459
|
+
const paletteDirty = updatePalette(state, r.colors);
|
|
460
|
+
const { gl, program, sourceTexture, paletteTexture, uniforms, vao } = state;
|
|
461
|
+
gl.viewport(0, 0, width, height);
|
|
462
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
463
|
+
gl.clearColor(0, 0, 0, 0);
|
|
464
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
465
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
466
|
+
gl.bindTexture(gl.TEXTURE_2D, sourceTexture);
|
|
467
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
468
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
|
|
469
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
|
|
470
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
471
|
+
gl.bindTexture(gl.TEXTURE_2D, paletteTexture);
|
|
472
|
+
if (paletteDirty) {
|
|
473
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
474
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
|
|
475
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, r.colors.length, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, state.palettePixelData);
|
|
476
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
477
|
+
}
|
|
478
|
+
gl.useProgram(program);
|
|
479
|
+
if (uniforms.uSource)
|
|
480
|
+
gl.uniform1i(uniforms.uSource, 0);
|
|
481
|
+
if (uniforms.uPalette)
|
|
482
|
+
gl.uniform1i(uniforms.uPalette, 1);
|
|
483
|
+
if (uniforms.uResolution)
|
|
484
|
+
gl.uniform2f(uniforms.uResolution, width, height);
|
|
485
|
+
if (uniforms.uNumColors)
|
|
486
|
+
gl.uniform1f(uniforms.uNumColors, r.colors.length);
|
|
487
|
+
if (uniforms.uCellSize)
|
|
488
|
+
gl.uniform1f(uniforms.uCellSize, r.cellSize);
|
|
489
|
+
if (uniforms.uSpacing)
|
|
490
|
+
gl.uniform1f(uniforms.uSpacing, r.spacing);
|
|
491
|
+
if (uniforms.uAngle)
|
|
492
|
+
gl.uniform1f(uniforms.uAngle, r.angle * Math.PI / 180);
|
|
493
|
+
if (uniforms.uOffset)
|
|
494
|
+
gl.uniform2f(uniforms.uOffset, r.offsetX, r.offsetY);
|
|
495
|
+
if (uniforms.uMaskToSourceAlpha)
|
|
496
|
+
gl.uniform1i(uniforms.uMaskToSourceAlpha, r.maskToSourceAlpha ? 1 : 0);
|
|
497
|
+
gl.bindVertexArray(vao);
|
|
498
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
499
|
+
gl.bindVertexArray(null);
|
|
500
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
501
|
+
gl.useProgram(null);
|
|
502
|
+
},
|
|
503
|
+
cleanup: ({ gl, program, vao, vbo, sourceTexture, paletteTexture }) => {
|
|
504
|
+
gl.deleteTexture(sourceTexture);
|
|
505
|
+
gl.deleteTexture(paletteTexture);
|
|
506
|
+
gl.deleteBuffer(vbo);
|
|
507
|
+
gl.deleteProgram(program);
|
|
508
|
+
gl.deleteVertexArray(vao);
|
|
509
|
+
},
|
|
510
|
+
schema: checkerboardSchema,
|
|
511
|
+
validateParams: validateCheckerboardParams
|
|
512
|
+
});
|
|
513
|
+
export {
|
|
514
|
+
checkerboardSchema,
|
|
515
|
+
checkerboard
|
|
516
|
+
};
|
|
@@ -325,7 +325,7 @@ var validateChromaticAberrationParams = (params) => {
|
|
|
325
325
|
validateNonNegative(resolved.amount, "amount");
|
|
326
326
|
};
|
|
327
327
|
var chromaticAberration = createEffect({
|
|
328
|
-
type: "remotion
|
|
328
|
+
type: "dev.remotion.effects.chromaticAberration",
|
|
329
329
|
label: "chromaticAberration()",
|
|
330
330
|
documentationLink: "https://www.remotion.dev/docs/effects/chromatic-aberration",
|
|
331
331
|
backend: "webgl2",
|
package/dist/esm/color-key.mjs
CHANGED
|
@@ -374,7 +374,7 @@ var parseKeyColor = (state, color) => {
|
|
|
374
374
|
];
|
|
375
375
|
};
|
|
376
376
|
var colorKey = createEffect({
|
|
377
|
-
type: "remotion
|
|
377
|
+
type: "dev.remotion.effects.colorKey",
|
|
378
378
|
label: "colorKey()",
|
|
379
379
|
documentationLink: "https://www.remotion.dev/docs/effects/color-key",
|
|
380
380
|
backend: "webgl2",
|
|
@@ -493,7 +493,7 @@ var setupContourLines = (target) => {
|
|
|
493
493
|
};
|
|
494
494
|
};
|
|
495
495
|
var contourLines = createEffect({
|
|
496
|
-
type: "remotion
|
|
496
|
+
type: "dev.remotion.effects.contourLines",
|
|
497
497
|
label: "contourLines()",
|
|
498
498
|
documentationLink: "https://www.remotion.dev/docs/effects/contour-lines",
|
|
499
499
|
backend: "webgl2",
|
package/dist/esm/contrast.mjs
CHANGED
|
@@ -121,7 +121,7 @@ var validateContrastParams = (params) => {
|
|
|
121
121
|
validateNonNegative(amount, "amount");
|
|
122
122
|
};
|
|
123
123
|
var contrast = createEffect({
|
|
124
|
-
type: "remotion
|
|
124
|
+
type: "dev.remotion.effects.contrast",
|
|
125
125
|
label: "contrast()",
|
|
126
126
|
documentationLink: "https://www.remotion.dev/docs/effects/contrast",
|
|
127
127
|
backend: "2d",
|
package/dist/esm/dot-grid.mjs
CHANGED
|
@@ -238,7 +238,7 @@ var linkProgram = (gl, vs, fs) => {
|
|
|
238
238
|
return program;
|
|
239
239
|
};
|
|
240
240
|
var dotGrid = createEffect({
|
|
241
|
-
type: "remotion
|
|
241
|
+
type: "dev.remotion.effects.dotGrid",
|
|
242
242
|
label: "dotGrid()",
|
|
243
243
|
documentationLink: "https://www.remotion.dev/docs/effects/dot-grid",
|
|
244
244
|
backend: "webgl2",
|
package/dist/esm/drop-shadow.mjs
CHANGED
|
@@ -588,7 +588,7 @@ var validateDropShadowParams = (params) => {
|
|
|
588
588
|
validateUnitInterval(r.opacity, "opacity");
|
|
589
589
|
};
|
|
590
590
|
var dropShadow = createEffect({
|
|
591
|
-
type: "remotion
|
|
591
|
+
type: "dev.remotion.effects.dropShadow",
|
|
592
592
|
label: "dropShadow()",
|
|
593
593
|
documentationLink: "https://www.remotion.dev/docs/effects/drop-shadow",
|
|
594
594
|
backend: "webgl2",
|
package/dist/esm/duotone.mjs
CHANGED
|
@@ -324,7 +324,7 @@ var getParsedColors = (state, resolved) => {
|
|
|
324
324
|
};
|
|
325
325
|
};
|
|
326
326
|
var duotone = createEffect({
|
|
327
|
-
type: "remotion
|
|
327
|
+
type: "dev.remotion.effects.duotone",
|
|
328
328
|
label: "duotone()",
|
|
329
329
|
documentationLink: "https://www.remotion.dev/docs/effects/duotone",
|
|
330
330
|
backend: "webgl2",
|