ugly-game 0.15.35 → 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.
@@ -766,6 +766,8 @@ export declare class GpuShadowRenderer {
766
766
  camVisible: number;
767
767
  lightVisible: number;
768
768
  lightPerCascade: number[];
769
+ camPerBucket: number[];
770
+ bucketVerts: number[];
769
771
  };
770
772
  private hizPipe;
771
773
  private hizBGL;
@@ -1116,5 +1118,16 @@ export declare class GpuShadowRenderer {
1116
1118
  lightVisible: number;
1117
1119
  /** Per cascade, nearest first. Length is the ACTIVE cascade count, not MAX_CASCADES. */
1118
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[];
1119
1132
  }>;
1120
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 = { total: 0, camVisible: 0, lightVisible: 0, lightPerCascade: [] };
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;
@@ -4428,8 +4435,18 @@ export class GpuShadowRenderer {
4428
4435
  const a = new Uint32Array(this.statsBuf.getMappedRange().slice(0));
4429
4436
  this.statsBuf.unmap();
4430
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 = [];
4431
4448
  for (let b = 0; b < CULL_BUCKETS; b++)
4432
- camVisible += a[b * 4 + 1] ?? 0;
4449
+ bucketVerts.push(a[b * 4] ?? 0);
4433
4450
  const lightPerCascade = [];
4434
4451
  for (let i = 0; i < nc; i++)
4435
4452
  lightPerCascade.push(a[(CULL_BUCKETS + i) * 4 + 1] ?? 0);
@@ -4438,6 +4455,8 @@ export class GpuShadowRenderer {
4438
4455
  camVisible,
4439
4456
  lightVisible: lightPerCascade.reduce((x, y) => x + y, 0),
4440
4457
  lightPerCascade,
4458
+ camPerBucket,
4459
+ bucketVerts,
4441
4460
  };
4442
4461
  return this.lastCull;
4443
4462
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-game",
3
- "version": "0.15.35",
3
+ "version": "0.15.36",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {