Ollin

Simulation

These examples run systems that change on the GPU each frame. They cover three areas: the built-in Sim field catalog, the artificial-life particle systems, and the particle fluids & soft bodies. A Sim field is a stateful texture that you draw into to seed or force it; see the Layered effects reference. This folder is separate from Physics, which covers CPU rigid and soft bodies, and from Compute, which covers raw kernels over buffers and textures.

ExampleWhat it shows
GrayScotta Gray-Scott reaction-diffusion field that evolves on the GPU (makeSimField(.reactionDiffusion(...)))
Winda simulation of your own: a wind carrying dust, run by two kernels the sketch writes (Sim.shader), a drag pushing it through the inject kernel, a noise layer stirring it as an input, the edge switched live between wrapping and walls, the wind drawn as arrows (.arrows), and the mean speed read back every half second (snapshot())
PredatorPreytwo populations on one land, prey and predators chasing each other in waves: an invasion front, then rotating spirals in its wake. Drag to release predators (makeSimField(.predatorPrey(...)))
Automatathirteen classic cellular automata under one rule picker: Game of Life, Brian's Brain, Wireworld, Griffeath's cyclic automaton, an excitable medium, the hodgepodge machine, the forest fire, Schelling's segregation, the Ising model, the Abelian sandpile, Lenia, SmoothLife, and falling sand. Each one has its own ramp, seeding recipe, and parameters. Drag to paint, and hold a key to erase (makeSimField(...))
Kuramotofireflies falling into step: four hundred Kuramoto oscillators flashing at their own pace, pulled toward the crowd, with the phases on a wheel and the order parameter as an arrow from its center; below the critical coupling they twinkle at random, above it they flash as one (Kuramoto, coherence)
Crowdwalkers that make room for each other: every one takes the velocity nearest its wish that keeps it clear of the others for the next second, trusting each neighbor to do half. Four scenes: a room draining through a door, a corridor where opposing streams sort into lanes, four streams crossing, and a ring crossing to its far side, with jammed walkers ringed in orange (Crowd, preferredVelocity, isJammed)
LifeQuiltthe classic life rules stepped by hand on the CPU and drawn as a quilt of triangular wedges, colored by a radial cosine palette. It is the by-hand counterpart to the GPU rules in Automata (drawTriangle, SDF)
MultiScaleTuringMcCabe's multi-scale Turing patterns: five scales compete at each pixel and organize themselves from noise into a relief that looks like a diatom. You can fold the result into a rosette (makeSimField(.multiScaleTuring(...)))
Fluida real-time incompressible fluid that carries color. Drag to swirl it (makeSimField(.fluid(...)))
SelfWarpthe picture warps its own earlier frames: orbiting orbs smear into ribbons along their measured motion. Drag to paint with a wake (makeSimField(.selfWarp(...)))
Ripplesa water surface under rain: the 2D wave equation shaded as liquid. Click to add a drop (makeSimField(.ripples(...)))
Watercolorwet paint on rough paper: a scripted wash, a wet-in-wet charge, a backrun bloom, and a glaze. You can take over from the script with the mouse (watercolor(pigments:))
ParticleLifeattraction and repulsion matrices that grow membranes, chasers, and worms (makeParticleLife(...))
PrimordialParticlesone turning rule that grows cells, and the cells divide (makePrimordialParticles(...))
Physarumslime-mold agents that grow branching trail networks (makePhysarum(...))
ParticleFluida box of water made of particles. It starts as a dam break, splashes, then settles into a pool. Drag to grab it (makeParticleFluid(...))
SoftBodiesshape-matched jelly blobs that tumble into a pile. Drag to knead them (makeSoftBodies(...))
Swarmsteering at scale: 30,000 creatures decide where to go from the same short list of urges, and the GPU works it out. Because the list is shared, the same weights make a flock, a crowd, or a drifting cloud (makeSwarm(...))
SwarmChemistryevery particle carries its own copy of the rule it moves by. When two particles touch, one copy overwrites the other, so a recipe spreads when the particles that hold it keep meeting others and winning
ParticleLeniano force law at all. Instead there is an energy field, and the particles walk downhill on it. A ring-shaped kernel measures how crowded each particle is
Attractora strange attractor as moving material rather than a still curve. A million particles integrate the same velocity field on the GPU. They are pulled onto the shape and then stream along it
Evolutionthirty thousand attempts at one journey, and none of them knows the route. A genome is a list of pushes. Whoever lands nearest is more likely to become a parent, so the route is found in a dozen generations
Breedingevolution with nobody keeping score. Sixteen ornaments are each drawn from eight numbers, and the only thing that decides which ones have children is which ones you liked looking at

Run one with swift run Example-Simulation-<Name>, e.g. swift run Example-Simulation-ParticleFluid.

↑↓ move ↩ open