smallpt: A physically based ray tracer in just 99 lines of C++

blaizedsouza · x · 2026-09-17

Kevin Beason's smallpt implements a physically based ray tracer in just 99 lines of C++. The whole renderer boils down to vectors, rays, spheres, and a recursive radiance() function, tracing light with reflections, refractions, soft shadows, and color bleeding. It can render a Cornell box with mirror and glass spheres using thousands of samples per pixel — a classic minimal read for understanding ray tracing fundamentals.

Original post →

More from coding & agent

coding & agent channel →