Get the latest tech news

Painting with Math: A Gentle Study of Raymarching (2023)


A compilation of my Raymarching and Signed Distance Field learnings and work. In it, I teach you how to leverage those techniques along with lighting models, smoothmin, soft shadows, and some math to create beautiful 3D raymarched scenes ranging from abstract shapes to infinite realistic-looking landscapes.

Raymarching consists of marching step-by-step alongside rays cast from an origin point(a camera, the observer's eye, ...) through each pixel of an output image until they intersect with objects in the scene within a set maximum number of steps. Diagram representing the position of a theoretical sphere and our ray origin in relation to the center of the scene.Our raymarch function will loop for up to MAX_STEPS until we reach the step limit, in which case we'll draw nothing or hit the surface of the shape defined by our SDF. On top of all that, the file containing the code bringing those worlds to life only weighs a couple of kilobytes,~5kB the last time I checked for the Martian landscape excluding the texture which is itself 10x bigger already but it can technically be replaced by a hash function so I'm not counting it in.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of math

math

Photo of raymarching

raymarching

Photo of gentle study

gentle study

Related news:

News photo

As a programmer, get your math sorted

News photo

DeepMind claims its newest AI tool is a whiz at math and science problems

News photo

DeepSeek upgrades its math-focused AI model Prover