rayzee 7.26.1 → 7.26.2

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": "7.26.1",
3
+ "version": "7.26.2",
4
4
  "type": "module",
5
5
  "description": "Real-time WebGPU path tracing engine built on Three.js",
6
6
  "main": "dist/rayzee.umd.js",
@@ -183,29 +183,6 @@ export class GeometryExtractor {
183
183
  materialIndex = this.materials.length - 1;
184
184
  this._materialUuidMap.set( material.uuid, materialIndex );
185
185
 
186
- // Detect material features for shader optimization (strict > 0 check)
187
- if ( newMaterial.clearcoat > 0 ) this.sceneFeatures.hasClearcoat = true;
188
- if ( newMaterial.transmission > 0 ) this.sceneFeatures.hasTransmission = true;
189
- if ( newMaterial.dispersion > 0 ) this.sceneFeatures.hasDispersion = true;
190
- if ( newMaterial.iridescence > 0 ) this.sceneFeatures.hasIridescence = true;
191
- if ( newMaterial.sheen > 0 ) this.sceneFeatures.hasSheen = true;
192
- if ( newMaterial.transparent || newMaterial.opacity < 1.0 || newMaterial.alphaTest > 0 ) this.sceneFeatures.hasTransparency = true;
193
- if ( newMaterial.subsurface > 0 ) this.sceneFeatures.hasSubsurface = true;
194
-
195
- // Detect multi-lobe materials (require multi-lobe MIS for optimal sampling)
196
- const featureCount = [
197
- newMaterial.clearcoat > 0,
198
- newMaterial.transmission > 0,
199
- newMaterial.iridescence > 0,
200
- newMaterial.sheen > 0
201
- ].filter( Boolean ).length;
202
-
203
- if ( featureCount >= 2 ) {
204
-
205
- this.sceneFeatures.hasMultiLobeMaterials = true;
206
-
207
- }
208
-
209
186
  }
210
187
 
211
188
  return materialIndex;
@@ -846,19 +823,6 @@ export class GeometryExtractor {
846
823
  this._materialUuidMap = new Map();
847
824
  this._textureIndexCache = new WeakMap();
848
825
 
849
- // Reset scene-wide feature detection flags
850
- this.sceneFeatures = {
851
- hasClearcoat: false,
852
- hasTransmission: false,
853
- hasDispersion: false,
854
- hasIridescence: false,
855
- hasSheen: false,
856
- hasTransparency: false,
857
- hasSubsurface: false,
858
- hasMultiLobeMaterials: false, // Materials with 2+ BRDF lobes
859
- hasMRTOutputs: true // Always enabled for ASVGF/adaptive sampling support
860
- };
861
-
862
826
  }
863
827
 
864
828
  getExtractedData() {
@@ -888,8 +852,7 @@ export class GeometryExtractor {
888
852
  specularIntensityMaps: this.specularIntensityMaps,
889
853
  specularColorMaps: this.specularColorMaps,
890
854
  directionalLights: this.directionalLights,
891
- cameras: this.cameras,
892
- sceneFeatures: this.sceneFeatures // Scene-wide material feature flags
855
+ cameras: this.cameras
893
856
  };
894
857
 
895
858
  }
