diff --git a/crates/render/src/layout/tests.rs b/crates/render/src/layout/tests.rs index 11b62c8e6d..a7e86737f1 100644 --- a/crates/render/src/layout/tests.rs +++ b/crates/render/src/layout/tests.rs @@ -3116,6 +3116,33 @@ fn a_reliefs_shadow_softness_changes_its_page_only_off_the_default() { assert!(widest > wide, "wide {wide}, widest {widest}"); } +/// A page whose frame and colour bar draw a relief rising eastward with aerial perspective (#3141) +/// is lighter the stronger the setting, its low ground hazed; the default draws it as before. +#[test] +fn a_reliefs_aerial_perspective_lightens_its_page() { + let page = |aerial| { + let relief = rustgis_map::raster::RasterRenderer::ShadedRelief { + band: 0, + ramp: Some(rustgis_map::Ramp::Terrain), + azimuth: 315.0, + altitude: 30.0, + z_factor: 1.0, + shadow: 0.0, + sky: 0.0, + fill: 0.0, + rock: None, + ambient: None, + balanced: false, + shadow_softness: None, + aerial, + }; + let map = ramp_map(relief, rustgis_map::raster::Stretch::MinMax); + colorbar_page(&map, Orientation::Horizontal, false, "").data().iter().map(|c| u64::from(*c)).sum::() + }; + let (none, some, full) = (page(0.0), page(0.6), page(1.0)); + assert!(none < some && some < full, "{none} {some} {full}"); +} + /// A map with one 100 × 1 raster valued 0–99 by column, styled by `renderer`. fn ramp_map(renderer: rustgis_map::raster::RasterRenderer, stretch: rustgis_map::raster::Stretch) -> Map { use rustgis_data::raster::{ColorHint, Crs, GeoTransform, Raster}; diff --git a/crates/ui-egui/src/panes.rs b/crates/ui-egui/src/panes.rs index dd8aacaae5..35f06cf0aa 100644 --- a/crates/ui-egui/src/panes.rs +++ b/crates/ui-egui/src/panes.rs @@ -7527,13 +7527,13 @@ fn raster_symbology(app: &mut RustGisApp, ui: &mut Ui, l: &Layer, t: &Tokens) { ambient, balanced, shadow_softness, - // Not in this pane yet (#3141). - aerial: _, + aerial, } => { use rustgis_engine::map::shadow::{SOFT_EDGE_MAX, SOFT_EDGE_MIN, soft_edge}; let (az, alt, zf, sh, sk, fl) = (*azimuth, *altitude, *z_factor, *shadow, *sky, *fill); let ss = soft_edge(*shadow_softness); let am = relief_ambient(*ambient, *balanced); + let ae = *aerial; let rp = ramp.as_ref().map(|r| r.name().to_string()); let relief = move |band: usize, az: f64, alt: f64, zf: f64, sh: f64| { let mut p = json!({ @@ -7556,6 +7556,7 @@ fn raster_symbology(app: &mut RustGisApp, ui: &mut Ui, l: &Layer, t: &Tokens) { ("Sky visibility", sk, 0.0..=1.0, 0.01, 4), ("Fill light", fl, 0.0..=1.0, 0.01, 5), ("Ambient", am, 0.0..=1.0, 0.01, 6), + ("Aerial perspective", ae, 0.0..=1.0, 0.01, 8), ] { let input_label = ui.label(tl!(label)); let mut x = v; @@ -7576,6 +7577,9 @@ fn raster_symbology(app: &mut RustGisApp, ui: &mut Ui, l: &Layer, t: &Tokens) { 7 => r.on_hover_text(tl!( "How soft the edges of the cast shadows are: half the sun's apparent size, from 0.5° (crisp) to 15°" )), + 8 => r.on_hover_text(tl!( + "Low ground, by its height on the stretch, lit with less contrast and hazed, so the high ground stands out, from 0 (none) to 1" + )), _ => r, }; if drag.settled(ui, &r, &mut x) && x != v { @@ -7592,6 +7596,7 @@ fn raster_symbology(app: &mut RustGisApp, ui: &mut Ui, l: &Layer, t: &Tokens) { 5 => p["fill"] = json!(x), 6 => p["ambient"] = json!(x), 7 => p["shadowSoftness"] = json!(x), + 8 => p["aerial"] = json!(x), _ => {} } let _ = app.run("raster.symbology", p); diff --git a/docs/user-guide/data.md b/docs/user-guide/data.md index b930ff1f48..ddd3e58480 100644 --- a/docs/user-guide/data.md +++ b/docs/user-guide/data.md @@ -1813,6 +1813,21 @@ hides part of the sky, the ground is drawn darker than the bar. Left unset, `amb contrast; `"ambient": null` goes back to that default. A Z factor of 1.5 to 2 suits the balanced light on 30 m data. Both are saved with the project only when set. +**Aerial perspective**, on a Shaded Relief layer (`raster.symbology` `"aerial"`, 0 to 1), draws +low ground with less contrast and hazed toward a light grey, as if seen through more air, so the +high ground stands out from the hills, as relief artists draw it. The haze lightens dark colours +and softens very light ones (above `#ECECEC`) slightly toward it. What is low follows the layer's +stretch, as the colour ramp does: with `t` a cell's height on the stretch (0 at its low end, 1 at +its high end) and +`k = aerial × (1 − t)^1.5`, the cell's light is pulled `0.7 k` of the way toward flat ground's, +and its colour, the fill light included, is mixed `0.45 k` of the way toward a light haze +(`#ECECEC`). So the plains get most of it, the middle heights keep most of their relief and the +summits none. 0, the default, draws the relief as before; 0.5 to 0.7 is a good start, and 1 washes +the plains out. Set the stretch to the map's own heights, or the low end may be a sea floor or a +pit. A layout's colour bar shows the haze but not the lowered contrast, which is the shading's. A +value outside 0 to 1 is refused; `"aerial": null` or 0 removes it. It is saved with the project +only when set. + With **Resampling** set to bilinear, a Shaded Relief layer's light (its hillshade, cast shadows, sky visibility and fill light) and its rock tint are blended between the cells' centres, as its values are, so a cell drawn over many pixels shades smoothly instead of in squares; nearest keeps