Skip to content

Add tools/maphd.py: a sharper world map from the player's own files - #1138

Closed
Zarigis wants to merge 1 commit into
Revivedx:testfrom
Zarigis:maphd-tool
Closed

Zarigis wants to merge 1 commit into
Revivedx:testfrom
Zarigis:maphd-tool

Conversation

@Zarigis

@Zarigis Zarigis commented Nov 26, 2026

Copy link
Copy Markdown

Adds tools/maphd.py, which makes a sharper world map from the player's own game files. Every map tile is cleaned with Real-ESRGAN, and the result is a Mods tab mod.

python3 tools/maphd.py <game files folder> mods/MapHD --esrgan <realesrgan-ncnn-vulkan> [--scale 1|2]

--scale 1 (the default) cleans the map's blocky compression and soft edges, and keeps each tile at its own size. --scale 2 also stores the two closest zoom levels at twice the size, for windows above 1080p. That needs #1137 to show anything. Without it, the map is drawn at 1080 lines whatever the window, and the bigger tiles are just shrunk back.

What this changes

New tool, test, Makefile target (make test-maphd), and a paragraph in the FAQ under "Can I use mods?". No runtime changes.

What the tool does

The map has four zoom levels, each 586 tiles (UI/MapTex/MainField/MapTex{,1,2,3}_*.sbmaptex), BC1 textures in BFRES/BNTX. For each tile, the tool:

  1. Decodes it with a border taken from its neighbours (the grid is Z, A–K by 0–9), so the seams match.
  2. Runs Real-ESRGAN (realesr-animevideov3, 2×), once per level, over the level's folder. Each level is cleaned on its own: the coarser levels are drawn separately with fewer contour lines, not reduced copies.
  3. Scales back with Lanczos, crops the border, and compresses to BC1 again (a numpy encoder: principal axis, a single-colour fit for flat blocks, two least-squares passes).

With --scale 2, the closest level (3000 → 6000 pixels a tile) is Real-ESRGAN's image itself. The medium level (840 → 1680) is reduced from the closest level's image, so it shows the detailed drawing rather than the game's simpler one at that zoom. A bigger tile grows its BNTX, and the BFRES around it: the embedded-file entry, the relocation table's section over the BNTX, and the file size. The two coarsest levels are as with --scale 1.

Requirements: the player supplies realesrgan-ncnn-vulkan (the "ncnn Vulkan" download from Real-ESRGAN's releases page) with its models/ folder. The tool needs numpy and Pillow. The in-between images go to a work folder, about 20 GB, so a stopped run carries on where it was.

No ResourceSizeTable and no extra memory needed: the tiles are loose files, so Savage Wind grows their entries itself (#898). With only the --scale 2 tiles as a mod and the game's own memory, it grew all 1,172 entries, and the map opened and zoomed at both bigger levels.

The output is made from the player's game files, so the tool's help and the FAQ say not to share it. Nothing is downloaded, and nothing outside the mod and work folders is written.

How it was tested

Windows 11, RTX 4080 SUPER, NVIDIA 617.42, 3840×2160, game 1.9.0, on test at 2a51d02.

  • The whole map was made at both scales with the scripts this tool was ported from: 586 tiles × 4 levels, about 84 minutes for --scale 2, most of it the closest level. Both were played in game.
  • The tool's output matches those scripts exactly. Sample tiles from every level, including variants, are byte-identical at both scales. So are the padded images, edges and corners included, and Real-ESRGAN's output.
  • make test-maphd: 22 checks on synthetic tiles. It covers Yaz0, the block-linear swizzle, BC1, reading and growing a tile, the neighbour borders, both scales, the medium level built from the closest, and the fallback when the closest image is missing.
More detail and caveats

Checklist

  • Based on the latest test and opened against test
  • Built and run locally, and checked in the game
  • No game files, keys, firmware, generated game code or save files in the changes

Every map tile (four zoom levels, 586 tiles each, BC1) is decoded with a
border from its neighbours, cleaned with Real-ESRGAN (realesr-animevideov3,
2x; the player supplies realesrgan-ncnn-vulkan), scaled back and compressed
to BC1 again, as a Mods tab mod.

--scale 2 stores the two closest zoom levels at twice the size (the closest
level is Real-ESRGAN's image, the medium one is reduced from it). That only
shows more detail with the map drawn at the window's resolution (Revivedx#1137).
Savage Wind grows the bigger tiles' ResourceSizeTable entries itself.

tools/test_maphd.py checks it on synthetic tiles (make test-maphd). The
FAQ mentions it under "Can I use mods?".
@Zarigis
Zarigis marked this pull request as ready for review November 26, 2026 02:07
@Revivedx

Copy link
Copy Markdown
Owner

Thanks @Zarigis! A sharper map made from the player's own files is a nice idea, and the tests are thorough. Like #1136, mod making goes in SWMM+ (https://github.com/Revivedx/SWMMPlus) rather than in Savage Wind. Could you bring it there as a PR? #1137 (the map drawn at the window's resolution) is going into our next batch, so the --scale 2 tiles will show their detail. Closing here in favour of SWMM+.

@Revivedx Revivedx closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants