Repository navigation
Render a rectangle of a map, pixel-identical to cropping the whole-map render. - #11
Open
2Pacalypse- wants to merge 1 commit into
Open
2Pacalypse- wants to merge 1 commit into
2Pacalypse- wants to merge 1 commit into
Conversation
…p render. RenderOptions::region (WASM `region`, CLI --region) composites only the terrain under the region plus the resampling kernel's margin and draws only the sprites that can reach it, so tiled viewers never hold a whole full-resolution map.
2Pacalypse-
added a commit
to ShieldBattery/ShieldBattery
that referenced
this pull request
Nov 4, 2026
…'s released. Built from ShieldBattery/broodmap#11 at 2afeb5a. Swap the file: spec for a registry version once it's published.
2Pacalypse-
added a commit
to ShieldBattery/ShieldBattery
that referenced
this pull request
Nov 4, 2026
…'s released. Built from ShieldBattery/broodmap#11 at 2afeb5a. Swap the file: spec for a registry version once it's published.
2Pacalypse-
added a commit
to ShieldBattery/ShieldBattery
that referenced
this pull request
Nov 5, 2026
…icker, highlight and subtract views. (#1885) * Compare maps on their own linkable page, with split, slider, fade, flicker, highlight and subtract views. * Mock the map compare page metadata resolver in the page metadata tests. * Keep map family editor drafts when adding a file, and route compare page map links in the app. * Add a copy link button to the map compare page. * Show full-detail map tiles rendered by the app when zooming in on the map compare page. * Install broodmap from a vendored package with region renders until it's released. Built from ShieldBattery/broodmap#11 at 2afeb5a. Swap the file: spec for a registry version once it's published. * Render map compare tiles one at a time with broodmap's region render.
2Pacalypse-
added a commit
to ShieldBattery/ShieldBattery
that referenced
this pull request
Nov 10, 2026
…icker, highlight and subtract views. (#1885) * Compare maps on their own linkable page, with split, slider, fade, flicker, highlight and subtract views. * Mock the map compare page metadata resolver in the page metadata tests. * Keep map family editor drafts when adding a file, and route compare page map links in the app. * Add a copy link button to the map compare page. * Show full-detail map tiles rendered by the app when zooming in on the map compare page. * Install broodmap from a vendored package with region renders until it's released. Built from ShieldBattery/broodmap#11 at 2afeb5a. Swap the file: spec for a registry version once it's published. * Render map compare tiles one at a time with broodmap's region render.
2Pacalypse-
added a commit
to ShieldBattery/ShieldBattery
that referenced
this pull request
Nov 15, 2026
…icker, highlight and subtract views. (#1885) * Compare maps on their own linkable page, with split, slider, fade, flicker, highlight and subtract views. * Mock the map compare page metadata resolver in the page metadata tests. * Keep map family editor drafts when adding a file, and route compare page map links in the app. * Add a copy link button to the map compare page. * Show full-detail map tiles rendered by the app when zooming in on the map compare page. * Install broodmap from a vendored package with region renders until it's released. Built from ShieldBattery/broodmap#11 at 2afeb5a. Swap the file: spec for a registry version once it's published. * Render map compare tiles one at a time with broodmap's region render.
2Pacalypse-
added a commit
to ShieldBattery/ShieldBattery
that referenced
this pull request
Nov 17, 2026
…icker, highlight and subtract views. (#1885) * Compare maps on their own linkable page, with split, slider, fade, flicker, highlight and subtract views. * Mock the map compare page metadata resolver in the page metadata tests. * Keep map family editor drafts when adding a file, and route compare page map links in the app. * Add a copy link button to the map compare page. * Show full-detail map tiles rendered by the app when zooming in on the map compare page. * Install broodmap from a vendored package with region renders until it's released. Built from ShieldBattery/broodmap#11 at 2afeb5a. Swap the file: spec for a registry version once it's published. * Render map compare tiles one at a time with broodmap's region render.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a region render: a rectangle of a map, rendered pixel-identical to cropping the same rectangle out of a whole-map render. Tiled viewers can then show a map at full detail without anything ever holding the whole full-resolution image (a 256x256 map at 32 px/tile is 8192x8192, 256 MB of RGBA, and the wasm bindings held about three copies of it). ShieldBattery uses it for the map compare page's zoom, rendering 512px tiles on request from the user's own install.
API
RenderOptions::region: Option<TileRect>, withTileRect { x, y, width, height }in map tiles. Every render entry point honours it:render_chk_preview,render_preview,render_terrain,plan_previewandexecute_plan.RenderPlangains aregionfield that's left out of serialized JSON when unset, so older plans still load. The CLI gets--region x,y,w,h.width*pptxheight*pptpixels, clipped to the map; a region entirely off the map gives a 0x0 image. For a fixed density, setsizeto the map's longer side in tiles times the px/tile you want.renderRgba/renderPng/planJsontake"region": { "x", "y", "width", "height" }, plus"maxOutputPixels"for denser renders of big maps (Remastered at 64+ px/tile on a 256x256 map). NewMapRenderOptionsandMapRegiondeclarations, checked bytest:types. The README gets an options table and a tiling recipe;docs/render-design.mdgets a "Region renders" section.requiredGraphics/loadAssetswith aregionlist only that region's art. Without one they cover every region, so a tiling viewer loads once without a region and then renders many tiles.Why it's exact
Cost
Per-tile cost is mostly compositing and filtering the terrain under the tile, so rendering every tile costs about 15% more than one whole-map render. Peak memory is the region's output plus one strip of its tile columns, a few filtered rows and the decoded art of images that land on it.
On
(7)Continental Divide.scm(256x256), native release build, assets in memory:Through wasm in Node: ~0.5 ms per tile against ~250 ms for the whole map at 32 px/tile, and ~12 ms against ~830 ms at 16 px/tile. Loading a 256x256 map's art for tiling from a real install added ~10-45 MB for Original and ~60 MB for Remastered at 128 px/tile.
Testing
overlay.rs(random terrain, sprite art with transparent holes, units with shadows, doodads off every edge, tokens on region boundaries) checks a full tiling plus edge and off-map regions at native resolution and four downscales, down to 1 px/tile. Removing the filter margin makes it fail.real_assets.rs(needsBROODMAP_TEST_SCR_DIR): every 512px tile plus one unaligned region oflt.scm,Impossible_Scen._Future.scx,OcOc_Bound_2(p).scxandSniper_Seed_vA.scx, at Original 32 and 16 px/tile and Remastered 16 px/tile, from assets loaded once for the whole map. All 9 real-asset tests pass against a local SC:R install.renderRgbathe same way, and a Node smoke test through the built package matched 336 tiles across Lost Temple and Continental Divide.cargo fmt --check,cargo clippy --workspace --all-targets --all-features -D warnings,cargo test --workspace, MSRVcargo +1.95 check, nightly check of the fuzz crate, and the wasm pipeline (pnpm test,build,test:package,test:types,build:demo).