A camera does something that computer graphics has copied for decades: it only focuses on one slice of the world. Everything nearer or farther goes soft. That effect, depth of field, is the star of this demo. The scene is a field of drifting low-poly crystals, and the soft background lights behind them are not soft dots. They are soft discs, rendered exactly the way a lens renders them.
Why a Lens Blurs at All
A lens bends light toward one flat plane. Only objects at the right distance land there in sharp focus. A point nearer or farther never lands as a point. Instead it lands as a small disc of light, and that disc grows the further it sits from focus. Photographers call it the circle of confusion. When the discs get big enough, you see them as the round, glowing blobs in a night photo. That is bokeh, and it is depth of field made visible.
The beautiful part is that the blur carries no information. A blurry background point is just a disc of its own color. So a program can draw that physics honestly, at almost no cost. Once you see it written as three lines of shader math, you cannot unsee it in photographs either.
Depth of Field, Computed One Disc at a Time
The demo does precisely that. For every background light, the shader measures the distance from the camera. Then it subtracts the focus distance and takes the absolute value. That number is the diameter of the disc. Close to the focal plane, the disc is a pinpoint. Far from it, the disc spreads out and fades, because the same light now covers more area.
Then the shader adds the discs together, the way a camera sensor adds light. Because of this, overlapping blobs brighten honestly instead of stacking as flat sprites. First you notice the soft lights. Next you notice your eye keeps searching for the sharp ones, exactly like a photograph. The round shape is a deliberate choice too. A real lens throws whatever shape its aperture blades cut, but an ideal round opening stays the friendliest lie.
The Crystals Themselves
The foreground holds hand-cut low-poly solids. Each one tumbles slowly on its own axis, with a hand-written shading pipeline. Flat facets catch the light differently as they rotate, which gives the field its rhythm. When you drag to orbit, the focal plane stays put while the field swings through it. Watch a crystal drift from sharp to soft, and then back again. That transition is the whole point of the piece.
Try It Yourself
Click and drag to rotate the field. Scroll to move the camera, and the depth of field re-evaluates the entire scene each frame. In practice, park the camera close to one cluster and let the rest fall behind it. The far lights bloom into discs within a second. After a minute you will start judging real photos by how big their discs are. Consider that a hazard of the trade.
Where to Go Next
The technique comes straight from camera physics. So it pairs well with the rest of this series. See the volumetric nebula for a shader that fakes distance instead of a lens. Or hear the machines talk in a CRT boot sequence, rebuilt on a modern GPU. Reverse Engineering igloo.inc — A Deep Dive.
