rayzee 8.8.2 → 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 (104) hide show
  1. package/README.md +210 -20
  2. package/dist/{NeuralRetouch-CYOJ21Wn.js → NeuralRetouch-BRquqfmZ.js} +1 -1
  3. package/dist/{NeuralSuperRes-Dc6jRYke.js → NeuralSuperRes-CbNvQjCw.js} +5 -2
  4. package/dist/{ToneMapGPU-BVE852iN.js → ToneMapGPU-DpUZDMbQ.js} +2 -1
  5. package/dist/rayzee.es.js +10795 -5324
  6. package/dist/rayzee.umd.js +279 -268
  7. package/package.json +1 -1
  8. package/src/AssetConfig.js +4 -0
  9. package/src/EngineDefaults.js +60 -76
  10. package/src/EngineEvents.js +7 -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/Passes/OIDNTemporalHistory.js +25 -7
  16. package/src/PathTracerApp.js +313 -25
  17. package/src/Processor/ArchiveCache.js +120 -0
  18. package/src/Processor/ArchiveReader.js +179 -32
  19. package/src/Processor/AssetLoader.js +523 -76
  20. package/src/Processor/AtmosphereModel.js +465 -0
  21. package/src/Processor/BVHBuilder.js +4 -1
  22. package/src/Processor/BVHLeafFold.js +100 -0
  23. package/src/Processor/BVHRefitter.js +98 -214
  24. package/src/Processor/ChunkedRecords.js +189 -4
  25. package/src/Processor/EmissiveTriangleBuilder.js +8 -0
  26. package/src/Processor/GeometryExtractor.js +238 -40
  27. package/src/Processor/InstanceTable.js +55 -37
  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 +210 -55
  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 +49 -8
  45. package/src/SceneState/SceneState.js +367 -0
  46. package/src/SceneState/portable.js +52 -0
  47. package/src/Stages/MotionVector.js +8 -42
  48. package/src/Stages/NRD.js +30 -21
  49. package/src/Stages/NormalDepth.js +12 -23
  50. package/src/Stages/PathTracer.js +114 -6
  51. package/src/Stages/PathTracerStage.js +251 -104
  52. package/src/Storage/BLASCache.js +190 -0
  53. package/src/Storage/CDFCache.js +77 -0
  54. package/src/Storage/DownloadCache.js +266 -0
  55. package/src/Storage/GeometrySpill.js +217 -0
  56. package/src/Storage/SceneGraphCodec.js +503 -0
  57. package/src/Storage/SpillStore.js +112 -0
  58. package/src/Storage/StorageManager.js +934 -0
  59. package/src/Storage/StorageOps.js +137 -0
  60. package/src/Storage/StorageWorker.js +37 -0
  61. package/src/Storage/events.js +29 -0
  62. package/src/Storage/identity.js +77 -0
  63. package/src/Storage/index.js +9 -0
  64. package/src/Storage/inlineTransport.js +24 -0
  65. package/src/Storage/locks.js +99 -0
  66. package/src/Storage/openStorage.js +87 -0
  67. package/src/Storage/sceneCachePolicy.js +12 -0
  68. package/src/Storage/shared.js +9 -0
  69. package/src/Storage/transport.js +62 -0
  70. package/src/TSL/Atmosphere.js +684 -0
  71. package/src/TSL/BVHTraversal.js +288 -239
  72. package/src/TSL/CameraRay.js +99 -14
  73. package/src/TSL/Common.js +11 -2
  74. package/src/TSL/DebugKernel.js +2 -2
  75. package/src/TSL/Displacement.js +6 -6
  76. package/src/TSL/EmissiveSampling.js +5 -5
  77. package/src/TSL/EnvironmentCDF.js +176 -0
  78. package/src/TSL/GenerateKernel.js +5 -5
  79. package/src/TSL/HitFacet.js +4 -4
  80. package/src/TSL/LightsDirect.js +8 -8
  81. package/src/TSL/LightsSampling.js +55 -37
  82. package/src/TSL/Random.js +1 -0
  83. package/src/TSL/ShadeKernel.js +75 -19
  84. package/src/TSL/Sun.js +40 -0
  85. package/src/TSL/TextureSampling.js +6 -7
  86. package/src/index.js +22 -0
  87. package/src/managers/CameraManager.js +412 -56
  88. package/src/managers/DenoisingManager.js +4 -3
  89. package/src/managers/EnvironmentManager.js +263 -33
  90. package/src/managers/GoboManager.js +19 -8
  91. package/src/managers/IESManager.js +3 -3
  92. package/src/managers/InteractionManager.js +30 -2
  93. package/src/managers/LightManager.js +98 -5
  94. package/src/managers/MaterialDataManager.js +22 -2
  95. package/src/managers/TransformManager.js +26 -0
  96. package/src/managers/UniformManager.js +11 -7
  97. package/src/managers/VideoRenderManager.js +38 -17
  98. package/src/managers/ViewCamera.js +77 -0
  99. package/src/managers/WalkControls.js +262 -0
  100. package/src/managers/helpers/OutlineHelper.js +22 -2
  101. package/src/managers/timeline/CameraTrack.js +235 -0
  102. package/src/managers/timeline/TimelineManager.js +146 -0
  103. package/src/version.js +3 -0
  104. package/src/Processor/ProceduralSky.js +0 -291
