Deconstructing Voxel Space: The 2.5D Engine That Defined Early 90s Terrain

In 1992, the computing landscape was fundamentally different. CPUs were orders of magnitude slower than today's processors, and the concept of GPU acceleration was either non-existent or prohibitively expensive for the average consumer. Most 3D games of the era relied on the CPU to render flat, single-colored polygons, resulting in stark, angular environments.

Amidst this, NovaLogic released Comanche, a game that appeared years ahead of its time. It featured breathtakingly detailed mountains, valleys, and a sense of depth that felt revolutionary. The secret to this visual fidelity wasn't true 3D polygons, but a technique known as Voxel Space. While often conflated with modern volumetric pixels, the Voxel Space engine is essentially a 2.5D system that uses a clever combination of height maps and ray-casting principles to simulate a 3D world.

The Foundation: Height Maps and Color Maps

At its core, the Voxel Space engine avoids the complexity of calculating 3D geometry in real-time. Instead, it represents the terrain using two primary 2D arrays:

  1. Height Map: A grid (e.g., 1024x1024) where each byte represents the elevation of the terrain at that specific coordinate.
  2. Color Map: A corresponding grid of the same size that stores the color of the terrain at that point.

This approach imposes a significant constraint: the terrain can only have one height per position. This means complex structures like multi-story buildings, caves, or overhanging cliffs are impossible to represent. However, this limitation allows for an incredible optimization: the color map can have shading and shadows "baked in." Because the engine simply retrieves the color from the map rather than calculating illumination dynamically, the rendering process remains lightweight while still appearing visually rich.

The Rendering Algorithm

The Voxel Space engine operates by rasterizing these maps and drawing vertical lines on the screen. The basic process follows these steps:

  • Painter's Algorithm: To handle occlusion (ensuring distant objects don't overlap near ones), the engine renders from the back of the scene to the front.
  • Perspective Projection: The engine determines which line on the map corresponds to a specific optical distance from the observer, accounting for the field of view (FOV) so that distant objects appear smaller.
  • Rasterization: The line is segmented to match the screen's column width.
  • Vertical Line Drawing: For each segment, the engine retrieves the height and color from the maps, applies perspective projection to the height coordinate, and draws a vertical line.

Implementing Rotation

To allow the player to look in directions other than north, the engine incorporates trigonometric rotations. By calculating the sine and cosine of the viewing angle ($φ$), the engine can rotate the coordinates of the lines being sampled from the height and color maps, allowing for a full 360-degree view of the landscape.

Performance Optimizations

Given the hardware constraints of the early 90s, raw implementation wasn't enough. Several key optimizations were used to maintain a playable frame rate:

Front-to-Back Rendering and the Y-Buffer

While the Painter's Algorithm (back-to-front) is intuitive, it results in significant "overdraw," where the same pixel is colored multiple times. A more efficient approach is rendering from front to back. To prevent distant terrain from overwriting near terrain, a Y-buffer is used. This buffer stores the highest Y-position (the "top" of the terrain) already drawn for each column. New lines are only drawn if they are higher than the current value in the Y-buffer, effectively eliminating unnecessary drawing.

Level of Detail (LOD)

To further save cycles, the engine can implement Level of Detail. By increasing the step size ($dz$) as the distance from the camera increases, the engine renders fewer details in the distance while maintaining high precision in the foreground.

Technical Perspectives and Legacy

The Voxel Space technique sparked significant discussion among developers and enthusiasts. One common point of technical clarification is the distinction between this method and true voxels. As noted by community member @nine_k:

"Technically this is not related to voxels ('volumetric pixels', so to say), which split the 3D space equally along all three axes. This is just a height map, a set of prisms... Every prism has a regular fixed-size square base."

Despite its limitations, the influence of this approach extended beyond Comanche. Similar logic appeared in titles like Magic Carpet (1994) and influenced the 4k intro scene, such as MARS.EXE. The technique represents a golden era of "squeezing every last drop of performance" out of limited hardware, utilizing lookup tables and bit-shifting to bypass slow floating-point math on CPUs like the 80286.

Today, while we have the power to render millions of true polygons per second, the Voxel Space engine remains a masterclass in algorithmic efficiency and the art of the visual approximation.

Sources