ugly-game 0.15.77 → 0.15.79

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.
@@ -103,6 +103,15 @@ export interface PropRendererOptions extends Partial<PropLook> {
103
103
  format: GPUTextureFormat;
104
104
  transferWGSL: string;
105
105
  };
106
+ /** Optional shared scene fog. WGSL defines `propFog(color, delta, legacy, uniform)`
107
+ * returning linear RGB. `delta` is relative to the camera and `legacy` is
108
+ * the frame's RGB and density. The uniform type must have 16-byte alignment
109
+ * or less and fit in `uniformWords` floats, a positive multiple of four. */
110
+ fog?: {
111
+ wgsl: string;
112
+ uniformType: string;
113
+ uniformWords: number;
114
+ };
106
115
  /** Compile material/topology inspection channels. Off by default. On the
107
116
  * first topology view, an expanded corner stream is built for wire/density. */
108
117
  inspection?: boolean;
@@ -346,6 +355,7 @@ export declare class GpuPropsRenderer {
346
355
  private drawBGL;
347
356
  private occPipe;
348
357
  private uBuf;
358
+ private readonly fogUniformWords;
349
359
  private readonly pointLightWords;
350
360
  /**
351
361
  * The occluder's per-cascade uniform — lightVP + wind. ONE PER CASCADE, and that is a bug fix, not
@@ -377,6 +387,9 @@ export declare class GpuPropsRenderer {
377
387
  * the LOD system rather than merely to the encoder.
378
388
  */
379
389
  private geo;
390
+ private geometrySlots;
391
+ private geometryVertices;
392
+ private geometryIndices;
380
393
  private cullVis;
381
394
  private cullBGs;
382
395
  /** Survivor lists are per (model, cascade) but packed into one buffer per model at this stride. */
@@ -447,7 +460,15 @@ export declare class GpuPropsRenderer {
447
460
  * `setModels` had been given that alpha; back at 1 it is opaque and casts again.
448
461
  */
449
462
  setMaterial(model: number, surface: Pick<PropMesh, 'alpha' | 'roughness' | 'metalness' | 'clearcoat' | 'clearcoatRoughness' | 'directClearcoat' | 'reflectionStrength' | 'specularIntensity' | 'metalFlakes' | 'flakeScale' | 'pearlStrength'>): void;
450
- setModels(meshes: PropMesh[]): void;
463
+ /**
464
+ * Replace the draw list and report the geometry bytes written by this call.
465
+ * Pass retainGeometry for immutable meshes whose identities survive draw-list
466
+ * changes. The arena appends new geometry until full, then compacts to the
467
+ * active list. Callers with mutable mesh arrays use the default upload path.
468
+ */
469
+ setModels(meshes: PropMesh[], retainGeometry?: boolean): number;
470
+ /** Allocated geometry only. Includes unused arena capacity. */
471
+ geometryBufferBytes(): number;
451
472
  /**
452
473
  * Group instances by model and upload the per-model instance buffers.
453
474
  *
@@ -502,7 +523,7 @@ export declare class GpuPropsRenderer {
502
523
  * a single shared uniform written once per cascade during encoding does not work — see `lightBufs`.
503
524
  */
504
525
  shadowPass(pass: GPURenderPassEncoder, lightVP: Float32Array, cascade?: number): void;
505
- frame(enc: GPUCommandEncoder, colorView: GPUTextureView, depthView: GPUTextureView, camVP: Float32Array, sunDir: [number, number, number], sunCol: [number, number, number], amb: [number, number, number], camPos: [number, number, number], fog: [number, number, number], fogDensity: number, up?: [number, number, number], lightVP?: Float32Array | Float32Array[], shadowView?: GPUTextureView, shadowSamp?: GPUSampler, channel?: PropInspectionChannel, sceneTexture?: GPUTexture): void;
526
+ frame(enc: GPUCommandEncoder, colorView: GPUTextureView, depthView: GPUTextureView, camVP: Float32Array, sunDir: [number, number, number], sunCol: [number, number, number], amb: [number, number, number], camPos: [number, number, number], fog: [number, number, number], fogDensity: number, up?: [number, number, number], lightVP?: Float32Array | Float32Array[], shadowView?: GPUTextureView, shadowSamp?: GPUSampler, channel?: PropInspectionChannel, sceneTexture?: GPUTexture, fogUniform?: Float32Array): void;
506
527
  /** Draw over the presented compositor result, testing its final depth.
507
528
  * Reuses the same uploaded instances, material bindings and frame uniforms. */
508
529
  framePresentation(enc: GPUCommandEncoder, colorView: GPUTextureView, depthView: GPUTextureView, sceneTexture?: GPUTexture): void;
@@ -20,7 +20,7 @@ export const MAX_CASCADES = 4; // must match gpuShadow's
20
20
  export const MAX_PROP_POINT_LIGHTS = 8;
21
21
  const POINT_LIGHT_WORDS = 4 + MAX_PROP_POINT_LIGHTS * 16;
22
22
  const PROP_UNIFORM_WORDS = 72 + 16 * MAX_CASCADES + 8 + POINT_LIGHT_WORDS;
23
- const drawShader = (inspect, split, transfer = '') => /* wgsl */ `
23
+ const drawShader = (inspect, split, transfer = '', fog) => /* wgsl */ `
24
24
  // wind = (dirX, dirZ, amplitude, phase) — sway, amplitude scaled by the world's air density
25
25
  // surf = (grainScale, grainDepth, roughness, emissive)
26
26
  // grade = (hueShift, saturation, valueLift, unused)
@@ -34,8 +34,15 @@ const drawShader = (inspect, split, transfer = '') => /* wgsl */ `
34
34
  // look2 = (shadow filter 0 pcf3 / 1 pcf5 / 2 pcf7 / 3 poisson, radius in texels,
35
35
  // scene-environment max lod, scene-environment irradiance lod)
36
36
  struct PointLight { positionRadius: vec4<f32>, colorBounce: vec4<f32>, roomCenter: vec4<f32>, roomHalfSize: vec4<f32> };
37
- struct U { mvp: mat4x4<f32>, lightVP: mat4x4<f32>, sun: vec4<f32>, sunCol: vec4<f32>, amb: vec4<f32>, cam: vec4<f32>, fog: vec4<f32>, up: vec4<f32>, wind: vec4<f32>, surf: vec4<f32>, grade: vec4<f32>, csm: vec4<f32>, cascades: array<mat4x4<f32>, ${MAX_CASCADES}>, look: vec4<f32>, look2: vec4<f32>, pointMeta: vec4<f32>, pointLights: array<PointLight, ${MAX_PROP_POINT_LIGHTS}> };
37
+ ${fog?.wgsl ?? ''}
38
+ struct U { mvp: mat4x4<f32>, lightVP: mat4x4<f32>, sun: vec4<f32>, sunCol: vec4<f32>, amb: vec4<f32>, cam: vec4<f32>, fog: vec4<f32>, up: vec4<f32>, wind: vec4<f32>, surf: vec4<f32>, grade: vec4<f32>, csm: vec4<f32>, cascades: array<mat4x4<f32>, ${MAX_CASCADES}>, look: vec4<f32>, look2: vec4<f32>, pointMeta: vec4<f32>, pointLights: array<PointLight, ${MAX_PROP_POINT_LIGHTS}>${fog ? `, fogUniform: ${fog.uniformType}` : ''} };
38
39
  @group(0) @binding(0) var<uniform> u: U;
40
+ fn applyPropFog(color: vec3<f32>, world: vec3<f32>) -> vec3<f32> {
41
+ let delta = world - u.cam.xyz;
42
+ ${fog
43
+ ? 'return propFog(color, delta, u.fog, u.fogUniform);'
44
+ : 'return mix(color, u.fog.xyz, clamp(1.0-exp(-length(delta)*u.fog.w),0.0,1.0));'}
45
+ }
39
46
  // One instance. 'm' is the placement; d0/d1/d2 are the per-instance DEFORM, which is what lets
40
47
  // thousands of visibly different plants share a single mesh and a single draw call. Baking each
41
48
  // variant on the CPU instead costs one model, one vertex buffer and one draw call per plant —
@@ -423,8 +430,7 @@ fn shade(i: VO) -> vec4<f32> {
423
430
  base = hsvShift(base, u.grade.x, max(u.grade.y, 0.0), max(u.grade.z, 0.0));
424
431
  ${inspect ? inspectionFragment : ''}
425
432
  if (mtl.optics.y > 1.5) {
426
- let fog = clamp(1.0-exp(-length(i.world-u.cam.xyz)*u.fog.w),0.0,1.0);
427
- return vec4(mix(propEmission(tex.rgb,i.c,normalize(i.n),i.world),u.fog.xyz,fog),mtl.mat.x);
433
+ return vec4(applyPropFog(propEmission(tex.rgb,i.c,normalize(i.n),i.world),i.world),mtl.mat.x);
428
434
  }
429
435
  let spec = u.surf.z;
430
436
  var lit = base * (u.amb.xyz * ff + d * u.sunCol.xyz * sh * (1.0 + spec * 0.6))
@@ -523,8 +529,6 @@ fn shade(i: VO) -> vec4<f32> {
523
529
  // clipping reflected softboxes to a flat white patch.
524
530
  lit = toneMap(hdr);
525
531
  }
526
- let dist = length(i.world - u.cam.xyz);
527
- let f = clamp(1.0 - exp(-dist * u.fog.w), 0.0, 1.0);
528
532
  // mtl.mat.x is the model's opacity, 1 for every model that does not set it — the same constant
529
533
  // this returned before, so the opaque pipeline draws exactly what it always did.
530
534
  var opacity = surfaceOpacity(N,i.world);
@@ -553,7 +557,7 @@ fn shade(i: VO) -> vec4<f32> {
553
557
  }
554
558
  // A display-referred render texture (rear-view camera) is already lit.
555
559
  if (mtl.optics.y > 0.5) { return vec4(tex.rgb, mtl.mat.x); }
556
- return vec4(mix(lit, u.fog.xyz, f), opacity);
560
+ return vec4(applyPropFog(lit, i.world), opacity);
557
561
  }
558
562
  @fragment fn fs(i: VO) -> @location(0) vec4<f32> {
559
563
  let color = shade(i);
@@ -753,6 +757,7 @@ export class GpuPropsRenderer {
753
757
  drawBGL;
754
758
  occPipe;
755
759
  uBuf;
760
+ fogUniformWords;
756
761
  pointLightWords = new Float32Array(POINT_LIGHT_WORDS);
757
762
  /**
758
763
  * The occluder's per-cascade uniform — lightVP + wind. ONE PER CASCADE, and that is a bug fix, not
@@ -788,6 +793,9 @@ export class GpuPropsRenderer {
788
793
  * the LOD system rather than merely to the encoder.
789
794
  */
790
795
  geo = null;
796
+ geometrySlots = new WeakMap();
797
+ geometryVertices = 0;
798
+ geometryIndices = 0;
791
799
  cullVis = []; // survivor list — per MODEL, see cullPass
792
800
  cullBGs = [];
793
801
  /** Survivor lists are per (model, cascade) but packed into one buffer per model at this stride. */
@@ -896,7 +904,7 @@ export class GpuPropsRenderer {
896
904
  constructor(device, format, options = {}) {
897
905
  this.device = device;
898
906
  this.format = format;
899
- const { inspection = false, sampleCount = 1, depth = FORWARD_DEPTH, shadowDepthFormat = 'depth32float', presentation, ...look } = options;
907
+ const { inspection = false, sampleCount = 1, depth = FORWARD_DEPTH, shadowDepthFormat = 'depth32float', presentation, fog, ...look } = options;
900
908
  // Runtime guard for untyped callers: WebGPU only guarantees 1 and 4.
901
909
  if (![1, 4].includes(sampleCount))
902
910
  throw new RangeError(`Unsupported prop sampleCount ${String(sampleCount)}`);
@@ -905,11 +913,19 @@ export class GpuPropsRenderer {
905
913
  this.sampleCount = sampleCount;
906
914
  this.depth = depth;
907
915
  this.presentation = presentation;
916
+ this.fogUniformWords = fog?.uniformWords ?? 0;
917
+ if (fog &&
918
+ (!Number.isInteger(fog.uniformWords) ||
919
+ fog.uniformWords <= 0 ||
920
+ fog.uniformWords % 4 !== 0 ||
921
+ (PROP_UNIFORM_WORDS + fog.uniformWords) * 4 >
922
+ device.limits.maxUniformBufferBindingSize))
923
+ throw new RangeError('Invalid prop fog uniform size');
908
924
  this.setLook(look);
909
925
  this.inspection = inspection;
910
926
  this.srgbTarget = format.endsWith('-srgb');
911
927
  const sm = device.createShaderModule({
912
- code: drawShader(inspection, !!presentation),
928
+ code: drawShader(inspection, !!presentation, '', fog),
913
929
  });
914
930
  // The three groups the SHADER declares, written out so BOTH render pipelines share them. Under
915
931
  // `layout: 'auto'` each pipeline would mint its own and the bind groups built elsewhere in this
@@ -1069,7 +1085,7 @@ export class GpuPropsRenderer {
1069
1085
  fragment: {
1070
1086
  ...base.fragment,
1071
1087
  module: (presentationModule ??= device.createShaderModule({
1072
- code: drawShader(inspection, true, presentation.transferWGSL),
1088
+ code: drawShader(inspection, true, presentation.transferWGSL, fog),
1073
1089
  })),
1074
1090
  targets: [
1075
1091
  {
@@ -1124,7 +1140,7 @@ export class GpuPropsRenderer {
1124
1140
  },
1125
1141
  });
1126
1142
  this.uBuf = device.createBuffer({
1127
- size: PROP_UNIFORM_WORDS * 4,
1143
+ size: (PROP_UNIFORM_WORDS + this.fogUniformWords) * 4,
1128
1144
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
1129
1145
  });
1130
1146
  for (let c = 0; c < MAX_CASCADES; c++)
@@ -1253,7 +1269,13 @@ export class GpuPropsRenderer {
1253
1269
  if (changed)
1254
1270
  this.device.queue.writeBuffer(packed.matBuf, 0, packed.materialValues);
1255
1271
  }
1256
- setModels(meshes) {
1272
+ /**
1273
+ * Replace the draw list and report the geometry bytes written by this call.
1274
+ * Pass retainGeometry for immutable meshes whose identities survive draw-list
1275
+ * changes. The arena appends new geometry until full, then compacts to the
1276
+ * active list. Callers with mutable mesh arrays use the default upload path.
1277
+ */
1278
+ setModels(meshes, retainGeometry = false) {
1257
1279
  this.glassInstances.length = 0;
1258
1280
  if (!meshes.some((m) => m.glassThickness))
1259
1281
  this.releaseGlassSnapshots();
@@ -1309,54 +1331,86 @@ export class GpuPropsRenderer {
1309
1331
  // Indices stay MODEL-LOCAL and are offset by `baseVertex` at draw time rather than being rewritten
1310
1332
  // — rewriting them would work equally well for the camera pass and would silently break the
1311
1333
  // occluder pass, whose index buffer is fed to `drawIndexedIndirect` with args the GPU writes.
1312
- const totalVerts = meshes.reduce((n, m) => n + m.positions.length / 3, 0);
1313
- const totalIdx = meshes.reduce((n, m) => n + m.indices.length, 0);
1314
- // Cooked streams already have the GPU layout. Upload them directly to their
1315
- // arena offsets instead of allocating/copying five more CPU-sized arenas.
1316
- this.geo?.destroy();
1317
- this.geo = {
1318
- pos: dev.createBuffer({
1319
- size: Math.max(12, totalVerts * 12),
1320
- usage: U.VERTEX | U.COPY_DST,
1321
- }),
1322
- nrm: dev.createBuffer({
1323
- size: Math.max(12, totalVerts * 12),
1324
- usage: U.VERTEX | U.COPY_DST,
1325
- }),
1326
- col: dev.createBuffer({
1327
- size: Math.max(12, totalVerts * 12),
1328
- usage: U.VERTEX | U.COPY_DST,
1329
- }),
1330
- uv: dev.createBuffer({
1331
- size: Math.max(8, totalVerts * 8),
1332
- usage: U.VERTEX | U.COPY_DST,
1333
- }),
1334
- idx: dev.createBuffer({
1335
- size: Math.max(4, totalIdx * 4),
1336
- usage: U.INDEX | U.COPY_DST,
1337
- }),
1338
- destroy() {
1339
- for (const buffer of [this.pos, this.nrm, this.col, this.uv, this.idx])
1340
- buffer.destroy();
1341
- },
1342
- };
1334
+ const missing = retainGeometry
1335
+ ? [...new Set(meshes.filter((mesh) => !this.geometrySlots.has(mesh)))]
1336
+ : meshes;
1337
+ const newVertices = missing.reduce((n, m) => n + m.positions.length / 3, 0);
1338
+ const newIndices = missing.reduce((n, m) => n + m.indices.length, 0);
1339
+ const reuseArena = retainGeometry &&
1340
+ meshes.length > 0 &&
1341
+ this.geo &&
1342
+ this.geometryVertices + newVertices <= this.geo.pos.size / 12 &&
1343
+ this.geometryIndices + newIndices <= this.geo.idx.size / 4;
1344
+ if (!reuseArena) {
1345
+ const headroom = retainGeometry ? 2 : 1;
1346
+ const active = retainGeometry ? [...new Set(meshes)] : meshes;
1347
+ const vertices = active.reduce((n, m) => n + m.positions.length / 3, 0);
1348
+ const indices = active.reduce((n, m) => n + m.indices.length, 0);
1349
+ const maxBuffer = dev.limits.maxBufferSize;
1350
+ const vertexCapacity = Math.max(vertices, Math.min(vertices * headroom, Math.floor(maxBuffer / 12)));
1351
+ const indexCapacity = Math.max(indices, Math.min(indices * headroom, Math.floor(maxBuffer / 4)));
1352
+ this.geometrySlots = new WeakMap();
1353
+ this.geometryVertices = 0;
1354
+ this.geometryIndices = 0;
1355
+ this.geo?.destroy();
1356
+ this.geo = {
1357
+ pos: dev.createBuffer({
1358
+ size: Math.max(12, vertexCapacity * 12),
1359
+ usage: U.VERTEX | U.COPY_DST,
1360
+ }),
1361
+ nrm: dev.createBuffer({
1362
+ size: Math.max(12, vertexCapacity * 12),
1363
+ usage: U.VERTEX | U.COPY_DST,
1364
+ }),
1365
+ col: dev.createBuffer({
1366
+ size: Math.max(12, vertexCapacity * 12),
1367
+ usage: U.VERTEX | U.COPY_DST,
1368
+ }),
1369
+ uv: dev.createBuffer({
1370
+ size: Math.max(8, vertexCapacity * 8),
1371
+ usage: U.VERTEX | U.COPY_DST,
1372
+ }),
1373
+ idx: dev.createBuffer({
1374
+ size: Math.max(4, indexCapacity * 4),
1375
+ usage: U.INDEX | U.COPY_DST,
1376
+ }),
1377
+ destroy() {
1378
+ for (const buffer of [
1379
+ this.pos,
1380
+ this.nrm,
1381
+ this.col,
1382
+ this.uv,
1383
+ this.idx,
1384
+ ])
1385
+ buffer.destroy();
1386
+ },
1387
+ };
1388
+ }
1389
+ let uploadedBytes = 0;
1343
1390
  const upload = (buffer, offset, data) => {
1344
- if (data.byteLength)
1345
- dev.queue.writeBuffer(buffer, offset, data);
1391
+ if (!data.byteLength)
1392
+ return;
1393
+ dev.queue.writeBuffer(buffer, offset, data);
1394
+ uploadedBytes += data.byteLength;
1346
1395
  };
1347
- let vCursor = 0, iCursor = 0;
1348
1396
  this.models = meshes.map((m, modelIndex) => {
1349
- const verts = m.positions.length / 3;
1350
- const baseVertex = vCursor, firstIndex = iCursor;
1351
- upload(this.geo.pos, baseVertex * 12, m.positions);
1352
- upload(this.geo.nrm, baseVertex * 12, m.normals);
1353
- upload(this.geo.col, baseVertex * 12, m.colors);
1354
- // Fresh WebGPU allocations are zero initialized, including absent UVs.
1355
- if (m.uvs)
1356
- upload(this.geo.uv, baseVertex * 8, m.uvs);
1357
- upload(this.geo.idx, firstIndex * 4, m.indices);
1358
- vCursor += verts;
1359
- iCursor += m.indices.length;
1397
+ let slot = retainGeometry ? this.geometrySlots.get(m) : undefined;
1398
+ if (!slot) {
1399
+ const baseVertex = this.geometryVertices;
1400
+ const firstIndex = this.geometryIndices;
1401
+ slot = { baseVertex, firstIndex };
1402
+ upload(this.geo.pos, baseVertex * 12, m.positions);
1403
+ upload(this.geo.nrm, baseVertex * 12, m.normals);
1404
+ upload(this.geo.col, baseVertex * 12, m.colors);
1405
+ // Appended ranges are still zero initialized, including absent UVs.
1406
+ if (m.uvs)
1407
+ upload(this.geo.uv, baseVertex * 8, m.uvs);
1408
+ upload(this.geo.idx, firstIndex * 4, m.indices);
1409
+ this.geometryVertices += m.positions.length / 3;
1410
+ this.geometryIndices += m.indices.length;
1411
+ if (retainGeometry)
1412
+ this.geometrySlots.set(m, slot);
1413
+ }
1360
1414
  // A GPUTexture is already uploaded and already mipped (the KTX2 path) — bind it directly.
1361
1415
  // Only an ImageBitmap needs uploadAlbedo's hand-rolled half-scale mip chain.
1362
1416
  const ownsTex = !!m.albedo && !(m.albedo instanceof GPUTexture);
@@ -1416,8 +1470,7 @@ export class GpuPropsRenderer {
1416
1470
  matBuf,
1417
1471
  materialValues,
1418
1472
  ownsTex,
1419
- firstIndex,
1420
- baseVertex,
1473
+ ...slot,
1421
1474
  idxCount: m.indices.length,
1422
1475
  extent: m.extent ?? measureExtent(m.positions),
1423
1476
  tex,
@@ -1437,6 +1490,16 @@ export class GpuPropsRenderer {
1437
1490
  }),
1438
1491
  };
1439
1492
  });
1493
+ for (const buffer of this.instBufs)
1494
+ buffer?.destroy();
1495
+ for (const buffer of this.cullVis)
1496
+ buffer?.destroy();
1497
+ for (const cascade of this.cullU)
1498
+ for (const buffer of cascade)
1499
+ buffer?.destroy();
1500
+ for (const cascade of this.cullArgs)
1501
+ for (const buffer of cascade)
1502
+ buffer?.destroy();
1440
1503
  this.caps = meshes.map(() => 0);
1441
1504
  this.instBufs = meshes.map(() => null);
1442
1505
  this.bgs = meshes.map(() => null);
@@ -1449,6 +1512,14 @@ export class GpuPropsRenderer {
1449
1512
  this.cullVis = meshes.map(() => null);
1450
1513
  this.visStride = meshes.map(() => 0);
1451
1514
  this.cullReady = false;
1515
+ return uploadedBytes;
1516
+ }
1517
+ /** Allocated geometry only. Includes unused arena capacity. */
1518
+ geometryBufferBytes() {
1519
+ const { geo } = this;
1520
+ return geo
1521
+ ? geo.pos.size + geo.nrm.size + geo.col.size + geo.uv.size + geo.idx.size
1522
+ : 0;
1452
1523
  }
1453
1524
  /**
1454
1525
  * Group instances by model and upload the per-model instance buffers.
@@ -1768,7 +1839,7 @@ export class GpuPropsRenderer {
1768
1839
  frame(enc, colorView, depthView, camVP, sunDir, sunCol, amb, camPos, fog, fogDensity, up,
1769
1840
  // Optional sun shadow-receive: pass the terrain's lightVP + shadow-map view + comparison sampler and props sit
1770
1841
  // in the same shadow. Omit all three (the demo path) → no shadowing, byte-identical to before.
1771
- lightVP, shadowView, shadowSamp, channel = 'lit', sceneTexture) {
1842
+ lightVP, shadowView, shadowSamp, channel = 'lit', sceneTexture, fogUniform) {
1772
1843
  if (this.glassInstances.length)
1773
1844
  this.glassVP.set(camVP);
1774
1845
  this.glassCopyPixels.scene = this.glassCopyPixels.presentation = 0;
@@ -1776,7 +1847,12 @@ export class GpuPropsRenderer {
1776
1847
  throw new Error('Prop inspection must be enabled at construction.');
1777
1848
  const receive = !!(lightVP && shadowView && shadowSamp);
1778
1849
  const mats = lightVP ? (Array.isArray(lightVP) ? lightVP : [lightVP]) : [];
1779
- const u = new Float32Array(PROP_UNIFORM_WORDS);
1850
+ const u = new Float32Array(PROP_UNIFORM_WORDS + this.fogUniformWords);
1851
+ if (fogUniform) {
1852
+ if (fogUniform.length !== this.fogUniformWords || !this.fogUniformWords)
1853
+ throw new RangeError('Prop fog uniform does not match the renderer');
1854
+ u.set(fogUniform, PROP_UNIFORM_WORDS);
1855
+ }
1780
1856
  u.set(camVP, 0);
1781
1857
  u.set(mats[0] ?? IDENTITY4, 16); // legacy cascade-0 slot, kept so the offsets above never move
1782
1858
  u.set([sunDir[0], sunDir[1], sunDir[2], receive ? 1 : 0], 32); // sun.w = shadow-receive enable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-game",
3
- "version": "0.15.77",
3
+ "version": "0.15.79",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {