A Monte Carlo companion to the 3D Rayleigh scattering sky: instead of painting a gradient, this version traces real individual photons at seven wavelengths through an atmosphere, lets each one roll a genuine 1/λ⁴ scattering probability at every step, and builds the sky and sunset colours from the actual tally of what scattered and what survived.
Rayleigh scattering intensity follows 1/λ⁴: blue light (450 nm) scatters roughly 5.5× more than red (700 nm) per unit path. Here that ratio is not assumed — it emerges from thousands of independent per-step dice rolls, one photon at a time, visibly thinning the blue lane while the red lane keeps marching through.
Drag the sun elevation slider toward the horizon to lengthen the atmospheric path — watch the red lane start scattering too as the sunset tally reddens. Raise the particle density to make every lane scatter faster. Reset the tally at any time to start the statistics fresh.
This is exactly how physicists validate a scattering law numerically: run a Monte Carlo radiative-transfer simulation and check that the emergent statistics match the analytic 1/λ⁴ prediction, rather than trusting the formula alone.
This model traces individual photons through a two-dimensional atmosphere instead of computing a colour formula directly. Seven visible wavelengths each get their own continuous stream of photons; at every discrete step along the path a photon rolls a genuine scattering probability proportional to 1/λ⁴. The sky colour you see is the live, running average of every photon that actually scattered; the sun/sunset colour is the running average of every photon that actually made it through unscattered. Nothing about the final colour is hand-set — it is the emergent result of thousands of independent random trials, the same Monte Carlo method used to validate radiative-transfer physics numerically.
Seven wavelength lanes (400–700 nm), each a continuous stream of moving photon dots. Every step, every photon rolls dice against a real per-step scattering probability derived from σ(λ) = (550/λ)⁴. Scattered photons visibly peel off into short radiating bursts and are tallied into the sky-colour accumulator; survivors reach the far side and are tallied into the sun/sunset accumulator.
Drag "Sun elevation" toward the horizon to lengthen the atmospheric path (air mass), which needs more steps to cross and scatters even the red lane. Raise "Particle density" to make every wavelength scatter faster at a fixed path length. "Reset tally" clears the running counts so you can watch the statistics build up from zero.
This is a genuine Monte Carlo radiative-transfer simulation in miniature: real physicists check an analytic scattering law by tracing large numbers of individual photon histories and confirming the emergent statistics match the 1/λ⁴ prediction, exactly what the live tally here is doing in your browser.
The 3D sim paints an analytic sky gradient directly from the closed-form Beer–Lambert transmission formula. This 2D version does not compute colour directly at all — it traces individual photons step by step, has each one roll a real per-step scattering probability, and only then builds the sky and sunset colours from the resulting tally of scattered versus surviving photons.
The 2D Atmospheric Optics sim also renders a Rayleigh sky, but analytically, alongside an unrelated ice-halo scene. This sim has no halo and no analytic gradient — its only mechanic is per-photon Monte Carlo scattering, where the sky and sunset colours are literally counted, not painted.
Rayleigh's law says scattering intensity is inversely proportional to the fourth power of wavelength. A 450 nm blue photon is about 5.5× more likely to scatter per unit distance than a 700 nm red photon. In this simulator that ratio shows up as a real difference in scatter probability rolled every step, not as a pre-set number.
Lowering the sun lengthens the atmospheric path length using the Kasten–Young air-mass approximation. A longer path means more steps, so even red photons — which rarely scatter per step — eventually start scattering too. The survivors that make it all the way through skew increasingly red, exactly like a real sunset.
Yes. Each photon's fate (scatter or survive) is decided independently by a random draw against a physically derived per-step probability. The displayed colours are running frequency counts of those draws, which is the same method used in radiative-transfer physics to verify scattering laws numerically.