rayzee 7.26.0 → 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/README.md +7 -4
- package/dist/rayzee.es.js +1820 -1847
- package/dist/rayzee.umd.js +58 -58
- package/package.json +1 -1
- package/src/PathTracerApp.js +43 -14
- package/src/Processor/AssetLoader.js +103 -37
- package/src/Processor/GeometryExtractor.js +1 -38
- package/src/Processor/SceneProcessor.js +0 -4
- package/src/Processor/utils.js +11 -0
- package/src/Stages/PathTracerStage.js +0 -3
- package/src/managers/MaterialDataManager.js +2 -145
|
@@ -52,7 +52,7 @@ const SCALAR_PROPERTY_OFFSETS = {
|
|
|
52
52
|
export class MaterialDataManager {
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* @param {Object} sdfs - SceneProcessor instance
|
|
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,
|
|
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
|
|