rayzee 9.0.0 → 9.1.0

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.
Files changed (94) hide show
  1. package/README.md +139 -8
  2. package/dist/{NeuralRetouch-CYOJ21Wn.js → NeuralRetouch-BRquqfmZ.js} +1 -1
  3. package/dist/{NeuralSuperRes-CQLCLpcC.js → NeuralSuperRes-CbNvQjCw.js} +3 -2
  4. package/dist/{ToneMapGPU-BVE852iN.js → ToneMapGPU-DpUZDMbQ.js} +2 -1
  5. package/dist/rayzee.es.js +10344 -5334
  6. package/dist/rayzee.umd.js +265 -265
  7. package/package.json +1 -1
  8. package/src/AssetConfig.js +4 -0
  9. package/src/EngineDefaults.js +38 -56
  10. package/src/EngineEvents.js +3 -0
  11. package/src/EngineIssues.js +6 -0
  12. package/src/Headless.js +3 -1
  13. package/src/Passes/AIUpscaler.js +2 -1
  14. package/src/Passes/OIDNDenoiser.js +3 -6
  15. package/src/PathTracerApp.js +290 -19
  16. package/src/Processor/ArchiveCache.js +120 -0
  17. package/src/Processor/ArchiveReader.js +179 -32
  18. package/src/Processor/AssetLoader.js +514 -76
  19. package/src/Processor/AtmosphereModel.js +465 -0
  20. package/src/Processor/BVHBuilder.js +4 -1
  21. package/src/Processor/BVHLeafFold.js +100 -0
  22. package/src/Processor/BVHRefitter.js +98 -214
  23. package/src/Processor/ChunkedRecords.js +189 -4
  24. package/src/Processor/EmissiveTriangleBuilder.js +8 -0
  25. package/src/Processor/GeometryExtractor.js +238 -40
  26. package/src/Processor/InstanceTable.js +55 -37
  27. package/src/Processor/PBRT/PBRTCurves.js +104 -27
  28. package/src/Processor/PBRT/PBRTParser.js +132 -22
  29. package/src/Processor/PBRT/PBRTSceneBuilder.js +192 -49
  30. package/src/Processor/PBRT/buffers.js +27 -0
  31. package/src/Processor/PBRT/index.js +55 -15
  32. package/src/Processor/PackedRayBuffer.js +10 -13
  33. package/src/Processor/ParallelBVHBuilder.js +36 -15
  34. package/src/Processor/PhysicalSky.js +308 -0
  35. package/src/Processor/QueueManager.js +1 -0
  36. package/src/Processor/SceneProcessor.js +1132 -181
  37. package/src/Processor/SplitBLAS.js +249 -0
  38. package/src/Processor/SunPosition.js +41 -0
  39. package/src/Processor/TextureCreator.js +21 -0
  40. package/src/Processor/Workers/AIUpscalerWorker.js +79 -52
  41. package/src/Processor/Workers/BVHWorker.js +17 -13
  42. package/src/Processor/ZipReader.js +207 -0
  43. package/src/RenderSettings.js +38 -0
  44. package/src/SceneState/SceneState.js +367 -0
  45. package/src/SceneState/portable.js +52 -0
  46. package/src/Stages/NormalDepth.js +7 -6
  47. package/src/Stages/PathTracer.js +108 -4
  48. package/src/Stages/PathTracerStage.js +251 -104
  49. package/src/Storage/BLASCache.js +190 -0
  50. package/src/Storage/CDFCache.js +77 -0
  51. package/src/Storage/DownloadCache.js +266 -0
  52. package/src/Storage/GeometrySpill.js +217 -0
  53. package/src/Storage/SceneGraphCodec.js +503 -0
  54. package/src/Storage/SpillStore.js +112 -0
  55. package/src/Storage/StorageManager.js +934 -0
  56. package/src/Storage/StorageOps.js +137 -0
  57. package/src/Storage/StorageWorker.js +37 -0
  58. package/src/Storage/events.js +29 -0
  59. package/src/Storage/identity.js +77 -0
  60. package/src/Storage/index.js +9 -0
  61. package/src/Storage/inlineTransport.js +24 -0
  62. package/src/Storage/locks.js +99 -0
  63. package/src/Storage/openStorage.js +87 -0
  64. package/src/Storage/sceneCachePolicy.js +12 -0
  65. package/src/Storage/shared.js +9 -0
  66. package/src/Storage/transport.js +62 -0
  67. package/src/TSL/Atmosphere.js +684 -0
  68. package/src/TSL/BVHTraversal.js +288 -239
  69. package/src/TSL/Common.js +11 -2
  70. package/src/TSL/Displacement.js +6 -6
  71. package/src/TSL/EmissiveSampling.js +5 -5
  72. package/src/TSL/EnvironmentCDF.js +176 -0
  73. package/src/TSL/GenerateKernel.js +3 -3
  74. package/src/TSL/HitFacet.js +4 -4
  75. package/src/TSL/LightsDirect.js +8 -8
  76. package/src/TSL/LightsSampling.js +55 -37
  77. package/src/TSL/Random.js +1 -0
  78. package/src/TSL/ShadeKernel.js +75 -19
  79. package/src/TSL/Sun.js +40 -0
  80. package/src/TSL/TextureSampling.js +6 -7
  81. package/src/index.js +18 -0
  82. package/src/managers/CameraManager.js +169 -1
  83. package/src/managers/EnvironmentManager.js +263 -33
  84. package/src/managers/GoboManager.js +19 -8
  85. package/src/managers/IESManager.js +3 -3
  86. package/src/managers/LightManager.js +98 -5
  87. package/src/managers/MaterialDataManager.js +22 -2
  88. package/src/managers/TransformManager.js +26 -0
  89. package/src/managers/UniformManager.js +5 -3
  90. package/src/managers/VideoRenderManager.js +3 -1
  91. package/src/managers/timeline/CameraTrack.js +22 -0
  92. package/src/managers/timeline/TimelineManager.js +14 -0
  93. package/src/version.js +3 -0
  94. package/src/Processor/ProceduralSky.js +0 -291
