Rainbow — Implementation Review and Measured Results

Parent: Rainbow development

Scope

Implementation and source readback completed at local commit f4e0751. This is a self-review against John's explicit requests for efficient CPU use and source a professional engineer can read; no independent reviewer was used. Example images are computed from droplet scattering, with no generated/painted rainbow texture.

Is the code fast?

Yes for the demonstrated workload: 8,000,000 weighted samples at 1440x900 with two CPU threads took 1.012 s before output and 1.945 s including PNG, EXR, accumulator and metadata. Peak RSS was 129868 KiB. A 32,000,000-sample truncated-lognormal scene took 4.406 s before output and 5.324 s including output; peak RSS 133176 KiB. These are individual runs on Ryzen 7 5800H, not general performance guarantees.

A comparable eight-million-sample one-thread run took 1.717 s before output; its PNG SHA256 exactly matches the two-thread image. Projection/raster stages benefited from threads; the measured serial binning stage was about 0.14 s. Multicore OpenMP and checked particle shards support additional processors, but only modest two-thread workloads were used after the earlier blackout. No remote rendering workers or eight/sixteen-thread benchmarks were launched.

Performance mechanisms verified in the source: reuse spectral Mie lookup tables; SIMD across independent angles; stateless particle seeds; contiguous batches of projected records; no per-particle heap allocation; one writer per image tile; bounded batch memory; no atomic pixel updates. Output profiles now record stage timings, complete elapsed time, peak RSS, resolved parameters and compiled source digest.

Can a professional engineer read and maintain it?

The source separates configuration/schema validation, optical physics, camera/particle rendering, and image I/O, with public types under include/rainbow. Configuration fields carry units, physical density is separate from computational sample count, CLI parsing is separate from library work, and formulas identify their references. Readback found and fixed false proximity warnings from an overly loose bounding sphere, ignored thread settings in the library table builder, missing finite-vector/empty-table checks, insufficient output-memory allowance, and an inaccurate gamut-mapping comment.

Numerical evidence

Release CTest passed the Mie published coefficient reference, differential/scattering energy integral, nonabsorbing energy balance, Rayleigh limit, SIMD/scalar recurrence agreement, recurrence-padding check, configuration rejection, density linearity, PSF energy conservation, tile boundaries, thread consistency and missing/duplicate shard rejection. Six Python health-logger tests passed. AddressSanitizer and UndefinedBehaviorSanitizer CTest passed in 1.31 s with ASAN_OPTIONS=detect_leaks=0. LeakSanitizer itself cannot run in this sandbox's tracing environment; leak checking is unverified, not passed.

Refinement check on the same one-million-particle realization: halve wavelength step from 5 to 2.5 nm and angular step from 0.05 to 0.025 degrees. Normalized foreground Y L1 difference was 0.009122 (about 0.9%); integrated Y changed about 0.12%. The coarse foreground was density-rescaled using exact thin-limit linearity. This is a scene-specific check, not an error bound across radii, source models or settings.

Artifacts and limits

output/waterfall.png and .exr: 80-um-radius monodisperse cloud, 8 million weighted samples; strong supernumerary bands. output/spray.png and .exr: truncated number-lognormal radius distribution, median 80 um, geometric sigma 1.18, bounds 45..130 um, 32 optical radius bins, 32 million weighted samples; fine bands largely wash out. Both are 1440x900 and were visually inspected. Outputs remain ignored/generated; recreate them with the commands in rainbow/dev/usage.

Initial model remains optically thin, spherical droplets, fixed 20 C real water index, blackbody sunlight and empirical Gaussian camera PSF. No fluid dynamics, multiple scattering, spectral attenuation, tabulated radius distribution, automatic sweep scheduler or polarization-resolved transport is implemented. Particle grain in weighted mode is partly numerical sampling noise. No general convergence claim for the lognormal radius grid or arbitrary large drops is made.

Host monitoring

The user explicitly authorized SSH localhost for service activation. The user service is enabled/running; source sender now reuses an existing unlocked user-owned SSH agent if systemd inherited an empty GnuPG agent. Fresh two-second remote fsync acknowledgements were verified on gravlax throughout resumed work, with no recorded kernel faults or queue drops. Maximum sampled CPU temperature reached 86 C during compilation; later sample after rendering was 61.5 C. These observations do not establish the original blackout's cause.

Logging operation

Verification commands

Photographic comparison — 2026-10-16

Reference downloaded and visually inspected: Double Rainbow at the Base of Vernal Fall along Mist Trail, photographed 2001-07-15 by Wing-Chi Poon; original JPEG 1600x1200. Source: Wikimedia Commons photograph and attribution. Licensed CC BY-SA 2.5: license. Local output/reference-vernal-fall.jpg is unchanged; output/photo-comparison.png pairs an uncropped resized copy with output/spray.png, with attribution/license in the panel. Share the comparison panel under CC BY-SA 2.5. Displayed on the desktop using SSH localhost and ImageMagick display; window title verified with wmctrl.

