--- topic: painted-far-map triggers: [painted.rs, render_revision.rs, BOLD_BORDER_TILE_M, countries.rs, countries.tsv, "atlas countries", MAP_EV100, DAY_FALL, map_light.wesl, ne-admin0-europe, hex_grid.wesl, hex_tile, apply_hex_grid, CARTO_HEX_GRID, lights_mask, GlobeNight, update_globe_night, GlobeCloudMode, CARTO_GLOBE_CLOUDS, CITY_LIGHT, globe_ocean.wesl, PAINTED_TWIN_ZOOM, PAINTED_FADE_M, PaintedTwin, twin_cache_key, painted_style, FarDetail, far_buildings, far_detail, FAR_STYLE_TILE_M, "palette::painted", place_names.rs, extract_place_labels, PlaceKind, "place names", "city banner", "macro view", "zoomed out"] updated: 2026-11-26 --- # The far tiles are a painted map, and names come from the same tiles Built 2026-10-31 from the macro-view design (`docs/mockups/macro-view/`, v3 and v4, decided 2026-10-30). What follows is what the code does not say. ## Which tiles are painted: by tile, so by distance A raster whose tile shows more than `FAR_STYLE_TILE_M` (5 km) of ground is drawn by `vector_tiles::painted` rather than the realistic paint loop. The tile tree picks coarser tiles further from the camera (screen-space error), so this follows **distance from the camera, not its height** — which is what the design asked for: in a tilted view at 3 km the ground near the camera keeps today's style and only the band towards the horizon is painted. Over the Netherlands that is z12 (~5.9 km) and coarser, and every globe tile. ## The two styles crossfade on distance, through a painted twin A tile cannot be both styles at once, so a z13 tile (`tile_loader::PAINTED_TWIN_ZOOM`) is drawn twice: as itself and as a painted twin, kept on disk under its own key (`twin_cache_key`) and bound beside it in the ground material (106–107). `ground_detail.wesl` mixes the two on the fragment's distance from the camera, 4.5 to 8 km (`map_stream::PAINTED_FADE_M`). Why z13 and those numbers: the tree picks z14 and finer within ~4 km and z12 and coarser past ~8–10 km, so z14 is never asked to be part-painted and z12 is always fully painted. The band ends before 10 km because v4's straight-down 10 km frame is fully painted. What it costs: a second raster and texture for each z13 tile — 49 at most, ~70 MB of graphics memory on a desktop, a quarter of that at a phone's 256 px — and four z14 fetches each for its footprints. v2's chart sinks the 3D buildings into the ground between 15 and 50 km. Only the far OSM tier has a height ramp (`building_fade`), so instead every 3D building stops at `osm_buildings::BUILDINGS_TOP_ALT` (10 km), in one step: measured 2026-11-01 on mac-1 at 12 km over Groningen on the phone rung, they were sub-pixel specks over their own painted footprints and held 258 MB of the 332 MB resident (74 MB after). And the haze over the ground at 10 km is left as it is: v3 keeps it to ~15 km, and above that `CITY_ATMOSPHERE_ALT` already thins it. ## Footprints on a far tile cost sixteen fetches Shortbread carries `buildings` **only at z14** (checked 2026-10-30 over Utrecht: z10–z13 have none; z14 is ~650 KB with ~9,000 footprints and a `height` on each). So a painted z12 tile gathers its sixteen z14 descendants' footprints (`tile_loader::far_detail`), and nothing coarser does: a z11 tile would be 64 fetches for buildings under a pixel each. In practice footprints therefore reach as far as the tree still picks z12 — around 10–15 km straight down — and the design's "buildings to ~60 km" is **not** met; beyond z12 built-up land carries a soft lifted edge instead (`drop_edge`). Getting the grain further out would need a coarser building layer made by atlas, which is new data the design said it did not want. The descendants come through the shared byte cache and `parse_shared`, so where the near map already fetched them they cost a parse. ## Shadows are quantised because they are in the cache key A footprint's shadow is `height / tan(sun elevation)` long, away from the sun (`shadow_step`), with the elevation held to at least 15°. The sun is read from `FAR_SUN` (kept by `tile_loader::track_far_sun`), quantised to 15° of azimuth and 5° of elevation, because the shadow is drawn into the pixels and so is part of the rendered tile's cache key: an unquantised sun would make every stored tile a miss each minute. A tile already drawn keeps its shadows until it is re-streamed. ## Colours are the mockup's, in a map light from 20 km out `palette::painted` holds the mockup's screen colours, used as albedo. Lit as ground they came out a fifth darker and greyer than the sheet (asked 2026-11-03, "grauwer dan in de mockup"; mac-1, 350 km, 3 November 12:00 UTC: farmland 111,113,88 for the sheet's 143,141,95). Three causes, measured by turning each off: the **sun's angle** (~20° up that day) was most of it; the **tonemapping** (TonyMcMapface) lifts dark tones and pales everything; the **aerial perspective** added ~10 of blue. So `map_light.wesl`, called by `ground_detail.wesl` and `globe_ocean.wesl` after lighting, takes over between 20 and 60 km of camera distance: the same lights at their own colour and strength, but as if overhead wherever they are above the horizon, so the night side stays night and a sunset stays red. The colour goes in through a curve (`CURVE` 1.5, `GAIN` 1.5) against the tonemapping: farmland then measures 140,144,91, the Dutch mix of grass and towns a tenth brighter than the sheet, the sea 44,92,135 — bluer than the sheet's 40,74,104, which a sea-only change would have to fix. It replaces the lit colour outright, so the globe's sun glint is gone from 60 km out. The atmosphere's density at the globe threshold went from 0.12 to 0.03 (`ATMOSPHERE_DENSITY_NEAR`) for the rest of the blue. **The sheet is graded towards semi-realistic** (asked 2026-11-12: too vivid, first "more like Google Earth", then "semi-realistic, keeping the towns and roads" — the strategy map stays, only its colours calm down). The mockup's colours through that curve drew a poster: from 12,000 km on mac-1 a cream Sahara (246,227,178) and a teal Congo (60,103,105). `map_light::grade` greys the albedo (`GRADE_SAT`) and darkens it from the map light's own band on, a little (`NEAR_DIM`) for the strategy map and more (`ORBIT_DIM`) from 300 to 2,000 km, where it also takes blue out (not from snow and ice, which that turned cream). The deep-space air went from 0.15 to 0.08 (`SPACE_ATMOSPHERE_DENSITY`), whose in-scattered blue no albedo could take back — and until the rebuild threshold was made relative (`MEDIUM_REBUILD_STEP`) it never reached even that, which left the globe clear and over-sharp; the person then asked for Google Earth's light haze, thicker towards the limb, gone once zoomed in, which 0.08 gives. From orbit the map light also falls off over the whole day side (`map_light::daylight`, `DAY_FALL`), as on Google Earth's globe, instead of lighting the day side flat to the terminator; and `palette::painted::SAND` from cream to tan. Same frame after: Sahara ~218,179,124, Congo ~38,73,72. The land is still flat class colours with hard edges; real satellite texture would need imagery (`land-cover.md` on `satellite.versatiles`). **One map from 700 km to orbit** (asked 2026-11-18: the globe's dark olive did not fit the green and yellow strategy map; "more saturation, a bit like the detail view"). Three things stood between the two, measured on mac-2 over the same ground near Osnabrück on a November noon: the day side's fall over the whole of n·l (Europe at n·l ~0.35 got a third of the light), the camera's exposure (eye adaptation near the ground, the fixed day exposure in space: 0.6 stop), and `ORBIT_DIM`. Now the fall runs over the band towards the terminator only, the map light from orbit has its own exposure (`MAP_EV100`), and `ORBIT_DIM` darkens bright albedos only, the desert. 700 → 2,800 km went from 157,167,101 → 88,103,51 to 152,165,99 → 134,147,77 at full saturation; the strategy map below 300 km is unchanged (50 km over Groningen: identical mean). That read as too much colour beside the close-up of a city (the close-up differs ~10 between its channels, the far map ~48), so the land from 20 km up takes the near map's aerial-measured tones (`palette::painted`, farmland an olive instead of the mockup's ochre) and `GRADE_SAT` goes 0.8 → 0.55: 50 km over Groningen 96,111,83, Europe from 3,500 km 105,120,98 (mac-1, June noon). **Borders in the ground from orbit** (asked the same day, "information in the ground layer"): the globe shows a coarse tile shrunk three or four times over, so the 1.6 px cream line vanished. Tiles over 40 km (`BOLD_BORDER_TILE_M`) draw it 3.8 px, opaque and near white (`NEIGHBOUR_BORDER_FAR`): the tile tree shows every tile at about the same texels per pixel, so one width reads alike across the view, where a 150 km threshold left the finer tiles under the camera thin and cream beside bold ones further out. Tiles over 150 km (`PROVINCE_LINES_TILE_M`) leave out provinces and borders at sea, a grey haze there. 2.8 px cream was still "not clear". A dark casing under it was tried and read as a smudge once shrunk ("vague, not pretty"). `render_revision` now measures the synthetic border at a globe tile's size too. ## Place names `systems::place_names` reads `place_labels` and `public_transport` from the vector tiles at z10 (towns, kept to 250 km up), z12 (districts, to 30 km) and z13 (stations, to 20 km) around the camera, and lays them out over the map (`place_names::lay_out_place_names`) for the component library to draw (`lib_place_names`; egui painted them until 2026-11-26). Each kind has a distance it is named to (`shows`), and names are placed biggest place first with room around district names, because at 3 km a tile holds dozens of neighbourhoods and the first build wrote all of them. Villages, hamlets and localities are left out. A station gets its name only when it starts with a loaded town's name (rail stations do; metro and tram stops get the icon). **Countries** take over from 250 km up, where the town tiles stop: Natural Earth's admin-0 label point, population estimate and `MIN_LABEL`, written by `atlas countries` to `assets/globe/countries.tsv` and embedded (`cartopolis_geo::countries`), because the tiles carry neither a country's population nor a good point for its name. A country is named once the camera is under 60,000 km / 2^`MIN_LABEL` (France ~18,500 km, the Netherlands 3,750 km, Luxembourg 1,150 km; at 80,000 km the whole globe carried ~25 names and looked odd), and only on the lit side as the globe draws it (`sunlit`): over the night side a name floated in the black, in the town banner a size up without the dot. Names are English, as the rest of the interface is; Natural Earth carries `NAME_NL` and the other languages should the app get a language setting. Every drawn name is a click target (2026-11-02): a click or a long press opens the map's action ring on the place (`ContextMenuState::place`), offering only Go there, Route here and Lenses (asked to keep it short, 2026-11-02); Lenses centres the place under the crosshair, the "here" a lens reads, and puts up the shelf (`scenario::open_shelf`). Each name is its own library node that takes the tap, as a saved pin is, so the world's click handlers do not act on the ground underneath it; the tap comes back to `lay_out_place_names` the frame after. ## From above: clouds as a setting, the night side **Clouds** from above are Layers ▸ Map ▸ From above, off / light / full, **off by default** (`GlobeCloudMode`). It governs the globe's shell only; Settings ▸ World ▸ Clouds still turns every cloud off, the street's included. A scripted capture never reads the saved setting, so `CARTO_GLOBE_CLOUDS=off|light|full` sets it for one. **The night side** follows the real sun's direction (`update_globe_night`), not the directional light: at night over the map anchor the sun light is dimmed to nothing, and a terminator read from it would put the whole globe in the dark. **City lights have no data of their own.** A globe tile is painted, and built-up land is painted in exactly three tones, from the land cover and OSM alike; so `globe::lights_mask` reads them off the tile's own pixels into an R8 mip chain. That also means a tile read back from the disk cache has its lights, with no second cache entry. The design drew them from Natural Earth's urban areas; this is WorldCover's built-up class instead, which is denser in the east. **Brightness, measured** (mac-1, 2026-10-31, 8,000 km, 17:30 UTC): the emissive is added before exposure and blooms, so it saturates long before it looks bright. At 9000/6500/3400 the lights were balls and the night side an orange wash; cutting it 8× dimmed the frame by only a quarter. `CITY_LIGHT` at 160/115/60 gives separate points of light on a dark ground. The flat map near the anchor (drawn to 250 km up) has no night side or lights; from orbit it is a small patch, not looked at yet. ## The hex grid is one grid in Mercator, off by default Layers ▸ Map ▸ From above ▸ Hex grid, **off by default** (decided 2026-10-30: a layer, not part of the base map); `CARTO_HEX_GRID=1` turns it on for a capture. `hex_grid.wesl` lays it in Web Mercator's unit square from each tile's own key (`map_stream::hex_tile`) and UV, so the flat clipmap tiles and the globe's draw the same lines; measured 2026-10-31 at 350 km over the Netherlands, the vertical sides fall 47 px apart on both tiers, the expected ~9 km cell. It is drawn over land only (the tile's water mask), between ~100 and ~4,000 km from the camera. The cell's sides are normal to the lattice's six neighbours, at 0° and ±60°; the first build used ±30° and drew bow-ties at every vertex. ## Borders between countries Borders between countries are the v1-macro mockup's thin cream (`palette::painted::NEIGHBOUR_BORDER`), provinces and borders at sea the grey `BOUNDARY`. No recorded tile crosses a country border, so the render-revision measure draws a synthetic one. The mockup also outlined the Netherlands whole in orange with an inward glow, and from 2026-11-02 the far map did too (`paint_country`, fed Natural Earth's `ne-admin0-europe` by `systems::home_country`). Removed 2026-11-10 at the owner's request: it did not render well from space, where the zoom from the globe to the city passes over it. `atlas areas ne-admin0-europe` still writes the outline; nothing in the client reads it.