rayzee 6.1.0 → 6.2.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 +281 -279
- package/dist/rayzee.es.js.map +1 -1
- package/dist/rayzee.umd.js +14 -7
- package/dist/rayzee.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/TSL/PathTracer.js +20 -3
package/dist/rayzee.es.js
CHANGED
|
@@ -4405,7 +4405,7 @@ p(([e, t]) => {
|
|
|
4405
4405
|
let n = dn(t), r = U(.25 / 255, -.25 / 255, .25 / 255).toVar();
|
|
4406
4406
|
return r.assign(I(r.mul(2), r.mul(-2), n)), e.add(r);
|
|
4407
4407
|
});
|
|
4408
|
-
var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjectionMatrix: mat4x4f, cameraViewMatrix: mat4x4f ) -> f32 {\n let clipPos = cameraProjectionMatrix * cameraViewMatrix * vec4f( worldPos, 1.0f );\n let ndcDepth = clipPos.z / clipPos.w * 0.5f + 0.5f;\n return clamp( ndcDepth, 0.0f, 1.0f );\n }\n"), ws = p(([e, t, n, r, i]) => {
|
|
4408
|
+
var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjectionMatrix: mat4x4f, cameraViewMatrix: mat4x4f ) -> f32 {\n let clipPos = cameraProjectionMatrix * cameraViewMatrix * vec4f( worldPos, 1.0f );\n let ndcDepth = clipPos.z / clipPos.w * 0.5f + 0.5f;\n return clamp( ndcDepth, 0.0f, 1.0f );\n }\n"), ws = /* @__PURE__ */ G("\n fn nanInfToRed( c: vec3f ) -> vec3f {\n let isNan = c.x != c.x || c.y != c.y || c.z != c.z;\n let isInf = abs( c.x ) > 1e30f || abs( c.y ) > 1e30f || abs( c.z ) > 1e30f;\n if ( isNan || isInf ) { return vec3f( 1.0f, 0.0f, 0.0f ); }\n return vec3f( 0.0f );\n }\n"), Ts = p(([e, t, n, r, i]) => {
|
|
4409
4409
|
let a = Se(n, e.div(t), 0), o = M(0).toVar();
|
|
4410
4410
|
return m(a.b.greaterThan(.5), () => {
|
|
4411
4411
|
o.assign(0);
|
|
@@ -4413,7 +4413,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4413
4413
|
let e = M(te(a.r.mul(j(i)).add(.5)));
|
|
4414
4414
|
o.assign(E(e, r, i));
|
|
4415
4415
|
}), o;
|
|
4416
|
-
}),
|
|
4416
|
+
}), Es = (e) => {
|
|
4417
4417
|
let { pixelCoord: t, writeColorTex: n, writeNDTex: r, writeAlbedoTex: i, resolution: a, frame: o, samplesPerPixel: s, visMode: c, cameraWorldMatrix: l, cameraProjectionMatrixInverse: u, cameraViewMatrix: f, cameraProjectionMatrix: p, bvhBuffer: g, triangleBuffer: _, materialBuffer: v, albedoMaps: y, normalMaps: b, bumpMaps: x, metalnessMaps: S, roughnessMaps: C, emissiveMaps: w, displacementMaps: T, directionalLightsBuffer: E, numDirectionalLights: D, areaLightsBuffer: O, numAreaLights: ee, pointLightsBuffer: k, numPointLights: A, spotLightsBuffer: te, numSpotLights: ne, envTexture: N, environmentIntensity: re, envMatrix: ie, envCDFBuffer: P, envTotalSum: ae, envCompensationDelta: oe, envResolution: F, enableEnvironmentLight: se, useEnvMapIS: ce, groundProjectionEnabled: le, groundProjectionRadius: ue, groundProjectionHeight: de, maxBounceCount: fe, transmissiveBounces: pe, showBackground: me, transparentBackground: he, backgroundIntensity: ge, fireflyThreshold: _e, globalIlluminationIntensity: ve, enableEmissiveTriangleSampling: ye, emissiveTriangleBuffer: be, emissiveVec4Offset: xe, emissiveTriangleCount: z, emissiveTotalPower: V, emissiveBoost: we, lightBVHBuffer: Te, lightBVHNodeCount: G, debugVisScale: De, enableAccumulation: Oe, hasPreviousAccumulated: ke, prevAccumTexture: Ae, prevNormalDepthTexture: je, prevAlbedoTexture: Me, accumulationAlpha: Ne, cameraIsMoving: Pe, useAdaptiveSampling: Fe, adaptiveSamplingTexture: Ie, adaptiveSamplingMin: Le, adaptiveSamplingMax: Re, enableDOF: ze, focalLength: Be, aperture: Ve, focusDistance: He, sceneScale: Ue, apertureScale: We, anamorphicRatio: Ge } = e, Ke = Ee(B(M(t.x)), B(M(t.y))), qe = t.div(a), Je = t.div(a).mul(2).sub(1).toVar();
|
|
4418
4418
|
Je.y.assign(Je.y.negate());
|
|
4419
4419
|
let Ye = W(0).toVar(), Xe = M(0).toVar(), Ze = bn({
|
|
@@ -4422,7 +4422,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4422
4422
|
frame: o
|
|
4423
4423
|
}).toVar(), K = U(0, 0, 1).toVar(), Qe = j(1).toVar(), $e = j(0).toVar(), et = M(s).toVar();
|
|
4424
4424
|
m(o.greaterThan(B(2)).and(Fe), () => {
|
|
4425
|
-
let e =
|
|
4425
|
+
let e = Ts(t, a, Ie, Le, Re);
|
|
4426
4426
|
et.assign(e), m(et.equal(M(0)), () => {
|
|
4427
4427
|
m(Oe.and(ke), () => {
|
|
4428
4428
|
let e = Se(Ae, qe, 0);
|
|
@@ -4446,7 +4446,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4446
4446
|
Ye.assign(W(r, 1, 1)), Xe.assign(1), d();
|
|
4447
4447
|
});
|
|
4448
4448
|
let i = r.sub(.5).mul(it), s = Je.add(i), h = Lr.wrap(Ii(s, n, l, u, ze, Be, Ve, He, Ue, We, Ge)), j = W(0).toVar();
|
|
4449
|
-
m(c.greaterThan(M(0)), () => {
|
|
4449
|
+
m(c.greaterThan(M(0)).and(c.notEqual(M(11))), () => {
|
|
4450
4450
|
j.assign(Ss(h.origin, h.direction, g, _, v, N, ie, re, se, c, De, t, a, y, b, x, S, C, w, p, f, o));
|
|
4451
4451
|
}).Else(() => {
|
|
4452
4452
|
let r = fs.wrap(vs(h, n, e, g, _, v, y, b, x, S, C, w, T, E, D, O, ee, k, A, te, ne, N, re, ie, P, ae, oe, F, se, ce, le, ue, de, fe, pe, ge, me, he, _e, ve, ye, be, xe, z, V, we, Te, G, t, a, o));
|
|
@@ -4464,13 +4464,15 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4464
4464
|
Ye.divAssign(j(Xe)), $e.divAssign(j(Xe));
|
|
4465
4465
|
});
|
|
4466
4466
|
let at = Ye.xyz.toVar(), ot = W(K.mul(.5).add(.5), Qe).toVar(), q = U(nt).toVar(), st = R(he, $e, j(1)).toVar();
|
|
4467
|
-
m(Oe.and(Pe.not()).and(o.greaterThan(B(0))).and(ke), () => {
|
|
4467
|
+
m(Oe.and(Pe.not()).and(o.greaterThan(B(0))).and(ke).and(c.notEqual(M(11))), () => {
|
|
4468
4468
|
let e = Se(Ae, qe, 0).toVar();
|
|
4469
4469
|
at.assign(I(e.xyz, Ye.xyz, Ne)), ot.assign(I(Se(je, qe, 0), ot, Ne)), q.assign(I(Se(Me, qe, 0).xyz, q, Ne)), m(he, () => {
|
|
4470
4470
|
st.assign(I(e.w, $e, Ne));
|
|
4471
4471
|
});
|
|
4472
|
+
}), m(c.equal(M(11)), () => {
|
|
4473
|
+
at.assign(ws(at));
|
|
4472
4474
|
}), Ce(n, Ke, W(at.xyz, st)).toWriteOnly(), Ce(r, Ke, ot).toWriteOnly(), Ce(i, Ke, W(q, 1)).toWriteOnly();
|
|
4473
|
-
},
|
|
4475
|
+
}, Ds = class {
|
|
4474
4476
|
constructor(e = "Build") {
|
|
4475
4477
|
this.label = e, this.entries = /* @__PURE__ */ new Map(), this.order = [], this.totalStart = performance.now();
|
|
4476
4478
|
}
|
|
@@ -4497,7 +4499,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4497
4499
|
total: Math.round(e)
|
|
4498
4500
|
};
|
|
4499
4501
|
}
|
|
4500
|
-
},
|
|
4502
|
+
}, Os = 8, ks = class {
|
|
4501
4503
|
constructor() {
|
|
4502
4504
|
this.computeNode = null, this.prevColorTexNode = null, this.prevNormalDepthTexNode = null, this.prevAlbedoTexNode = null, this.adaptiveSamplingTexNode = null, this.tileOffsetX = V(0, "int"), this.tileOffsetY = V(0, "int"), this.renderWidth = V(1920, "int"), this.renderHeight = V(1080, "int"), this._dispatchX = 0, this._dispatchY = 0, this._dispatchSize = [
|
|
4503
4505
|
0,
|
|
@@ -4506,12 +4508,12 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4506
4508
|
], this._sceneTextureNodes = null, this._compiled = !1;
|
|
4507
4509
|
}
|
|
4508
4510
|
setupCompute(e) {
|
|
4509
|
-
let { stage: t, storageTextures: n } = e, r = new
|
|
4511
|
+
let { stage: t, storageTextures: n } = e, r = new Ds("setupCompute");
|
|
4510
4512
|
r.start("Create texture nodes");
|
|
4511
4513
|
let i = this._createTextureNodes(t, n);
|
|
4512
4514
|
r.end("Create texture nodes"), r.start("Build compute node (TSL)");
|
|
4513
4515
|
let a = n.renderWidth, o = n.renderHeight;
|
|
4514
|
-
this._dispatchX = Math.ceil(a /
|
|
4516
|
+
this._dispatchX = Math.ceil(a / Os), this._dispatchY = Math.ceil(o / Os), this.renderWidth.value = a, this.renderHeight.value = o;
|
|
4515
4517
|
let s = n.getWriteTextures();
|
|
4516
4518
|
this.computeNode = this._buildComputeNode(t, i, s.color, s.normalDepth, s.albedo), this._compiled = !1, r.end("Build compute node (TSL)"), r.print();
|
|
4517
4519
|
}
|
|
@@ -4531,11 +4533,11 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4531
4533
|
return this._sceneTextureNodes;
|
|
4532
4534
|
}
|
|
4533
4535
|
setSize(e, t) {
|
|
4534
|
-
this._dispatchX = Math.ceil(e /
|
|
4536
|
+
this._dispatchX = Math.ceil(e / Os), this._dispatchY = Math.ceil(t / Os), this.computeNode && (this._dispatchSize[0] = this._dispatchX, this._dispatchSize[1] = this._dispatchY, this.computeNode.dispatchSize = this._dispatchSize), this.renderWidth.value = e, this.renderHeight.value = t, this.tileOffsetX.value = 0, this.tileOffsetY.value = 0;
|
|
4535
4537
|
}
|
|
4536
4538
|
setTileDispatch(e, t, n, r) {
|
|
4537
4539
|
this.tileOffsetX.value = e, this.tileOffsetY.value = t;
|
|
4538
|
-
let i = Math.ceil(n /
|
|
4540
|
+
let i = Math.ceil(n / Os), a = Math.ceil(r / Os);
|
|
4539
4541
|
this.computeNode && (this._dispatchSize[0] = i, this._dispatchSize[1] = a, this.computeNode.dispatchSize = this._dispatchSize);
|
|
4540
4542
|
}
|
|
4541
4543
|
setFullScreenDispatch() {
|
|
@@ -4586,9 +4588,9 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4586
4588
|
_buildComputeNode(e, t, n, r, i) {
|
|
4587
4589
|
let { triStorage: a, bvhStorage: o, matStorage: s, lightBufferStorage: c, envTex: l, adaptiveSamplingTex: u, envCDFStorage: d, albedoMapsTex: f, normalMapsTex: h, bumpMapsTex: g, metalnessMapsTex: _, roughnessMapsTex: v, emissiveMapsTex: y, displacementMapsTex: b } = t, x = this.tileOffsetX, S = this.tileOffsetY, C = this.renderWidth, w = this.renderHeight, T = this.prevColorTexNode, E = this.prevNormalDepthTexNode, D = this.prevAlbedoTexNode;
|
|
4588
4590
|
return p(() => {
|
|
4589
|
-
let t = x.add(M(ke.x).mul(
|
|
4591
|
+
let t = x.add(M(ke.x).mul(Os)).add(M(P.x)), p = S.add(M(ke.y).mul(Os)).add(M(P.y));
|
|
4590
4592
|
m(t.lessThan(C).and(p.lessThan(w)), () => {
|
|
4591
|
-
|
|
4593
|
+
Es({
|
|
4592
4594
|
pixelCoord: H(j(t).add(.5), j(p).add(.5)),
|
|
4593
4595
|
writeColorTex: n,
|
|
4594
4596
|
writeNDTex: r,
|
|
@@ -4672,15 +4674,15 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4672
4674
|
this._dispatchY,
|
|
4673
4675
|
1
|
|
4674
4676
|
], [
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
+
Os,
|
|
4678
|
+
Os,
|
|
4677
4679
|
1
|
|
4678
4680
|
]);
|
|
4679
4681
|
}
|
|
4680
4682
|
dispose() {
|
|
4681
4683
|
this.computeNode?.dispose(), this.computeNode = null, this.prevColorTexNode = null, this.prevNormalDepthTexNode = null, this.prevAlbedoTexNode = null, this.adaptiveSamplingTexNode = null, this._sceneTextureNodes = null, this._compiled = !1;
|
|
4682
4684
|
}
|
|
4683
|
-
},
|
|
4685
|
+
}, As = class {
|
|
4684
4686
|
constructor(e, t) {
|
|
4685
4687
|
this.traversalCost = e, this.intersectionCost = t, this.maxTreeletLeaves = 7, this.minImprovement = .02, this.topologyCache = /* @__PURE__ */ new Map();
|
|
4686
4688
|
for (let e = 3; e <= this.maxTreeletLeaves; e++) this.topologyCache.set(e, this.generateTopologies(e));
|
|
@@ -4871,10 +4873,10 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4871
4873
|
}
|
|
4872
4874
|
buildSubtree(e, t, n) {
|
|
4873
4875
|
if (typeof e == "number") {
|
|
4874
|
-
let r = t[n[e]], i = new
|
|
4876
|
+
let r = t[n[e]], i = new js();
|
|
4875
4877
|
return i.minX = r.minX, i.minY = r.minY, i.minZ = r.minZ, i.maxX = r.maxX, i.maxY = r.maxY, i.maxZ = r.maxZ, i.triangleOffset = r.triangleOffset, i.triangleCount = r.triangleCount, i;
|
|
4876
4878
|
}
|
|
4877
|
-
let r = this.buildSubtree(e[0], t, n), i = this.buildSubtree(e[1], t, n), a = new
|
|
4879
|
+
let r = this.buildSubtree(e[0], t, n), i = this.buildSubtree(e[1], t, n), a = new js();
|
|
4878
4880
|
return a.leftChild = r, a.rightChild = i, a.minX = Math.min(r.minX, i.minX), a.minY = Math.min(r.minY, i.minY), a.minZ = Math.min(r.minZ, i.minZ), a.maxX = Math.max(r.maxX, i.maxX), a.maxY = Math.max(r.maxY, i.maxY), a.maxZ = Math.max(r.maxZ, i.maxZ), a;
|
|
4879
4881
|
}
|
|
4880
4882
|
setTreeletSize(e) {
|
|
@@ -4888,11 +4890,11 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4888
4890
|
getStatistics() {
|
|
4889
4891
|
return { ...this.stats };
|
|
4890
4892
|
}
|
|
4891
|
-
},
|
|
4893
|
+
}, js = class {
|
|
4892
4894
|
constructor() {
|
|
4893
4895
|
this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.leftChild = null, this.rightChild = null, this.triangleOffset = 0, this.triangleCount = 0;
|
|
4894
4896
|
}
|
|
4895
|
-
},
|
|
4897
|
+
}, Ms = class {
|
|
4896
4898
|
constructor(e, t) {
|
|
4897
4899
|
this.traversalCost = e, this.intersectionCost = t, this.batchSizeRatio = .02, this.maxIterations = 2, this.timeBudgetMs = 15e3, this.stats = {
|
|
4898
4900
|
reinsertionsApplied: 0,
|
|
@@ -5057,7 +5059,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5057
5059
|
}
|
|
5058
5060
|
return this.stats.timeMs = performance.now() - n, this.stats;
|
|
5059
5061
|
}
|
|
5060
|
-
},
|
|
5062
|
+
}, Ns = "" + new URL("assets/BVHWorker-CNJ0UBQz.js", import.meta.url).href, Ps = {
|
|
5061
5063
|
FLOATS_PER_TRIANGLE: 32,
|
|
5062
5064
|
POSITION_A_OFFSET: 0,
|
|
5063
5065
|
POSITION_B_OFFSET: 4,
|
|
@@ -5067,11 +5069,11 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5067
5069
|
NORMAL_C_OFFSET: 20,
|
|
5068
5070
|
UV_AB_OFFSET: 24,
|
|
5069
5071
|
UV_C_MAT_OFFSET: 28
|
|
5070
|
-
},
|
|
5072
|
+
}, Fs = Ps.FLOATS_PER_TRIANGLE, Is = class {
|
|
5071
5073
|
constructor() {
|
|
5072
5074
|
this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.leftChild = null, this.rightChild = null, this.triangleOffset = 0, this.triangleCount = 0;
|
|
5073
5075
|
}
|
|
5074
|
-
},
|
|
5076
|
+
}, Ls = class {
|
|
5075
5077
|
constructor() {
|
|
5076
5078
|
this.useWorker = !0, this.maxLeafSize = 8, this.numBins = 32, this.minBins = 8, this.maxBins = 64, this.totalNodes = 0, this.processedTriangles = 0, this.totalTriangles = 0, this.lastProgressUpdate = 0, this.progressUpdateInterval = 100, this.traversalCost = 1, this.intersectionCost = 2.5, this.useMortonCodes = !0, this.mortonBits = 10, this.mortonClusterThreshold = 128, this.enableObjectMedianFallback = !0, this.enableSpatialMedianFallback = !0, this.splitStats = {
|
|
5077
5079
|
sahSplits: 0,
|
|
@@ -5131,9 +5133,9 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5131
5133
|
e.enabled !== void 0 && (this.enableReinsertionOptimization = e.enabled), e.batchSizeRatio !== void 0 && (this.reinsertionBatchSizeRatio = Math.max(.005, Math.min(.1, e.batchSizeRatio))), e.maxIterations !== void 0 && (this.reinsertionMaxIterations = Math.max(1, Math.min(5, e.maxIterations)));
|
|
5132
5134
|
}
|
|
5133
5135
|
initializeTriangleArrays() {
|
|
5134
|
-
let e = this.totalTriangles, t = this.triangles, n =
|
|
5136
|
+
let e = this.totalTriangles, t = this.triangles, n = Ps.POSITION_A_OFFSET, r = Ps.POSITION_B_OFFSET, i = Ps.POSITION_C_OFFSET;
|
|
5135
5137
|
for (let a = 0; a < e; a++) {
|
|
5136
|
-
let e = a *
|
|
5138
|
+
let e = a * Fs, o = t[e + n], s = t[e + n + 1], c = t[e + n + 2], l = t[e + r], u = t[e + r + 1], d = t[e + r + 2], f = t[e + i], p = t[e + i + 1], m = t[e + i + 2], h = a * 3;
|
|
5137
5139
|
this.centroids[h] = (o + l + f) / 3, this.centroids[h + 1] = (s + u + p) / 3, this.centroids[h + 2] = (c + d + m) / 3, this.bMin[h] = o < l ? o < f ? o : f : l < f ? l : f, this.bMin[h + 1] = s < u ? s < p ? s : p : u < p ? u : p, this.bMin[h + 2] = c < d ? c < m ? c : m : d < m ? d : m, this.bMax[h] = o > l ? o > f ? o : f : l > f ? l : f, this.bMax[h + 1] = s > u ? s > p ? s : p : u > p ? u : p, this.bMax[h + 2] = c > d ? c > m ? c : m : d > m ? d : m, this.indices[a] = a;
|
|
5138
5140
|
}
|
|
5139
5141
|
}
|
|
@@ -5178,11 +5180,11 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5178
5180
|
this.splitStats.mortonSortTime += performance.now() - t;
|
|
5179
5181
|
}
|
|
5180
5182
|
build(e, t = 30, n = null) {
|
|
5181
|
-
return this.totalTriangles = e.byteLength / (
|
|
5183
|
+
return this.totalTriangles = e.byteLength / (Fs * 4), this.processedTriangles = 0, this.lastProgressUpdate = performance.now(), this.useWorker && typeof Worker < "u" ? new Promise((r, i) => {
|
|
5182
5184
|
let a = (a) => {
|
|
5183
5185
|
let o = this.totalTriangles, s = typeof SharedArrayBuffer < "u";
|
|
5184
5186
|
console.log(`[BVHBuilder] SharedArrayBuffer: ${s ? "enabled" : "unavailable (using transfer fallback)"}`);
|
|
5185
|
-
let c = s ? new SharedArrayBuffer(o *
|
|
5187
|
+
let c = s ? new SharedArrayBuffer(o * Fs * 4) : null;
|
|
5186
5188
|
a.onmessage = (e) => {
|
|
5187
5189
|
let { bvhData: t, triangles: o, originalToBvh: s, error: l, progress: u, treeletStats: d } = e.data;
|
|
5188
5190
|
if (l) {
|
|
@@ -5225,9 +5227,9 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5225
5227
|
a.postMessage(u, [l]);
|
|
5226
5228
|
};
|
|
5227
5229
|
try {
|
|
5228
|
-
a(new Worker(
|
|
5230
|
+
a(new Worker(Ns, { type: "module" }));
|
|
5229
5231
|
} catch (i) {
|
|
5230
|
-
i.name === "SecurityError" ? or(
|
|
5232
|
+
i.name === "SecurityError" ? or(Ns).then(a).catch(() => {
|
|
5231
5233
|
console.warn("Worker fetch fallback failed, using synchronous build"), r(this._buildSyncAndFlatten(e, t, n));
|
|
5232
5234
|
}) : (console.warn("Worker creation failed, falling back to synchronous build:", i), r(this._buildSyncAndFlatten(e, t, n)));
|
|
5233
5235
|
}
|
|
@@ -5246,7 +5248,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5246
5248
|
}
|
|
5247
5249
|
buildSync(e, t = 30, n = null, r = null) {
|
|
5248
5250
|
let i = performance.now();
|
|
5249
|
-
this.totalNodes = 0, this.processedTriangles = 0, this.triangles = e, this.totalTriangles = e.byteLength / (
|
|
5251
|
+
this.totalNodes = 0, this.processedTriangles = 0, this.triangles = e, this.totalTriangles = e.byteLength / (Fs * 4), this.lastProgressUpdate = performance.now(), this.splitStats = {
|
|
5250
5252
|
sahSplits: 0,
|
|
5251
5253
|
objectMedianSplits: 0,
|
|
5252
5254
|
spatialMedianSplits: 0,
|
|
@@ -5271,7 +5273,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5271
5273
|
this.centroids = new Float32Array(a * 3), this.bMin = new Float32Array(a * 3), this.bMax = new Float32Array(a * 3), this.indices = new Uint32Array(a), this.mortonCodes = new Uint32Array(a), this.initializeTriangleArrays(), this.splitStats.initTime = performance.now() - o, this.sortTrianglesByMortonCode();
|
|
5272
5274
|
let s = performance.now(), c = this.buildNodeRecursive(0, a, t, n);
|
|
5273
5275
|
if (this.splitStats.sahBuildTime = performance.now() - s, this.enableTreeletOptimization && this.totalTriangles > 1e3) {
|
|
5274
|
-
let e = this.totalTriangles > this.treeletComplexityThreshold, t = e ? 3 : this.treeletSize, r = e ? 10 : this.maxTreeletsPerScene, i = new
|
|
5276
|
+
let e = this.totalTriangles > this.treeletComplexityThreshold, t = e ? 3 : this.treeletSize, r = e ? 10 : this.maxTreeletsPerScene, i = new As(this.traversalCost, this.intersectionCost);
|
|
5275
5277
|
i.setTreeletSize(t), i.setMinImprovement(this.treeletMinImprovement), i.setMaxTreelets(r);
|
|
5276
5278
|
let a = performance.now();
|
|
5277
5279
|
for (let e = 0; e < this.treeletOptimizationPasses; e++) {
|
|
@@ -5293,7 +5295,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5293
5295
|
this.splitStats.treeletsProcessed = s.treeletsProcessed, this.splitStats.treeletsImproved = s.treeletsImproved, this.splitStats.averageSAHImprovement = s.averageSAHImprovement;
|
|
5294
5296
|
}
|
|
5295
5297
|
if (this.enableReinsertionOptimization && this.totalTriangles > 1e3) {
|
|
5296
|
-
let e = new
|
|
5298
|
+
let e = new Ms(this.traversalCost, this.intersectionCost);
|
|
5297
5299
|
e.setBatchSizeRatio(this.reinsertionBatchSizeRatio), e.setMaxIterations(this.reinsertionMaxIterations);
|
|
5298
5300
|
let t = n ? (e) => {
|
|
5299
5301
|
n(e);
|
|
@@ -5308,10 +5310,10 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5308
5310
|
}
|
|
5309
5311
|
let l = performance.now();
|
|
5310
5312
|
this.applySAOrdering(c), this.splitStats.saOrderTime = performance.now() - l;
|
|
5311
|
-
let u = performance.now(), d = this.triangles, f = r || new Float32Array(a *
|
|
5313
|
+
let u = performance.now(), d = this.triangles, f = r || new Float32Array(a * Fs);
|
|
5312
5314
|
for (let e = 0; e < a; e++) {
|
|
5313
|
-
let t = this.indices[e] *
|
|
5314
|
-
f.set(d.subarray(t, t +
|
|
5315
|
+
let t = this.indices[e] * Fs, n = e * Fs;
|
|
5316
|
+
f.set(d.subarray(t, t + Fs), n);
|
|
5315
5317
|
}
|
|
5316
5318
|
this.reorderedTriangleData = f;
|
|
5317
5319
|
let p = new Uint32Array(a);
|
|
@@ -5327,7 +5329,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5327
5329
|
n - this.lastProgressUpdate < this.progressUpdateInterval || (this.lastProgressUpdate = n, t(Math.min(Math.floor(this.processedTriangles / this.totalTriangles * 100), 99)));
|
|
5328
5330
|
}
|
|
5329
5331
|
buildNodeRecursiveToDepth(e, t, n, r, i, a, o, s, c, l, u) {
|
|
5330
|
-
let d = new
|
|
5332
|
+
let d = new Is();
|
|
5331
5333
|
this.totalNodes++;
|
|
5332
5334
|
let f = t - e;
|
|
5333
5335
|
if (a === void 0 ? this.updateNodeBounds(d, e, t) : (d.minX = a, d.minY = o, d.minZ = s, d.maxX = c, d.maxY = l, d.maxZ = u), f <= this.maxLeafSize || n <= 0) return d.triangleOffset = e, d.triangleCount = f, this.updateProgress(f, i), d;
|
|
@@ -5368,7 +5370,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5368
5370
|
return h === e || h === t ? (d.triangleOffset = e, d.triangleCount = f, this.updateProgress(f, i), d) : (d.leftChild = this.buildNodeRecursiveToDepth(e, h, n - 1, r - 1, i, g, _, v, y, b, x), d.rightChild = this.buildNodeRecursiveToDepth(h, t, n - 1, r - 1, i, S, C, w, T, E, D), d);
|
|
5369
5371
|
}
|
|
5370
5372
|
buildNodeRecursive(e, t, n, r, i, a, o, s, c, l) {
|
|
5371
|
-
let u = new
|
|
5373
|
+
let u = new Is();
|
|
5372
5374
|
this.totalNodes++;
|
|
5373
5375
|
let d = t - e;
|
|
5374
5376
|
if (i === void 0 ? this.updateNodeBounds(u, e, t) : (u.minX = i, u.minY = a, u.minZ = o, u.maxX = s, u.maxY = c, u.maxZ = l), d <= this.maxLeafSize || n <= 0) return u.triangleOffset = e, u.triangleCount = d, this.updateProgress(d, r), u;
|
|
@@ -5666,7 +5668,7 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5666
5668
|
let o = r - e, s = i - t, c = a - n;
|
|
5667
5669
|
return 2 * (o * s + s * c + c * o);
|
|
5668
5670
|
}
|
|
5669
|
-
},
|
|
5671
|
+
}, Rs = {
|
|
5670
5672
|
FLOATS_PER_TRIANGLE: 32,
|
|
5671
5673
|
POSITION_A_OFFSET: 0,
|
|
5672
5674
|
POSITION_B_OFFSET: 4,
|
|
@@ -5674,28 +5676,28 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5674
5676
|
NORMAL_A_OFFSET: 12,
|
|
5675
5677
|
NORMAL_B_OFFSET: 16,
|
|
5676
5678
|
NORMAL_C_OFFSET: 20
|
|
5677
|
-
},
|
|
5679
|
+
}, zs = Rs.FLOATS_PER_TRIANGLE, Bs = 16, Vs = -1, Hs = -2, Us = class {
|
|
5678
5680
|
constructor() {
|
|
5679
5681
|
this._bounds = null, this._boundsNodeCount = 0;
|
|
5680
5682
|
}
|
|
5681
5683
|
updateTrianglePositions(e, t, n) {
|
|
5682
5684
|
let r = n.length;
|
|
5683
5685
|
for (let i = 0; i < r; i++) {
|
|
5684
|
-
let r = n[i], a = i *
|
|
5685
|
-
e[a +
|
|
5686
|
+
let r = n[i], a = i * zs, o = r * 9, s = t[o], c = t[o + 1], l = t[o + 2], u = t[o + 3], d = t[o + 4], f = t[o + 5], p = t[o + 6], m = t[o + 7], h = t[o + 8];
|
|
5687
|
+
e[a + Rs.POSITION_A_OFFSET] = s, e[a + Rs.POSITION_A_OFFSET + 1] = c, e[a + Rs.POSITION_A_OFFSET + 2] = l, e[a + Rs.POSITION_B_OFFSET] = u, e[a + Rs.POSITION_B_OFFSET + 1] = d, e[a + Rs.POSITION_B_OFFSET + 2] = f, e[a + Rs.POSITION_C_OFFSET] = p, e[a + Rs.POSITION_C_OFFSET + 1] = m, e[a + Rs.POSITION_C_OFFSET + 2] = h;
|
|
5686
5688
|
let g = u - s, _ = d - c, v = f - l, y = p - s, b = m - c, x = h - l, S = _ * x - v * b, C = v * y - g * x, w = g * b - _ * y;
|
|
5687
|
-
e[a +
|
|
5689
|
+
e[a + Rs.NORMAL_A_OFFSET] = S, e[a + Rs.NORMAL_A_OFFSET + 1] = C, e[a + Rs.NORMAL_A_OFFSET + 2] = w, e[a + Rs.NORMAL_B_OFFSET] = S, e[a + Rs.NORMAL_B_OFFSET + 1] = C, e[a + Rs.NORMAL_B_OFFSET + 2] = w, e[a + Rs.NORMAL_C_OFFSET] = S, e[a + Rs.NORMAL_C_OFFSET + 1] = C, e[a + Rs.NORMAL_C_OFFSET + 2] = w;
|
|
5688
5690
|
}
|
|
5689
5691
|
}
|
|
5690
5692
|
refitRange(e, t, n, r) {
|
|
5691
5693
|
r > this._boundsNodeCount && (this._bounds = new Float32Array(r * 6), this._boundsNodeCount = r);
|
|
5692
5694
|
let i = this._bounds, a = n + r;
|
|
5693
5695
|
for (let r = a - 1; r >= n; r--) {
|
|
5694
|
-
let a = r *
|
|
5695
|
-
if (e[a + 3] ===
|
|
5696
|
+
let a = r * Bs, o = (r - n) * 6;
|
|
5697
|
+
if (e[a + 3] === Vs) {
|
|
5696
5698
|
let n = e[a], r = e[a + 1], s = Infinity, c = Infinity, l = Infinity, u = -Infinity, d = -Infinity, f = -Infinity;
|
|
5697
5699
|
for (let e = 0; e < r; e++) {
|
|
5698
|
-
let r = (n + e) *
|
|
5700
|
+
let r = (n + e) * zs, i = t[r + Rs.POSITION_A_OFFSET], a = t[r + Rs.POSITION_A_OFFSET + 1], o = t[r + Rs.POSITION_A_OFFSET + 2], p = t[r + Rs.POSITION_B_OFFSET], m = t[r + Rs.POSITION_B_OFFSET + 1], h = t[r + Rs.POSITION_B_OFFSET + 2], g = t[r + Rs.POSITION_C_OFFSET], _ = t[r + Rs.POSITION_C_OFFSET + 1], v = t[r + Rs.POSITION_C_OFFSET + 2];
|
|
5699
5701
|
s = Math.min(s, i, p, g), c = Math.min(c, a, m, _), l = Math.min(l, o, h, v), u = Math.max(u, i, p, g), d = Math.max(d, a, m, _), f = Math.max(f, o, h, v);
|
|
5700
5702
|
}
|
|
5701
5703
|
i[o] = s, i[o + 1] = c, i[o + 2] = l, i[o + 3] = u, i[o + 4] = d, i[o + 5] = f;
|
|
@@ -5709,15 +5711,15 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5709
5711
|
n !== this._boundsNodeCount && (this._bounds = new Float32Array(n * 6), this._boundsNodeCount = n);
|
|
5710
5712
|
let r = this._bounds;
|
|
5711
5713
|
for (let i = n - 1; i >= 0; i--) {
|
|
5712
|
-
let n = i *
|
|
5713
|
-
if (o ===
|
|
5714
|
+
let n = i * Bs, a = i * 6, o = e[n + 3];
|
|
5715
|
+
if (o === Vs) {
|
|
5714
5716
|
let i = e[n], o = e[n + 1], s = Infinity, c = Infinity, l = Infinity, u = -Infinity, d = -Infinity, f = -Infinity;
|
|
5715
5717
|
for (let e = 0; e < o; e++) {
|
|
5716
|
-
let n = (i + e) *
|
|
5718
|
+
let n = (i + e) * zs, r = t[n + Rs.POSITION_A_OFFSET], a = t[n + Rs.POSITION_A_OFFSET + 1], o = t[n + Rs.POSITION_A_OFFSET + 2], p = t[n + Rs.POSITION_B_OFFSET], m = t[n + Rs.POSITION_B_OFFSET + 1], h = t[n + Rs.POSITION_B_OFFSET + 2], g = t[n + Rs.POSITION_C_OFFSET], _ = t[n + Rs.POSITION_C_OFFSET + 1], v = t[n + Rs.POSITION_C_OFFSET + 2];
|
|
5717
5719
|
s = Math.min(s, r, p, g), c = Math.min(c, a, m, _), l = Math.min(l, o, h, v), u = Math.max(u, r, p, g), d = Math.max(d, a, m, _), f = Math.max(f, o, h, v);
|
|
5718
5720
|
}
|
|
5719
5721
|
r[a] = s, r[a + 1] = c, r[a + 2] = l, r[a + 3] = u, r[a + 4] = d, r[a + 5] = f;
|
|
5720
|
-
} else if (o ===
|
|
5722
|
+
} else if (o === Hs) {
|
|
5721
5723
|
let t = e[n] * 6;
|
|
5722
5724
|
r[a] = r[t], r[a + 1] = r[t + 1], r[a + 2] = r[t + 2], r[a + 3] = r[t + 3], r[a + 4] = r[t + 4], r[a + 5] = r[t + 5];
|
|
5723
5725
|
} else {
|
|
@@ -5726,19 +5728,19 @@ var Cs = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
5726
5728
|
}
|
|
5727
5729
|
}
|
|
5728
5730
|
}
|
|
5729
|
-
},
|
|
5730
|
-
function
|
|
5731
|
-
let i = e.byteLength / (
|
|
5731
|
+
}, Ws = "" + new URL("assets/BVHSubtreeWorker-D9GImjGj.js", import.meta.url).href, Gs = 32, Ks = 5e4, qs = 8;
|
|
5732
|
+
function Js(e, t, n, r) {
|
|
5733
|
+
let i = e.byteLength / (Gs * 4), a = Math.min(navigator.hardwareConcurrency || 4, qs), o = Math.ceil(Math.log2(a * 2.5 + 1));
|
|
5732
5734
|
return console.log(`[ParallelBVH] Parallel build: ${i.toLocaleString()} triangles, ${a} workers, parallelDepth=${o}`), new Promise((s, c) => {
|
|
5733
5735
|
(async () => {
|
|
5734
5736
|
let c = new SharedArrayBuffer(e.byteLength);
|
|
5735
5737
|
new Float32Array(c).set(e);
|
|
5736
|
-
let l = new SharedArrayBuffer(i * 3 * 4), u = new SharedArrayBuffer(i * 3 * 4), d = new SharedArrayBuffer(i * 3 * 4), f = new SharedArrayBuffer(i * 4), p = new SharedArrayBuffer(i * 4), m = new SharedArrayBuffer(i *
|
|
5738
|
+
let l = new SharedArrayBuffer(i * 3 * 4), u = new SharedArrayBuffer(i * 3 * 4), d = new SharedArrayBuffer(i * 3 * 4), f = new SharedArrayBuffer(i * 4), p = new SharedArrayBuffer(i * 4), m = new SharedArrayBuffer(i * Gs * 4), h;
|
|
5737
5739
|
try {
|
|
5738
|
-
h = new Worker(
|
|
5740
|
+
h = new Worker(Ns, { type: "module" });
|
|
5739
5741
|
} catch (e) {
|
|
5740
5742
|
if (e.name !== "SecurityError") throw e;
|
|
5741
|
-
h = await or(
|
|
5743
|
+
h = await or(Ns);
|
|
5742
5744
|
}
|
|
5743
5745
|
let g = null, _ = [h], v = { id: null }, y = !1, b = () => {
|
|
5744
5746
|
v.id &&= (clearTimeout(v.id), null);
|
|
@@ -5749,7 +5751,7 @@ function qs(e, t, n, r) {
|
|
|
5749
5751
|
if (y) return;
|
|
5750
5752
|
y = !0, console.warn(`[ParallelBVH] Parallel build failed (${e}), falling back to single worker`), b();
|
|
5751
5753
|
let i = new ArrayBuffer(c.byteLength);
|
|
5752
|
-
new Float32Array(i).set(new Float32Array(c)), s(
|
|
5754
|
+
new Float32Array(i).set(new Float32Array(c)), s(Xs(new Float32Array(i), t, n, r));
|
|
5753
5755
|
};
|
|
5754
5756
|
h.onerror = (e) => {
|
|
5755
5757
|
x(`coordinator error: ${e.message}`);
|
|
@@ -5764,7 +5766,7 @@ function qs(e, t, n, r) {
|
|
|
5764
5766
|
return;
|
|
5765
5767
|
}
|
|
5766
5768
|
if (t.type === "phase1Result") {
|
|
5767
|
-
g = t.splitStats,
|
|
5769
|
+
g = t.splitStats, Ys(t, a, c, l, u, d, f, m, i, n, h, _, b, x, s, v, r).catch((e) => x(e.message));
|
|
5768
5770
|
return;
|
|
5769
5771
|
}
|
|
5770
5772
|
if (t.type === "assembleResult") {
|
|
@@ -5798,7 +5800,7 @@ function qs(e, t, n, r) {
|
|
|
5798
5800
|
});
|
|
5799
5801
|
});
|
|
5800
5802
|
}
|
|
5801
|
-
async function
|
|
5803
|
+
async function Ys(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g) {
|
|
5802
5804
|
let { topFlatData: _, topNodeCount: v, frontierTasks: y, frontierMap: b } = e;
|
|
5803
5805
|
if (!y || y.length === 0) {
|
|
5804
5806
|
console.log("[ParallelBVH] No frontier tasks, assembling with top-level tree only"), u.postMessage({
|
|
@@ -5847,10 +5849,10 @@ async function Js(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g) {
|
|
|
5847
5849
|
if (t.length === 0) continue;
|
|
5848
5850
|
let s;
|
|
5849
5851
|
try {
|
|
5850
|
-
s = new Worker(
|
|
5852
|
+
s = new Worker(Ws, { type: "module" });
|
|
5851
5853
|
} catch (e) {
|
|
5852
5854
|
if (e.name !== "SecurityError") throw e;
|
|
5853
|
-
s = await or(
|
|
5855
|
+
s = await or(Ws);
|
|
5854
5856
|
}
|
|
5855
5857
|
d.push(s), s.onerror = (e) => {
|
|
5856
5858
|
p(`subtree worker error: ${e.message}`);
|
|
@@ -5901,17 +5903,17 @@ async function Js(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g) {
|
|
|
5901
5903
|
});
|
|
5902
5904
|
}
|
|
5903
5905
|
}
|
|
5904
|
-
function
|
|
5906
|
+
function Xs(e, t, n, r) {
|
|
5905
5907
|
return new Promise((i, a) => {
|
|
5906
5908
|
(async () => {
|
|
5907
5909
|
let o;
|
|
5908
5910
|
try {
|
|
5909
|
-
o = new Worker(
|
|
5911
|
+
o = new Worker(Ns, { type: "module" });
|
|
5910
5912
|
} catch (e) {
|
|
5911
5913
|
if (e.name !== "SecurityError") throw e;
|
|
5912
|
-
o = await or(
|
|
5914
|
+
o = await or(Ns);
|
|
5913
5915
|
}
|
|
5914
|
-
let s = e.byteLength / (
|
|
5916
|
+
let s = e.byteLength / (Gs * 4), c = typeof SharedArrayBuffer < "u" ? new SharedArrayBuffer(s * Gs * 4) : null;
|
|
5915
5917
|
o.onmessage = (e) => {
|
|
5916
5918
|
let { bvhData: t, triangles: r, originalToBvh: s, error: l, progress: u, treeletStats: d } = e.data;
|
|
5917
5919
|
if (l) {
|
|
@@ -5949,16 +5951,16 @@ function Ys(e, t, n, r) {
|
|
|
5949
5951
|
});
|
|
5950
5952
|
});
|
|
5951
5953
|
}
|
|
5952
|
-
function
|
|
5953
|
-
return typeof Worker < "u" && typeof SharedArrayBuffer < "u" && e >=
|
|
5954
|
+
function Zs(e) {
|
|
5955
|
+
return typeof Worker < "u" && typeof SharedArrayBuffer < "u" && e >= Ks;
|
|
5954
5956
|
}
|
|
5955
5957
|
//#endregion
|
|
5956
5958
|
//#region src/Processor/TLASBuilder.js
|
|
5957
|
-
var
|
|
5959
|
+
var Qs = 16, $s = class {
|
|
5958
5960
|
constructor() {
|
|
5959
5961
|
this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.leftChild = null, this.rightChild = null, this.entryIndex = -1;
|
|
5960
5962
|
}
|
|
5961
|
-
},
|
|
5963
|
+
}, ec = class {
|
|
5962
5964
|
constructor() {
|
|
5963
5965
|
this._flatBuffer = null, this._flatBufferCapacity = 0;
|
|
5964
5966
|
}
|
|
@@ -5976,7 +5978,7 @@ var Zs = 16, Qs = class {
|
|
|
5976
5978
|
};
|
|
5977
5979
|
}
|
|
5978
5980
|
_buildRecursive(e, t) {
|
|
5979
|
-
let n = new
|
|
5981
|
+
let n = new $s();
|
|
5980
5982
|
if (t.length === 1) {
|
|
5981
5983
|
let r = e[t[0]].worldAABB;
|
|
5982
5984
|
return n.minX = r.minX, n.minY = r.minY, n.minZ = r.minZ, n.maxX = r.maxX, n.maxY = r.maxY, n.maxZ = r.maxZ, n.entryIndex = t[0], n;
|
|
@@ -6013,12 +6015,12 @@ var Zs = 16, Qs = class {
|
|
|
6013
6015
|
let e = r.pop();
|
|
6014
6016
|
e._flatIndex = n.length, n.push(e), e.rightChild && r.push(e.rightChild), e.leftChild && r.push(e.leftChild);
|
|
6015
6017
|
}
|
|
6016
|
-
let i = n.length *
|
|
6018
|
+
let i = n.length * Qs;
|
|
6017
6019
|
i > this._flatBufferCapacity && (this._flatBuffer = new Float32Array(i), this._flatBufferCapacity = i);
|
|
6018
6020
|
let a = this._flatBuffer;
|
|
6019
6021
|
a.fill(0, 0, i);
|
|
6020
6022
|
for (let e = 0; e < n.length; e++) {
|
|
6021
|
-
let r = n[e], i = e *
|
|
6023
|
+
let r = n[e], i = e * Qs;
|
|
6022
6024
|
if (r.leftChild) {
|
|
6023
6025
|
let e = r.leftChild, t = r.rightChild;
|
|
6024
6026
|
a[i] = e.minX, a[i + 1] = e.minY, a[i + 2] = e.minZ, a[i + 3] = e._flatIndex, a[i + 4] = e.maxX, a[i + 5] = e.maxY, a[i + 6] = e.maxZ, a[i + 7] = t._flatIndex, a[i + 8] = t.minX, a[i + 9] = t.minY, a[i + 10] = t.minZ, a[i + 12] = t.maxX, a[i + 13] = t.maxY, a[i + 14] = t.maxZ;
|
|
@@ -6060,7 +6062,7 @@ var Zs = 16, Qs = class {
|
|
|
6060
6062
|
}
|
|
6061
6063
|
return t;
|
|
6062
6064
|
}
|
|
6063
|
-
},
|
|
6065
|
+
}, tc = class {
|
|
6064
6066
|
constructor() {
|
|
6065
6067
|
this.entries = [], this.totalBLASNodes = 0, this.tlasNodeCount = 0;
|
|
6066
6068
|
}
|
|
@@ -6137,7 +6139,7 @@ var Zs = 16, Qs = class {
|
|
|
6137
6139
|
clear() {
|
|
6138
6140
|
this.entries = [], this.totalBLASNodes = 0, this.tlasNodeCount = 0;
|
|
6139
6141
|
}
|
|
6140
|
-
},
|
|
6142
|
+
}, nc = "" + new URL("assets/TexturesWorker-DBqGmVdR.js", import.meta.url).href, rc = class {
|
|
6141
6143
|
constructor() {
|
|
6142
6144
|
this.canvasContextPairs = [], this.maxPoolSize = qn.CANVAS_POOL_SIZE;
|
|
6143
6145
|
}
|
|
@@ -6177,7 +6179,7 @@ var Zs = 16, Qs = class {
|
|
|
6177
6179
|
dispose() {
|
|
6178
6180
|
this.canvasContextPairs = [];
|
|
6179
6181
|
}
|
|
6180
|
-
},
|
|
6182
|
+
}, ic = class {
|
|
6181
6183
|
constructor(e = {}) {
|
|
6182
6184
|
this.pools = /* @__PURE__ */ new Map(), this.memoryUsage = 0, this.maxMemoryUsage = e.maxMemory || Zn.MAX_BUFFER_MEMORY, this.allocatedBuffers = /* @__PURE__ */ new WeakMap(), this.sizeStrategy = e.sizeStrategy || "adaptive";
|
|
6183
6185
|
}
|
|
@@ -6235,7 +6237,7 @@ var Zs = 16, Qs = class {
|
|
|
6235
6237
|
let e = this.getMemoryStats();
|
|
6236
6238
|
return e.utilizationPercentage > 90 ? (console.warn(`Memory pool critical: ${e.utilizationPercentage.toFixed(1)}% used (${(e.currentUsage / (1024 * 1024)).toFixed(1)}MB / ${(e.maxUsage / (1024 * 1024)).toFixed(1)}MB)`), "critical") : e.utilizationPercentage > 70 ? (console.warn(`Memory pool high: ${e.utilizationPercentage.toFixed(1)}% used (${(e.currentUsage / (1024 * 1024)).toFixed(1)}MB / ${(e.maxUsage / (1024 * 1024)).toFixed(1)}MB)`), "high") : "normal";
|
|
6237
6239
|
}
|
|
6238
|
-
},
|
|
6240
|
+
}, ac = class {
|
|
6239
6241
|
constructor(e = qn.CACHE_SIZE_LIMIT) {
|
|
6240
6242
|
this.cache = /* @__PURE__ */ new Map(), this.accessOrder = [], this.maxSize = e;
|
|
6241
6243
|
}
|
|
@@ -6272,12 +6274,12 @@ var Zs = 16, Qs = class {
|
|
|
6272
6274
|
e && e.dispose && e.dispose();
|
|
6273
6275
|
}), this.cache.clear(), this.accessOrder = [];
|
|
6274
6276
|
}
|
|
6275
|
-
},
|
|
6277
|
+
}, oc = class {
|
|
6276
6278
|
constructor(e = {}) {
|
|
6277
|
-
this.useWorkers = typeof Worker < "u", this.maxConcurrentWorkers = qn.MAX_CONCURRENT_WORKERS, this.activeWorkers = 0, this.canvasPool = new
|
|
6279
|
+
this.useWorkers = typeof Worker < "u", this.maxConcurrentWorkers = qn.MAX_CONCURRENT_WORKERS, this.activeWorkers = 0, this.canvasPool = new rc(), this.bufferPool = new ic({
|
|
6278
6280
|
maxMemory: e.maxBufferMemory || Zn.MAX_BUFFER_MEMORY,
|
|
6279
6281
|
sizeStrategy: e.bufferSizeStrategy || "adaptive"
|
|
6280
|
-
}), this.textureCache = new
|
|
6282
|
+
}), this.textureCache = new ac(), this.capabilities = this.detectCapabilities(), this.optimalMethod = this.selectOptimalMethod();
|
|
6281
6283
|
}
|
|
6282
6284
|
detectCapabilities() {
|
|
6283
6285
|
return {
|
|
@@ -6334,10 +6336,10 @@ var Zs = 16, Qs = class {
|
|
|
6334
6336
|
try {
|
|
6335
6337
|
let t;
|
|
6336
6338
|
try {
|
|
6337
|
-
t = new Worker(
|
|
6339
|
+
t = new Worker(nc, { type: "module" });
|
|
6338
6340
|
} catch (e) {
|
|
6339
6341
|
if (e.name !== "SecurityError") throw e;
|
|
6340
|
-
t = await or(
|
|
6342
|
+
t = await or(nc);
|
|
6341
6343
|
}
|
|
6342
6344
|
let n = await this.prepareTexturesForWorkerDirect(e), r = await new Promise((e, r) => {
|
|
6343
6345
|
t.onmessage = (t) => {
|
|
@@ -6604,7 +6606,7 @@ var Zs = 16, Qs = class {
|
|
|
6604
6606
|
let l = performance.now();
|
|
6605
6607
|
try {
|
|
6606
6608
|
if (!t || t.length === 0) throw Error("No materials provided for texture creation");
|
|
6607
|
-
this.textureCache.dispose(), this.textureCache = new
|
|
6609
|
+
this.textureCache.dispose(), this.textureCache = new ac();
|
|
6608
6610
|
let e = [];
|
|
6609
6611
|
n && n.length > 0 && e.push(this.createTexturesToDataTexture(n).then((e) => ({
|
|
6610
6612
|
type: "albedo",
|
|
@@ -6716,7 +6718,7 @@ var Zs = 16, Qs = class {
|
|
|
6716
6718
|
t.push(null), r.push({
|
|
6717
6719
|
index: i,
|
|
6718
6720
|
flipY: n.flipY,
|
|
6719
|
-
promise:
|
|
6721
|
+
promise: sc(e.data, e.width, e.height)
|
|
6720
6722
|
});
|
|
6721
6723
|
continue;
|
|
6722
6724
|
}
|
|
@@ -6729,7 +6731,7 @@ var Zs = 16, Qs = class {
|
|
|
6729
6731
|
t.push(null), r.push({
|
|
6730
6732
|
index: e,
|
|
6731
6733
|
flipY: n.flipY,
|
|
6732
|
-
promise:
|
|
6734
|
+
promise: sc(n.image.data, n.image.width, n.image.height)
|
|
6733
6735
|
});
|
|
6734
6736
|
continue;
|
|
6735
6737
|
}
|
|
@@ -6781,13 +6783,13 @@ var Zs = 16, Qs = class {
|
|
|
6781
6783
|
this.canvasPool.dispose(), this.bufferPool.dispose(), this.textureCache.dispose();
|
|
6782
6784
|
}
|
|
6783
6785
|
};
|
|
6784
|
-
function
|
|
6786
|
+
function sc(e, t, n) {
|
|
6785
6787
|
let r = new Uint8ClampedArray(e.buffer, e.byteOffset, e.byteLength);
|
|
6786
6788
|
return createImageBitmap(new ImageData(r, t, n));
|
|
6787
6789
|
}
|
|
6788
6790
|
//#endregion
|
|
6789
6791
|
//#region src/Processor/GeometryExtractor.js
|
|
6790
|
-
var
|
|
6792
|
+
var cc = 128, lc = class {
|
|
6791
6793
|
constructor() {
|
|
6792
6794
|
this._vectorPool = {
|
|
6793
6795
|
vec3: Array(9).fill().map(() => new Nt()),
|
|
@@ -7002,7 +7004,7 @@ var sc = 128, cc = class {
|
|
|
7002
7004
|
n || (n = /* @__PURE__ */ new Map(), this._textureIndexCache.set(t, n));
|
|
7003
7005
|
let r = e.source.uuid, i = n.get(r);
|
|
7004
7006
|
if (i !== void 0) return i;
|
|
7005
|
-
if (t.length <
|
|
7007
|
+
if (t.length < cc) {
|
|
7006
7008
|
t.push(e);
|
|
7007
7009
|
let i = t.length - 1;
|
|
7008
7010
|
return n.set(r, i), i;
|
|
@@ -7091,7 +7093,7 @@ var sc = 128, cc = class {
|
|
|
7091
7093
|
sceneFeatures: this.sceneFeatures
|
|
7092
7094
|
};
|
|
7093
7095
|
}
|
|
7094
|
-
},
|
|
7096
|
+
}, uc = class {
|
|
7095
7097
|
constructor() {
|
|
7096
7098
|
this.maxLeafSize = 8;
|
|
7097
7099
|
}
|
|
@@ -7150,7 +7152,7 @@ var sc = 128, cc = class {
|
|
|
7150
7152
|
l < i ? n = l + 1 : r = l;
|
|
7151
7153
|
}
|
|
7152
7154
|
}
|
|
7153
|
-
},
|
|
7155
|
+
}, dc = class {
|
|
7154
7156
|
constructor() {
|
|
7155
7157
|
this.emissiveTriangles = [], this.emissiveCount = 0, this.totalEmissivePower = 0, this.emissiveIndicesArray = null, this.emissivePowerArray = null, this.cdfArray = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0;
|
|
7156
7158
|
}
|
|
@@ -7294,7 +7296,7 @@ var sc = 128, cc = class {
|
|
|
7294
7296
|
}
|
|
7295
7297
|
buildLightBVH() {
|
|
7296
7298
|
if (this.emissiveCount === 0) return this.lightBVHNodeData = new Float32Array(16), this.lightBVHNodeData[7] = 1, this.lightBVHNodeCount = 1, 1;
|
|
7297
|
-
let { nodeData: e, nodeCount: t, sortedPerm: n } = new
|
|
7299
|
+
let { nodeData: e, nodeCount: t, sortedPerm: n } = new uc().build(this.emissiveTriangles);
|
|
7298
7300
|
return this.lightBVHNodeData = e, this.lightBVHNodeCount = t, this._rebuildSortedEmissiveData(n), t;
|
|
7299
7301
|
}
|
|
7300
7302
|
_rebuildSortedEmissiveData(e) {
|
|
@@ -7315,7 +7317,7 @@ var sc = 128, cc = class {
|
|
|
7315
7317
|
clear() {
|
|
7316
7318
|
this.emissiveTriangles = [], this.emissiveCount = 0, this.totalEmissivePower = 0, this.emissiveIndicesArray = null, this.emissivePowerArray = null, this.cdfArray = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0;
|
|
7317
7319
|
}
|
|
7318
|
-
},
|
|
7320
|
+
}, fc = "" + new URL("assets/BVHRefitWorker-GkmNJYvb.js", import.meta.url).href, pc = class {
|
|
7319
7321
|
constructor(e = {}) {
|
|
7320
7322
|
this.config = {
|
|
7321
7323
|
useWorkers: !0,
|
|
@@ -7338,12 +7340,12 @@ var sc = 128, cc = class {
|
|
|
7338
7340
|
};
|
|
7339
7341
|
}
|
|
7340
7342
|
_initProcessors() {
|
|
7341
|
-
this.geometryExtractor = new
|
|
7343
|
+
this.geometryExtractor = new lc(), this.bvhBuilder = new Ls(), this.bvhBuilder.maxLeafSize = this.config.maxLeafSize, this.bvhBuilder.setTreeletConfig({
|
|
7342
7344
|
enabled: this.config.enableTreeletOptimization,
|
|
7343
7345
|
size: this.config.treeletSize,
|
|
7344
7346
|
passes: this.config.treeletOptimizationPasses,
|
|
7345
7347
|
minImprovement: this.config.treeletMinImprovement
|
|
7346
|
-
}), this.textureCreator = new
|
|
7348
|
+
}), this.textureCreator = new oc(), this.emissiveTriangleBuilder = new dc(), this.tlasBuilder = new ec();
|
|
7347
7349
|
}
|
|
7348
7350
|
_log(e, t) {
|
|
7349
7351
|
this.config.verbose && console.log(`[SceneProcessor] ${e}`, t || "");
|
|
@@ -7351,7 +7353,7 @@ var sc = 128, cc = class {
|
|
|
7351
7353
|
async buildBVH(e) {
|
|
7352
7354
|
if (this.isProcessing) throw Error("Already processing a scene. Call dispose() first.");
|
|
7353
7355
|
this.isProcessing = !0, this.processingStage = "init";
|
|
7354
|
-
let t = new
|
|
7356
|
+
let t = new Ds(`SceneProcessor (${e.name || "scene"})`);
|
|
7355
7357
|
try {
|
|
7356
7358
|
this._reset(), this._log("Starting scene processing"), this.processingStage = "extraction", t.start("Geometry extraction"), await this._extractGeometry(e), t.end("Geometry extraction"), this.performanceMetrics.geometryExtractionTime = t.getDuration("Geometry extraction"), this.processingStage = "bvh", t.start("BVH construction (worker)"), t.start("Material textures (parallel)");
|
|
7357
7359
|
let n = !1, r = this._buildBVH().then(() => t.end("BVH construction (worker)")), i = this._createMaterialTextures().then(() => {
|
|
@@ -7412,11 +7414,11 @@ var sc = 128, cc = class {
|
|
|
7412
7414
|
try {
|
|
7413
7415
|
let t = Z.FLOATS_PER_TRIANGLE, n = this.meshTriangleRanges;
|
|
7414
7416
|
if (!n || n.length === 0) throw Error("No mesh triangle ranges available for TLAS/BLAS build");
|
|
7415
|
-
this.instanceTable = new
|
|
7417
|
+
this.instanceTable = new tc(), this.instanceTable.allocate(n.length);
|
|
7416
7418
|
let r = n.length, i = this.config.enableTreeletOptimization, a = [], o = [];
|
|
7417
7419
|
for (let e = 0; e < r; e++) {
|
|
7418
7420
|
let t = n[e];
|
|
7419
|
-
t.count !== 0 && (t.count >= 2e5 &&
|
|
7421
|
+
t.count !== 0 && (t.count >= 2e5 && Zs(t.count) ? o.push({
|
|
7420
7422
|
m: e,
|
|
7421
7423
|
range: t
|
|
7422
7424
|
}) : a.push({
|
|
@@ -7442,7 +7444,7 @@ var sc = 128, cc = class {
|
|
|
7442
7444
|
status: `Building BLAS ${e + o.length}/${c}...`,
|
|
7443
7445
|
progress: 25 + Math.floor(e / c * 45)
|
|
7444
7446
|
});
|
|
7445
|
-
}), u = o.map(({ m: e, range: n }) =>
|
|
7447
|
+
}), u = o.map(({ m: e, range: n }) => Js(this.triangleData.slice(n.start * t, (n.start + n.count) * t), this.config.bvhDepth, null, {
|
|
7446
7448
|
maxLeafSize: this.bvhBuilder.maxLeafSize,
|
|
7447
7449
|
numBins: this.bvhBuilder.numBins,
|
|
7448
7450
|
maxBins: this.bvhBuilder.maxBins,
|
|
@@ -7548,13 +7550,13 @@ var sc = 128, cc = class {
|
|
|
7548
7550
|
for (let e = 0; e < i; e++) {
|
|
7549
7551
|
let e;
|
|
7550
7552
|
try {
|
|
7551
|
-
e = new Worker(
|
|
7553
|
+
e = new Worker(Ns, { type: "module" });
|
|
7552
7554
|
} catch (t) {
|
|
7553
7555
|
if (t.name !== "SecurityError") {
|
|
7554
7556
|
l(t);
|
|
7555
7557
|
return;
|
|
7556
7558
|
}
|
|
7557
|
-
e = await or(
|
|
7559
|
+
e = await or(Ns);
|
|
7558
7560
|
}
|
|
7559
7561
|
e.onmessage = (t) => f(e, t), e.onerror = (e) => {
|
|
7560
7562
|
u.forEach((e) => e.terminate()), l(e);
|
|
@@ -7727,10 +7729,10 @@ var sc = 128, cc = class {
|
|
|
7727
7729
|
async refitBVH(e, t) {
|
|
7728
7730
|
if (!this.bvhData || !this.triangleData || !this.originalToBvhMap) throw Error("No BVH data available for refit. Run buildBVH() first.");
|
|
7729
7731
|
if (!this._refitWorker) try {
|
|
7730
|
-
this._refitWorker = new Worker(
|
|
7732
|
+
this._refitWorker = new Worker(fc, { type: "module" });
|
|
7731
7733
|
} catch (e) {
|
|
7732
7734
|
if (e.name !== "SecurityError") throw e;
|
|
7733
|
-
this._refitWorker = await or(
|
|
7735
|
+
this._refitWorker = await or(fc);
|
|
7734
7736
|
}
|
|
7735
7737
|
if (!this._refitSharedBuffers) {
|
|
7736
7738
|
let t = new SharedArrayBuffer(this.bvhData.byteLength), n = new SharedArrayBuffer(this.triangleData.byteLength), r = new SharedArrayBuffer(e.byteLength), i = new Float32Array(t), a = new Float32Array(n);
|
|
@@ -7763,7 +7765,7 @@ var sc = 128, cc = class {
|
|
|
7763
7765
|
refitBLASes(e, t, n) {
|
|
7764
7766
|
if (!this.instanceTable || !this.bvhData || !this.triangleData) throw Error("No TLAS/BLAS data available. Run buildBVH() first.");
|
|
7765
7767
|
let r = performance.now();
|
|
7766
|
-
this._blasRefitter ||= new
|
|
7768
|
+
this._blasRefitter ||= new Us();
|
|
7767
7769
|
for (let r of e) {
|
|
7768
7770
|
let e = this.instanceTable.entries[r];
|
|
7769
7771
|
e && (this._updateMeshTrianglePositions(e, t), n && this._patchMeshSmoothNormals(e, n), this._blasRefitter.refitRange(this.bvhData, this.triangleData, e.blasOffset, e.blasNodeCount), this.instanceTable.recomputeAABB(r, this.bvhData, this.triangleData));
|
|
@@ -7894,10 +7896,10 @@ var sc = 128, cc = class {
|
|
|
7894
7896
|
n && n.terminate();
|
|
7895
7897
|
let r;
|
|
7896
7898
|
try {
|
|
7897
|
-
r = new Worker(
|
|
7899
|
+
r = new Worker(Ns, { type: "module" }), i(t, e, r);
|
|
7898
7900
|
} catch (n) {
|
|
7899
7901
|
if (n.name !== "SecurityError") throw n;
|
|
7900
|
-
or(
|
|
7902
|
+
or(Ns).then((n) => i(t, e, n));
|
|
7901
7903
|
}
|
|
7902
7904
|
}
|
|
7903
7905
|
}
|
|
@@ -7930,7 +7932,7 @@ var sc = 128, cc = class {
|
|
|
7930
7932
|
dispose() {
|
|
7931
7933
|
this._log("Disposing resources"), this._disposeRefitWorker(), this._disposeTextures(), this._reset(), this.textureCreator &&= (this.textureCreator.dispose(), null), this.geometryExtractor = null, this.bvhBuilder = null, this.tlasBuilder = null, this._blasRefitter = null;
|
|
7932
7934
|
}
|
|
7933
|
-
},
|
|
7935
|
+
}, mc = class {
|
|
7934
7936
|
constructor() {
|
|
7935
7937
|
this.lightData = {
|
|
7936
7938
|
directional: [],
|
|
@@ -8093,7 +8095,7 @@ var sc = 128, cc = class {
|
|
|
8093
8095
|
}))
|
|
8094
8096
|
};
|
|
8095
8097
|
}
|
|
8096
|
-
},
|
|
8098
|
+
}, hc = {
|
|
8097
8099
|
stbnScalarAtlas: "https://assets.rayzee.atulmourya.com/noise/stbn_scalar_atlas.png",
|
|
8098
8100
|
stbnVec2Atlas: "https://assets.rayzee.atulmourya.com/noise/stbn_vec2_atlas.png",
|
|
8099
8101
|
ortRuntimeUrl: "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/ort.webgpu.bundle.min.mjs",
|
|
@@ -8104,27 +8106,27 @@ var sc = 128, cc = class {
|
|
|
8104
8106
|
upscalerModelBaseUrl: "https://huggingface.co/notaneimu/onnx-image-models/resolve/main/",
|
|
8105
8107
|
cacheNamespace: "rayzee"
|
|
8106
8108
|
};
|
|
8107
|
-
function
|
|
8108
|
-
e && Object.assign(
|
|
8109
|
+
function gc(e) {
|
|
8110
|
+
e && Object.assign(hc, e);
|
|
8109
8111
|
}
|
|
8110
|
-
function
|
|
8111
|
-
return { ...
|
|
8112
|
+
function _c() {
|
|
8113
|
+
return { ...hc };
|
|
8112
8114
|
}
|
|
8113
8115
|
//#endregion
|
|
8114
8116
|
//#region src/Stages/PathTracer.js
|
|
8115
|
-
var
|
|
8117
|
+
var vc = 4, yc = class extends Sn {
|
|
8116
8118
|
constructor(e, t, n, r = {}) {
|
|
8117
8119
|
super("PathTracer", {
|
|
8118
8120
|
...r,
|
|
8119
8121
|
executionMode: xn.ALWAYS
|
|
8120
8122
|
});
|
|
8121
8123
|
let i = r.width || 1920, a = r.height || 1080;
|
|
8122
|
-
this.camera = n, this.width = i, this.height = a, this.renderer = e, this.scene = t, this.tileManager = new Cn(i, a, X.tiles), this.sdfs = new
|
|
8124
|
+
this.camera = n, this.width = i, this.height = a, this.renderer = e, this.scene = t, this.tileManager = new Cn(i, a, X.tiles), this.sdfs = new pc(), this.lightSerializer = new mc(), this.accumulationEnabled = !0, this.isComplete = !1, this.cameras = [], this.performanceMonitor = Ln(), this.completionThreshold = 0, this.renderLimitMode = "frames", this._initDataTextures(), this.storageTextures = new zn(0, 0), this.uniforms = new $n(i, a), this._defineUniformGetters(), this.materialData = new ar(this.sdfs), this.materialData.callbacks.onReset = () => this.reset(), this.materialData.callbacks.getTriangleData = () => ({
|
|
8123
8125
|
array: this.triangleStorageAttr?.array,
|
|
8124
8126
|
count: this.triangleCount
|
|
8125
8127
|
}), this.materialData.callbacks.onTriangleDataChanged = () => {
|
|
8126
8128
|
this.triangleStorageAttr && (this.triangleStorageAttr.needsUpdate = !0);
|
|
8127
|
-
}, this.environment = new Ir(this.scene, this.uniforms), this.environment.callbacks.onReset = () => this.reset(), this.environment.callbacks.getSceneTextureNodes = () => this.shaderBuilder.getSceneTextureNodes(), this.shaderBuilder = new
|
|
8129
|
+
}, this.environment = new Ir(this.scene, this.uniforms), this.environment.callbacks.onReset = () => this.reset(), this.environment.callbacks.getSceneTextureNodes = () => this.shaderBuilder.getSceneTextureNodes(), this.shaderBuilder = new ks(), this._initRenderingState(), this.setupBlueNoise(), this.tempVector2 = new Mt(), this.lastCameraMatrix = new at(), this.lastProjectionMatrix = new at(), this.lastRenderMode = -1, this.tileCompletionFrame = 0, this.renderModeChangeTimeout = null, this.renderModeChangeDelay = 50, this.pendingRenderMode = null, this.adaptiveSamplingFrameToggle = !1, this.lastInteractionModeState = !1, this.cameraChanged = !1, this.tileChanged = !1, this.updateCompletionThreshold();
|
|
8128
8130
|
}
|
|
8129
8131
|
_initDataTextures() {
|
|
8130
8132
|
this.triangleStorageAttr = null, this.triangleStorageNode = null, this.triangleCount = 0, this.bvhStorageAttr = null, this.bvhStorageNode = null, this.bvhNodeCount = 0, this.directionalLightsData = null, this.pointLightsData = null, this.spotLightsData = null, this.areaLightsData = null, this.goboMaps = null, this.iesProfiles = null, this.stbnScalarTexture = null, this.stbnVec2Texture = null, this.lightStorageAttr = new o(new Float32Array(16), 4), this.lightStorageNode = ye(this.lightStorageAttr, "vec4", 1).toReadOnly(), this._lbvhDataCache = null, this._emissiveDataCache = null, this._instanceTable = null, this.adaptiveSamplingTexture = null, this.spheres = [];
|
|
@@ -8221,7 +8223,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
8221
8223
|
setupBlueNoise() {
|
|
8222
8224
|
let e = new kt();
|
|
8223
8225
|
e.setCrossOrigin("anonymous");
|
|
8224
|
-
let t = (e) => (e.minFilter = J, e.magFilter = J, e.wrapS = Ct, e.wrapT = Ct, e.generateMipmaps = !1, e), { stbnScalarAtlas: n, stbnVec2Atlas: r } =
|
|
8226
|
+
let t = (e) => (e.minFilter = J, e.magFilter = J, e.wrapS = Ct, e.wrapT = Ct, e.generateMipmaps = !1, e), { stbnScalarAtlas: n, stbnVec2Atlas: r } = _c();
|
|
8225
8227
|
e.load(n, (e) => {
|
|
8226
8228
|
this.stbnScalarTexture = t(e), nn.value = e, console.log(`PathTracer: STBN scalar atlas loaded ${e.image.width}x${e.image.height}`);
|
|
8227
8229
|
}), e.load(r, (e) => {
|
|
@@ -8307,7 +8309,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
8307
8309
|
setBVHData(e) {
|
|
8308
8310
|
if (!e) return;
|
|
8309
8311
|
let t = e.length / 4;
|
|
8310
|
-
this.bvhStorageNode ? (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode.value = this.bvhStorageAttr, this.bvhStorageNode.bufferCount = t) : (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode = ye(this.bvhStorageAttr, "vec4", t).toReadOnly()), this.bvhNodeCount = Math.floor(t /
|
|
8312
|
+
this.bvhStorageNode ? (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode.value = this.bvhStorageAttr, this.bvhStorageNode.bufferCount = t) : (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode = ye(this.bvhStorageAttr, "vec4", t).toReadOnly()), this.bvhNodeCount = Math.floor(t / vc), console.log(`PathTracer: ${this.bvhNodeCount} BVH nodes (storage buffer)`);
|
|
8311
8313
|
}
|
|
8312
8314
|
setInstanceTable(e) {
|
|
8313
8315
|
this._instanceTable = e;
|
|
@@ -8506,7 +8508,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
8506
8508
|
dispose() {
|
|
8507
8509
|
this.renderModeChangeTimeout &&= (clearTimeout(this.renderModeChangeTimeout), null), this.tileManager?.dispose(), this.cameraOptimizer?.dispose(), this.materialData?.dispose(), this.environment?.dispose(), this.shaderBuilder?.dispose(), this.uniforms?.dispose(), this.storageTextures?.dispose(), this.stbnScalarTexture?.dispose(), this.stbnVec2Texture?.dispose(), this.placeholderTexture?.dispose(), this.triangleStorageAttr = null, this.triangleStorageNode = null, this.bvhStorageAttr = null, this.bvhStorageNode = null, this.placeholderTexture = null, this.isReady = !1;
|
|
8508
8510
|
}
|
|
8509
|
-
},
|
|
8511
|
+
}, bc = class extends Sn {
|
|
8510
8512
|
constructor(e, t = {}) {
|
|
8511
8513
|
super("NormalDepth", {
|
|
8512
8514
|
...t,
|
|
@@ -8584,7 +8586,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
8584
8586
|
dispose() {
|
|
8585
8587
|
this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this.renderTarget?.dispose();
|
|
8586
8588
|
}
|
|
8587
|
-
},
|
|
8589
|
+
}, xc = class extends Sn {
|
|
8588
8590
|
constructor(e, t, n = {}) {
|
|
8589
8591
|
super("MotionVector", {
|
|
8590
8592
|
...n,
|
|
@@ -8693,7 +8695,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
8693
8695
|
dispose() {
|
|
8694
8696
|
this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose(), this.screenSpaceTarget?.dispose(), this.worldSpaceTarget?.dispose(), this._normalDepthTexNode?.dispose();
|
|
8695
8697
|
}
|
|
8696
|
-
},
|
|
8698
|
+
}, Sc = class extends Sn {
|
|
8697
8699
|
constructor(e, t = {}) {
|
|
8698
8700
|
super("ASVGF", {
|
|
8699
8701
|
...t,
|
|
@@ -8867,7 +8869,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
8867
8869
|
dispose() {
|
|
8868
8870
|
this._gradientNode?.dispose(), this._temporalNodeA?.dispose(), this._temporalNodeB?.dispose(), this._temporalTexA?.dispose(), this._temporalTexB?.dispose(), this._gradientStorageTex?.dispose(), this._heatmapComputeNode?.dispose(), this._heatmapStorageTex?.dispose(), this.heatmapTarget?.dispose(), this._colorTexNode?.dispose(), this._motionTexNode?.dispose(), this._readTemporalTexNode?.dispose(), this._heatmapRawColorTexNode?.dispose(), this._heatmapColorTexNode?.dispose(), this._heatmapTemporalTexNode?.dispose(), this._heatmapNDTexNode?.dispose(), this._heatmapMotionTexNode?.dispose(), this._heatmapGradientTexNode?.dispose();
|
|
8869
8871
|
}
|
|
8870
|
-
},
|
|
8872
|
+
}, Cc = /* @__PURE__ */ G("\n fn temporalAccumulate(\n lum: f32,\n prevMean: f32,\n prevMeanSq: f32,\n alpha: f32,\n spatialVariance: f32,\n varianceBoost: f32\n ) -> vec4f {\n\n let newMean = prevMean + ( lum - prevMean ) * alpha;\n let newMeanSq = prevMeanSq + ( lum * lum - prevMeanSq ) * alpha;\n let temporalVariance = max( newMeanSq - newMean * newMean, 0.0 );\n\n return vec4f(\n newMean,\n newMeanSq,\n temporalVariance * varianceBoost,\n spatialVariance * varianceBoost\n );\n\n }\n"), wc = class extends Sn {
|
|
8871
8873
|
constructor(e, t = {}) {
|
|
8872
8874
|
super("VarianceEstimation", {
|
|
8873
8875
|
...t,
|
|
@@ -8899,7 +8901,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
8899
8901
|
}
|
|
8900
8902
|
n.divAssign(9), a.divAssign(9);
|
|
8901
8903
|
let o = F(a.sub(n.mul(n)), j(0)), u = s.element(l.add(1).mul(10).add(c.add(1))), d = z(t, N(_, v));
|
|
8902
|
-
Ce(e, Ee(B(_), B(v)),
|
|
8904
|
+
Ce(e, Ee(B(_), B(v)), Cc(u, d.x, d.y, r, o, i)).toWriteOnly();
|
|
8903
8905
|
});
|
|
8904
8906
|
})().compute([
|
|
8905
8907
|
this._dispatchX,
|
|
@@ -8942,7 +8944,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
8942
8944
|
dispose() {
|
|
8943
8945
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._colorTexNode?.dispose(), this._readTexNodeA?.dispose(), this._readTexNodeB?.dispose();
|
|
8944
8946
|
}
|
|
8945
|
-
},
|
|
8947
|
+
}, Tc = /* @__PURE__ */ G("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n phiLum: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) * phiLum );\n // clamp dot to [0,1] not just max(., 0): miss-ray normals decode to\n // non-unit (-1,-1,-1) with dot=3, which would saturate pow to +inf\n // and poison output via inf*0 = NaN. See project_tsl_pitfalls memory.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), phiNorm );\n let depW = exp( -abs( centerDepth - sDepth ) / max( phiDep, 0.001 ) );\n let maxDiff = max( max( abs( centerColor.x - sColor.x ),\n abs( centerColor.y - sColor.y ) ),\n abs( centerColor.z - sColor.z ) );\n let colW = exp( -maxDiff * phiCol );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), Ec = class extends Sn {
|
|
8946
8948
|
constructor(e, t = {}) {
|
|
8947
8949
|
super("BilateralFiltering", {
|
|
8948
8950
|
...t,
|
|
@@ -8987,7 +8989,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
8987
8989
|
m(d.lessThan(M(c)).and(f.lessThan(M(l))), () => {
|
|
8988
8990
|
let p = N(d, f), m = z(t, p).xyz, h = z(n, p), g = h.xyz.mul(2).sub(1), _ = h.w, v = fi(m), y = U(0).toVar(), b = j(0).toVar();
|
|
8989
8991
|
for (let e = 0; e < 5; e++) for (let p = 0; p < 5; p++) {
|
|
8990
|
-
let h = p - 2, x = e - 2, S = u[e * 5 + p], C = d.add(s.mul(h)).clamp(M(0), M(c).sub(1)), w = f.add(s.mul(x)).clamp(M(0), M(l).sub(1)), T = z(t, N(C, w)).xyz, E = z(n, N(C, w)), D = E.xyz.mul(2).sub(1), O = E.w, ee =
|
|
8992
|
+
let h = p - 2, x = e - 2, S = u[e * 5 + p], C = d.add(s.mul(h)).clamp(M(0), M(c).sub(1)), w = f.add(s.mul(x)).clamp(M(0), M(l).sub(1)), T = z(t, N(C, w)).xyz, E = z(n, N(C, w)), D = E.xyz.mul(2).sub(1), O = E.w, ee = Tc(v, fi(T), g, D, _, O, m, T, j(S), o, i, a, r);
|
|
8991
8993
|
y.addAssign(T.mul(ee)), b.addAssign(ee);
|
|
8992
8994
|
}
|
|
8993
8995
|
let x = y.div(F(b, j(1e-4)));
|
|
@@ -9032,7 +9034,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
9032
9034
|
dispose() {
|
|
9033
9035
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._readTexNode?.dispose(), this._normalDepthTexNode?.dispose();
|
|
9034
9036
|
}
|
|
9035
|
-
},
|
|
9037
|
+
}, Dc = /* @__PURE__ */ G("\n fn computeSamplingGuidance(\n temporalVariance: f32,\n spatialVariance: f32,\n meanLuminance: f32,\n threshold: f32,\n frame: i32,\n minFrames: i32,\n convThreshold: f32,\n sensitivity: f32,\n convSpeedScale: f32\n ) -> vec4f {\n\n // The path tracer accumulates via alpha = 1/(frame+1), so temporal variance\n // of the accumulated output shrinks as ~sigma²/(frame+1)². Scale by (frame+1)\n // to get accumulated image quality ~sigma²/N — decreases as image converges.\n let frameScale = f32( frame + 1 );\n let effectiveVariance = temporalVariance * frameScale;\n\n // Normalize by luminance² — converts absolute variance to relative (CV²).\n // Floor of 0.01 prevents noise amplification for near-black pixels\n // (linear luminance < 0.1 → below perceptual visibility threshold).\n let normFactor = max( meanLuminance * meanLuminance, 0.01 );\n let normalizedVariance = effectiveVariance / normFactor;\n\n let varianceRatio = clamp( normalizedVariance / threshold, 0.0, 1.0 );\n\n // Apply sensitivity — higher values assign more samples to noisy pixels\n var normalizedSamples = clamp( varianceRatio * sensitivity, 0.0, 1.0 );\n\n // Small spatial boost for noisy neighbourhoods (un-scaled — provides\n // a minor secondary signal that naturally diminishes as image converges)\n let spatialBoost = clamp( spatialVariance / ( threshold * 4.0 ), 0.0, 0.2 );\n normalizedSamples = clamp( normalizedSamples + spatialBoost, 0.0, 1.0 );\n\n // Warm-up: variance estimates need a few frames to stabilise\n if ( frame < minFrames ) {\n\n let warmupFactor = f32( frame ) / f32( minFrames );\n normalizedSamples = mix( 1.0, normalizedSamples, warmupFactor * warmupFactor );\n\n }\n\n // Convergence: mark pixel only when per-frame noise is truly negligible.\n // convSpeedScale controls aggressiveness: higher = easier to converge\n // (scales the threshold up, so more pixels qualify as converged).\n let scaledConvThreshold = convThreshold * convSpeedScale;\n var converged = 0.0;\n if ( normalizedVariance < scaledConvThreshold && frame > minFrames ) {\n\n converged = 1.0;\n\n }\n\n return vec4f(\n normalizedSamples,\n varianceRatio,\n converged,\n 1.0\n );\n\n }\n"), Oc = /* @__PURE__ */ G("\n fn heatmapGradient( t: f32, normalizedVariance: f32, converged: f32 ) -> vec4f {\n\n let r = clamp( ( t - 0.5 ) * 4.0, 0.0, 1.0 );\n let g = clamp( t * 4.0, 0.0, 1.0 ) - clamp( ( t - 0.75 ) * 4.0, 0.0, 1.0 );\n let b = 1.0 - clamp( ( t - 0.25 ) * 4.0, 0.0, 1.0 );\n\n var color = vec3f( r, g, b );\n\n // Convergence: desaturate converged pixels\n if ( converged > 0.5 ) {\n\n let gray = color.x * 0.299 + color.y * 0.587 + color.z * 0.114;\n color = mix( color, vec3f( gray ), 0.6 );\n\n }\n\n // Brightness modulation\n color *= 0.7 + normalizedVariance * 0.3;\n\n return vec4f( color, 1.0 );\n\n }\n"), kc = class extends Sn {
|
|
9036
9038
|
constructor(e, t = {}) {
|
|
9037
9039
|
super("AdaptiveSampling", {
|
|
9038
9040
|
...t,
|
|
@@ -9056,7 +9058,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
9056
9058
|
this._computeNode = p(() => {
|
|
9057
9059
|
let u = M(ke.x).mul(16).add(M(P.x)), d = M(ke.y).mul(16).add(M(P.y));
|
|
9058
9060
|
m(u.lessThan(M(s)).and(d.lessThan(M(c))), () => {
|
|
9059
|
-
let s = z(e, N(u, d)), c =
|
|
9061
|
+
let s = z(e, N(u, d)), c = Dc(s.z, s.w, s.x, t, M(i), M(a), o, n, r);
|
|
9060
9062
|
Ce(l, Ee(B(u), B(d)), c).toWriteOnly();
|
|
9061
9063
|
});
|
|
9062
9064
|
})().compute([
|
|
@@ -9074,7 +9076,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
9074
9076
|
this._heatmapComputeNode = p(() => {
|
|
9075
9077
|
let i = M(ke.x).mul(16).add(M(P.x)), a = M(ke.y).mul(16).add(M(P.y));
|
|
9076
9078
|
m(i.lessThan(M(n)).and(a.lessThan(M(r))), () => {
|
|
9077
|
-
let n = z(e, N(i, a)), r =
|
|
9079
|
+
let n = z(e, N(i, a)), r = Oc(n.x.clamp(0, 1), n.y, n.z);
|
|
9078
9080
|
Ce(t, Ee(B(i), B(a)), r).toWriteOnly();
|
|
9079
9081
|
});
|
|
9080
9082
|
})().compute([
|
|
@@ -9133,7 +9135,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
9133
9135
|
dispose() {
|
|
9134
9136
|
this._computeNode?.dispose(), this._heatmapComputeNode?.dispose(), this._heatmapStorageTex?.dispose(), this._outputStorageTex?.dispose(), this.heatmapTarget?.dispose(), this._varianceTexNode?.dispose(), this._computeNode = null, this._heatmapComputeNode = null, this._heatmapStorageTex = null, this._outputStorageTex = null, this.heatmapTarget = null, this._varianceTexNode = null;
|
|
9135
9137
|
}
|
|
9136
|
-
},
|
|
9138
|
+
}, Ac = class extends Sn {
|
|
9137
9139
|
constructor(e, t = {}) {
|
|
9138
9140
|
super("EdgeAwareFiltering", {
|
|
9139
9141
|
...t,
|
|
@@ -9216,7 +9218,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
9216
9218
|
dispose() {
|
|
9217
9219
|
this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this.outputTarget?.dispose(), this._inputTexNode?.dispose(), this._ndTexNode?.dispose();
|
|
9218
9220
|
}
|
|
9219
|
-
},
|
|
9221
|
+
}, jc = 256, Mc = -8, Nc = 6 - Mc, Pc = Nc / jc, Fc = 1e4, Ic = /* @__PURE__ */ G("\n fn adaptExposure(\n geoMean: f32,\n prevExposure: f32,\n keyValue: f32,\n minExp: f32,\n maxExp: f32,\n speedBright: f32,\n speedDark: f32,\n dt: f32,\n isFirstFrame: f32\n ) -> vec4f {\n\n let targetExp = clamp( keyValue / max( geoMean, 0.001 ), minExp, maxExp );\n var newExposure = targetExp;\n\n // Temporal smoothing (skip on first frame)\n if ( isFirstFrame < 0.5 ) {\n\n // Asymmetric speed: brighter scenes adapt faster\n let speed = select( speedDark, speedBright, targetExp < prevExposure );\n let alpha = 1.0 - exp( -dt * speed );\n newExposure = mix( prevExposure, targetExp, alpha );\n\n }\n\n return vec4f( newExposure, geoMean, targetExp, 1.0 );\n\n }\n"), Lc = class extends Sn {
|
|
9220
9222
|
constructor(e, t = {}) {
|
|
9221
9223
|
super("AutoExposure", {
|
|
9222
9224
|
...t,
|
|
@@ -9232,7 +9234,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
9232
9234
|
depthBuffer: !1,
|
|
9233
9235
|
stencilBuffer: !1
|
|
9234
9236
|
};
|
|
9235
|
-
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = Ye, this._downsampleStorageTex.format = yt, this._downsampleStorageTex.minFilter = J, this._downsampleStorageTex.magFilter = J, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = Ye, this._reductionStorageTex.format = yt, this._reductionStorageTex.minFilter = J, this._reductionStorageTex.magFilter = J, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(
|
|
9237
|
+
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = Ye, this._downsampleStorageTex.format = yt, this._downsampleStorageTex.minFilter = J, this._downsampleStorageTex.magFilter = J, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = Ye, this._reductionStorageTex.format = yt, this._reductionStorageTex.minFilter = J, this._reductionStorageTex.magFilter = J, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(jc, "uint").toAtomic();
|
|
9236
9238
|
}
|
|
9237
9239
|
_buildCompute() {
|
|
9238
9240
|
this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
|
|
@@ -9266,7 +9268,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
9266
9268
|
for (let i = 0; i < 16; i++) {
|
|
9267
9269
|
let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = z(e, N(M(o), M(s))), l = c.x, u = c.y;
|
|
9268
9270
|
m(u.greaterThan(0), () => {
|
|
9269
|
-
let e = B(l.div(u).sub(j(
|
|
9271
|
+
let e = B(l.div(u).sub(j(Mc)).div(j(Nc)).mul(j(jc)).floor().clamp(0, j(jc - 1))), r = j(o).add(.5).div(j(64)), i = j(s).add(.5).div(j(64)), a = r.sub(.5), c = i.sub(.5), d = B(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(j(Fc)));
|
|
9270
9272
|
x(t.element(e), d);
|
|
9271
9273
|
});
|
|
9272
9274
|
}
|
|
@@ -9284,14 +9286,14 @@ var _c = 4, vc = class extends Sn {
|
|
|
9284
9286
|
let e = this._histogramBuffer, t = this._reductionStorageTex, n = this.lowPercentileU, r = this.highPercentileU;
|
|
9285
9287
|
this._histogramAnalyzeNode = p(() => {
|
|
9286
9288
|
let i = j(0).toVar();
|
|
9287
|
-
h(
|
|
9289
|
+
h(jc, ({ i: t }) => {
|
|
9288
9290
|
i.addAssign(j(S(e.element(t))));
|
|
9289
9291
|
});
|
|
9290
9292
|
let a = i.mul(n), o = i.mul(r), s = j(0).toVar(), c = j(0).toVar(), l = j(0).toVar(), u = j(0).toVar();
|
|
9291
|
-
h(
|
|
9293
|
+
h(jc, ({ i: t }) => {
|
|
9292
9294
|
let n = j(S(e.element(t)));
|
|
9293
9295
|
u.assign(s), s.addAssign(n), m(u.lessThan(o).and(s.greaterThan(a)), () => {
|
|
9294
|
-
let e = j(
|
|
9296
|
+
let e = j(Mc).add(j(t).add(.5).mul(j(Pc)));
|
|
9295
9297
|
c.addAssign(e.mul(n)), l.addAssign(n);
|
|
9296
9298
|
});
|
|
9297
9299
|
});
|
|
@@ -9306,7 +9308,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
9306
9308
|
_buildAdaptationCompute() {
|
|
9307
9309
|
let e = this._reductionReadTexNode, t = this._adaptationResult, n = this.keyValueU, r = this.minExposureU, i = this.maxExposureU, a = this.adaptSpeedBrightU, o = this.adaptSpeedDarkU, s = this.deltaTimeU, c = this.isFirstFrameU, l = this.previousExposureU;
|
|
9308
9310
|
this._adaptationComputeNode = p(() => {
|
|
9309
|
-
let u = z(e, N(M(0), M(0))).x, d =
|
|
9311
|
+
let u = z(e, N(M(0), M(0))).x, d = Ic(u, l, n, r, i, a, o, s, c);
|
|
9310
9312
|
t.element(B(0)).assign(d);
|
|
9311
9313
|
})().compute(1, [
|
|
9312
9314
|
1,
|
|
@@ -9373,7 +9375,7 @@ var _c = 4, vc = class extends Sn {
|
|
|
9373
9375
|
};
|
|
9374
9376
|
//#endregion
|
|
9375
9377
|
//#region src/TSL/SSRC.js
|
|
9376
|
-
function
|
|
9378
|
+
function Rc({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode: r, readPrevNDTexNode: i, writeCacheTex: a, writePrevNDTex: o, resW: s, resH: c, temporalAlpha: l, phiNormal: u, phiDepth: d, maxHistory: f, framesSinceReset: h }) {
|
|
9377
9379
|
return p(() => {
|
|
9378
9380
|
let p = M(ke.x).mul(8).add(M(P.x)), g = M(ke.y).mul(8).add(M(P.y));
|
|
9379
9381
|
m(p.lessThan(M(s)).and(g.lessThan(M(c))), () => {
|
|
@@ -9395,7 +9397,7 @@ function Lc({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode:
|
|
|
9395
9397
|
});
|
|
9396
9398
|
});
|
|
9397
9399
|
}
|
|
9398
|
-
function
|
|
9400
|
+
function zc({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r, resW: i, resH: a, spatialRadius: o, spatialWeight: s, phiNormal: c, phiDepth: l }) {
|
|
9399
9401
|
let u = [
|
|
9400
9402
|
[1, 0],
|
|
9401
9403
|
[-1, 0],
|
|
@@ -9421,7 +9423,7 @@ function Rc({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r,
|
|
|
9421
9423
|
}
|
|
9422
9424
|
//#endregion
|
|
9423
9425
|
//#region src/Stages/SSRC.js
|
|
9424
|
-
var
|
|
9426
|
+
var Bc = class extends Sn {
|
|
9425
9427
|
constructor(e, t = {}) {
|
|
9426
9428
|
super("SSRC", {
|
|
9427
9429
|
...t,
|
|
@@ -9496,12 +9498,12 @@ var zc = class extends Sn {
|
|
|
9496
9498
|
phiNormal: this.phiNormal,
|
|
9497
9499
|
phiDepth: this.phiDepth,
|
|
9498
9500
|
maxHistory: this.maxHistory
|
|
9499
|
-
}, t =
|
|
9501
|
+
}, t = Rc({
|
|
9500
9502
|
...e,
|
|
9501
9503
|
writeCacheTex: this._cacheTexA,
|
|
9502
9504
|
writePrevNDTex: this._prevNDTexA,
|
|
9503
9505
|
framesSinceReset: this._framesSinceReset
|
|
9504
|
-
}), n =
|
|
9506
|
+
}), n = Rc({
|
|
9505
9507
|
...e,
|
|
9506
9508
|
writeCacheTex: this._cacheTexB,
|
|
9507
9509
|
writePrevNDTex: this._prevNDTexB,
|
|
@@ -9515,7 +9517,7 @@ var zc = class extends Sn {
|
|
|
9515
9517
|
8,
|
|
9516
9518
|
1
|
|
9517
9519
|
];
|
|
9518
|
-
this._pass1NodeA = t().compute(r, i), this._pass1NodeB = n().compute(r, i), this._pass2Node =
|
|
9520
|
+
this._pass1NodeA = t().compute(r, i), this._pass1NodeB = n().compute(r, i), this._pass2Node = zc({
|
|
9519
9521
|
colorTexNode: this._colorTexNode,
|
|
9520
9522
|
ndTexNode: this._ndTexNode,
|
|
9521
9523
|
readCacheTexNode: this._readPass1CacheTexNode,
|
|
@@ -9528,7 +9530,7 @@ var zc = class extends Sn {
|
|
|
9528
9530
|
phiDepth: this.phiDepth
|
|
9529
9531
|
})().compute(r, i);
|
|
9530
9532
|
}
|
|
9531
|
-
},
|
|
9533
|
+
}, Vc = class extends Sn {
|
|
9532
9534
|
constructor(n, r = {}) {
|
|
9533
9535
|
super("Compositor", {
|
|
9534
9536
|
...r,
|
|
@@ -9554,7 +9556,7 @@ var zc = class extends Sn {
|
|
|
9554
9556
|
dispose() {
|
|
9555
9557
|
this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this.compositorQuad = null;
|
|
9556
9558
|
}
|
|
9557
|
-
},
|
|
9559
|
+
}, Hc = class {
|
|
9558
9560
|
constructor() {
|
|
9559
9561
|
this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
|
|
9560
9562
|
frame: 0,
|
|
@@ -9677,7 +9679,7 @@ var zc = class extends Sn {
|
|
|
9677
9679
|
dispose() {
|
|
9678
9680
|
this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
|
|
9679
9681
|
}
|
|
9680
|
-
},
|
|
9682
|
+
}, Uc = class extends Je {
|
|
9681
9683
|
constructor() {
|
|
9682
9684
|
super(), this._onceCallbacks = /* @__PURE__ */ new Map();
|
|
9683
9685
|
}
|
|
@@ -9715,9 +9717,9 @@ var zc = class extends Sn {
|
|
|
9715
9717
|
eventNames() {
|
|
9716
9718
|
return this._listeners ? Object.keys(this._listeners) : [];
|
|
9717
9719
|
}
|
|
9718
|
-
},
|
|
9720
|
+
}, Wc = class {
|
|
9719
9721
|
constructor(e, t, n) {
|
|
9720
|
-
this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new
|
|
9722
|
+
this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new Hc(), this.eventBus = new Uc(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
|
|
9721
9723
|
enabled: !1,
|
|
9722
9724
|
logSkipped: !1,
|
|
9723
9725
|
timings: /* @__PURE__ */ new Map(),
|
|
@@ -9849,7 +9851,7 @@ var zc = class extends Sn {
|
|
|
9849
9851
|
let e = this.getInfo();
|
|
9850
9852
|
console.group("[Pipeline] Info"), console.log("Stages:", e.stages), console.log("Context Textures:", e.textures), console.log("Context Render Targets:", e.renderTargets), console.log("Context Uniforms:", e.uniforms), console.log("Event Types:", e.events), console.log("State:", e.contextState), console.groupEnd();
|
|
9851
9853
|
}
|
|
9852
|
-
},
|
|
9854
|
+
}, Gc = class {
|
|
9853
9855
|
constructor() {
|
|
9854
9856
|
this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1;
|
|
9855
9857
|
}
|
|
@@ -9871,7 +9873,7 @@ var zc = class extends Sn {
|
|
|
9871
9873
|
resumeFromPause() {
|
|
9872
9874
|
this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
|
|
9873
9875
|
}
|
|
9874
|
-
},
|
|
9876
|
+
}, Kc = class extends Je {
|
|
9875
9877
|
constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
|
|
9876
9878
|
super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new bt(), this.focusMode = !1, this.focusPointIndicator = null, this.afPointPlacementMode = !1, this.handleAFPointClick = this.handleAFPointClick.bind(this), this.selectedObject = null, this.selectMode = !1, this.clickTimeout = null, this.mouseDownPosition = null, this.dragThreshold = 5, this.handleFocusClick = this.handleFocusClick.bind(this), this.handleSelectClick = this.handleSelectClick.bind(this), this.handleSelectDoubleClick = this.handleSelectDoubleClick.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), this.handleMouseUp = this.handleMouseUp.bind(this), this.handleContextMenu = this.handleContextMenu.bind(this), this.handleContextPointerDown = this.handleContextPointerDown.bind(this), this.handleContextPointerUp = this.handleContextPointerUp.bind(this), this.contextPointerDownPosition = null, this.canvas.addEventListener("pointerdown", this.handleContextPointerDown), this.canvas.addEventListener("pointerup", this.handleContextPointerUp), this.canvas.addEventListener("contextmenu", this.handleContextMenu), this._overlayManager = null, this._transformManager = null, this._appDispatch = null, this._orbitControls = null;
|
|
9877
9879
|
}
|
|
@@ -10092,7 +10094,7 @@ var zc = class extends Sn {
|
|
|
10092
10094
|
dispose() {
|
|
10093
10095
|
this.canvas.removeEventListener("click", this.handleAFPointClick), this.canvas.removeEventListener("click", this.handleFocusClick), this.canvas.removeEventListener("mousedown", this.handleMouseDown), this.canvas.removeEventListener("mouseup", this.handleMouseUp), this.canvas.removeEventListener("click", this.handleSelectClick), this.canvas.removeEventListener("dblclick", this.handleSelectDoubleClick), this.canvas.removeEventListener("contextmenu", this.handleContextMenu), this.canvas.removeEventListener("pointerdown", this.handleContextPointerDown), this.canvas.removeEventListener("pointerup", this.handleContextPointerUp), this.clickTimeout &&= (clearTimeout(this.clickTimeout), null), this.mouseDownPosition = null, this.contextPointerDownPosition = null, this.focusPointIndicator &&= (this.scene.remove(this.focusPointIndicator), null), this.canvas.style.cursor = "auto", this.scene = null, this.camera = null, this.canvas = null, this.assetLoader = null, this.pathTracer = null, this.floorPlane = null, this.raycaster = null;
|
|
10094
10096
|
}
|
|
10095
|
-
},
|
|
10097
|
+
}, qc = {
|
|
10096
10098
|
glb: {
|
|
10097
10099
|
type: "model",
|
|
10098
10100
|
name: "GLB (GLTF Binary)"
|
|
@@ -10157,7 +10159,7 @@ var zc = class extends Sn {
|
|
|
10157
10159
|
type: "archive",
|
|
10158
10160
|
name: "ZIP Archive"
|
|
10159
10161
|
}
|
|
10160
|
-
},
|
|
10162
|
+
}, Jc = class extends Je {
|
|
10161
10163
|
constructor(e, t, n) {
|
|
10162
10164
|
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this._externalModel = null, this.floorPlane = null, this.sceneScale = 1, this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null;
|
|
10163
10165
|
}
|
|
@@ -10168,7 +10170,7 @@ var zc = class extends Sn {
|
|
|
10168
10170
|
this.renderer = e;
|
|
10169
10171
|
}
|
|
10170
10172
|
getFileFormat(e) {
|
|
10171
|
-
return
|
|
10173
|
+
return qc[e.split(".").pop().toLowerCase()] || null;
|
|
10172
10174
|
}
|
|
10173
10175
|
readFileAsArrayBuffer(e) {
|
|
10174
10176
|
return new Promise((t, n) => {
|
|
@@ -10361,7 +10363,7 @@ var zc = class extends Sn {
|
|
|
10361
10363
|
}
|
|
10362
10364
|
for (let t in e) {
|
|
10363
10365
|
let n = t.split(".").pop().toLowerCase();
|
|
10364
|
-
if (
|
|
10366
|
+
if (qc[n] && qc[n].type === "model") return console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e);
|
|
10365
10367
|
}
|
|
10366
10368
|
throw Error("No supported model files found in the ZIP archive");
|
|
10367
10369
|
}
|
|
@@ -10519,7 +10521,7 @@ var zc = class extends Sn {
|
|
|
10519
10521
|
return null;
|
|
10520
10522
|
}
|
|
10521
10523
|
async createGLTFLoader() {
|
|
10522
|
-
let { dracoDecoderPath: e, ktx2TranscoderPath: t } =
|
|
10524
|
+
let { dracoDecoderPath: e, ktx2TranscoderPath: t } = _c(), n = new Rt();
|
|
10523
10525
|
n.setDecoderConfig({ type: "js" }), n.setDecoderPath(e);
|
|
10524
10526
|
let r = new zt();
|
|
10525
10527
|
r.setTranscoderPath(t), this.renderer && (r.detectSupport(this.renderer), r.workerConfig = {
|
|
@@ -10808,7 +10810,7 @@ var zc = class extends Sn {
|
|
|
10808
10810
|
}), e;
|
|
10809
10811
|
}
|
|
10810
10812
|
async onModelLoad(e) {
|
|
10811
|
-
let t = new
|
|
10813
|
+
let t = new Ds("onModelLoad");
|
|
10812
10814
|
t.start("Camera extraction");
|
|
10813
10815
|
let n = this.extractCamerasFromModel(e);
|
|
10814
10816
|
t.end("Camera extraction"), t.start("Camera setup");
|
|
@@ -10887,10 +10889,10 @@ var zc = class extends Sn {
|
|
|
10887
10889
|
getSupportedFormats(e = null) {
|
|
10888
10890
|
if (e) {
|
|
10889
10891
|
let t = {};
|
|
10890
|
-
for (let [n, r] of Object.entries(
|
|
10892
|
+
for (let [n, r] of Object.entries(qc)) r.type === e && (t[n] = r);
|
|
10891
10893
|
return t;
|
|
10892
10894
|
}
|
|
10893
|
-
return
|
|
10895
|
+
return qc;
|
|
10894
10896
|
}
|
|
10895
10897
|
dispose() {
|
|
10896
10898
|
for (let e in this.loaderCache) {
|
|
@@ -10902,7 +10904,7 @@ var zc = class extends Sn {
|
|
|
10902
10904
|
removeAllEventListeners() {
|
|
10903
10905
|
this._listeners = void 0;
|
|
10904
10906
|
}
|
|
10905
|
-
},
|
|
10907
|
+
}, Yc = {
|
|
10906
10908
|
maxBounces: {
|
|
10907
10909
|
uniform: "maxBounces",
|
|
10908
10910
|
reset: !0
|
|
@@ -11025,11 +11027,11 @@ var zc = class extends Sn {
|
|
|
11025
11027
|
},
|
|
11026
11028
|
renderMode: { handler: "handleRenderMode" },
|
|
11027
11029
|
environmentRotation: { handler: "handleEnvironmentRotation" }
|
|
11028
|
-
},
|
|
11030
|
+
}, Xc = {
|
|
11029
11031
|
bounces: "maxBounces",
|
|
11030
11032
|
adaptiveSampling: "useAdaptiveSampling",
|
|
11031
11033
|
debugMode: "visMode"
|
|
11032
|
-
},
|
|
11034
|
+
}, Zc = class extends Je {
|
|
11033
11035
|
constructor(e = X) {
|
|
11034
11036
|
super(), this._values = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._delegates = {}, this._initDefaults(e);
|
|
11035
11037
|
}
|
|
@@ -11071,7 +11073,7 @@ var zc = class extends Sn {
|
|
|
11071
11073
|
let i = this._values.get(e);
|
|
11072
11074
|
if (i === t) return;
|
|
11073
11075
|
this._values.set(e, t);
|
|
11074
|
-
let a =
|
|
11076
|
+
let a = Yc[e];
|
|
11075
11077
|
a && (this._applyRoute(a, t, i), (n === void 0 ? a.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
11076
11078
|
type: Y.SETTING_CHANGED,
|
|
11077
11079
|
key: e,
|
|
@@ -11085,7 +11087,7 @@ var zc = class extends Sn {
|
|
|
11085
11087
|
let e = this._values.get(r);
|
|
11086
11088
|
if (e === i) continue;
|
|
11087
11089
|
this._values.set(r, i);
|
|
11088
|
-
let a =
|
|
11090
|
+
let a = Yc[r];
|
|
11089
11091
|
a && (this._applyRoute(a, i, e), (a.reset ?? !0) && (n = !0), t || this.dispatchEvent({
|
|
11090
11092
|
type: Y.SETTING_CHANGED,
|
|
11091
11093
|
key: r,
|
|
@@ -11103,7 +11105,7 @@ var zc = class extends Sn {
|
|
|
11103
11105
|
}
|
|
11104
11106
|
applyAll() {
|
|
11105
11107
|
for (let [e, t] of this._values) {
|
|
11106
|
-
let n =
|
|
11108
|
+
let n = Yc[e];
|
|
11107
11109
|
n && this._applyRoute(n, t, void 0);
|
|
11108
11110
|
}
|
|
11109
11111
|
}
|
|
@@ -11111,10 +11113,10 @@ var zc = class extends Sn {
|
|
|
11111
11113
|
e.uniform ? (this._pathTracer?.setUniform(e.uniform, t), e.after && this._pathTracer?.[e.after]?.()) : e.handler ? this._handlers[e.handler]?.(t, n) : e.delegate && this._delegates[e.delegate]?.updateParam?.(e.param, t);
|
|
11112
11114
|
}
|
|
11113
11115
|
_initDefaults(e) {
|
|
11114
|
-
for (let t of Object.keys(
|
|
11115
|
-
for (let [t, n] of Object.entries(
|
|
11116
|
+
for (let t of Object.keys(Yc)) t in e && this._values.set(t, e[t]);
|
|
11117
|
+
for (let [t, n] of Object.entries(Xc)) t in e && this._values.set(n, e[t]);
|
|
11116
11118
|
}
|
|
11117
|
-
},
|
|
11119
|
+
}, Qc = class extends Je {
|
|
11118
11120
|
constructor(e) {
|
|
11119
11121
|
super();
|
|
11120
11122
|
let t = e.clientWidth, n = e.clientHeight;
|
|
@@ -11230,7 +11232,7 @@ var zc = class extends Sn {
|
|
|
11230
11232
|
dispose() {
|
|
11231
11233
|
this.controls?.dispose();
|
|
11232
11234
|
}
|
|
11233
|
-
},
|
|
11235
|
+
}, $c = class extends Je {
|
|
11234
11236
|
constructor(e, t, n, r = {}) {
|
|
11235
11237
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null;
|
|
11236
11238
|
}
|
|
@@ -11383,14 +11385,14 @@ var zc = class extends Sn {
|
|
|
11383
11385
|
], n.distance = e.distance ?? 0, n.penumbra = e.penumbra ?? 0, n.decay = e.decay ?? 2) : e.type === "PointLight" && (n.distance = e.distance ?? 0, n.decay = e.decay ?? 2);
|
|
11384
11386
|
return (e.type === "SpotLight" || e.type === "DirectionalLight") && e.userData?.gobo && (n.gobo = e.userData.gobo.name, n.goboIntensity = e.userData.gobo.intensity, n.goboInverted = !!e.userData.gobo.inverted, e.type === "DirectionalLight" && (n.goboScale = e.userData.gobo.scale ?? 5)), e.type === "SpotLight" && e.userData?.ies && (n.ies = e.userData.ies.name, n.iesIntensity = e.userData.ies.intensity ?? 1, n.fixtureLumens = e.userData.ies.fixtureLumens ?? null), n;
|
|
11385
11387
|
}
|
|
11386
|
-
},
|
|
11388
|
+
}, el = class {
|
|
11387
11389
|
constructor(e, t = {}) {
|
|
11388
11390
|
this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._size = 256;
|
|
11389
11391
|
}
|
|
11390
11392
|
async loadLibrary(e, { size: t = 256 } = {}) {
|
|
11391
11393
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
11392
11394
|
this._size = t;
|
|
11393
|
-
let n = await Promise.all(e.map((e) =>
|
|
11395
|
+
let n = await Promise.all(e.map((e) => tl(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
|
|
11394
11396
|
s.width = r, s.height = i;
|
|
11395
11397
|
let c = s.getContext("2d", { willReadFrequently: !0 });
|
|
11396
11398
|
for (let e = 0; e < a; e++) {
|
|
@@ -11419,7 +11421,7 @@ var zc = class extends Sn {
|
|
|
11419
11421
|
o.userData.gobo = {
|
|
11420
11422
|
name: e.name,
|
|
11421
11423
|
index: e.index,
|
|
11422
|
-
intensity:
|
|
11424
|
+
intensity: nl(r),
|
|
11423
11425
|
inverted: !!i,
|
|
11424
11426
|
scale: Math.max(1e-4, a)
|
|
11425
11427
|
};
|
|
@@ -11461,28 +11463,28 @@ var zc = class extends Sn {
|
|
|
11461
11463
|
return t && t.isSpotLight ? t : null;
|
|
11462
11464
|
}
|
|
11463
11465
|
};
|
|
11464
|
-
function
|
|
11466
|
+
function tl(e) {
|
|
11465
11467
|
return new Promise((t, n) => {
|
|
11466
11468
|
let r = new Image();
|
|
11467
11469
|
r.crossOrigin = "anonymous", r.onload = () => t(r), r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load gobo image: ${e}`)), r.src = e;
|
|
11468
11470
|
});
|
|
11469
11471
|
}
|
|
11470
|
-
function
|
|
11472
|
+
function nl(e) {
|
|
11471
11473
|
return Math.max(0, Math.min(1, e));
|
|
11472
11474
|
}
|
|
11473
11475
|
//#endregion
|
|
11474
11476
|
//#region src/Processor/IESParser.js
|
|
11475
|
-
function
|
|
11477
|
+
function rl(e, t = "ies") {
|
|
11476
11478
|
let n = e.search(/TILT\s*=/i);
|
|
11477
11479
|
if (n < 0) throw Error(`IES (${t}): missing TILT line`);
|
|
11478
11480
|
let r = e.indexOf("\n", n);
|
|
11479
11481
|
if (r < 0) throw Error(`IES (${t}): truncated TILT line`);
|
|
11480
11482
|
let i = e.slice(n, r).match(/TILT\s*=\s*(\w+)/i), a = i ? i[1].toUpperCase() : "NONE", o = e.slice(r);
|
|
11481
11483
|
if (a === "INCLUDE") {
|
|
11482
|
-
let e =
|
|
11483
|
-
o =
|
|
11484
|
+
let e = sl(o), t = 2 + 2 * Number(e[1]);
|
|
11485
|
+
o = cl(o, t);
|
|
11484
11486
|
}
|
|
11485
|
-
let s =
|
|
11487
|
+
let s = sl(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
|
|
11486
11488
|
l(), l(), l(), l();
|
|
11487
11489
|
let g = l();
|
|
11488
11490
|
if (l(), l(), !Number.isFinite(p) || p <= 0) throw Error(`IES (${t}): invalid vertical angle count ${p}`);
|
|
@@ -11508,18 +11510,18 @@ function nl(e, t = "ies") {
|
|
|
11508
11510
|
name: t
|
|
11509
11511
|
};
|
|
11510
11512
|
}
|
|
11511
|
-
function
|
|
11513
|
+
function il(e, t, n) {
|
|
11512
11514
|
let r = new Uint8Array(t * n), { verticalAngles: i, horizontalAngles: a, candela: o, maxCandela: s } = e;
|
|
11513
11515
|
if (s <= 0) return r;
|
|
11514
11516
|
let c = i[i.length - 1], l = a[a.length - 1], u = a[0], d = a.length === 1 || l === u;
|
|
11515
11517
|
for (let e = 0; e < n; e++) {
|
|
11516
|
-
let f = (e + .5) / n * c, p =
|
|
11518
|
+
let f = (e + .5) / n * c, p = ll(i, f), m = Math.min(p + 1, i.length - 1), h = i[m] - i[p], g = h > 0 ? (f - i[p]) / h : 0;
|
|
11517
11519
|
for (let n = 0; n < t; n++) {
|
|
11518
11520
|
let i;
|
|
11519
|
-
if (d) i =
|
|
11521
|
+
if (d) i = ul(o[p][0], o[m][0], g);
|
|
11520
11522
|
else {
|
|
11521
|
-
let e = u + (n + .5) / t * (l - u), r =
|
|
11522
|
-
i =
|
|
11523
|
+
let e = u + (n + .5) / t * (l - u), r = ll(a, e), s = Math.min(r + 1, a.length - 1), c = a[s] - a[r], d = c > 0 ? (e - a[r]) / c : 0, f = o[p][r], h = o[p][s], _ = o[m][r], v = o[m][s];
|
|
11524
|
+
i = ul(ul(f, h, d), ul(_, v, d), g);
|
|
11523
11525
|
}
|
|
11524
11526
|
let c = Math.min(1, Math.max(0, i / s));
|
|
11525
11527
|
r[e * t + n] = Math.round(c * 255);
|
|
@@ -11527,7 +11529,7 @@ function rl(e, t, n) {
|
|
|
11527
11529
|
}
|
|
11528
11530
|
return r;
|
|
11529
11531
|
}
|
|
11530
|
-
function
|
|
11532
|
+
function al(e, t = .1) {
|
|
11531
11533
|
let { verticalAngles: n, horizontalAngles: r, candela: i, maxCandela: a } = e, o = Math.PI / 4;
|
|
11532
11534
|
if (a <= 0 || !n?.length) return o;
|
|
11533
11535
|
let s = a * t, c = r.length, l = n[n.length - 1], u = !1;
|
|
@@ -11542,7 +11544,7 @@ function il(e, t = .1) {
|
|
|
11542
11544
|
let d = l * Math.PI / 180;
|
|
11543
11545
|
return Math.min(Math.max(d, 5 * Math.PI / 180), 89 * Math.PI / 180);
|
|
11544
11546
|
}
|
|
11545
|
-
function
|
|
11547
|
+
function ol(e, t, n = .7) {
|
|
11546
11548
|
let { verticalAngles: r, horizontalAngles: i, candela: a, maxCandela: o } = e;
|
|
11547
11549
|
if (o <= 0 || !r?.length || t <= 0) return 0;
|
|
11548
11550
|
let s = o * n, c = i.length, l = 0;
|
|
@@ -11555,15 +11557,15 @@ function al(e, t, n = .7) {
|
|
|
11555
11557
|
let u = t * 180 / Math.PI, d = u > 0 ? 1 - l / u : 0;
|
|
11556
11558
|
return Math.min(Math.max(d, 0), 1);
|
|
11557
11559
|
}
|
|
11558
|
-
function
|
|
11560
|
+
function sl(e) {
|
|
11559
11561
|
return e.split(/\s+/).filter((e) => e.length > 0);
|
|
11560
11562
|
}
|
|
11561
|
-
function
|
|
11563
|
+
function cl(e, t) {
|
|
11562
11564
|
let n = /\S+/g, r = 0;
|
|
11563
11565
|
for (; n.exec(e) !== null;) if (r++, r === t) return e.slice(n.lastIndex);
|
|
11564
11566
|
return "";
|
|
11565
11567
|
}
|
|
11566
|
-
function
|
|
11568
|
+
function ll(e, t) {
|
|
11567
11569
|
if (t <= e[0]) return 0;
|
|
11568
11570
|
if (t >= e[e.length - 1]) return e.length - 1;
|
|
11569
11571
|
let n = 0, r = e.length - 1;
|
|
@@ -11573,12 +11575,12 @@ function cl(e, t) {
|
|
|
11573
11575
|
}
|
|
11574
11576
|
return n;
|
|
11575
11577
|
}
|
|
11576
|
-
function
|
|
11578
|
+
function ul(e, t, n) {
|
|
11577
11579
|
return e + (t - e) * n;
|
|
11578
11580
|
}
|
|
11579
11581
|
//#endregion
|
|
11580
11582
|
//#region src/managers/IESManager.js
|
|
11581
|
-
var
|
|
11583
|
+
var dl = class {
|
|
11582
11584
|
constructor(e, t = {}) {
|
|
11583
11585
|
this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._gridWidth = 128, this._gridHeight = 128;
|
|
11584
11586
|
}
|
|
@@ -11589,11 +11591,11 @@ var ul = class {
|
|
|
11589
11591
|
try {
|
|
11590
11592
|
let r = await fetch(e.url);
|
|
11591
11593
|
if (!r.ok) throw Error(`HTTP ${r.status}`);
|
|
11592
|
-
let i =
|
|
11594
|
+
let i = rl(await r.text(), e.name);
|
|
11593
11595
|
return {
|
|
11594
11596
|
it: e,
|
|
11595
11597
|
profile: i,
|
|
11596
|
-
grid:
|
|
11598
|
+
grid: il(i, t, n)
|
|
11597
11599
|
};
|
|
11598
11600
|
} catch (t) {
|
|
11599
11601
|
return console.warn(`IESManager: failed to load "${e.name}": ${t.message}`), null;
|
|
@@ -11607,14 +11609,14 @@ var ul = class {
|
|
|
11607
11609
|
let r = t[e];
|
|
11608
11610
|
o[n + e * 4 + 0] = r, o[n + e * 4 + 1] = r, o[n + e * 4 + 2] = r, o[n + e * 4 + 3] = 255;
|
|
11609
11611
|
}
|
|
11610
|
-
let i = r[e].profile, c =
|
|
11612
|
+
let i = r[e].profile, c = al(i);
|
|
11611
11613
|
s.push({
|
|
11612
11614
|
name: r[e].it.name,
|
|
11613
11615
|
index: e,
|
|
11614
11616
|
maxCandela: i.maxCandela,
|
|
11615
11617
|
photometricType: i.photometricType,
|
|
11616
11618
|
suggestedAngle: c,
|
|
11617
|
-
suggestedPenumbra:
|
|
11619
|
+
suggestedPenumbra: ol(i, c),
|
|
11618
11620
|
lumens: i.lumens
|
|
11619
11621
|
});
|
|
11620
11622
|
}
|
|
@@ -11647,7 +11649,7 @@ var ul = class {
|
|
|
11647
11649
|
l = Number.isFinite(e.lumens) ? e.lumens : null, i.userData.ies = {
|
|
11648
11650
|
name: e.name,
|
|
11649
11651
|
index: e.index,
|
|
11650
|
-
intensity:
|
|
11652
|
+
intensity: fl(n),
|
|
11651
11653
|
fixtureLumens: l
|
|
11652
11654
|
}, r && (Number.isFinite(e.suggestedAngle) && (i.angle = e.suggestedAngle, o = e.suggestedAngle), Number.isFinite(e.suggestedPenumbra) && (i.penumbra = e.suggestedPenumbra, s = e.suggestedPenumbra), i.decay = 2, c = 2);
|
|
11653
11655
|
}
|
|
@@ -11670,44 +11672,44 @@ var ul = class {
|
|
|
11670
11672
|
return t && t.isSpotLight ? t : null;
|
|
11671
11673
|
}
|
|
11672
11674
|
};
|
|
11673
|
-
function
|
|
11675
|
+
function fl(e) {
|
|
11674
11676
|
return Math.max(0, Math.min(1, e));
|
|
11675
11677
|
}
|
|
11676
11678
|
//#endregion
|
|
11677
11679
|
//#region src/Processor/ToneMapCPU.js
|
|
11678
|
-
var
|
|
11679
|
-
function pl(e, t, n, r, i) {
|
|
11680
|
-
i[0] = fl(e), i[1] = fl(t), i[2] = fl(n);
|
|
11681
|
-
}
|
|
11680
|
+
var pl = (e) => Math.min(Math.max(e, 0), 1);
|
|
11682
11681
|
function ml(e, t, n, r, i) {
|
|
11683
|
-
i[0] =
|
|
11682
|
+
i[0] = pl(e), i[1] = pl(t), i[2] = pl(n);
|
|
11684
11683
|
}
|
|
11685
11684
|
function hl(e, t, n, r, i) {
|
|
11686
|
-
|
|
11685
|
+
i[0] = pl(e * r), i[1] = pl(t * r), i[2] = pl(n * r);
|
|
11687
11686
|
}
|
|
11688
11687
|
function gl(e, t, n, r, i) {
|
|
11688
|
+
e *= r, t *= r, n *= r, i[0] = pl(e / (e + 1)), i[1] = pl(t / (t + 1)), i[2] = pl(n / (n + 1));
|
|
11689
|
+
}
|
|
11690
|
+
function _l(e, t, n, r, i) {
|
|
11689
11691
|
e = Math.max(e * r - .004, 0), t = Math.max(t * r - .004, 0), n = Math.max(n * r - .004, 0);
|
|
11690
11692
|
let a = (e) => (e * (6.2 * e + .5) / (e * (6.2 * e + 1.7) + .06)) ** 2.2;
|
|
11691
11693
|
i[0] = a(e), i[1] = a(t), i[2] = a(n);
|
|
11692
11694
|
}
|
|
11693
|
-
function
|
|
11695
|
+
function vl(e, t, n, r, i) {
|
|
11694
11696
|
e = e * r / .6, t = t * r / .6, n = n * r / .6;
|
|
11695
11697
|
let a = .59719 * e + .35458 * t + .04823 * n, o = .076 * e + .90834 * t + .01566 * n, s = .0284 * e + .13383 * t + .83777 * n, c = (e) => (e * (e + .0245786) - 90537e-9) / (e * (.983729 * e + .432951) + .238081);
|
|
11696
|
-
a = c(a), o = c(o), s = c(s), i[0] =
|
|
11698
|
+
a = c(a), o = c(o), s = c(s), i[0] = pl(1.60475 * a - .53108 * o - .07367 * s), i[1] = pl(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = pl(-.00327 * a - .07276 * o + 1.07602 * s);
|
|
11697
11699
|
}
|
|
11698
|
-
function
|
|
11700
|
+
function yl(e, t, n, r, i) {
|
|
11699
11701
|
e *= r, t *= r, n *= r;
|
|
11700
11702
|
let a = .6274 * e + .3293 * t + .0433 * n, o = .0691 * e + .9195 * t + .0113 * n, s = .0164 * e + .088 * t + .8956 * n, c = .856627153315983 * a + .0951212405381588 * o + .0482516061458583 * s, l = .137318972929847 * a + .761241990602591 * o + .101439036467562 * s, u = .11189821299995 * a + .0767994186031903 * o + .811302368396859 * s, d = -12.47393, f = 4.026069 - d;
|
|
11701
|
-
c =
|
|
11703
|
+
c = pl((Math.log2(Math.max(c, 1e-10)) - d) / f), l = pl((Math.log2(Math.max(l, 1e-10)) - d) / f), u = pl((Math.log2(Math.max(u, 1e-10)) - d) / f);
|
|
11702
11704
|
let p = (e) => {
|
|
11703
11705
|
let t = e * e, n = t * t;
|
|
11704
11706
|
return 15.5 * n * t - 40.14 * n * e + 31.96 * n - 6.868 * t * e + .4298 * t + .1191 * e - .00232;
|
|
11705
11707
|
};
|
|
11706
11708
|
c = p(c), l = p(l), u = p(u);
|
|
11707
11709
|
let m = 1.1271005818144368 * c - .11060664309660323 * l - .016493938717834573 * u, h = -.1413297634984383 * c + 1.157823702216272 * l - .016493938717834257 * u, g = -.14132976349843826 * c - .11060664309660294 * l + 1.2519364065950405 * u;
|
|
11708
|
-
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] =
|
|
11710
|
+
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = pl(1.6605 * m - .5876 * h - .0728 * g), i[1] = pl(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = pl(-.0182 * m - .1006 * h + 1.1187 * g);
|
|
11709
11711
|
}
|
|
11710
|
-
function
|
|
11712
|
+
function bl(e, t, n, r, i) {
|
|
11711
11713
|
let a = .76;
|
|
11712
11714
|
e *= r, t *= r, n *= r;
|
|
11713
11715
|
let o = Math.min(e, Math.min(t, n)), s = o < .08 ? o - 6.25 * o * o : .04;
|
|
@@ -11722,43 +11724,43 @@ function yl(e, t, n, r, i) {
|
|
|
11722
11724
|
let f = 1 - 1 / (.15 * (c - u) + 1);
|
|
11723
11725
|
i[0] = e + (u - e) * f, i[1] = t + (u - t) * f, i[2] = n + (u - n) * f;
|
|
11724
11726
|
}
|
|
11725
|
-
var
|
|
11726
|
-
[dt,
|
|
11727
|
-
[$e,
|
|
11728
|
-
[St,
|
|
11729
|
-
[Le,
|
|
11730
|
-
[Ae,
|
|
11731
|
-
[Me,
|
|
11732
|
-
[lt,
|
|
11733
|
-
]),
|
|
11734
|
-
function
|
|
11727
|
+
var xl = new Map([
|
|
11728
|
+
[dt, ml],
|
|
11729
|
+
[$e, hl],
|
|
11730
|
+
[St, gl],
|
|
11731
|
+
[Le, _l],
|
|
11732
|
+
[Ae, vl],
|
|
11733
|
+
[Me, yl],
|
|
11734
|
+
[lt, bl]
|
|
11735
|
+
]), Sl = 1 / 2.2;
|
|
11736
|
+
function Cl(e) {
|
|
11735
11737
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
11736
11738
|
}
|
|
11737
|
-
var
|
|
11738
|
-
function
|
|
11739
|
+
var wl = .2126, Tl = .7152, El = .0722;
|
|
11740
|
+
function Dl(e, t) {
|
|
11739
11741
|
if (t === 1) return;
|
|
11740
|
-
let n = e[0] *
|
|
11742
|
+
let n = e[0] * wl + e[1] * Tl + e[2] * El;
|
|
11741
11743
|
e[0] = n + (e[0] - n) * t, e[1] = n + (e[1] - n) * t, e[2] = n + (e[2] - n) * t;
|
|
11742
11744
|
}
|
|
11743
11745
|
//#endregion
|
|
11744
11746
|
//#region src/Passes/OIDNDenoiser.js
|
|
11745
|
-
var
|
|
11746
|
-
async function
|
|
11747
|
-
if (!
|
|
11747
|
+
var Ol = null, kl = null;
|
|
11748
|
+
async function Al() {
|
|
11749
|
+
if (!Ol) {
|
|
11748
11750
|
let [e, t] = await Promise.all([import("oidn-web"), import("@tensorflow/tfjs-core")]);
|
|
11749
|
-
|
|
11751
|
+
Ol = e.initUNetFromURL, kl = t.engine;
|
|
11750
11752
|
}
|
|
11751
|
-
return
|
|
11753
|
+
return Ol;
|
|
11752
11754
|
}
|
|
11753
|
-
function
|
|
11754
|
-
if (
|
|
11755
|
-
let e =
|
|
11755
|
+
function jl() {
|
|
11756
|
+
if (kl) try {
|
|
11757
|
+
let e = kl();
|
|
11756
11758
|
e?.registryFactory && "webgpu-oidn" in e.registryFactory && e.removeBackend("webgpu-oidn");
|
|
11757
11759
|
} catch (e) {
|
|
11758
11760
|
console.warn("OIDNDenoiser: failed to clear cached TFJS backend", e);
|
|
11759
11761
|
}
|
|
11760
11762
|
}
|
|
11761
|
-
var
|
|
11763
|
+
var Ml = new Float32Array(3), Nl = {
|
|
11762
11764
|
QUALITY_MODELS: {
|
|
11763
11765
|
fast: "rt_hdr_alb_nrm_small",
|
|
11764
11766
|
balance: "rt_hdr_alb_nrm",
|
|
@@ -11770,7 +11772,7 @@ var jl = new Float32Array(3), Ml = {
|
|
|
11770
11772
|
debugGbufferMaps: !0,
|
|
11771
11773
|
tileSize: 256
|
|
11772
11774
|
}
|
|
11773
|
-
},
|
|
11775
|
+
}, Pl = class extends Je {
|
|
11774
11776
|
constructor(e, t, n, r, i = {}) {
|
|
11775
11777
|
if (super(), !e || !t || !n || !r) throw Error("OIDNDenoiser requires output canvas, renderer, scene, and camera");
|
|
11776
11778
|
this.renderer = t, this.scene = n, this.camera = r, this.input = t.domElement, this.output = e, this.extractGBufferData = i.extractGBufferData || null, this.getMRTRenderTarget = i.getMRTRenderTarget || null, this.backendParamsGetter = i.backendParams || null, this.getGPUTextures = i.getGPUTextures || null, this.getExposure = i.getExposure || (() => 1), this.getToneMapping = i.getToneMapping || (() => Ae), this.getSaturation = i.getSaturation || (() => 1), this.getTransparentBackground = i.getTransparentBackground || (() => !1), this.isGPUMode = !!this.backendParamsGetter, this.gpuDevice = null, this._gpuInputBuffers = {
|
|
@@ -11781,7 +11783,7 @@ var jl = new Float32Array(3), Ml = {
|
|
|
11781
11783
|
width: 0,
|
|
11782
11784
|
height: 0
|
|
11783
11785
|
}, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
|
|
11784
|
-
...
|
|
11786
|
+
...Nl.DEFAULT_OPTIONS,
|
|
11785
11787
|
...i
|
|
11786
11788
|
}, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this.state = {
|
|
11787
11789
|
isDenoising: !1,
|
|
@@ -11834,7 +11836,7 @@ var jl = new Float32Array(3), Ml = {
|
|
|
11834
11836
|
let e = this.backendParamsGetter();
|
|
11835
11837
|
this.gpuDevice = e?.device ?? null, t = e?.device ? e : void 0;
|
|
11836
11838
|
}
|
|
11837
|
-
this.unet = await (await
|
|
11839
|
+
this.unet = await (await Al())(e, t, {
|
|
11838
11840
|
aux: !0,
|
|
11839
11841
|
hdr: !0,
|
|
11840
11842
|
maxTileSize: this.tileSize
|
|
@@ -11849,14 +11851,14 @@ var jl = new Float32Array(3), Ml = {
|
|
|
11849
11851
|
}
|
|
11850
11852
|
}
|
|
11851
11853
|
_generateTzaUrl() {
|
|
11852
|
-
let { oidnWeightsBaseUrl: e } =
|
|
11854
|
+
let { oidnWeightsBaseUrl: e } = _c(), { QUALITY_MODELS: t } = Nl;
|
|
11853
11855
|
return `${e}${t[this.quality] || t.balance}.tza`;
|
|
11854
11856
|
}
|
|
11855
11857
|
async updateConfiguration(e) {
|
|
11856
11858
|
Object.keys(e).some((t) => this.config[t] !== e[t]) && (Object.assign(this.config, e), this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, await this._setupUNetDenoiser());
|
|
11857
11859
|
}
|
|
11858
11860
|
async updateQuality(e) {
|
|
11859
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
11861
|
+
if (!Object.prototype.hasOwnProperty.call(Nl.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(Nl.QUALITY_MODELS).join(", ")}`);
|
|
11860
11862
|
await this.updateConfiguration({ oidnQuality: e });
|
|
11861
11863
|
}
|
|
11862
11864
|
async start() {
|
|
@@ -12037,10 +12039,10 @@ var jl = new Float32Array(3), Ml = {
|
|
|
12037
12039
|
d.copyBufferToBuffer(e.data, r, u, a, c);
|
|
12038
12040
|
}
|
|
12039
12041
|
r.queue.submit([d.finish()]), u.mapAsync(GPUMapMode.READ).then(() => {
|
|
12040
|
-
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l =
|
|
12042
|
+
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l = xl.get(this.getToneMapping()) || xl.get(Ae), d = this._cachedAlpha, f = this._cachedAlphaWidth;
|
|
12041
12043
|
for (let i = 0, a = e.length; i < a; i += 4) {
|
|
12042
12044
|
let a = e[i] * r, s = e[i + 1] * r, u = e[i + 2] * r;
|
|
12043
|
-
if (c !== 1 && (
|
|
12045
|
+
if (c !== 1 && (Ml[0] = a, Ml[1] = s, Ml[2] = u, Dl(Ml, c), a = Ml[0], s = Ml[1], u = Ml[2]), l(a, s, u, 1, Ml), t.data[i] = Cl(Ml[0]) * 255 + .5 | 0, t.data[i + 1] = Cl(Ml[1]) * 255 + .5 | 0, t.data[i + 2] = Cl(Ml[2]) * 255 + .5 | 0, d) {
|
|
12044
12046
|
let e = (i >> 2) % o, r = (i >> 2) / o | 0;
|
|
12045
12047
|
t.data[i + 3] = d[(n.y + r) * f + n.x + e];
|
|
12046
12048
|
} else t.data[i + 3] = 255;
|
|
@@ -12077,10 +12079,10 @@ var jl = new Float32Array(3), Ml = {
|
|
|
12077
12079
|
try {
|
|
12078
12080
|
let o = r.createCommandEncoder({ label: "oidn-readback" });
|
|
12079
12081
|
o.copyBufferToBuffer(e, 0, a, 0, i), r.queue.submit([o.finish()]), await a.mapAsync(GPUMapMode.READ);
|
|
12080
|
-
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d =
|
|
12082
|
+
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d = xl.get(this.getToneMapping()) || xl.get(Ae), f = this._cachedAlpha;
|
|
12081
12083
|
for (let e = 0, t = s.length; e < t; e += 4) {
|
|
12082
12084
|
let t = s[e] * l, n = s[e + 1] * l, r = s[e + 2] * l;
|
|
12083
|
-
u !== 1 && (
|
|
12085
|
+
u !== 1 && (Ml[0] = t, Ml[1] = n, Ml[2] = r, Dl(Ml, u), t = Ml[0], n = Ml[1], r = Ml[2]), d(t, n, r, 1, Ml), c.data[e] = Cl(Ml[0]) * 255 + .5 | 0, c.data[e + 1] = Cl(Ml[1]) * 255 + .5 | 0, c.data[e + 2] = Cl(Ml[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
|
|
12084
12086
|
}
|
|
12085
12087
|
a.unmap(), this.ctx.putImageData(c, 0, 0);
|
|
12086
12088
|
} finally {
|
|
@@ -12101,9 +12103,9 @@ var jl = new Float32Array(3), Ml = {
|
|
|
12101
12103
|
this._pendingStagingBuffers.clear();
|
|
12102
12104
|
}
|
|
12103
12105
|
dispose() {
|
|
12104
|
-
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(),
|
|
12106
|
+
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), jl(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), console.log("OIDNDenoiser disposed");
|
|
12105
12107
|
}
|
|
12106
|
-
},
|
|
12108
|
+
}, Fl = "" + new URL("assets/AIUpscalerWorker-AXN-lKWN.js", import.meta.url).href, Il = {
|
|
12107
12109
|
fast: {
|
|
12108
12110
|
2: "2x-spanx2-ch48.onnx",
|
|
12109
12111
|
4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
|
|
@@ -12117,17 +12119,17 @@ var jl = new Float32Array(3), Ml = {
|
|
|
12117
12119
|
4: "4xNomos2_hq_mosr_fp32.onnx"
|
|
12118
12120
|
}
|
|
12119
12121
|
};
|
|
12120
|
-
function
|
|
12121
|
-
let { upscalerModelBaseUrl: e } =
|
|
12122
|
-
for (let n in
|
|
12122
|
+
function Ll() {
|
|
12123
|
+
let { upscalerModelBaseUrl: e } = _c(), t = {};
|
|
12124
|
+
for (let n in Il) {
|
|
12123
12125
|
t[n] = {};
|
|
12124
|
-
for (let r in
|
|
12126
|
+
for (let r in Il[n]) t[n][r] = e + Il[n][r];
|
|
12125
12127
|
}
|
|
12126
12128
|
return t;
|
|
12127
12129
|
}
|
|
12128
|
-
var
|
|
12130
|
+
var Rl = {
|
|
12129
12131
|
get QUALITY_PRESETS() {
|
|
12130
|
-
return
|
|
12132
|
+
return Ll();
|
|
12131
12133
|
},
|
|
12132
12134
|
TILE_SIZE: 512,
|
|
12133
12135
|
TILE_OVERLAP: 16,
|
|
@@ -12138,17 +12140,17 @@ var Ll = {
|
|
|
12138
12140
|
}],
|
|
12139
12141
|
graphOptimizationLevel: "all"
|
|
12140
12142
|
}
|
|
12141
|
-
},
|
|
12143
|
+
}, zl = class extends Je {
|
|
12142
12144
|
constructor(e, t, n = {}) {
|
|
12143
12145
|
if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
|
|
12144
|
-
this.renderer = t, this.input = t.domElement, this.output = e, this.getSourceCanvas = n.getSourceCanvas || null, this.getGPUTextures = n.getGPUTextures || null, this.getExposure = n.getExposure || (() => 1), this.getToneMapping = n.getToneMapping || (() => Ae), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize ||
|
|
12146
|
+
this.renderer = t, this.input = t.domElement, this.output = e, this.getSourceCanvas = n.getSourceCanvas || null, this.getGPUTextures = n.getGPUTextures || null, this.getExposure = n.getExposure || (() => 1), this.getToneMapping = n.getToneMapping || (() => Ae), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize || Rl.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
|
|
12145
12147
|
isUpscaling: !1,
|
|
12146
12148
|
isLoading: !1,
|
|
12147
12149
|
abortController: null
|
|
12148
12150
|
}, this._worker = null, this._currentModelUrl = null, this._tileId = 0, this._pendingWorkerHandlers = /* @__PURE__ */ new Set(), this._upscaledAlpha = null, this._upscaledAlphaWidth = 0, this._backupCanvas = null, this._baseWidth = e.width, this._baseHeight = e.height, this._hdrStagingBuffer = null, this._hdrStagingWidth = 0, this._hdrStagingHeight = 0;
|
|
12149
12151
|
}
|
|
12150
12152
|
async _ensureSession() {
|
|
12151
|
-
let e =
|
|
12153
|
+
let e = Rl.QUALITY_PRESETS[this.quality];
|
|
12152
12154
|
if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
|
|
12153
12155
|
let t = e[this.scaleFactor];
|
|
12154
12156
|
if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
|
|
@@ -12159,19 +12161,19 @@ var Ll = {
|
|
|
12159
12161
|
});
|
|
12160
12162
|
try {
|
|
12161
12163
|
if (!this._worker) try {
|
|
12162
|
-
this._worker = new Worker(
|
|
12164
|
+
this._worker = new Worker(Fl, { type: "module" });
|
|
12163
12165
|
} catch (e) {
|
|
12164
12166
|
if (e.name !== "SecurityError") throw e;
|
|
12165
|
-
this._worker = await or(
|
|
12167
|
+
this._worker = await or(Fl);
|
|
12166
12168
|
}
|
|
12167
12169
|
await new Promise((e, n) => {
|
|
12168
12170
|
let r = (t) => {
|
|
12169
12171
|
t.data.type === "loaded" ? (this._worker.removeEventListener("message", r), t.data.tileSize && !this._tileSizeOverride && (this.tileSize = t.data.tileSize), console.log(`AI Upscaler: ${this.scaleFactor}x model loaded, backend: ${t.data.backend}, tileSize: ${this.tileSize}`), e()) : t.data.type === "error" && (this._worker.removeEventListener("message", r), n(Error(t.data.message)));
|
|
12170
|
-
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } =
|
|
12172
|
+
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } = _c();
|
|
12171
12173
|
this._worker.addEventListener("message", r), this._worker.postMessage({
|
|
12172
12174
|
type: "load",
|
|
12173
12175
|
url: t,
|
|
12174
|
-
sessionOptions:
|
|
12176
|
+
sessionOptions: Rl.SESSION_OPTIONS,
|
|
12175
12177
|
ortRuntimeUrl: i,
|
|
12176
12178
|
ortWasmPaths: a,
|
|
12177
12179
|
cacheNamespace: o
|
|
@@ -12241,8 +12243,8 @@ var Ll = {
|
|
|
12241
12243
|
willReadFrequently: !0,
|
|
12242
12244
|
alpha: !0
|
|
12243
12245
|
});
|
|
12244
|
-
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn =
|
|
12245
|
-
let o =
|
|
12246
|
+
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = xl.get(this.getToneMapping()) || xl.get(Ae), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
|
|
12247
|
+
let o = Rl.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
|
|
12246
12248
|
for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
|
|
12247
12249
|
if (e.aborted) throw new DOMException("Aborted", "AbortError");
|
|
12248
12250
|
let l = Math.min(u * c, Math.max(0, n - s)), p = Math.min(o * c, Math.max(0, r - s)), m = Math.min(s, n - l), h = Math.min(s, r - p), g = this._extractTile(t, l, p, m, h), _ = await this._inferTile(g, m, h), v = l * i, y = p * i, b = m * i, x = h * i, S = this._tensorToImageData(_, b, x, v, y);
|
|
@@ -12315,7 +12317,7 @@ var Ll = {
|
|
|
12315
12317
|
let u = ((n + e) * o + (t + i)) * 4, d = e * r + i;
|
|
12316
12318
|
if (s) {
|
|
12317
12319
|
let e = this._hdrToneMapFn, t = this._hdrExposure, n = this._hdrSaturation, r = a[u] * t, i = a[u + 1] * t, o = a[u + 2] * t;
|
|
12318
|
-
n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o,
|
|
12320
|
+
n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, Dl(this._tmOut, n), r = this._tmOut[0], i = this._tmOut[1], o = this._tmOut[2]), e(r, i, o, 1, this._tmOut), l[d] = this._tmOut[0] ** +Sl, l[c + d] = this._tmOut[1] ** +Sl, l[2 * c + d] = this._tmOut[2] ** +Sl;
|
|
12319
12321
|
} else l[d] = a[u] / 255, l[c + d] = a[u + 1] / 255, l[2 * c + d] = a[u + 2] / 255;
|
|
12320
12322
|
}
|
|
12321
12323
|
return l;
|
|
@@ -12373,10 +12375,10 @@ var Ll = {
|
|
|
12373
12375
|
this._backupCanvas = document.createElement("canvas"), this._backupCanvas.width = e.width, this._backupCanvas.height = e.height;
|
|
12374
12376
|
let t = this._backupCanvas.getContext("2d");
|
|
12375
12377
|
if (e.isHDR) {
|
|
12376
|
-
let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s =
|
|
12378
|
+
let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = xl.get(this.getToneMapping()) || xl.get(Ae), c = this.getExposure(), l = this.getSaturation(), u = new Float32Array(3);
|
|
12377
12379
|
for (let e = 0, t = r * i; e < t; e++) {
|
|
12378
12380
|
let t = e * 4, r = n[t] * c, i = n[t + 1] * c, a = n[t + 2] * c;
|
|
12379
|
-
l !== 1 && (u[0] = r, u[1] = i, u[2] = a,
|
|
12381
|
+
l !== 1 && (u[0] = r, u[1] = i, u[2] = a, Dl(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +Sl * 255 + .5 | 0, o[t + 1] = u[1] ** +Sl * 255 + .5 | 0, o[t + 2] = u[2] ** +Sl * 255 + .5 | 0, o[t + 3] = 255;
|
|
12380
12382
|
}
|
|
12381
12383
|
t.putImageData(a, 0, 0);
|
|
12382
12384
|
} else t.putImageData(e, 0, 0);
|
|
@@ -12388,7 +12390,7 @@ var Ll = {
|
|
|
12388
12390
|
this.hdr = !!e;
|
|
12389
12391
|
}
|
|
12390
12392
|
setQuality(e) {
|
|
12391
|
-
if (!
|
|
12393
|
+
if (!Rl.QUALITY_PRESETS[e]) {
|
|
12392
12394
|
console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
|
|
12393
12395
|
return;
|
|
12394
12396
|
}
|
|
@@ -12411,7 +12413,7 @@ var Ll = {
|
|
|
12411
12413
|
async dispose() {
|
|
12412
12414
|
this.abort(), this._cleanupPendingWorkerHandlers(), this._worker &&= (this._worker.postMessage({ type: "dispose" }), this._worker.terminate(), null), this._currentModelUrl = null, this._backupCanvas = null, this._upscaledAlpha = null, this.state.abortController = null, this._hdrStagingBuffer?.destroy(), this._hdrStagingBuffer = null, this._hdrStagingWidth = 0, this._hdrStagingHeight = 0, console.log("AIUpscaler disposed");
|
|
12413
12415
|
}
|
|
12414
|
-
},
|
|
12416
|
+
}, Bl = class extends Je {
|
|
12415
12417
|
constructor({ renderer: e, mainCanvas: t, scene: n, camera: r, stages: i, pipeline: a, getExposure: o, getSaturation: s, getTransparentBg: c }) {
|
|
12416
12418
|
super(), this.renderer = e, this.mainCanvas = t, this.denoiserCanvas = this._createDenoiserCanvas(t), this.scene = n, this.camera = r, this.pipeline = a, this._stages = i, this._getExposure = o, this._getSaturation = s, this._getTransparentBg = c, this.denoiser = null, this.upscaler = null, this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._pendingStartUpscaler = null, this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null;
|
|
12417
12419
|
}
|
|
@@ -12432,7 +12434,7 @@ var Ll = {
|
|
|
12432
12434
|
setupDenoiser() {
|
|
12433
12435
|
if (!this.denoiserCanvas) return;
|
|
12434
12436
|
let e = this._stages.pathTracer;
|
|
12435
|
-
this.denoiser = new
|
|
12437
|
+
this.denoiser = new Pl(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
|
|
12436
12438
|
...X,
|
|
12437
12439
|
backendParams: () => ({
|
|
12438
12440
|
device: this.renderer.backend.device,
|
|
@@ -12457,7 +12459,7 @@ var Ll = {
|
|
|
12457
12459
|
setupUpscaler() {
|
|
12458
12460
|
if (!this.denoiserCanvas) return;
|
|
12459
12461
|
let e = this._stages.pathTracer;
|
|
12460
|
-
this.upscaler = new
|
|
12462
|
+
this.upscaler = new zl(this.denoiserCanvas, this.renderer, {
|
|
12461
12463
|
scaleFactor: X.upscalerScale || 2,
|
|
12462
12464
|
quality: X.upscalerQuality || "fast",
|
|
12463
12465
|
getSourceCanvas: () => this.denoiser?.enabled ? null : this.renderer.domElement,
|
|
@@ -12618,7 +12620,7 @@ var Ll = {
|
|
|
12618
12620
|
let t = Bn[e];
|
|
12619
12621
|
t && this._stages.asvgf?.updateParameters(t);
|
|
12620
12622
|
}
|
|
12621
|
-
},
|
|
12623
|
+
}, Vl = class {
|
|
12622
12624
|
constructor() {
|
|
12623
12625
|
this.layer = "hud", this.visible = !1, this._tileBounds = null, this._imageWidth = 1, this._imageHeight = 1, this.enabled = !0, this._borderColor = "rgba(255, 0, 0, 0.6)", this._borderWidthRatio = 1 / 540, this._borderWidthMin = 1.5, this._borderWidthMax = 4;
|
|
12624
12626
|
}
|
|
@@ -12642,7 +12644,7 @@ var Ll = {
|
|
|
12642
12644
|
dispose() {
|
|
12643
12645
|
this.visible = !1;
|
|
12644
12646
|
}
|
|
12645
|
-
},
|
|
12647
|
+
}, Hl = class {
|
|
12646
12648
|
constructor(n, r, i) {
|
|
12647
12649
|
this.layer = "scene", this.visible = !0, this._outlineNode = Kt(r, i, {
|
|
12648
12650
|
selectedObjects: [],
|
|
@@ -12676,7 +12678,7 @@ var Ll = {
|
|
|
12676
12678
|
dispose() {
|
|
12677
12679
|
this.visible = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
|
|
12678
12680
|
}
|
|
12679
|
-
},
|
|
12681
|
+
}, Ul = class {
|
|
12680
12682
|
constructor(e, t) {
|
|
12681
12683
|
this.renderer = e, this.camera = t, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = document.createElement("canvas"), this._hudCanvas.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;", this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null;
|
|
12682
12684
|
}
|
|
@@ -12691,13 +12693,13 @@ var Ll = {
|
|
|
12691
12693
|
}
|
|
12692
12694
|
setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
|
|
12693
12695
|
this.setHelperScene(e);
|
|
12694
|
-
let s = new
|
|
12696
|
+
let s = new Vl();
|
|
12695
12697
|
this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener("resolution_changed", (e) => {
|
|
12696
12698
|
s.setRenderSize(e.width, e.height);
|
|
12697
12699
|
}), n.eventBus.on("tile:changed", (e) => {
|
|
12698
12700
|
e.renderMode === 1 && e.tileBounds && (s.setActiveTile(e.tileBounds), s.show());
|
|
12699
12701
|
}), n.eventBus.on("pipeline:reset", () => s.hide()), i.addEventListener(Y.RENDER_COMPLETE, () => s.hide()), this._wireDenoiserTileEvents(s, r);
|
|
12700
|
-
let c = new
|
|
12702
|
+
let c = new Hl(this.renderer, t, this.camera);
|
|
12701
12703
|
this.register("outline", c);
|
|
12702
12704
|
}
|
|
12703
12705
|
_wireDenoiserTileEvents(e, t) {
|
|
@@ -12764,7 +12766,7 @@ var Ll = {
|
|
|
12764
12766
|
for (let e of this._helpers.values()) e.dispose?.();
|
|
12765
12767
|
this._helpers.clear(), this._hudCanvas.parentElement && this._hudCanvas.parentElement.removeChild(this._hudCanvas);
|
|
12766
12768
|
}
|
|
12767
|
-
},
|
|
12769
|
+
}, Wl = class extends Je {
|
|
12768
12770
|
constructor() {
|
|
12769
12771
|
super(), this.mixer = null, this.timer = new At(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._tempVec = new Nt(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this.wakeCallback = null;
|
|
12770
12772
|
}
|
|
@@ -12864,7 +12866,7 @@ var Ll = {
|
|
|
12864
12866
|
dispose() {
|
|
12865
12867
|
this.mixer &&= (this.mixer.stopAllAction(), this.mixer.uncacheRoot(this._mixerRoot), null), this.actions = [], this.isPlaying = !1, this.timer.reset(), this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._skinnedCache = null, this._clipsCache = null;
|
|
12866
12868
|
}
|
|
12867
|
-
},
|
|
12869
|
+
}, Gl = class {
|
|
12868
12870
|
constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
|
|
12869
12871
|
this._app = r, this._orbitControls = n, this._camera = e, this._controls = new qt(e, t), this._gizmoScene = new Tt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new Nt(), this._normalMatrix = new it(), this._refitInFlight = !1, this._baselineComputed = !1, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
|
|
12870
12872
|
}
|
|
@@ -12975,15 +12977,15 @@ var Ll = {
|
|
|
12975
12977
|
dispose() {
|
|
12976
12978
|
this._controls.removeEventListener("dragging-changed", this._onDraggingChanged), this._controls.removeEventListener("objectChange", this._onObjectChange), this.detach(), this._gizmoScene.remove(this._controls.getHelper()), this._controls.dispose(), this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._baselineComputed = !1, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
|
|
12977
12979
|
}
|
|
12978
|
-
},
|
|
12980
|
+
}, Kl = /* @__PURE__ */ new WeakMap(), ql = class extends Je {
|
|
12979
12981
|
constructor(e, t = {}) {
|
|
12980
12982
|
super();
|
|
12981
12983
|
try {
|
|
12982
|
-
|
|
12984
|
+
Kl.get(e)?.dispose();
|
|
12983
12985
|
} catch (e) {
|
|
12984
12986
|
console.warn("PathTracerApp: prior canvas owner dispose failed", e);
|
|
12985
12987
|
}
|
|
12986
|
-
|
|
12988
|
+
Kl.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new Zc(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Wl(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this.completion = new Gc(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1;
|
|
12987
12989
|
}
|
|
12988
12990
|
_addTrackedListener(e, t, n) {
|
|
12989
12991
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -13128,7 +13130,7 @@ var Ll = {
|
|
|
13128
13130
|
}
|
|
13129
13131
|
async loadSceneData() {
|
|
13130
13132
|
this.interactionManager?.deselect(), this.animationManager.dispose(), this._animRefitInFlight = !1;
|
|
13131
|
-
let e = new
|
|
13133
|
+
let e = new Ds("loadSceneData"), t = this.meshScene.environment, n = null;
|
|
13132
13134
|
if (t?.image?.data && (e.start("Environment CDF build (worker)"), this.stages.pathTracer.scene.environment = t, n = this.stages.pathTracer.environment.buildEnvironmentCDF().then(() => e.end("Environment CDF build (worker)"))), e.start("BVH build (SceneProcessor)"), await this._sdf.buildBVH(this.meshScene), e.end("BVH build (SceneProcessor)"), On({
|
|
13133
13135
|
status: "Transferring data to GPU...",
|
|
13134
13136
|
progress: 86
|
|
@@ -13264,32 +13266,32 @@ var Ll = {
|
|
|
13264
13266
|
}), await this.renderer.init(), r.setLTC(Pt.init()), this.renderer.outputColorSpace = a, this.renderer.toneMapping = Ae, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
|
|
13265
13267
|
}
|
|
13266
13268
|
_initCameraManager() {
|
|
13267
|
-
this.cameraManager = new
|
|
13269
|
+
this.cameraManager = new Qc(this.canvas);
|
|
13268
13270
|
}
|
|
13269
13271
|
_initScenes() {
|
|
13270
13272
|
this.scene = new Tt(), this.meshScene = new Tt(), this._sceneHelpers = new Zt();
|
|
13271
13273
|
}
|
|
13272
13274
|
_initAssetPipeline() {
|
|
13273
|
-
this._sdf = new
|
|
13275
|
+
this._sdf = new pc(), this.assetLoader = new Jc(this.meshScene, this.cameraManager.camera, this.cameraManager.controls), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
|
|
13274
13276
|
this.needsReset = !0, this.wake();
|
|
13275
13277
|
});
|
|
13276
13278
|
}
|
|
13277
13279
|
_initPipeline() {
|
|
13278
13280
|
this._createStages();
|
|
13279
13281
|
let { clientWidth: e, clientHeight: t } = this.canvas;
|
|
13280
|
-
this.pipeline = new
|
|
13282
|
+
this.pipeline = new Wc(this.renderer, e || 1, t || 1), this.pipeline.addStage(this.stages.pathTracer), this.pipeline.addStage(this.stages.normalDepth), this.pipeline.addStage(this.stages.motionVector), this.pipeline.addStage(this.stages.ssrc), this.pipeline.addStage(this.stages.asvgf), this.pipeline.addStage(this.stages.variance), this.pipeline.addStage(this.stages.bilateralFilter), this.pipeline.addStage(this.stages.adaptiveSampling), this.pipeline.addStage(this.stages.edgeFilter), this.pipeline.addStage(this.stages.autoExposure), this.pipeline.addStage(this.stages.compositor);
|
|
13281
13283
|
let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
|
|
13282
13284
|
this.pipeline.setSize(n, r);
|
|
13283
13285
|
}
|
|
13284
13286
|
_initManagers() {
|
|
13285
|
-
this.interactionManager = new
|
|
13287
|
+
this.interactionManager = new Kc({
|
|
13286
13288
|
scene: this.meshScene,
|
|
13287
13289
|
camera: this.cameraManager.camera,
|
|
13288
13290
|
canvas: this.canvas,
|
|
13289
13291
|
assetLoader: this.assetLoader,
|
|
13290
13292
|
pathTracer: null,
|
|
13291
13293
|
floorPlane: this.assetLoader.floorPlane
|
|
13292
|
-
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new
|
|
13294
|
+
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new $c(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new el(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new dl(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new Gl({
|
|
13293
13295
|
camera: this.cameraManager.camera,
|
|
13294
13296
|
canvas: this.canvas,
|
|
13295
13297
|
orbitControls: this.cameraManager.controls,
|
|
@@ -13360,13 +13362,13 @@ var Ll = {
|
|
|
13360
13362
|
}
|
|
13361
13363
|
_createStages() {
|
|
13362
13364
|
let e = this.settings.get("adaptiveSamplingMax"), t = this.settings.get("useAdaptiveSampling");
|
|
13363
|
-
this.stages.pathTracer = new
|
|
13365
|
+
this.stages.pathTracer = new yc(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new bc(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new xc(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.ssrc = new Bc(this.renderer, { enabled: !1 }), this.stages.asvgf = new Sc(this.renderer, { enabled: !1 }), this.stages.variance = new wc(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new Ec(this.renderer, { enabled: !1 }), this.stages.adaptiveSampling = new kc(this.renderer, {
|
|
13364
13366
|
adaptiveSamplingMax: e,
|
|
13365
13367
|
enabled: t
|
|
13366
|
-
}), this.stages.edgeFilter = new
|
|
13368
|
+
}), this.stages.edgeFilter = new Ac(this.renderer, { enabled: !1 }), this.stages.autoExposure = new Lc(this.renderer, { enabled: X.autoExposure ?? !1 }), this.stages.compositor = new Vc(this.renderer, { saturation: this.settings.get("saturation") ?? X.saturation });
|
|
13367
13369
|
}
|
|
13368
13370
|
_setupDenoisingManager() {
|
|
13369
|
-
this.denoisingManager = new
|
|
13371
|
+
this.denoisingManager = new Bl({
|
|
13370
13372
|
renderer: this.renderer,
|
|
13371
13373
|
mainCanvas: this.canvas,
|
|
13372
13374
|
scene: this.scene,
|
|
@@ -13409,7 +13411,7 @@ var Ll = {
|
|
|
13409
13411
|
this.scene.updateMatrixWorld(), this.overlayManager?.render(), this.transformManager?.render(this.renderer);
|
|
13410
13412
|
}
|
|
13411
13413
|
_setupOverlayManager() {
|
|
13412
|
-
this.overlayManager = new
|
|
13414
|
+
this.overlayManager = new Ul(this.renderer, this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
|
|
13413
13415
|
helperScene: this._sceneHelpers,
|
|
13414
13416
|
meshScene: this.meshScene,
|
|
13415
13417
|
pipeline: this.pipeline,
|
|
@@ -13425,7 +13427,7 @@ var Ll = {
|
|
|
13425
13427
|
_forwardEvents(e, t) {
|
|
13426
13428
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
13427
13429
|
}
|
|
13428
|
-
},
|
|
13430
|
+
}, Jl = class {
|
|
13429
13431
|
constructor(e) {
|
|
13430
13432
|
this._app = e, this._cancelled = !1, this._rendering = !1;
|
|
13431
13433
|
}
|
|
@@ -13525,6 +13527,6 @@ var Ll = {
|
|
|
13525
13527
|
}
|
|
13526
13528
|
};
|
|
13527
13529
|
//#endregion
|
|
13528
|
-
export { Gn as AF_DEFAULTS, Bn as ASVGF_QUALITY_PRESETS, Wn as AUTO_FOCUS_MODES,
|
|
13530
|
+
export { Gn as AF_DEFAULTS, Bn as ASVGF_QUALITY_PRESETS, Wn as AUTO_FOCUS_MODES, Wl as AnimationManager, Kn as BVH_LEAF_MARKERS, Un as CAMERA_PRESETS, Vn as CAMERA_RANGES, Qc as CameraManager, Jn as DEFAULT_TEXTURE_MATRIX, Bl as DenoisingManager, X as ENGINE_DEFAULTS, Y as EngineEvents, el as GoboManager, dl as IESManager, Xn as INTERACTIVE_RENDER_CONFIG, Kc as InteractionManager, $c as LightManager, Zn as MEMORY_CONSTANTS, Ul as OverlayManager, Yn as PRODUCTION_RENDER_CONFIG, ql as PathTracerApp, Hc as PipelineContext, Wc as RenderPipeline, Zc as RenderSettings, Sn as RenderStage, Hn as SKY_PRESETS, xn as StageExecutionMode, qn as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, Gl as TransformManager, Jl as VideoRenderManager, gc as configureAssets, _c as getAssetConfig };
|
|
13529
13531
|
|
|
13530
13532
|
//# sourceMappingURL=rayzee.es.js.map
|