ugly-game 0.15.33 → 0.15.35
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 +4 -0
- package/dist/gpuShadow.js +20 -5
- package/package.json +1 -1
package/dist/gpuShadow.d.ts
CHANGED
|
@@ -765,6 +765,7 @@ export declare class GpuShadowRenderer {
|
|
|
765
765
|
total: number;
|
|
766
766
|
camVisible: number;
|
|
767
767
|
lightVisible: number;
|
|
768
|
+
lightPerCascade: number[];
|
|
768
769
|
};
|
|
769
770
|
private hizPipe;
|
|
770
771
|
private hizBGL;
|
|
@@ -1111,6 +1112,9 @@ export declare class GpuShadowRenderer {
|
|
|
1111
1112
|
readCullStats(): Promise<{
|
|
1112
1113
|
total: number;
|
|
1113
1114
|
camVisible: number;
|
|
1115
|
+
/** Every cascade's submission summed — what the sun's passes cost between them. */
|
|
1114
1116
|
lightVisible: number;
|
|
1117
|
+
/** Per cascade, nearest first. Length is the ACTIVE cascade count, not MAX_CASCADES. */
|
|
1118
|
+
lightPerCascade: number[];
|
|
1115
1119
|
}>;
|
|
1116
1120
|
}
|
package/dist/gpuShadow.js
CHANGED
|
@@ -3100,7 +3100,7 @@ export class GpuShadowRenderer {
|
|
|
3100
3100
|
/** Current shadow-map edge length; see setShadowMapSize. */
|
|
3101
3101
|
shadowSize = SHADOW_SIZE;
|
|
3102
3102
|
/** Last frame's visible counts (main-pass camera cull, shadow-pass light cull) + total — for IR/telemetry. */
|
|
3103
|
-
lastCull = { total: 0, camVisible: 0, lightVisible: 0 };
|
|
3103
|
+
lastCull = { total: 0, camVisible: 0, lightVisible: 0, lightPerCascade: [] };
|
|
3104
3104
|
// Hi-Z OCCLUSION: a coarse max-depth buffer rebuilt from each frame's depth, sampled by next frame's camera cull.
|
|
3105
3105
|
hizPipe;
|
|
3106
3106
|
hizBGL;
|
|
@@ -3518,8 +3518,13 @@ export class GpuShadowRenderer {
|
|
|
3518
3518
|
}
|
|
3519
3519
|
this.camCullBG = this.cullBG(this.camArgs, this.camVis, this.camCull);
|
|
3520
3520
|
this.lightCullBG = this.lightArgs.map((a, i) => this.cullBG(a, this.lightVis[i], this.lightCull[i]));
|
|
3521
|
+
// ⚠️ ROOM FOR EVERY CASCADE, NOT ONE. This used to hold `CULL_BUCKETS + 1` indirect-arg slots —
|
|
3522
|
+
// the camera's buckets plus cascade 0 — so with three cascades two thirds of the shadow
|
|
3523
|
+
// submission was simply invisible. A three-cascade run then reported a `lightVisible` that
|
|
3524
|
+
// looked unchanged from the one-cascade case, which reads as "the split is doing nothing" when
|
|
3525
|
+
// what it actually meant was "you are looking at the nearest slice only".
|
|
3521
3526
|
this.statsBuf = this.device.createBuffer({
|
|
3522
|
-
size: 4 * 4 * (CULL_BUCKETS +
|
|
3527
|
+
size: 4 * 4 * (CULL_BUCKETS + MAX_CASCADES),
|
|
3523
3528
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
3524
3529
|
});
|
|
3525
3530
|
}
|
|
@@ -4411,18 +4416,28 @@ export class GpuShadowRenderer {
|
|
|
4411
4416
|
// vertex-count bucket, so args[0].ic alone reports whatever fraction happened to be simple —
|
|
4412
4417
|
// 45% on ordinary terrain — and every caller that trusts camVisible would silently under-read.
|
|
4413
4418
|
enc.copyBufferToBuffer(this.camArgs, 0, this.statsBuf, 0, 16 * CULL_BUCKETS);
|
|
4414
|
-
|
|
4419
|
+
// ⚠️ AND EVERY CASCADE, for the same reason the camera reads every bucket: a total assembled from
|
|
4420
|
+
// one of several passes is not a total, and the failure is silent under-reporting rather than an
|
|
4421
|
+
// error. `nc` here is what `ensureCascades` last allocated, so a config change is picked up
|
|
4422
|
+
// without the caller having to say what it changed to.
|
|
4423
|
+
const nc = Math.max(1, Math.min(MAX_CASCADES, this.lightArgs.length));
|
|
4424
|
+
for (let i = 0; i < nc; i++)
|
|
4425
|
+
enc.copyBufferToBuffer(this.lightArgs[i], 0, this.statsBuf, 16 * (CULL_BUCKETS + i), 16);
|
|
4415
4426
|
this.device.queue.submit([enc.finish()]);
|
|
4416
4427
|
await this.statsBuf.mapAsync(GPUMapMode.READ);
|
|
4417
4428
|
const a = new Uint32Array(this.statsBuf.getMappedRange().slice(0));
|
|
4418
4429
|
this.statsBuf.unmap();
|
|
4419
4430
|
let camVisible = 0;
|
|
4420
4431
|
for (let b = 0; b < CULL_BUCKETS; b++)
|
|
4421
|
-
camVisible += a[b * 4 + 1];
|
|
4432
|
+
camVisible += a[b * 4 + 1] ?? 0;
|
|
4433
|
+
const lightPerCascade = [];
|
|
4434
|
+
for (let i = 0; i < nc; i++)
|
|
4435
|
+
lightPerCascade.push(a[(CULL_BUCKETS + i) * 4 + 1] ?? 0);
|
|
4422
4436
|
this.lastCull = {
|
|
4423
4437
|
total: this.count,
|
|
4424
4438
|
camVisible,
|
|
4425
|
-
lightVisible:
|
|
4439
|
+
lightVisible: lightPerCascade.reduce((x, y) => x + y, 0),
|
|
4440
|
+
lightPerCascade,
|
|
4426
4441
|
};
|
|
4427
4442
|
return this.lastCull;
|
|
4428
4443
|
}
|