Skip to content
Benjamín Díaz
Back to projects

Procedural Art

GPU-Accelerated Simulations for the Web

Five browser simulations I built with Three.js and WebGL: Boids, Reaction-Diffusion, Physarum, Curl Noise, and Fluid. Published as an npm library.

Benjamín Díaz · Published ·

  • Three.js
  • WebGL
  • GPGPU
  • TypeScript
  • Creative Coding
  • npm
  • GLSL
Try the interactive experienceRun all simulations directly in your browser
Launch
Procedural ArtExperiments

I brought five procedural art experiments to the browser: Boids, Reaction-Diffusion, Physarum, Curl Noise, and Fluid. They use Three.js, WebGL, and custom shaders, and are published as @benjadiazp/procedural-art on npm.

The project grew out of my Unity compute shader experiments. I wanted people to be able to open the simulations and try them without installing an engine.

The simulations

Boids uses three local rules to create flocking: separation, alignment, and cohesion. My version adds predators and prey, with spatial hashing to reduce neighbor searches.

Reaction-Diffusion uses the Gray-Scott model to create spots, stripes, and branching patterns. Changing the feed and kill rates changes what grows across the surface. Lighting makes the flat simulation look three-dimensional.

Physarum is inspired by slime mold. Agents leave trails, sense the concentration around them, and turn toward it. The trails form networks as the simulation runs.

Curl Noise moves particles through a divergence-free noise field, producing flowing paths without solving a fluid simulation.

Fluid solves a real-time fluid model. Moving the mouse adds velocity and dye, so you can stir the image yourself.

Running on the GPU

The simulations keep state in floating-point textures. Fragment shaders update that state through render passes; this is GPGPU work using WebGL, rather than Unity-style compute shaders. Depending on the simulation, the result is drawn with instanced meshes or a full-screen quad.

The library exposes a mount() function that takes a DOM container. It returns methods to change the simulation, list the available ones, and release its resources. Controls and their labels can be configured by the page embedding it.

You can try all five in the live demo, or use the npm package in your own page.