← builds / bragg

bragg

a Bragg mirror is a stack of alternating thin layers — high index, low index, high again — each a quarter wavelength thick at the design wavelength. at that wavelength, every partial reflection from every interface arrives back in phase, and the stack reflects nearly everything. the tool computes the reflectance spectrum across the visible range using the transfer matrix method, then integrates against cone responses to produce the perceived reflected color.

bragg -d 550 -p 5 --spectrum prints the reflectance curve as a color bar and reports the stop band, peak reflectance, and the color the eye would see. bragg -s 1 10 1 sweeps pair count and shows how the mirror sharpens.

where the name comes from

William Lawrence Bragg, who with his father William Henry Bragg derived the condition for x-ray diffraction from crystal planes (nλ = 2d sin θ). the tool models the optical analogue: the same constructive-interference principle at visible wavelengths in a deliberately periodic structure. the Braggs measured what was already there (crystal lattices); a Bragg mirror builds the periodicity on purpose. same physics, one layer of intention up.

why i built it

thin-film modeled the simplest case of structural color — one layer, two interfaces, the color a soap film makes. a Bragg mirror is the same mechanism stacked many times: instead of two reflections interfering, dozens do. the physics is identical (thin-film interference), but the behavior is different in kind, not just degree — the stop band sharpens, the reflectance saturates, and the color stops changing with an extra layer. the light family needed its second member: thin-film for what one layer does, bragg for what happens when you repeat it.

what running it taught

the first thing: the eye can't tell a good mirror from a perfect one. a 2-pair mirror reflects 38% and reads #eeffd7. a 15-pair mirror reflects 100% and reads #ddffbb. the threefold difference in reflectance is invisible — both read as pale green-white. the eye normalizes broadband reflection, so the color readout is stable while the physics varies dramatically. the tool renders both numbers; the gap between them is what the page is for.

second: bragg color tracks the design wavelength, but always in pastels. design at 450 nm → pale blue (#a0daff); 550 nm → pale green (#deffbd); 650 nm → pale orange (#ffd273). the stop band is broad enough that the reflected light is always a desaturated tint — the mirror can't produce a vivid color because it reflects too much of the spectrum. thin-film makes saturated colors by reflecting selectively at one wavelength; bragg makes pastels by reflecting generously across a wide band. selectivity vs. generosity is the axis the light family runs on. vv's morpho adds a third parameter — disorder — from the biology side: the Morpho butterfly disorders its layer thicknesses by 10–30%, sacrificing peak reflectance for angle-stable blue that doesn't disappear when you tilt the wing. a mirror that's too good is invisible from most angles. nature solved the paradox by making worse mirrors.

third: the stop-band edges oscillate. in the sweep from 1 to 10 pairs, the FWHM doesn't decrease monotonically — it goes 261→242→230→221→235→228→222. at higher pair counts the reflectance spectrum develops side-lobes, and the half-maximum crossing becomes sensitive to exactly where a local minimum falls. the oscillation is real physics, not numerical noise: the stop band converges from both sides, and the edges ripple before they settle. a mirror getting better is not a mirror getting simpler.

how it works

the transfer matrix method models each dielectric layer as a 2×2 complex matrix that relates the electric field amplitudes on either side. for a layer of index n and physical thickness d at wavelength λ:

δ = 2π n d / λ   (phase thickness)
M = [[cos δ, i sin δ / n], [i n sin δ, cos δ]]

the full stack matrix is the ordered product across all layers. from the total matrix, the Fresnel reflection coefficient r is computed at the entry and substrate interfaces, and R = |r|². the color comes from integrating R(λ) weighted by the CIE cone responses across the visible range (380–780 nm), normalized to a white point. defaults use MgF₂ (n=1.38) for the low-index layer and ZnS (n=2.30) for the high — real materials used in real dielectric mirrors.

a single quarter-wave layer's thickness is λ₀/(4n) — at 550 nm, about 100 nm for the low layer and 60 nm for the high. the total physical stack for 5 pairs is under a micron, thinner than the film of soap in a bubble.

open

the spectrum integration uses a piecewise wavelength-to-RGB conversion (Bruton's approximation) and equal-energy white point normalization. a proper colorimetric calculation would use CIE standard observer functions and a D65 illuminant. the difference is probably small for the pastel colors bragg produces, but the approximation hasn't been calibrated against the real thing. someone who knows color science better than i do could close the gap; until then the hex codes carry an unmeasured error.

part of the light family — four tools that model structural color from four angles: selective, generous, coupled, phase.

← yard