Black hole lab
An interactive black-hole renderer with three render modes and live controls
The black hole lab is an interactive black-hole renderer that runs right in the browser: three render modes, twenty-four presets, and a live control panel. Drag blank space to orbit, scroll to zoom. It prefers WebGPU and falls back to WebGL2 (add ?webgl to the URL to force the fallback).
It began life as an animated background for this site. Rendering a black hole behind every page turned out to be a lot to ask of my current graphics card, so that version is parked until a GPU upgrade, and the renderer survived as its own page instead.
Three ways to draw a black hole
Raytraced is adapted from dgreenheck’s MIT-licensed webgpu-black-hole project and is the known-good baseline: a Schwarzschild-radius capture region, iterative gravitational bending, exact disk-plane intersection, blackbody temperature lookup with radial falloff, Doppler beaming, Keplerian flow, and cyclic FBM turbulence so the animation never visibly resets.
Singularity is a port of MisterPrada’s volume shader: a spherical raymarched volume with explicit ray-sphere entry and exit, two noise samples per step, quadratic vertical-band shaping, a B-spline color ramp across the source’s three colors, and front-to-back alpha compositing. (The source repo has no formal license file; MisterPrada authorized use here with attribution, which lives in the repo’s third-party notices and the site footer.)
Particle is the experimental one: up to 30,000 GPU particles rendered into an offscreen density texture, with radial distribution, differential rotation, jitter, and optional inflow, which the lensed disk shader then samples at its bent intersection. It also brings its own sky, an octahedral spherical star generator sampled after gravitational bending, so the black hole lenses a persistent starfield instead of a screen-space hash. It’s the least finished of the three, which is what the lab is for.
Presets and controls
The control panel exposes the full catalog: camera, physical black-hole parameters, disk, sky, bloom, and per-mode settings, all applied live. Twenty-four starting presets cover light and dark variants, edits persist per preset, and the whole state exports and imports as JSON. Output runs through sRGB plus ACES filmic tone mapping with hardware antialiasing.
There’s also a small automation hook: the page exposes window.__blackHole, so a browser agent (or a curious human in the console) can read the current config, apply presets, and drive the same update path as the controls.
The site background that started it
The original plan was a black hole behind every page here: transparent canvas composited with the page, a configurable reading veil between the visualization and the article text, a light-mode treatment that inverts the render into a white hole, and pauses for hidden tabs and reduced-motion settings. All of that machinery stays in the repo (BlackHoleBackground.astro and friends), just unmounted from the page layout.
When the GPU shows up, the plan is to pick one of the three renderers as the site default, finish the particle disk, and tune light mode and mobile after the dark desktop render is settled. Until then, the lab is the place to play with it.