Black Holes Are Buggy

October 5, 2026 · webgl · shaders

The thin rings on my black hole page are a known graphics bug: the disk spins at different speeds at different distances, which smears its pattern into ultra-thin rings within minutes. Every graphics programmer treats this as a bug to fix. I decided it looks awesome, so I kept it on purpose. In real life it wouldn't look like this at all: a real disk is streaky, churned-up gas spiraling around the hole, not neat grooves. Here's everything I learned building it.

Ergosphere: the live black hole

A black hole you can orbit, with the animated ringed disk. Pinch to zoom. Open it on your phone.

Open the black hole →

1. The bug

Jonas Javier wrote it up while building his own black hole for the web: give the disk realistic spin and "within minutes the disk turned into concentric rings thinner than a pixel." The inner part of the disk orbits faster than the outer part, so any pattern on it gets stretched into thinner and thinner streaks until they blur into perfect rings. Graphics programmers add extra code specifically to kill this. I kept it in, and I'll tell you why.

A blotchy disk pattern winding into thin concentric rings as the inner part orbits faster than the outer part
Watch the inner disk lap the outer, stretching the pattern into thinner and thinner streaks until they blur into rings.

Real science pictures don't look like this either. NASA's famous black hole renders show the gas churned into spiral light-and-dark lanes: streaky, not grooved. The black hole in Interstellar is smooth, fading from hot to cool colors. The vinyl-record look is pure style. Which is exactly why it belongs on my page.

NASA scientific visualization of a black hole: churned spiral lanes of gas around a black shadow, brighter on one side
What it's actually supposed to look like: NASA's scientific visualization shows churned spiral lanes, not neat grooves. Interstellar's Gargantua went the other way: smooth, fading from hot to cool. Image: NASA's Goddard Space Flight Center / Jeremy Schnittman (public domain).

2. How the disk actually moves

The one thing worth getting right is the spin. A real black hole disk doesn't spin like a record. The inner edge orbits way faster than the outer edge. There's a physics rule (Kepler's third law) that says orbit speed drops off as r^(-3/2), so the code draws the disk's pattern in coordinates that spin along with the gas itself:

Side by side: a record spinning as one rigid piece versus a black hole disk with the inner markers orbiting faster than the outer ones
Left: a record, spinning as one piece. Right: a black hole disk, where the inner edge orbits way faster than the outer edge.
// Where to look up the pattern: this pixel's angle, minus how far its ring has spun
angle = atan(z, x) - t * OMEGA(r)
// How fast each ring spins: inner rings lap the outer ones (Kepler's rule)
OMEGA(r) = OMEGA_IN * (rIn / r)^1.5

Each ring of the disk effectively has its own clock. The pattern is also stretched so it keeps the same look at every distance, from the blazing inner edge to the faint outer edge. Get this wrong and the disk looks like a spinning sticker; get it right and it feels like orbiting gas even before you add any detail. Nobody wants a spinning sticker. Stickers are for water bottles and the back of laptops.

One catch: perfectly round bands can't show spin at all. They look the same from every angle by design. So the disk also has bright knots and spiral streaks that move with the spinning gas. Those are what your eye actually follows as the inner disk laps the outer.

Two disks side by side, both rotating: the left has plain rings and looks frozen, the right has bright knots that make the spin obvious
Rings alone can't show spin: the left disk is rotating, but you'd never know it. Add bright knots that ride the gas, and the motion reads instantly.

3. The trick that keeps it spinning forever

You can't just let t * OMEGA(r) grow forever. The uneven spin keeps piling up and the rings melt into blurry mush: exactly Javier's bug. The fix, found independently by several graphics programmers:

Animated chart of two crossfading sine-squared weight curves over one 20 second cycle, with a sweeping time cursor
Two copies of the disk, half a cycle apart. The weights crossfade on sine-squared curves, and each layer hits exactly zero when its own clock resets.

Total twist never builds up past one 20-second cycle, so the bands stay crisp forever. A separate shimmer layer runs on the real clock (not each layer's own clock), which glues the two layers together during the fade instead of showing the seam.

4. The step bug that deleted the sky

The nastiest bug in the whole build wasn't in how things looked. It was in the structure. The renderer draws the scene by walking light rays forward in fixed steps (dt = 0.14), 96 steps max, covering about 13 units. But the default camera sits 20+ units out. Rays aimed above the shadow ran out of steps while looping around the photon sphere (the zone where light itself orbits the hole). Never caught, never crossing the disk, just giving up. The arcs of bent light above the shadow, the signature Interstellar look, were never drawn at all. My black hole had a blind spot exactly where its best feature should be. The disk looked like a separate lump floating under the shadow.

Diagram: with fixed steps the ray's evenly spaced dots run out halfway around the black hole; with adaptive steps the dots finish the trip
Fixed steps run out of road before the ray finishes its trip. Adaptive steps take big strides far away and tiny steps near the hole, so every ray finishes.

The fix is steps that adapt: dt = clamp(0.09 * r, 0.035, 0.9). Long strides cover the empty far regions where gravity barely matters; tiny steps handle the intense light-bending near the hole. Same number of steps, but now the bent rays finish their journey, and the arcs appeared. Lesson: when your lighting looks wrong, check whether your rays are even finishing the trip.

5. The hidden seam in the texture

There was a sharp diagonal seam across the disk where fine rings suddenly met coarse marbling. Root cause: atan's branch cut. atan measures angles, and it jumps from +180° back to -180° along one line. Any angle multiplier that isn't a whole number (a * 2.2, a * 3.4…) makes the pattern jump at that line, and the line shows up on screen as a diagonal. The fix: build all the angular pattern from smooth looping coordinates, vec2(cos(a), sin(a)), which glide around the full circle with no jump, and keep spiral tilts at whole numbers. If your generated texture has a mysterious straight seam, check your angle math for jumps like this.

Two disks: the left shows a sharp diagonal seam where the angle math jumps, the right is smooth with no seam
Left: a jump in the angle math draws a visible seam across the disk (highlighted). Right: smooth (cos, sin) coordinates, no seam.

6. Making it look hot

Motion does half the work; light does the other half:

7. What the math gives you for free

The photon ring and the arcs of disk bent above and below the shadow aren't drawn on anywhere. They come straight out of the light-bending math itself. Trace the rays through curved spacetime and the lensing just shows up. That's the best kind of graphics programming: you build the physics and the beauty is a side effect.

What I stole and from where

The bigger lesson: sometimes the bug is the look. The difference between a bug and a style is whether you understand it well enough to control it. Bugs you understand are called features. Bugs you understand and like are called style.