ugly-game 0.15.8 → 0.15.9
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.
- package/dist/gpuShadow.d.ts +21 -0
- package/dist/gpuShadow.js +64 -4
- package/package.json +1 -1
package/dist/gpuShadow.d.ts
CHANGED
|
@@ -106,6 +106,27 @@ export declare function occSolid(mask: number, o: readonly [number, number, numb
|
|
|
106
106
|
* one that knows the other block is there.
|
|
107
107
|
*/
|
|
108
108
|
export declare function edgeOpen(mask: number, a: readonly [number, number, number], b: readonly [number, number, number]): number;
|
|
109
|
+
/**
|
|
110
|
+
* THE TAPER — does this edge keep going in the next cell along it?
|
|
111
|
+
*
|
|
112
|
+
* A chamfer used to be all-or-nothing per cell, so where a chamfered edge met a block that does not
|
|
113
|
+
* chamfer (its own neighbour is solid) the rounding STOPPED DEAD in a step the height of the bevel.
|
|
114
|
+
* That is the "concave corners are not rendering correctly" report: at every inside junction a
|
|
115
|
+
* rounded edge ran into a square one and left a hard notch.
|
|
116
|
+
*
|
|
117
|
+
* `j` is the edge's own direction, signed toward the end this vertex sits at. Evaluating `edgeOpen`
|
|
118
|
+
* one cell further along it asks whether the neighbour chamfers the same edge; multiplying, the band
|
|
119
|
+
* fades to nothing across the last block instead of ending in a wall.
|
|
120
|
+
*
|
|
121
|
+
* ⚠️ AND THIS IS WHY IT CANNOT TEAR, which the previous attempt at the same symptom could not claim.
|
|
122
|
+
* Take the two cells sharing a vertex along the edge: one computes `edgeOpen(here) · edgeOpen(there)`
|
|
123
|
+
* and the other computes `edgeOpen(there) · edgeOpen(here)`. The product is SYMMETRIC, so they agree
|
|
124
|
+
* by construction rather than by luck — no block can cut a shared corner its neighbour keeps.
|
|
125
|
+
*
|
|
126
|
+
* Every cell it reads (a+j, b+j, a+b+j) has all components in {-1,0,1}, so it stays inside the
|
|
127
|
+
* 27-neighbourhood the mask carries.
|
|
128
|
+
*/
|
|
129
|
+
export declare function edgeOpenTapered(mask: number, a: readonly [number, number, number], b: readonly [number, number, number], j: readonly [number, number, number]): number;
|
|
109
130
|
/**
|
|
110
131
|
* THE NOTCH — the exact complement of `edgeOpen`: both faces SOLID, the diagonal between them AIR.
|
|
111
132
|
*
|
package/dist/gpuShadow.js
CHANGED
|
@@ -191,6 +191,42 @@ export function edgeOpen(mask, a, b) {
|
|
|
191
191
|
const d = [a[0] + b[0], a[1] + b[1], a[2] + b[2]];
|
|
192
192
|
return ((1 - occSolid(mask, a)) * (1 - occSolid(mask, b)) * (1 - occSolid(mask, d)));
|
|
193
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* THE TAPER — does this edge keep going in the next cell along it?
|
|
196
|
+
*
|
|
197
|
+
* A chamfer used to be all-or-nothing per cell, so where a chamfered edge met a block that does not
|
|
198
|
+
* chamfer (its own neighbour is solid) the rounding STOPPED DEAD in a step the height of the bevel.
|
|
199
|
+
* That is the "concave corners are not rendering correctly" report: at every inside junction a
|
|
200
|
+
* rounded edge ran into a square one and left a hard notch.
|
|
201
|
+
*
|
|
202
|
+
* `j` is the edge's own direction, signed toward the end this vertex sits at. Evaluating `edgeOpen`
|
|
203
|
+
* one cell further along it asks whether the neighbour chamfers the same edge; multiplying, the band
|
|
204
|
+
* fades to nothing across the last block instead of ending in a wall.
|
|
205
|
+
*
|
|
206
|
+
* ⚠️ AND THIS IS WHY IT CANNOT TEAR, which the previous attempt at the same symptom could not claim.
|
|
207
|
+
* Take the two cells sharing a vertex along the edge: one computes `edgeOpen(here) · edgeOpen(there)`
|
|
208
|
+
* and the other computes `edgeOpen(there) · edgeOpen(here)`. The product is SYMMETRIC, so they agree
|
|
209
|
+
* by construction rather than by luck — no block can cut a shared corner its neighbour keeps.
|
|
210
|
+
*
|
|
211
|
+
* Every cell it reads (a+j, b+j, a+b+j) has all components in {-1,0,1}, so it stays inside the
|
|
212
|
+
* 27-neighbourhood the mask carries.
|
|
213
|
+
*/
|
|
214
|
+
export function edgeOpenTapered(mask, a, b, j) {
|
|
215
|
+
const here = edgeOpen(mask, a, b);
|
|
216
|
+
if (here === 0)
|
|
217
|
+
return 0;
|
|
218
|
+
const sa = [a[0] + j[0], a[1] + j[1], a[2] + j[2]];
|
|
219
|
+
const sb = [b[0] + j[0], b[1] + j[1], b[2] + j[2]];
|
|
220
|
+
const sd = [
|
|
221
|
+
a[0] + b[0] + j[0],
|
|
222
|
+
a[1] + b[1] + j[1],
|
|
223
|
+
a[2] + b[2] + j[2],
|
|
224
|
+
];
|
|
225
|
+
return (here *
|
|
226
|
+
(1 - occSolid(mask, sa)) *
|
|
227
|
+
(1 - occSolid(mask, sb)) *
|
|
228
|
+
(1 - occSolid(mask, sd)));
|
|
229
|
+
}
|
|
194
230
|
/**
|
|
195
231
|
* THE NOTCH — the exact complement of `edgeOpen`: both faces SOLID, the diagonal between them AIR.
|
|
196
232
|
*
|
|
@@ -249,10 +285,16 @@ export function bevelVertex(corner, home, mask, bevel) {
|
|
|
249
285
|
const s = Math.sign(corner[k]);
|
|
250
286
|
const e = [0, 0, 0];
|
|
251
287
|
e[k] = s;
|
|
288
|
+
// The edge being cut runs along the THIRD axis — not this face's axis, not the pull axis — and
|
|
289
|
+
// this vertex sits at one end of it. `j` points at that end, which is what the taper needs.
|
|
290
|
+
const jAxis = [0, 1, 2].find((i) => i !== k && home[i] === 0) ?? k;
|
|
291
|
+
const j = [0, 0, 0];
|
|
292
|
+
j[jAxis] = Math.sign(corner[jAxis]);
|
|
252
293
|
out[k] -=
|
|
253
294
|
s *
|
|
254
295
|
bevel *
|
|
255
|
-
(
|
|
296
|
+
(edgeOpenTapered(mask, home, e, j) +
|
|
297
|
+
NOTCH_SCALE * notchOpen(mask, home, e));
|
|
256
298
|
}
|
|
257
299
|
return out;
|
|
258
300
|
}
|
|
@@ -331,6 +373,20 @@ fn notchOpen(mask: u32, a: vec3<f32>, b: vec3<f32>) -> f32 {
|
|
|
331
373
|
// home face. See bevelVertex in TS for why nothing here may move a vertex on an EXPOSED face except
|
|
332
374
|
// the convex term: the visible surface is shared with neighbours computing from their own cells, and
|
|
333
375
|
// a one-sided cut tears it.
|
|
376
|
+
// THE TAPER — does this edge keep going in the next cell along it? A chamfer that was all-or-nothing
|
|
377
|
+
// per cell STOPPED DEAD in a step wherever it met a block that does not chamfer, which is the
|
|
378
|
+
// "concave corners are not rendering correctly" report. j points along the edge toward the end this
|
|
379
|
+
// vertex sits at; asking edgeOpen one cell further fades the band out instead.
|
|
380
|
+
//
|
|
381
|
+
// ⚠️ AND IT CANNOT TEAR: the two cells sharing a vertex along the edge compute edgeOpen(here) *
|
|
382
|
+
// edgeOpen(there) and edgeOpen(there) * edgeOpen(here). The product is SYMMETRIC, so they agree by
|
|
383
|
+
// construction. Mirrors edgeOpenTapered() in TS.
|
|
384
|
+
fn edgeOpenTapered(mask: u32, a: vec3<f32>, b: vec3<f32>, j: vec3<f32>) -> f32 {
|
|
385
|
+
let here = edgeOpen(mask, a, b);
|
|
386
|
+
if (here == 0.0) { return 0.0; }
|
|
387
|
+
return here * (1.0 - occAt(mask, a + j)) * (1.0 - occAt(mask, b + j))
|
|
388
|
+
* (1.0 - occAt(mask, a + b + j));
|
|
389
|
+
}
|
|
334
390
|
fn bevelPos(mask: u32, c: vec3<f32>, a: vec3<f32>, bevel: f32) -> vec3<f32> {
|
|
335
391
|
if (bevel <= 0.0 || mask == 0u) { return c; }
|
|
336
392
|
let free = vec3(1.0, 1.0, 1.0) - abs(a); // the two in-face axes; the face axis is never pulled
|
|
@@ -338,10 +394,14 @@ fn bevelPos(mask: u32, c: vec3<f32>, a: vec3<f32>, bevel: f32) -> vec3<f32> {
|
|
|
338
394
|
let ax = vec3(s.x, 0.0, 0.0);
|
|
339
395
|
let ay = vec3(0.0, s.y, 0.0);
|
|
340
396
|
let az = vec3(0.0, 0.0, s.z);
|
|
397
|
+
// The edge cut along axis k runs along the OTHER free axis; free masks the face axis off, so the
|
|
398
|
+
// partner direction is the sum of the free ones minus this one.
|
|
399
|
+
let fx = free.x * ax; let fy = free.y * ay; let fz = free.z * az;
|
|
400
|
+
let sum = fx + fy + fz;
|
|
341
401
|
var d = vec3(0.0, 0.0, 0.0);
|
|
342
|
-
d.x = free.x * s.x * bevel * (
|
|
343
|
-
d.y = free.y * s.y * bevel * (
|
|
344
|
-
d.z = free.z * s.z * bevel * (
|
|
402
|
+
d.x = free.x * s.x * bevel * (edgeOpenTapered(mask, a, ax, sum - fx) + ${NOTCH_SCALE} * notchOpen(mask, a, ax));
|
|
403
|
+
d.y = free.y * s.y * bevel * (edgeOpenTapered(mask, a, ay, sum - fy) + ${NOTCH_SCALE} * notchOpen(mask, a, ay));
|
|
404
|
+
d.z = free.z * s.z * bevel * (edgeOpenTapered(mask, a, az, sum - fz) + ${NOTCH_SCALE} * notchOpen(mask, a, az));
|
|
345
405
|
return c - d;
|
|
346
406
|
}
|
|
347
407
|
// Vertex AO for cube vertex vi, in [AO_MIN, 1]. Every cube vertex sits at a CORNER, so CUBE_POS is
|