Visualizations
201 / 500

201 · Physics

Near Light Speed

Drive a city street near light speed and see what relativity really does to the view.

Light here is slowed to 40 meters per second, so driving speeds become relativistic, and every pixel is ray traced through a procedural city with sun shadows. Each ray is first aberrated: light reaching your eye from one direction left the city from a direction farther back, which pulls the whole world into a tunnel ahead and makes the painted cubes you pass look rotated, showing their far faces, instead of squashed (Terrell rotation). The city is at rest, so the ray is traced in the city's own frame from where you are at the instant you see it. Then its color is Doppler shifted: every surface is treated as a spectrum, sunlight times a reflectance whose red and blue bands run on into the infrared and ultraviolet, shifted by the Doppler factor and integrated against the eye's color matching curves, so the road ahead turns blue-white while the sides fade through yellow and red to black. The searchlight effect, which brightens the view ahead by the fourth power of the Doppler factor, can be switched on too.

Try it. Drag the throttle or press Up and Down to change speed, and drag the view or press Left and Right to look around. Toggle aberration, Doppler shift, the searchlight effect and a split view that compares the naive picture with the real one (or press 1 to 4). Space jumps between cruising and 90% of light speed.

  • Relativistic aberration
  • Spectral Doppler shift
  • Grid ray tracing

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a "what you would see near light speed" renderer with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window. Ray trace into a small offscreen canvas (about 240 pixels wide) and draw it scaled up.
- Build a scene that is cheap to intersect: a checkered ground plane, a sky gradient, and colored cubes along both sides of a road, each face a different color. The camera sits on the road at eye height.
- Add a speed slider for beta = v / c from 0 to 0.99, and move the camera forward over time.
- For each pixel, make the ray direction d' in the camera's frame, then aberrate it into the scene's frame (the scene is at rest, the camera moves along +z): d_z = (d'_z - beta) / (1 - beta d'_z), and multiply d_x and d_y by 1 / (gamma (1 - beta d'_z)). Trace that ray from the camera. At high speed the world squeezes into a tunnel ahead, and passing cubes appear rotated.
- Add a key that toggles aberration so the difference is obvious.

Once that works, make it beautiful:
- Doppler shift: light along d' arrives with factor D = 1 / (gamma (1 - beta d'_z)). Start by shifting hue toward blue when D > 1 and toward red when D < 1, then upgrade to treating each color as a spectrum and shifting its wavelengths.
- Optionally scale brightness by D^4 for the searchlight effect, with an auto exposure.
- Turn the cubes into a little city of boxes with window patterns, and add a split view comparing the naive picture with the relativistic one.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as sun shadows, a grid traversal for a large city, or moving objects traced at the retarded time.
PreviousSelf Healing CodeScratch, smudge and tear a printed barcode while Reed-Solomon algebra repairs it live. NextMiura FoldMiura-ori, Yoshimura and waterbomb sheets fold with exact rigid-origami kinematics.

Related visualizations

  • MiragePhysics Bent light over hot asphalt and cold sea: road puddles, floating cars, Fata Morgana.
  • Radiating ChargePhysics Shake an electric charge and watch light peel off its field lines at c.
  • Light & ShadowPhysics Red, green and blue lights cast crisp, colored shadows through spinning shapes.
  • Path Tracer3D Photorealistic light, computed by bouncing millions of random rays.
  • Pseudo 3D RoadRetro A sunset coastal highway faked the 80s arcade way, from flat segments and sprites.
  • Procedural CityGenerative art An isometric city that builds itself and runs through day and night.
  • WormholeAstronomy Fly through a traversable wormhole into another universe, with real light bending.
  • Rainbow OpticsPhysics A double rainbow, dark band and fogbow computed from Snell's law and wave optics.
  • Sky MachinePhysics Drag the sun and watch real Rayleigh and Mie scattering paint the sky.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs