# brainrot 013: aquarium Live: https://brainrot.runfridge.dev/013/ Source: https://github.com/hwhang0917/brainrot/tree/main/013 License: MIT (see LICENSE at repo root); attribution only, no warranty. Sounds: the .mp3 files come from Mixkit and Pixabay under their own licenses, not MIT (see LICENSE). ## What it is A full-screen reef tank: three clownfish, three regal blue tangs, three Moorish idols and one puffer swim over gravel, rock, corals, a clam and swaying grass. Two tools sit at the bottom (keys 1 and 2): "tap" knocks on the glass where you click, so nearby fish bolt and the puffer swells and bristles; "feed" shakes a pinch of flakes onto the water above the click. Hungry fish chase the flakes. Flakes nobody eats land on the gravel as muck, and the water greens over about ten minutes. A plate on the hood holds two clickable rocker switches: LIGHT fades the lamp to moonlight blue, and AIR stops the bubbles, the clam and the pump sound. The clam fills with air, opens to show its pearl and lets out a burst of bubbles every 9 s, and the one clownfish that likes bubbles comes over to play in the stream. Sound starts on the shared sound gate or the mute button: a looping bubbler plus one-shot tap, shake, splash and switch clips. URL params: `?cloud=0.8` starts with murky water, `?shell=1` holds the clam open. ## How it was built - Rendering is pixi.js (WebGL preferred). The background (water, light rays, caustics, gravel, rock, staghorn, brain coral, sea fan, clam, grass) comes from one GLSL fragment shader. It runs as a Filter on a full-screen Graphics and draws every decor piece as a distance field lit by one LAMP direction. The water filter renders at resolution 1, one texel per CSS pixel, so retina phones don't pay 4x for it. - The fish are sprites. Each body is painted once on a 512×384 canvas per fish (`bodyCanvas(species, seed)`) with its own seed, so no two fish look quite alike. The caudal and pectoral fins are drawn live every frame with pixi Graphics, from per-species outlines (`ART`). A second filter over the whole school applies the same caustics, depth fog, murk and lamp darkening, so the fish sit in the water rather than on top of it. - The simulation (`tank.ts`) is pure state in screen px. The fish are boids per species: separation applies across all species, while alignment and cohesion apply only within a species. On top of that come wall push, wander, a food pull scaled by hunger, startle, puffing and a play orbit over the clam. Flakes sink and drift. A fish eats a flake when the flake is near its mouth, half a body length ahead of its centre. Muck slowly drives `cloud` (CLOUD_RISE_SECONDS 600), and the filter decays muck over 5400 s. The neighbour search is a deliberate O(n²) loop (marked `ponytail:`). - History, all from 2026-10-11: it started as platy, neon tetra and tiger barb with a water-change button. The water change was removed in favour of the tap/feed tools copied from the 012 campfire. Then it became a reef with real switches. After that the decor moved into the shader instead of being cut-out shapes. Last came per-fish seeds and painted flakes. The bubbler clip was re-cut with its tail crossfaded into its head, and the loop skips LOOP_TRIM (0.06 s) at each end to get past MP3 padding. - The page was vibe coded: prompted into existence with a coding agent and iterated commit by commit. ## Files - 013/index.html: page shell, back/mute/CRT buttons, the tap/feed tool bar (data-key badges), the hint. - 013/main.ts: pixi app, both GLSL filters (water and school), fish sprites with live fins, hood switches, bubbles, flakes, ripples, tools and input, and WebAudio (loop and one-shots). Imports `lib/crt.ts` (mountCrt), `lib/hud.ts` (mountHud) and `lib/soundGate.ts` (mountSoundGate), and borrows `006/switch.mp3`. - 013/tank.ts: the pure simulation (create, resize, tap, feed, step), with all behaviour constants and `events` per step ('eat' | 'splash' | 'land' | 'pop'). - 013/tank.test.ts: node tests for staying in the water, eating vs. muck, the tap radius, clam pop and play, puffer deflation, and the filter clearing muck. - 013/fish.ts: Canvas2D painters per species (CLOWN, TANG, IDOL, PUFFER), `ART` fin outlines, BODY_W/BODY_H/PEDUNCLE_X. Uses `seeded` from `lib/rng.ts`. - 013/food.ts: `flakeCanvas(colour, variant)`, the seeded painted flakes (3 colours × 4 variants). - 013/water.frag.ts: the background fragment shader as a default-exported GLSL string (uniforms uTime, uAspect, uCloud, uLight, uShell, uPixel). - 013/*.mp3: bubbler (loop), tap, shake, splash. ## Extending it - Run: `npm install && npm run dev`, open http://localhost:5173/013/ . Tests: `npm test`. Typecheck+build: `npm run build`. - Tuning knobs: the constants at the top of `tank.ts` (boid weights, CRUISE/MAX_SPEED, HUNGER_RATE, MUCK_PER_FLAKE, SHELL_PERIOD, FISH_COUNT and the species assignment in `create`) and at the top of `main.ts` (FISH_LEN, bubble rate, gains, LIGHT_SECONDS). - Some constants are duplicated and must stay in sync by hand. In tank.ts, `SURFACE` (0.09) and `GRAVEL` (0.86) are measured from the top, y down. In both shaders the same values appear as 0.91 and 0.14, measured y up. `SHELL_X` (0.4) appears in tank.ts and water.frag.ts. - tank.ts takes an injected `rng` so tests are deterministic. Keep DOM and pixi out of it. main.ts reads `tank.events` once per frame to trigger sounds and bubble bursts. - In the ANGLE renderer, GLSL const arrays fail to initialise. The shader uses lookup functions instead (`stagSeg`), so keep that pattern. - Audio rules: every load starts muted; the AudioContext is created on the first gesture or the sound gate; one splash plays at most every SPLASH_GAP. - There is no browser test for this page. Check visual changes by running it, or add a `page.test.ts` using `test/browser.ts` (see 014 or 015). - Conventions: keep pure simulation in its own module with a `node --test` file beside it; match the surrounding code style; Conventional Commits `type(013): message`.