rayzee 7.29.0 → 7.30.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.
@@ -19,17 +19,21 @@ import { createLogger, fmt } from '../utils/Logger.js';
19
19
 
20
20
  const log = createLogger( 'gpu' );
21
21
 
22
- function createWriteStorageTex() {
22
+ // Compute-output StorageTexture at the reserved size, never resized (see above). LinearFilter is
23
+ // load-bearing: textureLoad codegen requires it on a StorageTexture.
24
+ export function createStorageTexture( type = FloatType, filter = LinearFilter ) {
23
25
 
24
26
  const tex = new StorageTexture( MAX_STORAGE_TEXTURE_SIZE, MAX_STORAGE_TEXTURE_SIZE );
25
- tex.type = FloatType;
27
+ tex.type = type;
26
28
  tex.format = RGBAFormat;
27
- tex.minFilter = LinearFilter;
28
- tex.magFilter = LinearFilter;
29
+ tex.minFilter = filter;
30
+ tex.magFilter = filter;
29
31
  return tex;
30
32
 
31
33
  }
32
34
 
35
+ const createWriteStorageTex = () => createStorageTexture();
36
+
33
37
  export class StorageTexturePool {
34
38
 
35
39
  constructor( width, height ) {
@@ -1,5 +1,5 @@
1
1
  import { DataArrayTexture, RGBAFormat, LinearFilter, UnsignedByteType, SRGBColorSpace, LinearSRGBColorSpace, RepeatWrapping } from "three";
2
- import { TEXTURE_CONSTANTS, MEMORY_CONSTANTS, DEFAULT_TEXTURE_MATRIX, MATERIAL_DATA_LAYOUT, normalizeAttenuationDistance } from '../EngineDefaults.js';
2
+ import { alignBucketWidth, TEXTURE_CONSTANTS, MEMORY_CONSTANTS, DEFAULT_TEXTURE_MATRIX, MATERIAL_DATA_LAYOUT, normalizeAttenuationDistance } from '../EngineDefaults.js';
3
3
  import TexturesWorker from './Workers/TexturesWorker.js?worker&inline';
4
4
  import { ISSUE_CODES } from '../EngineIssues.js';
5
5
  import { linearToSRGB } from './ToneMapCPU.js';
@@ -1318,18 +1318,17 @@ export class TextureCreator {
1318
1318
 
1319
1319
  }
1320
1320
 
1321
- maxWidth = Math.pow( 2, Math.ceil( Math.log2( maxWidth ) ) );
1322
- maxHeight = Math.pow( 2, Math.ceil( Math.log2( maxHeight ) ) );
1321
+ // Scale down proportionally only when the cap is exceeded; native res is kept below it.
1322
+ const longest = Math.max( maxWidth, maxHeight );
1323
+ if ( longest > this.maxTextureSize ) {
1323
1324
 
1324
- // Halve only while a dimension exceeds the cap (preserves native res up to the cap).
1325
- while ( maxWidth > this.maxTextureSize || maxHeight > this.maxTextureSize ) {
1326
-
1327
- maxWidth = Math.max( 1, Math.floor( maxWidth / 2 ) );
1328
- maxHeight = Math.max( 1, Math.floor( maxHeight / 2 ) );
1325
+ const scale = this.maxTextureSize / longest;
1326
+ maxWidth = Math.round( maxWidth * scale );
1327
+ maxHeight = Math.round( maxHeight * scale );
1329
1328
 
1330
1329
  }
1331
1330
 
1332
- return { maxWidth, maxHeight };
1331
+ return { maxWidth: alignBucketWidth( maxWidth, this.maxTextureSize ), maxHeight: Math.max( 1, maxHeight ) };
1333
1332
 
1334
1333
  }
1335
1334
 
@@ -619,23 +619,22 @@ function calculateOptimalDimensions( textures, maxTextureSize ) {
619
619
 
620
620
  }
621
621
 
622
- // Round to power of 2 for optimal GPU performance
623
- maxWidth = Math.pow( 2, Math.ceil( Math.log2( maxWidth ) ) );
624
- maxHeight = Math.pow( 2, Math.ceil( Math.log2( maxHeight ) ) );
622
+ // Scale down proportionally only when the cap is exceeded; native res is kept below it.
623
+ const cap = Math.min( maxTextureSize, MEMORY_LIMITS.MAX_TEXTURE_DIMENSION );
624
+ const longest = Math.max( maxWidth, maxHeight );
625
+ if ( longest > cap ) {
625
626
 
626
- // Respect texture size limits
627
- maxWidth = Math.min( maxWidth, maxTextureSize, MEMORY_LIMITS.MAX_TEXTURE_DIMENSION );
628
- maxHeight = Math.min( maxHeight, maxTextureSize, MEMORY_LIMITS.MAX_TEXTURE_DIMENSION );
629
-
630
- // Halve only while a dimension exceeds the cap (preserves native res up to the cap).
631
- while ( maxWidth > maxTextureSize || maxHeight > maxTextureSize ) {
632
-
633
- maxWidth = Math.max( 1, Math.floor( maxWidth / 2 ) );
634
- maxHeight = Math.max( 1, Math.floor( maxHeight / 2 ) );
627
+ const scale = cap / longest;
628
+ maxWidth = Math.round( maxWidth * scale );
629
+ maxHeight = Math.round( maxHeight * scale );
635
630
 
636
631
  }
637
632
 
638
- return { maxWidth, maxHeight };
633
+ // An RGBA8 row upload must be a multiple of 256 bytes, so widths land on 64 texels.
634
+ // Mirrors alignBucketWidth in EngineDefaults (not importable from worker context).
635
+ maxWidth = Math.min( cap, Math.max( 4, Math.ceil( Math.max( 1, maxWidth ) / 64 ) * 64 ) );
636
+
637
+ return { maxWidth, maxHeight: Math.max( 1, maxHeight ) };
639
638
 
640
639
  }
641
640
 
@@ -645,7 +644,7 @@ function calculateReducedDimensions( textures, maxTextureSize ) {
645
644
  const original = calculateOptimalDimensions( textures, maxTextureSize );
646
645
 
647
646
  return {
648
- maxWidth: Math.max( 1, Math.floor( original.maxWidth / 2 ) ),
647
+ maxWidth: Math.max( 64, Math.ceil( original.maxWidth / 128 ) * 64 ),
649
648
  maxHeight: Math.max( 1, Math.floor( original.maxHeight / 2 ) )
650
649
  };
651
650
 
@@ -38,12 +38,6 @@ export function getDisplaySamples( pathTracerStage ) {
38
38
 
39
39
  }
40
40
 
41
- export function getNearestPowerOf2( size ) {
42
-
43
- return Math.pow( 2, Math.ceil( Math.log2( size ) ) );
44
-
45
- }
46
-
47
41
  export function disposeMaterial( material ) {
48
42
 
49
43
  if ( Array.isArray( material ) ) {
@@ -182,10 +182,10 @@ export class RenderSettings extends EventDispatcher {
182
182
 
183
183
  if ( ! isPanorama ) return;
184
184
 
185
- // ASVGF is driven entirely by MotionVector, which unprojects through
186
- // projectionMatrixInverse — meaningless once every pixel is its own direction.
187
- // Fall back to the spatial-only denoiser rather than leaving no strategy.
188
- if ( denoisingManager?.denoiserStrategy === 'asvgf' ) denoisingManager.setDenoiserStrategy( 'edgeaware' );
185
+ // MotionVector unprojects through projectionMatrixInverse, which is meaningless once
186
+ // every pixel is its own direction. Fall back to the spatial-only denoiser rather
187
+ // than leaving no strategy.
188
+ if ( denoisingManager?.requiresMotionVectors ) denoisingManager.setDenoiserStrategy( 'edgeaware' );
189
189
  // Auto-focus raycasts via Raycaster.setFromCamera, which only knows the frustum.
190
190
  cameraManager?.setAutoFocusMode( 'manual' );
191
191
 
@@ -70,6 +70,7 @@ export class Compositor extends RenderStage {
70
70
  || context.getTexture( 'edgeFiltering:output' )
71
71
  || context.getTexture( 'bilateralFiltering:output' )
72
72
  || context.getTexture( 'asvgf:output' )
73
+ || context.getTexture( 'nrd:output' )
73
74
  || context.getTexture( 'pathtracer:color' );
74
75
 
75
76
  }