How Raycasting Shaped 3D Graphics and Gaming History

When we think about modern 3D graphics, we imagine sleek engines powered by advanced GPUs. But before hardware acceleration and polygon-based rendering took over, there was raycasting: a clever technique that made immersive 3D worlds possible on limited hardware.

In a recent talk, our Lead Software Engineer, Robert, took us on a journey through the fundamentals of raycasting, the maths behind it, its historical role in gaming, and some intriguing personal projects that push the boundaries of what raycasting can do.

What is Raycasting?

At its core, raycasting is the process of casting rays from an origin point in a certain direction to detect intersections with objects in a scene. Mathematically:

  • A line extends infinitely in both directions.
  • A line segment has a defined start and end point.
  • A ray has an origin and a direction vector, continuing infinitely in that direction.

By solving for the intersection between a ray and an object (often simplified as line segments in 2D), you can determine where the ray hits and how far it travels before colliding. This distance is critical for rendering, as it defines which surfaces are visible to the player and at what depth.

The Role of Trigonometry

Raycasting is not just about straight lines – trigonometry plays a vital role. The direction of each ray is calculated using sine and cosine functions based on the player’s viewing angle. This allows rotation, perspective, and the simulation of a field of vision, giving flat maps a three-dimensional feel when projected on screen.

The Grid and Efficiency

Early raycasting engines relied on grid-based maps. Levels were divided into squares, making collision detection more efficient: instead of calculating endless intersections, the engine only needed to check which grid cell a ray entered.

To speed things up, programmers adapted techniques like the Bresenham line algorithm – an efficient way of drawing lines without costly division operations. This efficiency was crucial in the early 1990s, when hardware was extremely limited.

Raycasting in Early Games

The talk showcased several pioneering titles that popularised raycasting:

  • Ken’s Labyrinth – an early example of grid-based raycasting.
  • Wolfenstein 3D – ID Software’s landmark title that defined the genre.
  • Duke Nukem 3D and Rise of the Triad – adding textured floors, ceilings, skyboxes, and more advanced animations.
  • Descent – pushing beyond raycasting into six degrees of freedom.

These games proved that raycasting could deliver fast, immersive visuals and laid the foundation for the FPS genre.

Quirky Experiment: SQL Raycasting

One of the more surprising examples was a raycasting engine written entirely as a SQL query. Running at about 30 frames per second, it recursively steps rays forward until they hit a wall, outputting the result as a table. Despite bugs and limitations, it is a testament to how flexible and minimal raycasting can be – even outside traditional programming environments.

Personal Projects and Creative Applications

Watch the video below to see several of Robert’s personal projects, showcasing how raycasting principles extend far beyond retro gaming:

  • A 2D raycasting game built in WinForms.
  • A radial raycaster for height maps.
  • A 3D engine with six degrees of freedom, coded in C# with raw memory manipulation.
  • VoxLab – a voxel-based destructible terrain game with procedural cave generation and physics.
  • A CMOS circuit simulator visualising CPU adder circuits.
  • A DNA programming puzzle game teaching computational logic through string manipulation.

Each of these projects reflects how raycasting’s simplicity and adaptability still inspire experimentation today.

From Raycasting to Modern 3D

While raycasting was a breakthrough in its time, the arrival of dedicated graphics cards shifted the industry towards polygon-based rendering. Modern GPUs can handle millions of triangles per second, making raycasting largely obsolete in mainstream gaming. Yet, its principles remain valuable – both for understanding the evolution of graphics and for niche projects where efficiency and simplicity matter.

Conclusion

Raycasting may seem like a relic of the past, but it continues to inspire developers, hobbyists, and educators alike. Whether through retro games, experimental engines, or creative simulations, it demonstrates how powerful simple mathematical ideas can be when applied cleverly.

Watch the full presentation here:

Share the Post:

Related Posts