ugly-game 0.15.7 → 0.15.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -128,18 +128,26 @@ export declare const NOTCH_SCALE = 0.5;
128
128
  * THE VERTEX RULE, in JS — the oracle `gpuShadow.bevel.test.mts` checks and the exact thing
129
129
  * `bevelPos()` in COMMON_WGSL does. Kept in step with it by hand; the test is what notices.
130
130
  *
131
- * A vertex's pull along a free axis `k` is inward (`-sign(corner[k])`), gated by one of three
132
- * conditions on that axis:
131
+ * A vertex's pull along a free axis `k` is inward (`-sign(corner[k])`), gated by two conditions on
132
+ * that axis, which cannot both hold (one needs `home` AIR, the other needs it SOLID):
133
133
  *
134
134
  * CONVEX — `edgeOpen(home, e_k)`. The ordinary chamfer, at full size.
135
- * NOTCH, FLANKING — `notchOpen(home, e_k)`. This vertex is on one of the two faces meeting at a
136
- * notch edge; this cuts that edge itself.
137
- * NOTCH, CAPPING — `notchOpen(e_k, e_j)`, `j` being the OTHER free axis. This vertex is on the
138
- * face PERPENDICULAR to a notch edge — the ground above it, say. Both its free axes pull, which
139
- * cuts that face's corner diagonally so the notch chamfer does not stop dead in a step.
135
+ * NOTCH — `notchOpen(home, e_k)`, at `NOTCH_SCALE`. Softens the inside corner of an L.
140
136
  *
141
- * The convex term cannot collide with either notch term: it requires both cells AIR, they require
142
- * one SOLID.
137
+ * ⚠️ NEITHER TERM MAY EVER MOVE A VERTEX ON AN EXPOSED FACE EXCEPT THE CONVEX ONE, and the oracle
138
+ * asserts it over 800 masks. An exposed face is part of the surface you can SEE, and its corners are
139
+ * shared with the neighbouring blocks that own the rest of that surface — each computing from its
140
+ * OWN neighbourhood. A term reading cells this block can see and its neighbour cannot will move a
141
+ * shared corner one-sidedly and tear the ground open.
142
+ *
143
+ * The convex term is safe because it requires the cell across the shared face to be AIR, and if it
144
+ * is air there is no neighbour to disagree with. `notchOpen` is safe because it requires `home`
145
+ * SOLID — a buried face, where the neighbour's own full face closes the wedge.
146
+ *
147
+ * A third "capping" term once cut an exposed face's corner wherever the in-plane diagonal was air,
148
+ * to stop the notch chamfer ending in a step. That is a plain diagonal step-down in any heightmap,
149
+ * the neighbour sharing the corner could not make the same cut, and it shipped as visibly torn
150
+ * ground — "concave corners are not rendering correctly". The step is the correct trade.
143
151
  */
144
152
  export declare function bevelVertex(corner: readonly [number, number, number], home: readonly [number, number, number], mask: number, bevel: number): [number, number, number];
