rayzee 9.0.0 → 9.1.1

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 (95) 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 +10353 -5337
  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/KernelManager.js +4 -1
  28. package/src/Processor/PBRT/PBRTCurves.js +104 -27
  29. package/src/Processor/PBRT/PBRTParser.js +132 -22
  30. package/src/Processor/PBRT/PBRTSceneBuilder.js +192 -49
  31. package/src/Processor/PBRT/buffers.js +27 -0
  32. package/src/Processor/PBRT/index.js +55 -15
  33. package/src/Processor/PackedRayBuffer.js +10 -13
  34. package/src/Processor/ParallelBVHBuilder.js +36 -15
  35. package/src/Processor/PhysicalSky.js +308 -0
  36. package/src/Processor/QueueManager.js +1 -0
  37. package/src/Processor/SceneProcessor.js +1132 -181
  38. package/src/Processor/SplitBLAS.js +249 -0
  39. package/src/Processor/SunPosition.js +41 -0
  40. package/src/Processor/TextureCreator.js +21 -0
  41. package/src/Processor/Workers/AIUpscalerWorker.js +79 -52
  42. package/src/Processor/Workers/BVHWorker.js +17 -13
  43. package/src/Processor/ZipReader.js +207 -0
  44. package/src/RenderSettings.js +38 -0
  45. package/src/SceneState/SceneState.js +367 -0
  46. package/src/SceneState/portable.js +52 -0
  47. package/src/Stages/NormalDepth.js +7 -6
  48. package/src/Stages/PathTracer.js +108 -4
  49. package/src/Stages/PathTracerStage.js +251 -104
  50. package/src/Storage/BLASCache.js +190 -0
  51. package/src/Storage/CDFCache.js +77 -0
  52. package/src/Storage/DownloadCache.js +266 -0
  53. package/src/Storage/GeometrySpill.js +217 -0
  54. package/src/Storage/SceneGraphCodec.js +503 -0
  55. package/src/Storage/SpillStore.js +112 -0
  56. package/src/Storage/StorageManager.js +934 -0
  57. package/src/Storage/StorageOps.js +137 -0
  58. package/src/Storage/StorageWorker.js +37 -0
  59. package/src/Storage/events.js +29 -0
  60. package/src/Storage/identity.js +77 -0
  61. package/src/Storage/index.js +9 -0
  62. package/src/Storage/inlineTransport.js +24 -0
  63. package/src/Storage/locks.js +99 -0
  64. package/src/Storage/openStorage.js +87 -0
  65. package/src/Storage/sceneCachePolicy.js +12 -0
  66. package/src/Storage/shared.js +9 -0
  67. package/src/Storage/transport.js +62 -0
  68. package/src/TSL/Atmosphere.js +684 -0
  69. package/src/TSL/BVHTraversal.js +288 -239
  70. package/src/TSL/Common.js +11 -2
  71. package/src/TSL/Displacement.js +6 -6
  72. package/src/TSL/EmissiveSampling.js +5 -5
  73. package/src/TSL/EnvironmentCDF.js +176 -0
  74. package/src/TSL/GenerateKernel.js +3 -3
  75. package/src/TSL/HitFacet.js +4 -4
  76. package/src/TSL/LightsDirect.js +8 -8
  77. package/src/TSL/LightsSampling.js +55 -37
  78. package/src/TSL/Random.js +1 -0
  79. package/src/TSL/ShadeKernel.js +75 -19
  80. package/src/TSL/Sun.js +40 -0
  81. package/src/TSL/TextureSampling.js +6 -7
  82. package/src/index.js +18 -0
  83. package/src/managers/CameraManager.js +169 -1
  84. package/src/managers/EnvironmentManager.js +263 -33
  85. package/src/managers/GoboManager.js +19 -8
  86. package/src/managers/IESManager.js +3 -3
  87. package/src/managers/LightManager.js +98 -5
  88. package/src/managers/MaterialDataManager.js +22 -2
  89. package/src/managers/TransformManager.js +26 -0
  90. package/src/managers/UniformManager.js +5 -3
  91. package/src/managers/VideoRenderManager.js +3 -1
  92. package/src/managers/timeline/CameraTrack.js +22 -0
  93. package/src/managers/timeline/TimelineManager.js +14 -0
  94. package/src/version.js +3 -0
  95. package/src/Processor/ProceduralSky.js +0 -291
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayzee",
3
- "version": "9.0.0",
3
+ "version": "9.1.1",
4
4
  "type": "module",
