Noise visualization
Using the @remotion/noise
package, you can add noise for your videos.
Noise Dot Grid Demo
This example shows how to create a floating dot grid "surface" using createNoise3D()
function.
- 1st and 2nd dimensions used for space domain.
- 3rd dimension used for time domain.
tsx
import {createNoise3D } from "@remotion/noise";importReact from "react";import {interpolate ,useCurrentFrame ,useVideoConfig } from "remotion";constxNoise3d =createNoise3D ("x");constyNoise3d =createNoise3D ("y");constopacityNoise3d =createNoise3D ("opacity");constcolorNoise3d =createNoise3D ("color");constOVERSCAN_MARGIN = 100;constNoiseComp :React .FC <{scale : number;speed : number;circleRadius : number;}> = ({scale ,speed ,circleRadius }) => {constframe =useCurrentFrame ();const {height ,width } =useVideoConfig ();constrows =Math .round ((height +OVERSCAN_MARGIN ) /scale );constcols =Math .round ((width +OVERSCAN_MARGIN ) /scale );return (<svg width ={width }height ={height }>{newArray (cols ).fill (0).map ((_ ,i ) =>newArray (rows ).fill (0).map ((__ ,j ) => {constx =i *scale ;consty =j *scale ;constpx =i /cols ;constpy =j /rows ;constdx =xNoise3d (px ,py ,frame *speed ) *scale ;constdy =yNoise3d (px ,py ,frame *speed ) *scale ;constopacity =interpolate (opacityNoise3d (i ,j ,frame *speed ),[-1, 1],[0, 1]);constcolor =colorNoise3d (px ,py ,frame *speed ) < 0? "rgb(0,87,184)": "rgb(254,221,0)";return (<circle key ={`${i }-${j }`}cx ={x +dx }cy ={y +dy }r ={circleRadius }fill ={color }opacity ={opacity }/>);}))}</svg >);};
tsx
import {createNoise3D } from "@remotion/noise";importReact from "react";import {interpolate ,useCurrentFrame ,useVideoConfig } from "remotion";constxNoise3d =createNoise3D ("x");constyNoise3d =createNoise3D ("y");constopacityNoise3d =createNoise3D ("opacity");constcolorNoise3d =createNoise3D ("color");constOVERSCAN_MARGIN = 100;constNoiseComp :React .FC <{scale : number;speed : number;circleRadius : number;}> = ({scale ,speed ,circleRadius }) => {constframe =useCurrentFrame ();const {height ,width } =useVideoConfig ();constrows =Math .round ((height +OVERSCAN_MARGIN ) /scale );constcols =Math .round ((width +OVERSCAN_MARGIN ) /scale );return (<svg width ={width }height ={height }>{newArray (cols ).fill (0).map ((_ ,i ) =>newArray (rows ).fill (0).map ((__ ,j ) => {constx =i *scale ;consty =j *scale ;constpx =i /cols ;constpy =j /rows ;constdx =xNoise3d (px ,py ,frame *speed ) *scale ;constdy =yNoise3d (px ,py ,frame *speed ) *scale ;constopacity =interpolate (opacityNoise3d (i ,j ,frame *speed ),[-1, 1],[0, 1]);constcolor =colorNoise3d (px ,py ,frame *speed ) < 0? "rgb(0,87,184)": "rgb(254,221,0)";return (<circle key ={`${i }-${j }`}cx ={x +dx }cy ={y +dy }r ={circleRadius }fill ={color }opacity ={opacity }/>);}))}</svg >);};