@@ -148,7 +148,7 @@ export class NormalDepth extends RenderStage {
148
148
  if ( ! pt ) return false;
149
149
 
150
150
  const matAttr = pt.materialData?.materialStorageAttr;
151
- const triSwapped = pt.triangleStorageAttr && pt.triangleStorageAttr !== this._lastTriAttr;
151
+ const triSwapped = pt.triangleGeoAttr && pt.triangleGeoAttr !== this._lastTriAttr;
152
152
  const bvhSwapped = pt.bvhStorageAttr && pt.bvhStorageAttr !== this._lastBvhAttr;
153
153
  const matSwapped = matAttr && matAttr !== this._lastMatAttr;
154
154
 
@@ -167,12 +167,13 @@ export class NormalDepth extends RenderStage {
167
167
 
168
168
  }
169
169
 
170
- if ( pt.triangleStorageAttr && ! this._triStorageNode ) {
170
+ if ( pt.triangleGeoAttr && ! this._triStorageNode ) {
171
171
 
172
172
  // uvec4, matching PathTracerStage: packed lanes must keep their exact bit pattern.
173
- this._triStorageNode = storage(
174
- pt.triangleStorageAttr, 'uvec4', pt.triangleStorageAttr.count
175
- ).toReadOnly();
173
+ this._triStorageNode = {
174
+ geo: storage( pt.triangleGeoAttr, 'uvec4', pt.triangleGeoAttr.count ).toReadOnly(),
175
+ shade: storage( pt.triangleShadeAttr, 'uvec4', pt.triangleShadeAttr.count ).toReadOnly(),
176
+ };
176
177
 
177
178
  }
178
179
 
@@ -193,7 +194,7 @@ export class NormalDepth extends RenderStage {
193
194
  // In-place bucket swaps (model change) — graph closes over the nodes, only .value changes.
194
195
  if ( this._linearBuckets ) refreshBucketTextureNodes( this._linearBuckets, pt.materialData?.linearBuckets );
195
196
 
196
- this._lastTriAttr = pt.triangleStorageAttr || this._lastTriAttr;
197
+ this._lastTriAttr = pt.triangleGeoAttr || this._lastTriAttr;
197
198
  this._lastBvhAttr = pt.bvhStorageAttr || this._lastBvhAttr;
198
199
  this._lastMatAttr = matAttr || this._lastMatAttr;
199
200
 
@@ -188,7 +188,7 @@ export class PathTracer extends PathTracerStage {
188
188
  } );
189
189
 
190
190
  // Scene geometry (triangle data, two-level BVH, light BVH + emissive)
191
- t.register( 'geometry', () => [ this.triangleStorageAttr, this.bvhStorageAttr, this.lightStorageAttr ] );
191
+ t.register( 'geometry', () => [ this.triangleGeoAttr, this.triangleShadeAttr, this.bvhStorageAttr, this.lightStorageAttr ] );
192
192
 
193
193
  // Material storage buffer + per-property texture arrays
194
194
  t.register( 'materials', () => {
@@ -547,6 +547,107 @@ export class PathTracer extends PathTracerStage {
547
547
 
548
548
  }
549
549
 
550
+ /**
551
+ * The accumulation as it stands, for a checkpoint: the three MRT attachments (aux only while it
552
+ * holds samples), the per-pixel convergence buffers, and the counters that decide the next
553
+ * sample — together what a later frame reads, so restoring them continues the same sequence.
554
+ * @returns {Promise<Object>} typed arrays, tight rows, top row first as the textures hold them
555
+ */
556
+ async captureAccumulation() {
557
+
558
+ const pool = this.storageTextures;
559
+ const width = pool.renderWidth;
560
+ const height = pool.renderHeight;
561
+ const pixels = width * height;
562
+
563
+ const readAttachment = async index => {
564
+
565
+ const padded = await this.renderer.readRenderTargetPixelsAsync( pool.readTarget, 0, 0, width, height, index );
566
+ const stride = Math.ceil( width * 16 / 256 ) * 64;
567
+ if ( stride === width * 4 ) return new Float32Array( padded.buffer, padded.byteOffset, pixels * 4 ).slice();
568
+ const tight = new Float32Array( pixels * 4 );
569
+ for ( let y = 0; y < height; y ++ ) tight.set( padded.subarray( y * stride, y * stride + width * 4 ), y * width * 4 );
570
+ return tight;
571
+
572
+ };
573
+
574
+ const readBuffer = async ( attr, Type ) => attr ? new Type( await this.renderer.getArrayBufferAsync( attr, null, 0, pixels * 4 ) ) : null;
575
+ const aux = this._auxGBufferEnabled && this._auxSamples > 0;
576
+
577
+ // Every copy is submitted here, in this task, before any await: a frame rendered between two of
578
+ // them would give a checkpoint whose parts disagree.
579
+ const state = {
580
+ frameCount: this.frameCount,
581
+ seedTick: this._seedTick,
582
+ auxSamples: aux ? this._auxSamples : 0,
583
+ convergedFraction: this._convergedFraction,
584
+ convergedGeometryFraction: this._convergedGeometryFraction,
585
+ isComplete: this.isComplete,
586
+ };
587
+ const reads = [
588
+ readAttachment( 0 ),
589
+ aux ? readAttachment( 1 ) : null,
590
+ aux ? readAttachment( 2 ) : null,
591
+ readBuffer( this._m2Attr, Float32Array ),
592
+ readBuffer( this._streakAttr, Uint32Array ),
593
+ readBuffer( this._frozenMaskAttr, Uint32Array ),
594
+ ];
595
+ const [ color, normalDepth, albedo, m2, streak, frozenMask ] = await Promise.all( reads );
596
+
597
+ return { width, height, state, color, normalDepth, albedo, m2, streak, frozenMask };
598
+
599
+ }
600
+
601
+ /**
602
+ * Writes a {@link captureAccumulation} back, so the next frame continues it. The render size must
603
+ * match; nothing may reset accumulation after this.
604
+ */
605
+ restoreAccumulation( checkpoint ) {
606
+
607
+ const pool = this.storageTextures;
608
+ const { width, height, state } = checkpoint;
609
+ if ( pool.renderWidth !== width || pool.renderHeight !== height ) {
610
+
611
+ throw new Error( `checkpoint is ${width}×${height}; the render is ${pool.renderWidth}×${pool.renderHeight}` );
612
+
613
+ }
614
+
615
+ const backend = this.renderer.backend;
616
+ const device = backend.device;
617
+ if ( ! backend.get( pool.readTarget.textures[ 0 ] ).texture ) this.renderer.initRenderTarget( pool.readTarget );
618
+
619
+ const writeAttachment = ( index, data ) => device.queue.writeTexture(
620
+ { texture: backend.get( pool.readTarget.textures[ index ] ).texture },
621
+ data,
622
+ { bytesPerRow: width * 16, rowsPerImage: height },
623
+ { width, height },
624
+ );
625
+
626
+ const writeBuffer = ( attr, data ) => {
627
+
628
+ if ( attr && data ) device.queue.writeBuffer( backend.get( attr ).buffer, 0, data );
629
+
630
+ };
631
+
632
+ writeAttachment( 0, checkpoint.color );
633
+ if ( checkpoint.normalDepth ) writeAttachment( 1, checkpoint.normalDepth );
634
+ if ( checkpoint.albedo ) writeAttachment( 2, checkpoint.albedo );
635
+ writeBuffer( this._m2Attr, checkpoint.m2 );
636
+ writeBuffer( this._streakAttr, checkpoint.streak );
637
+ writeBuffer( this._frozenMaskAttr, checkpoint.frozenMask );
638
+
639
+ this.frameCount = state.frameCount;
640
+ this.frame.value = state.frameCount;
641
+ this._seedTick = state.seedTick;
642
+ this.hasPreviousAccumulated.value = state.frameCount > 0 ? 1 : 0;
643
+ this._auxSamples = checkpoint.normalDepth ? state.auxSamples : 0;
644
+ this._auxSeedPending = this._auxGBufferEnabled && ! checkpoint.normalDepth;
645
+ this._convergedFraction = state.convergedFraction ?? 0;
646
+ this._convergedGeometryFraction = state.convergedGeometryFraction ?? 0;
647
+ this.isComplete = false;
648
+
649
+ }
650
+
550
651
  reset() {
551
652
 
552
653
  super.reset();
@@ -1147,7 +1248,7 @@ export class PathTracer extends PathTracerStage {
1147
1248
 
1148
1249
  const genParams = {
1149
1250
  rayBufferRW: pb.rayBuffer.rw,
1150
- rngBufferRW: pb.rngBuffer.rw,
1251
+ hitBufferRW: pb.hitBuffer.rw,
1151
1252
  gBufferRW,
1152
1253
  resolution: this.resolution,
1153
1254
  // RNG axis only (baseSeed + stratified jitter) — takes the seed counter, not the
@@ -1458,8 +1559,7 @@ export class PathTracer extends PathTracerStage {
1458
1559
  envCDFTexture: freshEnvCDF,
1459
1560
  lightBuffer: freshLight,
1460
1561
  rayBufferRW: pb.rayBuffer.rw,
1461
- rngBufferRW: pb.rngBuffer.rw,
1462
- hitBufferRO: pb.hitBuffer.ro,
1562
+ hitBufferRW: pb.hitBuffer.rw,
1463
1563
  counters,
1464
1564
  activeIndicesRO: this._sortMaterials ? qm.getSortedRO() : qm.getActiveReadRO(),
1465
1565
  envTexture: freshEnvTex,
@@ -1512,6 +1612,10 @@ export class PathTracer extends PathTracerStage {
1512
1612
  maxRayCount: this._wfMaxRayCount,
1513
1613
  chunkRowBase: this._wfChunkRowBase,
1514
1614
  auxGBufferEnabled: this._auxGBufferUniform,
1615
+ hasSun: this.hasSun,
1616
+ sunDirection: this.sunDirection,
1617
+ sunRadiance: this.sunRadiance,
1618
+ sunParams: this.sunParams,
1515
1619
  } );
1516
1620
  this._kernelManager.register( 'shade',
1517
1621
  shadeFn().compute(