| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
Build pull request / Build pull request (pull_request) Successful in 3m44s
Soul s2 (refuses-converts-crash-to-kill): turning a numpy failure at a refusal case into an AssertionError made mutate.py count crashes as kills, the hole the Refusal class closes. Reverts that deviation of
|
||
| .. | ||
| tests | ||
| .gitignore | ||
| export.py | ||
| places.json | ||
| README.md | ||
| refusal.py | ||
| ridge-bake.schema.json | ||
| ridge.py | ||
ridge-bake
Offline baker for the ridge backdrop: it turns a Copernicus DEM into K+1 G-buffer cards per place, split by K authored seams and cut into 32 azimuth tiles round the whole 360 degree ring, plus a manifest.json (schema 3) and an index.json that the runtime reads. Each card tile is a colour WebP (albedo and coverage) and a geometry WebP (normal and log-distance). The baker is not shipped; public/ridge/ holds its output. The client owns lighting, haze and ink: no sun, haze or shadow is baked.
Run
python3 -I scripts/ridge-bake/export.py <place-id> --tiles DIR --out public/ridge/ [--work DIR] [--sheet contact.png]
Needs Python 3 with numpy, tifffile and imagecodecs. --tiles is a directory of Copernicus GLO-30 tiles (never committed); --work caches the mosaic and rays (default $TMPDIR/ridge-bake-work); --sheet writes the contact sheet at 1/4 of the ring's width (the ring composite, every card's strip alone and the depth image with every seam, the 32 tile boundaries drawn, lit by one fixed light). The bake prints r_max_m, the resident run and the worst fit error per card. python3 -I scripts/ridge-bake/export.py --write-schema rewrites ridge-bake.schema.json, which the tests pin.
Tests: RIDGE_PY=<python> RIDGE_TILES=DIR scripts/ridge-bake/tests/run.sh [test_ridge.py|mutate.py] (mutate.py re-introduces each rule's failure into a copy of the baker and fails if a test does not notice).
Tiles per preset (places.json)
Files are Copernicus_DSM_COG_10_<N|S>dd_00_<E|W>ddd_00_DEM.tif; the list below is <N|S>dd<E|W>ddd.
| place id | tiles |
|---|---|
| vienna | N47E015 N47E016 N47E017 N48E015 N48E016 N48E017 N49E015 N49E016 |
| matterhorn | N45E007 N45E008 N46E007 N46E008 |
| fuji | N34E138 N34E139 N35E137 N35E138 N35E139 |
| halfdome | N37W121 N37W120 N38W120 |
| grandcanyon | N35W113 N35W112 N36W113 N36W112 |
| amadablam | N27E086 N27E087 N28E086 N28E087 |
| trecime | N46E011 N46E012 |
Where the bakes ran
Yggdrasil (16 cores, 62 GB), as mind-void-self, work under /var/tmp/ridge-bake (never /tmp, a 31 GB tmpfs): venv/ (python 3.13 with numpy, tifffile, imagecodecs from PyPI), tiles/, work/<place>/, one out/<place>/ per place until its look is accepted. Tiles come from the public Copernicus DEM GLO-30 AWS Open Data bucket: https://copernicus-dem-30m.s3.amazonaws.com/<name>/<name>.tif with <name> = Copernicus_DSM_COG_10_<N|S>dd_00_<E|W>ddd_00_DEM (17 tiles, 598 MB).
The authored splits sit in depth gaps found by scanning candidate lists (seam medians printed per list): seams flees a split that falls inside a continuous mass of visible terrain to the nearest gap, so a split inside the mass yields an empty card 0 (Matterhorn's visible terrain is one mass from 4.9 to 15 km; gaps at 19, 28 and 43 km). Place splits at the gap medians the scan reports.
Cards
places.json gives each preset card_split_km, an ordered list of 1 to 5 seam depths in km, and optionally prefilter_m. A preset without card_split_km is refused, and so is a split that leaves a card empty (the message names the splits); K splits make K+1 cards, at most MAX_CARDS = 6 per place. New places get a seam probe look before their first bake.
- March.
stage0marches 6400 azimuth columns of rays over the DEM with Earth curvature and refraction (ridge.elev), cached by a key of its inputs. - Low-pass.
prefilterblurs the sampled heights with a Gaussian ofprefilter_mmetres along each ray and across rays at equal distance (sigma =prefilter_m/ (distance x column width) columns), then recomputes the angles. Roofs go, hills stay. - View.
set_viewmaps angle to row linearly: the highest skyline angle of the whole ring sits at 4% of the frame height, the lowest at 66%, and the horizon keepsGROUND_ROWS_MIN= 150 rows under it (the runtime'sgroundRowsNeeded: (1 - 0.85) x 600 / 0.6, so the plane reaches the bottom of every viewport at rest). The scale is the lesser of the two fits, clamped to 0.5x to 10x vertical exaggeration (rulingsridge-ring-vertical-anchors,ridge-ground-rows-below-horizon: every azimuth sits inside one frame; a place whose whole-ring relief leaves too few ground rows is flattened below 1x); a skyline that cannot hold the rows even at 0.5x is refused namingsky_degand the floor.export.validate_manifestrefuses a plane with fewer than 150 rows under the horizon andmanifest.tsrefuses it at load. - Seams.
coveragecounts the visible rows of the opaque view per log-distance bin and column.seamsfinds one seam per authored split per column by dynamic programming (seam carving, forward energy): it sits in a gap between depths, moving it costs 2 per bin plus the visible rows it sweeps (so it never hops across a ridge between two columns and splits it side by side), a seam inside visible terrain is cheap to cross-fade, the authored depth only breaks ties. Seam k stays 0.4 nat beyond seam k-1. The DP runs over the ring three times side by side and keeps the middle lap, so a seam is continuous across the wrap (column 6399 to 0) and a tile boundary is only a crop. - Cards.
cardsruns per tile, on that tile's columns and the matching normals (it is column-independent: a tile is a crop of per-column results, so no seam appears at a tile boundary). It makes card i from the first visible hit at or beyond seam i-1 (layered depth: a farther card keeps the terrain a nearer ridge hides), alpha 1 minus a smoothstep over seam i in log-distance (the cross-fade), crest rows with fractional coverage, distance and normal interpolated between samples by angle, albedo from a small height and slope material, cropped to the rows where alpha is not zero. The rows of card i > 0 below the angle of its first sample (hit and first sample of the card) are its wall: the extruded face of the ridge the card starts at, which keeps that sample's distance, wears the ground material at its height with the face up, and is flaggedwall. Card 0 also draws the near march (rulingridge-near-ground-outline): the place's own DEM fromNEAR_START_M= 1 m to the near clipNEAR_CLIP_M= 500 m (near_march: float64 bilinear samples every max(1 m, 0.02 d) up to 10 m, about 170 per column, low-passed with the place's ownprefilter_m), joined to the far march byjoin_nearon the whole ring before the tile cut, its angles capped per column at the angle of the clip sample so the near ground draws inside the silhouette of the terrain at the clip (a near hill above that edge is cut along it). Its rows are ordinary terrain with their own normal and the albedo of their own height and n_up, flaggednearin memory;cardsrefuses a march that starts at the clip. The runtime reads them as ground at the clip distance (they decode atlog_d_min) and lights them like any card pixel. The alpha-over composite of the cards equals the opaque view;check_coverrefuses a tile that differs by more than 0.02. - Tiles. The ring is absolute compass, column 0 = north, column c at azimuth (c + 0.5) / 6400 x 360;
places.json'saz_deg/look_atis only the rest azimuth (view.look_az_deg). Tile t owns columns [200 t, 200 t + 200) (11.25 degrees) and its files hold [200 t - 2, 200 t + 202): two columns of real neighbour data each side (the client's ink pass and lighting read one texel each way; the client crops it), taken periodically byridge.ring_cols. Per card and tile the file is cropped to the rows where that tile's 8-bit alpha is not zero (top,h); a card that holds nothing in a tile isnullthere (the client interpolates its distance from the neighbours); a card with no solid pixel in any tile is refused. - Distance and the offset range. The bake holds no camera (ruling
ridge-camera-full-ring).packgives each card tiledistance_m= exp(median ln d) over the tile's solid pixels that are neither wall nor near ground (its interior 200 columns); the client derives each card's slide from that and the viewer's offset r and heading.camera.r_max_mis the largest |r| (never above half the nearest terrain's distance) at which, for every tile, card and phi (24 steps of the camera's angle on the circle against its heading; the offset-only rotation mode moves phi round the whole circle), the least-squares linea + s betafitted to the exact view angleatan2(R sin beta - r sin phi, R cos beta - r cos phi)over the widest viewport (HFOV_MAX_DEG= 72 / 1.1) errs by at mostFIT_PX_MAX= 24 card px (the continuous error: the line by quadrature over the viewport, the worst error looked for on 513 points, so a handful of samples cannot undercount it); the distance d is that of the NEAREST solid (alpha >= 0.5, neither wall nor near ground) pixel the card draws in the tile's interior columns, which is where the slide errs most (the line is fitted for the tile'sdistance_m, the median, but the bound is held for the nearest terrain: a tile whose terrain spans 600 to 2000 m is bound at 600 m); each tile's near pixels (under the clip) count as terrain at the clip, 500 m, alongside its solid pixels, whatever else the tile holds (they are drawn at the clip; a tile of near ground only is slid there too), so a tile with any near pixel binds at 500 m at the latest; and the resident gate (below) must hold at r_max_m too.camera.r_max_forward_mis the same search at phi = 0 alone (sameFIT_PX_MAX, the same half-distance cap, the same resident gate): the camera pushed forward along its heading, which is where the offset stays when the view direction turns with it (the modes 'still' and 'both'), so it is at leastr_max_m; the client takesr_max_mfor the offset-only mode and for a backward offset,r_max_forward_mfor a forward one in the other modes (view.tsoffsetRange).FIT_PX_MAXis provisional, tuned by eye (rulingridge-offset-range-fit). A bake whoser_max_mis belowR_MAX_FLOOR_M= 25 m is refused, naming the card and tile.distance_mand the nearest-terrain table exclude the near ground (a tile with nothing outside it getsdistance_m= 500 m), so card 0's distances are never nearer than the near clip (write_bakerefuses one that is), andr_max_mandr_max_forward_mhold for the nearest solid terrain each card draws in each tile, at or beyond 500 m, a tile with near pixels counts them at 500 m: the ground nearer than that rides card 0's slide and is not measured beyond that. - Normals.
normalstakes the along-ray slope and the across-ray slope at equal distance (neighbouring columns, same sample), both times the vertical exaggeration.
Files per card i and tile t: card-<i>-t<tt>-colour.webp (lossy RGB albedo, lossless straight alpha) and card-<i>-t<tt>-geometry.webp (lossless: R, G = (n + 1) / 2 for the normal's along and across components, B = log-distance normalised between encoding.log_d_min and log_d_max; wall pixels write R = G = 255, a code outside the unit disc that no real normal reaches), each 204 columns wide. The manifest lists the cards nearest first (near_m, far_m: the median seam depths over the ring) and tiles[t][i] = { top, h, distance_m, colour, geometry } or null; the runtime paints the cards last to first. The bake_id is the sha256 of the files, tile-major, then card, colour then geometry.
Budgets (check_budget; a cap is never raised to fit a bake, the lever is TILES = 64): every file of one tile at most 235 kB (1.5 MB per 72 degrees), every file of the place at most 7.5 MB, at most 6 cards, and the lit canvases (4 bytes x 202 columns x band rows, per card) of the worst run of N consecutive tiles, cyclic, at most 20 MB, where N = ceil(arc_max / 11.25) + 5 and arc_max = HFOV_MAX_DEG / s_min + 2 (r_max / Rmin) 57.3 degrees with Rmin the nearest card's smallest tile distance and s_min = Rmin / (Rmin + r_max). The loader decodes one tile at a time, so the decode transient is not gated.
Licence
Elevation: Copernicus DEM GLO-30. The credit line is written into every manifest (attribution) and must be shown with any rendering:
Contains modified Copernicus data: DEM © DLR e.V. 2010-2014 and © Airbus Defence and Space GmbH 2014-2018 provided under COPERNICUS by the European Union and ESA; all rights reserved.
Licence: free, full and open access, with the credit line shown (https://spacedata.copernicus.eu/collections/copernicus-digital-elevation-model).