rayzee 5.9.2 → 5.9.4

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.2",
3
+ "version": "5.9.4",
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
@@ -31,9 +31,12 @@ export class TileHelper {
31
31
  // Whether the user has enabled the tile helper via UI toggle
32
32
  this.enabled = true;
33
33
 
34
- // Style
34
+ // Style — line width derives from display size each frame so the
35
+ // border looks the same thickness regardless of canvas resolution.
35
36
  this._borderColor = 'rgba(255, 0, 0, 0.6)';
36
- this._borderWidth = 2;
37
+ this._borderWidthRatio = 1 / 540; // ~2px on 1080p, ~4px on 4K
38
+ this._borderWidthMin = 1.5;
39
+ this._borderWidthMax = 4;
37
40
 
38
41
  }
39
42
 
@@ -87,9 +90,13 @@ export class TileHelper {
87
90
  const w = bounds.width * scaleX;
88
91
  const h = bounds.height * scaleY;
89
92
 
90
- // Active tile border
93
+ const lineWidth = Math.min(
94
+ this._borderWidthMax,
95
+ Math.max( this._borderWidthMin, Math.min( displayW, displayH ) * this._borderWidthRatio )
96
+ );
97
+
91
98
  ctx.strokeStyle = this._borderColor;
92
- ctx.lineWidth = this._borderWidth;
99
+ ctx.lineWidth = lineWidth;
93
100
  ctx.strokeRect( x, y, w, h );
94
101
 
95
102
  }