rayzee 7.6.0 → 7.8.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/README.md +1 -1
- package/dist/rayzee.es.js +1971 -1971
- package/dist/rayzee.es.js.map +1 -1
- package/dist/rayzee.umd.js +55 -55
- package/dist/rayzee.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/EngineDefaults.js +45 -1
- package/src/Processor/SceneProcessor.js +165 -112
- package/src/Processor/ShaderBuilder.js +6 -27
- package/src/Stages/NormalDepth.js +16 -27
- package/src/Stages/PathTracer.js +16 -40
- package/src/TSL/DebugKernel.js +0 -2
- package/src/TSL/Debugger.js +1 -8
- package/src/TSL/Displacement.js +10 -10
- package/src/TSL/FinalWriteKernel.js +5 -2
- package/src/TSL/LightsDirect.js +8 -9
- package/src/TSL/ShadeKernel.js +1 -6
- package/src/TSL/TextureSampling.js +155 -34
- package/src/managers/MaterialDataManager.js +71 -39
|
@@ -34,14 +34,18 @@ export class MaterialDataManager {
|
|
|
34
34
|
this.materialStorageNode = null;
|
|
35
35
|
this.materialCount = 0;
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
// Consolidated size-bucketed material texture arrays (see SceneProcessor._bucketTextures):
|
|
38
|
+
// srgbBuckets[K] — albedo + emissive (SRGBColorSpace)
|
|
39
|
+
// linearBuckets[K] — normal/bump/roughness/metalness/displacement
|
|
40
|
+
// Each entry is a DataArrayTexture | null (null = empty bucket).
|
|
41
|
+
this.srgbBuckets = null;
|
|
42
|
+
this.linearBuckets = null;
|
|
43
|
+
|
|
44
|
+
// uuid → packed (bucket,layer) index maps for the current scene, handed over by the
|
|
45
|
+
// SceneProcessor that built the buckets. Let runtime material edits (updateMaterial)
|
|
46
|
+
// re-pack a texture's index against the current bucket layout.
|
|
47
|
+
this._srgbTexPacked = null;
|
|
48
|
+
this._linearTexPacked = null;
|
|
45
49
|
|
|
46
50
|
// Compiled features cache (for change detection)
|
|
47
51
|
this.compiledFeatures = null;
|
|
@@ -112,45 +116,60 @@ export class MaterialDataManager {
|
|
|
112
116
|
*/
|
|
113
117
|
setMaterialTextures( textures ) {
|
|
114
118
|
|
|
115
|
-
if ( textures.
|
|
116
|
-
if ( textures.
|
|
117
|
-
if ( textures.normalMaps ) this.normalMaps = textures.normalMaps;
|
|
118
|
-
if ( textures.bumpMaps ) this.bumpMaps = textures.bumpMaps;
|
|
119
|
-
if ( textures.roughnessMaps ) this.roughnessMaps = textures.roughnessMaps;
|
|
120
|
-
if ( textures.metalnessMaps ) this.metalnessMaps = textures.metalnessMaps;
|
|
121
|
-
if ( textures.displacementMaps ) this.displacementMaps = textures.displacementMaps;
|
|
119
|
+
if ( textures.srgbBuckets ) this.srgbBuckets = textures.srgbBuckets;
|
|
120
|
+
if ( textures.linearBuckets ) this.linearBuckets = textures.linearBuckets;
|
|
122
121
|
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
/**
|
|
126
|
-
*
|
|
125
|
+
* Receive the scene's uuid→packed texture-index maps (from the SceneProcessor that bucketed).
|
|
126
|
+
* @param {Map|null} srgb
|
|
127
|
+
* @param {Map|null} linear
|
|
128
|
+
*/
|
|
129
|
+
setTexturePackMaps( srgb, linear ) {
|
|
130
|
+
|
|
131
|
+
this._srgbTexPacked = srgb || null;
|
|
132
|
+
this._linearTexPacked = linear || null;
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Packed (bucket, layer) index for a Three.js texture against the current bucket layout,
|
|
138
|
+
* or -1 if it isn't bucketed (a genuinely new texture → needs rebuildMaterials).
|
|
139
|
+
* @param {import('three').Texture|null} texture
|
|
140
|
+
* @param {boolean} isSrgb - true for albedo/emissive pool, false for the linear pool
|
|
141
|
+
* @returns {number}
|
|
142
|
+
*/
|
|
143
|
+
getPackedTextureIndex( texture, isSrgb ) {
|
|
144
|
+
|
|
145
|
+
if ( ! texture ) return - 1;
|
|
146
|
+
const uuid = texture.source?.uuid ?? texture.uuid;
|
|
147
|
+
const map = isSrgb ? this._srgbTexPacked : this._linearTexPacked;
|
|
148
|
+
const packed = map?.get( uuid );
|
|
149
|
+
return packed === undefined ? - 1 : packed;
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Load consolidated bucket arrays + pack maps from the SceneProcessor.
|
|
127
155
|
*/
|
|
128
156
|
loadTexturesFromSdfs() {
|
|
129
157
|
|
|
130
|
-
this.
|
|
131
|
-
this.
|
|
132
|
-
this.
|
|
133
|
-
this.bumpMaps = this.sdfs.bumpTextures;
|
|
134
|
-
this.roughnessMaps = this.sdfs.roughnessTextures;
|
|
135
|
-
this.metalnessMaps = this.sdfs.metalnessTextures;
|
|
136
|
-
this.displacementMaps = this.sdfs.displacementTextures;
|
|
158
|
+
this.srgbBuckets = this.sdfs.srgbBucketTextures;
|
|
159
|
+
this.linearBuckets = this.sdfs.linearBucketTextures;
|
|
160
|
+
this.setTexturePackMaps( this.sdfs._srgbTexPacked, this.sdfs._linearTexPacked );
|
|
137
161
|
|
|
138
162
|
}
|
|
139
163
|
|
|
140
164
|
/**
|
|
141
|
-
* Get
|
|
142
|
-
* @returns {
|
|
165
|
+
* Get the consolidated bucket arrays.
|
|
166
|
+
* @returns {{ srgbBuckets: Array, linearBuckets: Array }}
|
|
143
167
|
*/
|
|
144
168
|
getTextureArrays() {
|
|
145
169
|
|
|
146
170
|
return {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
normalMaps: this.normalMaps,
|
|
150
|
-
bumpMaps: this.bumpMaps,
|
|
151
|
-
roughnessMaps: this.roughnessMaps,
|
|
152
|
-
metalnessMaps: this.metalnessMaps,
|
|
153
|
-
displacementMaps: this.displacementMaps,
|
|
171
|
+
srgbBuckets: this.srgbBuckets,
|
|
172
|
+
linearBuckets: this.linearBuckets,
|
|
154
173
|
};
|
|
155
174
|
|
|
156
175
|
}
|
|
@@ -550,6 +569,22 @@ export class MaterialDataManager {
|
|
|
550
569
|
updateMaterial( materialIndex, material ) {
|
|
551
570
|
|
|
552
571
|
const completeMaterialData = this.sdfs.geometryExtractor.createMaterialObject( material );
|
|
572
|
+
|
|
573
|
+
// createMaterialObject returns stale per-type indices; re-pack each map to the packed
|
|
574
|
+
// (bucket, layer) index for the CURRENT bucket layout. -1 for a texture not yet bucketed
|
|
575
|
+
// (a genuinely new map → the caller must rebuildMaterials to add it to a bucket array).
|
|
576
|
+
if ( this._srgbTexPacked || this._linearTexPacked ) {
|
|
577
|
+
|
|
578
|
+
completeMaterialData.map = this.getPackedTextureIndex( material.map, true );
|
|
579
|
+
completeMaterialData.emissiveMap = this.getPackedTextureIndex( material.emissiveMap, true );
|
|
580
|
+
completeMaterialData.normalMap = this.getPackedTextureIndex( material.normalMap, false );
|
|
581
|
+
completeMaterialData.bumpMap = this.getPackedTextureIndex( material.bumpMap, false );
|
|
582
|
+
completeMaterialData.roughnessMap = this.getPackedTextureIndex( material.roughnessMap, false );
|
|
583
|
+
completeMaterialData.metalnessMap = this.getPackedTextureIndex( material.metalnessMap, false );
|
|
584
|
+
completeMaterialData.displacementMap = this.getPackedTextureIndex( material.displacementMap, false );
|
|
585
|
+
|
|
586
|
+
}
|
|
587
|
+
|
|
553
588
|
this.updateMaterialDataFromObject( materialIndex, completeMaterialData );
|
|
554
589
|
|
|
555
590
|
}
|
|
@@ -813,13 +848,10 @@ export class MaterialDataManager {
|
|
|
813
848
|
this.materialStorageAttr = null;
|
|
814
849
|
this.materialStorageNode = null;
|
|
815
850
|
this.materialCount = 0;
|
|
816
|
-
this.
|
|
817
|
-
this.
|
|
818
|
-
this.
|
|
819
|
-
this.
|
|
820
|
-
this.roughnessMaps = null;
|
|
821
|
-
this.metalnessMaps = null;
|
|
822
|
-
this.displacementMaps = null;
|
|
851
|
+
this.srgbBuckets = null;
|
|
852
|
+
this.linearBuckets = null;
|
|
853
|
+
this._srgbTexPacked = null;
|
|
854
|
+
this._linearTexPacked = null;
|
|
823
855
|
this.compiledFeatures = null;
|
|
824
856
|
|
|
825
857
|
}
|