5
5
  "description": "Real-time WebGPU path tracing engine built on Three.js",
6
6
  "main": "dist/rayzee.umd.js",
@@ -56,6 +56,10 @@ const config = {
56
56
  // Prefix used when the engine writes to client-side stores (IndexedDB, etc).
57
57
  // Set to a unique value to avoid collisions when multiple apps embed the engine on the same origin.
58
58
  cacheNamespace: 'rayzee',
59
+
60
+ // On-disk storage (origin private file system) under a directory named by cacheNamespace:
61
+ // 'auto' uses it where the browser has one, false turns every storage feature off.
62
+ storage: 'auto',
59
63
  };
60
64
 
61
65
  /**
@@ -1,3 +1,10 @@
1
+ import { sunPosition, dayOfYearForMonth } from './Processor/SunPosition.js';
2
+
3
+ /** The default sun as a time of day (solar hours), month and latitude; north lies along −Z. */
4
+ export const DEFAULT_SUN_PATH = Object.freeze( { time: 10, month: 3, latitude: 40 } );
5
+
6
+ const DEFAULT_SUN = sunPosition( { hours: DEFAULT_SUN_PATH.time, dayOfYear: dayOfYearForMonth( DEFAULT_SUN_PATH.month ), latitude: DEFAULT_SUN_PATH.latitude } );
7
+
1
8
  /**
2
9
  * Engine-owned default values and configuration constants.
3
10
  * These are used exclusively by the rendering engine (src/core/)
@@ -94,14 +101,17 @@ export const ENGINE_DEFAULTS = {
94
101
  // Solid Color Sky
95
102
  solidSkyColor: '#87CEEB',
96
103
 
97
- // Procedural Sky Parameters (Preetham Model - Clear Morning preset)
98
- skySunAzimuth: 90,
99
- skySunElevation: 20,
100
- skySunIntensity: 15.0,
101
- skyRayleighDensity: 0.9,
102
- skyTurbidity: 0.8,
103
- skyMieAnisotropy: 0.76,
104
- skyPreset: 'clearMorning',
104
+ // Physical sky (Processor/PhysicalSky.js) — the Clear Day preset
105
+ skySunAzimuth: 180 - DEFAULT_SUN.azimuth,
106
+ skySunElevation: DEFAULT_SUN.elevation,
107
+ skySunStrength: 1, // artistic multiplier on the disc and its light; 1 is physical
108
+ skySunSize: 0.53, // angular diameter, degrees
109
+ skyTurbidity: 2, // 1 is aerosol-free air, ~2 a clear day, 6+ hazy
110
+ skyOzone: 300, // Dobson units
111
+ skyAirDensity: 1,
112
+ skyGroundAlbedo: '#959595', // 0.3 linear
113
+ skyAltitude: 50, // metres
114
+ skyPreset: 'clearDay',
105
115
 
106
116
  // Camera projection — 'perspective' | 'orthographic' | 'equirectangular'. Panorama ranges are UI-facing degrees.
107
117
  cameraProjection: 'perspective',
@@ -427,55 +437,17 @@ export const CAMERA_RANGES = {
427
437
  }
428
438
  };
429
439
 
440
+ // `exposure` (EV) makes up about two thirds of the light a lower sun loses, as a photographer
441
+ // would: a sunset still reads darker than noon.
430
442
  export const SKY_PRESETS = {
431
- clearMorning: {
432
- name: "Clear Morning",
433
- sunAzimuth: 90,
434
- sunElevation: 20,
435
- sunIntensity: 15.0,
436
- rayleighDensity: 0.9,
437
- turbidity: 0.8,
438
- },
439
- clearNoon: {
440
- name: "Clear Noon",
441
- sunAzimuth: 0,
442
- sunElevation: 75,
443
- sunIntensity: 20.0,
444
- rayleighDensity: 1.0,
445
- turbidity: 0.3,
446
- },
447
- overcast: {
448
- name: "Overcast",
449
- sunAzimuth: 0,
450
- sunElevation: 45,
451
- sunIntensity: 6.0,
452
- rayleighDensity: 0.6,
453
- turbidity: 4.0,
454
- },
455
- goldenHour: {
456
- name: "Golden Hour",
457
- sunAzimuth: 270,
458
- sunElevation: 10,
459
- sunIntensity: 19.0,
460
- rayleighDensity: 0.8,
461
- turbidity: 1.2,
462
- },
463
- sunset: {
464
- name: "Sunset",
465
- sunAzimuth: 270,
466
- sunElevation: 2,
467
- sunIntensity: 18.0,
468
- rayleighDensity: 0.7,
469
- turbidity: 2.0,
470
- },
471
- dusk: {
472
- name: "Dusk",
473
- sunAzimuth: 270,
474
- sunElevation: - 8,
475
- sunIntensity: 8.0,
476
- rayleighDensity: 0.5,
477
- turbidity: 1.5,
478
- }
443
+ clearDay: { name: 'Clear Day', sunAzimuth: 180 - DEFAULT_SUN.azimuth, sunElevation: DEFAULT_SUN.elevation, turbidity: 2, exposure: 0 },
444
+ clearMorning: { name: 'Clear Morning', sunAzimuth: 90, sunElevation: 15, turbidity: 2, exposure: 1.4 },
445
+ clearNoon: { name: 'Clear Noon', sunAzimuth: 180, sunElevation: 70, turbidity: 2, exposure: 0 },
446
+ hazyAfternoon: { name: 'Hazy Afternoon', sunAzimuth: 225, sunElevation: 35, turbidity: 4.5, exposure: 0.4 },
447
+ goldenHour: { name: 'Golden Hour', sunAzimuth: 270, sunElevation: 6, turbidity: 2.5, exposure: 2.7 },
448
+ sunset: { name: 'Sunset', sunAzimuth: 270, sunElevation: 1, turbidity: 3, exposure: 4.2 },
449
+ blueHour: { name: 'Blue Hour', sunAzimuth: 270, sunElevation: - 4, turbidity: 2, exposure: 7 },
450
+ mountain: { name: 'Mountain Air', sunAzimuth: 135, sunElevation: 40, turbidity: 1.3, altitude: 3000, exposure: 0 },
479
451
  };
480
452
 
481
453
  export const CAMERA_PRESETS = {
@@ -836,6 +808,16 @@ export const BVH_LEAF_MARKERS = {
836
808
  FRONTIER: 0x40000002, // parallel-build placeholder, overwritten during assembly
837
809
  };
838
810
 
811
+ /**
812
+ * A triangle leaf of at most this many triangles is folded into its parent: the child's slot ([3]
813
+ * or [7]) holds `~( first << 4 | count )`, the very value traversal pushes, so an inner node is
814
+ * read exactly as before and only popping a negative entry differs. Node indices stay below
815
+ * {@link BVH_MAX_INDEX}, leaf tags between it and 2^31, folded leaves from 2^31 up — so the count
816
+ * has four bits and the first triangle must stay below {@link BVH_FOLDED_FIRST_LIMIT}.
817
+ */
818
+ export const BVH_FOLDED_LEAF_MAX = 15;
819
+ export const BVH_FOLDED_FIRST_LIMIT = 1 << 27;
820
+
839
821
  /** A u32 view over a float buffer, for writing index fields as exact bit patterns. */
