Skip to content

feat(examples): add a MultiCOGLayer explainer - #761

Merged
kylebarron merged 21 commits into
mainfrom
kyle/multi-cog-explainer
Oct 21, 2026
Merged

kylebarron merged 21 commits into
mainfrom
kyle/multi-cog-explainer

Conversation

@kylebarron

@kylebarron kylebarron commented Oct 21, 2026 •

Copy link
Copy Markdown
Member
walk-1920x1080-step1 walk-1920x1080-step2 walk-1920x1080-step3 walk-1920x1080-step4 walk-1920x1080-step5 walk-1920x1080-step6 walk-1920x1080-step7 walk-1920x1080-step8 walk-1920x1080-step9

Note

This PR was written by Claude (Claude Code), not by @kylebarron.

Adds examples/explainers/multi-cog-explainer, a step-by-step animation of how MultiCOGLayer draws bands stored at different resolutions as one image. Like the reprojection explainer, it works both as a talk prop and on its own.

It follows one real Sentinel-2 tile (scene S2C_18FXJ_20260406_0_L2A over Torres del Paine, tile (4, 4) of B04) through nine steps:

  1. Three files, one scene: B04 (10 m), B11 (20 m) and B01 (60 m) side by side, with insets of the same 600 m square.
  2. One image: the whole scene composited by the layer's shader (B11 as red, B04 as green, B01 as blue), from each band's smallest overview.
  3. The primary grid: the finest band's 11 x 11 grid of 1024 px tiles.
  4. Every band has its own tiles: one 20 m tile covers the primary tile, but the 60 m grid doesn't line up with it, so it takes four 60 m tiles.
  5. Fetch: the covering tiles, 1024 or 256 px each, covering very different ground.
  6. Stitch: the four 60 m tiles become one 512 x 512 texture.
  7. Where the tile lands: each band's UV transform, drawn on its texture.
  8. Sample: a probe samples all three textures at uv * scale + offset, and bars show the values becoming red, green and blue.
  9. The tile on the map: the composited tile flies back into its place.

The explainer doesn't use MultiCOGLayer itself. It calls the building blocks the layer calls (selectSecondaryLevel, resolveSecondaryTiles, fetchTiles and assembleTiles), so every grid, covering tile, UV transform and texel coordinate on screen comes from the library. It draws composites with RasterLayer and the CompositeBands module. The data is read live from the sentinel-cogs bucket (about 5 MB). At startup the explainer checks each file's geometry against src/scene/constants.ts, and fails with a message naming the band and field if the files have changed.

Also included:

  • a card in the Explainers section of the docs examples page;
  • the design spec, dev-docs/specs/2026-10-20-multi-cog-explainer-design.md.

As with the reprojection explainer, the code is LLM-generated and unreviewed (see its README).

Closes #757

🤖 Written by Claude Code

kylebarron and others added 20 commits October 21, 2026 11:10
Spec for an "anatomy of a tile" explainer that follows one Sentinel-2
tile through MultiCOGLayer's pipeline: each band's own tile grid, the
covering tiles, stitching, the UV transforms, and sampling. Tracked in
#757.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RasterLayer runs in the slide's OrthographicView with identity reprojection functions, a cartesian coordinate system and a modelMatrix placement; moving the rect keeps the mesh (checked in Chrome), so no custom quad layer is needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The flights were bitmaps, which drew under every composite, so the tiles slid out from under the scene instead of lifting off it. Bitmaps marked `above` now draw after the composites.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the layer does

The explainer passed selectSecondaryLevel a one-item list, so the level choice was made by hand. It now builds each band's levels coarsest first, as MultiCOGLayer does, passes the chosen index as secondaryZ, and fetches from that level's image, as the layer's selectImage does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd what the shader runs per

Sentinel-2 itself ships JPEG2000; the COGs are the AWS archive's. The band-to-color mapping is the app's choice, not the layer's. And the shader runs once per screen pixel the tile covers, not once per texel of the tile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The white boxes marking where each inset looks disappeared on snow in B04 and B01. They and the inset frames now use the band's color over a dark halo.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
loadScene reports each band's header, covering tiles and overview as they arrive, and the loading screen shows a spinner and a bar, so a slow network at a venue reads as loading rather than stuck.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the feat label Oct 21, 2026

@kylebarron kylebarron left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing; this will be good to explain from

@kylebarron
kylebarron merged commit 180fc5a into main Oct 21, 2026
4 checks passed
@kylebarron
kylebarron deleted the kyle/multi-cog-explainer branch October 21, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a MultiCOGLayer explainer: anatomy of a tile

1 participant