Two universes joined by a tunnel. Each universe here is only a sky, a pattern painted infinitely far away, so everything strange you see is the tunnel bending light. Every pixel is a light ray traced through curved space, and it runs in real time because one slice of rays answers every pixel.
Start one dimension down. Take a funnel and glue its narrow end to the narrow end of a second funnel. An ant on that surface can walk down one funnel, through the ring where they meet, and out across the other. Far from the ring each funnel opens out almost flat, so to the ant there are two ordinary flat worlds with a hole connecting them.
The wormhole is that, one dimension up. Around the hole you can draw spheres, like the rings on the funnel. Moving inward, each sphere is smaller than the last, until you reach the smallest one, the throat. Keep going and the spheres grow again, but now you're in the other universe. Universe A is where you start; B is through the hole.
So two things say where you are: the distance ℓ along the tunnel (positive in
A, zero at the throat, negative in B) and a direction on the sphere. The shape comes entirely
from how big the sphere at distance ℓ is, its radius r(ℓ):
$$ ds^2 = d\ell^2 + r(\ell)^2\,(d\theta^2 + \sin^2\theta\, d\varphi^2) $$
Read it as: a step of dℓ along the tunnel is that long, and a step across the
sphere is as long as it would be on an ordinary sphere of radius r. This page
uses the r(ℓ) from the paper the Interstellar effects team wrote about
rendering their wormhole: a straight tube with radius throat radius and length
throat length, opening into flat space over a distance set by flare. The funnels
in these diagrams, and the small one in the corner while you fly, are drawn from it with your
current settings.
On a curved surface the straightest path is the one an ant walks if it never turns left or right. Light does the same in curved space. Here are rays leaving one spot on the funnel in every direction at once, all at the same speed, traced by the same code that moves you when you fly. Violet rays end up back in A; orange ones went through to B.
Rays aimed at the hole go through. Rays aimed off to the side bend around the throat and come back out into A heading somewhere new. A ray aimed exactly at the edge of the throat would circle it forever, and rays aimed close to that edge circle it a few times before escaping to one side or the other.
That funnel is a slice through the real space: the slice containing a ray and the center of the hole. The space looks the same in every direction around the hole, so a ray never leaves its slice, and every ray in 3D behaves like one of these.
Put your eye at that spot. Each pixel shows whatever part of the sky its ray ends up heading toward. Look at the hole and the rays go through and fan out across all of B, so the whole of B's sky is squeezed into a disk. Around the disk the rays bend back into A, so you see your own sky warped into rings, including the parts behind you. Rays that circled the throat make thinner and thinner copies packed against the edge of the disk.
The fat pinches where a line crosses a bright ring come from the bit of A's sky hidden directly behind the hole. Light from it can bend around the throat on any side, so that one point shows up as a whole circle, and a line passing through it gets stretched sideways there.
The accretion disk buttons put a flat ring of glowing gas around the throat, orange in A and blue in B, like the disks that circle real black holes. You see them the same way, by following rays. A ray's slice cuts a disk's plane along a line through the hole, so as the ray swings around the hole it passes through that plane once every half turn. The first pass is the disk where you'd expect it. A ray aimed a little above the hole bends around and passes through the plane again behind it, so you see the back of the disk arched over the top of the hole, and under the bottom too. That's the shape of Interstellar's black hole, and it comes from the same bending as everything else here.
To find those passes, each ray in the table below also records the angle around the hole at which it crosses each of 14 spheres spanning the disk, going in and coming out, in each universe. Every pixel walks its ray's crossings in order and checks where the angle passes through its own slice's half-turn marks.
Tracing a curved path for each of a few million pixels every frame would be slow. But a
ray's fate depends on only two numbers: where you are along the tunnel (ℓ), and
the angle between the ray and the direction straight away from the hole. The rest is which
way round its slice faces, and turning a slice around doesn't change what happens in it.
So each frame the GPU traces 4096 rays at your ℓ, at angles from straight away
from the hole to straight at it, packed tightest near the edge of the throat where the answer
changes fastest. It steps each one until it's far enough out that space is flat again, and
stores which universe the ray ended in and which way it was heading. Then every pixel works
out its own angle, looks up the nearest rays in that table, and turns the answer back into
its own slice. This chart is that table, read back from the GPU while a camera moves in and
out:
The skies are formulas of a direction (its latitude and longitude, which face of a solid it points at) rather than images, so they stay sharp however much the throat magnifies them.
You move by the same rule as light. Let go of the keys and you coast along the straightest path, which can curve you around the hole. Your view turns with the space as you go, so flying straight through the middle from the starting spot, B's sky comes out upright. Loop close around the hole and you come back rolled a little: carry an arrow around a loop on a curved surface, never turning it, and it comes back pointing somewhere else. Q and E roll you back.
Made after optozorax's video What would a wormhole look like in real life? The wormhole's shape is from James, von Tunzelmann, Franklin and Thorne, Visualizing Interstellar's Wormhole (2015).