@remotion/effects 4.0.467 → 4.0.468
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/color-utils.d.ts +2 -0
- package/dist/duotone.d.ts +31 -0
- package/dist/esm/barrel-distortion.mjs +14 -1
- package/dist/esm/blur.mjs +7 -1
- package/dist/esm/brightness.mjs +14 -1
- package/dist/esm/chromatic-aberration.mjs +14 -1
- package/dist/esm/contrast.mjs +14 -1
- package/dist/esm/duotone.mjs +365 -0
- package/dist/esm/glow.mjs +585 -0
- package/dist/esm/grayscale.mjs +14 -1
- package/dist/esm/halftone.mjs +17 -18
- package/dist/esm/hue.mjs +14 -1
- package/dist/esm/invert.mjs +14 -1
- package/dist/esm/mirror.mjs +14 -1
- package/dist/esm/saturation.mjs +14 -1
- package/dist/esm/scale.mjs +7 -1
- package/dist/esm/shine.mjs +389 -0
- package/dist/esm/tint.mjs +14 -1
- package/dist/esm/translate.mjs +15 -2
- package/dist/esm/vignette.mjs +439 -0
- package/dist/esm/wave.mjs +7 -1
- package/dist/glow/glow-runtime.d.ts +52 -0
- package/dist/glow/glow-shaders.d.ts +5 -0
- package/dist/glow/index.d.ts +13 -0
- package/dist/glow.d.ts +1 -0
- package/dist/shine.d.ts +17 -0
- package/dist/validate-effect-param.d.ts +1 -0
- package/dist/vignette.d.ts +68 -0
- package/package.json +35 -3
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
// src/glow/index.ts
|
|
2
|
+
import { Internals as Internals2 } 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
|
+
|
|
27
|
+
// src/color-utils.ts
|
|
28
|
+
var DEFAULT_AMOUNT = 1;
|
|
29
|
+
var DEFAULT_BRIGHTNESS_AMOUNT = 0;
|
|
30
|
+
var DEFAULT_HUE_DEGREES = 0;
|
|
31
|
+
var colorAmountSchema = {
|
|
32
|
+
type: "number",
|
|
33
|
+
min: 0,
|
|
34
|
+
max: 1,
|
|
35
|
+
step: 0.01,
|
|
36
|
+
default: DEFAULT_AMOUNT,
|
|
37
|
+
description: "Amount"
|
|
38
|
+
};
|
|
39
|
+
var colorMultiplierSchema = {
|
|
40
|
+
type: "number",
|
|
41
|
+
min: 0,
|
|
42
|
+
step: 0.01,
|
|
43
|
+
default: DEFAULT_AMOUNT,
|
|
44
|
+
description: "Amount"
|
|
45
|
+
};
|
|
46
|
+
var brightnessAmountSchema = {
|
|
47
|
+
type: "number",
|
|
48
|
+
min: -1,
|
|
49
|
+
max: 1,
|
|
50
|
+
step: 0.01,
|
|
51
|
+
default: DEFAULT_BRIGHTNESS_AMOUNT,
|
|
52
|
+
description: "Amount"
|
|
53
|
+
};
|
|
54
|
+
var hueDegreesSchema = {
|
|
55
|
+
type: "number",
|
|
56
|
+
step: 1,
|
|
57
|
+
default: DEFAULT_HUE_DEGREES,
|
|
58
|
+
description: "Degrees"
|
|
59
|
+
};
|
|
60
|
+
var assertOptionalFiniteNumber = (value, name) => {
|
|
61
|
+
if (value === undefined) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
assertRequiredFiniteNumber(value, name);
|
|
65
|
+
};
|
|
66
|
+
var validateUnitInterval = (value, name) => {
|
|
67
|
+
if (value < 0) {
|
|
68
|
+
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
69
|
+
}
|
|
70
|
+
if (value > 1) {
|
|
71
|
+
throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var validateNonNegative = (value, name) => {
|
|
75
|
+
if (value < 0) {
|
|
76
|
+
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var validateSignedUnitInterval = (value, name) => {
|
|
80
|
+
if (value < -1) {
|
|
81
|
+
throw new TypeError(`"${name}" must be >= -1, but got ${JSON.stringify(value)}`);
|
|
82
|
+
}
|
|
83
|
+
if (value > 1) {
|
|
84
|
+
throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var clampColorChannel = (value) => {
|
|
88
|
+
return Math.max(0, Math.min(255, value));
|
|
89
|
+
};
|
|
90
|
+
var parseColorRgba = (ctx, color) => {
|
|
91
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
92
|
+
ctx.fillStyle = color;
|
|
93
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
94
|
+
const { data } = ctx.getImageData(0, 0, 1, 1);
|
|
95
|
+
return [data[0], data[1], data[2], data[3]];
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// src/glow/glow-runtime.ts
|
|
99
|
+
import { Internals } from "remotion";
|
|
100
|
+
|
|
101
|
+
// src/glow/glow-shaders.ts
|
|
102
|
+
var GLOW_VS = `#version 300 es
|
|
103
|
+
layout(location = 0) in vec2 aPos;
|
|
104
|
+
layout(location = 1) in vec2 aUv;
|
|
105
|
+
out vec2 vUv;
|
|
106
|
+
|
|
107
|
+
void main() {
|
|
108
|
+
vUv = aUv;
|
|
109
|
+
gl_Position = vec4(aPos, 0.0, 1.0);
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
var GLOW_EXTRACT_FS = `#version 300 es
|
|
113
|
+
precision highp float;
|
|
114
|
+
|
|
115
|
+
in vec2 vUv;
|
|
116
|
+
out vec4 fragColor;
|
|
117
|
+
|
|
118
|
+
uniform sampler2D uSource;
|
|
119
|
+
uniform vec4 uColor;
|
|
120
|
+
uniform float uThreshold;
|
|
121
|
+
|
|
122
|
+
void main() {
|
|
123
|
+
vec4 source = texture(uSource, vUv);
|
|
124
|
+
float alpha = source.a;
|
|
125
|
+
|
|
126
|
+
if (alpha <= 0.001) {
|
|
127
|
+
fragColor = vec4(0.0);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
vec3 rgb = source.rgb / alpha;
|
|
132
|
+
float luminance = dot(rgb, vec3(0.299, 0.587, 0.114));
|
|
133
|
+
float threshold = clamp(uThreshold, 0.0, 1.0);
|
|
134
|
+
float contribution = threshold >= 1.0
|
|
135
|
+
? step(1.0, luminance)
|
|
136
|
+
: clamp((luminance - threshold) / max(1.0 - threshold, 0.0001), 0.0, 1.0);
|
|
137
|
+
float glowAlpha = alpha * contribution * uColor.a;
|
|
138
|
+
|
|
139
|
+
fragColor = vec4(uColor.rgb * glowAlpha, glowAlpha);
|
|
140
|
+
}
|
|
141
|
+
`;
|
|
142
|
+
var buildBlurFs = (direction) => {
|
|
143
|
+
const dirVec = direction === "horizontal" ? "vec2(1.0, 0.0)" : "vec2(0.0, 1.0)";
|
|
144
|
+
return `#version 300 es
|
|
145
|
+
precision highp float;
|
|
146
|
+
|
|
147
|
+
in vec2 vUv;
|
|
148
|
+
out vec4 fragColor;
|
|
149
|
+
|
|
150
|
+
uniform sampler2D uSource;
|
|
151
|
+
uniform float uRadius;
|
|
152
|
+
uniform vec2 uTexelSize;
|
|
153
|
+
|
|
154
|
+
const int KERNEL_HALF = 4;
|
|
155
|
+
const vec2 DIRECTION = ${dirVec};
|
|
156
|
+
|
|
157
|
+
void main() {
|
|
158
|
+
if (uRadius <= 0.0) {
|
|
159
|
+
fragColor = texture(uSource, vUv);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
float pixelStride = uRadius / float(KERNEL_HALF);
|
|
164
|
+
float sigma = uRadius / 3.0;
|
|
165
|
+
float twoSigmaSq = 2.0 * sigma * sigma;
|
|
166
|
+
|
|
167
|
+
vec4 sum = vec4(0.0);
|
|
168
|
+
float weightSum = 0.0;
|
|
169
|
+
|
|
170
|
+
for (int i = -KERNEL_HALF; i <= KERNEL_HALF; ++i) {
|
|
171
|
+
float offsetPx = float(i) * pixelStride;
|
|
172
|
+
float w = exp(-(offsetPx * offsetPx) / twoSigmaSq);
|
|
173
|
+
vec2 uv = vUv + DIRECTION * uTexelSize * offsetPx;
|
|
174
|
+
sum += texture(uSource, uv) * w;
|
|
175
|
+
weightSum += w;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
fragColor = sum / weightSum;
|
|
179
|
+
}
|
|
180
|
+
`;
|
|
181
|
+
};
|
|
182
|
+
var GLOW_BLUR_FS_HORIZONTAL = buildBlurFs("horizontal");
|
|
183
|
+
var GLOW_BLUR_FS_VERTICAL = buildBlurFs("vertical");
|
|
184
|
+
var GLOW_COMPOSITE_FS = `#version 300 es
|
|
185
|
+
precision highp float;
|
|
186
|
+
|
|
187
|
+
in vec2 vUv;
|
|
188
|
+
out vec4 fragColor;
|
|
189
|
+
|
|
190
|
+
uniform sampler2D uSource;
|
|
191
|
+
uniform sampler2D uGlow;
|
|
192
|
+
uniform float uIntensity;
|
|
193
|
+
|
|
194
|
+
void main() {
|
|
195
|
+
vec4 source = texture(uSource, vUv);
|
|
196
|
+
vec4 glow = texture(uGlow, vUv) * max(uIntensity, 0.0);
|
|
197
|
+
vec4 outColor = source + glow;
|
|
198
|
+
|
|
199
|
+
fragColor = vec4(min(outColor.rgb, vec3(1.0)), min(outColor.a, 1.0));
|
|
200
|
+
}
|
|
201
|
+
`;
|
|
202
|
+
|
|
203
|
+
// src/glow/glow-runtime.ts
|
|
204
|
+
var { createWebGL2ContextError } = Internals;
|
|
205
|
+
var compileShader = (gl, type, source) => {
|
|
206
|
+
const shader = gl.createShader(type);
|
|
207
|
+
if (!shader) {
|
|
208
|
+
throw new Error("Failed to create WebGL shader");
|
|
209
|
+
}
|
|
210
|
+
gl.shaderSource(shader, source);
|
|
211
|
+
gl.compileShader(shader);
|
|
212
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
213
|
+
const log = gl.getShaderInfoLog(shader);
|
|
214
|
+
gl.deleteShader(shader);
|
|
215
|
+
throw new Error(`Glow shader compile failed: ${log ?? "(no log)"}`);
|
|
216
|
+
}
|
|
217
|
+
return shader;
|
|
218
|
+
};
|
|
219
|
+
var linkProgram = (gl, vs, fs) => {
|
|
220
|
+
const program = gl.createProgram();
|
|
221
|
+
if (!program) {
|
|
222
|
+
throw new Error("Failed to create WebGL program");
|
|
223
|
+
}
|
|
224
|
+
gl.attachShader(program, vs);
|
|
225
|
+
gl.attachShader(program, fs);
|
|
226
|
+
gl.linkProgram(program);
|
|
227
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
228
|
+
const log = gl.getProgramInfoLog(program);
|
|
229
|
+
gl.deleteProgram(program);
|
|
230
|
+
throw new Error(`Glow program link failed: ${log ?? "(no log)"}`);
|
|
231
|
+
}
|
|
232
|
+
return program;
|
|
233
|
+
};
|
|
234
|
+
var createProgram = (gl, vertexSource, fragmentSource) => {
|
|
235
|
+
const vs = compileShader(gl, gl.VERTEX_SHADER, vertexSource);
|
|
236
|
+
const fs = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
|
|
237
|
+
const program = linkProgram(gl, vs, fs);
|
|
238
|
+
gl.deleteShader(vs);
|
|
239
|
+
gl.deleteShader(fs);
|
|
240
|
+
return program;
|
|
241
|
+
};
|
|
242
|
+
var createRgbaTexture = (gl) => {
|
|
243
|
+
const texture = gl.createTexture();
|
|
244
|
+
if (!texture) {
|
|
245
|
+
throw new Error("Failed to create WebGL texture");
|
|
246
|
+
}
|
|
247
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
248
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
249
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
250
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
251
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
252
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
253
|
+
return texture;
|
|
254
|
+
};
|
|
255
|
+
var getBlurUniforms = (gl, program) => ({
|
|
256
|
+
uRadius: gl.getUniformLocation(program, "uRadius"),
|
|
257
|
+
uTexelSize: gl.getUniformLocation(program, "uTexelSize"),
|
|
258
|
+
uSource: gl.getUniformLocation(program, "uSource")
|
|
259
|
+
});
|
|
260
|
+
var setupGlow = (target) => {
|
|
261
|
+
const gl = target.getContext("webgl2", {
|
|
262
|
+
premultipliedAlpha: true,
|
|
263
|
+
alpha: true,
|
|
264
|
+
preserveDrawingBuffer: true
|
|
265
|
+
});
|
|
266
|
+
if (!gl) {
|
|
267
|
+
throw createWebGL2ContextError("glow effect");
|
|
268
|
+
}
|
|
269
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
270
|
+
const programExtract = createProgram(gl, GLOW_VS, GLOW_EXTRACT_FS);
|
|
271
|
+
const programHorizontal = createProgram(gl, GLOW_VS, GLOW_BLUR_FS_HORIZONTAL);
|
|
272
|
+
const programVertical = createProgram(gl, GLOW_VS, GLOW_BLUR_FS_VERTICAL);
|
|
273
|
+
const programComposite = createProgram(gl, GLOW_VS, GLOW_COMPOSITE_FS);
|
|
274
|
+
const vao = gl.createVertexArray();
|
|
275
|
+
if (!vao) {
|
|
276
|
+
throw new Error("Failed to create WebGL vertex array");
|
|
277
|
+
}
|
|
278
|
+
gl.bindVertexArray(vao);
|
|
279
|
+
const data = new Float32Array([
|
|
280
|
+
-1,
|
|
281
|
+
-1,
|
|
282
|
+
0,
|
|
283
|
+
0,
|
|
284
|
+
1,
|
|
285
|
+
-1,
|
|
286
|
+
1,
|
|
287
|
+
0,
|
|
288
|
+
-1,
|
|
289
|
+
1,
|
|
290
|
+
0,
|
|
291
|
+
1,
|
|
292
|
+
1,
|
|
293
|
+
1,
|
|
294
|
+
1,
|
|
295
|
+
1
|
|
296
|
+
]);
|
|
297
|
+
const vbo = gl.createBuffer();
|
|
298
|
+
if (!vbo) {
|
|
299
|
+
throw new Error("Failed to create WebGL buffer");
|
|
300
|
+
}
|
|
301
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
302
|
+
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
|
303
|
+
gl.enableVertexAttribArray(0);
|
|
304
|
+
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 16, 0);
|
|
305
|
+
gl.enableVertexAttribArray(1);
|
|
306
|
+
gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 16, 8);
|
|
307
|
+
gl.bindVertexArray(null);
|
|
308
|
+
const textureSource = createRgbaTexture(gl);
|
|
309
|
+
const textureGlowA = createRgbaTexture(gl);
|
|
310
|
+
const textureGlowB = createRgbaTexture(gl);
|
|
311
|
+
const framebuffer = gl.createFramebuffer();
|
|
312
|
+
if (!framebuffer) {
|
|
313
|
+
throw new Error("Failed to create WebGL framebuffer");
|
|
314
|
+
}
|
|
315
|
+
const colorCanvas = document.createElement("canvas");
|
|
316
|
+
colorCanvas.width = 1;
|
|
317
|
+
colorCanvas.height = 1;
|
|
318
|
+
const colorCtx = colorCanvas.getContext("2d", { willReadFrequently: true });
|
|
319
|
+
if (!colorCtx) {
|
|
320
|
+
throw new Error("Failed to acquire 2D context for color parsing");
|
|
321
|
+
}
|
|
322
|
+
return {
|
|
323
|
+
gl,
|
|
324
|
+
programExtract,
|
|
325
|
+
programHorizontal,
|
|
326
|
+
programVertical,
|
|
327
|
+
programComposite,
|
|
328
|
+
vao,
|
|
329
|
+
vbo,
|
|
330
|
+
textureSource,
|
|
331
|
+
textureGlowA,
|
|
332
|
+
textureGlowB,
|
|
333
|
+
framebuffer,
|
|
334
|
+
extract: {
|
|
335
|
+
uSource: gl.getUniformLocation(programExtract, "uSource"),
|
|
336
|
+
uColor: gl.getUniformLocation(programExtract, "uColor"),
|
|
337
|
+
uThreshold: gl.getUniformLocation(programExtract, "uThreshold")
|
|
338
|
+
},
|
|
339
|
+
horizontal: getBlurUniforms(gl, programHorizontal),
|
|
340
|
+
vertical: getBlurUniforms(gl, programVertical),
|
|
341
|
+
composite: {
|
|
342
|
+
uSource: gl.getUniformLocation(programComposite, "uSource"),
|
|
343
|
+
uGlow: gl.getUniformLocation(programComposite, "uGlow"),
|
|
344
|
+
uIntensity: gl.getUniformLocation(programComposite, "uIntensity")
|
|
345
|
+
},
|
|
346
|
+
colorCtx,
|
|
347
|
+
cachedColorStr: "",
|
|
348
|
+
cachedColorRgba: [255, 255, 255, 255]
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
var cleanupGlow = ({
|
|
352
|
+
gl,
|
|
353
|
+
programExtract,
|
|
354
|
+
programHorizontal,
|
|
355
|
+
programVertical,
|
|
356
|
+
programComposite,
|
|
357
|
+
vao,
|
|
358
|
+
vbo,
|
|
359
|
+
textureSource,
|
|
360
|
+
textureGlowA,
|
|
361
|
+
textureGlowB,
|
|
362
|
+
framebuffer
|
|
363
|
+
}) => {
|
|
364
|
+
gl.deleteFramebuffer(framebuffer);
|
|
365
|
+
gl.deleteTexture(textureSource);
|
|
366
|
+
gl.deleteTexture(textureGlowA);
|
|
367
|
+
gl.deleteTexture(textureGlowB);
|
|
368
|
+
gl.deleteBuffer(vbo);
|
|
369
|
+
gl.deleteProgram(programExtract);
|
|
370
|
+
gl.deleteProgram(programHorizontal);
|
|
371
|
+
gl.deleteProgram(programVertical);
|
|
372
|
+
gl.deleteProgram(programComposite);
|
|
373
|
+
gl.deleteVertexArray(vao);
|
|
374
|
+
};
|
|
375
|
+
var drawFullscreenQuad = (state) => {
|
|
376
|
+
const { gl, vao } = state;
|
|
377
|
+
gl.bindVertexArray(vao);
|
|
378
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
379
|
+
gl.bindVertexArray(null);
|
|
380
|
+
};
|
|
381
|
+
var setTextureSize = (gl, texture, width, height) => {
|
|
382
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
383
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
384
|
+
};
|
|
385
|
+
var setFramebufferTexture = (gl, framebuffer, texture) => {
|
|
386
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
387
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
|
|
388
|
+
const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
|
|
389
|
+
if (status !== gl.FRAMEBUFFER_COMPLETE) {
|
|
390
|
+
throw new Error(`Glow framebuffer incomplete: 0x${status.toString(16)}`);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
var setBlurUniforms = ({
|
|
394
|
+
gl,
|
|
395
|
+
uniforms,
|
|
396
|
+
radius,
|
|
397
|
+
width,
|
|
398
|
+
height
|
|
399
|
+
}) => {
|
|
400
|
+
if (uniforms.uSource)
|
|
401
|
+
gl.uniform1i(uniforms.uSource, 0);
|
|
402
|
+
if (uniforms.uRadius)
|
|
403
|
+
gl.uniform1f(uniforms.uRadius, radius);
|
|
404
|
+
if (uniforms.uTexelSize)
|
|
405
|
+
gl.uniform2f(uniforms.uTexelSize, 1 / width, 1 / height);
|
|
406
|
+
};
|
|
407
|
+
var normalizedColor = (color) => {
|
|
408
|
+
return [color[0] / 255, color[1] / 255, color[2] / 255, color[3] / 255];
|
|
409
|
+
};
|
|
410
|
+
var applyGlow = ({
|
|
411
|
+
state,
|
|
412
|
+
source,
|
|
413
|
+
width,
|
|
414
|
+
height,
|
|
415
|
+
radius,
|
|
416
|
+
intensity,
|
|
417
|
+
threshold,
|
|
418
|
+
color,
|
|
419
|
+
flipSourceY
|
|
420
|
+
}) => {
|
|
421
|
+
const {
|
|
422
|
+
gl,
|
|
423
|
+
textureSource,
|
|
424
|
+
textureGlowA,
|
|
425
|
+
textureGlowB,
|
|
426
|
+
framebuffer,
|
|
427
|
+
programExtract,
|
|
428
|
+
programHorizontal,
|
|
429
|
+
programVertical,
|
|
430
|
+
programComposite
|
|
431
|
+
} = state;
|
|
432
|
+
gl.viewport(0, 0, width, height);
|
|
433
|
+
gl.clearColor(0, 0, 0, 0);
|
|
434
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
435
|
+
gl.bindTexture(gl.TEXTURE_2D, textureSource);
|
|
436
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
|
|
437
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
|
|
438
|
+
setTextureSize(gl, textureGlowA, width, height);
|
|
439
|
+
setTextureSize(gl, textureGlowB, width, height);
|
|
440
|
+
const [r, g, b, a] = normalizedColor(color);
|
|
441
|
+
setFramebufferTexture(gl, framebuffer, textureGlowA);
|
|
442
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
443
|
+
gl.useProgram(programExtract);
|
|
444
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
445
|
+
gl.bindTexture(gl.TEXTURE_2D, textureSource);
|
|
446
|
+
if (state.extract.uSource)
|
|
447
|
+
gl.uniform1i(state.extract.uSource, 0);
|
|
448
|
+
if (state.extract.uColor)
|
|
449
|
+
gl.uniform4f(state.extract.uColor, r, g, b, a);
|
|
450
|
+
if (state.extract.uThreshold)
|
|
451
|
+
gl.uniform1f(state.extract.uThreshold, threshold);
|
|
452
|
+
drawFullscreenQuad(state);
|
|
453
|
+
setFramebufferTexture(gl, framebuffer, textureGlowB);
|
|
454
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
455
|
+
gl.useProgram(programHorizontal);
|
|
456
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
457
|
+
gl.bindTexture(gl.TEXTURE_2D, textureGlowA);
|
|
458
|
+
setBlurUniforms({
|
|
459
|
+
gl,
|
|
460
|
+
uniforms: state.horizontal,
|
|
461
|
+
radius,
|
|
462
|
+
width,
|
|
463
|
+
height
|
|
464
|
+
});
|
|
465
|
+
drawFullscreenQuad(state);
|
|
466
|
+
setFramebufferTexture(gl, framebuffer, textureGlowA);
|
|
467
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
468
|
+
gl.useProgram(programVertical);
|
|
469
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
470
|
+
gl.bindTexture(gl.TEXTURE_2D, textureGlowB);
|
|
471
|
+
setBlurUniforms({
|
|
472
|
+
gl,
|
|
473
|
+
uniforms: state.vertical,
|
|
474
|
+
radius,
|
|
475
|
+
width,
|
|
476
|
+
height
|
|
477
|
+
});
|
|
478
|
+
drawFullscreenQuad(state);
|
|
479
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
480
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
481
|
+
gl.useProgram(programComposite);
|
|
482
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
483
|
+
gl.bindTexture(gl.TEXTURE_2D, textureSource);
|
|
484
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
485
|
+
gl.bindTexture(gl.TEXTURE_2D, textureGlowA);
|
|
486
|
+
if (state.composite.uSource)
|
|
487
|
+
gl.uniform1i(state.composite.uSource, 0);
|
|
488
|
+
if (state.composite.uGlow)
|
|
489
|
+
gl.uniform1i(state.composite.uGlow, 1);
|
|
490
|
+
if (state.composite.uIntensity)
|
|
491
|
+
gl.uniform1f(state.composite.uIntensity, intensity);
|
|
492
|
+
drawFullscreenQuad(state);
|
|
493
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
494
|
+
gl.useProgram(null);
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
// src/glow/index.ts
|
|
498
|
+
var { createEffect } = Internals2;
|
|
499
|
+
var DEFAULT_RADIUS = 20;
|
|
500
|
+
var DEFAULT_INTENSITY = 1;
|
|
501
|
+
var DEFAULT_THRESHOLD = 0;
|
|
502
|
+
var DEFAULT_COLOR = "#ffffff";
|
|
503
|
+
var glowSchema = {
|
|
504
|
+
radius: {
|
|
505
|
+
type: "number",
|
|
506
|
+
min: 0,
|
|
507
|
+
max: 100,
|
|
508
|
+
step: 1,
|
|
509
|
+
default: DEFAULT_RADIUS,
|
|
510
|
+
description: "Radius"
|
|
511
|
+
},
|
|
512
|
+
intensity: {
|
|
513
|
+
type: "number",
|
|
514
|
+
min: 0,
|
|
515
|
+
max: 5,
|
|
516
|
+
step: 0.1,
|
|
517
|
+
default: DEFAULT_INTENSITY,
|
|
518
|
+
description: "Intensity"
|
|
519
|
+
},
|
|
520
|
+
threshold: {
|
|
521
|
+
type: "number",
|
|
522
|
+
min: 0,
|
|
523
|
+
max: 1,
|
|
524
|
+
step: 0.01,
|
|
525
|
+
default: DEFAULT_THRESHOLD,
|
|
526
|
+
description: "Threshold"
|
|
527
|
+
},
|
|
528
|
+
color: {
|
|
529
|
+
type: "color",
|
|
530
|
+
default: DEFAULT_COLOR,
|
|
531
|
+
description: "Color"
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
var resolve = (p) => ({
|
|
535
|
+
radius: p.radius ?? DEFAULT_RADIUS,
|
|
536
|
+
intensity: p.intensity ?? DEFAULT_INTENSITY,
|
|
537
|
+
threshold: p.threshold ?? DEFAULT_THRESHOLD,
|
|
538
|
+
color: p.color ?? DEFAULT_COLOR
|
|
539
|
+
});
|
|
540
|
+
var validateGlowParams = (params) => {
|
|
541
|
+
assertEffectParamsObject(params, "Glow");
|
|
542
|
+
assertOptionalFiniteNumber(params.radius, "radius");
|
|
543
|
+
assertOptionalFiniteNumber(params.intensity, "intensity");
|
|
544
|
+
assertOptionalFiniteNumber(params.threshold, "threshold");
|
|
545
|
+
assertOptionalColor(params.color, "color");
|
|
546
|
+
const r = resolve(params);
|
|
547
|
+
validateNonNegative(r.radius, "radius");
|
|
548
|
+
validateNonNegative(r.intensity, "intensity");
|
|
549
|
+
validateUnitInterval(r.threshold, "threshold");
|
|
550
|
+
};
|
|
551
|
+
var glow = createEffect({
|
|
552
|
+
type: "remotion/glow",
|
|
553
|
+
label: "Glow",
|
|
554
|
+
documentationLink: "https://www.remotion.dev/docs/effects/glow",
|
|
555
|
+
backend: "webgl2",
|
|
556
|
+
calculateKey: (params) => {
|
|
557
|
+
const r = resolve(params);
|
|
558
|
+
return `glow-${r.radius}-${r.intensity}-${r.threshold}-${r.color}`;
|
|
559
|
+
},
|
|
560
|
+
setup: (target) => setupGlow(target),
|
|
561
|
+
apply: ({ source, width, height, params, state, flipSourceY }) => {
|
|
562
|
+
const r = resolve(params);
|
|
563
|
+
if (state.cachedColorStr !== r.color) {
|
|
564
|
+
state.cachedColorStr = r.color;
|
|
565
|
+
state.cachedColorRgba = parseColorRgba(state.colorCtx, r.color);
|
|
566
|
+
}
|
|
567
|
+
applyGlow({
|
|
568
|
+
state,
|
|
569
|
+
source,
|
|
570
|
+
width,
|
|
571
|
+
height,
|
|
572
|
+
radius: r.radius,
|
|
573
|
+
intensity: r.intensity,
|
|
574
|
+
threshold: r.threshold,
|
|
575
|
+
color: state.cachedColorRgba,
|
|
576
|
+
flipSourceY
|
|
577
|
+
});
|
|
578
|
+
},
|
|
579
|
+
cleanup: (state) => cleanupGlow(state),
|
|
580
|
+
schema: glowSchema,
|
|
581
|
+
validateParams: validateGlowParams
|
|
582
|
+
});
|
|
583
|
+
export {
|
|
584
|
+
glow
|
|
585
|
+
};
|
package/dist/esm/grayscale.mjs
CHANGED
|
@@ -17,6 +17,12 @@ var assertRequiredColor = (value, name) => {
|
|
|
17
17
|
throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
+
var assertOptionalColor = (value, name) => {
|
|
21
|
+
if (value === undefined) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
assertRequiredColor(value, name);
|
|
25
|
+
};
|
|
20
26
|
|
|
21
27
|
// src/color-utils.ts
|
|
22
28
|
var DEFAULT_AMOUNT = 1;
|
|
@@ -81,6 +87,13 @@ var validateSignedUnitInterval = (value, name) => {
|
|
|
81
87
|
var clampColorChannel = (value) => {
|
|
82
88
|
return Math.max(0, Math.min(255, value));
|
|
83
89
|
};
|
|
90
|
+
var parseColorRgba = (ctx, color) => {
|
|
91
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
92
|
+
ctx.fillStyle = color;
|
|
93
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
94
|
+
const { data } = ctx.getImageData(0, 0, 1, 1);
|
|
95
|
+
return [data[0], data[1], data[2], data[3]];
|
|
96
|
+
};
|
|
84
97
|
|
|
85
98
|
// src/grayscale.ts
|
|
86
99
|
var { createEffect } = Internals;
|
|
@@ -98,7 +111,7 @@ var validateGrayscaleParams = (params) => {
|
|
|
98
111
|
};
|
|
99
112
|
var grayscale = createEffect({
|
|
100
113
|
type: "remotion/grayscale",
|
|
101
|
-
label: "
|
|
114
|
+
label: "grayscale()",
|
|
102
115
|
documentationLink: "https://www.remotion.dev/docs/effects/grayscale",
|
|
103
116
|
backend: "2d",
|
|
104
117
|
calculateKey: (params) => {
|
package/dist/esm/halftone.mjs
CHANGED
|
@@ -17,6 +17,12 @@ var assertRequiredColor = (value, name) => {
|
|
|
17
17
|
throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
+
var assertOptionalColor = (value, name) => {
|
|
21
|
+
if (value === undefined) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
assertRequiredColor(value, name);
|
|
25
|
+
};
|
|
20
26
|
|
|
21
27
|
// src/color-utils.ts
|
|
22
28
|
var DEFAULT_AMOUNT = 1;
|
|
@@ -81,6 +87,13 @@ var validateSignedUnitInterval = (value, name) => {
|
|
|
81
87
|
var clampColorChannel = (value) => {
|
|
82
88
|
return Math.max(0, Math.min(255, value));
|
|
83
89
|
};
|
|
90
|
+
var parseColorRgba = (ctx, color) => {
|
|
91
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
92
|
+
ctx.fillStyle = color;
|
|
93
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
94
|
+
const { data } = ctx.getImageData(0, 0, 1, 1);
|
|
95
|
+
return [data[0], data[1], data[2], data[3]];
|
|
96
|
+
};
|
|
84
97
|
|
|
85
98
|
// src/halftone.ts
|
|
86
99
|
var { createEffect, createWebGL2ContextError } = Internals;
|
|
@@ -177,14 +190,6 @@ var assertOptionalBoolean = (value, name) => {
|
|
|
177
190
|
throw new TypeError(`"${name}" must be a boolean, but got ${JSON.stringify(value)}`);
|
|
178
191
|
}
|
|
179
192
|
};
|
|
180
|
-
var assertOptionalColor = (value, name) => {
|
|
181
|
-
if (value === undefined) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
185
|
-
throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
193
|
var resolve = (p) => ({
|
|
189
194
|
shape: p.shape ?? "circle",
|
|
190
195
|
dotSize: p.dotSize ?? 20,
|
|
@@ -342,16 +347,9 @@ var linkProgram = (gl, vs, fs) => {
|
|
|
342
347
|
}
|
|
343
348
|
return program;
|
|
344
349
|
};
|
|
345
|
-
var parseColorRgba = (ctx, color) => {
|
|
346
|
-
ctx.clearRect(0, 0, 1, 1);
|
|
347
|
-
ctx.fillStyle = color;
|
|
348
|
-
ctx.fillRect(0, 0, 1, 1);
|
|
349
|
-
const { data } = ctx.getImageData(0, 0, 1, 1);
|
|
350
|
-
return [data[0] / 255, data[1] / 255, data[2] / 255, data[3] / 255];
|
|
351
|
-
};
|
|
352
350
|
var halftone = createEffect({
|
|
353
351
|
type: "remotion/halftone",
|
|
354
|
-
label: "
|
|
352
|
+
label: "halftone()",
|
|
355
353
|
documentationLink: "https://www.remotion.dev/docs/effects/halftone",
|
|
356
354
|
backend: "webgl2",
|
|
357
355
|
calculateKey: (params) => {
|
|
@@ -442,7 +440,7 @@ var halftone = createEffect({
|
|
|
442
440
|
uUseSourceColor: gl.getUniformLocation(program, "uUseSourceColor"),
|
|
443
441
|
colorCtx,
|
|
444
442
|
cachedColorStr: "",
|
|
445
|
-
cachedColorRgba: [0, 0, 0,
|
|
443
|
+
cachedColorRgba: [0, 0, 0, 255]
|
|
446
444
|
};
|
|
447
445
|
},
|
|
448
446
|
apply: ({ source, width, height, params, state, flipSourceY }) => {
|
|
@@ -453,6 +451,7 @@ var halftone = createEffect({
|
|
|
453
451
|
state.cachedColorRgba = parseColorRgba(state.colorCtx, r.dotColor);
|
|
454
452
|
}
|
|
455
453
|
const [cr, cg, cb, ca] = state.cachedColorRgba;
|
|
454
|
+
const caNormalized = ca / 255;
|
|
456
455
|
const filter = r.sampling === "nearest" ? gl.NEAREST : gl.LINEAR;
|
|
457
456
|
gl.viewport(0, 0, width, height);
|
|
458
457
|
gl.clearColor(0, 0, 0, 0);
|
|
@@ -478,7 +477,7 @@ var halftone = createEffect({
|
|
|
478
477
|
if (state.uOffset)
|
|
479
478
|
gl.uniform2f(state.uOffset, r.offsetX, r.offsetY);
|
|
480
479
|
if (state.uColor)
|
|
481
|
-
gl.uniform4f(state.uColor, cr *
|
|
480
|
+
gl.uniform4f(state.uColor, cr / 255 * caNormalized, cg / 255 * caNormalized, cb / 255 * caNormalized, caNormalized);
|
|
482
481
|
if (state.uShape)
|
|
483
482
|
gl.uniform1i(state.uShape, SHAPE_INDEX[r.shape]);
|
|
484
483
|
if (state.uShadeOutside)
|