Skip to content

🎥 Make videos programmatically with React

@remotion/effects: Add progressive pixelation effects (#9047)

Jonny Burgera946a1ef36e5
diff --git a/packages/docs/components/effects-demos/registry.ts b/packages/docs/components/effects-demos/registry.ts
index 1b5c3b408f..c4916ab1f8 100644
--- a/packages/docs/components/effects-demos/registry.ts
+++ b/packages/docs/components/effects-demos/registry.ts
@@ -25,6 +25,7 @@ import {lightTrail} from '@remotion/effects/light-trail';
import {linearGradient} from '@remotion/effects/linear-gradient';
import {linearGradientTint} from '@remotion/effects/linear-gradient-tint';
import {linearProgressiveBlur} from '@remotion/effects/linear-progressive-blur';
+import {linearProgressivePixelate} from '@remotion/effects/linear-progressive-pixelate';
import {lines} from '@remotion/effects/lines';
import {mirror} from '@remotion/effects/mirror';
import {noise} from '@remotion/effects/noise';
@@ -34,6 +35,7 @@ import {pattern} from '@remotion/effects/pattern';
import {pixelDissolve} from '@remotion/effects/pixel-dissolve';
import {pixelate} from '@remotion/effects/pixelate';
import {radialProgressiveBlur} from '@remotion/effects/radial-progressive-blur';
+import {radialProgressivePixelate} from '@remotion/effects/radial-progressive-pixelate';
import {rings} from '@remotion/effects/rings';
import {roughenEdges} from '@remotion/effects/roughen-edges';
import {saturation} from '@remotion/effects/saturation';
@@ -86,6 +88,7 @@ import {
import {EffectsLinearGradientPreview} from '../effects/effects-linear-gradient-preview';
import {EffectsLinearGradientTintPreview} from '../effects/effects-linear-gradient-tint-preview';
import {EffectsLinearProgressiveBlurPreview} from '../effects/effects-linear-progressive-blur-preview';
+import {EffectsLinearProgressivePixelatePreview} from '../effects/effects-linear-progressive-pixelate-preview';
import {EffectsLinesPreview} from '../effects/effects-lines-preview';
import {EffectsMirrorPreview} from '../effects/effects-mirror-preview';
import {
@@ -108,6 +111,7 @@ import {
EffectsRadialProgressiveBlurPreview,
RADIAL_PROGRESSIVE_BLUR_PREVIEW_PARAMS,
} from '../effects/effects-radial-progressive-blur-preview';
+import {EffectsRadialProgressivePixelatePreview} from '../effects/effects-radial-progressive-pixelate-preview';
import {EffectsRingsPreview} from '../effects/effects-rings-preview';
import {EffectsRoughenEdgesPreview} from '../effects/effects-roughen-edges-preview';
import {EffectsSaturationPreview} from '../effects/effects-saturation-preview';
@@ -584,6 +588,22 @@ export const effectsDemos: EffectsDemoType[] = [
comp: EffectsPixelatePreview,
schema: pixelate().definition.schema,
},
+ {
+ ...defaults,
+ id: 'effects-linear-progressive-pixelate',
+ effectName: 'linearProgressivePixelate',
+ effectImportPath: '@remotion/effects/linear-progressive-pixelate',
+ comp: EffectsLinearProgressivePixelatePreview,
+ schema: linearProgressivePixelate().definition.schema,
+ },
+ {
+ ...defaults,
+ id: 'effects-radial-progressive-pixelate',
+ effectName: 'radialProgressivePixelate',
+ effectImportPath: '@remotion/effects/radial-progressive-pixelate',
+ comp: EffectsRadialProgressivePixelatePreview,
+ schema: radialProgressivePixelate().definition.schema,
+ },
{
...defaults,
id: 'effects-pixel-dissolve',
diff --git a/packages/docs/components/effects/effects-linear-progressive-pixelate-preview.tsx b/packages/docs/components/effects/effects-linear-progressive-pixelate-preview.tsx
new file mode 100644
index 0000000000..91f8ad81d8
--- /dev/null
+++ b/packages/docs/components/effects/effects-linear-progressive-pixelate-preview.tsx
@@ -0,0 +1,35 @@
+import {linearProgressivePixelate} from '@remotion/effects/linear-progressive-pixelate';
+import React from 'react';
+import {CanvasImage} from 'remotion';
+import {EFFECTS_PREVIEW_IMAGE_SRC} from './effects-preview-image';
+
+export const LINEAR_PROGRESSIVE_PIXELATE_PREVIEW_PARAMS = {
+ start: [0.1, 0.5],
+ end: [0.9, 0.5],
+ startBlockSize: 1,
+ endBlockSize: 64,
+} as const;
+
+export const EffectsLinearProgressivePixelatePreview: React.FC<{
+ readonly start: readonly [number, number];
+ readonly end: readonly [number, number];
+ readonly startBlockSize: number;
+ readonly endBlockSize: number;
+}> = ({start, end, startBlockSize, endBlockSize}) => {
+ return (
+ <CanvasImage
+ src={EFFECTS_PREVIEW_IMAGE_SRC}
+ width={1280}
+ height={720}
+ fit="cover"
+ effects={[
+ linearProgressivePixelate({
+ start,
+ end,
+ startBlockSize,
+ endBlockSize,
+ }),
+ ]}
+ />
+ );
+};
diff --git a/packages/docs/components/effects/effects-radial-progressive-pixelate-preview.tsx b/packages/docs/components/effects/effects-radial-progressive-pixelate-preview.tsx
new file mode 100644
index 0000000000..dadfcda10a
--- /dev/null
+++ b/packages/docs/components/effects/effects-radial-progressive-pixelate-preview.tsx
@@ -0,0 +1,52 @@
+import {radialProgressivePixelate} from '@remotion/effects/radial-progressive-pixelate';
+import React from 'react';
+import {CanvasImage} from 'remotion';
+import {EFFECTS_PREVIEW_IMAGE_SRC} from './effects-preview-image';
+
+export const RADIAL_PROGRESSIVE_PIXELATE_PREVIEW_PARAMS = {
+ center: [0.48, 0.5],
+ width: 1.29,
+ height: 1,
+ rotation: 0,
+ start: 0.55,
+ startBlockSize: 1,
+ endBlockSize: 64,
+} as const;
+
+export const EffectsRadialProgressivePixelatePreview: React.FC<{
+ readonly center: readonly [number, number];
+ readonly width: number;
+ readonly height: number;
+ readonly rotation: number;
+ readonly start: number;
+ readonly startBlockSize: number;
+ readonly endBlockSize: number;
+}> = ({
+ center,
+ width,
+ height,
+ rotation,
+ start,
+ startBlockSize,
+ endBlockSize,
+}) => {
+ return (
+ <CanvasImage
+ src={EFFECTS_PREVIEW_IMAGE_SRC}
+ width={1280}
+ height={720}
+ fit="cover"
+ effects={[
+ radialProgressivePixelate({
+ center,
+ width,
+ height,
+ rotation,
+ start,
+ startBlockSize,
+ endBlockSize,
+ }),
+ ]}
+ />
+ );
+};
diff --git a/packages/docs/docs/effects/linear-progressive-pixelate.mdx b/packages/docs/docs/effects/linear-progressive-pixelate.mdx
new file mode 100644
index 0000000000..218311426a
--- /dev/null
+++ b/packages/docs/docs/effects/linear-progressive-pixelate.mdx
@@ -0,0 +1,89 @@
+---
+image: /generated/articles-docs-effects-linear-progressive-pixelate.png
+slug: /effects/linear-progressive-pixelate
+title: linearProgressivePixelate()
+sidebar_label: linearProgressivePixelate()
+crumb: '@remotion/effects'
+---
+
+# linearProgressivePixelate()<AvailableFrom v="4.0.490" />
+
+_Part of the [`@remotion/effects`](/docs/effects/api) package._
+
+A pixelation effect whose block size changes across a two-stop linear gradient.
+
+Use it for progressive mosaics, focus transitions, and directional pixelation on canvas-based components such as [`<Video>`](/docs/media/video), [`<HtmlInCanvas>`](/docs/remotion/html-in-canvas), and [`<Solid>`](/docs/solid).
+
+## Preview
+
+<EffectsDemo type="effects-linear-progressive-pixelate" />
+
+## Example
+
+```tsx twoslash title="MyComp.tsx"
+import {AbsoluteFill} from 'remotion';
+import {Video} from '@remotion/media';
+import {linearProgressivePixelate} from '@remotion/effects/linear-progressive-pixelate';
+
+export const MyComp: React.FC = () => {
+ return (
+ <AbsoluteFill>
+ <Video
+ src="https://remotion.media/video.mp4"
+ effects={[
+ linearProgressivePixelate({
+ start: [0, 0.5],
+ end: [1, 0.5],
+ startBlockSize: 1,
+ endBlockSize: 40,
+ }),
+ ]}
+ />
+ </AbsoluteFill>
+ );
+};
+```
+
+## API
+
+Pass an object with the following properties. You can also call `linearProgressivePixelate()` without arguments.
+
+### `start?`
+
+UV coordinate where `startBlockSize` is reached. Defaults to `[0, 0.5]`.
+
+Pass a `[number, number]` tuple where `[0, 0]` is top-left and `[1, 1]` is bottom-right. Values outside that range place the stop outside the visible area.
+
+### `end?`
+
+UV coordinate where `endBlockSize` is reached. Defaults to `[1, 0.5]`.
+
+### `startBlockSize?`
+
+Target pixel block size at `start`, in pixels. Defaults to `1`, which leaves the source unchanged. Must be at least `1`.
+
+### `endBlockSize?`
+
+Target pixel block size at `end`, in pixels. Defaults to `40`. Must be at least `1`.
+
+### `disabled?`
+
+When `true`, the effect is skipped. Defaults to `false`.
+
+## Behavior
+
+The target block size is interpolated between `startBlockSize` and `endBlockSize` along the `start` to `end` line.
+
+Before `start`, the size is clamped to `startBlockSize`. After `end`, it is clamped to `endBlockSize`.
+
+## Requirements
+
+`linearProgressivePixelate()` uses a WebGL2 backend. During renders, enable WebGL via [`Config.setChromiumOpenGlRenderer('angle')`](/docs/config#setchromiumopenglrenderer). See [Using WebGL during renders](/docs/remotion/html-in-canvas#using-webgl-during-renders).
+
+## See also
+
+- [`@remotion/effects`](/docs/effects/api)
+- [`pixelate()`](/docs/effects/pixelate)
+- [`radialProgressivePixelate()`](/docs/effects/radial-progressive-pixelate)
+- [`linearProgressiveBlur()`](/docs/effects/linear-progressive-blur)
+- [Source code for this effect](https://github.com/remotion-dev/remotion/blob/main/packages/effects/src/linear-progressive-pixelate/index.ts)
diff --git a/packages/docs/docs/effects/radial-progressive-pixelate.mdx b/packages/docs/docs/effects/radial-progressive-pixelate.mdx
new file mode 100644
index 0000000000..ff0332a374
--- /dev/null
+++ b/packages/docs/docs/effects/radial-progressive-pixelate.mdx
@@ -0,0 +1,108 @@
+---
+image: /generated/articles-docs-effects-radial-progressive-pixelate.png
+slug: /effects/radial-progressive-pixelate
+title: radialProgressivePixelate()
+sidebar_label: radialProgressivePixelate()
+crumb: '@remotion/effects'
+---
+
+# radialProgressivePixelate()<AvailableFrom v="4.0.490" />
+
+_Part of the [`@remotion/effects`](/docs/effects/api) package._
+
+A pixelation effect whose block size changes from the center to the edge of an ellipse.
+
+Use it for pixelated focus regions, spotlight transitions, and radial mosaics on canvas-based components such as [`<Video>`](/docs/media/video), [`<HtmlInCanvas>`](/docs/remotion/html-in-canvas), and [`<Solid>`](/docs/solid).
+
+## Preview
+
+<EffectsDemo type="effects-radial-progressive-pixelate" />
+
+## Example
+
+```tsx twoslash title="MyComp.tsx"
+import {AbsoluteFill} from 'remotion';
+import {Video} from '@remotion/media';
+import {radialProgressivePixelate} from '@remotion/effects/radial-progressive-pixelate';
+
+export const MyComp: React.FC = () => {
+ return (
+ <AbsoluteFill>
+ <Video
+ src="https://remotion.media/video.mp4"
+ effects={[
+ radialProgressivePixelate({
+ center: [0.5, 0.5],
+ width: 1,
+ height: 1,
+ rotation: 0,
+ start: 0.4,
+ startBlockSize: 1,
+ endBlockSize: 40,
+ }),
+ ]}
+ />
+ </AbsoluteFill>
+ );
+};
+```
+
+## API
+
+Pass an object with the following properties. You can also call `radialProgressivePixelate()` without arguments.
+
+### `center?`
+
+Center of the ellipse in UV coordinates. Defaults to `[0.5, 0.5]`.
+
+Pass a `[number, number]` tuple where `[0, 0]` is top-left and `[1, 1]` is bottom-right. Values outside that range place the center outside the visible area.
+
+### `width?`
+
+Full ellipse width in UV coordinates. Defaults to `1`.
+
+### `height?`
+
+Full ellipse height in UV coordinates. Defaults to `1`.
+
+### `rotation?`
+
+Ellipse rotation in degrees. Defaults to `0`.
+
+### `start?`
+
+Normalized ellipse progress where interpolation starts. Defaults to `0`.
+
+`0` is the center. `1` is the outer ellipse defined by `width`, `height`, and `rotation`.
+
+### `startBlockSize?`
+
+Target pixel block size at `start`, in pixels. Defaults to `1`, which leaves the source unchanged. Must be at least `1`.
+
+### `endBlockSize?`
+
+Target pixel block size at the outer ellipse, in pixels. Defaults to `40`. Must be at least `1`.
+
+### `disabled?`
+
+When `true`, the effect is skipped. Defaults to `false`.
+
+## Behavior
+
+The target block size is interpolated between `startBlockSize` and `endBlockSize` from `start` to the outer ellipse.
+
+Before `start`, the size is clamped to `startBlockSize`. At and beyond the outer ellipse, it is clamped to `endBlockSize`.
+
+Swap the block sizes to pixelate the center and keep the outside clear.
+
+## Requirements
+
+`radialProgressivePixelate()` uses a WebGL2 backend. During renders, enable WebGL via [`Config.setChromiumOpenGlRenderer('angle')`](/docs/config#setchromiumopenglrenderer). See [Using WebGL during renders](/docs/remotion/html-in-canvas#using-webgl-during-renders).
+
+## See also
+
+- [`@remotion/effects`](/docs/effects/api)
+- [`pixelate()`](/docs/effects/pixelate)
+- [`linearProgressivePixelate()`](/docs/effects/linear-progressive-pixelate)
+- [`radialProgressiveBlur()`](/docs/effects/radial-progressive-blur)
+- [Source code for this effect](https://github.com/remotion-dev/remotion/blob/main/packages/effects/src/radial-progressive-pixelate/index.ts)
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index 2be71f8a98..c2d61e9018 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -299,6 +299,7 @@ const sidebars: SidebarsConfig = {
'effects/linear-gradient',
'effects/linear-gradient-tint',
'effects/linear-progressive-blur',
+ 'effects/linear-progressive-pixelate',
'effects/light-trail',
'effects/lines',
'effects/mirror',
@@ -309,6 +310,7 @@ const sidebars: SidebarsConfig = {
'effects/pixel-dissolve',
'effects/pixelate',
'effects/radial-progressive-blur',
+ 'effects/radial-progressive-pixelate',
'effects/rings',
'effects/roughen-edges',
'effects/saturation',
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index 6cecdcdaea..50a438edba 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -1988,6 +1988,15 @@ export const articles = [
noAi: false,
slug: 'effects/linear-progressive-blur',
},
+ {
+ id: 'effects/linear-progressive-pixelate',
+ title: 'linearProgressivePixelate()',
+ relativePath: 'docs/effects/linear-progressive-pixelate.mdx',
+ compId: 'articles-docs-effects-linear-progressive-pixelate',
+ crumb: '@remotion/effects',
+ noAi: false,
+ slug: 'effects/linear-progressive-pixelate',
+ },
{
id: 'effects/lines',
title: 'lines()',
@@ -2069,6 +2078,15 @@ export const articles = [
noAi: false,
slug: 'effects/radial-progressive-blur',
},
+ {
+ id: 'effects/radial-progressive-pixelate',
+ title: 'radialProgressivePixelate()',
+ relativePath: 'docs/effects/radial-progressive-pixelate.mdx',
+ compId: 'articles-docs-effects-radial-progressive-pixelate',
+ crumb: '@remotion/effects',
+ noAi: false,
+ slug: 'effects/radial-progressive-pixelate',
+ },
{
id: 'effects/rings',
title: 'rings()',
diff --git a/packages/docs/src/remotion/Root.tsx b/packages/docs/src/remotion/Root.tsx
index f5a38e4cc6..128da6901d 100644
--- a/packages/docs/src/remotion/Root.tsx
+++ b/packages/docs/src/remotion/Root.tsx
@@ -34,6 +34,10 @@ import {
import {EffectsLinearGradientPreview} from '../../components/effects/effects-linear-gradient-preview';
import {EffectsLinearGradientTintPreview} from '../../components/effects/effects-linear-gradient-tint-preview';
import {EffectsLinearProgressiveBlurPreview} from '../../components/effects/effects-linear-progressive-blur-preview';
+import {
+ EffectsLinearProgressivePixelatePreview,
+ LINEAR_PROGRESSIVE_PIXELATE_PREVIEW_PARAMS,
+} from '../../components/effects/effects-linear-progressive-pixelate-preview';
import {EffectsLinesPreview} from '../../components/effects/effects-lines-preview';
import {EffectsMirrorPreview} from '../../components/effects/effects-mirror-preview';
import {
@@ -53,6 +57,10 @@ import {
EffectsRadialProgressiveBlurPreview,
RADIAL_PROGRESSIVE_BLUR_PREVIEW_PARAMS,
} from '../../components/effects/effects-radial-progressive-blur-preview';
+import {
+ EffectsRadialProgressivePixelatePreview,
+ RADIAL_PROGRESSIVE_PIXELATE_PREVIEW_PARAMS,
+} from '../../components/effects/effects-radial-progressive-pixelate-preview';
import {EffectsRingsPreview} from '../../components/effects/effects-rings-preview';
import {
EffectsRoughenEdgesPreview,
@@ -413,6 +421,13 @@ export const RemotionRoot: React.FC = () => {
endBlur: 50,
}}
/>
+ <Still
+ id="effects-linear-progressive-pixelate-preview"
+ component={EffectsLinearProgressivePixelatePreview}
+ width={1280}
+ height={720}
+ defaultProps={LINEAR_PROGRESSIVE_PIXELATE_PREVIEW_PARAMS}
+ />
<Still
id="effects-linear-gradient-preview"
component={EffectsLinearGradientPreview}
@@ -445,6 +460,13 @@ export const RemotionRoot: React.FC = () => {
height={720}
defaultProps={RADIAL_PROGRESSIVE_BLUR_PREVIEW_PARAMS}
/>
+ <Still
+ id="effects-radial-progressive-pixelate-preview"
+ component={EffectsRadialProgressivePixelatePreview}
+ width={1280}
+ height={720}
+ defaultProps={RADIAL_PROGRESSIVE_PIXELATE_PREVIEW_PARAMS}
+ />
<Still
id="effects-light-trail-text-source"
component={LightTrailTextSource}
diff --git a/packages/docs/static/generated/articles-docs-effects-linear-progressive-pixelate.png b/packages/docs/static/generated/articles-docs-effects-linear-progressive-pixelate.png
new file mode 100644
index 0000000000..d18a978f59
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-effects-linear-progressive-pixelate.png differ
diff --git a/packages/docs/static/generated/articles-docs-effects-radial-progressive-pixelate.png b/packages/docs/static/generated/articles-docs-effects-radial-progressive-pixelate.png
new file mode 100644
index 0000000000..8c78c1e415
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-effects-radial-progressive-pixelate.png differ
diff --git a/packages/docs/static/img/effects-linear-progressive-pixelate-preview.png b/packages/docs/static/img/effects-linear-progressive-pixelate-preview.png
new file mode 100644
index 0000000000..f981decace
Binary files /dev/null and b/packages/docs/static/img/effects-linear-progressive-pixelate-preview.png differ
diff --git a/packages/docs/static/img/effects-radial-progressive-pixelate-preview.png b/packages/docs/static/img/effects-radial-progressive-pixelate-preview.png
new file mode 100644
index 0000000000..1a195b8ec7
Binary files /dev/null and b/packages/docs/static/img/effects-radial-progressive-pixelate-preview.png differ
diff --git a/packages/effects/bundle.ts b/packages/effects/bundle.ts
index bb1c6c9bd5..f4dc33cfb4 100644
--- a/packages/effects/bundle.ts
+++ b/packages/effects/bundle.ts
@@ -36,6 +36,7 @@ const effectEntrypoints = [
'src/linear-gradient.ts',
'src/linear-gradient-tint.ts',
'src/linear-progressive-blur.ts',
+ 'src/linear-progressive-pixelate.ts',
'src/light-trail.ts',
'src/mirror.ts',
'src/noise.ts',
@@ -44,6 +45,7 @@ const effectEntrypoints = [
'src/roughen-edges.ts',
'src/pattern.ts',
'src/radial-progressive-blur.ts',
+ 'src/radial-progressive-pixelate.ts',
'src/rings.ts',
'src/saturation.ts',
'src/scanlines.ts',
diff --git a/packages/effects/package.json b/packages/effects/package.json
index e1968e6987..8348c7eb3e 100644
--- a/packages/effects/package.json
+++ b/packages/effects/package.json
@@ -174,6 +174,11 @@
"module": "./dist/esm/linear-progressive-blur.mjs",
"import": "./dist/esm/linear-progressive-blur.mjs"
},
+ "./linear-progressive-pixelate": {
+ "types": "./dist/linear-progressive-pixelate.d.ts",
+ "module": "./dist/esm/linear-progressive-pixelate.mjs",
+ "import": "./dist/esm/linear-progressive-pixelate.mjs"
+ },
"./light-trail": {
"types": "./dist/light-trail.d.ts",
"module": "./dist/esm/light-trail.mjs",
@@ -219,6 +224,11 @@
"module": "./dist/esm/radial-progressive-blur.mjs",
"import": "./dist/esm/radial-progressive-blur.mjs"
},
+ "./radial-progressive-pixelate": {
+ "types": "./dist/radial-progressive-pixelate.d.ts",
+ "module": "./dist/esm/radial-progressive-pixelate.mjs",
+ "import": "./dist/esm/radial-progressive-pixelate.mjs"
+ },
"./rings": {
"types": "./dist/rings.d.ts",
"module": "./dist/esm/rings.mjs",
@@ -397,6 +407,9 @@
"linear-progressive-blur": [
"dist/linear-progressive-blur.d.ts"
],
+ "linear-progressive-pixelate": [
+ "dist/linear-progressive-pixelate.d.ts"
+ ],
"light-trail": [
"dist/light-trail.d.ts"
],
@@ -424,6 +437,9 @@
"radial-progressive-blur": [
"dist/radial-progressive-blur.d.ts"
],
+ "radial-progressive-pixelate": [
+ "dist/radial-progressive-pixelate.d.ts"
+ ],
"rings": [
"dist/rings.d.ts"
],
diff --git a/packages/effects/src/linear-progressive-pixelate.ts b/packages/effects/src/linear-progressive-pixelate.ts
new file mode 100644
index 0000000000..f9bfdefc8a
--- /dev/null
+++ b/packages/effects/src/linear-progressive-pixelate.ts
@@ -0,0 +1,5 @@
+export {
+ linearProgressivePixelate,
+ type LinearProgressivePixelateParams,
+ type LinearProgressivePixelateUvCoordinate,
+} from './linear-progressive-pixelate/index.js';
diff --git a/packages/effects/src/linear-progressive-pixelate/index.ts b/packages/effects/src/linear-progressive-pixelate/index.ts
new file mode 100644
index 0000000000..c80fa1be87
--- /dev/null
+++ b/packages/effects/src/linear-progressive-pixelate/index.ts
@@ -0,0 +1,166 @@
+import type {InteractivitySchema} from 'remotion';
+import {Internals} from 'remotion';
+import {assertOptionalFiniteNumber} from '../color-utils.js';
+import {
+ cleanupProgressivePixelate,
+ drawProgressivePixelate,
+ prepareProgressivePixelate,
+ setupProgressivePixelate,
+ type ProgressivePixelateState,
+} from '../progressive-pixelate-runtime.js';
+import {assertEffectParamsObject} from '../validate-effect-param.js';
+
+const {createEffect} = Internals;
+
+const DEFAULT_START = [0, 0.5] as const;
+const DEFAULT_END = [1, 0.5] as const;
+const DEFAULT_START_BLOCK_SIZE = 1;
+const DEFAULT_END_BLOCK_SIZE = 40;
+
+export type LinearProgressivePixelateUvCoordinate = readonly [number, number];
+
+export type LinearProgressivePixelateParams = {
+ /** UV coordinate where `startBlockSize` is reached. Defaults to `[0, 0.5]`. */
+ readonly start?: LinearProgressivePixelateUvCoordinate;
+ /** UV coordinate where `endBlockSize` is reached. Defaults to `[1, 0.5]`. */
+ readonly end?: LinearProgressivePixelateUvCoordinate;
+ /** Pixel block size at `start`. Defaults to `1`. */
+ readonly startBlockSize?: number;
+ /** Pixel block size at `end`. Defaults to `40`. */
+ readonly endBlockSize?: number;
+};
+
+type LinearProgressivePixelateResolved = {
+ readonly start: LinearProgressivePixelateUvCoordinate;
+ readonly end: LinearProgressivePixelateUvCoordinate;
+ readonly startBlockSize: number;
+ readonly endBlockSize: number;
+};
+
+const linearProgressivePixelateSchema = {
+ start: {
+ type: 'uv-coordinate',
+ min: -1,
+ max: 2,
+ step: 0.01,
+ default: DEFAULT_START,
+ description: 'Start',
+ visual: {
+ type: 'line',
+ to: 'end',
+ },
+ },
+ end: {
+ type: 'uv-coordinate',
+ min: -1,
+ max: 2,
+ step: 0.01,
+ default: DEFAULT_END,
+ description: 'End',
+ },
+ startBlockSize: {
+ type: 'number',
+ min: 1,
+ max: 200,
+ step: 1,
+ default: DEFAULT_START_BLOCK_SIZE,
+ description: 'Start block size',
+ hiddenFromList: false,
+ },
+ endBlockSize: {
+ type: 'number',
+ min: 1,
+ max: 200,
+ step: 1,
+ default: DEFAULT_END_BLOCK_SIZE,
+ description: 'End block size',
+ hiddenFromList: false,
+ },
+} as const satisfies InteractivitySchema;
+
+const resolve = (
+ params: LinearProgressivePixelateParams,
+): LinearProgressivePixelateResolved => ({
+ start: [
+ ...(params.start ?? DEFAULT_START),
+ ] as LinearProgressivePixelateUvCoordinate,
+ end: [
+ ...(params.end ?? DEFAULT_END),
+ ] as LinearProgressivePixelateUvCoordinate,
+ startBlockSize: params.startBlockSize ?? DEFAULT_START_BLOCK_SIZE,
+ endBlockSize: params.endBlockSize ?? DEFAULT_END_BLOCK_SIZE,
+});
+
+const assertOptionalUvCoordinate = (value: unknown, name: string): void => {
+ if (value === undefined) {
+ return;
+ }
+
+ if (
+ !Array.isArray(value) ||
+ value.length !== 2 ||
+ value.some((item) => typeof item !== 'number' || !Number.isFinite(item))
+ ) {
+ throw new TypeError(`"${name}" must be a [number, number] tuple`);
+ }
+};
+
+const validateBlockSize = (value: number, name: string): void => {
+ if (value < 1) {
+ throw new TypeError(`"${name}" must be >= 1`);
+ }
+};
+
+const validateParams = (params: LinearProgressivePixelateParams): void => {
+ assertEffectParamsObject(params, 'Linear progressive pixelate');
+ assertOptionalUvCoordinate(params.start, 'start');
+ assertOptionalUvCoordinate(params.end, 'end');
+ assertOptionalFiniteNumber(params.startBlockSize, 'startBlockSize');
+ assertOptionalFiniteNumber(params.endBlockSize, 'endBlockSize');
+ validateBlockSize(
+ params.startBlockSize ?? DEFAULT_START_BLOCK_SIZE,
+ 'startBlockSize',
+ );
+ validateBlockSize(
+ params.endBlockSize ?? DEFAULT_END_BLOCK_SIZE,
+ 'endBlockSize',
+ );
+};
+
+export const linearProgressivePixelate = createEffect<
+ LinearProgressivePixelateParams,
+ ProgressivePixelateState
+>({
+ type: 'dev.remotion.effects.linearProgressivePixelate',
+ label: 'linearProgressivePixelate()',
+ documentationLink:
+ 'https://www.remotion.dev/docs/effects/linear-progressive-pixelate',
+ backend: 'webgl2',
+ calculateKey: (params) => {
+ const r = resolve(params);
+ return `linear-progressive-pixelate-${r.start.join(':')}-${r.end.join(':')}-${r.startBlockSize}-${r.endBlockSize}`;
+ },
+ setup: setupProgressivePixelate,
+ apply: ({source, width, height, params, state, flipSourceY}) => {
+ const r = resolve(params);
+ prepareProgressivePixelate({
+ state,
+ source,
+ width,
+ height,
+ flipSourceY,
+ });
+ const {gl, uniforms} = state;
+ if (uniforms.uMode) gl.uniform1i(uniforms.uMode, 0);
+ if (uniforms.uStart) gl.uniform2f(uniforms.uStart, r.start[0], r.start[1]);
+ if (uniforms.uEnd) gl.uniform2f(uniforms.uEnd, r.end[0], r.end[1]);
+ if (uniforms.uStartBlockSize)
+ gl.uniform1f(uniforms.uStartBlockSize, r.startBlockSize);
+ if (uniforms.uEndBlockSize)
+ gl.uniform1f(uniforms.uEndBlockSize, r.endBlockSize);
+ drawProgressivePixelate(state);
+ },
+ cleanup: cleanupProgressivePixelate,
+ schema: linearProgressivePixelateSchema,
+ validateParams,
+});
diff --git a/packages/effects/src/progressive-pixelate-runtime.ts b/packages/effects/src/progressive-pixelate-runtime.ts
new file mode 100644
index 0000000000..729a98c2c8
--- /dev/null
+++ b/packages/effects/src/progressive-pixelate-runtime.ts
@@ -0,0 +1,300 @@
+import {Internals} from 'remotion';
+
+const {createWebGL2ContextError} = Internals;
+
+export type ProgressivePixelateUniforms = {
+ readonly uSource: WebGLUniformLocation | null;
+ readonly uResolution: WebGLUniformLocation | null;
+ readonly uMode: WebGLUniformLocation | null;
+ readonly uStart: WebGLUniformLocation | null;
+ readonly uEnd: WebGLUniformLocation | null;
+ readonly uCenter: WebGLUniformLocation | null;
+ readonly uWidth: WebGLUniformLocation | null;
+ readonly uHeight: WebGLUniformLocation | null;
+ readonly uRotation: WebGLUniformLocation | null;
+ readonly uRadialStart: WebGLUniformLocation | null;
+ readonly uStartBlockSize: WebGLUniformLocation | null;
+ readonly uEndBlockSize: WebGLUniformLocation | null;
+};
+
+export type ProgressivePixelateState = {
+ readonly gl: WebGL2RenderingContext;
+ readonly program: WebGLProgram;
+ readonly vao: WebGLVertexArrayObject;
+ readonly vbo: WebGLBuffer;
+ readonly texture: WebGLTexture;
+ readonly uniforms: ProgressivePixelateUniforms;
+};
+
+const VERTEX_SHADER = /* glsl */ `#version 300 es
+layout(location = 0) in vec2 aPos;
+layout(location = 1) in vec2 aUv;
+out vec2 vUv;
+
+void main() {
+ vUv = aUv;
+ gl_Position = vec4(aPos, 0.0, 1.0);
+}
+`;
+
+const FRAGMENT_SHADER = /* glsl */ `#version 300 es
+precision highp float;
+
+in vec2 vUv;
+out vec4 fragColor;
+
+uniform sampler2D uSource;
+uniform vec2 uResolution;
+uniform int uMode;
+uniform vec2 uStart;
+uniform vec2 uEnd;
+uniform vec2 uCenter;
+uniform float uWidth;
+uniform float uHeight;
+uniform float uRotation;
+uniform float uRadialStart;
+uniform float uStartBlockSize;
+uniform float uEndBlockSize;
+
+float linearProgress(vec2 uv) {
+ vec2 gradient = uEnd - uStart;
+ float gradientLengthSq = dot(gradient, gradient);
+ if (gradientLengthSq <= 0.0000001) {
+ return 0.0;
+ }
+
+ return clamp(dot(uv - uStart, gradient) / gradientLengthSq, 0.0, 1.0);
+}
+
+float radialProgress(vec2 uv) {
+ vec2 radii = vec2(uWidth * uResolution.x, uHeight * uResolution.y) * 0.5;
+ if (radii.x <= 0.0000001 || radii.y <= 0.0000001) {
+ return 0.0;
+ }
+
+ vec2 delta = (uv - uCenter) * uResolution;
+ float angle = radians(uRotation);
+ float c = cos(angle);
+ float s = sin(angle);
+ vec2 local = vec2(
+ c * delta.x + s * delta.y,
+ -s * delta.x + c * delta.y
+ );
+ float ellipseProgress = clamp(length(local / radii), 0.0, 1.0);
+ float distance = 1.0 - uRadialStart;
+ return abs(distance) <= 0.0000001
+ ? step(uRadialStart, ellipseProgress)
+ : clamp((ellipseProgress - uRadialStart) / distance, 0.0, 1.0);
+}
+
+vec4 samplePixelated(float blockSize) {
+ vec2 pixelSizeUv = vec2(blockSize) / uResolution;
+ vec2 blockUv = floor(vUv / pixelSizeUv) * pixelSizeUv + pixelSizeUv * 0.5;
+ return texture(uSource, blockUv);
+}
+
+void main() {
+ // Public UV coordinates use top-left origin, matching canvas/CSS coordinates.
+ vec2 publicUv = vec2(vUv.x, 1.0 - vUv.y);
+ float progress = uMode == 0
+ ? linearProgress(publicUv)
+ : radialProgress(publicUv);
+ float targetBlockSize = max(
+ 1.0,
+ mix(uStartBlockSize, uEndBlockSize, progress)
+ );
+
+ // Adjacent power-of-two grids remain aligned as the block size changes.
+ float level = log2(targetBlockSize);
+ float lowerBlockSize = exp2(floor(level));
+ float upperBlockSize = lowerBlockSize * 2.0;
+ float levelProgress = fract(level);
+ fragColor = mix(
+ samplePixelated(lowerBlockSize),
+ samplePixelated(upperBlockSize),
+ levelProgress
+ );
+}
+`;
+
+const compileShader = (
+ gl: WebGL2RenderingContext,
+ type: number,
+ source: string,
+): WebGLShader => {
+ const shader = gl.createShader(type);
+ if (!shader) {
+ throw new Error('Failed to create WebGL shader');
+ }
+
+ gl.shaderSource(shader, source);
+ gl.compileShader(shader);
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
+ const log = gl.getShaderInfoLog(shader);
+ gl.deleteShader(shader);
+ throw new Error(
+ `Progressive pixelate shader compile failed: ${log ?? '(no log)'}`,
+ );
+ }
+
+ return shader;
+};
+
+const linkProgram = (
+ gl: WebGL2RenderingContext,
+ vs: WebGLShader,
+ fs: WebGLShader,
+): WebGLProgram => {
+ const program = gl.createProgram();
+ if (!program) {
+ throw new Error('Failed to create WebGL program');
+ }
+
+ gl.attachShader(program, vs);
+ gl.attachShader(program, fs);
+ gl.linkProgram(program);
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
+ const log = gl.getProgramInfoLog(program);
+ gl.deleteProgram(program);
+ throw new Error(
+ `Progressive pixelate program link failed: ${log ?? '(no log)'}`,
+ );
+ }
+
+ return program;
+};
+
+export const setupProgressivePixelate = (
+ target: HTMLCanvasElement,
+): ProgressivePixelateState => {
+ const gl = target.getContext('webgl2', {
+ premultipliedAlpha: true,
+ alpha: true,
+ preserveDrawingBuffer: true,
+ });
+ if (!gl) {
+ throw createWebGL2ContextError('progressive pixelate effect');
+ }
+
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
+ const vs = compileShader(gl, gl.VERTEX_SHADER, VERTEX_SHADER);
+ const fs = compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT_SHADER);
+ const program = linkProgram(gl, vs, fs);
+ gl.deleteShader(vs);
+ gl.deleteShader(fs);
+
+ const vao = gl.createVertexArray();
+ if (!vao) {
+ throw new Error('Failed to create WebGL vertex array');
+ }
+
+ gl.bindVertexArray(vao);
+ const data = new Float32Array([
+ -1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1,
+ ]);
+ const vbo = gl.createBuffer();
+ if (!vbo) {
+ throw new Error('Failed to create WebGL buffer');
+ }
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
+ gl.enableVertexAttribArray(0);
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 16, 0);
+ gl.enableVertexAttribArray(1);
+ gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 16, 8);
+ gl.bindVertexArray(null);
+
+ const texture = gl.createTexture();
+ if (!texture) {
+ throw new Error('Failed to create WebGL texture');
+ }
+
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ gl.bindTexture(gl.TEXTURE_2D, null);
+
+ return {
+ gl,
+ program,
+ vao,
+ vbo,
+ texture,
+ uniforms: {
+ uSource: gl.getUniformLocation(program, 'uSource'),
+ uResolution: gl.getUniformLocation(program, 'uResolution'),
+ uMode: gl.getUniformLocation(program, 'uMode'),
+ uStart: gl.getUniformLocation(program, 'uStart'),
+ uEnd: gl.getUniformLocation(program, 'uEnd'),
+ uCenter: gl.getUniformLocation(program, 'uCenter'),
+ uWidth: gl.getUniformLocation(program, 'uWidth'),
+ uHeight: gl.getUniformLocation(program, 'uHeight'),
+ uRotation: gl.getUniformLocation(program, 'uRotation'),
+ uRadialStart: gl.getUniformLocation(program, 'uRadialStart'),
+ uStartBlockSize: gl.getUniformLocation(program, 'uStartBlockSize'),
+ uEndBlockSize: gl.getUniformLocation(program, 'uEndBlockSize'),
+ },
+ };
+};
+
+export const prepareProgressivePixelate = ({
+ state,
+ source,
+ width,
+ height,
+ flipSourceY,
+}: {
+ readonly state: ProgressivePixelateState;
+ readonly source: CanvasImageSource;
+ readonly width: number;
+ readonly height: number;
+ readonly flipSourceY: boolean;
+}): void => {
+ const {gl, uniforms} = state;
+ gl.viewport(0, 0, width, height);
+ gl.clearColor(0, 0, 0, 0);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
+ gl.activeTexture(gl.TEXTURE0);
+ gl.bindTexture(gl.TEXTURE_2D, state.texture);
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
+ gl.texImage2D(
+ gl.TEXTURE_2D,
+ 0,
+ gl.RGBA,
+ gl.RGBA,
+ gl.UNSIGNED_BYTE,
+ source as TexImageSource,
+ );
+ gl.useProgram(state.program);
+ if (uniforms.uSource) gl.uniform1i(uniforms.uSource, 0);
+ if (uniforms.uResolution) gl.uniform2f(uniforms.uResolution, width, height);
+};
+
+export const drawProgressivePixelate = (
+ state: ProgressivePixelateState,
+): void => {
+ const {gl} = state;
+ gl.bindVertexArray(state.vao);
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+ gl.bindVertexArray(null);
+ gl.bindTexture(gl.TEXTURE_2D, null);
+ gl.useProgram(null);
+};
+
+export const cleanupProgressivePixelate = ({
+ gl,
+ program,
+ vao,
+ vbo,
+ texture,
+}: ProgressivePixelateState): void => {
+ gl.deleteTexture(texture);
+ gl.deleteBuffer(vbo);
+ gl.deleteProgram(program);
+ gl.deleteVertexArray(vao);
+};
diff --git a/packages/effects/src/radial-progressive-pixelate.ts b/packages/effects/src/radial-progressive-pixelate.ts
new file mode 100644
index 0000000000..c02aa72134
--- /dev/null
+++ b/packages/effects/src/radial-progressive-pixelate.ts
@@ -0,0 +1,5 @@
+export {
+ radialProgressivePixelate,
+ type RadialProgressivePixelateParams,
+ type RadialProgressivePixelateUvCoordinate,
+} from './radial-progressive-pixelate/index.js';
diff --git a/packages/effects/src/radial-progressive-pixelate/index.ts b/packages/effects/src/radial-progressive-pixelate/index.ts
new file mode 100644
index 0000000000..f2846ca470
--- /dev/null
+++ b/packages/effects/src/radial-progressive-pixelate/index.ts
@@ -0,0 +1,219 @@
+import type {InteractivitySchema} from 'remotion';
+import {Internals} from 'remotion';
+import {
+ assertOptionalFiniteNumber,
+ validateNonNegative,
+ validateUnitInterval,
+} from '../color-utils.js';
+import {
+ cleanupProgressivePixelate,
+ drawProgressivePixelate,
+ prepareProgressivePixelate,
+ setupProgressivePixelate,
+ type ProgressivePixelateState,
+} from '../progressive-pixelate-runtime.js';
+import {assertEffectParamsObject} from '../validate-effect-param.js';
+
+const {createEffect} = Internals;
+
+const DEFAULT_CENTER = [0.5, 0.5] as const;
+const DEFAULT_WIDTH = 1;
+const DEFAULT_HEIGHT = 1;
+const DEFAULT_ROTATION = 0;
+const DEFAULT_START = 0;
+const DEFAULT_START_BLOCK_SIZE = 1;
+const DEFAULT_END_BLOCK_SIZE = 40;
+
+export type RadialProgressivePixelateUvCoordinate = readonly [number, number];
+
+export type RadialProgressivePixelateParams = {
+ /** UV coordinate at the center of the ellipse. Defaults to `[0.5, 0.5]`. */
+ readonly center?: RadialProgressivePixelateUvCoordinate;
+ /** Full ellipse width in UV coordinates. Defaults to `1`. */
+ readonly width?: number;
+ /** Full ellipse height in UV coordinates. Defaults to `1`. */
+ readonly height?: number;
+ /** Ellipse rotation in degrees. Defaults to `0`. */
+ readonly rotation?: number;
+ /** Normalized ellipse progress where interpolation starts. Defaults to `0`. */
+ readonly start?: number;
+ /** Pixel block size at `start`. Defaults to `1`. */
+ readonly startBlockSize?: number;
+ /** Pixel block size at the outer ellipse. Defaults to `40`. */
+ readonly endBlockSize?: number;
+};
+
+type RadialProgressivePixelateResolved = {
+ readonly center: RadialProgressivePixelateUvCoordinate;
+ readonly width: number;
+ readonly height: number;
+ readonly rotation: number;
+ readonly start: number;
+ readonly startBlockSize: number;
+ readonly endBlockSize: number;
+};
+
+const radialProgressivePixelateSchema = {
+ center: {
+ type: 'uv-coordinate',
+ min: -1,
+ max: 2,
+ step: 0.01,
+ default: DEFAULT_CENTER,
+ description: 'Center',
+ visual: {
+ type: 'ellipse',
+ width: 'width',
+ height: 'height',
+ rotation: 'rotation',
+ innerScale: 'start',
+ },
+ },
+ width: {
+ type: 'number',
+ min: 0,
+ step: 0.01,
+ default: DEFAULT_WIDTH,
+ description: 'Width',
+ hiddenFromList: false,
+ },
+ height: {
+ type: 'number',
+ min: 0,
+ step: 0.01,
+ default: DEFAULT_HEIGHT,
+ description: 'Height',
+ hiddenFromList: false,
+ },
+ rotation: {
+ type: 'rotation-degrees',
+ step: 1,
+ default: DEFAULT_ROTATION,
+ description: 'Rotation',
+ },
+ start: {
+ type: 'number',
+ min: 0,
+ max: 1,
+ step: 0.01,
+ default: DEFAULT_START,
+ description: 'Start',
+ hiddenFromList: false,
+ },
+ startBlockSize: {
+ type: 'number',
+ min: 1,
+ max: 200,
+ step: 1,
+ default: DEFAULT_START_BLOCK_SIZE,
+ description: 'Start block size',
+ hiddenFromList: false,
+ },
+ endBlockSize: {
+ type: 'number',
+ min: 1,
+ max: 200,
+ step: 1,
+ default: DEFAULT_END_BLOCK_SIZE,
+ description: 'End block size',
+ hiddenFromList: false,
+ },
+} as const satisfies InteractivitySchema;
+
+const resolve = (
+ params: RadialProgressivePixelateParams,
+): RadialProgressivePixelateResolved => ({
+ center: [
+ ...(params.center ?? DEFAULT_CENTER),
+ ] as RadialProgressivePixelateUvCoordinate,
+ width: params.width ?? DEFAULT_WIDTH,
+ height: params.height ?? DEFAULT_HEIGHT,
+ rotation: params.rotation ?? DEFAULT_ROTATION,
+ start: params.start ?? DEFAULT_START,
+ startBlockSize: params.startBlockSize ?? DEFAULT_START_BLOCK_SIZE,
+ endBlockSize: params.endBlockSize ?? DEFAULT_END_BLOCK_SIZE,
+});
+
+const assertOptionalUvCoordinate = (value: unknown, name: string): void => {
+ if (value === undefined) {
+ return;
+ }
+
+ if (
+ !Array.isArray(value) ||
+ value.length !== 2 ||
+ value.some((item) => typeof item !== 'number' || !Number.isFinite(item))
+ ) {
+ throw new TypeError(`"${name}" must be a [number, number] tuple`);
+ }
+};
+
+const validateBlockSize = (value: number, name: string): void => {
+ if (value < 1) {
+ throw new TypeError(`"${name}" must be >= 1`);
+ }
+};
+
+const validateParams = (params: RadialProgressivePixelateParams): void => {
+ assertEffectParamsObject(params, 'Radial progressive pixelate');
+ assertOptionalUvCoordinate(params.center, 'center');
+ assertOptionalFiniteNumber(params.width, 'width');
+ assertOptionalFiniteNumber(params.height, 'height');
+ assertOptionalFiniteNumber(params.rotation, 'rotation');
+ validateNonNegative(params.width ?? DEFAULT_WIDTH, 'width');
+ validateNonNegative(params.height ?? DEFAULT_HEIGHT, 'height');
+ assertOptionalFiniteNumber(params.start, 'start');
+ validateUnitInterval(params.start ?? DEFAULT_START, 'start');
+ assertOptionalFiniteNumber(params.startBlockSize, 'startBlockSize');
+ assertOptionalFiniteNumber(params.endBlockSize, 'endBlockSize');
+ validateBlockSize(
+ params.startBlockSize ?? DEFAULT_START_BLOCK_SIZE,
+ 'startBlockSize',
+ );
+ validateBlockSize(
+ params.endBlockSize ?? DEFAULT_END_BLOCK_SIZE,
+ 'endBlockSize',
+ );
+};
+
+export const radialProgressivePixelate = createEffect<
+ RadialProgressivePixelateParams,
+ ProgressivePixelateState
+>({
+ type: 'dev.remotion.effects.radialProgressivePixelate',
+ label: 'radialProgressivePixelate()',
+ documentationLink:
+ 'https://www.remotion.dev/docs/effects/radial-progressive-pixelate',
+ backend: 'webgl2',
+ calculateKey: (params) => {
+ const r = resolve(params);
+ return `radial-progressive-pixelate-${r.center.join(':')}-${r.width}-${r.height}-${r.rotation}-${r.start}-${r.startBlockSize}-${r.endBlockSize}`;
+ },
+ setup: setupProgressivePixelate,
+ apply: ({source, width, height, params, state, flipSourceY}) => {
+ const r = resolve(params);
+ prepareProgressivePixelate({
+ state,
+ source,
+ width,
+ height,
+ flipSourceY,
+ });
+ const {gl, uniforms} = state;
+ if (uniforms.uMode) gl.uniform1i(uniforms.uMode, 1);
+ if (uniforms.uCenter)
+ gl.uniform2f(uniforms.uCenter, r.center[0], r.center[1]);
+ if (uniforms.uWidth) gl.uniform1f(uniforms.uWidth, r.width);
+ if (uniforms.uHeight) gl.uniform1f(uniforms.uHeight, r.height);
+ if (uniforms.uRotation) gl.uniform1f(uniforms.uRotation, r.rotation);
+ if (uniforms.uRadialStart) gl.uniform1f(uniforms.uRadialStart, r.start);
+ if (uniforms.uStartBlockSize)
+ gl.uniform1f(uniforms.uStartBlockSize, r.startBlockSize);
+ if (uniforms.uEndBlockSize)
+ gl.uniform1f(uniforms.uEndBlockSize, r.endBlockSize);
+ drawProgressivePixelate(state);
+ },
+ cleanup: cleanupProgressivePixelate,
+ schema: radialProgressivePixelateSchema,
+ validateParams,
+});
diff --git a/packages/effects/src/test/effect-params.test.ts b/packages/effects/src/test/effect-params.test.ts
index 6030b12920..786c04e849 100644
--- a/packages/effects/src/test/effect-params.test.ts
+++ b/packages/effects/src/test/effect-params.test.ts
@@ -26,6 +26,7 @@ import {lightTrail} from '../light-trail/index.js';
import {linearGradientTint} from '../linear-gradient-tint.js';
import {linearGradient} from '../linear-gradient.js';
import {linearProgressiveBlur} from '../linear-progressive-blur/index.js';
+import {linearProgressivePixelate} from '../linear-progressive-pixelate/index.js';
import {lines} from '../lines.js';
import {mirror} from '../mirror.js';
import {
@@ -38,6 +39,7 @@ import {pattern} from '../pattern.js';
import {pixelDissolve} from '../pixel-dissolve.js';
import {pixelate} from '../pixelate.js';
import {radialProgressiveBlur} from '../radial-progressive-blur/index.js';
+import {radialProgressivePixelate} from '../radial-progressive-pixelate/index.js';
import {rings} from '../rings.js';
import {roughenEdges} from '../roughen-edges.js';
import {saturation} from '../saturation.js';
@@ -162,6 +164,9 @@ test('@remotion/effects expose documentation links', () => {
expect(linearProgressiveBlur().definition.documentationLink).toBe(
'https://www.remotion.dev/docs/effects/linear-progressive-blur',
);
+ expect(linearProgressivePixelate().definition.documentationLink).toBe(
+ 'https://www.remotion.dev/docs/effects/linear-progressive-pixelate',
+ );
expect(lightTrail().definition.documentationLink).toBe(
'https://www.remotion.dev/docs/effects/light-trail',
);
@@ -190,6 +195,9 @@ test('@remotion/effects expose documentation links', () => {
expect(radialProgressiveBlur().definition.documentationLink).toBe(
'https://www.remotion.dev/docs/effects/radial-progressive-blur',
);
+ expect(radialProgressivePixelate().definition.documentationLink).toBe(
+ 'https://www.remotion.dev/docs/effects/radial-progressive-pixelate',
+ );
expect(rings().definition.documentationLink).toBe(
'https://www.remotion.dev/docs/effects/rings',
);
@@ -281,6 +289,9 @@ test('@remotion/effects expose API names as Studio labels', () => {
expect(linearProgressiveBlur().definition.label).toBe(
'linearProgressiveBlur()',
);
+ expect(linearProgressivePixelate().definition.label).toBe(
+ 'linearProgressivePixelate()',
+ );
expect(lightTrail().definition.label).toBe('lightTrail()');
expect(dotGrid().definition.label).toBe('dotGrid()');
expect(mirror().definition.label).toBe('mirror()');
@@ -294,6 +305,9 @@ test('@remotion/effects expose API names as Studio labels', () => {
expect(radialProgressiveBlur().definition.label).toBe(
'radialProgressiveBlur()',
);
+ expect(radialProgressivePixelate().definition.label).toBe(
+ 'radialProgressivePixelate()',
+ );
expect(rings().definition.label).toBe('rings()');
expect(saturation().definition.label).toBe('saturation()');
expect(scanlines().definition.label).toBe('scanlines()');
@@ -3087,6 +3101,102 @@ test('radialProgressiveBlur() parameters produce distinct effect keys', () => {
).toBe(8);
});
+test('linearProgressivePixelate() accepts default params', () => {
+ expect(() => linearProgressivePixelate()).not.toThrow();
+});
+
+test('linearProgressivePixelate() connects its start and end controls', () => {
+ expect(linearProgressivePixelate().definition.schema.start).toMatchObject({
+ type: 'uv-coordinate',
+ visual: {
+ type: 'line',
+ to: 'end',
+ },
+ });
+});
+
+test('linearProgressivePixelate() validates its parameters', () => {
+ expect(() =>
+ linearProgressivePixelate({
+ start: [0.5] as unknown as [number, number],
+ }),
+ ).toThrow('"start" must be a [number, number] tuple');
+ expect(() => linearProgressivePixelate({end: [0.5, Number.NaN]})).toThrow(
+ '"end" must be a [number, number] tuple',
+ );
+ expect(() => linearProgressivePixelate({startBlockSize: Number.NaN})).toThrow(
+ '"startBlockSize" must be a finite number',
+ );
+ expect(() => linearProgressivePixelate({endBlockSize: 0})).toThrow(
+ '"endBlockSize" must be >= 1',
+ );
+});
+
+test('linearProgressivePixelate() parameters produce distinct effect keys', () => {
+ const effects = [
+ linearProgressivePixelate(),
+ linearProgressivePixelate({start: [0.2, 0.5]}),
+ linearProgressivePixelate({end: [0.8, 0.5]}),
+ linearProgressivePixelate({startBlockSize: 4}),
+ linearProgressivePixelate({endBlockSize: 80}),
+ ];
+ expect(new Set(effects.map((effect) => effect.effectKey)).size).toBe(5);
+});
+
+test('radialProgressivePixelate() accepts default params', () => {
+ expect(() => radialProgressivePixelate()).not.toThrow();
+});
+
+test('radialProgressivePixelate() connects its ellipse controls', () => {
+ const {schema} = radialProgressivePixelate().definition;
+ expect(schema.center).toMatchObject({
+ type: 'uv-coordinate',
+ visual: {
+ type: 'ellipse',
+ width: 'width',
+ height: 'height',
+ rotation: 'rotation',
+ innerScale: 'start',
+ },
+ });
+ expect(schema.width).not.toHaveProperty('max');
+ expect(schema.height).not.toHaveProperty('max');
+});
+
+test('radialProgressivePixelate() validates its parameters', () => {
+ expect(() =>
+ radialProgressivePixelate({
+ center: [0.5] as unknown as [number, number],
+ }),
+ ).toThrow('"center" must be a [number, number] tuple');
+ expect(() => radialProgressivePixelate({width: -0.1})).toThrow(
+ '"width" must be >= 0',
+ );
+ expect(() => radialProgressivePixelate({start: 1.1})).toThrow(
+ '"start" must be <= 1',
+ );
+ expect(() => radialProgressivePixelate({endBlockSize: Number.NaN})).toThrow(
+ '"endBlockSize" must be a finite number',
+ );
+ expect(() => radialProgressivePixelate({startBlockSize: 0})).toThrow(
+ '"startBlockSize" must be >= 1',
+ );
+});
+
+test('radialProgressivePixelate() parameters produce distinct effect keys', () => {
+ const effects = [
+ radialProgressivePixelate(),
+ radialProgressivePixelate({center: [0.4, 0.5]}),
+ radialProgressivePixelate({width: 1.2}),
+ radialProgressivePixelate({height: 1.2}),
+ radialProgressivePixelate({rotation: 15}),
+ radialProgressivePixelate({start: 0.2}),
+ radialProgressivePixelate({startBlockSize: 4}),
+ radialProgressivePixelate({endBlockSize: 80}),
+ ];
+ expect(new Set(effects.map((effect) => effect.effectKey)).size).toBe(8);
+});
+
test('zoomBlur() accepts default params', () => {
expect(() => zoomBlur()).not.toThrow();
});
diff --git a/packages/studio-shared/src/effect-catalog.ts b/packages/studio-shared/src/effect-catalog.ts
index f263ce129a..5cbec050ba 100644
--- a/packages/studio-shared/src/effect-catalog.ts
+++ b/packages/studio-shared/src/effect-catalog.ts
@@ -556,6 +556,28 @@ export const EFFECT_CATALOG: readonly EffectCatalogItem[] = [
},
},
},
+ {
+ id: 'effects-linear-progressive-pixelate',
+ category: 'Stylize',
+ label: 'linearProgressivePixelate()',
+ description: 'Gradient-controlled pixelation',
+ effect: {
+ name: 'linearProgressivePixelate',
+ importPath: '@remotion/effects/linear-progressive-pixelate',
+ config: {},
+ },
+ },
+ {
+ id: 'effects-radial-progressive-pixelate',
+ category: 'Stylize',
+ label: 'radialProgressivePixelate()',
+ description: 'Ellipse-controlled pixelation',
+ effect: {
+ name: 'radialProgressivePixelate',
+ importPath: '@remotion/effects/radial-progressive-pixelate',
+ config: {},
+ },
+ },
{
id: 'effects-scanlines',
category: 'Stylize',
diff --git a/packages/studio/src/test/effect-catalog.test.ts b/packages/studio/src/test/effect-catalog.test.ts
index cc117695c9..c4a9a775db 100644
--- a/packages/studio/src/test/effect-catalog.test.ts
+++ b/packages/studio/src/test/effect-catalog.test.ts
@@ -24,6 +24,12 @@ test('effect catalog exposes documentation links for picker context menu', () =>
expect(links.get('pixelate()')).toBe(
'https://www.remotion.dev/docs/effects/pixelate',
);
+ expect(links.get('linearProgressivePixelate()')).toBe(
+ 'https://www.remotion.dev/docs/effects/linear-progressive-pixelate',
+ );
+ expect(links.get('radialProgressivePixelate()')).toBe(
+ 'https://www.remotion.dev/docs/effects/radial-progressive-pixelate',
+ );
expect(links.get('shrinkwrap()')).toBe(
'https://www.remotion.dev/docs/effects/shrinkwrap',
);