// the find
miloyip/light2d
Light rendering in 2D
A teaching project by miloyip (author of the RapidJSON and nativejson-benchmark projects) that implements 2D global illumination from scratch in plain C. Each source file is a self-contained lesson — basic ray marching, then CSG, then reflection, refraction, Fresnel equations, Beer-Lambert absorption. Aimed at developers who want to understand the physics of light transport without drowning in a full 3D renderer.
Each concept gets its own standalone .c file with no shared library to untangle — you can read basic.c in an afternoon and actually understand every line. The progression from uniform sampling to stratified to jittered sampling is shown visually side-by-side, which is more useful than most textbook explanations. Covers a surprising amount of optical physics for a flat-file repo: SDF-based CSG, Snell's law with total internal reflection, and Fresnel reflectance for dielectrics. Public domain license means you can paste any of it anywhere without legal hesitation.
The repo is effectively archived — last commit was January 2022 and it has no issues or PRs open, so don't expect help if something is unclear. The README is mostly images with almost no prose explanation; the code comments do the teaching, which means you must read the C to understand anything. No build system beyond a bare makefile, and no output beyond PNG files, so integrating any of this into a live renderer requires you to do all the plumbing yourself. The 2D constraint is intentional but also limits applicability — the SDF and sampling techniques transfer to 3D, but the specific rendering loop does not.