Skip to content

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

feat: shader voronoi

dev_wandry2a24a11cd7f5
diff --git a/content/docs/shaders/index.mdx b/content/docs/shaders/index.mdx
index d4697e54..05c4aa83 100644
--- a/content/docs/shaders/index.mdx
+++ b/content/docs/shaders/index.mdx
@@ -91,5 +91,11 @@ Powered by [paper-design/shaders](https://github.com/paper-design/shaders) (Apac
status: "stable",
href: "/docs/shaders/shader-simplex-noise",
},
+ {
+ name: "ShaderVoronoi",
+ description: "Animated Voronoi cells shifting and re-tessellating",
+ status: "stable",
+ href: "/docs/shaders/shader-voronoi",
+ },
]}
/>
diff --git a/content/docs/shaders/meta.json b/content/docs/shaders/meta.json
index e9de188c..331d480b 100644
--- a/content/docs/shaders/meta.json
+++ b/content/docs/shaders/meta.json
@@ -13,6 +13,7 @@
"shader-color-panels",
"shader-neuro-noise",
"shader-perlin-noise",
- "shader-simplex-noise"
+ "shader-simplex-noise",
+ "shader-voronoi"
]
}
diff --git a/content/docs/shaders/shader-voronoi.mdx b/content/docs/shaders/shader-voronoi.mdx
new file mode 100644
index 00000000..e86ba8b9
--- /dev/null
+++ b/content/docs/shaders/shader-voronoi.mdx
@@ -0,0 +1,37 @@
+---
+title: Shader Voronoi
+description: Animated Voronoi cells shifting and re-tessellating
+---
+
+<ComponentPreview name="shader-voronoi" />
+
+## Installation
+
+<InstallBlock name="shader-voronoi" />
+
+## Usage
+
+```tsx
+// src/Root.tsx
+import { Composition } from "remotion";
+import { ShaderVoronoi } from "@/components/remocn/shader-voronoi";
+
+const ShaderVoronoiScene = () => (
+ <ShaderVoronoi speed={1} distortion={0.4} gap={0.04} />
+);
+
+export const RemotionRoot = () => (
+ <Composition
+ id="ShaderVoronoi"
+ component={ShaderVoronoiScene}
+ 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 15c8311c..5534636a 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -95,6 +95,8 @@ import { ShaderPerlinNoise } from "@/registry/remocn/shader-perlin-noise";
import { shaderPerlinNoiseConfig } from "@/registry/remocn/shader-perlin-noise/config";
import { ShaderSimplexNoise } from "@/registry/remocn/shader-simplex-noise";
import { shaderSimplexNoiseConfig } from "@/registry/remocn/shader-simplex-noise/config";
+import { ShaderVoronoi } from "@/registry/remocn/shader-voronoi";
+import { shaderVoronoiConfig } from "@/registry/remocn/shader-voronoi/config";
import { ShaderSpiral } from "@/registry/remocn/shader-spiral";
import { shaderSpiralConfig } from "@/registry/remocn/shader-spiral/config";
import { ShaderSwirl } from "@/registry/remocn/shader-swirl";
@@ -374,6 +376,10 @@ const registry: Record<string, RegistryEntry> = {
Component: ShaderSimplexNoise,
config: shaderSimplexNoiseConfig,
},
+ "shader-voronoi": {
+ Component: ShaderVoronoi,
+ config: shaderVoronoiConfig,
+ },
"dynamic-grid": { Component: DynamicGrid, config: dynamicGridConfig },
"simulated-cursor": {
Component: SimulatedCursor,
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index e903f1b6..0ae3f994 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -663,6 +663,22 @@
}
]
},
+ {
+ "name": "shader-voronoi",
+ "type": "registry:component",
+ "title": "Shader Voronoi",
+ "description": "Animated Voronoi cells shifting and re-tessellating.",
+ "dependencies": [
+ "@paper-design/shaders-react"
+ ],
+ "files": [
+ {
+ "path": "shader-voronoi/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/shader-voronoi.tsx"
+ }
+ ]
+ },
{
"name": "dynamic-grid",
"type": "registry:component",
diff --git a/registry/remocn/shader-voronoi/config.ts b/registry/remocn/shader-voronoi/config.ts
new file mode 100644
index 00000000..7ad2108e
--- /dev/null
+++ b/registry/remocn/shader-voronoi/config.ts
@@ -0,0 +1,45 @@
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const shaderVoronoiConfig: ComponentConfig = {
+ componentName: "ShaderVoronoi",
+ importPath: "@/components/remocn/shader-voronoi",
+ controls: {
+ speed: {
+ type: "number",
+ default: 1,
+ min: 0.1,
+ max: 4,
+ step: 0.1,
+ label: "Speed",
+ },
+ distortion: {
+ type: "number",
+ default: 0.4,
+ min: 0,
+ max: 1,
+ step: 0.05,
+ label: "Distortion",
+ },
+ gap: {
+ type: "number",
+ default: 0.04,
+ min: 0,
+ max: 0.2,
+ step: 0.01,
+ label: "Gap",
+ },
+ glow: {
+ type: "number",
+ default: 0,
+ min: 0,
+ max: 1,
+ step: 0.05,
+ label: "Glow",
+ },
+ colorGap: { type: "color", default: "#12121a", label: "Gap Color" },
+ },
+ durationInFrames: 150,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+};
diff --git a/registry/remocn/shader-voronoi/index.tsx b/registry/remocn/shader-voronoi/index.tsx
new file mode 100644
index 00000000..60222d1d
--- /dev/null
+++ b/registry/remocn/shader-voronoi/index.tsx
@@ -0,0 +1,62 @@
+"use client";
+
+import { Voronoi, type VoronoiProps } from "@paper-design/shaders-react";
+import { useCallback, useState } from "react";
+import {
+ continueRender,
+ delayRender,
+ useCurrentFrame,
+ useVideoConfig,
+} from "remotion";
+
+const NEUTRAL_COLORS = ["#3a3a5c", "#52527a"];
+
+export interface ShaderVoronoiProps
+ extends Omit<VoronoiProps, "frame" | "ref"> {}
+
+export function ShaderVoronoi({
+ speed = 1,
+ colors = NEUTRAL_COLORS,
+ colorGap = "#12121a",
+ distortion = 0.4,
+ gap = 0.04,
+ glow = 0,
+ className,
+ ...rest
+}: ShaderVoronoiProps) {
+ const frame = useCurrentFrame();
+ const { fps, width, height } = useVideoConfig();
+
+ const [handle] = useState(() => delayRender("shader-voronoi"));
+ 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 }}
+ >
+ <Voronoi
+ speed={0}
+ frame={(frame / fps) * speed * 1000}
+ colors={colors}
+ colorGap={colorGap}
+ distortion={distortion}
+ gap={gap}
+ glow={glow}
+ fit="cover"
+ width={width}
+ height={height}
+ {...rest}
+ />
+ </div>
+ );
+}