HomeArticlesRendering

Warp Speed Starfield: The Maths Behind Stars Streaking Past

Thousands of stars streak radially outward as you jump to light speed - how perspective projection, particle recycling and motion trails build the classic sci-fi effect.

mysimulator teamUpdated June 2026≈ 6 min read▶ Open the simulation

A cloud of points moving toward the camera

The scene behind a warp-speed effect is simple to describe: a few thousand points scattered randomly through a long 3D tunnel, each one carrying only a position and a constant forward velocity. Every frame, every star's depth coordinate (its distance from the camera along the view direction) decreases by velocity times the elapsed time, exactly like walking toward a scattering of fixed lampposts on a foggy road. There is no gravity, no collision, no interaction between stars at all - the entire visual complexity of the effect comes from how those simple straight-line 3D motions get flattened onto a 2D screen.

live demo · a starfield radiating outward from the centre● LIVE

Perspective projection: why edges move faster than the centre

A pinhole-camera model maps a 3D point (x, y, z) to a 2D screen point by dividing the sideways coordinates by depth:

screenX = focalLength * x / z
screenY = focalLength * y / z

As z shrinks toward zero, that division blows up, so a star's projected position accelerates away from the screen's centre the closer it gets to the camera - slowly at first while it is far away, then in a sudden, fast sweep to the edge of the frame right before it passes. A star that starts almost dead ahead has a tiny x and y to begin with, so however small its z gets, its projected position barely moves; a star that starts off-centre has more x and y to divide by a shrinking z, and its projected path is long and fast. That is the entire geometric reason the effect looks like it is radiating outward from a vanishing point at the centre of the screen.

Streaks: turning a point into a line

A single projected point moving fast enough between frames would look like it is skipping across the screen rather than streaking. The visual trick is to draw each star not as a dot but as a short line segment from its projected position last frame to its projected position this frame, stretched further the faster it is currently moving - which, combined with the perspective effect above, naturally makes stars near the edges draw long, fast streaks and stars near the centre stay almost pointlike, matching the way headlights blur past a car window at speed.

Recycling the particle pool

Once a star's depth passes the camera or falls outside the visible cone (the view frustum), it needs to disappear and a new one needs to take its place, but allocating and freeing thousands of objects every second would strain the garbage collector and stall the frame rate. Instead the simulation keeps a fixed-size array of stars and, whenever one expires, simply respawns it in place at a random position far down the tunnel - the same trick used by every particle system, from rain to fireworks to this site's own boids flock, and the reason the star count and the frame rate both stay rock steady no matter how long you watch.

How close is this to relativity?

Not very, and it is worth being honest about that. Real travel at a sizeable fraction of light speed would cause relativistic aberration, where the apparent positions of stars compress into a bright ring ahead of you rather than radiating outward from the centre, plus a strong blueshift ahead and redshift behind from the relativistic Doppler effect. The radiating-streak look is a visual shorthand borrowed from decades of science fiction, not a physically accurate rendering of what near-light-speed travel would actually look like - but the underlying projection maths is entirely real, and it is the same maths any 3D engine uses to put anything at all on your screen.

Frequently asked questions

Is the warp-speed starfield effect based on real physics?

Only loosely. The rendering technique, perspective projection of points moving toward the camera, is accurate optics. But real relativistic travel near light speed would compress the field of stars toward the direction of travel and shift their colour (relativistic aberration and Doppler shift), not simply streak them into lines radiating from the centre of the screen. The streaking look is a visual convention from science fiction more than a simulation of special relativity.

Why do stars near the centre of the screen move slower than stars near the edge?

Every star moves toward the camera at the same speed in 3D, but perspective projection maps 3D position to a 2D screen point by dividing by depth. A star nearly dead ahead has almost no sideways position to begin with, so its projected point barely moves even as it rushes closer, while a star off to the side sweeps a large angle across the field of view and its projected streak is long and fast.

Why does a star suddenly reset instead of just disappearing?

Once a star passes the camera, its depth becomes zero or negative and the perspective projection breaks down or the point leaves the visible frustum entirely. Rather than removing it from memory and allocating a new one, the simulation reuses the same particle slot by respawning it far away with a fresh random position, which is far cheaper than constant allocation and keeps the star count and frame rate constant.

Try it live

Everything above runs in your browser - open Warp Speed Starfield and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Warp Speed Starfield simulation

What did you find?

Add reproduction steps (optional)