rayzee 7.26.1 → 7.26.3
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/dist/rayzee.es.js +11 -74
- package/dist/rayzee.umd.js +3 -3
- package/package.json +1 -1
- package/src/Processor/GeometryExtractor.js +1 -38
- package/src/Processor/SceneProcessor.js +0 -4
- package/src/Stages/PathTracer.js +12 -0
- package/src/Stages/PathTracerStage.js +0 -3
- package/src/managers/MaterialDataManager.js +2 -145
package/dist/rayzee.es.js
CHANGED
|
@@ -1298,7 +1298,7 @@ var gi = class {
|
|
|
1298
1298
|
anisotropyRotation: Z.ANISOTROPY_ROTATION
|
|
1299
1299
|
}, Ei = class {
|
|
1300
1300
|
constructor(e) {
|
|
1301
|
-
this.sdfs = e, this.materialStorageAttr = null, this.materialStorageNode = null, this.materialCount = 0, this.srgbBuckets = null, this.linearBuckets = null, this._srgbTexPacked = null, this._linearTexPacked = null, this.
|
|
1301
|
+
this.sdfs = e, this.materialStorageAttr = null, this.materialStorageNode = null, this.materialCount = 0, this.srgbBuckets = null, this.linearBuckets = null, this._srgbTexPacked = null, this._linearTexPacked = null, this.callbacks = {};
|
|
1302
1302
|
}
|
|
1303
1303
|
setMaterialData(e) {
|
|
1304
1304
|
if (!e) return;
|
|
@@ -1461,17 +1461,7 @@ var gi = class {
|
|
|
1461
1461
|
yi.warn(`unknown material property: ${t}`);
|
|
1462
1462
|
return;
|
|
1463
1463
|
}
|
|
1464
|
-
this.materialStorageAttr.needsUpdate = !0, wi.has(t) && this._recomputeOpaqueBlockerForMaterial(e),
|
|
1465
|
-
"transmission",
|
|
1466
|
-
"clearcoat",
|
|
1467
|
-
"sheen",
|
|
1468
|
-
"iridescence",
|
|
1469
|
-
"dispersion",
|
|
1470
|
-
"transparent",
|
|
1471
|
-
"opacity",
|
|
1472
|
-
"alphaTest",
|
|
1473
|
-
"subsurface"
|
|
1474
|
-
].includes(t) && this.rescanMaterialFeatures() && this._notifyFeaturesChanged(), this._notifyReset();
|
|
1464
|
+
this.materialStorageAttr.needsUpdate = !0, wi.has(t) && this._recomputeOpaqueBlockerForMaterial(e), this._notifyReset();
|
|
1475
1465
|
}
|
|
1476
1466
|
updateMaterialDataFromObject(e, t) {
|
|
1477
1467
|
if (!this.materialStorageAttr) {
|
|
@@ -1524,7 +1514,7 @@ var gi = class {
|
|
|
1524
1514
|
let a = t[e] ?? i;
|
|
1525
1515
|
for (let e = 0; e < 8; e++) r + o + e < n.length && (n[r + o + e] = a[e]);
|
|
1526
1516
|
}
|
|
1527
|
-
this.materialStorageAttr.needsUpdate = !0, this.
|
|
1517
|
+
this.materialStorageAttr.needsUpdate = !0, this._notifyReset();
|
|
1528
1518
|
}
|
|
1529
1519
|
updateMaterial(e, t) {
|
|
1530
1520
|
let n = this.sdfs.geometryExtractor.createMaterialObject(t);
|
|
@@ -1551,46 +1541,9 @@ var gi = class {
|
|
|
1551
1541
|
for (let e = 0; e < 8; e++) i + a + e < r.length && (r[i + a + e] = n[e]);
|
|
1552
1542
|
this.materialStorageAttr.needsUpdate = !0, this._notifyReset();
|
|
1553
1543
|
}
|
|
1554
|
-
rescanMaterialFeatures() {
|
|
1555
|
-
if (!this.materialStorageAttr?.array) return yi.warn("material storage buffer not available for feature scanning"), !1;
|
|
1556
|
-
let e = this.materialStorageAttr.array, t = this.sdfs.materialCount || 1, n = {
|
|
1557
|
-
hasClearcoat: !1,
|
|
1558
|
-
hasTransmission: !1,
|
|
1559
|
-
hasDispersion: !1,
|
|
1560
|
-
hasIridescence: !1,
|
|
1561
|
-
hasSheen: !1,
|
|
1562
|
-
hasTransparency: !1,
|
|
1563
|
-
hasSubsurface: !1,
|
|
1564
|
-
hasMultiLobeMaterials: !1,
|
|
1565
|
-
hasMRTOutputs: !0
|
|
1566
|
-
};
|
|
1567
|
-
for (let r = 0; r < t; r++) {
|
|
1568
|
-
let t = r * Z.FLOATS_PER_MATERIAL, i = e[t + Z.TRANSMISSION], a = e[t + Z.DISPERSION], o = e[t + Z.SHEEN], s = e[t + Z.IRIDESCENCE], c = e[t + Z.CLEARCOAT], l = e[t + Z.OPACITY], u = e[t + Z.TRANSPARENT], d = e[t + Z.ALPHA_TEST], f = e[t + Z.SUBSURFACE];
|
|
1569
|
-
c > 0 && (n.hasClearcoat = !0), i > 0 && (n.hasTransmission = !0), a > 0 && (n.hasDispersion = !0), s > 0 && (n.hasIridescence = !0), o > 0 && (n.hasSheen = !0), (u > 0 || l < 1 || d > 0) && (n.hasTransparency = !0), f > 0 && (n.hasSubsurface = !0), [
|
|
1570
|
-
c > 0,
|
|
1571
|
-
i > 0,
|
|
1572
|
-
s > 0,
|
|
1573
|
-
o > 0
|
|
1574
|
-
].filter(Boolean).length >= 2 && (n.hasMultiLobeMaterials = !0);
|
|
1575
|
-
}
|
|
1576
|
-
let r = JSON.stringify(this.sdfs.sceneFeatures) !== JSON.stringify(n);
|
|
1577
|
-
return r && (this.sdfs.sceneFeatures = n), r;
|
|
1578
|
-
}
|
|
1579
|
-
injectMaterialFeatureDefines() {
|
|
1580
|
-
let e = this.sdfs.sceneFeatures;
|
|
1581
|
-
if (!e) {
|
|
1582
|
-
yi.warn("no sceneFeatures detected, skipping define injection");
|
|
1583
|
-
return;
|
|
1584
|
-
}
|
|
1585
|
-
let t = JSON.stringify(e);
|
|
1586
|
-
(!this.compiledFeatures || this.compiledFeatures !== t) && (yi.debug("material features:", e), this.compiledFeatures = t);
|
|
1587
|
-
}
|
|
1588
1544
|
_notifyReset() {
|
|
1589
1545
|
this.callbacks.onReset && this.callbacks.onReset();
|
|
1590
1546
|
}
|
|
1591
|
-
_notifyFeaturesChanged() {
|
|
1592
|
-
this.injectMaterialFeatureDefines();
|
|
1593
|
-
}
|
|
1594
1547
|
_recomputeOpaqueBlockerForMaterial(e) {
|
|
1595
1548
|
let t = this.materialStorageAttr?.array;
|
|
1596
1549
|
if (!t) return;
|
|
@@ -1611,7 +1564,7 @@ var gi = class {
|
|
|
1611
1564
|
this._patchTriangleFlagForMaterial(e, Si, t);
|
|
1612
1565
|
}
|
|
1613
1566
|
dispose() {
|
|
1614
|
-
this.materialStorageAttr = null, this.materialStorageNode = null, this.materialCount = 0, this.srgbBuckets = null, this.linearBuckets = null, this._srgbTexPacked = null, this._linearTexPacked = null
|
|
1567
|
+
this.materialStorageAttr = null, this.materialStorageNode = null, this.materialCount = 0, this.srgbBuckets = null, this.linearBuckets = null, this._srgbTexPacked = null, this._linearTexPacked = null;
|
|
1615
1568
|
}
|
|
1616
1569
|
}, Di = "function e(e,t,n,r){let i=n,a=n+r-1;for(;i<a;){let n=i+a>>1;e[n]<t?i=n+1:a=n}return i-n}function t(t,n,r){let i=n*r,a=new Float32Array(i),o=0;for(let e=0;e<r;e++){let i=Math.sin(Math.PI*(e+.5)/r);for(let r=0;r<n;r++){let s=e*n+r,c=t[4*s],l=t[4*s+1],u=t[4*s+2],d=(.2126*c+.7152*l+.0722*u)*i;a[s]=d,o+=d}}let s=o/i,c=0;for(let e=0;e<i;e++)a[e]=Math.max(0,a[e]-s),c+=a[e];let l=c>0,u=l?c:o,d=l?s:0;if(!l)for(let e=0;e<r;e++){let i=Math.sin(Math.PI*(e+.5)/r);for(let r=0;r<n;r++){let o=e*n+r,s=t[4*o],c=t[4*o+1],l=t[4*o+2];a[o]=(.2126*s+.7152*c+.0722*l)*i}}let f=new Float32Array(i),p=new Float32Array(r),m=0;for(let e=0;e<r;e++){let t=0;for(let r=0;r<n;r++){let i=e*n+r;t+=a[i],f[i]=t}if(t!==0)for(let r=e*n,i=e*n+n;r<i;r++)f[r]/=t;m+=t,p[e]=m}if(m!==0)for(let e=0,t=p.length;e<t;e++)p[e]/=m;let h=new Float32Array(r);for(let t=0;t<r;t++)h[t]=(e(p,(t+1)/r,0,r)+.5)/r;let g=new Float32Array(n*r);for(let t=0;t<r;t++)for(let r=0;r<n;r++){let i=t*n+r;g[i]=(e(f,(r+1)/n,t*n,n)+.5)/n}return{marginalData:h,conditionalData:g,totalSum:u,compensationDelta:d}}self.onmessage=function(e){let{floatData:n,width:r,height:i}=e.data;try{let e=t(n,r,i);self.postMessage({marginalData:e.marginalData,conditionalData:e.conditionalData,totalSum:e.totalSum,compensationDelta:e.compensationDelta,width:r,height:i},[e.marginalData.buffer,e.conditionalData.buffer])}catch(e){self.postMessage({error:e.message})}};", Oi = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", Di], { type: "text/javascript;charset=utf-8" });
|
|
1617
1570
|
function ki(e) {
|
|
@@ -6773,12 +6726,7 @@ var qc = ui("geometry"), Jc = 128, Yc = class {
|
|
|
6773
6726
|
if (t === -1) {
|
|
6774
6727
|
e.depthWrite === !1 && (e.depthWrite = !0, fi(qc, "depthWrite", "material had depthWrite disabled — enabled for rastered rendering"));
|
|
6775
6728
|
let n = this.createMaterialObject(e);
|
|
6776
|
-
this.materials.push(n), t = this.materials.length - 1, this._materialUuidMap.set(e.uuid, t)
|
|
6777
|
-
n.clearcoat > 0,
|
|
6778
|
-
n.transmission > 0,
|
|
6779
|
-
n.iridescence > 0,
|
|
6780
|
-
n.sheen > 0
|
|
6781
|
-
].filter(Boolean).length >= 2 && (this.sceneFeatures.hasMultiLobeMaterials = !0);
|
|
6729
|
+
this.materials.push(n), t = this.materials.length - 1, this._materialUuidMap.set(e.uuid, t);
|
|
6782
6730
|
}
|
|
6783
6731
|
return t;
|
|
6784
6732
|
}
|
|
@@ -7014,17 +6962,7 @@ var qc = ui("geometry"), Jc = 128, Yc = class {
|
|
|
7014
6962
|
if (e.children) for (let t of e.children) this._traverseMaterialsOnly(t);
|
|
7015
6963
|
}
|
|
7016
6964
|
resetArrays() {
|
|
7017
|
-
this.triangleData = null, this.triangleCount = 0, this.currentTriangleIndex = 0, this.materials = [], this.materialTriangleCounts = [], this.meshes = [], this.meshTriangleRanges = [], this.maps = [], this.normalMaps = [], this.bumpMaps = [], this.metalnessMaps = [], this.emissiveMaps = [], this.roughnessMaps = [], this.displacementMaps = [], this.anisotropyMaps = [], this.transmissionMaps = [], this.clearcoatMaps = [], this.clearcoatRoughnessMaps = [], this.sheenColorMaps = [], this.sheenRoughnessMaps = [], this.iridescenceMaps = [], this.iridescenceThicknessMaps = [], this.specularIntensityMaps = [], this.specularColorMaps = [], this.directionalLights = [], this.cameras = [], this._materialUuidMap = /* @__PURE__ */ new Map(), this._textureIndexCache = /* @__PURE__ */ new WeakMap()
|
|
7018
|
-
hasClearcoat: !1,
|
|
7019
|
-
hasTransmission: !1,
|
|
7020
|
-
hasDispersion: !1,
|
|
7021
|
-
hasIridescence: !1,
|
|
7022
|
-
hasSheen: !1,
|
|
7023
|
-
hasTransparency: !1,
|
|
7024
|
-
hasSubsurface: !1,
|
|
7025
|
-
hasMultiLobeMaterials: !1,
|
|
7026
|
-
hasMRTOutputs: !0
|
|
7027
|
-
};
|
|
6965
|
+
this.triangleData = null, this.triangleCount = 0, this.currentTriangleIndex = 0, this.materials = [], this.materialTriangleCounts = [], this.meshes = [], this.meshTriangleRanges = [], this.maps = [], this.normalMaps = [], this.bumpMaps = [], this.metalnessMaps = [], this.emissiveMaps = [], this.roughnessMaps = [], this.displacementMaps = [], this.anisotropyMaps = [], this.transmissionMaps = [], this.clearcoatMaps = [], this.clearcoatRoughnessMaps = [], this.sheenColorMaps = [], this.sheenRoughnessMaps = [], this.iridescenceMaps = [], this.iridescenceThicknessMaps = [], this.specularIntensityMaps = [], this.specularColorMaps = [], this.directionalLights = [], this.cameras = [], this._materialUuidMap = /* @__PURE__ */ new Map(), this._textureIndexCache = /* @__PURE__ */ new WeakMap();
|
|
7028
6966
|
}
|
|
7029
6967
|
getExtractedData() {
|
|
7030
6968
|
return {
|
|
@@ -7052,8 +6990,7 @@ var qc = ui("geometry"), Jc = 128, Yc = class {
|
|
|
7052
6990
|
specularIntensityMaps: this.specularIntensityMaps,
|
|
7053
6991
|
specularColorMaps: this.specularColorMaps,
|
|
7054
6992
|
directionalLights: this.directionalLights,
|
|
7055
|
-
cameras: this.cameras
|
|
7056
|
-
sceneFeatures: this.sceneFeatures
|
|
6993
|
+
cameras: this.cameras
|
|
7057
6994
|
};
|
|
7058
6995
|
}
|
|
7059
6996
|
}, Xc = class {
|
|
@@ -7497,7 +7434,7 @@ var al = ui("scene"), ol = class {
|
|
|
7497
7434
|
let t = performance.now();
|
|
7498
7435
|
try {
|
|
7499
7436
|
let n = this.geometryExtractor.extract(e);
|
|
7500
|
-
this.triangleData = n.triangleData, this.triangleCount = n.triangleCount, this._log(`Using Float32Array format: ${this.triangleCount} triangles, ${(this.triangleData.byteLength / (1024 * 1024)).toFixed(2)}MB`), this.materials = n.materials, this.
|
|
7437
|
+
this.triangleData = n.triangleData, this.triangleCount = n.triangleCount, this._log(`Using Float32Array format: ${this.triangleCount} triangles, ${(this.triangleData.byteLength / (1024 * 1024)).toFixed(2)}MB`), this.materials = n.materials, this.materialTriangleCounts = n.materialTriangleCounts, this.meshes = n.meshes, this.meshTriangleRanges = n.meshTriangleRanges, this.maps = n.maps, this.normalMaps = n.normalMaps, this.bumpMaps = n.bumpMaps, this.roughnessMaps = n.roughnessMaps, this.metalnessMaps = n.metalnessMaps, this.emissiveMaps = n.emissiveMaps, this.displacementMaps = n.displacementMaps, this.anisotropyMaps = n.anisotropyMaps, this.transmissionMaps = n.transmissionMaps, this.clearcoatMaps = n.clearcoatMaps, this.clearcoatRoughnessMaps = n.clearcoatRoughnessMaps, this.sheenColorMaps = n.sheenColorMaps, this.sheenRoughnessMaps = n.sheenRoughnessMaps, this.iridescenceMaps = n.iridescenceMaps, this.iridescenceThicknessMaps = n.iridescenceThicknessMaps, this.specularIntensityMaps = n.specularIntensityMaps, this.specularColorMaps = n.specularColorMaps, this.directionalLights = n.directionalLights, this.cameras = n.cameras;
|
|
7501
7438
|
let r = performance.now() - t;
|
|
7502
7439
|
this._log(`Geometry extraction complete (${r.toFixed(2)}ms)`, {
|
|
7503
7440
|
triangleCount: this.triangleCount,
|
|
@@ -7807,7 +7744,7 @@ var al = ui("scene"), ol = class {
|
|
|
7807
7744
|
try {
|
|
7808
7745
|
this.isProcessing = !0;
|
|
7809
7746
|
let n = this.geometryExtractor.extractMaterialsOnly(e);
|
|
7810
|
-
this._disposeMaterialTextures(), this.materials = n.materials, this.
|
|
7747
|
+
this._disposeMaterialTextures(), this.materials = n.materials, this.meshes = n.meshes, this.maps = n.maps, this.normalMaps = n.normalMaps, this.bumpMaps = n.bumpMaps, this.roughnessMaps = n.roughnessMaps, this.metalnessMaps = n.metalnessMaps, this.emissiveMaps = n.emissiveMaps, this.displacementMaps = n.displacementMaps, await this._createMaterialTextures();
|
|
7811
7748
|
let r = performance.now() - t;
|
|
7812
7749
|
return this._log(`Material rebuild complete (${r.toFixed(2)}ms)`, {
|
|
7813
7750
|
materials: this.materials.length,
|
|
@@ -8488,7 +8425,7 @@ var _l = ui("pathtracer"), vl = 4, yl = class extends ur {
|
|
|
8488
8425
|
});
|
|
8489
8426
|
}
|
|
8490
8427
|
async build(e) {
|
|
8491
|
-
this.dispose(), this.scene = e, await this.sdfs.buildBVH(e), this.cameras = this.sdfs.cameras, this.
|
|
8428
|
+
this.dispose(), this.scene = e, await this.sdfs.buildBVH(e), this.cameras = this.sdfs.cameras, this.updateSceneUniforms(), this.updateLights(), this._initCameraOptimizer(), this.setupMaterial();
|
|
8492
8429
|
}
|
|
8493
8430
|
updateSceneUniforms() {
|
|
8494
8431
|
this.setTriangleData(this.sdfs.triangleData, this.sdfs.triangleCount), this.setBVHData(this.sdfs.bvhData), this.setInstanceTable(this.sdfs.instanceTable), this.materialData.setMaterialData(this.sdfs.materialData), this.materialData.loadTexturesFromSdfs(), this.sdfs.emissiveTriangleData ? this.setEmissiveTriangleData(this.sdfs.emissiveTriangleData, this.sdfs.emissiveTriangleCount || 0) : this.emissiveTriangleCount.value = 0, this.sdfs.lightBVHNodeData ? this.setLightBVHData(this.sdfs.lightBVHNodeData, this.sdfs.lightBVHNodeCount || 0) : this.lightBVHNodeCount.value = 0, this._meshRefs = this._collectMeshRefs(this.scene), this.setMeshVisibilityData(this._meshRefs), this.spheres = this.sdfs.spheres || [];
|
|
@@ -10956,7 +10893,7 @@ var lf = ui("wavefront"), uf = 256, df = [
|
|
|
10956
10893
|
this._readbackFrameCounter = this._readbackEveryNFrames;
|
|
10957
10894
|
return;
|
|
10958
10895
|
}
|
|
10959
|
-
if (this._readbackPending || (this._readbackFrameCounter++, this._readbackFrameCounter < this._readbackEveryNFrames)) return;
|
|
10896
|
+
if (this._readbackPending || (this.maxBounces.value !== this._lastBounceCountsBudget && (this._readbackFrameCounter = this._readbackEveryNFrames), this._readbackFrameCounter++, this._readbackFrameCounter < this._readbackEveryNFrames)) return;
|
|
10960
10897
|
this._readbackFrameCounter = 0;
|
|
10961
10898
|
let e = this._queueManager?.getBounceCountsAttribute();
|
|
10962
10899
|
if (!e) return;
|