ugly-game 0.15.34 → 0.15.36
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 +17 -0
- package/dist/gpuShadow.js +39 -5
- package/package.json +1 -1
package/dist/gpuShadow.d.ts
CHANGED
|
@@ -765,6 +765,9 @@ export declare class GpuShadowRenderer {
|
|
|
765
765
|
total: number;
|
|
766
766
|
camVisible: number;
|
|
767
767
|
lightVisible: number;
|
|
768
|
+
lightPerCascade: number[];
|
|
769
|
+
camPerBucket: number[];
|
|
770
|
+
bucketVerts: number[];
|
|
768
771
|
};
|
|
769
772
|
private hizPipe;
|
|
770
773
|
private hizBGL;
|
|
@@ -1111,6 +1114,20 @@ export declare class GpuShadowRenderer {
|
|
|
1111
1114
|
readCullStats(): Promise<{
|
|
1112
1115
|
total: number;
|
|
1113
1116
|
camVisible: number;
|
|
1117
|
+
/** Every cascade's submission summed — what the sun's passes cost between them. */
|
|
1114
1118
|
lightVisible: number;
|
|
1119
|
+
/** Per cascade, nearest first. Length is the ACTIVE cascade count, not MAX_CASCADES. */
|
|
1120
|
+
lightPerCascade: number[];
|
|
1121
|
+
/**
|
|
1122
|
+
* The camera's survivors split by VERTEX-COUNT BUCKET, and the vertex count each bucket draws.
|
|
1123
|
+
*
|
|
1124
|
+
* ⚠️ WITHOUT THIS, "how expensive is an instance" HAS NO DENOMINATOR. A cube costs between 6 and
|
|
1125
|
+
* 36 vertices depending on how many of its faces are exposed, so a frame time divided by an
|
|
1126
|
+
* instance count is an average over a distribution nobody has looked at — and the whole point of
|
|
1127
|
+
* face-cull bucketing is that the distribution is heavily skewed. Multiplying these two arrays
|
|
1128
|
+
* gives the vertices actually submitted, which is the number a vertex-bound frame is bound by.
|
|
1129
|
+
*/
|
|
1130
|
+
camPerBucket: number[];
|
|
1131
|
+
bucketVerts: number[];
|
|
1115
1132
|
}>;
|
|
1116
1133
|
}
|
package/dist/gpuShadow.js
CHANGED
|
@@ -3100,7 +3100,14 @@ 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 = {
|
|
3103
|
+
lastCull = {
|
|
3104
|
+
total: 0,
|
|
3105
|
+
camVisible: 0,
|
|
3106
|
+
lightVisible: 0,
|
|
3107
|
+
lightPerCascade: [],
|
|
3108
|
+
camPerBucket: [],
|
|
3109
|
+
bucketVerts: [],
|
|
3110
|
+
};
|
|
3104
3111
|
// Hi-Z OCCLUSION: a coarse max-depth buffer rebuilt from each frame's depth, sampled by next frame's camera cull.
|
|
3105
3112
|
hizPipe;
|
|
3106
3113
|
hizBGL;
|
|
@@ -3518,8 +3525,13 @@ export class GpuShadowRenderer {
|
|
|
3518
3525
|
}
|
|
3519
3526
|
this.camCullBG = this.cullBG(this.camArgs, this.camVis, this.camCull);
|
|
3520
3527
|
this.lightCullBG = this.lightArgs.map((a, i) => this.cullBG(a, this.lightVis[i], this.lightCull[i]));
|
|
3528
|
+
// ⚠️ ROOM FOR EVERY CASCADE, NOT ONE. This used to hold `CULL_BUCKETS + 1` indirect-arg slots —
|
|
3529
|
+
// the camera's buckets plus cascade 0 — so with three cascades two thirds of the shadow
|
|
3530
|
+
// submission was simply invisible. A three-cascade run then reported a `lightVisible` that
|
|
3531
|
+
// looked unchanged from the one-cascade case, which reads as "the split is doing nothing" when
|
|
3532
|
+
// what it actually meant was "you are looking at the nearest slice only".
|
|
3521
3533
|
this.statsBuf = this.device.createBuffer({
|
|
3522
|
-
size: 4 * 4 * (CULL_BUCKETS +
|
|
3534
|
+
size: 4 * 4 * (CULL_BUCKETS + MAX_CASCADES),
|
|
3523
3535
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
3524
3536
|
});
|
|
3525
3537
|
}
|
|
@@ -4411,18 +4423,40 @@ export class GpuShadowRenderer {
|
|
|
4411
4423
|
// vertex-count bucket, so args[0].ic alone reports whatever fraction happened to be simple —
|
|
4412
4424
|
// 45% on ordinary terrain — and every caller that trusts camVisible would silently under-read.
|
|
4413
4425
|
enc.copyBufferToBuffer(this.camArgs, 0, this.statsBuf, 0, 16 * CULL_BUCKETS);
|
|
4414
|
-
|
|
4426
|
+
// ⚠️ AND EVERY CASCADE, for the same reason the camera reads every bucket: a total assembled from
|
|
4427
|
+
// one of several passes is not a total, and the failure is silent under-reporting rather than an
|
|
4428
|
+
// error. `nc` here is what `ensureCascades` last allocated, so a config change is picked up
|
|
4429
|
+
// without the caller having to say what it changed to.
|
|
4430
|
+
const nc = Math.max(1, Math.min(MAX_CASCADES, this.lightArgs.length));
|
|
4431
|
+
for (let i = 0; i < nc; i++)
|
|
4432
|
+
enc.copyBufferToBuffer(this.lightArgs[i], 0, this.statsBuf, 16 * (CULL_BUCKETS + i), 16);
|
|
4415
4433
|
this.device.queue.submit([enc.finish()]);
|
|
4416
4434
|
await this.statsBuf.mapAsync(GPUMapMode.READ);
|
|
4417
4435
|
const a = new Uint32Array(this.statsBuf.getMappedRange().slice(0));
|
|
4418
4436
|
this.statsBuf.unmap();
|
|
4419
4437
|
let camVisible = 0;
|
|
4438
|
+
const camPerBucket = [];
|
|
4439
|
+
for (let b = 0; b < CULL_BUCKETS; b++) {
|
|
4440
|
+
const n = a[b * 4 + 1] ?? 0;
|
|
4441
|
+
camPerBucket.push(n);
|
|
4442
|
+
camVisible += n;
|
|
4443
|
+
}
|
|
4444
|
+
// ⚠️ THE VERTEX COUNT COMES FROM THE INDIRECT ARGS, NOT FROM A CONSTANT. `frame` picks the
|
|
4445
|
+
// bucket vertex counts per frame — bevel sections, face-cull buckets, or three copies of the
|
|
4446
|
+
// sharp cube — and writing the constant here would misreport every configuration but one.
|
|
4447
|
+
const bucketVerts = [];
|
|
4420
4448
|
for (let b = 0; b < CULL_BUCKETS; b++)
|
|
4421
|
-
|
|
4449
|
+
bucketVerts.push(a[b * 4] ?? 0);
|
|
4450
|
+
const lightPerCascade = [];
|
|
4451
|
+
for (let i = 0; i < nc; i++)
|
|
4452
|
+
lightPerCascade.push(a[(CULL_BUCKETS + i) * 4 + 1] ?? 0);
|
|
4422
4453
|
this.lastCull = {
|
|
4423
4454
|
total: this.count,
|
|
4424
4455
|
camVisible,
|
|
4425
|
-
lightVisible:
|
|
4456
|
+
lightVisible: lightPerCascade.reduce((x, y) => x + y, 0),
|
|
4457
|
+
lightPerCascade,
|
|
4458
|
+
camPerBucket,
|
|
4459
|
+
bucketVerts,
|
|
4426
4460
|
};
|
|
4427
4461
|
return this.lastCull;
|
|
4428
4462
|
}
|