BlueGit

timfa questward

Fix stone-wall neighbor seams with constant connected cross-section.

Connected N/S/E/W runs use a fixed core thickness so tile edges meet; frustum taper only remains on free ends and alone pieces.

timfa Tim Falken · pushed by timfa

Authored 2026-08-31 · 2 months ago

Hash
86f45d8a63919e4fcfe7442a353ce3c22769ac4b
Parent
2ea20e03
14 files changed +65 −60
client/assets/blocks/stone-wall/0.png Binary file +0 −0

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

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

The contents of this binary file are not shown.

client/scripts/generate-stone-wall-sprites.mjs +65 −60
@@ -1,13 +1,13 @@
1 1 /**
2 2 * Generate 16×16 gray cobblestone stone-wall PNGs for neighbor-connect masks 0–15.
3 3 *
4 * Shape is a truncated pyramid / frustum (wider base, narrower top). Footprint is a
5 * strip-union like tables: E–W bar ∪ N–S bar so L/T/+ bends keep concave corners
6 * while straight runs stay one tile thick and meet at the edges.
4 * Truncated-pyramid / frustum look when alone or at free ends. Connected runs use a
5 * constant cross-section extruded to the tile edge (strip-union like tables/fences)
6 * so N/S and E/W seams match.
7 7 *
8 8 * node client/scripts/generate-stone-wall-sprites.mjs
9 9 */
10 import { mkdirSync, writeFileSync, unlinkSync, existsSync } from "node:fs";
10 import { mkdirSync, writeFileSync } from "node:fs";
11 11 import { deflateSync } from "node:zlib";
12 12 import { fileURLToPath } from "node:url";
13 13 import { dirname, join } from "node:path";
@@ -16,7 +16,6 @@ import { NeighborBit } from "../../shared/world/neighborConnect.js";
16 16 const SIZE = 16;
17 17 const OUT = join(dirname(fileURLToPath(import.meta.url)), "../assets/blocks/stone-wall");
18 18
19 /** Gray cobble palette (no magenta — stone stays gray for now). */
20 19 const TOP = [168, 168, 172, 255];
21 20 const TOP_HI = [198, 198, 202, 255];
22 21 const TOP_LO = [140, 140, 144, 255];
@@ -26,13 +25,15 @@ const FACE_LO = [88, 88, 92, 255];
26 25 const EDGE = [70, 70, 74, 255];
27 26 const MORTAR = [78, 78, 82, 255];
28 27
29 /** Alone / core frustum (inclusive pixel bounds). */
28 /** Constant core used for connected runs (must meet neighbour tile edges cleanly). */
29 const CORE_X0 = 5;
30 const CORE_X1 = 10;
30 31 const TOP_Y0 = 3;
31 32 const TOP_Y1 = 6;
32 33 const FACE_Y1 = 12;
33 const CX = 7.5;
34 const TOP_HALF_W = 3.0;
35 const BASE_HALF_W = 5.5;
34 /** Alone / free-end base is wider than the top (frustum). */
35 const BASE_X0 = 3;
36 const BASE_X1 = 12;
36 37
37 38 function crcTable ()
38 39 {
@@ -108,55 +109,59 @@ function setPx (rgba, x, y, color)
108 109 rgba[i + 3] = color[3];
109 110 }
110 111
111 function halfWidthAtY (y)
112 /** Frustum half-width in X at row y (alone / free-end silhouette). */
113 function frustumX0X1 (y)
112 114 {
113 115 if (y <= TOP_Y1)
114 { return TOP_HALF_W; }
116 { return { x0: CORE_X0, x1: CORE_X1 }; }
115 117 if (y >= FACE_Y1)
116 { return BASE_HALF_W; }
118 { return { x0: BASE_X0, x1: BASE_X1 }; }
117 119 const t = (y - TOP_Y1) / (FACE_Y1 - TOP_Y1);
118 return TOP_HALF_W + (BASE_HALF_W - TOP_HALF_W) * t;
119 }
120
121 /** Core Y range for alone wall; extended to tile edges when connected N/S. */
122 function yRange (connectN, connectS)
123 {
124 return {
125 y0: connectN ? 0 : TOP_Y0,
126 y1: connectS ? SIZE - 1 : FACE_Y1
127 };
120 const x0 = Math.round(CORE_X0 + (BASE_X0 - CORE_X0) * t);
121 const x1 = Math.round(CORE_X1 + (BASE_X1 - CORE_X1) * t);
122 return { x0, x1 };
128 123 }
129 124
130 125 /**
131 * Strip-union footprint: E–W frustum bar ∪ N–S frustum bar.
132 * Free ends keep the tapered half-width; connected sides run to the tile edge.
126 * Strip-union with constant core thickness on connected sides.
127 * Free ends keep the frustum taper so alone / stubs still read as 3D.
133 128 */
134 129 function inWall (x, y, connectN, connectE, connectS, connectW)
135 130 {
136 const { y0, y1 } = yRange(connectN, connectS);
137 if (y < y0 || y > y1)
138 { return false; }
139
140 const hw = halfWidthAtY(Math.min(FACE_Y1, Math.max(TOP_Y0, y)));
141 const coreX0 = Math.ceil(CX - hw);
142 const coreX1 = Math.floor(CX + hw);
143
144 const inH = y >= (connectN ? 0 : TOP_Y0)
145 && y <= (connectS ? SIZE - 1 : FACE_Y1)
146 && (
147 (x >= coreX0 && x <= coreX1)
148 || (connectW && x < coreX0)
149 || (connectE && x > coreX1)
150 );
151
152 const inV = x >= coreX0 && x <= coreX1
153 && (
154 (y >= TOP_Y0 && y <= FACE_Y1)
155 || (connectN && y < TOP_Y0)
156 || (connectS && y > FACE_Y1)
157 );
158
159 return inH || inV;
131 const alone = !connectN && !connectE && !connectS && !connectW;
132 const wantH = alone || connectE || connectW;
133 const wantV = alone || connectN || connectS;
134
135 if (wantH)
136 {
137 const y0 = connectN ? 0 : TOP_Y0;
138 const y1 = connectS ? SIZE - 1 : FACE_Y1;
139 if (y >= y0 && y <= y1)
140 {
141 const { x0: fx0, x1: fx1 } = frustumX0X1(Math.min(FACE_Y1, Math.max(TOP_Y0, y)));
142 // Connected cardinals run to the tile edge (constant seam).
143 // Free ends keep the frustum taper.
144 const x0 = connectW ? 0 : fx0;
145 const x1 = connectE ? SIZE - 1 : fx1;
146 if (x >= x0 && x <= x1)
147 { return true; }
148 }
149 }
150
151 if (wantV)
152 {
153 const x0 = CORE_X0;
154 const x1 = CORE_X1;
155 if (x >= x0 && x <= x1)
156 {
157 const y0 = connectN ? 0 : TOP_Y0;
158 const y1 = connectS ? SIZE - 1 : FACE_Y1;
159 if (y >= y0 && y <= y1)
160 { return true; }
161 }
162 }
163
164 return false;
160 165 }
161 166
162 167 function hash2 (x, y)
@@ -179,6 +184,13 @@ function cobbleShade (base, x, y)
179 184 return base;
180 185 }
181 186
187 function isTopRow (y, connectN)
188 {
189 if (connectN)
190 { return y <= TOP_Y1; }
191 return y >= TOP_Y0 && y <= TOP_Y1;
192 }
193
182 194 function paintWall (mask)
183 195 {
184 196 const rgba = new Uint8Array(SIZE * SIZE * 4);
@@ -200,9 +212,7 @@ function paintWall (mask)
200 212 const w = inWall(x - 1, y, connectN, connectE, connectS, connectW);
201 213
202 214 let base;
203 const onTop = y <= TOP_Y1 || (connectN && y < TOP_Y0 + 2 && n && s);
204 // Prefer a clear top deck in the core band; south of TOP_Y1 is the face.
205 if (y <= TOP_Y1 && (y >= TOP_Y0 || connectN))
215 if (isTopRow(y, connectN))
206 216 {
207 217 if (!n)
208 218 { base = TOP_HI; }
@@ -213,7 +223,6 @@ function paintWall (mask)
213 223 }
214 224 else
215 225 {
216 // South face / body of the frustum
217 226 if (!s)
218 227 { base = FACE_LO; }
219 228 else if (!n)
@@ -222,8 +231,10 @@ function paintWall (mask)
222 231 { base = FACE; }
223 232 }
224 233
225 // Free side rims read as darker bevels (trapezoid silhouette).
226 if ((!w && !connectW) || (!e && !connectE))
234 // Free side bevels (not on edges that continue into a neighbour).
235 const freeW = !w && !(connectW && x === 0);
236 const freeE = !e && !(connectE && x === SIZE - 1);
237 if (freeW || freeE)
227 238 {
228 239 if (base === TOP || base === TOP_HI)
229 240 { base = TOP_LO; }
@@ -238,12 +249,6 @@ function paintWall (mask)
238 249 }
239 250
240 251 mkdirSync(OUT, { recursive: true });
241 for (const legacy of ["1.png", "2.png"])
242 {
243 const path = join(OUT, legacy);
244 if (existsSync(path))
245 { unlinkSync(path); }
246 }
247 252 for (let mask = 0; mask < 16; mask++)
248 253 {
249 254 writeFileSync(join(OUT, `${mask}.png`), encodePng(paintWall(mask)));
@@ -1,13 +1,13 @@
1/**
1/**
2 * Generate 16×16 gray cobblestone stone-wall PNGs for neighbor-connect masks 0–15.
2 * Generate 16×16 gray cobblestone stone-wall PNGs for neighbor-connect masks 0–15.
3 *
3 *
4 * Shape is a truncated pyramid / frustum (wider base, narrower top). Footprint is a
4 * Truncated-pyramid / frustum look when alone or at free ends. Connected runs use a
5 * strip-union like tables: E–W bar ∪ N–S bar so L/T/+ bends keep concave corners
5 * constant cross-section extruded to the tile edge (strip-union like tables/fences)
6 * while straight runs stay one tile thick and meet at the edges.
6 * so N/S and E/W seams match.
7 *
7 *
8 * node client/scripts/generate-stone-wall-sprites.mjs
8 * node client/scripts/generate-stone-wall-sprites.mjs
9 */
9 */
10import { mkdirSync, writeFileSync, unlinkSync, existsSync } from "node:fs";
10import { mkdirSync, writeFileSync } from "node:fs";
11import { deflateSync } from "node:zlib";
11import { deflateSync } from "node:zlib";
12import { fileURLToPath } from "node:url";
12import { fileURLToPath } from "node:url";
13import { dirname, join } from "node:path";
13import { dirname, join } from "node:path";
@@ -16,7 +16,6 @@ import { NeighborBit } from "../../shared/world/neighborConnect.js";
16const SIZE = 16;
16const SIZE = 16;
17const OUT = join(dirname(fileURLToPath(import.meta.url)), "../assets/blocks/stone-wall");
17const OUT = join(dirname(fileURLToPath(import.meta.url)), "../assets/blocks/stone-wall");
18
18
19/** Gray cobble palette (no magenta — stone stays gray for now). */
20const TOP = [168, 168, 172, 255];
19const TOP = [168, 168, 172, 255];
21const TOP_HI = [198, 198, 202, 255];
20const TOP_HI = [198, 198, 202, 255];
22const TOP_LO = [140, 140, 144, 255];
21const TOP_LO = [140, 140, 144, 255];
@@ -26,13 +25,15 @@ const FACE_LO = [88, 88, 92, 255];
26const EDGE = [70, 70, 74, 255];
25const EDGE = [70, 70, 74, 255];
27const MORTAR = [78, 78, 82, 255];
26const MORTAR = [78, 78, 82, 255];
28
27
29/** Alone / core frustum (inclusive pixel bounds). */
28/** Constant core used for connected runs (must meet neighbour tile edges cleanly). */
29const CORE_X0 = 5;
30const CORE_X1 = 10;
30const TOP_Y0 = 3;
31const TOP_Y0 = 3;
31const TOP_Y1 = 6;
32const TOP_Y1 = 6;
32const FACE_Y1 = 12;
33const FACE_Y1 = 12;
33const CX = 7.5;
34/** Alone / free-end base is wider than the top (frustum). */
34const TOP_HALF_W = 3.0;
35const BASE_X0 = 3;
35const BASE_HALF_W = 5.5;
36const BASE_X1 = 12;
36
37
37function crcTable ()
38function crcTable ()
38{
39{
@@ -108,55 +109,59 @@ function setPx (rgba, x, y, color)
108 rgba[i + 3] = color[3];
109 rgba[i + 3] = color[3];
109}
110}
110
111
111function halfWidthAtY (y)
112/** Frustum half-width in X at row y (alone / free-end silhouette). */
113function frustumX0X1 (y)
112{
114{
113 if (y <= TOP_Y1)
115 if (y <= TOP_Y1)
114 { return TOP_HALF_W; }
116 { return { x0: CORE_X0, x1: CORE_X1 }; }
115 if (y >= FACE_Y1)
117 if (y >= FACE_Y1)
116 { return BASE_HALF_W; }
118 { return { x0: BASE_X0, x1: BASE_X1 }; }
117 const t = (y - TOP_Y1) / (FACE_Y1 - TOP_Y1);
119 const t = (y - TOP_Y1) / (FACE_Y1 - TOP_Y1);
118 return TOP_HALF_W + (BASE_HALF_W - TOP_HALF_W) * t;
120 const x0 = Math.round(CORE_X0 + (BASE_X0 - CORE_X0) * t);
119}
121 const x1 = Math.round(CORE_X1 + (BASE_X1 - CORE_X1) * t);
120
122 return { x0, x1 };
121/** Core Y range for alone wall; extended to tile edges when connected N/S. */
122function yRange (connectN, connectS)
123{
124 return {
125 y0: connectN ? 0 : TOP_Y0,
126 y1: connectS ? SIZE - 1 : FACE_Y1
127 };
128}
123}
129
124
130/**
125/**
131 * Strip-union footprint: E–W frustum bar ∪ N–S frustum bar.
126 * Strip-union with constant core thickness on connected sides.
132 * Free ends keep the tapered half-width; connected sides run to the tile edge.
127 * Free ends keep the frustum taper so alone / stubs still read as 3D.
133 */
128 */
134function inWall (x, y, connectN, connectE, connectS, connectW)
129function inWall (x, y, connectN, connectE, connectS, connectW)
135{
130{
136 const { y0, y1 } = yRange(connectN, connectS);
131 const alone = !connectN && !connectE && !connectS && !connectW;
137 if (y < y0 || y > y1)
132 const wantH = alone || connectE || connectW;
138 { return false; }
133 const wantV = alone || connectN || connectS;
139
134
140 const hw = halfWidthAtY(Math.min(FACE_Y1, Math.max(TOP_Y0, y)));
135 if (wantH)
141 const coreX0 = Math.ceil(CX - hw);
136 {
142 const coreX1 = Math.floor(CX + hw);
137 const y0 = connectN ? 0 : TOP_Y0;
143
138 const y1 = connectS ? SIZE - 1 : FACE_Y1;
144 const inH = y >= (connectN ? 0 : TOP_Y0)
139 if (y >= y0 && y <= y1)
145 && y <= (connectS ? SIZE - 1 : FACE_Y1)
140 {
146 && (
141 const { x0: fx0, x1: fx1 } = frustumX0X1(Math.min(FACE_Y1, Math.max(TOP_Y0, y)));
147 (x >= coreX0 && x <= coreX1)
142 // Connected cardinals run to the tile edge (constant seam).
148 || (connectW && x < coreX0)
143 // Free ends keep the frustum taper.
149 || (connectE && x > coreX1)
144 const x0 = connectW ? 0 : fx0;
150 );
145 const x1 = connectE ? SIZE - 1 : fx1;
151
146 if (x >= x0 && x <= x1)
152 const inV = x >= coreX0 && x <= coreX1
147 { return true; }
153 && (
148 }
154 (y >= TOP_Y0 && y <= FACE_Y1)
149 }
155 || (connectN && y < TOP_Y0)
150
156 || (connectS && y > FACE_Y1)
151 if (wantV)
157 );
152 {
158
153 const x0 = CORE_X0;
159 return inH || inV;
154 const x1 = CORE_X1;
155 if (x >= x0 && x <= x1)
156 {
157 const y0 = connectN ? 0 : TOP_Y0;
158 const y1 = connectS ? SIZE - 1 : FACE_Y1;
159 if (y >= y0 && y <= y1)
160 { return true; }
161 }
162 }
163
164 return false;
160}
165}
161
166
162function hash2 (x, y)
167function hash2 (x, y)
@@ -179,6 +184,13 @@ function cobbleShade (base, x, y)
179 return base;
184 return base;
180}
185}
181
186
187function isTopRow (y, connectN)
188{
189 if (connectN)
190 { return y <= TOP_Y1; }
191 return y >= TOP_Y0 && y <= TOP_Y1;
192}
193
182function paintWall (mask)
194function paintWall (mask)
183{
195{
184 const rgba = new Uint8Array(SIZE * SIZE * 4);
196 const rgba = new Uint8Array(SIZE * SIZE * 4);
@@ -200,9 +212,7 @@ function paintWall (mask)
200 const w = inWall(x - 1, y, connectN, connectE, connectS, connectW);
212 const w = inWall(x - 1, y, connectN, connectE, connectS, connectW);
201
213
202 let base;
214 let base;
203 const onTop = y <= TOP_Y1 || (connectN && y < TOP_Y0 + 2 && n && s);
215 if (isTopRow(y, connectN))
204 // Prefer a clear top deck in the core band; south of TOP_Y1 is the face.
205 if (y <= TOP_Y1 && (y >= TOP_Y0 || connectN))
206 {
216 {
207 if (!n)
217 if (!n)
208 { base = TOP_HI; }
218 { base = TOP_HI; }
@@ -213,7 +223,6 @@ function paintWall (mask)
213 }
223 }
214 else
224 else
215 {
225 {
216 // South face / body of the frustum
217 if (!s)
226 if (!s)
218 { base = FACE_LO; }
227 { base = FACE_LO; }
219 else if (!n)
228 else if (!n)
@@ -222,8 +231,10 @@ function paintWall (mask)
222 { base = FACE; }
231 { base = FACE; }
223 }
232 }
224
233
225 // Free side rims read as darker bevels (trapezoid silhouette).
234 // Free side bevels (not on edges that continue into a neighbour).
226 if ((!w && !connectW) || (!e && !connectE))
235 const freeW = !w && !(connectW && x === 0);
236 const freeE = !e && !(connectE && x === SIZE - 1);
237 if (freeW || freeE)
227 {
238 {
228 if (base === TOP || base === TOP_HI)
239 if (base === TOP || base === TOP_HI)
229 { base = TOP_LO; }
240 { base = TOP_LO; }
@@ -238,12 +249,6 @@ function paintWall (mask)
238}
249}
239
250
240mkdirSync(OUT, { recursive: true });
251mkdirSync(OUT, { recursive: true });
241for (const legacy of ["1.png", "2.png"])
242{
243 const path = join(OUT, legacy);
244 if (existsSync(path))
245 { unlinkSync(path); }
246}
247for (let mask = 0; mask < 16; mask++)
252for (let mask = 0; mask < 16; mask++)
248{
253{
249 writeFileSync(join(OUT, `${mask}.png`), encodePng(paintWall(mask)));
254 writeFileSync(join(OUT, `${mask}.png`), encodePng(paintWall(mask)));