@@ -1,291 +0,0 @@
1
- import {
2
- RGBAFormat, FloatType, LinearFilter, RepeatWrapping, ClampToEdgeWrapping,
3
- EquirectangularReflectionMapping, LinearSRGBColorSpace, DataTexture
4
- } from 'three';
5
-
6
- /**
7
- * ProceduralSky
8
- *
9
- * CPU-based Preetham atmospheric scattering sky generator.
10
- * Produces a DataTexture directly — no render targets, no GPU readback,
11
- * no resource lifecycle issues with the WebGPU backend.
12
- *
13
- * For a 512×256 texture this takes ~5-10ms on CPU, which is negligible
14
- * since it only runs on parameter change (not per-frame).
15
- *
16
- * Public API matches ProceduralSkyRenderer: render(params) → texture.
17
- */
18
-
19
- // ── Constants (from preetham_sky.glsl) ──
20
-
21
- const PI = Math.PI;
22
- const TWO_PI = Math.PI * 2;
23
- const E = Math.E;
24
-
25
- const TOTAL_RAYLEIGH = [ 5.804542996261093e-6, 1.3562911419845635e-5, 3.0265902468824876e-5 ];
26
- const MIE_CONST = [ 1.8399918514433978e14, 2.7798023919660528e14, 4.0790479543861094e14 ];
27
-
28
- const CUTOFF_ANGLE = 1.6110731556870734;
29
- const STEEPNESS = 1.5;
30
- const EE_CONST = 1000.0;
31
-
32
- const RAYLEIGH_ZENITH_LENGTH = 8400.0;
33
- const MIE_ZENITH_LENGTH = 1250.0;
34
- const SUN_ANGULAR_DIAMETER_COS = 0.9999566769464484;
35
-
36
- const THREE_OVER_SIXTEEN_PI = 0.05968310365946075;
37
- const ONE_OVER_FOUR_PI = 0.07957747154594767;
38
-
39
- // ── CPU Math ──
40
-
41
- function computeSunIntensity( zenithAngleCos ) {
42
-
43
- const clamped = Math.max( - 1.0, Math.min( 1.0, zenithAngleCos ) );
44
- return EE_CONST * Math.max( 0.0, 1.0 - Math.pow( E, - ( CUTOFF_ANGLE - Math.acos( clamped ) ) / STEEPNESS ) );
45
-
46
- }
47
-
48
- function totalMie( T ) {
49
-
50
- const c = ( 0.2 * T ) * 10e-18;
51
- return [ 0.434 * c * MIE_CONST[ 0 ], 0.434 * c * MIE_CONST[ 1 ], 0.434 * c * MIE_CONST[ 2 ] ];
52
-
53
- }
54
-
55
- function rayleighPhase( cosTheta ) {
56
-
57
- return THREE_OVER_SIXTEEN_PI * ( 1.0 + Math.pow( cosTheta, 2.0 ) );
58
-
59
- }
60
-
61
- function hgPhase( cosTheta, g ) {
62
-
63
- const g2 = g * g;
64
- return ONE_OVER_FOUR_PI * ( ( 1.0 - g2 ) / Math.pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 ) );
65
-
66
- }
67
-
68
- function dot3( a, b ) {
69
-
70
- return a[ 0 ] * b[ 0 ] + a[ 1 ] * b[ 1 ] + a[ 2 ] * b[ 2 ];
71
-
72
- }
73
-
74
- function normalize3( v ) {
75
-
76
- const len = Math.sqrt( v[ 0 ] * v[ 0 ] + v[ 1 ] * v[ 1 ] + v[ 2 ] * v[ 2 ] );
77
- if ( len === 0 ) return [ 0, 0, 0 ];
78
- return [ v[ 0 ] / len, v[ 1 ] / len, v[ 2 ] / len ];
79
-
80
- }
81
-
82
- function computePreethamPixel( u, v, sunDir, sunIntensity, rayleighDensity, mieDensity, mieAnisotropy, turbidity ) {
83
-
84
- // Equirectangular → direction
85
- const theta = ( 1.0 - v ) * PI;
86
- const phi = ( u - 0.5 ) * TWO_PI;
87
- const sinTheta = Math.sin( theta );
88
- const direction = normalize3( [
89
- sinTheta * Math.sin( phi ),
90
- Math.cos( theta ),
91
- sinTheta * Math.cos( phi )
92
- ] );
93
-
94
- const vSunDirection = normalize3( sunDir );
95
-
96
- // Sun intensity from zenith angle
97
- const vSunE = computeSunIntensity( vSunDirection[ 1 ] ) * sunIntensity;
98
-
99
- // Sun fade near horizon
100
- const vSunfade = 1.0 - Math.max( 0.0, Math.min( 1.0, 1.0 - Math.exp( vSunDirection[ 1 ] / 450000.0 ) ) );
101
-
102
- // Rayleigh coefficient
103
- const rayleighCoeff = rayleighDensity - ( 1.0 * ( 1.0 - vSunfade ) );
104
- const vBetaR = [ TOTAL_RAYLEIGH[ 0 ] * rayleighCoeff, TOTAL_RAYLEIGH[ 1 ] * rayleighCoeff, TOTAL_RAYLEIGH[ 2 ] * rayleighCoeff ];
105
-
106
- // Mie coefficient
107
- const mieCoeff = totalMie( turbidity );
108
- const vBetaM = [ mieCoeff[ 0 ] * mieDensity, mieCoeff[ 1 ] * mieDensity, mieCoeff[ 2 ] * mieDensity ];
109
-
110
- // Zenith angle and optical path length
111
- const fragZenithAngle = Math.acos( Math.max( 0.0, direction[ 1 ] ) );
112
- const cosZenith = Math.cos( fragZenithAngle );
113
- const zenithDeg = fragZenithAngle * ( 180.0 / PI );
114
- const inverseFactor = cosZenith + 0.15 * Math.pow( 93.885 - zenithDeg, - 1.253 );
115
- const sR = RAYLEIGH_ZENITH_LENGTH / inverseFactor;
116
- const sM = MIE_ZENITH_LENGTH / inverseFactor;
117
-
118
- // Extinction (Beer's law)
119
- const Fex = [
120
- Math.exp( - ( vBetaR[ 0 ] * sR + vBetaM[ 0 ] * sM ) ),
121
- Math.exp( - ( vBetaR[ 1 ] * sR + vBetaM[ 1 ] * sM ) ),
122
- Math.exp( - ( vBetaR[ 2 ] * sR + vBetaM[ 2 ] * sM ) )
123
- ];
124
-
125
- // Scattering angle
126
- const cosViewSun = dot3( direction, vSunDirection );
127
-
128
- // Phase functions
129
- const rPhase = rayleighPhase( cosViewSun * 0.5 + 0.5 );
130
- const betaRTheta = [ vBetaR[ 0 ] * rPhase, vBetaR[ 1 ] * rPhase, vBetaR[ 2 ] * rPhase ];
131
-
132
- const mPhase = hgPhase( cosViewSun, mieAnisotropy );
133
- const betaMTheta = [ vBetaM[ 0 ] * mPhase, vBetaM[ 1 ] * mPhase, vBetaM[ 2 ] * mPhase ];
134
-
135
- // Inscattered light
136
- const betaSum = [ betaRTheta[ 0 ] + betaMTheta[ 0 ], betaRTheta[ 1 ] + betaMTheta[ 1 ], betaRTheta[ 2 ] + betaMTheta[ 2 ] ];
137
- const betaRplusM = [ vBetaR[ 0 ] + vBetaM[ 0 ], vBetaR[ 1 ] + vBetaM[ 1 ], vBetaR[ 2 ] + vBetaM[ 2 ] ];
138
-
139
- const Lin = [
140
- Math.pow( vSunE * ( betaSum[ 0 ] / betaRplusM[ 0 ] ) * ( 1.0 - Fex[ 0 ] ), 1.5 ),
141
- Math.pow( vSunE * ( betaSum[ 1 ] / betaRplusM[ 1 ] ) * ( 1.0 - Fex[ 1 ] ), 1.5 ),
142
- Math.pow( vSunE * ( betaSum[ 2 ] / betaRplusM[ 2 ] ) * ( 1.0 - Fex[ 2 ] ), 1.5 )
143
- ];
144
-
145
- // Sunset mix
146
- const sunsetFactor = Math.max( 0.0, Math.min( 1.0, 1.0 - Math.pow( 1.0 - vSunDirection[ 1 ], 5.0 ) ) );
147
- const sunsetColor = [
148
- Math.sqrt( vSunE * ( betaSum[ 0 ] / betaRplusM[ 0 ] ) * Fex[ 0 ] ),
149
- Math.sqrt( vSunE * ( betaSum[ 1 ] / betaRplusM[ 1 ] ) * Fex[ 1 ] ),
150
- Math.sqrt( vSunE * ( betaSum[ 2 ] / betaRplusM[ 2 ] ) * Fex[ 2 ] )
151
- ];
152
-
153
- const mixW = 1.0 - sunsetFactor;
154
- for ( let i = 0; i < 3; i ++ ) {
155
-
156
- const mixVal = 1.0 * ( 1.0 - mixW ) + sunsetColor[ i ] * mixW;
157
- Lin[ i ] *= mixVal;
158
-
159
- }
160
-
161
- // Base luminance + sun disk
162
- const L0 = [ 0.1 * Fex[ 0 ], 0.1 * Fex[ 1 ], 0.1 * Fex[ 2 ] ];
163
- const sundisk = smoothstep( SUN_ANGULAR_DIAMETER_COS, SUN_ANGULAR_DIAMETER_COS + 0.00002, cosViewSun );
164
- for ( let i = 0; i < 3; i ++ ) {
165
-
166
- L0[ i ] += vSunE * 19000.0 * Fex[ i ] * sundisk;
167
-
168
- }
169
-
170
- // Final color — clamp to half-float max (65504) to avoid overflow
171
- // in the CDF builder's half-float conversion
172
- const MAX_HDR = 65504.0;
173
- return [
174
- Math.min( ( Lin[ 0 ] + L0[ 0 ] ) * 0.04, MAX_HDR ),
175
- Math.min( ( Lin[ 1 ] + L0[ 1 ] ) * 0.04 + 0.0003, MAX_HDR ),
176
- Math.min( ( Lin[ 2 ] + L0[ 2 ] ) * 0.04 + 0.00075, MAX_HDR ),
177
- 1.0
178
- ];
179
-
180
- }
181
-
182
- function smoothstep( edge0, edge1, x ) {
183
-
184
- const t = Math.max( 0.0, Math.min( 1.0, ( x - edge0 ) / ( edge1 - edge0 ) ) );
185
- return t * t * ( 3.0 - 2.0 * t );
186
-
187
- }
188
-
189
- // ── Renderer Class ──
190
-
191
- export class ProceduralSky {
192
-
193
- constructor( width = 512, height = 256 ) {
194
-
195
- this.width = width;
196
- this.height = height;
197
- this.lastRenderTime = 0;
198
-
199
- // Pre-allocate pixel buffer and DataTexture (reused across renders)
200
- this._pixels = new Float32Array( width * height * 4 );
201
- this._texture = new DataTexture( this._pixels, width, height, RGBAFormat, FloatType );
202
- this._texture.mapping = EquirectangularReflectionMapping;
203
- this._texture.colorSpace = LinearSRGBColorSpace;
204
- this._texture.minFilter = LinearFilter;
205
- this._texture.magFilter = LinearFilter;
206
- this._texture.wrapS = RepeatWrapping;
207
- this._texture.wrapT = ClampToEdgeWrapping;
208
- this._texture.generateMipmaps = false;
209
-
210
- }
211
-
212
- /**
213
- * Generate Preetham sky into a reusable DataTexture.
214
- * @param {Object} params - Sky parameters
215
- * @returns {DataTexture} Equirectangular sky texture with CPU data
216
- */
217
- render( params ) {
218
-
219
- const startTime = performance.now();
220
-
221
- const sunDir = [ params.sunDirection.x, params.sunDirection.y, params.sunDirection.z ];
222
- const sunIntensity = params.sunIntensity || 1.0;
223
- const rayleighDensity = params.rayleighDensity || 2.0;
224
- const mieDensity = params.mieDensity || 0.005;
225
- const mieAnisotropy = params.mieAnisotropy || 0.8;
226
- const turbidity = params.turbidity || 2.0;
227
-
228
- const { width, height } = this;
229
- const pixels = this._pixels;
230
-
231
- for ( let y = 0; y < height; y ++ ) {
232
-
233
- const v = ( y + 0.5 ) / height;
234
-
235
- for ( let x = 0; x < width; x ++ ) {
236
-
237
- const u = ( x + 0.5 ) / width;
238
- const color = computePreethamPixel( u, v, sunDir, sunIntensity, rayleighDensity, mieDensity, mieAnisotropy, turbidity );
239
-
240
- const idx = ( y * width + x ) * 4;
241
- pixels[ idx ] = color[ 0 ];
242
- pixels[ idx + 1 ] = color[ 1 ];
243
- pixels[ idx + 2 ] = color[ 2 ];
244
- pixels[ idx + 3 ] = color[ 3 ];
245
-
246
- }
247
-
248
- }
249
-
250
- this._texture.needsUpdate = true;
251
- // Fresh linear Rec.709 pixels in a reused texture. Colour management records which space a
252
- // texture's pixels hold so it never converts them twice; left in place, that record would
253
- // claim these were already converted and they never would be.
254
- delete this._texture.userData?.__rayzeeColorSpace;
255
- this.lastRenderTime = performance.now() - startTime;
256
-
257
- return this._texture;
258
-
259
- }
260
-
261
- setResolution( width, height ) {
262
-
263
- if ( this.width === width && this.height === height ) return;
264
- this.width = width;
265
- this.height = height;
266
- this._pixels = new Float32Array( width * height * 4 );
267
- this._texture.dispose();
268
- this._texture = new DataTexture( this._pixels, width, height, RGBAFormat, FloatType );
269
- this._texture.mapping = EquirectangularReflectionMapping;
270
- this._texture.colorSpace = LinearSRGBColorSpace;
271
- this._texture.minFilter = LinearFilter;
272
- this._texture.magFilter = LinearFilter;
273
- this._texture.wrapS = RepeatWrapping;
274
- this._texture.wrapT = ClampToEdgeWrapping;
275
- this._texture.generateMipmaps = false;
276
-
277
- }
278
-
279
- getLastRenderTime() {
280
-
281
- return this.lastRenderTime;
282
-
283
- }
284
-
285
- dispose() {
286
-
287
- this._texture.dispose();
288
-
289
- }
290
-
291
- }