rayzee 5.9.3 → 5.10.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayzee",
3
- "version": "5.9.3",
3
+ "version": "5.10.0",
4
4
  "type": "module",
5
5
  "description": "Real-time WebGPU path tracing engine built on Three.js",
6
6
  "main": "dist/rayzee.umd.js",
@@ -1,12 +1,17 @@
1
1
  import { EventDispatcher, ACESFilmicToneMapping } from 'three';
2
2
 
3
3
  let _initUNetFromURL = null;
4
+ let _tfEngine = null;
4
5
  async function getInitUNetFromURL() {
5
6
 
6
7
  if ( ! _initUNetFromURL ) {
7
8
 
8
- const mod = await import( 'oidn-web' );
9
- _initUNetFromURL = mod.initUNetFromURL;
9
+ const [ oidnMod, tfMod ] = await Promise.all( [
10
+ import( 'oidn-web' ),
11
+ import( '@tensorflow/tfjs-core' )
12
+ ] );
13
+ _initUNetFromURL = oidnMod.initUNetFromURL;
14
+ _tfEngine = tfMod.engine;
10
15
 
11
16
  }
12
17
 
@@ -14,6 +19,29 @@ async function getInitUNetFromURL() {
14
19
 
15
20
  }
16
21
 
22
+ // oidn-web caches its WebGPUBackend in TFJS's global ENGINE under 'webgpu-oidn'.
23
+ // On dispose, drop it so the next instance binds to the new GPUDevice instead of
24
+ // reusing the destroyed one (which would produce black tiles).
25
+ function removeOidnTfjsBackend() {
26
+
27
+ if ( ! _tfEngine ) return;
28
+ try {
29
+
30
+ const eng = _tfEngine();
31
+ if ( eng?.registryFactory && 'webgpu-oidn' in eng.registryFactory ) {
32
+
33
+ eng.removeBackend( 'webgpu-oidn' );
34
+
35
+ }
36
+
37
+ } catch ( e ) {
38
+
39
+ console.warn( 'OIDNDenoiser: failed to clear cached TFJS backend', e );
40
+
41
+ }
42
+
43
+ }
44
+
17
45
  import { createRenderTargetHelper } from '../Processor/createRenderTargetHelper.js';
18
46
  import { TONE_MAP_FNS, linearToSRGB, applySaturation } from '../Processor/ToneMapCPU.js';
19
47
 
@@ -966,6 +994,9 @@ export class OIDNDenoiser extends EventDispatcher {
966
994
 
967
995
  // Dispose resources
968
996
  this.unet?.dispose();
997
+ // Must precede renderer.dispose() so the GPUDevice is still alive when
998
+ // TFJS tears down the cached backend's buffers/textures.
999
+ removeOidnTfjsBackend();
969
1000
  this._destroyGPUInputBuffers();
970
1001
 
971
1002
  // Dispose debug helpers