From 394e8faef2adf56c30faafd2cd3b99e4c5619779 Mon Sep 17 00:00:00 2001 From: Axel Meyer Date: Thu, 21 May 2026 22:53:30 +0200 Subject: [PATCH] Bake stub atlas-sets for demo_tilemap and walls_tilemap Replaces the legacy color-only *.tilemap.json fixtures with baked 2-tile atlas-sets in the new atlases//{diffuse,height,atlas-json, lock-json} layout. Stub PNGs are 32x32 solid colors matching the previous color values; height channel is synthesized L8=0 by the baker. A scripts/bake.sh re-bake helper drives the atlas-baker tool against assets/_sources/. Co-Authored-By: Claude Opus 4.7 (1M context) --- assets/_sources/_gen.js | 21 +++++++++++ .../_sources/demo_tilemap/grass_diffuse.png | Bin 0 -> 128 bytes .../_sources/demo_tilemap/stone_diffuse.png | Bin 0 -> 125 bytes .../walls_tilemap/wall_brick_diffuse.png | Bin 0 -> 128 bytes .../walls_tilemap/wall_wood_diffuse.png | Bin 0 -> 128 bytes assets/atlases/demo_tilemap/tiles.atlas.json | 31 ++++++++++++++++ .../demo_tilemap/tiles.atlas.lock.json | 9 +++++ .../demo_tilemap/tiles.diffuse.atlas.png | Bin 0 -> 162 bytes .../demo_tilemap/tiles.height.atlas.png | Bin 0 -> 176 bytes assets/atlases/walls_tilemap/tiles.atlas.json | 33 ++++++++++++++++++ .../walls_tilemap/tiles.atlas.lock.json | 9 +++++ .../walls_tilemap/tiles.diffuse.atlas.png | Bin 0 -> 161 bytes .../walls_tilemap/tiles.height.atlas.png | Bin 0 -> 176 bytes assets/tiles/demo_tilemap.tilemap.json | 8 ----- assets/tiles/walls_tilemap.tilemap.json | 8 ----- scripts/bake.sh | 19 ++++++++++ 16 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 assets/_sources/_gen.js create mode 100644 assets/_sources/demo_tilemap/grass_diffuse.png create mode 100644 assets/_sources/demo_tilemap/stone_diffuse.png create mode 100644 assets/_sources/walls_tilemap/wall_brick_diffuse.png create mode 100644 assets/_sources/walls_tilemap/wall_wood_diffuse.png create mode 100644 assets/atlases/demo_tilemap/tiles.atlas.json create mode 100644 assets/atlases/demo_tilemap/tiles.atlas.lock.json create mode 100644 assets/atlases/demo_tilemap/tiles.diffuse.atlas.png create mode 100644 assets/atlases/demo_tilemap/tiles.height.atlas.png create mode 100644 assets/atlases/walls_tilemap/tiles.atlas.json create mode 100644 assets/atlases/walls_tilemap/tiles.atlas.lock.json create mode 100644 assets/atlases/walls_tilemap/tiles.diffuse.atlas.png create mode 100644 assets/atlases/walls_tilemap/tiles.height.atlas.png delete mode 100644 assets/tiles/demo_tilemap.tilemap.json delete mode 100644 assets/tiles/walls_tilemap.tilemap.json create mode 100644 scripts/bake.sh diff --git a/assets/_sources/_gen.js b/assets/_sources/_gen.js new file mode 100644 index 0000000..6768a36 --- /dev/null +++ b/assets/_sources/_gen.js @@ -0,0 +1,21 @@ +const { PNG } = require('pngjs'); +const fs = require('node:fs'); +const path = require('node:path'); + +function writeSolidRGBA(p, w, h, rgba) { + const png = new PNG({ width: w, height: h }); + for (let i = 0; i < png.data.length; i += 4) { + png.data[i + 0] = rgba[0]; + png.data[i + 1] = rgba[1]; + png.data[i + 2] = rgba[2]; + png.data[i + 3] = rgba[3]; + } + fs.writeFileSync(p, PNG.sync.write(png)); +} + +const SOURCES = path.resolve(__dirname); +writeSolidRGBA(path.join(SOURCES, 'demo_tilemap', 'grass_diffuse.png'), 32, 32, [110, 170, 80, 255]); +writeSolidRGBA(path.join(SOURCES, 'demo_tilemap', 'stone_diffuse.png'), 32, 32, [120, 120, 120, 255]); +writeSolidRGBA(path.join(SOURCES, 'walls_tilemap', 'wall_brick_diffuse.png'), 32, 32, [180, 100, 80, 255]); +writeSolidRGBA(path.join(SOURCES, 'walls_tilemap', 'wall_wood_diffuse.png'), 32, 32, [140, 90, 50, 255]); +console.log('test-stub sources generated'); diff --git a/assets/_sources/demo_tilemap/grass_diffuse.png b/assets/_sources/demo_tilemap/grass_diffuse.png new file mode 100644 index 0000000000000000000000000000000000000000..da75774c959d9a096131a9ed6348f00130b0c1b4 GIT binary patch literal 128 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzcTX3`kP6152N@X|6nGj8{G29B xoS9_DcKc4bonoh_Pm<8&8Anvq3<)r|oms`S{Pz7*pMXX(c)I$ztaD0e0sv9sC=CDr literal 0 HcmV?d00001 diff --git a/assets/_sources/demo_tilemap/stone_diffuse.png b/assets/_sources/demo_tilemap/stone_diffuse.png new file mode 100644 index 0000000000000000000000000000000000000000..7991b4cc862c6ef89431ce690911a06c6b850b57 GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz7f%<*kP6152N@X|40xIi`d;n2 tpE_YruDeH)(Bv6MRMZSRJ$(o;YtQsBEmu+Bp$9aN!PC{xWt~$(6965%C6@pI literal 0 HcmV?d00001 diff --git a/assets/_sources/walls_tilemap/wall_brick_diffuse.png b/assets/_sources/walls_tilemap/wall_brick_diffuse.png new file mode 100644 index 0000000000000000000000000000000000000000..7811e7cc7d056a00f0fc376ab950345e6a59a003 GIT binary patch literal 128 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzcTX3`kP6152N@X|6nGj8{G6O6 wF4ozx-QH7er`YM~lO!~G#t{`YLjufgXFf13?@3|e1RBZU>FVdQ&MBb@01=KQT>t<8 literal 0 HcmV?d00001 diff --git a/assets/_sources/walls_tilemap/wall_wood_diffuse.png b/assets/_sources/walls_tilemap/wall_wood_diffuse.png new file mode 100644 index 0000000000000000000000000000000000000000..69085d1a2eae87d2893f2a644979ba3859291154 GIT binary patch literal 128 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzcTX3`kP6152N@X|6nGj8{8S## wIC;*F?e?B(JH<{}4SVqiFOV1l}r z)^aZ`9>a)5MplPYzn9jYljpCh=bxwYIAu=HB?`81Nici2FaU kT(PlT*sM_4oQ6m~U<+fttXTXFpc5E8UHx3vIVCg!09&mqpa1{> literal 0 HcmV?d00001 diff --git a/assets/atlases/walls_tilemap/tiles.atlas.json b/assets/atlases/walls_tilemap/tiles.atlas.json new file mode 100644 index 0000000..f7fe07a --- /dev/null +++ b/assets/atlases/walls_tilemap/tiles.atlas.json @@ -0,0 +1,33 @@ +{ + "atlas_id": "walls_tilemap", + "atlas_version": 1, + "atlas_size_px": [ + 64, + 64 + ], + "tile_size_px": 32, + "tiles": [ + { + "id": 1, + "name": "wall_brick", + "uv": [ + 0, + 0, + 32, + 32 + ], + "blocks_sight": true + }, + { + "id": 2, + "name": "wall_wood", + "uv": [ + 32, + 0, + 32, + 32 + ], + "blocks_sight": true + } + ] +} diff --git a/assets/atlases/walls_tilemap/tiles.atlas.lock.json b/assets/atlases/walls_tilemap/tiles.atlas.lock.json new file mode 100644 index 0000000..8082971 --- /dev/null +++ b/assets/atlases/walls_tilemap/tiles.atlas.lock.json @@ -0,0 +1,9 @@ +{ + "atlas_id": "walls_tilemap", + "bindings": { + "wall_brick": 1, + "wall_wood": 2 + }, + "deleted": [], + "next_id": 3 +} diff --git a/assets/atlases/walls_tilemap/tiles.diffuse.atlas.png b/assets/atlases/walls_tilemap/tiles.diffuse.atlas.png new file mode 100644 index 0000000000000000000000000000000000000000..dbf9572b29aa2b1135afe4cbb2a6763ae9073fd8 GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=8J;eVAr*{o4>}4SVqiFOK%li_ z#gVR;(t3QD6v#jA> Tp1ZyP?PTzD^>bP0l+XkK$do>s literal 0 HcmV?d00001 diff --git a/assets/atlases/walls_tilemap/tiles.height.atlas.png b/assets/atlases/walls_tilemap/tiles.height.atlas.png new file mode 100644 index 0000000000000000000000000000000000000000..a5d5cf1c51461a2bca2eac8c391333c552669921 GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=<(@8%Ar*{I4>B?`81Nici2FaU kT(PlT*sM_4oQ6m~U<+fttXTXFpc5E8UHx3vIVCg!09&mqpa1{> literal 0 HcmV?d00001 diff --git a/assets/tiles/demo_tilemap.tilemap.json b/assets/tiles/demo_tilemap.tilemap.json deleted file mode 100644 index a5381d2..0000000 --- a/assets/tiles/demo_tilemap.tilemap.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "demo_tilemap", - "tile_size": 32, - "tiles": [ - {"id": "grass", "walkable": true, "color": [110, 170, 80]}, - {"id": "stone", "walkable": false, "color": [120, 120, 120]} - ] -} diff --git a/assets/tiles/walls_tilemap.tilemap.json b/assets/tiles/walls_tilemap.tilemap.json deleted file mode 100644 index 3db2075..0000000 --- a/assets/tiles/walls_tilemap.tilemap.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "walls_tilemap", - "tile_size": 32, - "tiles": [ - {"id": "wall_brick", "walkable": false, "color": [180, 100, 80]}, - {"id": "wall_wood", "walkable": false, "color": [140, 90, 50]} - ] -} diff --git a/scripts/bake.sh b/scripts/bake.sh new file mode 100644 index 0000000..23a79da --- /dev/null +++ b/scripts/bake.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Re-bake the stub atlases used by maps-test fixtures. +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +LIB_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" +BAKER=~/Projects/Sporel/sporel-tool-atlas-baker/bin/atlas-baker.js + +node "$BAKER" \ + --in "$LIB_DIR/assets/_sources/demo_tilemap" \ + --out "$LIB_DIR/assets/atlases/demo_tilemap" \ + --atlas-id demo_tilemap \ + --tile-size 32 + +node "$BAKER" \ + --in "$LIB_DIR/assets/_sources/walls_tilemap" \ + --out "$LIB_DIR/assets/atlases/walls_tilemap" \ + --atlas-id walls_tilemap \ + --tile-size 32 \ + --blocks-sight-pattern '^wall_'