840
822
  export function bvhIndexView( f32 ) {
841
823
 
@@ -65,4 +65,7 @@ export const EngineEvents = {
65
65
 
66
66
  // Scene metadata
67
67
  SCENE_METADATA_APPLIED: 'engine:sceneMetadataApplied',
68
+
69
+ // Storage (OPFS): usage or entries changed
70
+ STORAGE_CHANGED: 'engine:storageChanged',
68
71
  };
@@ -24,6 +24,12 @@ export const ISSUE_CODES = Object.freeze( {
24
24
  VIEW_TRANSFORM_DISPLAY_MISMATCH: 'viewTransform.display_mismatch',
25
25
  VIEW_TRANSFORM_BAKE_FAILED: 'viewTransform.bake_failed',
26
26
  COLOR_CONFIG_LOAD_FAILED: 'color.config_load_failed',
27
+ STORAGE_UNAVAILABLE: 'storage.unavailable',
28
+ STORAGE_QUOTA_EXCEEDED: 'storage.quota_exceeded',
29
+ STORAGE_WRITE_FAILED: 'storage.write_failed',
30
+ STORAGE_READ_FAILED: 'storage.read_failed',
31
+ STORAGE_ENTRY_CORRUPT: 'storage.entry_corrupt',
32
+ STORAGE_CACHE_MISMATCH: 'storage.cache_mismatch',
27
33
  } );
28
34
 
29
35
  /** Strict throws on ERROR only. */
package/src/Headless.js CHANGED
@@ -81,11 +81,13 @@ export async function openHeadless( {
81
81
  profile = 'physical',
82
82
  deterministic = true,
83
83
  settings = null,
84
+ storage = false,
84
85
  } = {} ) {
85
86
 
86
87
  if ( ! canvas ) throw new Error( 'openHeadless: a canvas is required' );
87
88
 
88
- const app = new PathTracerApp( canvas, { autoResize: false, strict, profile } );
89
+ // Off unless asked for: cached state from an earlier run must not change what a batch renders.
90
+ const app = new PathTracerApp( canvas, { autoResize: false, strict, profile, storage } );
89
91
 
90
92
  try {
91
93
 
@@ -205,7 +205,7 @@ export class AIUpscaler extends EventDispatcher {
205
205
 
206
206
  };
207
207
 
208
- const { ortRuntimeUrl, ortWasmPaths, cacheNamespace } = getAssetConfig();
208
+ const { ortRuntimeUrl, ortWasmPaths, cacheNamespace, storage } = getAssetConfig();
209
209
  this._worker.addEventListener( 'message', handler );
210
210
  this._worker.postMessage( {
211
211
  type: 'load',
@@ -214,6 +214,7 @@ export class AIUpscaler extends EventDispatcher {
214
214
  ortRuntimeUrl,
215
215
  ortWasmPaths,
216
216
  cacheNamespace,
217
+ storage,
217
218
  } );
218
219
 
219
220
  } );
@@ -21,6 +21,7 @@ async function getInitUNetFromBuffer() {
21
21
  }
22
22
 
23
23
  import { getAssetConfig } from '../AssetConfig.js';
24
+ import { sharedDownloads, DOWNLOAD_POLICY } from '../Storage/DownloadCache.js';
24
25
 
25
26
  const MODEL_CONFIG = {
26
27
  // No cleanAux flag in oidn-web, so the blob is it — and it must match what setCleanAuxNormal
@@ -466,12 +467,8 @@ export class OIDNDenoiser extends EventDispatcher {
466
467
  let bytes = this._weights.get( url );
467
468
  if ( ! bytes ) {
468
469
 
469
- bytes = fetch( url ).then( res => {
470
-
471
- if ( ! res.ok ) throw new Error( `HTTP ${ res.status } fetching ${ url }` );
472
- return res.arrayBuffer();
473
-
474
- } );
470
+ bytes = sharedDownloads().fetch( url, { policy: DOWNLOAD_POLICY.IMMUTABLE } )
471
+ .then( ( { file, release } ) => file.arrayBuffer().finally( release ) );
475
472
  bytes.catch( () => this._weights.delete( url ) );
476
473
  this._weights.set( url, bytes );
477
474