Map Tiles
Generates orthographic map tile images at multiple zoom levels for use with web map viewers (e.g., Leaflet). Includes an ImGui control panel with progress tracking.
Generates orthographic map tile images at multiple zoom levels for use with web map viewers (e.g., Leaflet). Includes an ImGui control panel with progress tracking.
Overview
util_maptiles renders the current level from a top-down orthographic camera at multiple zoom levels, producing a tile pyramid suitable for slippy map viewers. Exports tile images as PNG, a metadata JSON file, and an optional navgraph overlay.
Extension path: lua/ge/extensions/util/maptiles.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
onUpdate | (dtReal, dtSim, dtRaw) | Main update loop: renders tiles and UI. |
Internals
Tile Generation Parameters
| Parameter | Default | Description |
|---|---|---|
baseTileSize | 1000 | World units per tile at zoom 0. |
basePixelSize | 512 | Pixel resolution per tile. |
maxZoomLevel | 5 | Maximum zoom level (0 = most zoomed out). |
framesPerTile | 2 | Frames to wait before capturing each tile. |
outputDirectory | "tiles" | Base output directory. |
Rendering Setup
Before generation, rendering settings are adjusted for quality:
TS::detailAdjust→ 20000 (max mesh detail)Terrain::lodScale→ 0.00001 (max terrain detail)groundCoverScale→ 8 (dense vegetation)- Shadows disabled (
sunsky.castShadows = false) - Shadow texture minimized (
texSize = 64)
Settings are restored after completion.
Tile Grid
For each zoom level, tile size = baseTileSize / 2^zoomLevel:
- Tiles are generated left-to-right, top-to-bottom.
- Each tile uses an orthographic
RenderViewpositioned above its center. - Terrain height is determined by raycasting at tile center.
Output Structure
tiles/
{levelName}/
{zoom}/{x}/{y}.png
metadata.json
navgraph.json (optional)Metadata
{
"levelName": {
"baseTileSize": 1000,
"basePixelSize": 512,
"maxZoomLevel": 5,
"terrainSizeUnits": 4000,
"tileGrid": {
"0": { "tileSizeUnits": 1000, "pixelSize": 512, "tilesX": 4, "tilesY": 4 }
}
}
}Navgraph Export
exportNavgraph() converts the road network into polygon data:
- Each road link becomes a quad (4 points) sized by node radii.
- Coordinates are transformed to tile-space.
- Color-coded by drivability level.
- Output:
tiles/navgraph.json.
ImGui Interface
- Progress grid: Color-coded tile status (grey=pending, yellow=current, green=done).
- Preview: Live render view of the current tile.
- ETA: Estimated time remaining based on average per-tile time.
- Debug panel: 3D world toggle, zoom level selector, manual tile stepping.
How It Works
- Load:
extensions.load('util_maptiles'). - Open the ImGui window and click "Start Tile Generation".
- The system iterates through zoom levels 0→5, rendering each tile.
- Tiles are saved as PNG files in the output directory.
- Metadata JSON is written on completion.
Lua Examples
-- Load the map tile utility
extensions.load('util_maptiles')
-- The UI handles all interaction
-- Navgraph can be exported separately via the UI button
-- Coordinate conversion (for custom overlay integration):
-- Game coords → export coords: flip Y, offset by bounds, scale by pixel/tile ratioAdditional Exports
M.onUpdate- (undocumented)