@@ -324,7 +324,6 @@ export class SceneProcessor {
324
324
 
325
325
  // Store other extracted data
326
326
  this.materials = extractedData.materials;
327
- this.materialCount = this.materials.length; // Store material count for feature scanning
328
327
  this.materialTriangleCounts = extractedData.materialTriangleCounts; // Per-material tri count for sort-bin remap
329
328
  this.meshes = extractedData.meshes;
330
329
  this.meshTriangleRanges = extractedData.meshTriangleRanges; // Per-mesh { start, count } for TLAS/BLAS
@@ -347,7 +346,6 @@ export class SceneProcessor {
347
346
  this.specularColorMaps = extractedData.specularColorMaps;
348
347
  this.directionalLights = extractedData.directionalLights;
349
348
  this.cameras = extractedData.cameras;
350
- this.sceneFeatures = extractedData.sceneFeatures; // Store material feature flags for shader optimization
351
349
 
352
350
  const duration = performance.now() - startTime;
353
351
  this._log( `Geometry extraction complete (${duration.toFixed( 2 )}ms)`, {
@@ -1157,7 +1155,6 @@ export class SceneProcessor {
1157
1155
 
1158
1156
  // Update material arrays (but keep existing triangle data)
1159
1157
  this.materials = extractedData.materials;
1160
- this.materialCount = this.materials.length; // Update material count
1161
1158
  this.meshes = extractedData.meshes; // Update mesh data
1162
1159
  this.maps = extractedData.maps;
1163
1160
  this.normalMaps = extractedData.normalMaps;
@@ -1166,7 +1163,6 @@ export class SceneProcessor {
1166
1163
  this.metalnessMaps = extractedData.metalnessMaps;
1167
1164
  this.emissiveMaps = extractedData.emissiveMaps;
1168
1165
  this.displacementMaps = extractedData.displacementMaps;
1169
- this.sceneFeatures = extractedData.sceneFeatures; // Update material feature flags
1170
1166
 
1171
1167
  // Bucket textures, remap material indices, regenerate raw material data, and
1172
1168
  // build the consolidated bucket arrays — same path as the initial build.
@@ -453,9 +453,6 @@ export class PathTracerStage extends RenderStage {
453
453
  await this.sdfs.buildBVH( scene );
454
454
  this.cameras = this.sdfs.cameras;
455
455
 
456
- // Inject shader defines based on detected material features
457
- this.materialData.injectMaterialFeatureDefines();
458
-
459
456
  // Update uniforms with scene data
460
457
  this.updateSceneUniforms();
461
458
  this.updateLights();
@@ -52,7 +52,7 @@ const SCALAR_PROPERTY_OFFSETS = {
52
52
  export class MaterialDataManager {
53
53
 
54
54
  /**
55
- * @param {Object} sdfs - SceneProcessor instance (for geometryExtractor & sceneFeatures)
55
+ * @param {Object} sdfs - SceneProcessor instance
56
56
  */
57
57
  constructor( sdfs ) {
58
58
 
@@ -76,12 +76,9 @@ export class MaterialDataManager {
76
76
  this._srgbTexPacked = null;
77
77
  this._linearTexPacked = null;
78
78
 
79
- // Compiled features cache (for change detection)
80
- this.compiledFeatures = null;
81
-
82
79
  /**
83
80
  * Optional callbacks set by the owning stage.
84
- * @type {{ onReset?: Function, onFeaturesChanged?: Function, getTriangleData?: Function, onTriangleDataChanged?: Function }}
81
+ * @type {{ onReset?: Function, getTriangleData?: Function, onTriangleDataChanged?: Function }}
85
82
  */
86
83
  this.callbacks = {};
87
84
 
@@ -429,18 +426,6 @@ export class MaterialDataManager {
429
426
 
430
427
  }
431
428
 
432
- const featureProperties = [ 'transmission', 'clearcoat', 'sheen', 'iridescence', 'dispersion', 'transparent', 'opacity', 'alphaTest', 'subsurface' ];
433
- if ( featureProperties.includes( property ) ) {
434
-
435
- const featuresChanged = this.rescanMaterialFeatures();
436
- if ( featuresChanged ) {
437
-
438
- this._notifyFeaturesChanged();
439
-
440
- }
441
-
442
- }
443
-
444
429
  this._notifyReset();
445
430
 
446
431
  }
@@ -621,13 +606,6 @@ export class MaterialDataManager {
621
606
 
622
607
  this.materialStorageAttr.needsUpdate = true;
623
608
 
624
- const featuresChanged = this.rescanMaterialFeatures();
625
- if ( featuresChanged ) {
626
-
627
- this._notifyFeaturesChanged();
628
-
629
- }
630
-
631
609
  this._notifyReset();
632
610
 
633
611
  }
@@ -724,119 +702,6 @@ export class MaterialDataManager {
724
702
 
725
703
  }
726
704
 
727
- // ===== FEATURE SCANNING =====
728
-
729
- /**
730
- * Scan all materials to detect which advanced features are in use.
731
- * @returns {boolean} True if features changed
732
- */
733
- rescanMaterialFeatures() {
734
-
735
- if ( ! this.materialStorageAttr?.array ) {
736
-
737
- log.warn( 'material storage buffer not available for feature scanning' );
738
- return false;
739
-
740
- }
741
-
742
- const data = this.materialStorageAttr.array;
743
- const materialCount = this.sdfs.materialCount || 1;
744
-
745
- const newFeatures = {
746
- hasClearcoat: false,
747
- hasTransmission: false,
748
- hasDispersion: false,
749
- hasIridescence: false,
750
- hasSheen: false,
751
- hasTransparency: false,
752
- hasSubsurface: false,
753
- hasMultiLobeMaterials: false,
754
- hasMRTOutputs: true
755
- };
756
-
757
- for ( let i = 0; i < materialCount; i ++ ) {
758
-
759
- const stride = i * M.FLOATS_PER_MATERIAL;
760
-
761
- const transmission = data[ stride + M.TRANSMISSION ];
762
- const dispersion = data[ stride + M.DISPERSION ];
763
- const sheen = data[ stride + M.SHEEN ];
764
- const iridescence = data[ stride + M.IRIDESCENCE ];
765
- const clearcoat = data[ stride + M.CLEARCOAT ];
766
- const opacity = data[ stride + M.OPACITY ];
767
- const transparent = data[ stride + M.TRANSPARENT ];
768
- const alphaTest = data[ stride + M.ALPHA_TEST ];
769
- const subsurface = data[ stride + M.SUBSURFACE ];
770
-
771
- if ( clearcoat > 0 ) newFeatures.hasClearcoat = true;
772
- if ( transmission > 0 ) newFeatures.hasTransmission = true;
773
- if ( dispersion > 0 ) newFeatures.hasDispersion = true;
774
- if ( iridescence > 0 ) newFeatures.hasIridescence = true;
775
- if ( sheen > 0 ) newFeatures.hasSheen = true;
776
- if ( transparent > 0 || opacity < 1.0 || alphaTest > 0 ) newFeatures.hasTransparency = true;
777
- if ( subsurface > 0 ) newFeatures.hasSubsurface = true;
778
-
779
- const featureCount = [
780
- clearcoat > 0,
781
- transmission > 0,
782
- iridescence > 0,
783
- sheen > 0
784
- ].filter( Boolean ).length;
785
-
786
- if ( featureCount >= 2 ) {
787
-
788
- newFeatures.hasMultiLobeMaterials = true;
789
-
790
- }
791
-
792
- }
793
-
794
- const oldFeaturesJSON = JSON.stringify( this.sdfs.sceneFeatures );
795
- const newFeaturesJSON = JSON.stringify( newFeatures );
796
- const changed = oldFeaturesJSON !== newFeaturesJSON;
797
-
798
- if ( changed ) {
799
-
800
- this.sdfs.sceneFeatures = newFeatures;
801
-
802
- }
803
-
804
- return changed;
805
-
806
- }
807
-
808
- /**
809
- * Inject shader preprocessor defines based on detected features.
810
- */
811
- injectMaterialFeatureDefines() {
812
-
813
- const features = this.sdfs.sceneFeatures;
814
-
815
- if ( ! features ) {
816
-
817
- log.warn( 'no sceneFeatures detected, skipping define injection' );
818
- return;
819
-
820
- }
821
-
822
- const featuresJSON = JSON.stringify( features );
823
- const featuresChanged = ! this.compiledFeatures || this.compiledFeatures !== featuresJSON;
824
-
825
- if ( ! featuresChanged ) {
826
-
827
- return;
828
-
829
- }
830
-
831
- // For TSL, we can't inject defines into the shader at runtime
832
- // Instead, we would need to conditionally generate the shader
833
- // For now, log the features for debugging
834
- log.debug( 'material features:', features );
835
-
836
- this.compiledFeatures = featuresJSON;
837
-
838
- }
839
-
840
705
  // ===== PRIVATE CALLBACKS =====
841
706
 
842
707
  /** @private */
@@ -850,13 +715,6 @@ export class MaterialDataManager {
850
715
 
851
716
  }
852
717
 
853
- /** @private */
854
- _notifyFeaturesChanged() {
855
-
856
- this.injectMaterialFeatureDefines();
857
-
858
- }
859
-
860
718
  /**
861
719
  * Rewrite the per-triangle `side` flag (NORMAL_C.w) for every triangle whose
862
720
  * materialIndex matches. Linear over triangles because there's no reverse
@@ -936,7 +794,6 @@ export class MaterialDataManager {
936
794
  this.linearBuckets = null;
937
795
  this._srgbTexPacked = null;
938
796
  this._linearTexPacked = null;
939
- this.compiledFeatures = null;
940
797
 
941
798
  }
942
799