BlueGit

timfa questward

wall texture

timfa Tim Falken · pushed by timfa

Authored 2026-08-31 · 2 months ago

Hash
0896e8da9fa285fc802258126aa39779fdfe2155
Parent
5666b73e
42 files changed +500 −55
client/assets/blocks/_examples/stone-wall/ref-thick-textured-alone-256.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/_examples/stone-wall/ref-thick-textured-variants.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/_examples/stone-wall/ref-thin-textured-alone-256.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/_examples/stone-wall/ref-thin-textured-variants.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-e.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-es.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-esw.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-n.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-ne.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-nes.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-nesw.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-ns.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-s.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-sw.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-swn.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-w.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-we.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-wn.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall-wne.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thick-stone-wall/thick-stone-wall.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-e.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-es.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-esw.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-n.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-ne.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-nes.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-nesw.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-ns.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-s.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-sw.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-swn.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-w.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-we.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-wn.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall-wne.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/blocks/thin-stone-wall/thin-stone-wall.png Binary file +0 −0

The contents of this binary file are not shown.

client/scripts/export-thick-wall-refs.py added +120 −0
@@ -0,0 +1,120 @@
1 #!/usr/bin/env python3
2 """Export face-id / heightmap / upscaled refs from thick-stone-wall alone.
3
4 Run from repo root:
5 python3 client/scripts/export-thick-wall-refs.py
6
7 Requires: Pillow
8 """
9 from __future__ import annotations
10
11 from pathlib import Path
12
13 from PIL import Image, ImageDraw
14
15 ROOT = Path(__file__).resolve().parents[1]
16 ALONE = ROOT / "assets/blocks/_examples/stone-wall/thick-stone-wall.png"
17 OUT = ROOT / "assets/blocks/_examples/stone-wall"
18
19 # Source greys → semantic face roles (see docs/STONE_WALL_SHAPES.md)
20 FACE_RGB = {
21 (175, 175, 175): (255, 255, 255), # N bevel
22 (149, 149, 149): (220, 60, 60), # W face
23 (108, 108, 108): (60, 100, 220), # E face
24 (84, 84, 84): (60, 180, 80), # S face
25 (128, 128, 128): (220, 180, 60), # top plateau
26 (64, 64, 64): (20, 20, 20), # outline
27 }
28
29 HEIGHT = {
30 (64, 64, 64): 40,
31 (84, 84, 84): 80,
32 (108, 108, 108): 140,
33 (149, 149, 149): 160,
34 (128, 128, 128): 200,
35 (175, 175, 175): 220,
36 }
37
38
39 def main() -> None:
40 OUT.mkdir(parents=True, exist_ok=True)
41 alone = Image.open(ALONE).convert("RGBA")
42 w, h = alone.size
43 face = Image.new("RGBA", (w, h), (0, 0, 0, 0))
44 height = Image.new("L", (w, h), 0)
45
46 for y in range(h):
47 for x in range(w):
48 r, g, b, a = alone.getpixel((x, y))
49 if a == 0:
50 continue
51 key = (r, g, b)
52 if key not in FACE_RGB:
53 raise SystemExit(f"Unknown grey {key} at ({x},{y})")
54 fr, fg, fb = FACE_RGB[key]
55 face.putpixel((x, y), (fr, fg, fb, 255))
56 height.putpixel((x, y), HEIGHT[key])
57
58 face.save(OUT / "ref-thick-face-id-16.png")
59 face.resize((w * 16, h * 16), Image.NEAREST).save(OUT / "ref-thick-face-id-256.png")
60 height.save(OUT / "ref-thick-height-16.png")
61 height.resize((w * 16, h * 16), Image.NEAREST).save(OUT / "ref-thick-height-256.png")
62 alone.resize((w * 16, h * 16), Image.NEAREST).save(OUT / "ref-thick-alone-256.png")
63
64 leg = Image.new("RGBA", (280, 200), (30, 30, 30, 255))
65 d = ImageDraw.Draw(leg)
66 items = [
67 ((255, 255, 255), "North bevel 0xAF"),
68 ((220, 60, 60), "West face 0x95"),
69 ((60, 100, 220), "East face 0x6C"),
70 ((60, 180, 80), "South face 0x54"),
71 ((220, 180, 60), "Top plateau 0x80"),
72 ((20, 20, 20), "Outline 0x40"),
73 ]
74 for i, (c, label) in enumerate(items):
75 yy = 16 + i * 28
76 d.rectangle([16, yy, 40, yy + 20], fill=(*c, 255))
77 d.text((52, yy + 2), label, fill=(230, 230, 230, 255))
78 leg.save(OUT / "ref-thick-face-legend.png")
79
80 # Labeled contact sheet of all 16 thick *shape* states (bit order).
81 wall_dir = OUT
82 names = [
83 ("alone", "thick-stone-wall.png"),
84 ("n", "thick-stone-wall-n.png"),
85 ("e", "thick-stone-wall-e.png"),
86 ("ne", "thick-stone-wall-ne.png"),
87 ("s", "thick-stone-wall-s.png"),
88 ("ns", "thick-stone-wall-ns.png"),
89 ("es", "thick-stone-wall-es.png"),
90 ("nes", "thick-stone-wall-nes.png"),
91 ("w", "thick-stone-wall-w.png"),
92 ("wn", "thick-stone-wall-wn.png"),
93 ("we", "thick-stone-wall-we.png"),
94 ("wne", "thick-stone-wall-wne.png"),
95 ("sw", "thick-stone-wall-sw.png"),
96 ("swn", "thick-stone-wall-swn.png"),
97 ("esw", "thick-stone-wall-esw.png"),
98 ("nesw", "thick-stone-wall-nesw.png"),
99 ]
100 scale, pad, label_h, cols = 8, 28, 14, 4
101 cell = 16 * scale
102 rows = 4
103 sheet_w = cols * cell + (cols + 1) * pad
104 sheet_h = rows * (cell + label_h) + (rows + 1) * pad
105 sheet = Image.new("RGBA", (sheet_w, sheet_h), (24, 24, 28, 255))
106 draw = ImageDraw.Draw(sheet)
107 for i, (label, fname) in enumerate(names):
108 r, c = divmod(i, cols)
109 x = pad + c * (cell + pad)
110 y = pad + r * (cell + label_h + pad)
111 im = Image.open(wall_dir / fname).convert("RGBA").resize((cell, cell), Image.NEAREST)
112 sheet.paste(im, (x, y), im)
113 draw.text((x, y + cell + 2), label, fill=(220, 220, 220, 255))
114 sheet.save(OUT / "ref-thick-all-variants.png")
115
116 print(f"Wrote refs to {OUT}")
117
118
119 if __name__ == "__main__":
120 main()
@@ -0,0 +1,120 @@
1#!/usr/bin/env python3
2"""Export face-id / heightmap / upscaled refs from thick-stone-wall alone.
3
4Run from repo root:
5 python3 client/scripts/export-thick-wall-refs.py
6
7Requires: Pillow
8"""
9from __future__ import annotations
10
11from pathlib import Path
12
13from PIL import Image, ImageDraw
14
15ROOT = Path(__file__).resolve().parents[1]
16ALONE = ROOT / "assets/blocks/_examples/stone-wall/thick-stone-wall.png"
17OUT = ROOT / "assets/blocks/_examples/stone-wall"
18
19# Source greys → semantic face roles (see docs/STONE_WALL_SHAPES.md)
20FACE_RGB = {
21 (175, 175, 175): (255, 255, 255), # N bevel
22 (149, 149, 149): (220, 60, 60), # W face
23 (108, 108, 108): (60, 100, 220), # E face
24 (84, 84, 84): (60, 180, 80), # S face
25 (128, 128, 128): (220, 180, 60), # top plateau
26 (64, 64, 64): (20, 20, 20), # outline
27}
28
29HEIGHT = {
30 (64, 64, 64): 40,
31 (84, 84, 84): 80,
32 (108, 108, 108): 140,
33 (149, 149, 149): 160,
34 (128, 128, 128): 200,
35 (175, 175, 175): 220,
36}
37
38
39def main() -> None:
40 OUT.mkdir(parents=True, exist_ok=True)
41 alone = Image.open(ALONE).convert("RGBA")
42 w, h = alone.size
43 face = Image.new("RGBA", (w, h), (0, 0, 0, 0))
44 height = Image.new("L", (w, h), 0)
45
46 for y in range(h):
47 for x in range(w):
48 r, g, b, a = alone.getpixel((x, y))
49 if a == 0:
50 continue
51 key = (r, g, b)
52 if key not in FACE_RGB:
53 raise SystemExit(f"Unknown grey {key} at ({x},{y})")
54 fr, fg, fb = FACE_RGB[key]
55 face.putpixel((x, y), (fr, fg, fb, 255))
56 height.putpixel((x, y), HEIGHT[key])
57
58 face.save(OUT / "ref-thick-face-id-16.png")
59 face.resize((w * 16, h * 16), Image.NEAREST).save(OUT / "ref-thick-face-id-256.png")
60 height.save(OUT / "ref-thick-height-16.png")
61 height.resize((w * 16, h * 16), Image.NEAREST).save(OUT / "ref-thick-height-256.png")
62 alone.resize((w * 16, h * 16), Image.NEAREST).save(OUT / "ref-thick-alone-256.png")
63
64 leg = Image.new("RGBA", (280, 200), (30, 30, 30, 255))
65 d = ImageDraw.Draw(leg)
66 items = [
67 ((255, 255, 255), "North bevel 0xAF"),
68 ((220, 60, 60), "West face 0x95"),
69 ((60, 100, 220), "East face 0x6C"),
70 ((60, 180, 80), "South face 0x54"),
71 ((220, 180, 60), "Top plateau 0x80"),
72 ((20, 20, 20), "Outline 0x40"),
73 ]
74 for i, (c, label) in enumerate(items):
75 yy = 16 + i * 28
76 d.rectangle([16, yy, 40, yy + 20], fill=(*c, 255))
77 d.text((52, yy + 2), label, fill=(230, 230, 230, 255))
78 leg.save(OUT / "ref-thick-face-legend.png")
79
80 # Labeled contact sheet of all 16 thick *shape* states (bit order).
81 wall_dir = OUT
82 names = [
83 ("alone", "thick-stone-wall.png"),
84 ("n", "thick-stone-wall-n.png"),
85 ("e", "thick-stone-wall-e.png"),
86 ("ne", "thick-stone-wall-ne.png"),
87 ("s", "thick-stone-wall-s.png"),
88 ("ns", "thick-stone-wall-ns.png"),
89 ("es", "thick-stone-wall-es.png"),
90 ("nes", "thick-stone-wall-nes.png"),
91 ("w", "thick-stone-wall-w.png"),
92 ("wn", "thick-stone-wall-wn.png"),
93 ("we", "thick-stone-wall-we.png"),
94 ("wne", "thick-stone-wall-wne.png"),
95 ("sw", "thick-stone-wall-sw.png"),
96 ("swn", "thick-stone-wall-swn.png"),
97 ("esw", "thick-stone-wall-esw.png"),
98 ("nesw", "thick-stone-wall-nesw.png"),
99 ]
100 scale, pad, label_h, cols = 8, 28, 14, 4
101 cell = 16 * scale
102 rows = 4
103 sheet_w = cols * cell + (cols + 1) * pad
104 sheet_h = rows * (cell + label_h) + (rows + 1) * pad
105 sheet = Image.new("RGBA", (sheet_w, sheet_h), (24, 24, 28, 255))
106 draw = ImageDraw.Draw(sheet)
107 for i, (label, fname) in enumerate(names):
108 r, c = divmod(i, cols)
109 x = pad + c * (cell + pad)
110 y = pad + r * (cell + label_h + pad)
111 im = Image.open(wall_dir / fname).convert("RGBA").resize((cell, cell), Image.NEAREST)
112 sheet.paste(im, (x, y), im)
113 draw.text((x, y + cell + 2), label, fill=(220, 220, 220, 255))
114 sheet.save(OUT / "ref-thick-all-variants.png")
115
116 print(f"Wrote refs to {OUT}")
117
118
119if __name__ == "__main__":
120 main()
client/scripts/generate-stone-wall-sprites.mjs +17 −15
@@ -9,24 +9,26 @@
9 9 *
10 10 * node client/scripts/generate-stone-wall-sprites.mjs
11 11 */
12 import {
13 mkdirSync,
14 writeFileSync,
15 readdirSync,
16 unlinkSync,
17 readFileSync,
18 existsSync,
19 cpSync,
20 rmSync
21 } from "node:fs";
12 import
13 {
14 mkdirSync,
15 writeFileSync,
16 readdirSync,
17 unlinkSync,
18 readFileSync,
19 existsSync,
20 cpSync,
21 rmSync
22 } from "node:fs";
22 23 import { deflateSync, inflateSync } from "node:zlib";
23 24 import { fileURLToPath } from "node:url";
24 25 import { dirname, join } from "node:path";
25 import {
26 NeighborBit,
27 cardinalConnectionSuffix,
28 composeNamedNeighborConnectState
29 } from "../../shared/world/neighborConnect.js";
26 import
27 {
28 NeighborBit,
29 cardinalConnectionSuffix,
30 composeNamedNeighborConnectState
31 } from "../../shared/world/neighborConnect.js";
30 32
31 33 const SIZE = 16;
32 34 const ROOT = join(dirname(fileURLToPath(import.meta.url)), "../assets/blocks");
@@ -9,24 +9,26 @@
9 *
9 *
10 * node client/scripts/generate-stone-wall-sprites.mjs
10 * node client/scripts/generate-stone-wall-sprites.mjs
11 */
11 */
12import {
12import
13 mkdirSync,
13 {
14 writeFileSync,
14 mkdirSync,
15 readdirSync,
15 writeFileSync,
16 unlinkSync,
16 readdirSync,
17 readFileSync,
17 unlinkSync,
18 existsSync,
18 readFileSync,
19 cpSync,
19 existsSync,
20 rmSync
20 cpSync,
21} from "node:fs";
21 rmSync
22 } from "node:fs";
22import { deflateSync, inflateSync } from "node:zlib";
23import { deflateSync, inflateSync } from "node:zlib";
23import { fileURLToPath } from "node:url";
24import { fileURLToPath } from "node:url";
24import { dirname, join } from "node:path";
25import { dirname, join } from "node:path";
25import {
26import
26 NeighborBit,
27 {
27 cardinalConnectionSuffix,
28 NeighborBit,
28 composeNamedNeighborConnectState
29 cardinalConnectionSuffix,
29} from "../../shared/world/neighborConnect.js";
30 composeNamedNeighborConnectState
31 } from "../../shared/world/neighborConnect.js";
30
32
31const SIZE = 16;
33const SIZE = 16;
32const ROOT = join(dirname(fileURLToPath(import.meta.url)), "../assets/blocks");
34const ROOT = join(dirname(fileURLToPath(import.meta.url)), "../assets/blocks");
client/scripts/texture-stone-wall-sprites.mjs added +297 −0
@@ -0,0 +1,297 @@
1 /**
2 * Bake grey cobblestone texture onto thick/thin stone-wall shape masks.
3 *
4 * Shape source of truth (greyscale face-IDs):
5 * client/assets/blocks/_examples/stone-wall/{thick,thin}-stone-wall*.png
6 *
7 * Textured output (gameplay sprites):
8 * client/assets/blocks/thick-stone-wall/
9 * client/assets/blocks/thin-stone-wall/
10 *
11 * Face greys (see docs/STONE_WALL_SHAPES.md) pick a cobble base luminance;
12 * a stable hash adds mortar/highlight speckles inside each face.
13 *
14 * node client/scripts/texture-stone-wall-sprites.mjs
15 */
16 import { mkdirSync, writeFileSync, readdirSync, readFileSync, existsSync } from "node:fs";
17 import { deflateSync, inflateSync } from "node:zlib";
18 import { fileURLToPath } from "node:url";
19 import { dirname, join } from "node:path";
20
21 const SIZE = 16;
22 const ROOT = join(dirname(fileURLToPath(import.meta.url)), "../assets/blocks");
23 const EXAMPLES = join(ROOT, "_examples/stone-wall");
24 const OUT = {
25 "thick-stone-wall": join(ROOT, "thick-stone-wall"),
26 "thin-stone-wall": join(ROOT, "thin-stone-wall")
27 };
28
29 /** Gray cobble palette (cool stone; no magenta). */
30 const TOP = [168, 168, 172, 255];
31 const TOP_HI = [198, 198, 202, 255];
32 const TOP_LO = [140, 140, 144, 255];
33 const FACE = [112, 112, 116, 255];
34 const FACE_HI = [132, 132, 136, 255];
35 const FACE_LO = [88, 88, 92, 255];
36 const EDGE = [70, 70, 74, 255];
37 const MORTAR = [78, 78, 82, 255];
38
39 /**
40 * Face-id grey → cobble base (directional light from NW).
41 * Thick and thin use slightly different vocabularies (thin frustum).
42 */
43 const THICK_ROLE_BASE = new Map([
44 [0xaf, TOP_HI], // north bevel
45 [0x95, FACE_HI], // west face
46 [0x80, TOP], // top plateau
47 [0x6c, FACE], // east face
48 [0x54, FACE_LO], // south face
49 [0x40, EDGE] // outline / crease
50 ]);
51
52 const THIN_ROLE_BASE = new Map([
53 [0xb6, FACE_HI], // west face (bright)
54 [0x95, TOP_HI], // north rim / ridge top
55 [0x80, FACE], // east face
56 [0x73, FACE_LO], // south / front body
57 [0x40, EDGE]
58 ]);
59
60 function roleBaseFor (prefix)
61 {
62 return prefix === "thin-stone-wall" ? THIN_ROLE_BASE : THICK_ROLE_BASE;
63 }
64
65 /** Fallback: map arbitrary grey luminance into the cobble range. */
66 function baseFromLuminance (g)
67 {
68 if (g <= 0x48)
69 { return EDGE; }
70 if (g <= 0x60)
71 { return FACE_LO; }
72 if (g <= 0x78)
73 { return FACE; }
74 if (g <= 0x90)
75 { return FACE_HI; }
76 if (g <= 0xa8)
77 { return TOP; }
78 return TOP_HI;
79 }
80
81 function crcTable ()
82 {
83 const table = new Uint32Array(256);
84 for (let n = 0; n < 256; n++)
85 {
86 let c = n;
87 for (let k = 0; k < 8; k++)
88 { c = (c & 1) ? (0xedb88320 ^ (c >>> 1)) : (c >>> 1); }
89 table[n] = c >>> 0;
90 }
91 return table;
92 }
93
94 const CRC_TABLE = crcTable();
95
96 function crc32 (buf)
97 {
98 let c = 0xffffffff;
99 for (let i = 0; i < buf.length; i++)
100 { c = CRC_TABLE[(c ^ buf[i]) & 0xff] ^ (c >>> 8); }
101 return (c ^ 0xffffffff) >>> 0;
102 }
103
104 function chunk (type, data)
105 {
106 const len = Buffer.alloc(4);
107 len.writeUInt32BE(data.length);
108 const typeBuf = Buffer.from(type, "ascii");
109 const crcBuf = Buffer.alloc(4);
110 crcBuf.writeUInt32BE(crc32(Buffer.concat([typeBuf, data])));
111 return Buffer.concat([len, typeBuf, data, crcBuf]);
112 }
113
114 function encodePng (rgba)
115 {
116 const raw = Buffer.alloc((SIZE * 4 + 1) * SIZE);
117 for (let y = 0; y < SIZE; y++)
118 {
119 const row = y * (SIZE * 4 + 1);
120 raw[row] = 0;
121 for (let x = 0; x < SIZE; x++)
122 {
123 const i = (y * SIZE + x) * 4;
124 const o = row + 1 + x * 4;
125 raw[o] = rgba[i];
126 raw[o + 1] = rgba[i + 1];
127 raw[o + 2] = rgba[i + 2];
128 raw[o + 3] = rgba[i + 3];
129 }
130 }
131 const ihdr = Buffer.alloc(13);
132 ihdr.writeUInt32BE(SIZE, 0);
133 ihdr.writeUInt32BE(SIZE, 4);
134 ihdr[8] = 8;
135 ihdr[9] = 6;
136 return Buffer.concat([
137 Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]),
138 chunk("IHDR", ihdr),
139 chunk("IDAT", deflateSync(raw, { level: 9 })),
140 chunk("IEND", Buffer.alloc(0))
141 ]);
142 }
143
144 function decodePngRgba (path)
145 {
146 const buf = readFileSync(path);
147 let off = 8;
148 let w = 0;
149 let h = 0;
150 const idat = [];
151 while (off < buf.length)
152 {
153 const len = buf.readUInt32BE(off);
154 const type = buf.slice(off + 4, off + 8).toString("ascii");
155 const data = buf.slice(off + 8, off + 8 + len);
156 if (type === "IHDR")
157 {
158 w = data.readUInt32BE(0);
159 h = data.readUInt32BE(4);
160 }
161 else if (type === "IDAT")
162 { idat.push(data); }
163 else if (type === "IEND")
164 { break; }
165 off += 12 + len;
166 }
167 const inflated = inflateSync(Buffer.concat(idat));
168 const rgba = new Uint8Array(w * h * 4);
169 const bpp = 4;
170 let src = 0;
171 for (let y = 0; y < h; y++)
172 {
173 const filter = inflated[src++];
174 const row = inflated.subarray(src, src + w * bpp);
175 src += w * bpp;
176 const prev = y > 0 ? rgba.subarray((y - 1) * w * bpp, y * w * bpp) : null;
177 const out = rgba.subarray(y * w * bpp, (y + 1) * w * bpp);
178 for (let i = 0; i < row.length; i++)
179 {
180 let v = row[i];
181 if (filter === 1)
182 { v = (v + (i >= bpp ? out[i - bpp] : 0)) & 255; }
183 else if (filter === 2)
184 { v = (v + (prev ? prev[i] : 0)) & 255; }
185 else if (filter === 3)
186 {
187 const a = i >= bpp ? out[i - bpp] : 0;
188 const b = prev ? prev[i] : 0;
189 v = (v + Math.floor((a + b) / 2)) & 255;
190 }
191 else if (filter === 4)
192 {
193 const a = i >= bpp ? out[i - bpp] : 0;
194 const b = prev ? prev[i] : 0;
195 const c = prev && i >= bpp ? prev[i - bpp] : 0;
196 const p = a + b - c;
197 const pa = Math.abs(p - a);
198 const pb = Math.abs(p - b);
199 const pc = Math.abs(p - c);
200 v = (v + (pa <= pb && pa <= pc ? a : pb <= pc ? b : c)) & 255;
201 }
202 out[i] = v;
203 }
204 }
205 if (w !== SIZE || h !== SIZE)
206 { throw new Error(`${path}: expected ${SIZE}×${SIZE}, got ${w}×${h}`); }
207 return rgba;
208 }
209
210 function hash2 (x, y)
211 {
212 let n = (x * 374761393 + y * 668265263) | 0;
213 n = (n ^ (n >>> 13)) * 1274126177;
214 return (n ^ (n >>> 16)) >>> 0;
215 }
216
217 function cobbleShade (base, x, y, isOutline)
218 {
219 if (isOutline)
220 {
221 // Keep creases mostly solid so silhouettes stay crisp.
222 const h = hash2(x, y);
223 return (h & 15) === 0 ? MORTAR : EDGE;
224 }
225 const h = hash2(x, y);
226 const speck = h & 7;
227 if (speck === 0)
228 { return MORTAR; }
229 if (speck === 1 || speck === 2)
230 {
231 return base === TOP || base === TOP_HI || base === TOP_LO
232 ? TOP_HI
233 : FACE_HI;
234 }
235 if (speck === 3)
236 {
237 return base === TOP || base === TOP_HI || base === TOP_LO
238 ? TOP_LO
239 : FACE_LO;
240 }
241 return base;
242 }
243
244 function textureMask (rgba, roleBase)
245 {
246 const out = new Uint8Array(SIZE * SIZE * 4);
247 for (let y = 0; y < SIZE; y++)
248 {
249 for (let x = 0; x < SIZE; x++)
250 {
251 const i = (y * SIZE + x) * 4;
252 const a = rgba[i + 3];
253 if (a === 0)
254 { continue; }
255 const g = rgba[i];
256 const base = roleBase.get(g) ?? baseFromLuminance(g);
257 const color = cobbleShade(base, x, y, g === 0x40);
258 out[i] = color[0];
259 out[i + 1] = color[1];
260 out[i + 2] = color[2];
261 out[i + 3] = 255;
262 }
263 }
264 return out;
265 }
266
267 function shapeFiles (prefix)
268 {
269 if (!existsSync(EXAMPLES))
270 { throw new Error(`Missing examples folder: ${EXAMPLES}`); }
271 return readdirSync(EXAMPLES)
272 .filter((name) => name.startsWith(prefix) && name.endsWith(".png"))
273 .sort();
274 }
275
276 let wrote = 0;
277 for (const [prefix, outDir] of Object.entries(OUT))
278 {
279 mkdirSync(outDir, { recursive: true });
280 const files = shapeFiles(prefix);
281 if (files.length !== 16)
282 {
283 throw new Error(
284 `Expected 16 ${prefix} masks in ${EXAMPLES}, found ${files.length}`
285 );
286 }
287 const roleBase = roleBaseFor(prefix);
288 for (const name of files)
289 {
290 const shaped = decodePngRgba(join(EXAMPLES, name));
291 const textured = textureMask(shaped, roleBase);
292 writeFileSync(join(outDir, name), encodePng(textured));
293 wrote++;
294 }
295 console.log(`Textured ${files.length} → ${outDir}`);
296 }
297 console.log(`Done (${wrote} sprites). Shapes left greyscale in ${EXAMPLES}`);
@@ -0,0 +1,297 @@
1/**
2 * Bake grey cobblestone texture onto thick/thin stone-wall shape masks.
3 *
4 * Shape source of truth (greyscale face-IDs):
5 * client/assets/blocks/_examples/stone-wall/{thick,thin}-stone-wall*.png
6 *
7 * Textured output (gameplay sprites):
8 * client/assets/blocks/thick-stone-wall/
9 * client/assets/blocks/thin-stone-wall/
10 *
11 * Face greys (see docs/STONE_WALL_SHAPES.md) pick a cobble base luminance;
12 * a stable hash adds mortar/highlight speckles inside each face.
13 *
14 * node client/scripts/texture-stone-wall-sprites.mjs
15 */
16import { mkdirSync, writeFileSync, readdirSync, readFileSync, existsSync } from "node:fs";
17import { deflateSync, inflateSync } from "node:zlib";
18import { fileURLToPath } from "node:url";
19import { dirname, join } from "node:path";
20
21const SIZE = 16;
22const ROOT = join(dirname(fileURLToPath(import.meta.url)), "../assets/blocks");
23const EXAMPLES = join(ROOT, "_examples/stone-wall");
24const OUT = {
25 "thick-stone-wall": join(ROOT, "thick-stone-wall"),
26 "thin-stone-wall": join(ROOT, "thin-stone-wall")
27};
28
29/** Gray cobble palette (cool stone; no magenta). */
30const TOP = [168, 168, 172, 255];
31const TOP_HI = [198, 198, 202, 255];
32const TOP_LO = [140, 140, 144, 255];
33const FACE = [112, 112, 116, 255];
34const FACE_HI = [132, 132, 136, 255];
35const FACE_LO = [88, 88, 92, 255];
36const EDGE = [70, 70, 74, 255];
37const MORTAR = [78, 78, 82, 255];
38
39/**
40 * Face-id grey → cobble base (directional light from NW).
41 * Thick and thin use slightly different vocabularies (thin frustum).
42 */
43const THICK_ROLE_BASE = new Map([
44 [0xaf, TOP_HI], // north bevel
45 [0x95, FACE_HI], // west face
46 [0x80, TOP], // top plateau
47 [0x6c, FACE], // east face
48 [0x54, FACE_LO], // south face
49 [0x40, EDGE] // outline / crease
50]);
51
52const THIN_ROLE_BASE = new Map([
53 [0xb6, FACE_HI], // west face (bright)
54 [0x95, TOP_HI], // north rim / ridge top
55 [0x80, FACE], // east face
56 [0x73, FACE_LO], // south / front body
57 [0x40, EDGE]
58]);
59
60function roleBaseFor (prefix)
61{
62 return prefix === "thin-stone-wall" ? THIN_ROLE_BASE : THICK_ROLE_BASE;
63}
64
65/** Fallback: map arbitrary grey luminance into the cobble range. */
66function baseFromLuminance (g)
67{
68 if (g <= 0x48)
69 { return EDGE; }
70 if (g <= 0x60)
71 { return FACE_LO; }
72 if (g <= 0x78)
73 { return FACE; }
74 if (g <= 0x90)
75 { return FACE_HI; }
76 if (g <= 0xa8)
77 { return TOP; }
78 return TOP_HI;
79}
80
81function crcTable ()
82{
83 const table = new Uint32Array(256);
84 for (let n = 0; n < 256; n++)
85 {
86 let c = n;
87 for (let k = 0; k < 8; k++)
88 { c = (c & 1) ? (0xedb88320 ^ (c >>> 1)) : (c >>> 1); }
89 table[n] = c >>> 0;
90 }
91 return table;
92}
93
94const CRC_TABLE = crcTable();
95
96function crc32 (buf)
97{
98 let c = 0xffffffff;
99 for (let i = 0; i < buf.length; i++)
100 { c = CRC_TABLE[(c ^ buf[i]) & 0xff] ^ (c >>> 8); }
101 return (c ^ 0xffffffff) >>> 0;
102}
103
104function chunk (type, data)
105{
106 const len = Buffer.alloc(4);
107 len.writeUInt32BE(data.length);
108 const typeBuf = Buffer.from(type, "ascii");
109 const crcBuf = Buffer.alloc(4);
110 crcBuf.writeUInt32BE(crc32(Buffer.concat([typeBuf, data])));
111 return Buffer.concat([len, typeBuf, data, crcBuf]);
112}
113
114function encodePng (rgba)
115{
116 const raw = Buffer.alloc((SIZE * 4 + 1) * SIZE);
117 for (let y = 0; y < SIZE; y++)
118 {
119 const row = y * (SIZE * 4 + 1);
120 raw[row] = 0;
121 for (let x = 0; x < SIZE; x++)
122 {
123 const i = (y * SIZE + x) * 4;
124 const o = row + 1 + x * 4;
125 raw[o] = rgba[i];
126 raw[o + 1] = rgba[i + 1];
127 raw[o + 2] = rgba[i + 2];
128 raw[o + 3] = rgba[i + 3];
129 }
130 }
131 const ihdr = Buffer.alloc(13);
132 ihdr.writeUInt32BE(SIZE, 0);
133 ihdr.writeUInt32BE(SIZE, 4);
134 ihdr[8] = 8;
135 ihdr[9] = 6;
136 return Buffer.concat([
137 Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]),
138 chunk("IHDR", ihdr),
139 chunk("IDAT", deflateSync(raw, { level: 9 })),
140 chunk("IEND", Buffer.alloc(0))
141 ]);
142}
143
144function decodePngRgba (path)
145{
146 const buf = readFileSync(path);
147 let off = 8;
148 let w = 0;
149 let h = 0;
150 const idat = [];
151 while (off < buf.length)
152 {
153 const len = buf.readUInt32BE(off);
154 const type = buf.slice(off + 4, off + 8).toString("ascii");
155 const data = buf.slice(off + 8, off + 8 + len);
156 if (type === "IHDR")
157 {
158 w = data.readUInt32BE(0);
159 h = data.readUInt32BE(4);
160 }
161 else if (type === "IDAT")
162 { idat.push(data); }
163 else if (type === "IEND")
164 { break; }
165 off += 12 + len;
166 }
167 const inflated = inflateSync(Buffer.concat(idat));
168 const rgba = new Uint8Array(w * h * 4);
169 const bpp = 4;
170 let src = 0;
171 for (let y = 0; y < h; y++)
172 {
173 const filter = inflated[src++];
174 const row = inflated.subarray(src, src + w * bpp);
175 src += w * bpp;
176 const prev = y > 0 ? rgba.subarray((y - 1) * w * bpp, y * w * bpp) : null;
177 const out = rgba.subarray(y * w * bpp, (y + 1) * w * bpp);
178 for (let i = 0; i < row.length; i++)
179 {
180 let v = row[i];
181 if (filter === 1)
182 { v = (v + (i >= bpp ? out[i - bpp] : 0)) & 255; }
183 else if (filter === 2)
184 { v = (v + (prev ? prev[i] : 0)) & 255; }
185 else if (filter === 3)
186 {
187 const a = i >= bpp ? out[i - bpp] : 0;
188 const b = prev ? prev[i] : 0;
189 v = (v + Math.floor((a + b) / 2)) & 255;
190 }
191 else if (filter === 4)
192 {
193 const a = i >= bpp ? out[i - bpp] : 0;
194 const b = prev ? prev[i] : 0;
195 const c = prev && i >= bpp ? prev[i - bpp] : 0;
196 const p = a + b - c;
197 const pa = Math.abs(p - a);
198 const pb = Math.abs(p - b);
199 const pc = Math.abs(p - c);
200 v = (v + (pa <= pb && pa <= pc ? a : pb <= pc ? b : c)) & 255;
201 }
202 out[i] = v;
203 }
204 }
205 if (w !== SIZE || h !== SIZE)
206 { throw new Error(`${path}: expected ${SIZE}×${SIZE}, got ${w}×${h}`); }
207 return rgba;
208}
209
210function hash2 (x, y)
211{
212 let n = (x * 374761393 + y * 668265263) | 0;
213 n = (n ^ (n >>> 13)) * 1274126177;
214 return (n ^ (n >>> 16)) >>> 0;
215}
216
217function cobbleShade (base, x, y, isOutline)
218{
219 if (isOutline)
220 {
221 // Keep creases mostly solid so silhouettes stay crisp.
222 const h = hash2(x, y);
223 return (h & 15) === 0 ? MORTAR : EDGE;
224 }
225 const h = hash2(x, y);
226 const speck = h & 7;
227 if (speck === 0)
228 { return MORTAR; }
229 if (speck === 1 || speck === 2)
230 {
231 return base === TOP || base === TOP_HI || base === TOP_LO
232 ? TOP_HI
233 : FACE_HI;
234 }
235 if (speck === 3)
236 {
237 return base === TOP || base === TOP_HI || base === TOP_LO
238 ? TOP_LO
239 : FACE_LO;
240 }
241 return base;
242}
243
244function textureMask (rgba, roleBase)
245{
246 const out = new Uint8Array(SIZE * SIZE * 4);
247 for (let y = 0; y < SIZE; y++)
248 {
249 for (let x = 0; x < SIZE; x++)
250 {
251 const i = (y * SIZE + x) * 4;
252 const a = rgba[i + 3];
253 if (a === 0)
254 { continue; }
255 const g = rgba[i];
256 const base = roleBase.get(g) ?? baseFromLuminance(g);
257 const color = cobbleShade(base, x, y, g === 0x40);
258 out[i] = color[0];
259 out[i + 1] = color[1];
260 out[i + 2] = color[2];
261 out[i + 3] = 255;
262 }
263 }
264 return out;
265}
266
267function shapeFiles (prefix)
268{
269 if (!existsSync(EXAMPLES))
270 { throw new Error(`Missing examples folder: ${EXAMPLES}`); }
271 return readdirSync(EXAMPLES)
272 .filter((name) => name.startsWith(prefix) && name.endsWith(".png"))
273 .sort();
274}
275
276let wrote = 0;
277for (const [prefix, outDir] of Object.entries(OUT))
278{
279 mkdirSync(outDir, { recursive: true });
280 const files = shapeFiles(prefix);
281 if (files.length !== 16)
282 {
283 throw new Error(
284 `Expected 16 ${prefix} masks in ${EXAMPLES}, found ${files.length}`
285 );
286 }
287 const roleBase = roleBaseFor(prefix);
288 for (const name of files)
289 {
290 const shaped = decodePngRgba(join(EXAMPLES, name));
291 const textured = textureMask(shaped, roleBase);
292 writeFileSync(join(outDir, name), encodePng(textured));
293 wrote++;
294 }
295 console.log(`Textured ${files.length} → ${outDir}`);
296}
297console.log(`Done (${wrote} sprites). Shapes left greyscale in ${EXAMPLES}`);
docs/STONE_WALL_SHAPES.md +38 −13
@@ -1,6 +1,6 @@
1 1 # Stone wall shape system
2 2
3 How **thick** stone-wall sprites encode a 3D block as flat greyscale, how **connections** open faces into neighbours, and how to clone the structure for new materials / textures.
3 How **thick** stone-wall sprites encode a 3D block as flat greyscale face-IDs, how **connections** open faces into neighbours, and how cobble texture is baked onto those masks for gameplay.
4 4
5 5 Thin walls use the same face vocabulary on a narrower frustum; this document centres on **thick**, which is the clearest reference.
6 6
@@ -10,9 +10,10 @@ Thin walls use the same face vocabulary on a narrower frustum; this document cen
10 10
11 11 | Path | What it is |
12 12 |------|------------|
13 | `client/assets/blocks/thick-stone-wall/thick-stone-wall.png` | **Source of truth** — alone 1×1 |
14 | `client/assets/blocks/thick-stone-wall/thick-stone-wall-*.png` | 15 connected variants |
15 | `client/assets/blocks/_examples/stone-wall/ref-thick-alone-256.png` | Nearest-neighbour ×16 alone |
13 | `client/assets/blocks/thick-stone-wall/thick-stone-wall.png` | **Gameplay** alone 1×1 (textured) |
14 | `client/assets/blocks/_examples/stone-wall/thick-stone-wall.png` | **Shape mask** alone 1×1 (face-id greys) |
15 | `client/assets/blocks/thick-stone-wall/thick-stone-wall-*.png` | 15 connected gameplay variants |
16 | `client/assets/blocks/_examples/stone-wall/ref-thick-alone-256.png` | Nearest-neighbour ×16 alone (shape) |
16 17 | `…/ref-thick-face-id-16.png` / `…-256.png` | False-colour face roles |
17 18 | `…/ref-thick-height-16.png` / `…-256.png` | Relative heightmap from roles |
18 19 | `…/ref-thick-face-legend.png` | Colour key for face-id |
@@ -207,7 +208,7 @@ Each keeps the two **outer** free faces and opens the two **inner** sides into t
207 208
208 209 **`w`** — west open: N/T/S run to `x=0`; free east column remains.
209 210
210 > **Authoring note:** on the current `thick-stone-wall-w.png`, the free east column is painted with **`0x95` (west grey)** rather than `0x6C`. Structurally it is still “east free face”. When texturing or rebuilding, prefer **remapping to `0x6C`** so E/W lighting stays consistent with alone. Horizontal flips of `e` must reassign face greys — do not keep mirrored luminance.
211 > **Note:** free east on `thick-stone-wall-w` uses `0x6C` (corrected). When flipping `e`↔`w` art, always reassign face greys — do not keep mirrored luminance.
211 212
212 213 ---
213 214
@@ -287,31 +288,55 @@ Suggested pipeline for a new wall set:
287 288
288 289 ## 10. Thin walls
289 290
290 `thin-stone-wall` uses the **same face roles** on a **narrow frustum** (alone body inset; N/S runs stay narrow; E/W opens the frustum to the edge). Clone thin silhouettes, recolour by the thick role table. Prefer thick as the teaching reference when learning the system.
291 `thin-stone-wall` uses the **same idea** on a **narrow frustum**, but a slightly different grey vocabulary:
292
293 | Grey | Hex | Thin role |
294 |------|-----|-----------|
295 | 64 | `0x40` | Outline |
296 | 182 | `0xB6` | West face |
297 | 149 | `0x95` | North rim / ridge top |
298 | 128 | `0x80` | East face (**not** top plateau — differs from thick) |
299 | 115 | `0x73` | South / front body |
300
301 Clone thin silhouettes; recolour via this table (or `texture-stone-wall-sprites.mjs`).
302
303 ---
304
305 ## 11. Baking cobble texture
306
307 Gameplay sprites in `thick-stone-wall/` and `thin-stone-wall/` are **textured**. Greyscale face-id masks stay in `_examples/stone-wall/`.
308
309 ```bash
310 node client/scripts/texture-stone-wall-sprites.mjs
311 ```
312
313 Reads example masks → writes cobble-shaded PNGs using the old cool-grey stone palette (TOP / FACE / EDGE / MORTAR speckles), keyed by face role. Re-run after editing shapes in `_examples`.
291 314
292 315 ---
293 316
294 ## 11. Code touchpoints
317 ## 12. Code touchpoints
295 318
296 319 | Concern | Location |
297 320 |---------|----------|
298 321 | Cardinal suffix / mask (`& 15`) | `shared/world/neighborConnect.js` |
299 322 | Block defs | `shared/definitions/tiles.js` |
300 | Sprites | `client/assets/blocks/thick-stone-wall/`, `thin-stone-wall/` |
301 | Shape examples + refs | `client/assets/blocks/_examples/stone-wall/` |
302 | Example-driven generator | `client/scripts/generate-stone-wall-sprites.mjs` |
323 | Textured sprites (gameplay) | `client/assets/blocks/thick-stone-wall/`, `thin-stone-wall/` |
324 | Greyscale shape masks + refs | `client/assets/blocks/_examples/stone-wall/` |
325 | Shape generator from connecting examples | `client/scripts/generate-stone-wall-sprites.mjs` |
326 | Cobble texture bake | `client/scripts/texture-stone-wall-sprites.mjs` |
303 327 | Ref export | `client/scripts/export-thick-wall-refs.py` |
304 328
305 329 Editor recomputes neighbour suffixes on paint and on chunk load so a 2×2 stays on corner suffixes, not `nesw`.
306 330
307 331 ---
308 332
309 ## 12. Regenerate reference maps
333 ## 13. Regenerate reference maps
310 334
311 Whenever `thick-stone-wall.png` (alone) changes:
335 Whenever the thick alone **shape** mask changes:
312 336
313 337 ```bash
314 338 python3 client/scripts/export-thick-wall-refs.py
339 node client/scripts/texture-stone-wall-sprites.mjs
315 340 ```
316 341
317 Then update the grey table in §2 if the vocabulary shifted.
342 Then update the grey table in §2 / §10 if the vocabulary shifted.
@@ -1,6 +1,6 @@
1# Stone wall shape system
1# Stone wall shape system
2
2
3How **thick** stone-wall sprites encode a 3D block as flat greyscale, how **connections** open faces into neighbours, and how to clone the structure for new materials / textures.
3How **thick** stone-wall sprites encode a 3D block as flat greyscale face-IDs, how **connections** open faces into neighbours, and how cobble texture is baked onto those masks for gameplay.
4
4
5Thin walls use the same face vocabulary on a narrower frustum; this document centres on **thick**, which is the clearest reference.
5Thin walls use the same face vocabulary on a narrower frustum; this document centres on **thick**, which is the clearest reference.
6
6
@@ -10,9 +10,10 @@ Thin walls use the same face vocabulary on a narrower frustum; this document cen
10
10
11| Path | What it is |
11| Path | What it is |
12|------|------------|
12|------|------------|
13| `client/assets/blocks/thick-stone-wall/thick-stone-wall.png` | **Source of truth** — alone 1×1 |
13| `client/assets/blocks/thick-stone-wall/thick-stone-wall.png` | **Gameplay** alone 1×1 (textured) |
14| `client/assets/blocks/thick-stone-wall/thick-stone-wall-*.png` | 15 connected variants |
14| `client/assets/blocks/_examples/stone-wall/thick-stone-wall.png` | **Shape mask** alone 1×1 (face-id greys) |
15| `client/assets/blocks/_examples/stone-wall/ref-thick-alone-256.png` | Nearest-neighbour ×16 alone |
15| `client/assets/blocks/thick-stone-wall/thick-stone-wall-*.png` | 15 connected gameplay variants |
16| `client/assets/blocks/_examples/stone-wall/ref-thick-alone-256.png` | Nearest-neighbour ×16 alone (shape) |
16| `…/ref-thick-face-id-16.png` / `…-256.png` | False-colour face roles |
17| `…/ref-thick-face-id-16.png` / `…-256.png` | False-colour face roles |
17| `…/ref-thick-height-16.png` / `…-256.png` | Relative heightmap from roles |
18| `…/ref-thick-height-16.png` / `…-256.png` | Relative heightmap from roles |
18| `…/ref-thick-face-legend.png` | Colour key for face-id |
19| `…/ref-thick-face-legend.png` | Colour key for face-id |
@@ -207,7 +208,7 @@ Each keeps the two **outer** free faces and opens the two **inner** sides into t
207
208
208**`w`** — west open: N/T/S run to `x=0`; free east column remains.
209**`w`** — west open: N/T/S run to `x=0`; free east column remains.
209
210
210> **Authoring note:** on the current `thick-stone-wall-w.png`, the free east column is painted with **`0x95` (west grey)** rather than `0x6C`. Structurally it is still “east free face”. When texturing or rebuilding, prefer **remapping to `0x6C`** so E/W lighting stays consistent with alone. Horizontal flips of `e` must reassign face greys — do not keep mirrored luminance.
211> **Note:** free east on `thick-stone-wall-w` uses `0x6C` (corrected). When flipping `e`↔`w` art, always reassign face greys — do not keep mirrored luminance.
211
212
212---
213---
213
214
@@ -287,31 +288,55 @@ Suggested pipeline for a new wall set:
287
288
288## 10. Thin walls
289## 10. Thin walls
289
290
290`thin-stone-wall` uses the **same face roles** on a **narrow frustum** (alone body inset; N/S runs stay narrow; E/W opens the frustum to the edge). Clone thin silhouettes, recolour by the thick role table. Prefer thick as the teaching reference when learning the system.
291`thin-stone-wall` uses the **same idea** on a **narrow frustum**, but a slightly different grey vocabulary:
292
293| Grey | Hex | Thin role |
294|------|-----|-----------|
295| 64 | `0x40` | Outline |
296| 182 | `0xB6` | West face |
297| 149 | `0x95` | North rim / ridge top |
298| 128 | `0x80` | East face (**not** top plateau — differs from thick) |
299| 115 | `0x73` | South / front body |
300
301Clone thin silhouettes; recolour via this table (or `texture-stone-wall-sprites.mjs`).
302
303---
304
305## 11. Baking cobble texture
306
307Gameplay sprites in `thick-stone-wall/` and `thin-stone-wall/` are **textured**. Greyscale face-id masks stay in `_examples/stone-wall/`.
308
309```bash
310node client/scripts/texture-stone-wall-sprites.mjs
311```
312
313Reads example masks → writes cobble-shaded PNGs using the old cool-grey stone palette (TOP / FACE / EDGE / MORTAR speckles), keyed by face role. Re-run after editing shapes in `_examples`.
291
314
292---
315---
293
316
294## 11. Code touchpoints
317## 12. Code touchpoints
295
318
296| Concern | Location |
319| Concern | Location |
297|---------|----------|
320|---------|----------|
298| Cardinal suffix / mask (`& 15`) | `shared/world/neighborConnect.js` |
321| Cardinal suffix / mask (`& 15`) | `shared/world/neighborConnect.js` |
299| Block defs | `shared/definitions/tiles.js` |
322| Block defs | `shared/definitions/tiles.js` |
300| Sprites | `client/assets/blocks/thick-stone-wall/`, `thin-stone-wall/` |
323| Textured sprites (gameplay) | `client/assets/blocks/thick-stone-wall/`, `thin-stone-wall/` |
301| Shape examples + refs | `client/assets/blocks/_examples/stone-wall/` |
324| Greyscale shape masks + refs | `client/assets/blocks/_examples/stone-wall/` |
302| Example-driven generator | `client/scripts/generate-stone-wall-sprites.mjs` |
325| Shape generator from connecting examples | `client/scripts/generate-stone-wall-sprites.mjs` |
326| Cobble texture bake | `client/scripts/texture-stone-wall-sprites.mjs` |
303| Ref export | `client/scripts/export-thick-wall-refs.py` |
327| Ref export | `client/scripts/export-thick-wall-refs.py` |
304
328
305Editor recomputes neighbour suffixes on paint and on chunk load so a 2×2 stays on corner suffixes, not `nesw`.
329Editor recomputes neighbour suffixes on paint and on chunk load so a 2×2 stays on corner suffixes, not `nesw`.
306
330
307---
331---
308
332
309## 12. Regenerate reference maps
333## 13. Regenerate reference maps
310
334
311Whenever `thick-stone-wall.png` (alone) changes:
335Whenever the thick alone **shape** mask changes:
312
336
313```bash
337```bash
314python3 client/scripts/export-thick-wall-refs.py
338python3 client/scripts/export-thick-wall-refs.py
339node client/scripts/texture-stone-wall-sprites.mjs
315```
340```
316
341
317Then update the grey table in §2 if the vocabulary shifted.
342Then update the grey table in §2 / §10 if the vocabulary shifted.
server/tests/central-exchange.test.js +14 −14
@@ -1,20 +1,20 @@
1 1 import test from "node:test";
2 2 import assert from "node:assert/strict";
3 3 import
4 {
5 NeighborBit,
6 computeNeighborConnectMask,
7 neighborConnectStateName,
8 parseNeighborConnectMask,
9 composeNeighborConnectState,
10 neighborConnectBlocksMatch,
11 parseMaterialNeighborConnectState,
12 worldTileToChunkLocal,
13 neighborConnectRefreshTiles,
14 cardinalConnectionSuffix,
15 composeNamedNeighborConnectState,
16 parseNamedNeighborConnectMask
17 } from "../../shared/world/neighborConnect.js";
4 {
5 NeighborBit,
6 computeNeighborConnectMask,
7 neighborConnectStateName,
8 parseNeighborConnectMask,
9 composeNeighborConnectState,
10 neighborConnectBlocksMatch,
11 parseMaterialNeighborConnectState,
12 worldTileToChunkLocal,
13 neighborConnectRefreshTiles,
14 cardinalConnectionSuffix,
15 composeNamedNeighborConnectState,
16 parseNamedNeighborConnectMask
17 } from "../../shared/world/neighborConnect.js";
18 18 import { CENTRAL_EXCHANGE_STAFF, pickExchangeClerk } from "../../shared/market/exchange.js";
19 19 import { MobId, normalizeSpawnerConfig, isCentralExchangeSpawner } from "../../shared/definitions/mobs.js";
20 20 import { BlockType, BLOCK_DEFINITIONS } from "../../shared/definitions/tiles.js";
@@ -1,20 +1,20 @@
1import test from "node:test";
1import test from "node:test";
2import assert from "node:assert/strict";
2import assert from "node:assert/strict";
3import
3import
4 {
4{
5 NeighborBit,
5 NeighborBit,
6 computeNeighborConnectMask,
6 computeNeighborConnectMask,
7 neighborConnectStateName,
7 neighborConnectStateName,
8 parseNeighborConnectMask,
8 parseNeighborConnectMask,
9 composeNeighborConnectState,
9 composeNeighborConnectState,
10 neighborConnectBlocksMatch,
10 neighborConnectBlocksMatch,
11 parseMaterialNeighborConnectState,
11 parseMaterialNeighborConnectState,
12 worldTileToChunkLocal,
12 worldTileToChunkLocal,
13 neighborConnectRefreshTiles,
13 neighborConnectRefreshTiles,
14 cardinalConnectionSuffix,
14 cardinalConnectionSuffix,
15 composeNamedNeighborConnectState,
15 composeNamedNeighborConnectState,
16 parseNamedNeighborConnectMask
16 parseNamedNeighborConnectMask
17 } from "../../shared/world/neighborConnect.js";
17} from "../../shared/world/neighborConnect.js";
18import { CENTRAL_EXCHANGE_STAFF, pickExchangeClerk } from "../../shared/market/exchange.js";
18import { CENTRAL_EXCHANGE_STAFF, pickExchangeClerk } from "../../shared/market/exchange.js";
19import { MobId, normalizeSpawnerConfig, isCentralExchangeSpawner } from "../../shared/definitions/mobs.js";
19import { MobId, normalizeSpawnerConfig, isCentralExchangeSpawner } from "../../shared/definitions/mobs.js";
20import { BlockType, BLOCK_DEFINITIONS } from "../../shared/definitions/tiles.js";
20import { BlockType, BLOCK_DEFINITIONS } from "../../shared/definitions/tiles.js";
server/tests/season.test.js +14 −13
@@ -2,19 +2,20 @@ import test from "node:test";
2 2 import assert from "node:assert/strict";
3 3 import { fileURLToPath } from "node:url";
4 4 import { join } from "node:path";
5 import {
6 SeasonId,
7 GrowthSeasonId,
8 seasonIdAt,
9 growthSeasonIdAt,
10 regrowDurationMultiplier,
11 scaleRegrowDurationMs,
12 resolveSeasonalVisualState,
13 preferredSeasonalDefaultState,
14 typeHasSeasonalStates,
15 seasonalCycleStates,
16 seasonIdFromVisualState
17 } from "../../shared/world/season.js";
5 import
6 {
7 SeasonId,
8 GrowthSeasonId,
9 seasonIdAt,
10 growthSeasonIdAt,
11 regrowDurationMultiplier,
12 scaleRegrowDurationMs,
13 resolveSeasonalVisualState,
14 preferredSeasonalDefaultState,
15 typeHasSeasonalStates,
16 seasonalCycleStates,
17 seasonIdFromVisualState
18 } from "../../shared/world/season.js";
18 19 import { shopRestockDayKey } from "../../shared/shop/pricing.js";
19 20 import { buildSpriteCatalog } from "../src/assets/spriteCatalog.js";
20 21
@@ -2,19 +2,20 @@ import test from "node:test";
2import assert from "node:assert/strict";
2import assert from "node:assert/strict";
3import { fileURLToPath } from "node:url";
3import { fileURLToPath } from "node:url";
4import { join } from "node:path";
4import { join } from "node:path";
5import {
5import
6 SeasonId,
6 {
7 GrowthSeasonId,
7 SeasonId,
8 seasonIdAt,
8 GrowthSeasonId,
9 growthSeasonIdAt,
9 seasonIdAt,
10 regrowDurationMultiplier,
10 growthSeasonIdAt,
11 scaleRegrowDurationMs,
11 regrowDurationMultiplier,
12 resolveSeasonalVisualState,
12 scaleRegrowDurationMs,
13 preferredSeasonalDefaultState,
13 resolveSeasonalVisualState,
14 typeHasSeasonalStates,
14 preferredSeasonalDefaultState,
15 seasonalCycleStates,
15 typeHasSeasonalStates,
16 seasonIdFromVisualState
16 seasonalCycleStates,
17} from "../../shared/world/season.js";
17 seasonIdFromVisualState
18 } from "../../shared/world/season.js";
18import { shopRestockDayKey } from "../../shared/shop/pricing.js";
19import { shopRestockDayKey } from "../../shared/shop/pricing.js";
19import { buildSpriteCatalog } from "../src/assets/spriteCatalog.js";
20import { buildSpriteCatalog } from "../src/assets/spriteCatalog.js";
20
21