Why were my shadows so pale?
On 1 October I set out to make the site’s shadows real enough to stage a shadow-puppet show. An audit of the shadow model against the formulas found the geometry right and five faults elsewhere, none of them the one I had guessed. One pale shadow turned out to be correct physics.
By 29 September every shadow on the site already shared one model, because light and shadow are the systems everything else here interacts with.
The faults I had seen: shadows that did not follow the light, and shadows too fuzzy and too light with the lamp close. Shadows should grow, stretch and darken with the caster’s distance and the lamp’s brightness, and should go through glass and be filtered twice by stacked panes.
The geometry was right
The audit read the code against the formulas. The casters, the shapes that throw shadows, are flat and parallel to the photograph, lit by a disc lamp. For that case the soft shadow is exactly the caster’s mask projected from the lamp and blurred by the lamp’s disc. The projection, the penumbra radius (the width of the soft edge) and the stretch by 1/cos θ all checked out.
My guess was wrong, and there were five other causes
My hypothesis was that only the lamp’s added light was being removed, so the photograph never darkened below its unlit look. The audit found the code does not do that, and found five real causes instead.
Opaque type passed 40% of the lamp (strength 0.6). Lit areas faded toward the lamp’s colour instead of multiplying: a photo value of 0.1 under the lamp came out at 0.68 lit and 0.36 in shadow, so the shadow was brighter than the unlit print.
The brightness knob was uploaded and never read. Height did not dim the light, because the inverse-square term was missing. And every caster on a channel shared one fixed height.
The pale smudge was physics
One of the pale shadows was correct behaviour. A lamp of size 46 at height 300 spans 17°, and through the glass a 4 px stroke can hide at most 17% of it. Times 0.6, that removes 10% of the light: the pale smudge I had seen. For a point lamp, size 6, the same stroke hides everything.
That is why the note’s first decision about puppets is a small lamp: every real shadow-theatre source asks for as small a filament as possible.
The fixes: multiply the light, and let distance matter
The photograph is now lit multiplicatively with a room-fill knob, and brightness and distance matter (E = P (H₀/H)² cos³θ).
Casters live in six layers in two RGB masks, in place of the eight-tile atlas first planned. Sampling is twelve Vogel-disc taps (samples laid out in a sunflower spiral) rotated per pixel, and the frosted face was settled as the pane’s lower face.
The puppet stage was removed and its parts kept
On 1 October I had the puppet stage removed: I wanted shadows good enough for a show, and did not want the show itself. What it added stays under other names: shape casters (used by the balloons) and the room-fill override (used by the torch).
Letter shadows, and shadows through the glass
The same day two more things changed. Each letter’s shadow had fallen on top of the neighbouring letters; one drop-shadow per block fixed that, and a preview gave each letter its own cast shadow.
Shadows through the glass and on the glass are correct behaviour and a fix, so I turned them on for everyone, with no switch.
Still to build
A mip prefilter (smaller, pre-blurred copies of the shadow masks) for shadow quality, and a debug view of the mask layers.
Sources and notes (6)
- Soler and Sillion 1998, convolution soft shadows — exact soft shadow of a flat caster parallel to the light
- Fernando 2005, percentage-closer soft shadows (NVIDIA) — penumbra from lamp size and distances
- Christian Science Monitor 1998, shadow puppetry (Reed) — puppet shadows ask for as small a filament as possible
- Inverse-square law (Wikipedia) — height dimming the light
- Lambert's cosine law (Wikipedia) — the cos factors in the irradiance formula
- Shadows note — the notes this was written from
Light & shadowAll 19 parts →
