Place all nine maps onto a north-up geographic world canvas
The canvas is no longer an abstract grid of unrelated cells. overall.jpeg is now the base, rotated 31 degrees so north is up, and every detail map is scaled and positioned onto its real location. Zoom out for all of Tarkov; zoom in and the full-resolution re3mr map takes over. The 31 degrees was measured, not guessed: Customs' detail map is north-up (its PSD compass confirms it) and runs 2.6:1 east-west, so solving its 259x207 zone outline for the band angle gives 31. rotate_point is verified sub-pixel against PIL. Adds Woods, Interchange, Reserve, Shoreline, Shoreline Resort, Lighthouse and Streets, and moves every source under sources/<id>/. baseGroup becomes baseLayers, a list of slash-paths. These PSDs share no naming convention at all -- the base is variously LOCATION, Baselayer, Day, 3DRENDER, BASEMAP+2DLAYERS or Map&Art; several need more than one top-level layer, and Woods buries its terrain three groups deep. Exports also keep alpha now, so maps composite onto the terrain instead of sitting in opaque rectangles. Placement needs sub-cell precision, but tile grids stay integral only when a map's origin is a multiple of tileSize * 2^maxZoom (131072 px). So rather than snapping a map to the grid, the tiler pads it up-and-left to the nearest cell boundary and visits only tiles holding content: exact placement, integral grid, no cost. Each map is tiled to its native level and carries a minZoom, so the overview stays cheap. Two psd-tools failures worked around: stroke effects on empty-bbox layers crash scikit-image (patched to skip), and psd_tools.composite exports a function that shadows its own submodule. Verified zoom 0-9: 10 layers, zero broken tiles. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
f997c2c5e2
commit
e8d8738892
13 files changed
+756
-372
No files matched your search
+83
-71
@@ -1,7 +1,7 @@
|
||||
# Adding a map
|
||||
|
||||
The whole job is: point the config at a PSD, name the group that holds the map
|
||||
art, pick a grid cell, build. Everything else is automatic.
|
||||
Point the config at a PSD, name the layers holding the map art, say where it
|
||||
goes on the world map, build. No application code changes.
|
||||
|
||||
Budget ~10 minutes plus render time (roughly 3 minutes per GB of PSD).
|
||||
|
||||
@@ -13,27 +13,36 @@ Budget ~10 minutes plus render time (roughly 3 minutes per GB of PSD).
|
||||
python -m pip install -r tools/requirements.txt
|
||||
```
|
||||
|
||||
Put the PSD under `sources/<area>/`. That directory is gitignored — source art
|
||||
Put the PSD under `sources/<id>/`. That directory is gitignored — source art
|
||||
lives on the shared drive, never in the repo.
|
||||
|
||||
---
|
||||
|
||||
## 1. Look at the layer tree
|
||||
## 1. Find the layers holding the map art
|
||||
|
||||
```bash
|
||||
python tools/psd_tree.py sources/customs/customs.psd
|
||||
python tools/psd_tree.py sources/woods/woods.psd --depth 2
|
||||
```
|
||||
|
||||
You are answering two questions.
|
||||
**There is no naming convention.** Every re3mr map does this differently, so
|
||||
you have to look each time:
|
||||
|
||||
**Which top-level group holds the map art?** On every re3mr map so far it is
|
||||
`LOCATION`, sitting next to `OVERLAY`/`OVERLAYS`, `LEGEND` and `TITLE`. Only the
|
||||
group you name gets rendered, so markers, legends, captions and titles are
|
||||
dropped by construction — you never have to hide them one by one.
|
||||
| Map | Base layers |
|
||||
| --- | --- |
|
||||
| Customs, Customs Dorms | `LOCATION` |
|
||||
| Woods | `re3mr.com/Map&Art` (nested inside a wrapper group) |
|
||||
| Lighthouse | `Day` (there is also a hidden `Night`) |
|
||||
| Shoreline | `Baselayer` |
|
||||
| Shoreline Resort | `BGCOLOR PATTERN`, `BASEMAP+2DLAYERS` |
|
||||
| Interchange | `Background`, `3DRENDER` |
|
||||
| Reserve | `Day copy`, `Color Fill 1`, `Group 5` |
|
||||
| Streets | `Layer 1`, `Map - 3D map portion…` |
|
||||
|
||||
**Are there `shape` layers inside it?** Note their names. psd-tools renders a
|
||||
stroke-only vector shape as a *solid fill*, which can bury the entire map under
|
||||
one flat colour. These go in `excludeLayers` at step 3.
|
||||
Note the two shapes this takes: several maps need **more than one** top-level
|
||||
layer, and some bury the art **inside a wrapper group** (use a slash path).
|
||||
|
||||
Also note any `shape` layers — psd-tools renders stroke-only vector shapes as
|
||||
solid fills, so they may need `excludeLayers`.
|
||||
|
||||
---
|
||||
|
||||
@@ -41,111 +50,114 @@ one flat colour. These go in `excludeLayers` at step 3.
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "factory",
|
||||
"name": "Factory",
|
||||
"psd": "sources/factory/factory.psd",
|
||||
"baseGroup": "LOCATION",
|
||||
"id": "woods",
|
||||
"name": "Woods",
|
||||
"psd": "sources/woods/woods.psd",
|
||||
"baseLayers": ["re3mr.com/Map&Art"],
|
||||
"excludeLayers": [],
|
||||
"crop": null,
|
||||
"cell": [2, 0]
|
||||
"place": { "cx": 818, "cy": 652, "w": 380 }
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Meaning |
|
||||
| --- | --- |
|
||||
| `id` | URL-safe; becomes `web/tiles/<id>/` |
|
||||
| `baseGroup` | the group from step 1 |
|
||||
| `excludeLayers` | layer names to hide anywhere inside `baseGroup` |
|
||||
| `baseLayers` | slash-paths from the document root; everything else is hidden |
|
||||
| `excludeLayers` | layer names to hide anywhere inside the kept set |
|
||||
| `crop` | `[x0, y0, x1, y1]` in PSD pixels, or `null` for the full canvas |
|
||||
| `cell` | `[col, row]` on the world grid — omit it and the next free cell is used |
|
||||
| `place` | where it sits on the world map — see step 4 |
|
||||
| `pxPerMeter` | optional, from the map's scale bar; recorded for later use |
|
||||
|
||||
A map must fit inside one grid cell: **8192 × 8192 px** at the default
|
||||
`maxZoom: 5`. The build fails with a clear message if it doesn't; raising
|
||||
`maxZoom` by one doubles the cell.
|
||||
|
||||
---
|
||||
|
||||
## 3. Render the base layer and check it
|
||||
## 3. Render the base layer and look at it
|
||||
|
||||
```bash
|
||||
python tools/export_base.py factory
|
||||
python tools/export_base.py woods
|
||||
```
|
||||
|
||||
Open `build/factory/base.png` and actually look at it. You are checking for:
|
||||
Open `build/woods/base.png` and check for:
|
||||
|
||||
- **large flat areas of solid colour** — a shape layer is filling. Add its name
|
||||
to `excludeLayers` and re-run. (Customs needs `"Map Borders"` for exactly
|
||||
this reason; without it the whole playable area renders white.)
|
||||
- **leftover markers or text** — you named the wrong group, or the art has
|
||||
markers nested inside the base group.
|
||||
- **how much dead canvas surrounds the art** — that sets your `crop`.
|
||||
to `excludeLayers`. (Customs needs `"Map Borders"`; without it the whole
|
||||
playable area renders white.)
|
||||
- **leftover markers, legends or titles** — wrong `baseLayers`.
|
||||
- **missing terrain** — you kept the overlay group but not the art beneath it.
|
||||
- **dead canvas around the art** — that sets your `crop`.
|
||||
|
||||
Re-run after any `maps.json` change; `export_base.py` always re-renders.
|
||||
A failed map no longer aborts the batch; check the summary at the end.
|
||||
|
||||
---
|
||||
|
||||
## 4. Set the crop
|
||||
## 4. Position it on the world map
|
||||
|
||||
Read the pixel bounds of the real map art off `base.png` and put them in
|
||||
`crop`. Customs uses `[0, 860, 7832, 3875]` — the PSD reserves the top ~860 px
|
||||
for the title bar and everything below y=3875 for the legend, and tiling that
|
||||
empty space just makes the map awkward to pan.
|
||||
The base of the canvas is `sources/overall/overall.jpeg`, rotated by
|
||||
`world.rotate` (31°) so north is up. `place` is in **rotated overall-map
|
||||
pixels** — the north-up image you actually look at.
|
||||
|
||||
If the art fills the canvas, leave `crop: null`.
|
||||
```bash
|
||||
python tools/place_preview.py
|
||||
```
|
||||
|
||||
That writes `build/place-preview.png`: the rotated base with a 100 px grid and
|
||||
every current `place` box drawn on it. Read the coordinates for your zone
|
||||
straight off the grid, set `cx`/`cy`/`w`, re-run. The loop takes seconds
|
||||
because nothing is tiled.
|
||||
|
||||
`w` is the map's width in overall-map pixels; height follows from the source
|
||||
aspect ratio. Positions are deliberately approximate — the game's individual
|
||||
maps are not drawn to match the satellite view exactly, so aim for "clearly the
|
||||
right place", not pixel alignment.
|
||||
|
||||
---
|
||||
|
||||
## 5. Build and verify
|
||||
|
||||
```bash
|
||||
python tools/build.py factory # export if stale, then tile, then manifest
|
||||
python tools/preview.py 3 # stitch every map into one overview
|
||||
python tools/build.py woods
|
||||
```
|
||||
|
||||
`build/world-preview.png` shows all maps at their world positions. Confirm the
|
||||
new one landed in the cell you intended and doesn't collide with a neighbour.
|
||||
|
||||
Then:
|
||||
|
||||
```bash
|
||||
python server/serve.py
|
||||
python tools/preview.py 4
|
||||
```
|
||||
|
||||
and open the printed URL.
|
||||
`build/world-preview.png` composites everything at its world position. Then:
|
||||
|
||||
```bash
|
||||
pwsh server/run.ps1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Useful variations
|
||||
|
||||
```bash
|
||||
python tools/build.py # every map
|
||||
python tools/build.py --tiles-only # re-tile after a crop change, skip the slow render
|
||||
python tools/build.py --force-export # re-render even if base.png looks current
|
||||
python tools/build.py # base + every map
|
||||
python tools/build.py overall # just retile the base map
|
||||
python tools/build.py --tiles-only # re-tile after a place/crop change
|
||||
python tools/build.py --force-export # re-render even if base.png is current
|
||||
```
|
||||
|
||||
`build.py` skips the PSD render when `base.png` is newer than the PSD, so
|
||||
iterating on `crop` is fast — that loop is seconds, not minutes.
|
||||
|
||||
Rebuilding one map never touches another map's tiles, and `world.json` keeps
|
||||
entries for maps that weren't part of this run.
|
||||
iterating on `place` and `crop` is seconds, not minutes.
|
||||
|
||||
---
|
||||
|
||||
## Why the grid works
|
||||
## How placement works
|
||||
|
||||
Every map is tiled independently, numbered from its own top-left corner. The
|
||||
world places a map in grid cell `(gx, gy)` at world pixel
|
||||
`(gx · cellSize, gy · cellSize)`, where
|
||||
World pixels are overall-map pixels × `world.overallScale` (64), chosen so the
|
||||
detail maps land near their native resolution — Customs works out to almost
|
||||
exactly its 7832 px source width.
|
||||
|
||||
```
|
||||
cellSize = tileSize · 2^maxZoom = 256 · 32 = 8192
|
||||
```
|
||||
Tile grids have to stay integral: a map's tile-index offset must be a whole
|
||||
number of tiles at every zoom, which only holds when its origin is a multiple
|
||||
of `tileSize · 2^maxZoom`. That is 131 072 world pixels — far too coarse to
|
||||
position anything. So rather than *moving* a map onto the grid, the tiler
|
||||
**pads** it: the raster is padded up-and-left to the nearest cell boundary and
|
||||
only tiles containing real content are ever visited. Exact placement, integral
|
||||
grid, and the padding costs nothing.
|
||||
|
||||
At that cell size the tile-index shift for a cell is exactly `gx · 2^z` at
|
||||
every zoom level — always a whole number. So the browser can translate world
|
||||
tile coordinates into a map's local ones with integer arithmetic and no
|
||||
resampling (`getTileUrl` in `web/app.js`).
|
||||
|
||||
That is what lets you add a map without re-tiling any other map, and what keeps
|
||||
unrelated maps sharing one continuous canvas.
|
||||
Each map is also only tiled down to its **native level** — the deepest zoom at
|
||||
which we are still downscaling its source. Past that the browser upscales,
|
||||
which looks the same as upscaling during the build but without storing tiles.
|
||||
`minZoom` likewise stops a map loading while it would be a speck on screen.
|
||||
Reference in new issue
Block a user