145
153
  export declare class GpuShadowRenderer {
package/dist/gpuShadow.js CHANGED
@@ -218,39 +218,41 @@ export const NOTCH_SCALE = 0.5;
218
218
  * THE VERTEX RULE, in JS — the oracle `gpuShadow.bevel.test.mts` checks and the exact thing
219
219
  * `bevelPos()` in COMMON_WGSL does. Kept in step with it by hand; the test is what notices.
220
220
  *
221
- * A vertex's pull along a free axis `k` is inward (`-sign(corner[k])`), gated by one of three
222
- * conditions on that axis:
221
+ * A vertex's pull along a free axis `k` is inward (`-sign(corner[k])`), gated by two conditions on
222
+ * that axis, which cannot both hold (one needs `home` AIR, the other needs it SOLID):
223
223
  *
224
224
  * CONVEX — `edgeOpen(home, e_k)`. The ordinary chamfer, at full size.
225
- * NOTCH, FLANKING — `notchOpen(home, e_k)`. This vertex is on one of the two faces meeting at a
226
- * notch edge; this cuts that edge itself.
227
- * NOTCH, CAPPING — `notchOpen(e_k, e_j)`, `j` being the OTHER free axis. This vertex is on the
228
- * face PERPENDICULAR to a notch edge — the ground above it, say. Both its free axes pull, which
229
- * cuts that face's corner diagonally so the notch chamfer does not stop dead in a step.
225
+ * NOTCH — `notchOpen(home, e_k)`, at `NOTCH_SCALE`. Softens the inside corner of an L.
230
226
  *
231
- * The convex term cannot collide with either notch term: it requires both cells AIR, they require
232
- * one SOLID.
227
+ * ⚠️ NEITHER TERM MAY EVER MOVE A VERTEX ON AN EXPOSED FACE EXCEPT THE CONVEX ONE, and the oracle
228
+ * asserts it over 800 masks. An exposed face is part of the surface you can SEE, and its corners are
229
+ * shared with the neighbouring blocks that own the rest of that surface — each computing from its
230
+ * OWN neighbourhood. A term reading cells this block can see and its neighbour cannot will move a
231
+ * shared corner one-sidedly and tear the ground open.
232
+ *
233
+ * The convex term is safe because it requires the cell across the shared face to be AIR, and if it
234
+ * is air there is no neighbour to disagree with. `notchOpen` is safe because it requires `home`
235
+ * SOLID — a buried face, where the neighbour's own full face closes the wedge.
236
+ *
237
+ * A third "capping" term once cut an exposed face's corner wherever the in-plane diagonal was air,
238
+ * to stop the notch chamfer ending in a step. That is a plain diagonal step-down in any heightmap,
239
+ * the neighbour sharing the corner could not make the same cut, and it shipped as visibly torn
240
+ * ground — "concave corners are not rendering correctly". The step is the correct trade.
233
241
  */
234
242
  export function bevelVertex(corner, home, mask, bevel) {
235
243
  const out = [corner[0], corner[1], corner[2]];
236
244
  if (bevel <= 0 || mask === 0)
237
245
  return out;
238
- const free = [0, 1, 2].filter((i) => home[i] === 0); // the two in-face axes
239
- const axis = (i) => {
240
- const v = [0, 0, 0];
241
- v[i] = Math.sign(corner[i]);
242
- return v;
243
- };
244
- for (const k of free) {
245
- const j = free.find((f) => f !== k) ?? k;
246
- const bk = axis(k);
247
- // ⚠️ max, NOT +. See the note above: both notch terms hold at once on a face flanking two
248
- // notches at right angles, and summing there pulls the corner twice as far as any neighbour
249
- // agrees to — which is a crack.
250
- const notch = Math.max(notchOpen(mask, home, bk), notchOpen(mask, bk, axis(j)));
246
+ for (let k = 0; k < 3; k++) {
247
+ if (home[k] !== 0)
248
+ continue; // the face axis itself is never pulled
249
+ const s = Math.sign(corner[k]);
250
+ const e = [0, 0, 0];
251
+ e[k] = s;
251
252
  out[k] -=
252
- Math.sign(corner[k]) *
253
- (bevel * edgeOpen(mask, home, bk) + bevel * NOTCH_SCALE * notch);
253
+ s *
254
+ bevel *
255
+ (edgeOpen(mask, home, e) + NOTCH_SCALE * notchOpen(mask, home, e));
254
256
  }
255
257
  return out;
256
258
  }
@@ -324,12 +326,11 @@ fn notchOpen(mask: u32, a: vec3<f32>, b: vec3<f32>) -> f32 {
324
326
  if (mask == 0u) { return 0.0; }
325
327
  return occAt(mask, a) * occAt(mask, b) * (1.0 - occAt(mask, a + b));
326
328
  }
327
- // The vertex rule. A vertex's pull along a free axis is INWARD, gated by the edge between its home
328
- // face and the face on that side (CONVEX, full size), or by a notch it flanks, or by a notch it caps
329
- // from the perpendicular face — see bevelVertex in TS for the full statement.
330
- //
331
- // ⚠️ max, NOT +, ON THE TWO NOTCH TERMS. Both hold at once on a face flanking two notches at right
332
- // angles, and summing there pulls that corner twice as far as any neighbour agrees to — a crack.
329
+ // The vertex rule. A vertex's pull along a free axis is INWARD, gated by the CONVEX chamfer (both
330
+ // cells air) or the NOTCH (both solid, diagonal air) — never both, since they disagree about the
331
+ // home face. See bevelVertex in TS for why nothing here may move a vertex on an EXPOSED face except
332
+ // the convex term: the visible surface is shared with neighbours computing from their own cells, and
333
+ // a one-sided cut tears it.
333
334
  fn bevelPos(mask: u32, c: vec3<f32>, a: vec3<f32>, bevel: f32) -> vec3<f32> {
334
335
  if (bevel <= 0.0 || mask == 0u) { return c; }
335
336
  let free = vec3(1.0, 1.0, 1.0) - abs(a); // the two in-face axes; the face axis is never pulled
@@ -337,17 +338,10 @@ fn bevelPos(mask: u32, c: vec3<f32>, a: vec3<f32>, bevel: f32) -> vec3<f32> {
337
338
  let ax = vec3(s.x, 0.0, 0.0);
338
339
  let ay = vec3(0.0, s.y, 0.0);
339
340
  let az = vec3(0.0, 0.0, s.z);
340
- // The OTHER free axis for each axis: one of the three is masked off by "free", so the remaining
341
- // two are each other's partner — the partner direction is the sum of the free ones minus this one.
342
- let fx = free.x * ax; let fy = free.y * ay; let fz = free.z * az;
343
- let sum = fx + fy + fz;
344
341
  var d = vec3(0.0, 0.0, 0.0);
345
- d.x = free.x * s.x * bevel * (edgeOpen(mask, a, ax)
346
- + ${NOTCH_SCALE} * max(notchOpen(mask, a, ax), notchOpen(mask, ax, sum - fx)));
347
- d.y = free.y * s.y * bevel * (edgeOpen(mask, a, ay)
348
- + ${NOTCH_SCALE} * max(notchOpen(mask, a, ay), notchOpen(mask, ay, sum - fy)));
349
- d.z = free.z * s.z * bevel * (edgeOpen(mask, a, az)
350
- + ${NOTCH_SCALE} * max(notchOpen(mask, a, az), notchOpen(mask, az, sum - fz)));
342
+ d.x = free.x * s.x * bevel * (edgeOpen(mask, a, ax) + ${NOTCH_SCALE} * notchOpen(mask, a, ax));
343
+ d.y = free.y * s.y * bevel * (edgeOpen(mask, a, ay) + ${NOTCH_SCALE} * notchOpen(mask, a, ay));
344
+ d.z = free.z * s.z * bevel * (edgeOpen(mask, a, az) + ${NOTCH_SCALE} * notchOpen(mask, a, az));
351
345
  return c - d;
352
346
  }
353
347
  // Vertex AO for cube vertex vi, in [AO_MIN, 1]. Every cube vertex sits at a CORNER, so CUBE_POS is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-game",
3
- "version": "0.15.7",
3
+ "version": "0.15.8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {