Saturn

Version 1 — © 1996 Christian Cohnen

Arrow keys: fly · Q/E: altitude · Space: stop

A real-time voxel landscape renderer using the Floating Horizon Hidden Line Removal algorithm. The name Saturn is a direct reference to the famous Mars demo — written as a tribute and extension of that technique. Saturn demo originally written in Watcom C for DOS in 1996 but never released on a demo competition, transpiled to JavaScript/Canvas in 2026.

The demo renders an infinite procedurally generated heightmap terrain from a first-person perspective. Each vertical screen column is processed front-to-back: the renderer tracks a floating horizon (the highest visible screen Y seen so far) and only draws pixels that rise above it, implementing hidden surface removal without a Z-buffer.

Features

Parameters (SATURN_CFG)

NameTypeDescriptionDefault
seednumberRandom seed for procedural terrain generation1

Keyboard Controls

KeyAction
Arrow Up / DownFly forward / backward
Arrow Left / RightTurn left / right
Q / PageUpIncrease view height
E / PageDownDecrease view height
SpaceStop & reset view

Code Example

<canvas id="game" width="320" height="200"></canvas>
<script>var SATURN_CFG = { seed: 42 };</script>
<script src="saturn.min.js"></script>

Algorithm

The Floating Horizon algorithm processes each screen column independently. For each column, the renderer casts a ray outward from the camera at the appropriate angle. At each depth step (radius), it projects the terrain height to a screen Y coordinate. If this Y is above the current floating horizon (the minimum Y seen so far for this column), the vertical span from the new Y to the old horizon is filled with a Gouraud-shaded color, and the horizon is updated. This eliminates hidden surfaces without any per-pixel depth testing. The sky panorama fills from the horizon line up to the top of the screen.

Original Program

Originally written in Borland Turbo C for DOS (1996). The terrain is a procedural 256×256 heightmap, generated fresh each run using the diamond-square midpoint displacement algorithm with a “mars filter” pass for characteristic plateau-shaped terrain. Shadow casting bakes a directional light map at startup. The JavaScript port uses the authentic sky image and palette from SUNSET.PCX, embedded directly in the script. The rendering logic faithfully follows SATURN.C.