Time-of-day sun driver + weather — guide
What it does
Animates the sky. Given where you are (latitude_deg), the date (day_of_year), the clock (hour) and the weather, it produces a SunSky (sun direction, colour, intensity + sky/ambient tint) that plugs straight into the existing 3D render path.
Use it
use facett_map3d_flight::{Atmosphere, DayCycle, Weather};
let atmos = Atmosphere::earth(); // build once (transmittance LUT)
let mut cycle = DayCycle { // Sweden, midsummer, clear
latitude_deg: 59.5, day_of_year: 172,
weather: Weather::clear(), exposure: 12.0,
};
// per frame, for the current time-of-day + camera altitude:
let (sky, horizon) = cycle.sun_sky(hour, &atmos, altitude_m);
// feed the shared uniforms your renderer already uses:
let light = sky.light_uniform(); // [dx,dy,dz, ambient]
let sun = sky.sun_uniform(); // [r,g,b, intensity]
let skyu = sky.sky_uniform(); // [r,g,b, horizon_bias]
- Golden hour:
cycle.golden_hour(hour)→0..1(1 with the sun ~2° up). The sun reddens + long shadows appear on their own — it comes from the atmosphere. - Weather:
cycle.weather = Weather::overcast();greys + flattens the sky and dims the sun.Weather::cloudy(0.5)for a half-overcast day. - Season / place: raise
day_of_yeartoward 172 for a higher summer sun; pushlatitude_degtoward the poles for a lower one. Winter noon is low + warm. - Night: below the horizon the direct sun goes to ~0 and the sky darkens to a faint floor — no special-casing needed.
Demo
facett-demo/src/demo_photoreal.rs (PhotorealDemo) is the interactive toggle: an hour slider, latitude/season sliders, an overcast switch and live sun/sky swatches. Its state_json() is the headless oracle the self-test drives.
Determinism
No clock, no RNG — two identical queries return bit-identical results (FC-7), so a scripted flythrough is reproducible and the sky is snapshot-stable.