Qualitative agreement: the photo and mixed-size render have a warm outer primary edge, blue inner edge and a weaker outer secondary with reversed order. The photograph does not resolve the many fine interior rings seen in our monodisperse render; the mixed-size render is closer to this particular observation. This does not prove waterfall spray never has supernumeraries. The drop-size dependence agrees with Les Cowley's Airy simulations: Supernumeraries and drop size.

Measured from displayed PNGs in 0.1-degree bins using the actual rectilinear camera and antisolar axis, upper sector y<450 and |x-719.5|<600: mixed-size primary RGB-channel maxima red 41.15 degrees, blue 40.25; secondary red 52.15, blue 54.15. These broad RGB peaks are exposure/tone-map/geometry dependent, not monochromatic geometrical caustics. Search maxima checked to be interior to each search range. Method and values saved in output/photo-comparison-measurements.json. No renderer settings or source changed.

Limits and implications: the photograph is patchy, with white falling water, background rocks/vegetation, occlusion and variable mist columns; our homogeneous box produces smooth symmetric arcs and a grey interior without scenery. Photograph exposure, lens calibration, processing, droplet radii and optical depth are unknown, and the downloaded JPEG contains no EXIF. Therefore no calibrated angular, radiometric or droplet-size validation is claimed. Foreground texture and dense white spray are outside the current thin single-scattering model. Next useful scene improvement is spatial density/illumination/occlusion variation; retain mixed radii, and seek calibrated imagery before fitting radii or brightness.

Better photographic references — 2026-10-16

Downloaded and inspected six full-resolution Commons photographs, plus Mickey Shannon's original Skogafoss image and the Radek Grochowski Victoria Falls photographs reproduced on Atmospheric Optics. Selected four freely reusable photographs for output/waterfall-reference-gallery.png and its desktop preview, alongside our 80-um and 160-um mixed-radius renders. Manifest, original titles, source URLs, licenses and comparison purposes: scenes/photo-references.toml. Verified original-file EXIF and SHA256 values are recorded in output/references/selected-attribution.json. Full photographs are resized uncropped, with no colour or exposure edits. The collage is CC BY-SA 4.0 with individual attributions.

Best close comparison: Norton Ip, Double rainbow @ Athabasca Falls, 5616x3744, Canon EOS 5D Mark II, 40 mm, f/7.1, 1/20 s, ISO100, CC BY-SA 2.0. Primary and secondary cross dark rock with distinct reversed colour orders and a wide intervening dark region. The background is structured, branches obscure part of the secondary, and daylight/shadow variation prevents interpreting raw pixel brightness as scattering alone. A detail crop was made at original pixel box (1300,800,4200,3000): output/references/athabasca-bows-detail.png, without colour adjustment. Athabasca source and license

Horcrux92's Marmore double bow (4160x3120, Huawei VNS-L31, 27 mm equivalent, f/2, 0.002105 s, ISO50, CC BY-SA 4.0) is useful for the broad primary and faint secondary; Photoshop processing is recorded. Jeremy Goldberg's Skogafoss (6938x4336, Sony ILCE-7R, 16 mm, f/8, 1/250 s, ISO100, CC0) gives the large arc and mist masking at high resolution. The Commons imported summary lists different exposure settings: original JPEG EXIF, verified locally, agrees with its detailed metadata table. Jonashtand's 201708 Skogafoss 05 (3840x2160, LG-H845N, CC BY-SA 4.0) offers a low double arc but requires phone lens/projection calibration. These source links are in the manifest.

An additional physically informative reference is Radek Grochowski's Victoria Falls pair: different portions of the spray show differing band width and alignment. Atmospheric Optics interprets this as differing droplet sizes; this is that source's interpretation, not a size measurement by us. Its three Airy-simulation bands are explicitly simulations and were not counted as photographs. Victoria Falls photographs and optical interpretation. Copyrighted Grochowski and Mickey Shannon images were inspected locally but are not included in our freely licensed collage. Shannon's picture is excellent for arc geometry but its very bright primary centre limits colour-profile comparison. Gilbon close-up was not selected because the bow is weak against distracting rock/vegetation.

These improve qualitative feature comparison and provide candidates for camera matching. None supplies measured droplet distributions, RAW radiometry, confirmed crop/distortion, or polarization-filter state. No droplet-size fit, exact angular validation, or new simulation was performed. None of the selected photographs convincingly resolves the many fine rings of our monodisperse image; this is not evidence that waterfall supernumeraries are absent. Desktop reference-gallery display was verified. Reassemble with: python3 tools/distribution_gallery.py --manifest scenes/photo-references.toml --output output/waterfall-reference-gallery.png .

version 3  ·  created 2026-10-16  ·  updated 2026-10-16