Skip to content
niccolofantonPublic

About

Interactive WebGL datamoshing demo: real-time glitch corruption on a 3D scene, built with React Three Fiber, three.js and GLSL shaders.

Resources

Stars

8 stars

Watchers

0 watching

Forks

Latest commit

 

History

26 Commits

Folders and files

Repository files navigation

Feeding a Decoder the Wrong Frame

Feeding a Decoder the Wrong Frame

A real-time datamosh effect in WebGL. Not a glitch filter over a finished render: an actual inter-frame decoder loop, built out of the pieces a video codec is made of — motion vectors, macroblocks, residuals — and then fed the wrong reference frame on purpose.

new frame = warp(previous frame, motion vectors) + residual

Source project for the Codrops article Feeding a Decoder the Wrong Frame by Niccolò Fanton.

The effect running in the full project

What's in here

Folder What it is
datamosh-fullproject/ The demo Codrops deploys. The complete piece: a loaded room, a dancer rig, an image-based sky, a camera controller, the debug frame buffers and a live parameter panel. React + react-three-fiber.
datamosh-demo/ The same pipeline with everything else taken away: plain three.js, six procedural shots, no downloaded assets. This is the code the article walks through, line for line.

Both projects are Vite + TypeScript. Choose one project directory first:

cd datamosh-demo     # or: cd datamosh-fullproject
pnpm install
pnpm dev

pnpm build produces a static dist/. Both are configured with Vite's base: './', so the build works from any subdirectory rather than only from a host root.

Which one to read

Read datamosh-demo/ first. It is the article's argument in about 1,200 lines with nothing in the way: main.ts owns the renderer and the shot schedule, scenes.ts is six scenes chosen for the kind of motion each one produces, and datamosh/ is the pipeline — a velocity pass, a feedback loop, and one fragment shader where the decode actually happens.

datamosh-fullproject/ is the same datamosh/ folder, wrapped in the scene the hero video shows. It is the more interesting thing to look at and the harder thing to read, because most of its extra code is about the room, the dancers and the camera, not about the effect.

How it works, in one paragraph

Every frame, a velocity pass renders each object's screen-space motion into its own buffer. While the trigger is held, the pipeline stops presenting the newly rendered image and instead resamples the previous output along those vectors — the same prediction step a decoder performs on a P-frame — and adds a quantised residual on top. Because the reference frame is never refreshed, the error compounds: detail from a shot that is no longer on screen gets dragged around by motion belonging to a shot that is. The article takes that sentence apart over nine figures.

Credits

  • Sky: kloppenheim_puresky from Poly Haven, CC0.
  • Dancer model and animation: thriller.fbx from Adobe Mixamo. Adobe permits royalty-free use in projects; the asset remains governed by Adobe's terms and is not relicensed under this repository's MIT licence.
  • Room: backroom-transformed.glb. The binary contains no upstream author or licence metadata; confirm its provenance before making the repository public.

Licence

The MIT licence applies to the source code. Third-party assets listed above are excluded.

About

Interactive WebGL datamoshing demo: real-time glitch corruption on a 3D scene, built with React Three Fiber, three.js and GLSL shaders.

Resources

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages