Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

feat: dithering

dev_wandryfc57f0fd12b0
diff --git a/content/docs/shaders/index.mdx b/content/docs/shaders/index.mdx
index f33a5afa..b4f002d3 100644
--- a/content/docs/shaders/index.mdx
+++ b/content/docs/shaders/index.mdx
@@ -112,3 +112,16 @@ Powered by [paper-design/shaders](https://github.com/paper-design/shaders) (Apac
},
]}
/>
+
+## Texture
+
+<ComponentCardGrid
+ items={[
+ {
+ name: "ShaderDithering",
+ description: "Ordered-dither shading over an animated gradient field",
+ status: "stable",
+ href: "/docs/shaders/shader-dithering",
+ },
+ ]}
+/>
diff --git a/content/docs/shaders/meta.json b/content/docs/shaders/meta.json
index 16b32c1a..6eb659b2 100644
--- a/content/docs/shaders/meta.json
+++ b/content/docs/shaders/meta.json
@@ -15,6 +15,7 @@
"shader-perlin-noise",
"shader-simplex-noise",
"shader-voronoi",
- "shader-dot-orbit"
+ "shader-dot-orbit",
+ "shader-dithering"
]
}
diff --git a/content/docs/shaders/shader-dithering.mdx b/content/docs/shaders/shader-dithering.mdx
new file mode 100644
index 00000000..6e2116d3
--- /dev/null
+++ b/content/docs/shaders/shader-dithering.mdx
@@ -0,0 +1,37 @@
+---
+title: Shader Dithering
+description: Ordered-dither shading over an animated gradient field
+---
+
+<ComponentPreview name="shader-dithering" />
+
+## Installation
+
+<InstallBlock name="shader-dithering" />
+
+## Usage
+
+```tsx
+// src/Root.tsx
+import { Composition } from "remotion";
+import { ShaderDithering } from "@/components/remocn/shader-dithering";
+
+const ShaderDitheringScene = () => (
+ <ShaderDithering speed={1} size={2} type="4x4" />
+);
+
+export const RemotionRoot = () => (
+ <Composition
+ id="ShaderDithering"
+ component={ShaderDitheringScene}
+ durationInFrames={150}
+ fps={30}
+ width={1280}
+ height={720}
+ />
+);
+```
+
+## Credits
+
+Shader by [paper-design/shaders](https://github.com/paper-design/shaders) (Apache-2.0).
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index 4efbbf6e..828f63dd 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -85,6 +85,8 @@ import { ShaderGrainGradient } from "@/registry/remocn/shader-grain-gradient";
import { shaderGrainGradientConfig } from "@/registry/remocn/shader-grain-gradient/config";
import { ShaderColorPanels } from "@/registry/remocn/shader-color-panels";
import { shaderColorPanelsConfig } from "@/registry/remocn/shader-color-panels/config";
+import { ShaderDithering } from "@/registry/remocn/shader-dithering";
+import { shaderDitheringConfig } from "@/registry/remocn/shader-dithering/config";
import { ShaderDotOrbit } from "@/registry/remocn/shader-dot-orbit";
import { shaderDotOrbitConfig } from "@/registry/remocn/shader-dot-orbit/config";
import { ShaderLiquidMetal } from "@/registry/remocn/shader-liquid-metal";
@@ -386,6 +388,10 @@ const registry: Record<string, RegistryEntry> = {
Component: ShaderDotOrbit,
config: shaderDotOrbitConfig,
},
+ "shader-dithering": {
+ Component: ShaderDithering,
+ config: shaderDitheringConfig,
+ },
"dynamic-grid": { Component: DynamicGrid, config: dynamicGridConfig },
"simulated-cursor": {
Component: SimulatedCursor,
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index cd3b4205..2ad5cefe 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -695,6 +695,22 @@
}
]
},
+ {
+ "name": "shader-dithering",
+ "type": "registry:component",
+ "title": "Shader Dithering",
+ "description": "Ordered-dither shading over an animated gradient field.",
+ "dependencies": [
+ "@paper-design/shaders-react"
+ ],
+ "files": [
+ {
+ "path": "shader-dithering/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/shader-dithering.tsx"
+ }
+ ]
+ },
{
"name": "dynamic-grid",
"type": "registry:component",
diff --git a/registry/remocn/shader-dithering/config.ts b/registry/remocn/shader-dithering/config.ts
new file mode 100644
index 00000000..9bac4830
--- /dev/null
+++ b/registry/remocn/shader-dithering/config.ts
@@ -0,0 +1,30 @@
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const shaderDitheringConfig: ComponentConfig = {
+ componentName: "ShaderDithering",
+ importPath: "@/components/remocn/shader-dithering",
+ controls: {
+ speed: {
+ type: "number",
+ default: 1,
+ min: 0.1,
+ max: 4,
+ step: 0.1,
+ label: "Speed",
+ },
+ size: {
+ type: "number",
+ default: 2,
+ min: 1,
+ max: 8,
+ step: 1,
+ label: "Dot Size",
+ },
+ colorBack: { type: "color", default: "#12121a", label: "Background" },
+ colorFront: { type: "color", default: "#6a6a85", label: "Front" },
+ },
+ durationInFrames: 150,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+};
diff --git a/registry/remocn/shader-dithering/index.tsx b/registry/remocn/shader-dithering/index.tsx
new file mode 100644
index 00000000..b0bc0a72
--- /dev/null
+++ b/registry/remocn/shader-dithering/index.tsx
@@ -0,0 +1,60 @@
+"use client";
+
+import { Dithering, type DitheringProps } from "@paper-design/shaders-react";
+import { useCallback, useState } from "react";
+import {
+ continueRender,
+ delayRender,
+ useCurrentFrame,
+ useVideoConfig,
+} from "remotion";
+
+export interface ShaderDitheringProps
+ extends Omit<DitheringProps, "frame" | "ref"> {}
+
+export function ShaderDithering({
+ speed = 1,
+ colorBack = "#12121a",
+ colorFront = "#6a6a85",
+ shape = "wave",
+ type = "4x4",
+ size = 2,
+ className,
+ ...rest
+}: ShaderDitheringProps) {
+ const frame = useCurrentFrame();
+ const { fps, width, height } = useVideoConfig();
+
+ const [handle] = useState(() => delayRender("shader-dithering"));
+ const gate = useCallback(
+ (element: HTMLDivElement | null) => {
+ if (!element) return;
+ requestAnimationFrame(() =>
+ requestAnimationFrame(() => continueRender(handle)),
+ );
+ },
+ [handle],
+ );
+
+ return (
+ <div
+ ref={gate}
+ className={className}
+ style={{ position: "absolute", inset: 0 }}
+ >
+ <Dithering
+ speed={0}
+ frame={(frame / fps) * speed * 1000}
+ colorBack={colorBack}
+ colorFront={colorFront}
+ shape={shape}
+ type={type}
+ size={size}
+ fit="cover"
+ width={width}
+ height={height}
+ {...rest}
+ />
+ </div>
+ );
+}