Gargantua · How it works
Nothing in the simulation is drawn by hand. Every pixel is a ray of light traced backwards through the curved spacetime of a spinning black hole, with the same equations the visual effects team of Interstellar used, live, in your browser.
01 · The spacetime
A spinning black hole is described exactly by one solution of Einstein's equations, found by Roy Kerr in 1963. It has two numbers: the mass M and the spin a (0 = not spinning, 1 = the fastest possible). Distances are measured in M: for Gargantua, 100 million times the Sun's mass, 1 M is about 150 million km, the distance from the Earth to the Sun. The film's Gargantua spins at a = 0.6.
The usual way of writing the solution (Boyer–Lindquist coordinates) breaks at the horizon: numbers blow up to infinity right where things get interesting, which is why most renderers stop there. This one uses the Kerr–Schild form in plain x, y, z coordinates, which stays smooth through both horizons, so the same code renders the outside, the crossing and the inside:
gμν = ημν + f lμ lν, f = 2Mr³ / (r⁴ + a²z²)
η is flat space and l a light-like direction. A bonus of this form: its inverse is exact and cheap, gμν = ημν − f lμ lν, so no matrix has to be inverted at every step.
02 · Light
Light moves along the straightest possible paths through curved spacetime (null geodesics). For each pixel the simulation starts a ray at the camera and runs it backwards in time until it hits the disk, falls into the hole, or escapes to the stars. The ray obeys Hamilton's equations:
H = ½ gμν pμ pν = 0, dx/dλ = ∂H/∂p, dp/dλ = −∂H/∂x
03 · The camera
The camera is placed the way the film's was: it rides with the local "non-rotating" observer (a ZAMO, Bardeen 1972), whose frame is built from the metric itself. When you fly, that frame is Lorentz-boosted by your speed, so the sky squeezes ahead of you exactly as special relativity says (aberration; tested).
The readout "1 h here = … on Earth" is that observer's clock against a clock far away: gravity (the lapse α) and speed (γ) together. Miller's planet in the film, where an hour is seven years, would need a spin within a hair of the maximum (Thorne, The Science of Interstellar); the trip stops there to show it.
04 · The disk
The disk is thin gas orbiting between the last stable orbit (inside it, gas can't stay in orbit) and its outer edge, each ring at its own orbital speed, Ω = 1 / (r3/2 + a). Its colour is a real blackbody temperature turned into screen colour through the human eye's colour response (Planck × CIE 1931).
In reality the gas moving towards you would look bluer and far brighter, and the side moving away dimmer and redder: its light is shifted by g = 1 / (ut (E − Ω L)), Doppler and gravity together, and its brightness by g⁴. The film left that out, so audiences wouldn't be confused (James et al. 2015). The simulation shows the film's choice; the real one is computed too:
05 · The sky
The Milky Way is NASA's map of the real sky (Deep Star Maps 2020, from the Gaia satellite). Near the hole, lensing stretches it enormously, so each pixel works out how much sky it covers (ray differentials) and reads the image at that size. Stars are drawn as sharp points where lensing puts them, brightened by exactly how much lensing magnifies them, so their light is conserved. The thin bright ring hugging the shadow is light that circled the hole once or more; there, each pixel traces 16 rays instead of one (the film's "ray bundles", in real time).
06 · Falling in
When the engine switches off, nothing is scripted: the camera follows its own free-fall path (a timelike geodesic in proper time), through the event horizon and down to the inner horizon. Looking back, the light from outside is redshifted straight behind you and blueshifted 2–8× in a bright rim around that view, as measured along the rays.
The fall ends at the inner horizon on purpose. In the ideal solution space goes on, but in a real black hole matter falling in at different times streams through itself there at almost the speed of light and its energy grows without limit ("mass inflation", Poisson & Israel 1990; Hamilton & Avelino 2010). What happens next needs a theory of quantum gravity, which nobody has yet, so the simulation stops rather than make it up.
07 · Real time
A full picture is about a million rays of up to 1,200 steps each. The trick is to trace only when the camera moves: the results are kept (where each ray hit the disk, where it reached the sky) and every frame only recolours them, so the disk turns and the picture stays smooth for free. While you move, rays are traced at a lower resolution, sized by the graphics card's own timers to hold the frame rate; when you stop, the full picture is traced in bands over a few frames. Edges and the photon ring are re-traced at screen resolution, and only those pixels: a stencil mask packs them together so the rest of the screen doesn't wait on them.
| Scene (1600×900, Chrome, integrated AMD Radeon graphics) | Frames per second |
|---|---|
| Standing still, picture sharp | 60+ |
| Flying at 12 M (film spin) | 41–57 |
| The trip (film spin) | 39–56 |
| Fast spin 0.999, inside the photon shell, moving | 17–53 |
| Falling through the horizon | 37–46 |
| From a stop to a sharp picture | ~1 s |
08 · Checked
The physics lives in one JavaScript file shared by the page and an automated test suite (90 tests in the site's repository, run on every change). The graphics card runs the same equations; the tests compare it with a precise 64-bit integrator.
| What | Simulation | Exact / reference |
|---|---|---|
| Shadow of a non-spinning hole | 5.19615 M | √27 M = 5.19615 |
| Shadow edges, a = 0.6 | 3.83849, 6.31565 M | 3.83850, 6.31568 (Bardeen 1973) |
| Shadow on screen at 30 M | ~370 px | 369 px (formula) |
| Horizons, last stable orbit, photon orbits | match | Bardeen, Press & Teukolsky 1972 |
| Energy, angular momentum, Carter constant along rays | conserved | Carter 1968 |
| Rays judged "falls in" early | 1,877 of 1,877 right | precise integrator |
| Free fall from 6 M, no spin | within 0.002 M | exact cycloid |
| Shrinking of the shadow when flying at it | match | special-relativity aberration |
| Disk light shift, face-on, no spin | √(1 − 3/r) | time dilation + gravity |
| Wormhole: rays that go through | exactly those with b < ρ | turning point r = b |
09 · The wormhole
The film's wormhole near Saturn has its own paper (James, von Tunzelmann, Franklin & Thorne 2015), written so students could render it. Its shape has three numbers: the throat's radius ρ (1 km in the film), the length of its short tunnel (1% of ρ) and its lensing width, how gradually space flares out from the throat (5% of ρ: a sharp edge):
ds² = −dt² + dℓ² + r(ℓ)² (dθ² + sin²θ dφ²), r = ρ + M [x arctan x − ½ ln(1 + x²)]
Because the wormhole is a perfect sphere, every ray stays in one flat plane and depends on just one angle: the angle between the pixel's direction and the throat. So instead of tracing a ray per pixel, the graphics card traces 2,048 rays per frame, one per angle, and every pixel looks its answer up. That is why the wormhole runs at over 100 frames per second, even on modest devices. Rays aimed inside the edge (impact parameter under ρ, exactly) come out in the other galaxy; those just outside wrap around the throat and show the sky behind it, stretched into a ring.
Sources