Raymarching & SDF

Version 1 of 4

CPU sphere tracing.

PC · CPU · like Slisesix · 2008

This version

The same idea as on a GPU, in JavaScript at 128 pixels wide: two balls melting together with smooth min, a torus, soft shadows from distance probes.

How this version works

JavaScript renders a pixel buffer 128 pixels wide from a fixed camera, taking up to 64 distance steps per ray. Two moving spheres are smoothly blended with each other and a torus, then joined to a flat floor using a minimum. Six nearby distance samples give the surface normal, while up to 18 probes towards the light estimate soft shadows. Coral-coloured objects sit on a grey-brown chequered floor, with diffuse lighting and exponential fog; missed rays receive a dark purple background.

The trick in this version

The low rendering resolution limits the cost of running all ray and shadow loops on the CPU. The scene is evaluated from mathematical functions rather than stored as a mesh, and distance-sized steps skip empty space.

Historical context · PC

  1. 2008 · iq / RGBA

    Slisesix

    First in 4K procedural graphics at Euskal Encounter 16: one function returning the distance to the closest surface, no rasteriser, an executable still image.

Platform
PC · CPU · like Slisesix
Era
PC
Rendered on
CPU
Tags
SDF · smooth min
Sources
Slisesix (2008)