@remotion/effects 4.0.464 → 4.0.465

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,18 @@
1
1
  # @remotion/effects
2
2
 
3
- Experimental presets for Remotion canvas effect hooks
3
+ Effects that can be applied to Remotion-based canvas components
4
+
5
+ [![NPM Downloads](https://img.shields.io/npm/dm/@remotion/effects.svg?style=flat&color=black&label=Downloads)](https://npmcharts.com/compare/@remotion/effects?minimal=true)
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @remotion/effects --save-exact
11
+ ```
12
+
13
+ When installing a Remotion package, make sure to align the version of all `remotion` and `@remotion/*` packages to the same version.
14
+ Remove the `^` character from the version number to use the exact version.
4
15
 
5
16
  ## Usage
6
17
 
7
- This is an internal package and has no documentation.
18
+ See the [documentation](https://www.remotion.dev/docs/effects/api) for more information.
@@ -26,6 +26,9 @@ type ApplyBlurParams = {
26
26
  readonly width: number;
27
27
  readonly height: number;
28
28
  readonly radius: number;
29
+ readonly horizontal: boolean;
30
+ readonly vertical: boolean;
31
+ readonly flipSourceY: boolean;
29
32
  };
30
- export declare const applyBlur: ({ state, source, width, height, radius, }: ApplyBlurParams) => void;
33
+ export declare const applyBlur: ({ state, source, width, height, radius, horizontal, vertical, flipSourceY, }: ApplyBlurParams) => void;
31
34
  export {};
@@ -1,5 +1,9 @@
1
1
  export type BlurParams = {
2
2
  readonly radius: number;
3
+ /** Apply blur along the horizontal axis. Defaults to `true`. */
4
+ readonly horizontal?: boolean;
5
+ /** Apply blur along the vertical axis. Defaults to `true`. */
6
+ readonly vertical?: boolean;
3
7
  };
4
8
  export declare const blur: (params: BlurParams & {
5
9
  readonly disabled?: boolean | undefined;
package/dist/blur.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { blur, type BlurParams } from './blur/index.js';
@@ -0,0 +1,8 @@
1
+ export declare const EffectInternals: {
2
+ readonly halftone: (params?: (import("./halftone.js").HalftoneParams & {
3
+ readonly disabled?: boolean | undefined;
4
+ }) | undefined) => import("remotion").EffectDescriptor<unknown>;
5
+ readonly tint: (params: import("./tint.js").TintParams & {
6
+ readonly disabled?: boolean | undefined;
7
+ }) => import("remotion").EffectDescriptor<unknown>;
8
+ };
package/dist/esm/blur.mjs CHANGED
@@ -1,19 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, {
5
- get: all[name],
6
- enumerable: true,
7
- configurable: true,
8
- set: (newValue) => all[name] = () => newValue
9
- });
10
- };
11
-
12
1
  // src/blur/index.ts
13
- var exports_blur = {};
14
- __export(exports_blur, {
15
- blur: () => blur
16
- });
17
2
  import { Internals as Internals2 } from "remotion";
18
3
 
19
4
  // src/validate-effect-param.ts
@@ -155,7 +140,6 @@ var setupBlur = (target) => {
155
140
  throw createWebGL2ContextError("blur effect");
156
141
  }
157
142
  gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
158
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
159
143
  const programHorizontal = createProgram(gl, BLUR_VS, BLUR_FS_HORIZONTAL);
160
144
  const programVertical = createProgram(gl, BLUR_VS, BLUR_FS_VERTICAL);
161
145
  const vao = gl.createVertexArray();
@@ -262,12 +246,31 @@ var drawFullscreenQuad = (state) => {
262
246
  gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
263
247
  gl.bindVertexArray(null);
264
248
  };
249
+ var uploadBlurSource = ({
250
+ gl,
251
+ textureSource,
252
+ source,
253
+ textureIntermediate,
254
+ width,
255
+ height,
256
+ flipSourceY
257
+ }) => {
258
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
259
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
260
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
261
+ gl.bindTexture(gl.TEXTURE_2D, textureIntermediate);
262
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
263
+ gl.bindTexture(gl.TEXTURE_2D, null);
264
+ };
265
265
  var applyBlur = ({
266
266
  state,
267
267
  source,
268
268
  width,
269
269
  height,
270
- radius
270
+ radius,
271
+ horizontal,
272
+ vertical,
273
+ flipSourceY
271
274
  }) => {
272
275
  const {
273
276
  gl,
@@ -278,32 +281,72 @@ var applyBlur = ({
278
281
  framebuffer
279
282
  } = state;
280
283
  gl.viewport(0, 0, width, height);
281
- gl.bindTexture(gl.TEXTURE_2D, textureSource);
282
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
283
- gl.bindTexture(gl.TEXTURE_2D, textureIntermediate);
284
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
285
- gl.bindTexture(gl.TEXTURE_2D, null);
286
- gl.clearColor(0, 0, 0, 0);
287
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
288
- gl.clear(gl.COLOR_BUFFER_BIT);
289
- gl.activeTexture(gl.TEXTURE0);
290
- gl.bindTexture(gl.TEXTURE_2D, textureSource);
291
- gl.useProgram(programHorizontal);
292
- setBlurUniforms({
284
+ uploadBlurSource({
293
285
  gl,
294
- uniforms: state.horizontal,
295
- radius,
286
+ textureSource,
287
+ source,
288
+ textureIntermediate,
296
289
  width,
297
- height
290
+ height,
291
+ flipSourceY
298
292
  });
299
- drawFullscreenQuad(state);
293
+ gl.clearColor(0, 0, 0, 0);
294
+ if (!horizontal && !vertical) {
295
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
296
+ gl.clear(gl.COLOR_BUFFER_BIT);
297
+ gl.activeTexture(gl.TEXTURE0);
298
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
299
+ gl.useProgram(programVertical);
300
+ setBlurUniforms({
301
+ gl,
302
+ uniforms: state.vertical,
303
+ radius: 0,
304
+ width,
305
+ height
306
+ });
307
+ drawFullscreenQuad(state);
308
+ gl.bindTexture(gl.TEXTURE_2D, null);
309
+ gl.useProgram(null);
310
+ return;
311
+ }
312
+ if (horizontal && vertical) {
313
+ gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
314
+ gl.clear(gl.COLOR_BUFFER_BIT);
315
+ gl.activeTexture(gl.TEXTURE0);
316
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
317
+ gl.useProgram(programHorizontal);
318
+ setBlurUniforms({
319
+ gl,
320
+ uniforms: state.horizontal,
321
+ radius,
322
+ width,
323
+ height
324
+ });
325
+ drawFullscreenQuad(state);
326
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
327
+ gl.clear(gl.COLOR_BUFFER_BIT);
328
+ gl.bindTexture(gl.TEXTURE_2D, textureIntermediate);
329
+ gl.useProgram(programVertical);
330
+ setBlurUniforms({
331
+ gl,
332
+ uniforms: state.vertical,
333
+ radius,
334
+ width,
335
+ height
336
+ });
337
+ drawFullscreenQuad(state);
338
+ gl.bindTexture(gl.TEXTURE_2D, null);
339
+ gl.useProgram(null);
340
+ return;
341
+ }
300
342
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
301
343
  gl.clear(gl.COLOR_BUFFER_BIT);
302
- gl.bindTexture(gl.TEXTURE_2D, textureIntermediate);
303
- gl.useProgram(programVertical);
344
+ gl.activeTexture(gl.TEXTURE0);
345
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
346
+ gl.useProgram(horizontal ? programHorizontal : programVertical);
304
347
  setBlurUniforms({
305
348
  gl,
306
- uniforms: state.vertical,
349
+ uniforms: horizontal ? state.horizontal : state.vertical,
307
350
  radius,
308
351
  width,
309
352
  height
@@ -315,6 +358,11 @@ var applyBlur = ({
315
358
 
316
359
  // src/blur/index.ts
317
360
  var { createEffect } = Internals2;
361
+ var resolveBlurParams = (params) => ({
362
+ radius: params.radius,
363
+ horizontal: params.horizontal ?? true,
364
+ vertical: params.vertical ?? true
365
+ });
318
366
  var blurSchema = {
319
367
  radius: {
320
368
  type: "number",
@@ -322,7 +370,17 @@ var blurSchema = {
322
370
  max: 100,
323
371
  step: 1,
324
372
  default: undefined,
325
- description: "Blur radius"
373
+ description: "Blur"
374
+ },
375
+ horizontal: {
376
+ type: "boolean",
377
+ default: true,
378
+ description: "Horizontal"
379
+ },
380
+ vertical: {
381
+ type: "boolean",
382
+ default: true,
383
+ description: "Vertical"
326
384
  }
327
385
  };
328
386
  var validateBlurParams = (params) => {
@@ -333,24 +391,28 @@ var blur = createEffect({
333
391
  type: "remotion/blur",
334
392
  label: "Blur",
335
393
  backend: "webgl2",
336
- calculateKey: (params) => String(params.radius),
394
+ calculateKey: (params) => {
395
+ const r = resolveBlurParams(params);
396
+ return `${r.radius}-${r.horizontal ? 1 : 0}-${r.vertical ? 1 : 0}`;
397
+ },
337
398
  setup: (target) => setupBlur(target),
338
- apply: ({ source, width, height, params, state }) => {
399
+ apply: ({ source, width, height, params, state, flipSourceY }) => {
400
+ const r = resolveBlurParams(params);
339
401
  applyBlur({
340
402
  state,
341
403
  source,
342
404
  width,
343
405
  height,
344
- radius: params.radius
406
+ radius: r.radius,
407
+ horizontal: r.horizontal,
408
+ vertical: r.vertical,
409
+ flipSourceY
345
410
  });
346
411
  },
347
412
  cleanup: (state) => cleanupBlur(state),
348
413
  schema: blurSchema,
349
414
  validateParams: validateBlurParams
350
415
  });
351
-
352
- // src/entrypoints/blur.ts
353
- var { blur: blur2 } = exports_blur;
354
416
  export {
355
- blur2 as blur
417
+ blur
356
418
  };
@@ -1 +1,428 @@
1
- export {};
1
+ // src/halftone.ts
2
+ import { Internals } from "remotion";
3
+ var { createEffect, createWebGL2ContextError } = Internals;
4
+ var SHADE_OUTSIDE_DOT_SCALE = 0.5;
5
+ var halftoneSchema = {
6
+ dotSize: {
7
+ type: "number",
8
+ min: 1,
9
+ max: 200,
10
+ step: 1,
11
+ default: 20,
12
+ description: "Dot size"
13
+ },
14
+ dotSpacing: {
15
+ type: "number",
16
+ min: 1,
17
+ max: 200,
18
+ step: 1,
19
+ default: 20,
20
+ description: "Dot spacing"
21
+ },
22
+ rotation: {
23
+ type: "number",
24
+ min: -180,
25
+ max: 180,
26
+ step: 1,
27
+ default: 0,
28
+ description: "Rotation"
29
+ },
30
+ offsetX: {
31
+ type: "number",
32
+ step: 1,
33
+ default: 0,
34
+ description: "Offset X"
35
+ },
36
+ offsetY: {
37
+ type: "number",
38
+ step: 1,
39
+ default: 0,
40
+ description: "Offset Y"
41
+ },
42
+ shape: {
43
+ type: "enum",
44
+ variants: {
45
+ circle: {},
46
+ square: {},
47
+ line: {}
48
+ },
49
+ default: "circle",
50
+ description: "Shape"
51
+ }
52
+ };
53
+ var resolve = (p) => ({
54
+ shape: p.shape ?? "circle",
55
+ dotSize: p.dotSize ?? 20,
56
+ dotSpacing: p.dotSpacing ?? p.dotSize ?? 20,
57
+ rotation: p.rotation ?? 0,
58
+ offsetX: p.offsetX ?? 0,
59
+ offsetY: p.offsetY ?? 0,
60
+ sampling: p.sampling ?? "bilinear",
61
+ color: p.color ?? "black",
62
+ shadeOutside: p.shadeOutside ?? false
63
+ });
64
+ var HALFTONE_VS = `#version 300 es
65
+ in vec2 aPos;
66
+ in vec2 aUv;
67
+ out vec2 vUv;
68
+ void main() {
69
+ vUv = aUv;
70
+ gl_Position = vec4(aPos, 0.0, 1.0);
71
+ }
72
+ `;
73
+ var HALFTONE_FS = `#version 300 es
74
+ precision highp float;
75
+
76
+ in vec2 vUv;
77
+ out vec4 fragColor;
78
+
79
+ uniform sampler2D uSource;
80
+ uniform vec2 uResolution;
81
+ uniform float uDotSize;
82
+ uniform float uDotSpacing;
83
+ uniform float uRotation;
84
+ uniform vec2 uOffset;
85
+ uniform vec4 uColor;
86
+ uniform int uShape;
87
+ uniform bool uShadeOutside;
88
+
89
+ const float SHADE_OUTSIDE_SCALE = ${SHADE_OUTSIDE_DOT_SCALE.toFixed(1)};
90
+
91
+ void main() {
92
+ vec2 fragPos = vUv * uResolution;
93
+ vec2 center = uResolution * 0.5;
94
+
95
+ vec2 d = fragPos - center;
96
+ float cosR = cos(uRotation);
97
+ float sinR = sin(uRotation);
98
+
99
+ vec2 gridPos = vec2(
100
+ d.x * cosR + d.y * sinR,
101
+ -d.x * sinR + d.y * cosR
102
+ );
103
+
104
+ float spacing = max(uDotSpacing, 0.001);
105
+ vec2 cellIndex = floor((gridPos + uOffset) / spacing + 0.5);
106
+ vec2 gridCenter = cellIndex * spacing - uOffset;
107
+
108
+ vec2 canvasPos = center + vec2(
109
+ gridCenter.x * cosR - gridCenter.y * sinR,
110
+ gridCenter.x * sinR + gridCenter.y * cosR
111
+ );
112
+
113
+ vec2 sampleUv = clamp(canvasPos / uResolution, vec2(0.0), vec2(1.0));
114
+ vec4 texColor = texture(uSource, sampleUv);
115
+
116
+ float alpha = texColor.a;
117
+ vec3 rgb = alpha > 0.001 ? texColor.rgb / alpha : vec3(0.0);
118
+ float lum = dot(rgb, vec3(0.299, 0.587, 0.114));
119
+
120
+ float lumDefault = lum * alpha + (1.0 - alpha);
121
+ float dotScale = uShadeOutside
122
+ ? (1.0 - alpha) * SHADE_OUTSIDE_SCALE
123
+ : 1.0 - lumDefault;
124
+
125
+ if (dotScale <= 0.01) {
126
+ fragColor = vec4(0.0);
127
+ return;
128
+ }
129
+
130
+ vec2 diff = gridPos - gridCenter;
131
+ float halfSize = uDotSize * 0.5;
132
+ float coverage = 0.0;
133
+
134
+ if (uShape == 0) {
135
+ float radius = halfSize * dotScale;
136
+ float dist = length(diff);
137
+ coverage = 1.0 - smoothstep(radius - 0.75, radius + 0.75, dist);
138
+ } else if (uShape == 1) {
139
+ float s = uDotSize * dotScale * 0.5;
140
+ coverage = (1.0 - smoothstep(s - 0.5, s + 0.5, abs(diff.x)))
141
+ * (1.0 - smoothstep(s - 0.5, s + 0.5, abs(diff.y)));
142
+ } else {
143
+ float lineHalf = uDotSize * dotScale * 0.5;
144
+ coverage = (1.0 - smoothstep(halfSize - 0.5, halfSize + 0.5, abs(diff.x)))
145
+ * (1.0 - smoothstep(lineHalf - 0.5, lineHalf + 0.5, abs(diff.y)));
146
+ }
147
+
148
+ fragColor = uColor * coverage;
149
+ }
150
+ `;
151
+ var SHAPE_INDEX = {
152
+ circle: 0,
153
+ square: 1,
154
+ line: 2
155
+ };
156
+ var compileShader = (gl, type, source) => {
157
+ const shader = gl.createShader(type);
158
+ if (!shader) {
159
+ throw new Error("Failed to create WebGL shader");
160
+ }
161
+ gl.shaderSource(shader, source);
162
+ gl.compileShader(shader);
163
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
164
+ const log = gl.getShaderInfoLog(shader);
165
+ gl.deleteShader(shader);
166
+ throw new Error(`Halftone shader compile failed: ${log ?? "(no log)"}`);
167
+ }
168
+ return shader;
169
+ };
170
+ var linkProgram = (gl, vs, fs) => {
171
+ const program = gl.createProgram();
172
+ if (!program) {
173
+ throw new Error("Failed to create WebGL program");
174
+ }
175
+ gl.attachShader(program, vs);
176
+ gl.attachShader(program, fs);
177
+ gl.linkProgram(program);
178
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
179
+ const log = gl.getProgramInfoLog(program);
180
+ gl.deleteProgram(program);
181
+ throw new Error(`Halftone program link failed: ${log ?? "(no log)"}`);
182
+ }
183
+ return program;
184
+ };
185
+ var parseColorRgba = (ctx, color) => {
186
+ ctx.clearRect(0, 0, 1, 1);
187
+ ctx.fillStyle = color;
188
+ ctx.fillRect(0, 0, 1, 1);
189
+ const { data } = ctx.getImageData(0, 0, 1, 1);
190
+ return [data[0] / 255, data[1] / 255, data[2] / 255, data[3] / 255];
191
+ };
192
+ var halftone = createEffect({
193
+ type: "remotion/halftone",
194
+ label: "Halftone",
195
+ backend: "webgl2",
196
+ calculateKey: (params) => {
197
+ const r = resolve(params);
198
+ return `halftone-${r.shape}-${r.dotSize}-${r.dotSpacing}-${r.rotation}-${r.offsetX}-${r.offsetY}-${r.sampling}-${r.color}-${r.shadeOutside ? 1 : 0}`;
199
+ },
200
+ setup: (target) => {
201
+ const gl = target.getContext("webgl2", {
202
+ premultipliedAlpha: true,
203
+ alpha: true,
204
+ preserveDrawingBuffer: true
205
+ });
206
+ if (!gl) {
207
+ throw createWebGL2ContextError("halftone effect");
208
+ }
209
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
210
+ const vs = compileShader(gl, gl.VERTEX_SHADER, HALFTONE_VS);
211
+ const fs = compileShader(gl, gl.FRAGMENT_SHADER, HALFTONE_FS);
212
+ const program = linkProgram(gl, vs, fs);
213
+ gl.deleteShader(vs);
214
+ gl.deleteShader(fs);
215
+ const vao = gl.createVertexArray();
216
+ if (!vao) {
217
+ throw new Error("Failed to create WebGL vertex array");
218
+ }
219
+ gl.bindVertexArray(vao);
220
+ const data = new Float32Array([
221
+ -1,
222
+ -1,
223
+ 0,
224
+ 0,
225
+ 1,
226
+ -1,
227
+ 1,
228
+ 0,
229
+ -1,
230
+ 1,
231
+ 0,
232
+ 1,
233
+ 1,
234
+ 1,
235
+ 1,
236
+ 1
237
+ ]);
238
+ const vbo = gl.createBuffer();
239
+ if (!vbo) {
240
+ throw new Error("Failed to create WebGL buffer");
241
+ }
242
+ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
243
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
244
+ const aPos = gl.getAttribLocation(program, "aPos");
245
+ const aUv = gl.getAttribLocation(program, "aUv");
246
+ gl.enableVertexAttribArray(aPos);
247
+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
248
+ gl.enableVertexAttribArray(aUv);
249
+ gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
250
+ gl.bindVertexArray(null);
251
+ const texture = gl.createTexture();
252
+ if (!texture) {
253
+ throw new Error("Failed to create WebGL texture");
254
+ }
255
+ gl.bindTexture(gl.TEXTURE_2D, texture);
256
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
257
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
258
+ gl.bindTexture(gl.TEXTURE_2D, null);
259
+ const colorCanvas = document.createElement("canvas");
260
+ colorCanvas.width = 1;
261
+ colorCanvas.height = 1;
262
+ const colorCtx = colorCanvas.getContext("2d", { willReadFrequently: true });
263
+ if (!colorCtx) {
264
+ throw new Error("Failed to acquire 2D context for color parsing");
265
+ }
266
+ return {
267
+ gl,
268
+ program,
269
+ vao,
270
+ vbo,
271
+ texture,
272
+ uSource: gl.getUniformLocation(program, "uSource"),
273
+ uResolution: gl.getUniformLocation(program, "uResolution"),
274
+ uDotSize: gl.getUniformLocation(program, "uDotSize"),
275
+ uDotSpacing: gl.getUniformLocation(program, "uDotSpacing"),
276
+ uRotation: gl.getUniformLocation(program, "uRotation"),
277
+ uOffset: gl.getUniformLocation(program, "uOffset"),
278
+ uColor: gl.getUniformLocation(program, "uColor"),
279
+ uShape: gl.getUniformLocation(program, "uShape"),
280
+ uShadeOutside: gl.getUniformLocation(program, "uShadeOutside"),
281
+ colorCtx,
282
+ cachedColorStr: "",
283
+ cachedColorRgba: [0, 0, 0, 1]
284
+ };
285
+ },
286
+ apply: ({ source, width, height, params, state, flipSourceY }) => {
287
+ const r = resolve(params);
288
+ const { gl, program, vao, texture } = state;
289
+ if (state.cachedColorStr !== r.color) {
290
+ state.cachedColorStr = r.color;
291
+ state.cachedColorRgba = parseColorRgba(state.colorCtx, r.color);
292
+ }
293
+ const [cr, cg, cb, ca] = state.cachedColorRgba;
294
+ const filter = r.sampling === "nearest" ? gl.NEAREST : gl.LINEAR;
295
+ gl.viewport(0, 0, width, height);
296
+ gl.clearColor(0, 0, 0, 0);
297
+ gl.clear(gl.COLOR_BUFFER_BIT);
298
+ gl.useProgram(program);
299
+ gl.bindVertexArray(vao);
300
+ gl.activeTexture(gl.TEXTURE0);
301
+ gl.bindTexture(gl.TEXTURE_2D, texture);
302
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
303
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
304
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
305
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
306
+ if (state.uSource)
307
+ gl.uniform1i(state.uSource, 0);
308
+ if (state.uResolution)
309
+ gl.uniform2f(state.uResolution, width, height);
310
+ if (state.uDotSize)
311
+ gl.uniform1f(state.uDotSize, r.dotSize);
312
+ if (state.uDotSpacing)
313
+ gl.uniform1f(state.uDotSpacing, r.dotSpacing);
314
+ if (state.uRotation)
315
+ gl.uniform1f(state.uRotation, r.rotation * Math.PI / 180);
316
+ if (state.uOffset)
317
+ gl.uniform2f(state.uOffset, r.offsetX, r.offsetY);
318
+ if (state.uColor)
319
+ gl.uniform4f(state.uColor, cr * ca, cg * ca, cb * ca, ca);
320
+ if (state.uShape)
321
+ gl.uniform1i(state.uShape, SHAPE_INDEX[r.shape]);
322
+ if (state.uShadeOutside)
323
+ gl.uniform1i(state.uShadeOutside, r.shadeOutside ? 1 : 0);
324
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
325
+ gl.bindVertexArray(null);
326
+ gl.bindTexture(gl.TEXTURE_2D, null);
327
+ gl.useProgram(null);
328
+ },
329
+ cleanup: ({ gl, program, vao, vbo, texture }) => {
330
+ gl.deleteBuffer(vbo);
331
+ gl.deleteProgram(program);
332
+ gl.deleteVertexArray(vao);
333
+ gl.deleteTexture(texture);
334
+ },
335
+ schema: halftoneSchema,
336
+ validateParams: () => {}
337
+ });
338
+
339
+ // src/tint.ts
340
+ import { Internals as Internals2 } from "remotion";
341
+
342
+ // src/validate-effect-param.ts
343
+ var assertEffectParamsObject = (params, effectLabel) => {
344
+ if (params === null || typeof params !== "object") {
345
+ throw new TypeError(`${effectLabel} effect requires a parameters object, but got ${JSON.stringify(params)}`);
346
+ }
347
+ };
348
+ var assertRequiredFiniteNumber = (value, name) => {
349
+ if (typeof value !== "number" || !Number.isFinite(value)) {
350
+ throw new TypeError(`"${name}" must be a finite number, but got ${JSON.stringify(value)}`);
351
+ }
352
+ };
353
+ var assertRequiredColor = (value, name) => {
354
+ if (typeof value !== "string" || value.length === 0) {
355
+ throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
356
+ }
357
+ };
358
+
359
+ // src/tint.ts
360
+ var { createEffect: createEffect2 } = Internals2;
361
+ var DEFAULT_AMOUNT = 0.5;
362
+ var tintSchema = {
363
+ color: {
364
+ type: "color",
365
+ default: undefined,
366
+ description: "Color"
367
+ },
368
+ amount: {
369
+ type: "number",
370
+ min: 0,
371
+ max: 1,
372
+ step: 0.01,
373
+ default: DEFAULT_AMOUNT,
374
+ description: "Amount"
375
+ }
376
+ };
377
+ var resolve2 = (p) => ({
378
+ color: p.color,
379
+ amount: p.amount ?? DEFAULT_AMOUNT
380
+ });
381
+ var validateTintParams = (params) => {
382
+ assertEffectParamsObject(params, "Tint");
383
+ assertRequiredColor(params.color, "color");
384
+ };
385
+ var tint = createEffect2({
386
+ type: "remotion/tint",
387
+ label: "Tint",
388
+ backend: "2d",
389
+ calculateKey: (params) => {
390
+ const r = resolve2(params);
391
+ return `tint-${r.color}-${r.amount}`;
392
+ },
393
+ setup: () => null,
394
+ apply: ({ source, target, width, height, params }) => {
395
+ const ctx = target.getContext("2d");
396
+ if (!ctx) {
397
+ throw new Error("Failed to acquire 2D context for tint effect. The canvas may have been assigned a different context type.");
398
+ }
399
+ const r = resolve2(params);
400
+ const amount = Math.max(0, Math.min(1, r.amount));
401
+ ctx.clearRect(0, 0, width, height);
402
+ ctx.globalAlpha = 1;
403
+ ctx.globalCompositeOperation = "source-over";
404
+ ctx.drawImage(source, 0, 0, width, height);
405
+ ctx.globalAlpha = amount;
406
+ ctx.globalCompositeOperation = "source-atop";
407
+ ctx.fillStyle = r.color;
408
+ ctx.fillRect(0, 0, width, height);
409
+ ctx.globalAlpha = 1;
410
+ ctx.globalCompositeOperation = "source-over";
411
+ },
412
+ cleanup: () => {
413
+ return;
414
+ },
415
+ schema: tintSchema,
416
+ validateParams: validateTintParams
417
+ });
418
+
419
+ // src/effect-internals.ts
420
+ var EffectInternals = {
421
+ halftone,
422
+ tint
423
+ };
424
+ export {
425
+ tintSchema,
426
+ halftoneSchema,
427
+ EffectInternals
428
+ };
package/dist/esm/wave.mjs CHANGED
@@ -1,18 +1,254 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, {
5
- get: all[name],
6
- enumerable: true,
7
- configurable: true,
8
- set: (newValue) => all[name] = () => newValue
9
- });
1
+ // src/wave/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
+ }
10
19
  };
11
20
 
12
- // src/wave.ts
21
+ // src/wave/wave-runtime.ts
13
22
  import { Internals } from "remotion";
14
- var { createEffect } = Internals;
23
+
24
+ // src/wave/wave-shaders.ts
25
+ var WAVE_VS = `#version 300 es
26
+ layout(location = 0) in vec2 aPos;
27
+ layout(location = 1) in vec2 aUv;
28
+ out vec2 vUv;
29
+ void main() {
30
+ vUv = aUv;
31
+ gl_Position = vec4(aPos, 0.0, 1.0);
32
+ }
33
+ `;
34
+ var WAVE_FS = `#version 300 es
35
+ precision highp float;
36
+ in vec2 vUv;
37
+ out vec4 fragColor;
38
+
39
+ uniform sampler2D uSource;
40
+ uniform vec2 uResolution;
41
+ uniform float uAmplitude;
42
+ uniform float uWavelength;
43
+ uniform float uPhase;
44
+ uniform int uDirection;
45
+
46
+ const float TWO_PI = 6.28318530718;
47
+
48
+ void main() {
49
+ float wavelength = max(uWavelength, 0.001);
50
+ vec2 srcUv = vUv;
51
+
52
+ if (uDirection == 0) {
53
+ float coordPx = vUv.x * uResolution.x;
54
+ float offsetPx =
55
+ sin((coordPx / wavelength) * TWO_PI + uPhase) * uAmplitude;
56
+ srcUv.y -= offsetPx / uResolution.y;
57
+ } else {
58
+ float coordPx = vUv.y * uResolution.y;
59
+ float offsetPx =
60
+ sin((coordPx / wavelength) * TWO_PI + uPhase) * uAmplitude;
61
+ srcUv.x -= offsetPx / uResolution.x;
62
+ }
63
+
64
+ fragColor = texture(uSource, srcUv);
65
+ }
66
+ `;
67
+
68
+ // src/wave/wave-runtime.ts
69
+ var { createWebGL2ContextError } = Internals;
70
+ var compileShader = (gl, type, source) => {
71
+ const shader = gl.createShader(type);
72
+ if (!shader) {
73
+ throw new Error("Failed to create WebGL shader");
74
+ }
75
+ gl.shaderSource(shader, source);
76
+ gl.compileShader(shader);
77
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
78
+ const log = gl.getShaderInfoLog(shader);
79
+ gl.deleteShader(shader);
80
+ throw new Error(`Shader compile failed: ${log ?? "(no log)"}`);
81
+ }
82
+ return shader;
83
+ };
84
+ var linkProgram = (gl, vs, fs) => {
85
+ const program = gl.createProgram();
86
+ if (!program) {
87
+ throw new Error("Failed to create WebGL program");
88
+ }
89
+ gl.attachShader(program, vs);
90
+ gl.attachShader(program, fs);
91
+ gl.linkProgram(program);
92
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
93
+ const log = gl.getProgramInfoLog(program);
94
+ gl.deleteProgram(program);
95
+ throw new Error(`Program link failed: ${log ?? "(no log)"}`);
96
+ }
97
+ return program;
98
+ };
99
+ var createProgram = (gl, vertexSource, fragmentSource) => {
100
+ const vs = compileShader(gl, gl.VERTEX_SHADER, vertexSource);
101
+ const fs = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
102
+ const program = linkProgram(gl, vs, fs);
103
+ gl.deleteShader(vs);
104
+ gl.deleteShader(fs);
105
+ return program;
106
+ };
107
+ var getWaveUniforms = (gl, program) => ({
108
+ uSource: gl.getUniformLocation(program, "uSource"),
109
+ uResolution: gl.getUniformLocation(program, "uResolution"),
110
+ uAmplitude: gl.getUniformLocation(program, "uAmplitude"),
111
+ uWavelength: gl.getUniformLocation(program, "uWavelength"),
112
+ uPhase: gl.getUniformLocation(program, "uPhase"),
113
+ uDirection: gl.getUniformLocation(program, "uDirection")
114
+ });
115
+ var createRgbaTexture = (gl) => {
116
+ const texture = gl.createTexture();
117
+ if (!texture) {
118
+ throw new Error("Failed to create WebGL texture");
119
+ }
120
+ gl.bindTexture(gl.TEXTURE_2D, texture);
121
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
122
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
123
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
124
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
125
+ gl.bindTexture(gl.TEXTURE_2D, null);
126
+ return texture;
127
+ };
128
+ var setupWave = (target) => {
129
+ const gl = target.getContext("webgl2", {
130
+ premultipliedAlpha: true,
131
+ alpha: true,
132
+ preserveDrawingBuffer: true
133
+ });
134
+ if (!gl) {
135
+ throw createWebGL2ContextError("wave effect");
136
+ }
137
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
138
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
139
+ const program = createProgram(gl, WAVE_VS, WAVE_FS);
140
+ const vao = gl.createVertexArray();
141
+ if (!vao) {
142
+ throw new Error("Failed to create WebGL vertex array");
143
+ }
144
+ gl.bindVertexArray(vao);
145
+ const data = new Float32Array([
146
+ -1,
147
+ -1,
148
+ 0,
149
+ 0,
150
+ 1,
151
+ -1,
152
+ 1,
153
+ 0,
154
+ -1,
155
+ 1,
156
+ 0,
157
+ 1,
158
+ 1,
159
+ 1,
160
+ 1,
161
+ 1
162
+ ]);
163
+ const vbo = gl.createBuffer();
164
+ if (!vbo) {
165
+ throw new Error("Failed to create WebGL buffer");
166
+ }
167
+ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
168
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
169
+ gl.enableVertexAttribArray(0);
170
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 16, 0);
171
+ gl.enableVertexAttribArray(1);
172
+ gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 16, 8);
173
+ gl.bindVertexArray(null);
174
+ const textureSource = createRgbaTexture(gl);
175
+ return {
176
+ gl,
177
+ program,
178
+ vao,
179
+ vbo,
180
+ textureSource,
181
+ uniforms: getWaveUniforms(gl, program)
182
+ };
183
+ };
184
+ var cleanupWave = (state) => {
185
+ const { gl, program, vao, vbo, textureSource } = state;
186
+ gl.deleteTexture(textureSource);
187
+ gl.deleteBuffer(vbo);
188
+ gl.deleteProgram(program);
189
+ gl.deleteVertexArray(vao);
190
+ };
191
+ var drawFullscreenQuad = (state) => {
192
+ const { gl, vao } = state;
193
+ gl.bindVertexArray(vao);
194
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
195
+ gl.bindVertexArray(null);
196
+ };
197
+ var applyWave = ({
198
+ state,
199
+ source,
200
+ width,
201
+ height,
202
+ amplitude,
203
+ wavelength,
204
+ phase,
205
+ direction
206
+ }) => {
207
+ const { gl, program, textureSource, uniforms } = state;
208
+ gl.viewport(0, 0, width, height);
209
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
210
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
211
+ gl.bindTexture(gl.TEXTURE_2D, null);
212
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
213
+ gl.clearColor(0, 0, 0, 0);
214
+ gl.clear(gl.COLOR_BUFFER_BIT);
215
+ gl.useProgram(program);
216
+ if (uniforms.uSource)
217
+ gl.uniform1i(uniforms.uSource, 0);
218
+ if (uniforms.uResolution)
219
+ gl.uniform2f(uniforms.uResolution, width, height);
220
+ if (uniforms.uAmplitude)
221
+ gl.uniform1f(uniforms.uAmplitude, amplitude);
222
+ if (uniforms.uWavelength)
223
+ gl.uniform1f(uniforms.uWavelength, wavelength);
224
+ if (uniforms.uPhase)
225
+ gl.uniform1f(uniforms.uPhase, phase);
226
+ if (uniforms.uDirection)
227
+ gl.uniform1i(uniforms.uDirection, direction === "horizontal" ? 0 : 1);
228
+ gl.activeTexture(gl.TEXTURE0);
229
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
230
+ drawFullscreenQuad(state);
231
+ gl.bindTexture(gl.TEXTURE_2D, null);
232
+ gl.useProgram(null);
233
+ };
234
+
235
+ // src/wave/index.ts
236
+ var { createEffect } = Internals2;
15
237
  var waveSchema = {
238
+ phase: {
239
+ type: "number",
240
+ default: 0,
241
+ description: "Phase"
242
+ },
243
+ direction: {
244
+ type: "enum",
245
+ variants: {
246
+ horizontal: {},
247
+ vertical: {}
248
+ },
249
+ default: "horizontal",
250
+ description: "Direction"
251
+ },
16
252
  amplitude: {
17
253
  type: "number",
18
254
  min: 0,
@@ -28,65 +264,62 @@ var waveSchema = {
28
264
  step: 1,
29
265
  default: 240,
30
266
  description: "Wavelength"
31
- },
32
- evolution: {
33
- type: "number",
34
- default: 0,
35
- description: "Evolution"
36
- },
37
- sliceWidth: {
38
- type: "number",
39
- min: 1,
40
- max: 100,
41
- step: 1,
42
- default: 4,
43
- description: "Slice width"
44
- },
45
- background: {
46
- type: "color",
47
- default: "transparent",
48
- description: "Background"
49
267
  }
50
268
  };
51
269
  var resolve = (p) => ({
270
+ phase: p.phase ?? 0,
271
+ direction: p.direction ?? "horizontal",
52
272
  amplitude: p.amplitude ?? 60,
53
- wavelength: p.wavelength ?? 240,
54
- evolution: p.evolution ?? 0,
55
- sliceWidth: p.sliceWidth ?? 4,
56
- background: p.background ?? "transparent"
273
+ wavelength: p.wavelength ?? 240
57
274
  });
275
+ var assertOptionalFiniteNumber = (value, name) => {
276
+ if (value === undefined) {
277
+ return;
278
+ }
279
+ assertRequiredFiniteNumber(value, name);
280
+ };
281
+ var validateWaveParams = (params) => {
282
+ assertEffectParamsObject(params, "Wave");
283
+ assertOptionalFiniteNumber(params.phase, "phase");
284
+ assertOptionalFiniteNumber(params.amplitude, "amplitude");
285
+ assertOptionalFiniteNumber(params.wavelength, "wavelength");
286
+ if (params.direction !== undefined && params.direction !== "horizontal" && params.direction !== "vertical") {
287
+ throw new TypeError(`"direction" must be "horizontal" or "vertical", but got ${JSON.stringify(params.direction)}`);
288
+ }
289
+ const resolved = resolve(params);
290
+ if (resolved.amplitude < 0) {
291
+ throw new TypeError(`"amplitude" must be >= 0, but got ${JSON.stringify(resolved.amplitude)}`);
292
+ }
293
+ if (resolved.wavelength <= 0) {
294
+ throw new TypeError(`"wavelength" must be > 0, but got ${JSON.stringify(resolved.wavelength)}`);
295
+ }
296
+ };
58
297
  var wave = createEffect({
59
298
  type: "remotion/wave",
60
299
  label: "Wave",
61
- backend: "2d",
300
+ backend: "webgl2",
62
301
  calculateKey: (params) => {
63
302
  const r = resolve(params);
64
- return `wave-${r.amplitude}-${r.wavelength}-${r.evolution}-${r.sliceWidth}-${r.background}`;
303
+ return `wave-${r.phase}-${r.direction}-${r.amplitude}-${r.wavelength}`;
65
304
  },
66
- setup: () => null,
67
- apply: ({ source, target, width, height, params }) => {
68
- const ctx = target.getContext("2d");
69
- if (!ctx) {
70
- throw new Error("Failed to acquire 2D context for wave effect. The canvas may have been assigned a different context type.");
71
- }
305
+ setup: (target) => setupWave(target),
306
+ apply: ({ source, width, height, params, state }) => {
72
307
  const r = resolve(params);
73
- ctx.clearRect(0, 0, width, height);
74
- if (r.background !== "transparent") {
75
- ctx.fillStyle = r.background;
76
- ctx.fillRect(0, 0, width, height);
77
- }
78
- for (let x = 0;x < width; x += r.sliceWidth) {
79
- const offset = Math.sin(x / r.wavelength * Math.PI * 2 + r.evolution) * r.amplitude;
80
- ctx.drawImage(source, x, 0, r.sliceWidth, height, x, offset, r.sliceWidth, height);
81
- }
82
- },
83
- cleanup: () => {
84
- return;
308
+ applyWave({
309
+ state,
310
+ source,
311
+ width,
312
+ height,
313
+ amplitude: r.amplitude,
314
+ wavelength: r.wavelength,
315
+ phase: r.phase,
316
+ direction: r.direction
317
+ });
85
318
  },
319
+ cleanup: (state) => cleanupWave(state),
86
320
  schema: waveSchema,
87
- validateParams: () => {}
321
+ validateParams: validateWaveParams
88
322
  });
89
323
  export {
90
- waveSchema,
91
324
  wave
92
325
  };
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
- export {};
1
+ export { EffectInternals } from './effect-internals.js';
2
+ export { halftoneSchema, type HalftoneParams } from './halftone.js';
3
+ export { tintSchema, type TintParams } from './tint.js';
@@ -0,0 +1,12 @@
1
+ export type WaveDirection = 'horizontal' | 'vertical';
2
+ export type WaveParams = {
3
+ /** Phase offset in radians. */
4
+ readonly phase?: number;
5
+ /** Wave propagation axis. Defaults to `horizontal`. */
6
+ readonly direction?: WaveDirection;
7
+ readonly amplitude?: number;
8
+ readonly wavelength?: number;
9
+ };
10
+ export declare const wave: (params?: (WaveParams & {
11
+ readonly disabled?: boolean | undefined;
12
+ }) | undefined) => import("remotion").EffectDescriptor<unknown>;
@@ -0,0 +1,29 @@
1
+ export type WaveState = {
2
+ gl: WebGL2RenderingContext;
3
+ program: WebGLProgram;
4
+ vao: WebGLVertexArrayObject;
5
+ vbo: WebGLBuffer;
6
+ textureSource: WebGLTexture;
7
+ uniforms: {
8
+ uSource: WebGLUniformLocation | null;
9
+ uResolution: WebGLUniformLocation | null;
10
+ uAmplitude: WebGLUniformLocation | null;
11
+ uWavelength: WebGLUniformLocation | null;
12
+ uPhase: WebGLUniformLocation | null;
13
+ uDirection: WebGLUniformLocation | null;
14
+ };
15
+ };
16
+ export declare const setupWave: (target: HTMLCanvasElement) => WaveState;
17
+ export declare const cleanupWave: (state: WaveState) => void;
18
+ type ApplyWaveParams = {
19
+ readonly state: WaveState;
20
+ readonly source: CanvasImageSource;
21
+ readonly width: number;
22
+ readonly height: number;
23
+ readonly amplitude: number;
24
+ readonly wavelength: number;
25
+ readonly phase: number;
26
+ readonly direction: 'horizontal' | 'vertical';
27
+ };
28
+ export declare const applyWave: ({ state, source, width, height, amplitude, wavelength, phase, direction, }: ApplyWaveParams) => void;
29
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const WAVE_VS = "#version 300 es\nlayout(location = 0) in vec2 aPos;\nlayout(location = 1) in vec2 aUv;\nout vec2 vUv;\nvoid main() {\n\tvUv = aUv;\n\tgl_Position = vec4(aPos, 0.0, 1.0);\n}\n";
2
+ export declare const WAVE_FS = "#version 300 es\nprecision highp float;\nin vec2 vUv;\nout vec4 fragColor;\n\nuniform sampler2D uSource;\nuniform vec2 uResolution;\nuniform float uAmplitude;\nuniform float uWavelength;\nuniform float uPhase;\nuniform int uDirection;\n\nconst float TWO_PI = 6.28318530718;\n\nvoid main() {\n\tfloat wavelength = max(uWavelength, 0.001);\n\tvec2 srcUv = vUv;\n\n\tif (uDirection == 0) {\n\t\tfloat coordPx = vUv.x * uResolution.x;\n\t\tfloat offsetPx =\n\t\t\tsin((coordPx / wavelength) * TWO_PI + uPhase) * uAmplitude;\n\t\tsrcUv.y -= offsetPx / uResolution.y;\n\t} else {\n\t\tfloat coordPx = vUv.y * uResolution.y;\n\t\tfloat offsetPx =\n\t\t\tsin((coordPx / wavelength) * TWO_PI + uPhase) * uAmplitude;\n\t\tsrcUv.x -= offsetPx / uResolution.x;\n\t}\n\n\tfragColor = texture(uSource, srcUv);\n}\n";
package/dist/wave.d.ts CHANGED
@@ -1,46 +1 @@
1
- export declare const waveSchema: {
2
- readonly amplitude: {
3
- readonly type: "number";
4
- readonly min: 0;
5
- readonly max: 500;
6
- readonly step: 1;
7
- readonly default: 60;
8
- readonly description: "Amplitude";
9
- };
10
- readonly wavelength: {
11
- readonly type: "number";
12
- readonly min: 1;
13
- readonly max: 2000;
14
- readonly step: 1;
15
- readonly default: 240;
16
- readonly description: "Wavelength";
17
- };
18
- readonly evolution: {
19
- readonly type: "number";
20
- readonly default: 0;
21
- readonly description: "Evolution";
22
- };
23
- readonly sliceWidth: {
24
- readonly type: "number";
25
- readonly min: 1;
26
- readonly max: 100;
27
- readonly step: 1;
28
- readonly default: 4;
29
- readonly description: "Slice width";
30
- };
31
- readonly background: {
32
- readonly type: "color";
33
- readonly default: "transparent";
34
- readonly description: "Background";
35
- };
36
- };
37
- export type WaveParams = {
38
- readonly amplitude?: number;
39
- readonly wavelength?: number;
40
- readonly evolution?: number;
41
- readonly sliceWidth?: number;
42
- readonly background?: string;
43
- };
44
- export declare const wave: (params?: (WaveParams & {
45
- readonly disabled?: boolean | undefined;
46
- }) | undefined) => import("remotion").EffectDescriptor<unknown>;
1
+ export { wave, type WaveDirection, type WaveParams } from './wave/index.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@remotion/effects",
3
- "version": "4.0.464",
4
- "description": "Experimental presets for Remotion canvas effect hooks",
3
+ "version": "4.0.465",
4
+ "description": "Effects that can be applied to Remotion-based canvas components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "module": "dist/esm/index.mjs",
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/remotion-dev/remotion/issues"
25
25
  },
26
26
  "dependencies": {
27
- "remotion": "4.0.464"
27
+ "remotion": "4.0.465"
28
28
  },
29
29
  "exports": {
30
30
  ".": {
@@ -32,46 +32,31 @@
32
32
  "module": "./dist/esm/index.mjs",
33
33
  "import": "./dist/esm/index.mjs"
34
34
  },
35
- "./halftone": {
36
- "types": "./dist/halftone.d.ts",
37
- "module": "./dist/esm/halftone.mjs",
38
- "import": "./dist/esm/halftone.mjs"
39
- },
40
- "./tint": {
41
- "types": "./dist/tint.d.ts",
42
- "module": "./dist/esm/tint.mjs",
43
- "import": "./dist/esm/tint.mjs"
35
+ "./blur": {
36
+ "types": "./dist/blur.d.ts",
37
+ "module": "./dist/esm/blur.mjs",
38
+ "import": "./dist/esm/blur.mjs"
44
39
  },
45
40
  "./wave": {
46
41
  "types": "./dist/wave.d.ts",
47
42
  "module": "./dist/esm/wave.mjs",
48
43
  "import": "./dist/esm/wave.mjs"
49
44
  },
50
- "./blur": {
51
- "types": "./dist/entrypoints/blur.d.ts",
52
- "module": "./dist/esm/blur.mjs",
53
- "import": "./dist/esm/blur.mjs"
54
- },
55
45
  "./package.json": "./package.json"
56
46
  },
57
47
  "typesVersions": {
58
48
  ">=1.0": {
59
- "halftone": [
60
- "dist/halftone.d.ts"
61
- ],
62
- "tint": [
63
- "dist/tint.d.ts"
49
+ "blur": [
50
+ "dist/blur.d.ts"
64
51
  ],
65
52
  "wave": [
66
53
  "dist/wave.d.ts"
67
- ],
68
- "blur": [
69
- "dist/entrypoints/blur.d.ts"
70
54
  ]
71
55
  }
72
56
  },
57
+ "homepage": "https://www.remotion.dev/docs/effects/api",
73
58
  "devDependencies": {
74
- "@remotion/eslint-config-internal": "4.0.464",
59
+ "@remotion/eslint-config-internal": "4.0.465",
75
60
  "eslint": "9.19.0",
76
61
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
77
62
  },