Raycasting is a rendering technique that creates the illusion of a 3D environment from a 2D map. Instead of fully modelling a three-dimensional scene, the engine casts one horizontal ray per column of pixels and measures how far it travels before hitting a wall. Closer walls appear taller on screen; distant walls appear shorter. The result is a convincing pseudo-3D perspective from a top-down grid map.
The technique was pioneered in commercial games by John Carmack at id Software. Wolfenstein 3D (1992) was the first mainstream game to use it, followed by DOOM (1993), which added floor/ceiling height variation and made the technique a cultural phenomenon. Carmack later described raycasting as a "hack" — technically incorrect 3D — but acknowledged that the perceptual result was compelling enough to define an era.
A key insight in Carmack's implementation was the use of the Digital Differential Analyzer (DDA) algorithm, which efficiently calculates ray-wall intersections without testing every cell in a grid. This allowed DOOM to run in real-time on 1993 consumer hardware (486 processors) that had no dedicated graphics acceleration.
This browser implementation uses the same DDA algorithm running in JavaScript. The map is a hand-crafted corridor with textured walls. Move through it using WASD or arrow keys and observe the perspective calculation updating in real-time — the same calculation that powered one of the most influential games in history, now running at 60fps in a browser tab.
Why Raycasting Matters in Computer Graphics History
- It demonstrated that 3D gameplay was possible on consumer hardware a decade before dedicated 3D GPUs became standard.
- The DOOM source code was released in 1997 and inspired thousands of programmers to learn graphics programming through reverse-engineering it.
- The DDA algorithm used in raycasting is still taught in computer graphics courses as an example of efficient grid traversal.
- Raycasting inspired a generation of modders who created total conversion modifications, eventually spawning Half-Life, Counter-Strike, and the modern FPS genre.