# Ridge stylization pass (Imagination, nibu-body, 2026-11-12) - target shape, not adopted

## Body today
- Layer 0 = real Copernicus GLO-30 horizon: `scripts/bake-horizon.py` -> `ridge/viennaHorizon.json` (one elevation per 0.5 deg azimuth, 60 km, +-1.5 deg box smooth, normalised to the layer's `relief`).
- Layers 1-3 = ridged-multifractal noise (`ridgeWorld.ts`); `ridgeBake.ts` paints each as crest slope + a vertical light-to-haze gradient + vertical "gully" streaks + a lit rim; the sky blurs/glows over it.
- Data: nine GLO-30 tiles are on disk (`scratch/cop30`, 380 MB), numpy+tifffile venv at `scratch/dembake-venv`. No PIL/ImageMagick; mockups write PNG with zlib.
- Why shots in `ridge-vienna-shots` read procedural: (1) one profile statistic for every layer, and layers 1-3 are not the place at all; (2) a single vertical axis of detail (curtain streaks) on every face; (3) near-monochrome white/lilac, no hue ramp (berann-depth, swiss-hue-ramps, atmos-layers); (4) blurred, perfect edges and no paper/ink grain, no misregistration (riso, berann-process); (5) detail comes from noise instead of from anything the DEM knows.
- The real angular range is tiny (about 2 deg of relief at 18 px/deg): any layered read needs an AUTHORED vertical exaggeration (berann-geometry: 1.5-4x; mockups use ~5.6x, labelled).

## Shared stage 0 (all pipelines): bake from DEM, offline, deterministic
`scripts/bake-view.py` (successor of bake-horizon.py): mosaic -> per azimuth ray march 0.5-95 km with curvature+refraction (horizon-curv, horizon-tools) -> per-distance-band unoccluded ridge angle (the real layered silhouette), plus optionally the visible depth/height/slope buffer. Committed bake carries the `source` block (glo30 licence). Mockup core: `ridge-mockups/src/core.py` (5 s on one core, 1280x600).

## A. Horizon-profile bands (cut-paper / gouache), real silhouettes per distance band
- Inputs: band envelopes (5 bands: 0.5-5, 5-12, 12-25, 25-45, 45-95 km) from the DEM; authored palette ramp; sky state.
- Stages: smooth DSM teeth (roofs/trees) per band -> hand-cut edge wobble (low-freq noise, seeded) + riso misregistration per band -> flat band fill by hue ramp (blue far to green-olive near, never paler than the sky) -> foot dissolves to valley mist -> mottled gouache body (two noise scales) + an echo plane inside the band + thin lit rim -> paper grain.
- Real: ridge shapes, which ridge is behind which, relative scale, azimuth placement (Rax/Schneeberg cluster). Authored: exaggeration, palette, edge character, internal texture.
- Determinism: total (seeded; bake is a pure function of DEM+params). Cost: bake 1-D arrays (5 x 1440 floats, a few KB); runtime = existing per-column painter, cheaper than today.
- Looks like: layered cut-paper / Firewatch-Alto-ish blue ranges over a paper sky. Failure modes: flat if the palette is wrong; near bands become a slab (city DSM, as in the mockup foreground) so crop/replace band 0; bands 3-4 hidden when nearer bands are higher (honest but may disappoint); easy to drift into "vector art".
- Mockup: `A-bands.png`.

## B. Generalised relief + slope-oriented painted strokes (Berann / Imhof)
- Inputs: the visible-terrain buffer (depth, height, slope) from the same ray march; light direction (authored NW or the sun); Imhof ramps.
- Stages: depth-dependent generalisation of normals -> Lambert + hue shift (lit ochre, shadow violet) + elevation tint -> aerial perspective by depth + valley haze -> soft underwash -> ~26k oriented strokes (fall-line near, horizontal far, bristle streak alpha, jitter in value/hue) -> ink-glaze on silhouette -> paper grain.
- Real: all forms, slopes, drainage/fall lines, light logic. Authored: ramps, stroke vocabulary, generalisation scale.
- Determinism: seeded stroke placement; runs offline to a texture. Cost: heavy bake (seconds CPU, tens of thousands of stroke patches), big shipped texture (a panorama PNG, hundreds of KB) and must be re-graded/relit by multiply layers for sky state, because the light is baked; scene loses the per-column procedural painter.
- Looks like: a painted relief panorama; with 26k naive strokes it reads as a photo "oil filter" (the mockup does: fur). Failure modes: stroke noise without compositional hierarchy; baked light fights the real sun; at this scene's tiny angular range most of the view is flat near ground with nothing to paint.
- Mockup: `B-strokes.png`.

## C. Ink: Tanaka contours + hachure + silhouette line (pen-and-ink)
- Inputs: same buffer. Stages: contour every 60 m by image-space iso-height, thickness by light (Tanaka), fall-line hachure by slope, firm ink line where depth jumps, one cold wash per depth band, paper.
- Real: everything but the line weights. Determinism: full. Cost: raster bake like B; light mostly line weight so relight is cheap. Looks like: an engraving / map-panorama. Failure modes: needs clear peaks (this view has few; near ground is empty), clashes with the soft physical sky, little ambient "atmosphere".
- Mockup: `C-ink.png`.

## D. Per-ray sweep -> ridge spans with own distance -> A's cut-paper (Meta's proposal; mockup `D-sweep.png`, raw spans `D-spans-debug.png`)
- Rule as built (`src/sweep.py`, CPU numpy, same march as core.py): per column, 500 m -> 95 km, step 40-250 m; angle = atan2(h - eye - d^2/(2R)(1-k), d) with R = 6371 km, k = 0.13 (the numbers already in core/A; research horizon-curv gives R = 6370 km, refraction a constant K, ~0.1 deg rms). Scan keeps runmax (what already occludes), minSince (lowest since the last peak) and a candidate peak; a peak commits when the ray falls by `hy` below it and it rose >= `hy` above minSince; only peaks above runmax are visible; span = (peak angle, valley angle, peak distance). Filter: `hy = 25 m / d` (height-equivalent prominence, so roofs/trees (GLO-30 is a DSM) vanish at every range). Then chains: spans in adjacent columns (4-column look-back) link when |ln d ratio| < 0.45 and |angle| < 0.25 deg; chains < 10 columns (0.56 deg) dropped; a chain gets ONE distance (median), so one hue and one haze for the whole ridge; ends taper into the valley over 8 columns. Painted far-to-near through A's own `cutpaper_layer` (extracted from mock_a, A output byte-identical after the refactor), hue = continuous function of the ridge's own log-distance, foot length from distance.
- Two corrections to the rule were needed: (1) a front-facing slope that only climbs has no peak, so the foreground disappeared and the far ridge's body filled it (visible hole, first render). Fix: a ray still climbing at 4 km commits its running shoulder as a ridge (`NEAR_CAP`). (2) Raw per-column spans are not usable as layers; the chain step is where the quality is.
- Numbers (1280 columns): prominence 3 m -> 9.7 spans/column (near field 5.9/col: roofs, trees); 10 m -> 4.4; 25 m -> 3.3; 60 m -> 2.6. Chains after linking: 23 / 36 / 12 / 12, kept: 18 / 20 / 8 / 10. Final: 8 ridges (2.9, 13.2, 13.4, 17.9, 26.3, 34.4, 61.9, 79.9 km). Top-silhouette jitter is identical across thresholds (median 0.006 deg/column), because the silhouette is the same nearest crest; noise lives in the buried ridges, not the skyline.
- Cost: rays 0.3 s (vectorised, cacheable), scan 0.5 s pure Python (1280 columns x ~900 samples, no numba), chains < 0.1 s, paint as A. Whole run ~9 s incl. PNG. Deterministic: two runs byte-identical (sha1 verified). Bake output would be ~3 spans x 1280 columns (or ~10 chains of ~100 numbers), i.e. kilobytes, like A.
- What D adds over A: each ridge owns its depth (A fakes this by a fixed band; a 13 km crest and a 17 km crest are two layers with their own haze, A merges them into one 12-25 km band, and a 70 km Rax crest is not painted with a 45 km one); occlusion falls out of the sweep rather than of band envelopes (A's band 3-4 envelopes can be wholly hidden or wrongly split where a ridge crosses a band boundary, D never draws a crest that nothing sees); valley minimum gives the mist foot a real height; ridge count is data-driven (8 here, not a fixed 5).
- What D loses: stability. Chain count swings 12 -> 36 -> 12 across prominence 25 -> 10 -> 3 m; hues step whenever a chain splits; one ridge can switch layer when the linker disagrees (the 13.2/13.4 km pair is one ridge cut in two). Climbing slopes own no peak (needs NEAR_CAP hack, a rule Meta did not state). Foreground colour is lost to the ridge's crest distance unless the cap fires. Tuning surface is 6 constants (prominence, MINW, LINK_D, LINK_A, LOOK, NEAR_CAP) against A's band edges. Looks marginally less composed than A: layers with similar distances get similar, muddy mid-greys (13 km ridge reads grey-mauve), where A's authored 5-step ramp is cleaner. Distance hue as a continuous function was my addition; with discrete bands D reads like A.
- Changes I would make to the rule: (a) prominence in metres of height-equivalent (not angle), 20-30 m; (b) near-cap commit as above; (c) merge spans across columns by distance+angle with look-back and drop chains < ~0.5 deg wide, as built; (d) quantise chain distance into a short ramp (a layer count cap, 6-8) so hue steps are authored, not a data accident: i.e. D as a data-driven band choice for A; (e) ridge identity must not be recomputed per frame: bake chains offline and key the painter by azimuth.

## Comparison
| | A bands | B strokes | C ink | D sweep |
|---|---|---|---|---|
| ridge owns its depth | no (5 fixed bands) | per pixel | per pixel | yes (chain median) |
| occlusion | band envelope | depth buffer | depth buffer | sweep runmax |
| layer count | fixed 5 | n/a | n/a | data-driven (8 here) |
| noise handling | blur 2.5 px | generalise normals | blur | prominence + chain width + blur |
| tuning surface | 6 edges, palette | big | medium | 6 constants, unstable chain count |
| cost (bake / runtime) | 5 s / kB, cheap | secs, big texture | like B | ~1 s CPU, kB (3 spans/col), cheap |
| determinism | total | seeded | total | total (byte-identical runs) |
| look | clean cut paper | oil-filter fur | engraving | cut paper, more layers, muddier mids |

## Recommendation (revised after D): A's painter with D's sweep as the bake, B/C later
Revised: keep A's painter and its shipped shape (azimuth-keyed per-layer top lines), but let the bake come from D's sweep-and-chain with the layer count capped at 6-8 and distances quantised onto the authored ramp; this keeps A's clean look and D's per-ridge depth and occlusion. Confidence ~0.6 that D-as-bake beats fixed bands (it is visibly better in how the 13/18/26/34 km ridges separate, not in overall beauty); ~0.7 that the painter is A's. Original text: Pipeline A, confidence ~0.7. It is the only one that keeps what the scene already has (per-column painter, sky-state relight by depth colour, real azimuth keying), turns the real DEM into the layers 1-3 now faked by noise (so the whole silhouette stack is real), costs kilobytes, and its "painted" read comes from the three things the notes say make the style: hue-ramped aerial perspective (atmos-layers, berann-depth, swiss-aerial), flat shapes with abstract internal detail (firewatch, alto), and imperfect registration/translucent ink layers on paper (riso, swiss-print). B is the truer Berann (berann-process, digital-berann) but it is a different product (baked panorama), has the highest procedural-read risk and the worst fit to a ~2 deg view; C is a strong alternative mode (reduced-motion, print, night inversion). Confidence is lower on exact look: needs Meta's eye on A with the true sky behind it before any render.
Cited notes: nibu-body:research:ridge-stylize.{glo30,horizon-curv,horizon-tools,berann-geometry,berann-depth,berann-process,berann-colour,swiss-aerial,swiss-hue-ramps,swiss-print,atmos-layers,firewatch,alto,riso,tanaka,terrain-npr,digital-berann}.

## Cut shape if A is chosen (Hands, later)
Owner of ridge shape: the committed bake (`viennaBands.json`, replaces `viennaHorizon.json` as the shape owner). Demoted: `ridgeWorld.ts` noise layers 1-3 (profile function becomes `bandProfile(band, azimuth)`), the gully streak term in `ridgeBake.ts` (vertical streaks) and the multi-octave warp parameters. Forbidden writers: any noise path deciding a silhouette. Deletion line: delete noise + warp + gully before adding the band painter. Drift: bands are azimuth-keyed, so layer drift (`seconds`) must be either dropped or become a parallax shift of azimuth, a Meta decision (q: camera).
