rayzee 7.28.1 → 7.28.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rayzee.es.js +688 -673
- package/dist/rayzee.umd.js +20 -20
- package/package.json +1 -1
- package/src/PathTracerApp.js +3 -0
- package/src/Processor/AssetLoader.js +19 -10
- package/src/Processor/QueueManager.js +9 -3
- package/src/Stages/PathTracer.js +20 -18
- package/src/TSL/CompactKernel.js +16 -3
- package/src/TSL/ShadeKernel.js +1 -0
package/dist/rayzee.es.js
CHANGED
|
@@ -8789,8 +8789,9 @@ var Nl = class {
|
|
|
8789
8789
|
ACTIVE_PIXEL_COUNT: 4,
|
|
8790
8790
|
GEOMETRY_COUNT: 5,
|
|
8791
8791
|
CONVERGED_GEOMETRY_COUNT: 6,
|
|
8792
|
-
|
|
8793
|
-
|
|
8792
|
+
ACTIVE_ENERGY: 7,
|
|
8793
|
+
COUNT: 8
|
|
8794
|
+
}, vu = 65535, yu = {
|
|
8794
8795
|
BOUNCE_MASK: 255,
|
|
8795
8796
|
ACTIVE: 256,
|
|
8796
8797
|
SPECULAR: 512,
|
|
@@ -8800,12 +8801,12 @@ var Nl = class {
|
|
|
8800
8801
|
HAS_HIT_OPAQUE: 65536,
|
|
8801
8802
|
AUX_LOCKED: 1 << 17,
|
|
8802
8803
|
REDIRECTED: 1 << 18
|
|
8803
|
-
},
|
|
8804
|
+
}, bu = class {
|
|
8804
8805
|
constructor(e = 0, t = null) {
|
|
8805
8806
|
this._renderer = t, this.capacity = 0, this.counters = null, this.activeIndices = null, this.activeIndicesRO = null, this.sortedIndices = null, this.sortedIndicesRO = null, this.sortGlobalHistogram = null, this.pingPong = 0, e > 0 && this.allocate(e);
|
|
8806
8807
|
}
|
|
8807
8808
|
allocate(e) {
|
|
8808
|
-
this.dispose(), this.capacity = e, this._countersAttr = new o(new Uint32Array(_u.COUNT), 1), this.counters = Ee(this._countersAttr, "uint").toAtomic(), this.MAX_BOUNCE_SNAPSHOTS = 32, this._bounceCountsAttr = new o(new Uint32Array(this.MAX_BOUNCE_SNAPSHOTS), 1), this.bounceCounts = Ee(this._bounceCountsAttr, "uint");
|
|
8809
|
+
this.dispose(), this.capacity = e, this._countersAttr = new o(new Uint32Array(_u.COUNT), 1), this.counters = Ee(this._countersAttr, "uint").toAtomic(), this.MAX_BOUNCE_SNAPSHOTS = 32, this._bounceCountsAttr = new o(new Uint32Array(2 * this.MAX_BOUNCE_SNAPSHOTS), 1), this.bounceCounts = Ee(this._bounceCountsAttr, "uint");
|
|
8809
8810
|
let t = new o(new Uint32Array(e), 1), n = new o(new Uint32Array(e), 1);
|
|
8810
8811
|
this._attrA = t, this._attrB = n, this.activeIndices = {
|
|
8811
8812
|
a: Ee(t, "uint"),
|
|
@@ -8859,12 +8860,12 @@ var Nl = class {
|
|
|
8859
8860
|
dispose() {
|
|
8860
8861
|
Ml(this._renderer, this._countersAttr), Ml(this._renderer, this._bounceCountsAttr), Ml(this._renderer, this._attrA), Ml(this._renderer, this._attrB), Ml(this._renderer, this._sortAttr), Ml(this._renderer, this._sortGlobalHistAttr), this._countersAttr = this._bounceCountsAttr = null, this._attrA = this._attrB = this._sortAttr = this._sortGlobalHistAttr = null, this.counters = null, this.activeIndices = null, this.activeIndicesRO = null, this.sortedIndices = null, this.sortedIndicesRO = null, this.sortGlobalHistogram = null, this.capacity = 0;
|
|
8861
8862
|
}
|
|
8862
|
-
},
|
|
8863
|
+
}, xu = {
|
|
8863
8864
|
[q]: 4,
|
|
8864
8865
|
[Vt]: 3,
|
|
8865
8866
|
[Ht]: 2,
|
|
8866
8867
|
[Gt]: 1
|
|
8867
|
-
},
|
|
8868
|
+
}, Su = {
|
|
8868
8869
|
[pt]: 4,
|
|
8869
8870
|
[gt]: 2,
|
|
8870
8871
|
[rn]: 1,
|
|
@@ -8874,23 +8875,23 @@ var Nl = class {
|
|
|
8874
8875
|
[an]: 4,
|
|
8875
8876
|
[_t]: 4
|
|
8876
8877
|
};
|
|
8877
|
-
function Su(e) {
|
|
8878
|
-
return (bu[e.format] ?? 4) * (xu[e.type] ?? 4);
|
|
8879
|
-
}
|
|
8880
8878
|
function Cu(e) {
|
|
8881
|
-
return e
|
|
8879
|
+
return (xu[e.format] ?? 4) * (Su[e.type] ?? 4);
|
|
8882
8880
|
}
|
|
8883
8881
|
function wu(e) {
|
|
8882
|
+
return e?.array?.byteLength || 0;
|
|
8883
|
+
}
|
|
8884
|
+
function Tu(e) {
|
|
8884
8885
|
if (!e) return 0;
|
|
8885
8886
|
if (e.isRenderTarget) {
|
|
8886
8887
|
let t = e.textures?.length ? e.textures : [e.texture], n = e.width || 0, r = e.height || 0, i = e.depth || 1, a = 0;
|
|
8887
|
-
for (let e of t) e && (a += n * r * i *
|
|
8888
|
+
for (let e of t) e && (a += n * r * i * Cu(e));
|
|
8888
8889
|
return a;
|
|
8889
8890
|
}
|
|
8890
8891
|
let t = e.image || {}, n = t.width ?? e.width ?? 0, r = t.height ?? e.height ?? 0, i = t.depth ?? 1;
|
|
8891
|
-
return n * r * i *
|
|
8892
|
+
return n * r * i * Cu(e);
|
|
8892
8893
|
}
|
|
8893
|
-
var
|
|
8894
|
+
var Eu = class {
|
|
8894
8895
|
constructor(e = null) {
|
|
8895
8896
|
this._providers = [], this._renderer = e, this.current = 0, this.peak = 0, this.byCategory = {};
|
|
8896
8897
|
}
|
|
@@ -8936,10 +8937,10 @@ var Tu = class {
|
|
|
8936
8937
|
_residentTextureBytes(e) {
|
|
8937
8938
|
if (e.isRenderTarget) {
|
|
8938
8939
|
let t = e.textures?.length ? e.textures : [e.texture], n = e.width || 0, r = e.height || 0, i = e.depth || 1, a = 0;
|
|
8939
|
-
for (let e of t) e && this._isResident(e) && (a += n * r * i *
|
|
8940
|
+
for (let e of t) e && this._isResident(e) && (a += n * r * i * Cu(e));
|
|
8940
8941
|
return a;
|
|
8941
8942
|
}
|
|
8942
|
-
return this._isResident(e) ?
|
|
8943
|
+
return this._isResident(e) ? Tu(e) : 0;
|
|
8943
8944
|
}
|
|
8944
8945
|
resetPeak() {
|
|
8945
8946
|
this.peak = this.current;
|
|
@@ -8948,7 +8949,7 @@ var Tu = class {
|
|
|
8948
8949
|
let e = (e) => (e / 1048576).toFixed(1), t = Object.entries(this.byCategory).map(([t, n]) => `${t}=${e(n)}`);
|
|
8949
8950
|
return `VRAM current=${e(this.current)}MB peak=${e(this.peak)}MB [${t.join(" ")}]`;
|
|
8950
8951
|
}
|
|
8951
|
-
},
|
|
8952
|
+
}, Du = fi("wavefront"), Ou = class {
|
|
8952
8953
|
constructor(e) {
|
|
8953
8954
|
this.renderer = e, this.kernels = /* @__PURE__ */ new Map(), this.timing = /* @__PURE__ */ new Map(), this.profiling = !1, this.profile = /* @__PURE__ */ new Map(), this._firstDispatches = [], this._firstDispatchFlush = null;
|
|
8954
8955
|
}
|
|
@@ -8962,7 +8963,7 @@ var Tu = class {
|
|
|
8962
8963
|
let e = this._firstDispatches;
|
|
8963
8964
|
if (this._firstDispatches = [], this._firstDispatchFlush = null, e.length === 0) return;
|
|
8964
8965
|
let t = e.reduce((e, t) => e + t.ms, 0), n = [...e].sort((e, t) => t.ms - e.ms);
|
|
8965
|
-
|
|
8966
|
+
Du.info(Q.list([`${e.length} kernel${e.length === 1 ? "" : "s"} compiled in ${Q.ms(t)}`, `slowest ${n.slice(0, 2).map((e) => `${e.name} ${Q.ms(e.ms)}`).join(", ")}`])), e.forEach((e) => Du.debug(`kernel '${e.name}' first dispatch (incl. compilation) ${Q.ms(e.ms)}`));
|
|
8966
8967
|
}
|
|
8967
8968
|
register(e, t) {
|
|
8968
8969
|
this.kernels.set(e, t), this.timing.set(e, {
|
|
@@ -9039,7 +9040,7 @@ var Tu = class {
|
|
|
9039
9040
|
dispose() {
|
|
9040
9041
|
clearTimeout(this._firstDispatchFlush), this._firstDispatchFlush = null, this._firstDispatches = [], this.kernels.clear(), this.timing.clear(), this.profile.clear();
|
|
9041
9042
|
}
|
|
9042
|
-
},
|
|
9043
|
+
}, ku = f(([e, t, n, r, i, a, o]) => {
|
|
9043
9044
|
let s = H(0).toVar();
|
|
9044
9045
|
return p(r.equal(j(1)), () => {
|
|
9045
9046
|
let n = P(i.x, i.y, e.x).toVar(), r = P(a.y, a.x, e.y).toVar(), c = D(r).toVar(), l = H(0).toVar(), u = H(0).toVar(), d = H(0).toVar();
|
|
@@ -9055,8 +9056,8 @@ var Tu = class {
|
|
|
9055
9056
|
let r = H(e.x.mul(2).sub(1), A(1).sub(e.y.mul(2)), 1), i = n.mul(U(r, 1));
|
|
9056
9057
|
s.assign(F(fe(t[0].xyz, t[1].xyz, t[2].xyz).mul(i.xyz.div(i.w))));
|
|
9057
9058
|
}), s;
|
|
9058
|
-
}),
|
|
9059
|
-
let g = H(n[3]).toVar(), _ =
|
|
9059
|
+
}), Au = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m, h]) => {
|
|
9060
|
+
let g = H(n[3]).toVar(), _ = ku(e, n, r, i, a, o, s).toVar(), v = g.toVar(), y = _.toVar();
|
|
9060
9061
|
return p(c.and(l.greaterThan(0)).and(u.lessThan(64)).and(d.greaterThan(.001)), () => {
|
|
9061
9062
|
let e = l.div(u).mul(.001).mul(f).mul(m), r = Yn(t), a = r.x.mul(h.max(.01)), o = r.y, s = H(0).toVar();
|
|
9062
9063
|
p(i.equal(j(1)), () => {
|
|
@@ -9070,14 +9071,14 @@ var Tu = class {
|
|
|
9070
9071
|
direction: y
|
|
9071
9072
|
});
|
|
9072
9073
|
});
|
|
9073
|
-
function
|
|
9074
|
+
function ju(e) {
|
|
9074
9075
|
let { rayBufferRW: t, rngBufferRW: n, gBufferRW: r, resolution: i, frame: a, cameraWorldMatrix: o, cameraProjectionMatrixInverse: s, cameraProjection: c, panoLonRange: l, panoLatRange: u, panoLevelHorizon: d, enableDOF: m, focalLength: h, aperture: g, focusDistance: _, sceneScale: v, apertureScale: y, anamorphicRatio: b, renderWidth: x, chunkRowBase: C, chunkRows: w, transmissiveBounces: T, transparentBackground: E, auxGBufferEnabled: D, listDriven: O = !1, activeIndicesRO: ee = null, counters: k = null } = e, te = D.greaterThan(R(0)), ne = (e, f, x) => {
|
|
9075
9076
|
let S = V(A(e).add(.5), A(f).add(.5)), C = Gn({ state: lr({
|
|
9076
9077
|
pixelCoord: S,
|
|
9077
9078
|
rayIndex: j(0),
|
|
9078
9079
|
frame: a
|
|
9079
|
-
}).toVar() }).toVar(), w = cr(S, j(1), j(1), C, i, a).toVar().sub(.5), E = V(S.x.add(w.x), S.y.sub(w.y)).div(i), D = ca.wrap(
|
|
9080
|
-
ql(t, x, D.origin, j(0), j(0)), Jl(t, x, D.direction, R(
|
|
9080
|
+
}).toVar() }).toVar(), w = cr(S, j(1), j(1), C, i, a).toVar().sub(.5), E = V(S.x.add(w.x), S.y.sub(w.y)).div(i), D = ca.wrap(Au(E, C, o, s, c, l, u, d, m, h, g, _, v, y, b));
|
|
9081
|
+
ql(t, x, D.origin, j(0), j(0)), Jl(t, x, D.direction, R(yu.ACTIVE)), Yl(t, x, U(1, 1, 1, 0).xyz, A(0)), Xl(t, x, U(H(0), A(1))), p(te, () => {
|
|
9081
9082
|
Vl(r, x, H(0, 0, 1), A(1), H(0)), uu(t, x, H(1));
|
|
9082
9083
|
}), iu(t, x, R(0), R(T), A(1), A(1), A(1)), n.element(x).assign(C);
|
|
9083
9084
|
};
|
|
@@ -9098,7 +9099,7 @@ function Au(e) {
|
|
|
9098
9099
|
}
|
|
9099
9100
|
//#endregion
|
|
9100
9101
|
//#region src/TSL/BVHTraversal.js
|
|
9101
|
-
var
|
|
9102
|
+
var Mu = 32, Nu = 512, Pu = 4, Fu = 8, Iu = 1e8, Lu = () => y("int", Mu).toVar(), Ru = W("\n fn RayTriangleGeometry( rayOrigin: vec3f, rayDir: vec3f, pA: vec3f, pB: vec3f, pC: vec3f, closestHitDst: f32, woopParams: vec4f ) -> vec4f {\n\n // Returns vec4(t, u, v, hit) where hit > 0.5 means intersection.\n // woopParams: (Sx, Sy, Sz, bitcast<f32>(packed kx|ky<<2|kz<<4))\n var result = vec4f( 1e20f, 0.0f, 0.0f, 0.0f );\n\n let Sx = woopParams.x;\n let Sy = woopParams.y;\n let Sz = woopParams.z;\n // Packed as regular f32 (values 0–42), not bitcast — avoids subnormal FTZ on Apple GPUs.\n let packed = i32( woopParams.w );\n let kx = packed & 3;\n let ky = ( packed >> 2 ) & 3;\n let kz = ( packed >> 4 ) & 3;\n\n let A = pA - rayOrigin;\n let B = pB - rayOrigin;\n let C = pC - rayOrigin;\n\n let Akz = A[ kz ];\n let Bkz = B[ kz ];\n let Ckz = C[ kz ];\n\n let Ax = A[ kx ] - Sx * Akz;\n let Ay = A[ ky ] - Sy * Akz;\n let Bx = B[ kx ] - Sx * Bkz;\n let By = B[ ky ] - Sy * Bkz;\n let Cx = C[ kx ] - Sx * Ckz;\n let Cy = C[ ky ] - Sy * Ckz;\n\n // Edge function tests — all three must share sign (or be exactly zero) for hit.\n let U = Cx * By - Cy * Bx;\n let V = Ax * Cy - Ay * Cx;\n let W = Bx * Ay - By * Ax;\n\n let neg = U < 0.0f || V < 0.0f || W < 0.0f;\n let pos = U > 0.0f || V > 0.0f || W > 0.0f;\n if ( !( neg && pos ) ) {\n\n let det = U + V + W;\n if ( det != 0.0f ) {\n\n let T = U * ( Sz * Akz ) + V * ( Sz * Bkz ) + W * ( Sz * Ckz );\n\n // Sign-aware bounds check on t (multiply both sides by sign(det) once).\n let detSign = select( -1.0f, 1.0f, det > 0.0f );\n let tSigned = T * detSign;\n let detAbs = abs( det );\n\n if ( tSigned > 0.0f && tSigned < closestHitDst * detAbs ) {\n\n // Match Möller-Trumbore convention: u = weight of B, v = weight of C.\n // In Woop's edge functions, U → weight of A, V → weight of B, W → weight of C.\n let invDet = 1.0f / det;\n result = vec4f( T * invDet, V * invDet, W * invDet, 1.0f );\n\n }\n\n }\n\n }\n\n return result;\n\n }\n"), zu = W("\n fn computeWoopRayParams( rayDir: vec3f ) -> vec4f {\n\n let absDir = abs( rayDir );\n\n // kz = argmax(|dir|)\n var kz: i32 = 0;\n if ( absDir.y >= absDir.x ) { kz = 1; }\n if ( absDir.z >= absDir[ u32( kz ) ] ) { kz = 2; }\n\n var kx: i32 = ( kz + 1 ) % 3;\n var ky: i32 = ( kx + 1 ) % 3;\n\n // Preserve triangle winding when the dominant axis component is negative.\n if ( rayDir[ u32( kz ) ] < 0.0f ) {\n let tmp = kx;\n kx = ky;\n ky = tmp;\n }\n\n let dz = rayDir[ u32( kz ) ];\n let Sx = rayDir[ u32( kx ) ] / dz;\n let Sy = rayDir[ u32( ky ) ] / dz;\n let Sz = 1.0f / dz;\n\n let packed = kx | ( ky << 2 ) | ( kz << 4 );\n return vec4f( Sx, Sy, Sz, f32( packed ) );\n\n }\n"), Bu = W("\n fn fastRayAABBDst( rayOrigin: vec3f, invDir: vec3f, boxMin: vec3f, boxMax: vec3f ) -> f32 {\n\n let t1 = ( boxMin - rayOrigin ) * invDir;\n let t2 = ( boxMax - rayOrigin ) * invDir;\n\n let tmin = min( t1, t2 );\n let tmax = max( t1, t2 );\n\n let tNear = max( max( tmin.x, tmin.y ), tmin.z );\n let tFar = min( min( tmax.x, tmax.y ), tmax.z ) * 1.00000024f; // Robust traversal: 2 ULP padding (Ize 2013)\n\n let isHit = tNear <= tFar && tFar > 0.0f;\n return select( 1e20f, max( tNear, 0.0f ), isHit );\n\n }\n"), Vu = (e) => f(([t, n, r, i]) => {
|
|
9102
9103
|
let a = i ?? T(!1), o = pa({
|
|
9103
9104
|
didHit: !1,
|
|
9104
9105
|
dst: A(0x56bc75e2d63100000),
|
|
@@ -9109,12 +9110,12 @@ var ju = 32, Mu = 512, Nu = 4, Pu = 8, Fu = 1e8, Iu = () => y("int", ju).toVar()
|
|
|
9109
9110
|
meshIndex: j(-1),
|
|
9110
9111
|
boxTests: j(0),
|
|
9111
9112
|
triTests: j(0)
|
|
9112
|
-
}).toVar(), s = j(-1).toVar(), c = A(0).toVar(), l = A(0).toVar(), u =
|
|
9113
|
+
}).toVar(), s = j(-1).toVar(), c = A(0).toVar(), l = A(0).toVar(), u = Lu(), f = j(1).toVar();
|
|
9113
9114
|
u.element(j(0)).assign(j(0));
|
|
9114
|
-
let h = P(H(1), Se(t.direction), he(t.direction, H(0))), g = P(H(1).div(t.direction), H(
|
|
9115
|
-
return m(f.greaterThan(j(0)).and(x.lessThan(j(
|
|
9115
|
+
let h = P(H(1), Se(t.direction), he(t.direction, H(0))), g = P(H(1).div(t.direction), H(Iu).mul(h), ce(_(t.direction), H(1e-8))).toVar(), v = t.origin, y = t.direction, b = zu({ rayDir: y }).toVar(), x = j(0).toVar();
|
|
9116
|
+
return m(f.greaterThan(j(0)).and(x.lessThan(j(Nu))), () => {
|
|
9116
9117
|
x.addAssign(1), f.subAssign(1);
|
|
9117
|
-
let t = u.element(f).toVar(), i = $(n, t, j(0), j(
|
|
9118
|
+
let t = u.element(f).toVar(), i = $(n, t, j(0), j(Pu));
|
|
9118
9119
|
e && o.boxTests.addAssign(1), p(i.w.lessThan(0), () => {
|
|
9119
9120
|
p(i.w.greaterThan(A(-1.5)), () => {
|
|
9120
9121
|
let t = j(i.x).toVar(), n = j(i.y).toVar();
|
|
@@ -9123,7 +9124,7 @@ var ju = 32, Mu = 512, Nu = 4, Pu = 8, Fu = 1e8, Iu = () => y("int", ju).toVar()
|
|
|
9123
9124
|
end: n
|
|
9124
9125
|
}, ({ i: n }) => {
|
|
9125
9126
|
e && o.triTests.addAssign(1);
|
|
9126
|
-
let i = t.add(n).toVar(), u = $(r, i, j(0), j(
|
|
9127
|
+
let i = t.add(n).toVar(), u = $(r, i, j(0), j(Fu)).xyz, d = $(r, i, j(1), j(Fu)).xyz, f = $(r, i, j(2), j(Fu)).xyz, m = Ru({
|
|
9127
9128
|
rayOrigin: v,
|
|
9128
9129
|
rayDir: y,
|
|
9129
9130
|
pA: u,
|
|
@@ -9133,7 +9134,7 @@ var ju = 32, Mu = 512, Nu = 4, Pu = 8, Fu = 1e8, Iu = () => y("int", ju).toVar()
|
|
|
9133
9134
|
woopParams: b
|
|
9134
9135
|
});
|
|
9135
9136
|
p(m.w.greaterThan(.5), () => {
|
|
9136
|
-
let e = m.x, t = m.y, n = m.z, u = $(r, i, j(3), j(
|
|
9137
|
+
let e = m.x, t = m.y, n = m.z, u = $(r, i, j(3), j(Fu)).xyz, d = $(r, i, j(4), j(Fu)).xyz, f = $(r, i, j(5), j(Fu)), h = f.xyz, g = j(f.w).toVar(), _ = A(1).sub(t).sub(n), v = y.dot(F(u.mul(_).add(d.mul(t)).add(h.mul(n))));
|
|
9137
9138
|
p(a.or(g.equal(j(2))).or(g.equal(j(0)).and(v.lessThan(-1e-4))).or(g.equal(j(1)).and(v.greaterThan(1e-4))), () => {
|
|
9138
9139
|
o.didHit.assign(!0), o.dst.assign(e), s.assign(i), c.assign(t), l.assign(n);
|
|
9139
9140
|
});
|
|
@@ -9142,17 +9143,17 @@ var ju = 32, Mu = 512, Nu = 4, Pu = 8, Fu = 1e8, Iu = () => y("int", ju).toVar()
|
|
|
9142
9143
|
d();
|
|
9143
9144
|
});
|
|
9144
9145
|
}).Else(() => {
|
|
9145
|
-
p(i.z.greaterThan(.5).and(f.lessThan(j(
|
|
9146
|
+
p(i.z.greaterThan(.5).and(f.lessThan(j(Mu))), () => {
|
|
9146
9147
|
u.element(f).assign(j(i.x)), f.addAssign(1);
|
|
9147
9148
|
});
|
|
9148
9149
|
});
|
|
9149
9150
|
}).Else(() => {
|
|
9150
|
-
let e = $(n, t, j(1), j(
|
|
9151
|
+
let e = $(n, t, j(1), j(Pu)), r = $(n, t, j(2), j(Pu)), a = $(n, t, j(3), j(Pu)), s = j(i.w).toVar(), c = j(e.w).toVar(), l = Bu({
|
|
9151
9152
|
rayOrigin: v,
|
|
9152
9153
|
invDir: g,
|
|
9153
9154
|
boxMin: i.xyz,
|
|
9154
9155
|
boxMax: e.xyz
|
|
9155
|
-
}).toVar(), d =
|
|
9156
|
+
}).toVar(), d = Bu({
|
|
9156
9157
|
rayOrigin: v,
|
|
9157
9158
|
invDir: g,
|
|
9158
9159
|
boxMin: r.xyz,
|
|
@@ -9160,21 +9161,21 @@ var ju = 32, Mu = 512, Nu = 4, Pu = 8, Fu = 1e8, Iu = () => y("int", ju).toVar()
|
|
|
9160
9161
|
}).toVar();
|
|
9161
9162
|
p(pe(l, d).lessThan(o.dst), () => {
|
|
9162
9163
|
let e = l.lessThan(d);
|
|
9163
|
-
p(I(e, d, l).lessThan(o.dst).and(f.lessThan(j(
|
|
9164
|
+
p(I(e, d, l).lessThan(o.dst).and(f.lessThan(j(Mu))), () => {
|
|
9164
9165
|
u.element(f).assign(I(e, c, s)), f.addAssign(1);
|
|
9165
|
-
}), p(f.lessThan(j(
|
|
9166
|
+
}), p(f.lessThan(j(Mu)), () => {
|
|
9166
9167
|
u.element(f).assign(I(e, s, c)), f.addAssign(1);
|
|
9167
9168
|
});
|
|
9168
9169
|
});
|
|
9169
9170
|
});
|
|
9170
9171
|
}), p(o.didHit, () => {
|
|
9171
9172
|
o.hitPoint.assign(t.origin.add(t.direction.mul(o.dst)));
|
|
9172
|
-
let e = A(1).sub(c).sub(l), n = $(r, s, j(3), j(
|
|
9173
|
+
let e = A(1).sub(c).sub(l), n = $(r, s, j(3), j(Fu)).xyz, i = $(r, s, j(4), j(Fu)).xyz, a = $(r, s, j(5), j(Fu)).xyz;
|
|
9173
9174
|
o.normal.assign(F(n.mul(e).add(i.mul(c)).add(a.mul(l))));
|
|
9174
|
-
let u = $(r, s, j(6), j(
|
|
9175
|
+
let u = $(r, s, j(6), j(Fu)), d = $(r, s, j(7), j(Fu));
|
|
9175
9176
|
o.uv.assign(u.xy.mul(e).add(u.zw.mul(c)).add(d.xy.mul(l))), o.materialIndex.assign(j(d.z)), o.meshIndex.assign(j(d.w)), o.triangleIndex.assign(s);
|
|
9176
9177
|
}), o;
|
|
9177
|
-
}),
|
|
9178
|
+
}), Hu = /* @__PURE__ */ Vu(!1), Uu = /* @__PURE__ */ Vu(!0), Wu = f(([e, t, n, r]) => {
|
|
9178
9179
|
let i = pa({
|
|
9179
9180
|
didHit: !1,
|
|
9180
9181
|
dst: r,
|
|
@@ -9185,12 +9186,12 @@ var ju = 32, Mu = 512, Nu = 4, Pu = 8, Fu = 1e8, Iu = () => y("int", ju).toVar()
|
|
|
9185
9186
|
meshIndex: j(-1),
|
|
9186
9187
|
boxTests: j(0),
|
|
9187
9188
|
triTests: j(0)
|
|
9188
|
-
}).toVar(), a =
|
|
9189
|
+
}).toVar(), a = Lu(), o = j(1).toVar();
|
|
9189
9190
|
a.element(j(0)).assign(j(0));
|
|
9190
|
-
let s = P(H(1), Se(e.direction), he(e.direction, H(0))), c = P(H(1).div(e.direction), H(
|
|
9191
|
-
return m(o.greaterThan(j(0)).and(i.didHit.not()).and(u.lessThan(j(
|
|
9191
|
+
let s = P(H(1), Se(e.direction), he(e.direction, H(0))), c = P(H(1).div(e.direction), H(Iu).mul(s), ce(_(e.direction), H(1e-8))).toVar(), l = zu({ rayDir: e.direction }).toVar(), u = j(0).toVar();
|
|
9192
|
+
return m(o.greaterThan(j(0)).and(i.didHit.not()).and(u.lessThan(j(Nu))), () => {
|
|
9192
9193
|
u.addAssign(1), o.subAssign(1);
|
|
9193
|
-
let r = a.element(o).toVar(), s = $(t, r, j(0), j(
|
|
9194
|
+
let r = a.element(o).toVar(), s = $(t, r, j(0), j(Pu));
|
|
9194
9195
|
p(s.w.lessThan(0), () => {
|
|
9195
9196
|
p(s.w.greaterThan(A(-1.5)), () => {
|
|
9196
9197
|
let t = j(s.x).toVar(), r = j(s.y).toVar();
|
|
@@ -9198,7 +9199,7 @@ var ju = 32, Mu = 512, Nu = 4, Pu = 8, Fu = 1e8, Iu = () => y("int", ju).toVar()
|
|
|
9198
9199
|
start: j(0),
|
|
9199
9200
|
end: r
|
|
9200
9201
|
}, ({ i: r }) => {
|
|
9201
|
-
let a = t.add(r).toVar(), o = $(n, a, j(0), j(
|
|
9202
|
+
let a = t.add(r).toVar(), o = $(n, a, j(0), j(Fu)).xyz, s = $(n, a, j(1), j(Fu)).xyz, c = $(n, a, j(2), j(Fu)).xyz, u = Ru({
|
|
9202
9203
|
rayOrigin: e.origin,
|
|
9203
9204
|
rayDir: e.direction,
|
|
9204
9205
|
pA: o,
|
|
@@ -9208,22 +9209,22 @@ var ju = 32, Mu = 512, Nu = 4, Pu = 8, Fu = 1e8, Iu = () => y("int", ju).toVar()
|
|
|
9208
9209
|
woopParams: l
|
|
9209
9210
|
});
|
|
9210
9211
|
p(u.w.greaterThan(.5), () => {
|
|
9211
|
-
let t = $(n, a, j(7), j(
|
|
9212
|
+
let t = $(n, a, j(7), j(Fu));
|
|
9212
9213
|
i.didHit.assign(!0), i.dst.assign(u.x), i.materialIndex.assign(j(t.z)), i.meshIndex.assign(j(t.w)), i.hitPoint.assign(e.origin.add(e.direction.mul(u.x))), i.uv.assign(V(u.y, u.z)), i.triangleIndex.assign(a), d();
|
|
9213
9214
|
});
|
|
9214
9215
|
});
|
|
9215
9216
|
}).Else(() => {
|
|
9216
|
-
p(s.z.greaterThan(.5).and(o.lessThan(j(
|
|
9217
|
+
p(s.z.greaterThan(.5).and(o.lessThan(j(Mu))), () => {
|
|
9217
9218
|
a.element(o).assign(j(s.x)), o.addAssign(1);
|
|
9218
9219
|
});
|
|
9219
9220
|
});
|
|
9220
9221
|
}).Else(() => {
|
|
9221
|
-
let n = $(t, r, j(1), j(
|
|
9222
|
+
let n = $(t, r, j(1), j(Pu)), l = $(t, r, j(2), j(Pu)), u = $(t, r, j(3), j(Pu)), d = j(s.w).toVar(), f = j(n.w).toVar(), m = Bu({
|
|
9222
9223
|
rayOrigin: e.origin,
|
|
9223
9224
|
invDir: c,
|
|
9224
9225
|
boxMin: s.xyz,
|
|
9225
9226
|
boxMax: n.xyz
|
|
9226
|
-
}).toVar(), h =
|
|
9227
|
+
}).toVar(), h = Bu({
|
|
9227
9228
|
rayOrigin: e.origin,
|
|
9228
9229
|
invDir: c,
|
|
9229
9230
|
boxMin: l.xyz,
|
|
@@ -9231,9 +9232,9 @@ var ju = 32, Mu = 512, Nu = 4, Pu = 8, Fu = 1e8, Iu = () => y("int", ju).toVar()
|
|
|
9231
9232
|
}).toVar();
|
|
9232
9233
|
p(pe(m, h).lessThan(i.dst), () => {
|
|
9233
9234
|
let e = m.lessThan(h);
|
|
9234
|
-
p(I(e, h, m).lessThan(i.dst).and(o.lessThan(j(
|
|
9235
|
+
p(I(e, h, m).lessThan(i.dst).and(o.lessThan(j(Mu))), () => {
|
|
9235
9236
|
a.element(o).assign(I(e, f, d)), o.addAssign(1);
|
|
9236
|
-
}), p(o.lessThan(j(
|
|
9237
|
+
}), p(o.lessThan(j(Mu)), () => {
|
|
9237
9238
|
a.element(o).assign(I(e, d, f)), o.addAssign(1);
|
|
9238
9239
|
});
|
|
9239
9240
|
});
|
|
@@ -9242,7 +9243,7 @@ var ju = 32, Mu = 512, Nu = 4, Pu = 8, Fu = 1e8, Iu = () => y("int", ju).toVar()
|
|
|
9242
9243
|
});
|
|
9243
9244
|
//#endregion
|
|
9244
9245
|
//#region src/TSL/ExtendKernel.js
|
|
9245
|
-
function
|
|
9246
|
+
function Gu(e) {
|
|
9246
9247
|
let { bvhBuffer: t, triangleBuffer: n, rayBufferRO: r, hitBufferRW: i, activeIndicesRO: a, counters: o, maxRayCount: s } = e;
|
|
9247
9248
|
return f(() => {
|
|
9248
9249
|
let e = oe, c = o ? S(o.element(R(_u.ENTERING_COUNT))) : s;
|
|
@@ -9250,38 +9251,38 @@ function Wu(e) {
|
|
|
9250
9251
|
h();
|
|
9251
9252
|
});
|
|
9252
9253
|
let l = a.element(e);
|
|
9253
|
-
p(Il(r, l).bitAnd(R(
|
|
9254
|
+
p(Il(r, l).bitAnd(R(yu.ACTIVE)).equal(R(0)), () => {
|
|
9254
9255
|
h();
|
|
9255
9256
|
});
|
|
9256
9257
|
let u = ca({
|
|
9257
9258
|
origin: Pl(r, l).toVar(),
|
|
9258
9259
|
direction: Fl(r, l).toVar()
|
|
9259
|
-
}), d = ru(r, l).stackDepth.greaterThan(R(0)), f = pa.wrap(
|
|
9260
|
+
}), d = ru(r, l).stackDepth.greaterThan(R(0)), f = pa.wrap(Hu(u, t, n, d)).toVar();
|
|
9260
9261
|
nu(i, l, f.dst, R(f.triangleIndex), f.uv.x, f.uv.y, f.normal, R(f.materialIndex), R(f.meshIndex));
|
|
9261
9262
|
});
|
|
9262
9263
|
}
|
|
9263
9264
|
//#endregion
|
|
9264
9265
|
//#region src/TSL/Environment.js
|
|
9265
|
-
var
|
|
9266
|
+
var Ku = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, environmentMatrix: mat4x4f ) -> vec2f {\n let d = normalize( ( environmentMatrix * vec4f( direction, 0.0f ) ).xyz );\n var uv = vec2f( atan2( d.z, d.x ), acos( d.y ) );\n uv = uv / vec2f( 6.28318530717958647692f, 3.14159265358979323846f );\n uv.x = uv.x + 0.5f;\n uv.y = 1.0f - uv.y;\n return uv;\n }\n"), qu = /* @__PURE__ */ W("\n fn equirectUvToDirection( uv: vec2f, environmentMatrix: mat4x4f ) -> vec3f {\n let adjustedUv = vec2f( uv.x - 0.5f, 1.0f - uv.y );\n let theta = adjustedUv.x * 6.28318530717958647692f;\n let phi = adjustedUv.y * 3.14159265358979323846f;\n let sinPhi = sin( phi );\n let localDir = vec3f( sinPhi * cos( theta ), cos( phi ), sinPhi * sin( theta ) );\n return normalize( ( transpose( environmentMatrix ) * vec4f( localDir, 0.0f ) ).xyz );\n }\n"), Ju = f(([e, t, n, r, i, a]) => {
|
|
9266
9267
|
let o = U(0).toVar();
|
|
9267
9268
|
return p(r.equal(0), () => {
|
|
9268
9269
|
o.assign(U(0));
|
|
9269
9270
|
}).Else(() => {
|
|
9270
|
-
let s =
|
|
9271
|
+
let s = Ku({
|
|
9271
9272
|
direction: t,
|
|
9272
9273
|
environmentMatrix: n
|
|
9273
9274
|
}).toVar(), c = Me(e, s, 0).rgb.toVar(), l = Ce(s.y.mul(Math.PI)).toVar(), u = k(c, Aa).mul(l), d = N(A(0), u.sub(i)).div(r), f = l.greaterThan(0).select(A(1).div(A(2 * Math.PI * Math.PI).mul(l)), A(0)), p = A(a.x).mul(A(a.y)).mul(d).mul(f);
|
|
9274
9275
|
o.assign(U(c, p));
|
|
9275
9276
|
}), o;
|
|
9276
|
-
}),
|
|
9277
|
-
let l = j(o.x).toVar(), u = o.y, d = E(s.x.mul(u.sub(1)), 0, u.sub(1)), f = j(ie(d)), p = pe(f.add(1), j(u).sub(1)), m = ae(d), h = P(t.load(M(l, f)).x, t.load(M(l, p)).x, m).toVar(), g = o.x, _ = o.y, v = E(s.y.mul(g.sub(1)), 0, g.sub(1)), y = E(h.mul(_.sub(1)), 0, _.sub(1)), b = j(ie(v)), x = j(ie(y)), S = pe(b.add(1), j(g).sub(1)), C = pe(x.add(1), j(_).sub(1)), w = ae(v), T = ae(y), D = t.load(M(b, x)).x, O = t.load(M(S, x)).x, ee = t.load(M(b, C)).x, te = t.load(M(S, C)).x, ne = V(P(P(D, O, w), P(ee, te, w), T).toVar(), h).toVar(), re =
|
|
9277
|
+
}), Yu = f(([e, t, n, r, i, a, o, s, c]) => {
|
|
9278
|
+
let l = j(o.x).toVar(), u = o.y, d = E(s.x.mul(u.sub(1)), 0, u.sub(1)), f = j(ie(d)), p = pe(f.add(1), j(u).sub(1)), m = ae(d), h = P(t.load(M(l, f)).x, t.load(M(l, p)).x, m).toVar(), g = o.x, _ = o.y, v = E(s.y.mul(g.sub(1)), 0, g.sub(1)), y = E(h.mul(_.sub(1)), 0, _.sub(1)), b = j(ie(v)), x = j(ie(y)), S = pe(b.add(1), j(g).sub(1)), C = pe(x.add(1), j(_).sub(1)), w = ae(v), T = ae(y), D = t.load(M(b, x)).x, O = t.load(M(S, x)).x, ee = t.load(M(b, C)).x, te = t.load(M(S, C)).x, ne = V(P(P(D, O, w), P(ee, te, w), T).toVar(), h).toVar(), re = qu({
|
|
9278
9279
|
uv: ne,
|
|
9279
9280
|
environmentMatrix: n
|
|
9280
9281
|
}).toVar(), oe = Me(e, ne, 0).rgb.mul(r).toVar();
|
|
9281
9282
|
c.assign(oe);
|
|
9282
9283
|
let se = Ce(ne.y.mul(Math.PI)).toVar(), ce = k(oe.div(r), Aa).mul(se), le = N(A(0), ce.sub(a)).div(i), ue = se.greaterThan(0).select(A(1).div(A(2 * Math.PI * Math.PI).mul(se)), A(0));
|
|
9283
9284
|
return U(re, A(o.x).mul(A(o.y)).mul(le).mul(ue));
|
|
9284
|
-
}),
|
|
9285
|
+
}), Xu = /* @__PURE__ */ W("\n fn sampleEnvironment(\n tex: texture_2d<f32>,\n samp: sampler,\n direction: vec3f,\n environmentMatrix: mat4x4f,\n environmentIntensity: f32,\n enableEnvironmentLight: f32\n ) -> vec4f {\n if ( enableEnvironmentLight < 0.5 ) { return vec4f( 0.0 ); }\n let uv = equirectDirectionToUv( direction, environmentMatrix );\n let texSample = textureSampleLevel( tex, samp, uv, 0.0 );\n return texSample * environmentIntensity;\n }\n", [Ku]), Zu = f(([e, t, n, r]) => {
|
|
9285
9286
|
let i = t.toConst(), a = e.toVar();
|
|
9286
9287
|
a.y.subAssign(r);
|
|
9287
9288
|
let o = n.mul(n).toConst(), s = a.dot(i).toConst(), c = a.dot(a).sub(o).toConst(), l = s.mul(s).sub(c).toConst(), u = t.toVar();
|
|
@@ -9296,13 +9297,13 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9296
9297
|
u.assign(a.add(i.mul(pe(t, r))).div(n));
|
|
9297
9298
|
});
|
|
9298
9299
|
}), u;
|
|
9299
|
-
}),
|
|
9300
|
+
}), Qu = f(([e, t, n, r, i, a]) => {
|
|
9300
9301
|
let o = t.toVar();
|
|
9301
9302
|
return p(n, () => {
|
|
9302
9303
|
let n = H(e.x, e.y.sub(a), e.z);
|
|
9303
|
-
o.assign(
|
|
9304
|
+
o.assign(Zu(n, t, r, i));
|
|
9304
9305
|
}), o;
|
|
9305
|
-
}),
|
|
9306
|
+
}), $u = f(([e, t]) => {
|
|
9306
9307
|
let n = H(0).toVar();
|
|
9307
9308
|
return p(e.roughness.greaterThan(.98).and(e.metalness.lessThan(.02)).and(e.transmission.equal(0)).and(e.clearcoat.equal(0)).and(e.sheen.equal(0)).and(e.iridescence.equal(0)), () => {
|
|
9308
9309
|
n.assign(e.color.rgb.mul(A(1).sub(e.metalness)).mul(wa));
|
|
@@ -9337,21 +9338,21 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9337
9338
|
n.assign(n.mul(u).add(l.mul(e.clearcoat)));
|
|
9338
9339
|
});
|
|
9339
9340
|
}), n;
|
|
9340
|
-
}),
|
|
9341
|
+
}), ed = f(([e, t, n, r]) => $u(r, _a.wrap(Va(n, e, t, r)))), td = 2 * Ca, nd = .9999, rd = f(([e, t]) => {
|
|
9341
9342
|
let n = A(1).toVar();
|
|
9342
9343
|
return p(t.lessThan(A(Ca).sub(.001)).and(e.greaterThan(0)), () => {
|
|
9343
9344
|
let r = t.mul(.5).toVar(), i = je(r).toVar(), a = Te(N(A(1).sub(e.mul(e)), 0)).div(N(e, 1e-4)), o = I(r.greaterThan(.05), A(1).div(N(i.sub(r), 1e-6)), A(3).div(N(r.mul(r).mul(r), 1e-9)));
|
|
9344
9345
|
n.assign(N(i.sub(a).mul(o), 0));
|
|
9345
9346
|
}), n;
|
|
9346
|
-
}),
|
|
9347
|
+
}), id = f(([e]) => {
|
|
9347
9348
|
let t = I(e.normalize.greaterThan(.5), A(1).div(N(e.area, 1e-10)), A(1));
|
|
9348
9349
|
return e.color.mul(e.intensity).mul(wa).mul(t);
|
|
9349
|
-
}),
|
|
9350
|
+
}), ad = f(([e, t, n, r]) => {
|
|
9350
9351
|
let i = T(!1).toVar(), a = H(0, 1, 0).toVar(), o = H(0).toVar(), s = A(0).toVar(), c = A(0).toVar(), l = j(2).toVar();
|
|
9351
9352
|
return p(e.area.greaterThan(0), () => {
|
|
9352
9353
|
let u = H(0).toVar(), d = A(-1).toVar();
|
|
9353
9354
|
p(e.shape.greaterThan(.5), () => {
|
|
9354
|
-
let t = Te(n.x).toVar(), r = A(
|
|
9355
|
+
let t = Te(n.x).toVar(), r = A(td).mul(n.y).toVar();
|
|
9355
9356
|
u.assign(e.position.add(e.u.mul(t.mul(D(r)))).add(e.v.mul(t.mul(Ce(r)))));
|
|
9356
9357
|
}).Else(() => {
|
|
9357
9358
|
let r = ic(t, e.position.sub(e.u).sub(e.v), e.u.mul(2), e.v.mul(2), n).toVar();
|
|
@@ -9364,7 +9365,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9364
9365
|
let f = u.sub(t).toVar(), m = k(f, f).toVar();
|
|
9365
9366
|
p(m.greaterThanEqual(1e-10), () => {
|
|
9366
9367
|
let t = Te(m).toVar(), n = f.div(t).toVar(), u = k(n.negate(), e.normal).toVar();
|
|
9367
|
-
l.assign(j(1)), s.assign(t), a.assign(n), o.assign(
|
|
9368
|
+
l.assign(j(1)), s.assign(t), a.assign(n), o.assign(id(e).mul(rd(u, e.spread)));
|
|
9368
9369
|
let p = m.div(N(e.area.mul(N(u, .001)), 1e-10)), h = I(d.greaterThan(0), d, p);
|
|
9369
9370
|
c.assign(h.mul(r)), i.assign(u.greaterThan(0));
|
|
9370
9371
|
});
|
|
@@ -9377,7 +9378,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9377
9378
|
lightType: l,
|
|
9378
9379
|
selectionTotalWeight: A(0)
|
|
9379
9380
|
});
|
|
9380
|
-
}),
|
|
9381
|
+
}), od = f(([e, t, n]) => {
|
|
9381
9382
|
let r = T(!1).toVar(), i = H(0, 1, 0).toVar(), a = H(0).toVar(), o = A(0).toVar(), s = A(0).toVar(), c = j(3).toVar(), l = e.position.sub(t).toVar(), u = k(l, l).toVar();
|
|
9382
9383
|
return p(u.greaterThanEqual(1e-20), () => {
|
|
9383
9384
|
let t = Te(u).toVar(), c = l.div(t).toVar(), d = k(c.negate(), e.direction).toVar(), f = D(e.angle).toVar();
|
|
@@ -9402,7 +9403,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9402
9403
|
lightType: c,
|
|
9403
9404
|
selectionTotalWeight: A(0)
|
|
9404
9405
|
});
|
|
9405
|
-
}),
|
|
9406
|
+
}), sd = f(([e, t, n]) => {
|
|
9406
9407
|
let r = T(!1).toVar(), i = H(0, 1, 0).toVar(), a = H(0).toVar(), o = A(0).toVar(), s = A(0).toVar(), c = j(2).toVar(), l = e.position.sub(t).toVar(), u = k(l, l).toVar();
|
|
9407
9408
|
return p(u.greaterThanEqual(1e-20), () => {
|
|
9408
9409
|
let t = Te(u).toVar(), d = l.div(t), f = Ks({
|
|
@@ -9420,14 +9421,14 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9420
9421
|
lightType: c,
|
|
9421
9422
|
selectionTotalWeight: A(0)
|
|
9422
9423
|
});
|
|
9423
|
-
}),
|
|
9424
|
+
}), cd = f(([e, t, n, r, i]) => {
|
|
9424
9425
|
let a = T(!1).toVar(), o = H(0, 1, 0).toVar(), s = H(0).toVar(), c = A(0).toVar();
|
|
9425
9426
|
return p(e.intensity.greaterThan(0), () => {
|
|
9426
9427
|
let l = F(e.direction).toVar(), u = e.color.mul(e.intensity).mul(Zs(e, t)).toVar();
|
|
9427
9428
|
o.assign(l), c.assign(n), p(e.angle.greaterThan(0), () => {
|
|
9428
|
-
let t = D(e.angle.mul(.5)).toVar(), a = P(t, A(1), r).toVar(), s = Te(N(A(0), A(1).sub(a.mul(a)))).toVar(), d = A(
|
|
9429
|
+
let t = D(e.angle.mul(.5)).toVar(), a = P(t, A(1), r).toVar(), s = Te(N(A(0), A(1).sub(a.mul(a)))).toVar(), d = A(td).mul(i).toVar(), f = F(O(I(_(l.x).greaterThan(.9), H(0, 1, 0), H(1, 0, 0)), l)).toVar(), p = O(l, f).toVar();
|
|
9429
9430
|
o.assign(F(l.mul(a).add(f.mul(D(d)).add(p.mul(Ce(d))).mul(s))));
|
|
9430
|
-
let m = A(
|
|
9431
|
+
let m = A(td).mul(N(A(1).sub(t), 1e-10)).toVar();
|
|
9431
9432
|
u.assign(u.div(m)), c.assign(n.div(m));
|
|
9432
9433
|
}), s.assign(u), a.assign(T(!0));
|
|
9433
9434
|
}), zs({
|
|
@@ -9439,7 +9440,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9439
9440
|
lightType: j(0),
|
|
9440
9441
|
selectionTotalWeight: A(0)
|
|
9441
9442
|
});
|
|
9442
|
-
}),
|
|
9443
|
+
}), ld = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, h, g, _, v, y]) => {
|
|
9443
9444
|
let b = T(!1).toVar(), x = H(0, 1, 0).toVar(), S = H(0).toVar(), C = A(0).toVar(), w = A(0).toVar(), E = j(2).toVar(), D = A(0).toVar(), O = d.add(h).add(_).add(y).toVar();
|
|
9444
9445
|
return p(O.greaterThan(j(0)), () => {
|
|
9445
9446
|
let ee = j(Xn + 64).toVar(), k = ee.add(d).toVar(), te = k.add(h).toVar(), ne = te.add(_).toVar(), re = j(-1).toVar(), ie = j(-1).toVar(), ae = A(0).toVar();
|
|
@@ -9499,7 +9500,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9499
9500
|
p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(d))), () => {
|
|
9500
9501
|
let d = Fs.wrap(Vs(u, t.sub(m)));
|
|
9501
9502
|
p(d.intensity.greaterThan(0), () => {
|
|
9502
|
-
let t = zs.wrap(
|
|
9503
|
+
let t = zs.wrap(cd(d, e, n, r.y, sr(o, j(0), l.add(j(14)), a, s, c)));
|
|
9503
9504
|
b.assign(t.valid), x.assign(t.direction), S.assign(t.emission), C.assign(t.distance), w.assign(t.pdf), E.assign(t.lightType), i.assign(T(!0));
|
|
9504
9505
|
});
|
|
9505
9506
|
}), m.addAssign(d);
|
|
@@ -9507,7 +9508,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9507
9508
|
p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(h))), () => {
|
|
9508
9509
|
let u = Is.wrap(Hs(f, t.sub(m)));
|
|
9509
9510
|
p(u.intensity.greaterThan(0), () => {
|
|
9510
|
-
let t = V(r.y, sr(o, j(0), l.add(j(15)), a, s, c)).toVar(), d = zs.wrap(
|
|
9511
|
+
let t = V(r.y, sr(o, j(0), l.add(j(15)), a, s, c)).toVar(), d = zs.wrap(ad(u, e, t, n));
|
|
9511
9512
|
b.assign(d.valid), x.assign(d.direction), S.assign(d.emission), C.assign(d.distance), w.assign(d.pdf), E.assign(d.lightType), i.assign(T(!0));
|
|
9512
9513
|
});
|
|
9513
9514
|
}), m.addAssign(h);
|
|
@@ -9515,7 +9516,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9515
9516
|
p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(_))), () => {
|
|
9516
9517
|
let r = Ls.wrap(Us(g, t.sub(m)));
|
|
9517
9518
|
p(r.intensity.greaterThan(0), () => {
|
|
9518
|
-
let t = zs.wrap(
|
|
9519
|
+
let t = zs.wrap(sd(r, e, n));
|
|
9519
9520
|
b.assign(t.valid), x.assign(t.direction), S.assign(t.emission), C.assign(t.distance), w.assign(t.pdf), E.assign(t.lightType), i.assign(T(!0));
|
|
9520
9521
|
});
|
|
9521
9522
|
}), m.addAssign(_);
|
|
@@ -9523,7 +9524,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9523
9524
|
p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(y))), () => {
|
|
9524
9525
|
let r = Rs.wrap(Ws(v, t.sub(m)));
|
|
9525
9526
|
p(r.intensity.greaterThan(0), () => {
|
|
9526
|
-
let t = zs.wrap(
|
|
9527
|
+
let t = zs.wrap(od(r, e, n));
|
|
9527
9528
|
b.assign(t.valid), x.assign(t.direction), S.assign(t.emission), C.assign(t.distance), w.assign(t.pdf), E.assign(t.lightType), i.assign(T(!0));
|
|
9528
9529
|
});
|
|
9529
9530
|
});
|
|
@@ -9531,16 +9532,16 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9531
9532
|
}).Else(() => {
|
|
9532
9533
|
let t = ae.div(N(D, 1e-10)).toVar();
|
|
9533
9534
|
p(re.equal(j(0)).and(ie.greaterThanEqual(j(0))), () => {
|
|
9534
|
-
let n = Fs.wrap(Vs(u, ie)), i = zs.wrap(
|
|
9535
|
+
let n = Fs.wrap(Vs(u, ie)), i = zs.wrap(cd(n, e, t, r.y, sr(o, j(0), l.add(j(14)), a, s, c)));
|
|
9535
9536
|
x.assign(i.direction), S.assign(i.emission), C.assign(i.distance), w.assign(i.pdf), E.assign(i.lightType), b.assign(i.valid);
|
|
9536
9537
|
}), p(re.equal(j(1)).and(ie.greaterThanEqual(j(0))), () => {
|
|
9537
|
-
let n = Is.wrap(Hs(f, ie)), i = V(r.y, sr(o, j(0), l.add(j(15)), a, s, c)).toVar(), u = zs.wrap(
|
|
9538
|
+
let n = Is.wrap(Hs(f, ie)), i = V(r.y, sr(o, j(0), l.add(j(15)), a, s, c)).toVar(), u = zs.wrap(ad(n, e, i, t));
|
|
9538
9539
|
b.assign(u.valid), x.assign(u.direction), S.assign(u.emission), C.assign(u.distance), w.assign(u.pdf), E.assign(u.lightType);
|
|
9539
9540
|
}), p(re.equal(j(2)).and(ie.greaterThanEqual(j(0))), () => {
|
|
9540
|
-
let n = Ls.wrap(Us(g, ie)), r = zs.wrap(
|
|
9541
|
+
let n = Ls.wrap(Us(g, ie)), r = zs.wrap(sd(n, e, t));
|
|
9541
9542
|
b.assign(r.valid), x.assign(r.direction), S.assign(r.emission), C.assign(r.distance), w.assign(r.pdf), E.assign(r.lightType);
|
|
9542
9543
|
}), p(re.equal(j(3)).and(ie.greaterThanEqual(j(0))), () => {
|
|
9543
|
-
let n = Rs.wrap(Ws(v, ie)), r = zs.wrap(
|
|
9544
|
+
let n = Rs.wrap(Ws(v, ie)), r = zs.wrap(od(n, e, t));
|
|
9544
9545
|
b.assign(r.valid), x.assign(r.direction), S.assign(r.emission), C.assign(r.distance), w.assign(r.pdf), E.assign(r.lightType);
|
|
9545
9546
|
});
|
|
9546
9547
|
});
|
|
@@ -9553,19 +9554,19 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9553
9554
|
lightType: E,
|
|
9554
9555
|
selectionTotalWeight: D
|
|
9555
9556
|
});
|
|
9556
|
-
}),
|
|
9557
|
-
let ce = H(0).toVar(), le = H(0).toVar(), ue = e.add(n.mul(.001)).toVar(), de = f(([e, t, n]) => ks(e, t, n,
|
|
9557
|
+
}), ud = f(([e, t]) => N(Oo(e, t), 1e-8)), dd = f(([e, t, n, r]) => ud(r, _a.wrap(Va(n, e, t, r)))), fd = f(([e, t, n, r, i, a, o, s, c, l, u, d, h, g, _, v, y, b, x, S, C, w, T, E, D, O, ee, te, ne, re, ie, ae, oe, M]) => {
|
|
9558
|
+
let ce = H(0).toVar(), le = H(0).toVar(), ue = e.add(n.mul(.001)).toVar(), de = f(([e, t, n]) => ks(e, t, n, Wu, T, E, D)), fe = v.add(b).add(S).add(w).toVar(), pe = fe.greaterThan(j(0)).toVar(), P = A(0).toVar();
|
|
9558
9559
|
return p(pe, () => {
|
|
9559
|
-
let a = or(u, j(0), g.add(j(2)), l, d, h).toVar(), o = zs.wrap(
|
|
9560
|
+
let a = or(u, j(0), g.add(j(2)), l, d, h).toVar(), o = zs.wrap(ld(e, t, r, a, c, l, u, d, h, g, _, v, y, b, x, S, C, w));
|
|
9560
9561
|
P.assign(o.selectionTotalWeight), p(o.valid.and(o.pdf.greaterThan(0)), () => {
|
|
9561
9562
|
let a = N(A(0), k(t, o.direction)).toVar();
|
|
9562
9563
|
p(a.greaterThan(0).and(Gs({
|
|
9563
9564
|
direction: o.direction,
|
|
9564
9565
|
surfaceNormal: n
|
|
9565
9566
|
})), () => {
|
|
9566
|
-
let n = e.add(o.direction.mul(o.distance)).sub(ue).toVar(), s = se(n).toVar(), c = de(ue, n.div(s), s.mul(
|
|
9567
|
+
let n = e.add(o.direction.mul(o.distance)).sub(ue).toVar(), s = se(n).toVar(), c = de(ue, n.div(s), s.mul(nd));
|
|
9567
9568
|
p(c.greaterThan(0).or(M), () => {
|
|
9568
|
-
let e = _a.wrap(Va(t, i, o.direction, r)), n =
|
|
9569
|
+
let e = _a.wrap(Va(t, i, o.direction, r)), n = $u(r, e), s = ud(r, e).toVar(), l = A(1).toVar();
|
|
9569
9570
|
p(s.greaterThan(0).and(o.lightType.equal(j(1))), () => {
|
|
9570
9571
|
l.assign(La({
|
|
9571
9572
|
pdf1: o.pdf,
|
|
@@ -9600,14 +9601,14 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9600
9601
|
});
|
|
9601
9602
|
});
|
|
9602
9603
|
}), p(c.greaterThanEqual(j(0)), () => {
|
|
9603
|
-
let l = Is.wrap(Hs(y, c)), u = e.add(a.mul(n)).sub(ue).toVar(), d = se(u).toVar(), f = de(ue, u.div(d), d.mul(
|
|
9604
|
+
let l = Is.wrap(Hs(y, c)), u = e.add(a.mul(n)).sub(ue).toVar(), d = se(u).toVar(), f = de(ue, u.div(d), d.mul(nd));
|
|
9604
9605
|
p(f.greaterThan(0).or(M), () => {
|
|
9605
9606
|
let c = N(A(0), k(a, l.normal).negate()).toVar();
|
|
9606
9607
|
p(c.greaterThan(0), () => {
|
|
9607
9608
|
let a = rc(e, l.position.sub(l.u).sub(l.v), l.u.mul(2), l.v.mul(2)).toVar(), u = n.mul(n).div(N(l.area.mul(c), Ea)), d = I(l.shape.lessThan(.5).and(a.greaterThan(1e-5)), A(1).div(N(a, 1e-10)), u).toVar(), m = Ms(l, e, t, r), h = I(P.greaterThan(0), m.div(N(P, 1e-10)), A(1).div(N(A(fe), 1))), g = La({
|
|
9608
9609
|
pdf1: o,
|
|
9609
9610
|
pdf2: d.mul(h).toVar()
|
|
9610
|
-
}).toVar(), _ =
|
|
9611
|
+
}).toVar(), _ = id(l).mul(rd(c, l.spread)).mul(s).mul(i).mul(g).div(N(o, 1e-10));
|
|
9611
9612
|
ce.addAssign(_.mul(f)), p(M, () => {
|
|
9612
9613
|
le.addAssign(_);
|
|
9613
9614
|
});
|
|
@@ -9616,7 +9617,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9616
9617
|
});
|
|
9617
9618
|
});
|
|
9618
9619
|
}), p(oe, () => {
|
|
9619
|
-
let e = or(u, j(0), g.add(j(1)), l, d, h).toVar(), a = H(0).toVar(), o =
|
|
9620
|
+
let e = or(u, j(0), g.add(j(1)), l, d, h).toVar(), a = H(0).toVar(), o = Yu(O, ne, te, ee, re, ie, ae, e, a).toVar(), s = o.xyz.toVar(), c = o.w.toVar();
|
|
9620
9621
|
p(c.greaterThan(0), () => {
|
|
9621
9622
|
let e = N(A(0), k(t, s)).toVar();
|
|
9622
9623
|
p(e.greaterThan(0).and(Gs({
|
|
@@ -9625,7 +9626,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9625
9626
|
})), () => {
|
|
9626
9627
|
let n = de(ue, s, A(0x56bc75e2d63100000));
|
|
9627
9628
|
p(n.greaterThan(0).or(M), () => {
|
|
9628
|
-
let o = _a.wrap(Va(t, i, s, r)), l =
|
|
9629
|
+
let o = _a.wrap(Va(t, i, s, r)), l = $u(r, o), u = ud(r, o).toVar(), d = I(u.greaterThan(0), Ra({
|
|
9629
9630
|
pdf1: c,
|
|
9630
9631
|
pdf2: u
|
|
9631
9632
|
}), A(1)).toVar(), f = a.mul(l).mul(e).mul(d).div(N(c, 1e-10));
|
|
@@ -9639,7 +9640,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9639
9640
|
shadowed: ce,
|
|
9640
9641
|
unoccluded: le
|
|
9641
9642
|
});
|
|
9642
|
-
}),
|
|
9643
|
+
}), pd = f(([e, t, n, r, i, a, o, s, c, l, u, d]) => {
|
|
9643
9644
|
let f = H(0).toVar(), m = H(0).toVar(), h = A(0).toVar();
|
|
9644
9645
|
return p(r.greaterThan(0).not(), () => {
|
|
9645
9646
|
let n = or(c, j(0), d.add(j(8)), s, l, u);
|
|
@@ -9652,7 +9653,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9652
9653
|
throughput: m,
|
|
9653
9654
|
combinedPdf: h
|
|
9654
9655
|
});
|
|
9655
|
-
}),
|
|
9656
|
+
}), md = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m, h]) => {
|
|
9656
9657
|
let g = H(0).toVar(), _ = H(0).toVar(), v = A(0).toVar(), y = T(!1).toVar(), b = H(1).toVar(), x = f.toVar();
|
|
9657
9658
|
p(d.not(), () => {
|
|
9658
9659
|
p(m, () => {
|
|
@@ -9708,7 +9709,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9708
9709
|
g.assign(u.direction), v.assign(N(x.transmission.mul(u.pdf), ka)), b.assign(u.colorWeight), y.assign(!0);
|
|
9709
9710
|
}), p(y.not(), () => {
|
|
9710
9711
|
let r = _a.wrap(Va(t, e, g, n));
|
|
9711
|
-
_.assign(
|
|
9712
|
+
_.assign($u(n, r)), v.assign(Eo(n, x, r));
|
|
9712
9713
|
}), v.assign(N(v, ka)), ma({
|
|
9713
9714
|
direction: g,
|
|
9714
9715
|
value: _,
|
|
@@ -9716,7 +9717,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9716
9717
|
isTransmission: y,
|
|
9717
9718
|
colorWeight: b
|
|
9718
9719
|
});
|
|
9719
|
-
}),
|
|
9720
|
+
}), hd = /* @__PURE__ */ W("\n fn regularizePathContribution( contribution: vec3f, pathLength: f32, fireflyThreshold: f32, frame: i32 ) -> vec3f {\n // Indirect-only clamp: pathLength 0 is a direct/primary contribution (bounce-0 hit, direct NEE,\n // or a directly-viewed backdrop/sun) — that is signal, not a firefly, and clamping it darkens\n // legitimately bright pixels. Fireflies arise on indirect bounces, so only suppress pathLength>=1.\n if ( pathLength < 0.5 ) {\n return contribution;\n }\n let threshold = calculateFireflyThreshold( fireflyThreshold, i32( pathLength ), frame );\n return applySoftSuppressionRGB( contribution, threshold, 0.5f );\n }\n", [Ha, Wa]), gd = /* @__PURE__ */ W("\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"), _d = f(([e, t, n, r, i, a, o, s, c, l]) => {
|
|
9720
9721
|
let u = A(1).toVar();
|
|
9721
9722
|
return p(e.greaterThanEqual(j(3)), () => {
|
|
9722
9723
|
let d = N(N(N(t.x, t.y), t.z), 0).toVar();
|
|
@@ -9767,11 +9768,11 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9767
9768
|
});
|
|
9768
9769
|
});
|
|
9769
9770
|
}), u;
|
|
9770
|
-
}),
|
|
9771
|
+
}), vd = An({
|
|
9771
9772
|
brdf: "vec3",
|
|
9772
9773
|
L: "vec3",
|
|
9773
9774
|
pdf: "float"
|
|
9774
|
-
}),
|
|
9775
|
+
}), yd = f(([e, t, n, r, i, a, o, s, c]) => {
|
|
9775
9776
|
let l = t.normal, u = e.direction.negate(), d = N(n.clearcoatRoughness, Oa), f = N(n.roughness, Oa), m = ha.wrap(Do(n)).toVar(), h = m.clearcoat.toVar(), g = m.specular.toVar(), _ = sr(a, j(0), c.add(j(13)), i, o, s), v = H(0).toVar(), y = H(0).toVar();
|
|
9776
9777
|
p(_.lessThan(h), () => {
|
|
9777
9778
|
let e = za({ N: l });
|
|
@@ -9804,22 +9805,22 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9804
9805
|
})), y.assign(F(u.add(v)));
|
|
9805
9806
|
});
|
|
9806
9807
|
let b = _a.wrap(Va(l, u, v, n)), x = N(Eo(n, m, b), .001);
|
|
9807
|
-
return
|
|
9808
|
-
brdf:
|
|
9808
|
+
return vd({
|
|
9809
|
+
brdf: $u(n, b),
|
|
9809
9810
|
L: v,
|
|
9810
9811
|
pdf: x
|
|
9811
9812
|
});
|
|
9812
|
-
}),
|
|
9813
|
+
}), bd = 32, xd = 16, Sd = 5, Cd = 8, wd = An({
|
|
9813
9814
|
hitPoint: "vec3",
|
|
9814
9815
|
uv: "vec2",
|
|
9815
9816
|
normal: "vec3",
|
|
9816
9817
|
height: "float"
|
|
9817
|
-
}),
|
|
9818
|
-
let a = t.hitPoint.toVar(), o = t.uv.toVar(), s = t.normal.toVar(), c = A(0).toVar(), l = t.triangleIndex, u = $(n, l, j(0), j(
|
|
9818
|
+
}), Td = f(([e, t, n, r, i]) => {
|
|
9819
|
+
let a = t.hitPoint.toVar(), o = t.uv.toVar(), s = t.normal.toVar(), c = A(0).toVar(), l = t.triangleIndex, u = $(n, l, j(0), j(Cd)).xyz.toVar(), d = $(n, l, j(1), j(Cd)).xyz, f = $(n, l, j(2), j(Cd)).xyz, h = $(n, l, j(6), j(Cd)).toVar(), g = $(n, l, j(7), j(Cd)), v = h.xy.toVar(), y = h.zw, b = g.xy, x = d.sub(u).toVar(), S = f.sub(u).toVar(), C = y.sub(v).toVar(), w = b.sub(v).toVar(), T = C.x.mul(w.y).sub(w.x.mul(C.y)).toVar();
|
|
9819
9820
|
return p(_(T).greaterThan(1e-8), () => {
|
|
9820
9821
|
let n = A(1).div(T), l = x.mul(w.y).sub(S.mul(C.y)).mul(n).toVar(), u = S.mul(C.x).sub(x.mul(w.x)).mul(n).toVar(), d = t.normal.toVar(), f = r.displacementScale.div(A(10)), h = e.direction, g = k(h, d).toVar(), v = h.sub(d.mul(g)).toVar(), y = k(l, l), b = k(l, u), E = k(u, u), D = y.mul(E).sub(b.mul(b)).toVar();
|
|
9821
9822
|
p(_(D).greaterThan(1e-10), () => {
|
|
9822
|
-
let e = A(1).div(D), n = k(v, l), x = k(v, u), S = V(E.mul(n).sub(b.mul(x)).mul(e), y.mul(x).sub(b.mul(n)).mul(e)).toVar(), C = g.toVar(), w = N(_(C), .001), T = f.div(w).toVar(), O = j(i.equal(j(0)).select(j(
|
|
9823
|
+
let e = A(1).div(D), n = k(v, l), x = k(v, u), S = V(E.mul(n).sub(b.mul(x)).mul(e), y.mul(x).sub(b.mul(n)).mul(e)).toVar(), C = g.toVar(), w = N(_(C), .001), T = f.div(w).toVar(), O = j(i.equal(j(0)).select(j(bd), j(xd))).toVar(), ee = T.negate().toVar(), te = T.sub(ee).div(A(O)).toVar(), ne = ee.toVar(), re = ee.toVar(), ie = j(0).toVar();
|
|
9823
9824
|
m({
|
|
9824
9825
|
start: j(0),
|
|
9825
9826
|
end: O,
|
|
@@ -9838,7 +9839,7 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9838
9839
|
let e = ne.toVar(), n = re.toVar();
|
|
9839
9840
|
m({
|
|
9840
9841
|
start: j(0),
|
|
9841
|
-
end: j(
|
|
9842
|
+
end: j(Sd),
|
|
9842
9843
|
type: "int",
|
|
9843
9844
|
condition: "<"
|
|
9844
9845
|
}, () => {
|
|
@@ -9853,13 +9854,13 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9853
9854
|
a.assign(_), o.assign(g), s.assign(k), c.assign(y);
|
|
9854
9855
|
});
|
|
9855
9856
|
});
|
|
9856
|
-
}),
|
|
9857
|
+
}), wd({
|
|
9857
9858
|
hitPoint: a,
|
|
9858
9859
|
uv: o,
|
|
9859
9860
|
normal: s,
|
|
9860
9861
|
height: c
|
|
9861
9862
|
});
|
|
9862
|
-
}),
|
|
9863
|
+
}), Ed = An({
|
|
9863
9864
|
position: "vec3",
|
|
9864
9865
|
normal: "vec3",
|
|
9865
9866
|
emission: "vec3",
|
|
@@ -9869,40 +9870,40 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9869
9870
|
area: "float",
|
|
9870
9871
|
cosThetaLight: "float",
|
|
9871
9872
|
valid: "bool"
|
|
9872
|
-
}),
|
|
9873
|
+
}), Dd = An({
|
|
9873
9874
|
contribution: "vec3",
|
|
9874
9875
|
hasEmissive: "bool",
|
|
9875
9876
|
emissionOnly: "vec3",
|
|
9876
9877
|
distance: "float"
|
|
9877
|
-
}),
|
|
9878
|
+
}), Od = f(([e, t, n, r]) => {
|
|
9878
9879
|
let i = Te(r.x), a = A(1).sub(i), o = r.y.mul(i), s = A(1).sub(a).sub(o);
|
|
9879
9880
|
return e.mul(a).add(t.mul(o)).add(n.mul(s));
|
|
9880
|
-
}),
|
|
9881
|
+
}), kd = f(([e, t, n]) => se(O(t.sub(e), n.sub(e))).mul(.5)), Ad = f(([e, t, n, r]) => {
|
|
9881
9882
|
let i = F(e.sub(r)), a = F(t.sub(r)), o = F(n.sub(r)), s = _(k(i, O(a, o))), c = A(1).add(k(a, o)).add(k(i, o)).add(k(i, a));
|
|
9882
9883
|
return N(A(2).mul(b(s, N(c, A(1e-10)))), A(0));
|
|
9883
|
-
}),
|
|
9884
|
+
}), jd = f(([e, t, n, r]) => {
|
|
9884
9885
|
let i = t.sub(e), a = n.sub(e), o = n.sub(t), s = N(k(i, i), N(k(a, a), k(o, o))), c = O(i, a), l = k(c, c), u = T(!1).toVar();
|
|
9885
9886
|
return p(l.greaterThan(1e-20), () => {
|
|
9886
9887
|
let t = k(c, r.sub(e)), n = t.mul(t).div(l), i = s.mul(s).lessThan(l.mul(64));
|
|
9887
9888
|
u.assign(s.greaterThan(n).and(i));
|
|
9888
9889
|
}), u;
|
|
9889
|
-
}),
|
|
9890
|
+
}), Md = An({
|
|
9890
9891
|
direction: "vec3",
|
|
9891
9892
|
position: "vec3",
|
|
9892
9893
|
solidAngle: "float",
|
|
9893
9894
|
valid: "bool"
|
|
9894
|
-
}),
|
|
9895
|
+
}), Nd = f(([e]) => {
|
|
9895
9896
|
let t = se(e);
|
|
9896
9897
|
return I(t.greaterThan(1e-10), e.div(t), H(0));
|
|
9897
|
-
}),
|
|
9898
|
-
let a =
|
|
9898
|
+
}), Pd = f(([e, t, n, r, i]) => {
|
|
9899
|
+
let a = Md({
|
|
9899
9900
|
direction: H(0),
|
|
9900
9901
|
position: H(0),
|
|
9901
9902
|
solidAngle: A(0),
|
|
9902
9903
|
valid: !1
|
|
9903
|
-
}).toVar(), o = F(e.sub(r)), s = F(t.sub(r)), c = F(n.sub(r)), l =
|
|
9904
|
+
}).toVar(), o = F(e.sub(r)), s = F(t.sub(r)), c = F(n.sub(r)), l = Ad(e, t, n, r);
|
|
9904
9905
|
return a.solidAngle.assign(l), p(l.greaterThan(1e-7), () => {
|
|
9905
|
-
let u = E(k(
|
|
9906
|
+
let u = E(k(Nd(O(o, s)), Nd(O(o, c))), -1, 1), d = Te(N(A(1).sub(u.mul(u)), 0)), f = v(u), m = i.x.mul(l).sub(f), h = Ce(m), g = D(m), y = E(k(o, s), -1, 1), b = g.sub(u), x = h.add(d.mul(y)), S = x.mul(g).sub(b.mul(h)).mul(u).sub(x), C = x.mul(h).add(b.mul(g)).mul(d), w = E(I(_(C).greaterThan(1e-10), S.div(C), A(1)), -1, 1), T = k(c, o), ee = Nd(c.sub(o.mul(T))), te = Te(N(A(1).sub(w.mul(w)), 0)), ne = F(o.mul(w).add(ee.mul(te))), re = k(ne, s), ie = A(1).sub(i.y.mul(A(1).sub(re))), ae = Te(N(A(1).sub(ie.mul(ie)), 0)), oe = Nd(ne.sub(s.mul(re))), j = F(s.mul(ie).add(oe.mul(ae))), M = F(O(t.sub(e), n.sub(e))), se = k(M, j);
|
|
9906
9907
|
p(_(se).greaterThan(1e-10), () => {
|
|
9907
9908
|
let t = k(M, e.sub(r)).div(se);
|
|
9908
9909
|
p(t.greaterThan(0), () => {
|
|
@@ -9910,15 +9911,15 @@ var Gu = /* @__PURE__ */ W("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
9910
9911
|
});
|
|
9911
9912
|
});
|
|
9912
9913
|
}), a;
|
|
9913
|
-
}),
|
|
9914
|
+
}), Fd = f(([e, t, n, r]) => {
|
|
9914
9915
|
let i = n.sub(t), a = r.sub(t), o = e.sub(t), s = k(i, i), c = k(i, a), l = k(a, a), u = k(o, i), d = k(o, a), f = A(1).div(N(s.mul(l).sub(c.mul(c)), A(1e-10))), p = l.mul(u).sub(c.mul(d)).mul(f), m = s.mul(d).sub(c.mul(u)).mul(f);
|
|
9915
9916
|
return H(A(1).sub(p).sub(m), p, m);
|
|
9916
|
-
}),
|
|
9917
|
+
}), Id = f(([e, t, n, r]) => {
|
|
9917
9918
|
let i = Te(r.x), a = A(1).sub(i), o = r.y.mul(i), s = A(1).sub(a).sub(o);
|
|
9918
9919
|
return F(e.mul(a).add(t.mul(o)).add(n.mul(s)));
|
|
9919
9920
|
});
|
|
9920
9921
|
f(([e]) => e.emissiveIntensity.greaterThan(0).and(se(e.emissive).greaterThan(0)));
|
|
9921
|
-
var
|
|
9922
|
+
var Ld = 8, Rd = 2, zd = An({
|
|
9922
9923
|
v0: "vec3",
|
|
9923
9924
|
v1: "vec3",
|
|
9924
9925
|
v2: "vec3",
|
|
@@ -9926,9 +9927,9 @@ var Id = 8, Ld = 2, Rd = An({
|
|
|
9926
9927
|
n1: "vec3",
|
|
9927
9928
|
n2: "vec3",
|
|
9928
9929
|
materialIndex: "int"
|
|
9929
|
-
}),
|
|
9930
|
-
let n = $(t, e, j(0), j(
|
|
9931
|
-
return
|
|
9930
|
+
}), Bd = f(([e, t]) => {
|
|
9931
|
+
let n = $(t, e, j(0), j(Ld)), r = $(t, e, j(1), j(Ld)), i = $(t, e, j(2), j(Ld)), a = $(t, e, j(3), j(Ld)), o = $(t, e, j(4), j(Ld)), s = $(t, e, j(5), j(Ld)), c = $(t, e, j(7), j(Ld));
|
|
9932
|
+
return zd({
|
|
9932
9933
|
v0: n.xyz,
|
|
9933
9934
|
v1: r.xyz,
|
|
9934
9935
|
v2: i.xyz,
|
|
@@ -9937,27 +9938,27 @@ var Id = 8, Ld = 2, Rd = An({
|
|
|
9937
9938
|
n2: s.xyz,
|
|
9938
9939
|
materialIndex: j(c.z)
|
|
9939
9940
|
});
|
|
9940
|
-
}),
|
|
9941
|
-
let s =
|
|
9942
|
-
return p(
|
|
9943
|
-
let e =
|
|
9941
|
+
}), Vd = f(([e, t, n, r, i, a, o]) => {
|
|
9942
|
+
let s = zd.wrap(Bd(e, i)), c = kd(s.v0, s.v1, s.v2), l = $(a, s.materialIndex, j(Ma.EMISSIVE_ROUGHNESS), ja), u = $(a, s.materialIndex, j(Ma.IOR_TRANSMISSION), ja), d = N(l.x.mul(.2126).add(l.y.mul(.7152)).add(l.z.mul(.0722)).mul(u.a).mul(c), A(1e-10)).div(N(o, A(1e-10))), f = A(0).toVar();
|
|
9943
|
+
return p(jd(s.v0, s.v1, s.v2, r), () => {
|
|
9944
|
+
let e = Ad(s.v0, s.v1, s.v2, r);
|
|
9944
9945
|
f.assign(d.div(N(e, A(1e-10))));
|
|
9945
9946
|
}).Else(() => {
|
|
9946
9947
|
let e = F(O(s.v1.sub(s.v0), s.v2.sub(s.v0))), r = N(k(n.negate(), e), .001), i = t.mul(t), a = d.div(c);
|
|
9947
9948
|
f.assign(a.mul(i).div(r));
|
|
9948
9949
|
}), N(f, ka);
|
|
9949
|
-
}),
|
|
9950
|
+
}), Hd = f(([e, t, n, r]) => {
|
|
9950
9951
|
let i = j(0).toVar(), a = n.sub(1).toVar();
|
|
9951
9952
|
return m(i.lessThan(a), () => {
|
|
9952
|
-
let n = i.add(a).div(2).toVar(), o = e.element(t.add(n.mul(j(
|
|
9953
|
+
let n = i.add(a).div(2).toVar(), o = e.element(t.add(n.mul(j(Rd)))).b;
|
|
9953
9954
|
p(o.lessThan(r), () => {
|
|
9954
9955
|
i.assign(n.add(1));
|
|
9955
9956
|
}).Else(() => {
|
|
9956
9957
|
a.assign(n);
|
|
9957
9958
|
});
|
|
9958
9959
|
}), i;
|
|
9959
|
-
}),
|
|
9960
|
-
let f =
|
|
9960
|
+
}), Ud = f(([e, t, n, r, i, a, o, s, c, l, u, d]) => {
|
|
9961
|
+
let f = Ed({
|
|
9961
9962
|
position: H(0),
|
|
9962
9963
|
normal: H(0),
|
|
9963
9964
|
emission: H(0),
|
|
@@ -9969,38 +9970,38 @@ var Id = 8, Ld = 2, Rd = An({
|
|
|
9969
9970
|
valid: !1
|
|
9970
9971
|
}).toVar();
|
|
9971
9972
|
return p(l.greaterThan(j(0)), () => {
|
|
9972
|
-
let m =
|
|
9973
|
-
p(
|
|
9974
|
-
let n =
|
|
9973
|
+
let m = Hd(s, c, l, sr(r, j(0), o.add(j(1)), n, i, a)).toVar(), h = c.add(m.mul(j(Rd))), g = s.element(h), _ = s.element(h.add(1)), v = j(g.r), y = N(g.g, A(1e-10)), b = _.xyz, x = _.w, S = zd.wrap(Bd(v, d)), C = or(r, j(0), o.add(j(3)), n, i, a).toVar(), w = F(O(S.v1.sub(S.v0), S.v2.sub(S.v0)));
|
|
9974
|
+
p(jd(S.v0, S.v1, S.v2, e), () => {
|
|
9975
|
+
let n = Md.wrap(Pd(S.v0, S.v1, S.v2, e, C));
|
|
9975
9976
|
p(n.valid.and(n.solidAngle.greaterThan(1e-7)), () => {
|
|
9976
9977
|
let r = n.direction, i = n.position, a = k(r, t), o = k(r, w.negate());
|
|
9977
9978
|
p(a.greaterThan(0).and(o.greaterThan(0)), () => {
|
|
9978
|
-
let t =
|
|
9979
|
+
let t = Fd(i, S.v0, S.v1, S.v2), a = F(S.n0.mul(t.x).add(S.n1.mul(t.y)).add(S.n2.mul(t.z))), s = se(i.sub(e)), c = y.div(N(u, A(1e-10))).div(n.solidAngle);
|
|
9979
9980
|
f.position.assign(i), f.normal.assign(a), f.emission.assign(b), f.direction.assign(r), f.distance.assign(s), f.pdf.assign(N(c, ka)), f.area.assign(x), f.cosThetaLight.assign(o), f.valid.assign(!0);
|
|
9980
9981
|
});
|
|
9981
9982
|
});
|
|
9982
9983
|
}).Else(() => {
|
|
9983
|
-
let n =
|
|
9984
|
+
let n = Od(S.v0, S.v1, S.v2, C), r = Id(S.n0, S.n1, S.n2, C), i = n.sub(e), a = k(i, i), o = Te(a), s = i.div(o), c = k(s, t), l = k(s, r.negate());
|
|
9984
9985
|
p(c.greaterThan(0).and(l.greaterThan(0)), () => {
|
|
9985
9986
|
let e = y.div(N(u, A(1e-10)).mul(x)).mul(a).div(l);
|
|
9986
9987
|
f.position.assign(n), f.normal.assign(r), f.emission.assign(b), f.direction.assign(s), f.distance.assign(o), f.pdf.assign(N(e, ka)), f.area.assign(x), f.cosThetaLight.assign(l), f.valid.assign(!0);
|
|
9987
9988
|
});
|
|
9988
9989
|
});
|
|
9989
9990
|
}), f;
|
|
9990
|
-
}),
|
|
9991
|
-
let b =
|
|
9991
|
+
}), Wd = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m, h, g, _, v, y]) => {
|
|
9992
|
+
let b = Dd({
|
|
9992
9993
|
contribution: H(0),
|
|
9993
9994
|
hasEmissive: !1,
|
|
9994
9995
|
emissionOnly: H(0),
|
|
9995
9996
|
distance: A(0)
|
|
9996
|
-
}).toVar(), x =
|
|
9997
|
+
}).toVar(), x = Ed.wrap(Ud(e, t, o, s, c, l, u, f, m, h, g, _));
|
|
9997
9998
|
return p(x.valid.and(x.pdf.greaterThan(0)), () => {
|
|
9998
9999
|
b.hasEmissive.assign(!0), b.emissionOnly.assign(x.emission), b.distance.assign(x.distance);
|
|
9999
10000
|
let a = N(A(0), k(t, x.direction));
|
|
10000
10001
|
p(a.greaterThan(0).and(k(x.direction, n).greaterThan(0)), () => {
|
|
10001
10002
|
let o = y(e, n, i), s = e.add(o), c = x.distance.sub(.001), l = v(s, x.direction, c);
|
|
10002
10003
|
p(l.greaterThan(0), () => {
|
|
10003
|
-
let e = _a.wrap(Va(t, r, x.direction, i)), n =
|
|
10004
|
+
let e = _a.wrap(Va(t, r, x.direction, i)), n = $u(i, e), o = ud(i, e), s = I(o.greaterThan(0), La({
|
|
10004
10005
|
pdf1: x.pdf,
|
|
10005
10006
|
pdf2: o
|
|
10006
10007
|
}), A(1));
|
|
@@ -10008,11 +10009,11 @@ var Id = 8, Ld = 2, Rd = An({
|
|
|
10008
10009
|
});
|
|
10009
10010
|
});
|
|
10010
10011
|
}), b;
|
|
10011
|
-
}),
|
|
10012
|
-
let o = e.add(n).mul(.5), s = se(n.sub(e)), c = a.sub(o), l = N(k(c, c), A(1e-12)), u = N(l, s.mul(.5)), d = k(r, c.div(Te(l))), f = Te(N(A(1).sub(d.mul(d)), A(0))), p = s.mul(s).mul(.25), m = E(p.div(l), A(0), A(1)), h = I(l.lessThan(p), A(-1), Te(N(A(1).sub(m), A(0)))), g = Te(N(A(1).sub(h.mul(h)), A(0))), _ = Te(N(A(1).sub(i.mul(i)), A(0))), v =
|
|
10012
|
+
}), Gd = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v]) => Dd.wrap(Wd(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v)).contribution), Kd = 4, qd = 2, Jd = 32, Yd = f(([e, t, n, r]) => I(t.greaterThan(r), A(1), t.mul(r).add(e.mul(n)))), Xd = f(([e, t, n, r]) => I(t.greaterThan(r), A(0), e.mul(r).sub(t.mul(n)))), Zd = f(([e, t, n, r, i, a]) => {
|
|
10013
|
+
let o = e.add(n).mul(.5), s = se(n.sub(e)), c = a.sub(o), l = N(k(c, c), A(1e-12)), u = N(l, s.mul(.5)), d = k(r, c.div(Te(l))), f = Te(N(A(1).sub(d.mul(d)), A(0))), p = s.mul(s).mul(.25), m = E(p.div(l), A(0), A(1)), h = I(l.lessThan(p), A(-1), Te(N(A(1).sub(m), A(0)))), g = Te(N(A(1).sub(h.mul(h)), A(0))), _ = Te(N(A(1).sub(i.mul(i)), A(0))), v = Yd(f, d, _, i), y = Yd(Xd(f, d, _, i), v, g, h);
|
|
10013
10014
|
return N(I(y.greaterThan(A(0)), t.mul(y).div(u), A(0)), A(0));
|
|
10014
|
-
}),
|
|
10015
|
-
let f =
|
|
10015
|
+
}), Qd = f(([e, t, n, r, i, a, o, s, c, l, u]) => {
|
|
10016
|
+
let f = Ed({
|
|
10016
10017
|
position: H(0),
|
|
10017
10018
|
normal: H(0),
|
|
10018
10019
|
emission: H(0),
|
|
@@ -10023,12 +10024,12 @@ var Id = 8, Ld = 2, Rd = An({
|
|
|
10023
10024
|
cosThetaLight: A(0),
|
|
10024
10025
|
valid: !1
|
|
10025
10026
|
}).toVar(), h = A(1).toVar(), g = j(0).toVar(), _ = T(!1).toVar(), v = sr(r, j(0), o.add(j(1)), n, i, a).toVar();
|
|
10026
|
-
return m(
|
|
10027
|
-
let t = g.mul(j(
|
|
10027
|
+
return m(Jd, () => {
|
|
10028
|
+
let t = g.mul(j(Kd)), n = s.element(t.add(j(1))), r = s.element(t.add(j(2)));
|
|
10028
10029
|
p(n.w.greaterThan(.5), () => {
|
|
10029
10030
|
_.assign(T(!0)), d();
|
|
10030
10031
|
});
|
|
10031
|
-
let i = j(r.x), a = j(r.y), o = i.mul(j(
|
|
10032
|
+
let i = j(r.x), a = j(r.y), o = i.mul(j(Kd)), c = s.element(o), l = s.element(o.add(j(1))), u = a.mul(j(Kd)), f = s.element(u), m = s.element(u.add(j(1))), y = s.element(o.add(j(3))), b = s.element(u.add(j(3))), x = Zd(c.xyz, c.w, l.xyz, y.xyz, y.w, e), S = Zd(f.xyz, f.w, m.xyz, b.xyz, b.w, e), C = x.add(S);
|
|
10032
10033
|
p(C.lessThanEqual(A(0)), () => {
|
|
10033
10034
|
g.assign(i);
|
|
10034
10035
|
}).Else(() => {
|
|
@@ -10041,44 +10042,44 @@ var Id = 8, Ld = 2, Rd = An({
|
|
|
10041
10042
|
});
|
|
10042
10043
|
});
|
|
10043
10044
|
}), p(_, () => {
|
|
10044
|
-
let _ = g.mul(j(
|
|
10045
|
+
let _ = g.mul(j(Kd)), y = s.element(_), b = s.element(_.add(j(2))), x = j(b.x), S = j(b.y), C = N(y.w, A(1e-10)), w = v.mul(C), T = A(0).toVar(), E = x.add(S.sub(j(1))).toVar(), D = A(1e-10).toVar();
|
|
10045
10046
|
m({
|
|
10046
10047
|
start: j(0),
|
|
10047
10048
|
end: S
|
|
10048
10049
|
}, ({ i: e }) => {
|
|
10049
|
-
let t = x.add(e), n = l.add(t.mul(j(
|
|
10050
|
+
let t = x.add(e), n = l.add(t.mul(j(qd))), r = N(c.element(n).g, A(0));
|
|
10050
10051
|
T.addAssign(r), p(T.greaterThanEqual(w).and(r.greaterThan(A(0))), () => {
|
|
10051
10052
|
E.assign(t), D.assign(r), d();
|
|
10052
10053
|
});
|
|
10053
10054
|
}), h.mulAssign(D.div(C));
|
|
10054
|
-
let ee = l.add(E.mul(j(
|
|
10055
|
-
p(
|
|
10056
|
-
let n =
|
|
10055
|
+
let ee = l.add(E.mul(j(qd))), te = c.element(ee), ne = c.element(ee.add(j(1))), re = j(te.r), ie = ne.xyz, ae = ne.w, oe = zd.wrap(Bd(re, u)), M = or(r, j(0), o.add(j(3)), n, i, a).toVar(), ce = F(O(oe.v1.sub(oe.v0), oe.v2.sub(oe.v0)));
|
|
10056
|
+
p(jd(oe.v0, oe.v1, oe.v2, e), () => {
|
|
10057
|
+
let n = Md.wrap(Pd(oe.v0, oe.v1, oe.v2, e, M));
|
|
10057
10058
|
p(n.valid.and(n.solidAngle.greaterThan(A(1e-7))), () => {
|
|
10058
10059
|
let r = n.direction, i = n.position, a = k(r, t), o = k(r, ce.negate());
|
|
10059
10060
|
p(a.greaterThan(A(0)).and(o.greaterThan(A(0))), () => {
|
|
10060
|
-
let t =
|
|
10061
|
+
let t = Fd(i, oe.v0, oe.v1, oe.v2), a = F(oe.n0.mul(t.x).add(oe.n1.mul(t.y)).add(oe.n2.mul(t.z))), s = se(i.sub(e)), c = h.div(N(n.solidAngle, A(1e-10)));
|
|
10061
10062
|
f.position.assign(i), f.normal.assign(a), f.emission.assign(ie), f.direction.assign(r), f.distance.assign(s), f.pdf.assign(N(c, ka)), f.area.assign(ae), f.cosThetaLight.assign(o), f.valid.assign(!0);
|
|
10062
10063
|
});
|
|
10063
10064
|
});
|
|
10064
10065
|
}).Else(() => {
|
|
10065
|
-
let n =
|
|
10066
|
+
let n = Od(oe.v0, oe.v1, oe.v2, M), r = Id(oe.n0, oe.n1, oe.n2, M), i = n.sub(e), a = k(i, i), o = Te(a), s = i.div(o), c = k(s, t), l = k(s, r.negate());
|
|
10066
10067
|
p(c.greaterThan(A(0)).and(l.greaterThan(A(0))), () => {
|
|
10067
10068
|
let e = h.div(N(ae, A(1e-10))).mul(a).div(l);
|
|
10068
10069
|
f.position.assign(n), f.normal.assign(r), f.emission.assign(ie), f.direction.assign(s), f.distance.assign(o), f.pdf.assign(N(e, ka)), f.area.assign(ae), f.cosThetaLight.assign(l), f.valid.assign(!0);
|
|
10069
10070
|
});
|
|
10070
10071
|
});
|
|
10071
10072
|
}), f;
|
|
10072
|
-
}),
|
|
10073
|
+
}), $d = f(([e, t, n, r, i, a, o, s]) => {
|
|
10073
10074
|
let c = A(0).toVar(), l = j(e).toVar(), u = i.element(o.add(l.shiftRight(j(2)))), f = l.bitAnd(j(3)), h = I(f.equal(j(0)), u.x, I(f.equal(j(1)), u.y, I(f.equal(j(2)), u.z, u.w))).toVar();
|
|
10074
10075
|
return p(h.greaterThanEqual(A(0)), () => {
|
|
10075
10076
|
let e = j(h).toVar(), o = A(1).toVar(), u = j(0).toVar(), f = j(0).toVar(), g = T(!1).toVar();
|
|
10076
|
-
m(
|
|
10077
|
-
let t = u.mul(j(
|
|
10077
|
+
m(Jd, () => {
|
|
10078
|
+
let t = u.mul(j(Kd));
|
|
10078
10079
|
p(i.element(t.add(j(1))).w.greaterThan(.5), () => {
|
|
10079
10080
|
g.assign(T(!0)), d();
|
|
10080
10081
|
});
|
|
10081
|
-
let n = i.element(t.add(j(2))), a = j(n.x), s = j(n.y), c = a.mul(j(
|
|
10082
|
+
let n = i.element(t.add(j(2))), a = j(n.x), s = j(n.y), c = a.mul(j(Kd)), l = i.element(c), m = i.element(c.add(j(1))), h = i.element(c.add(j(3))), _ = s.mul(j(Kd)), v = i.element(_), y = i.element(_.add(j(1))), b = i.element(_.add(j(3))), x = Zd(l.xyz, l.w, m.xyz, h.xyz, h.w, r), S = Zd(v.xyz, v.w, y.xyz, b.xyz, b.w, r), C = x.add(S), w = e.shiftRight(f).bitAnd(j(1)).equal(j(1));
|
|
10082
10083
|
p(C.lessThanEqual(A(0)), () => {
|
|
10083
10084
|
p(w, () => {
|
|
10084
10085
|
o.assign(A(0)), u.assign(s);
|
|
@@ -10094,28 +10095,28 @@ var Id = 8, Ld = 2, Rd = An({
|
|
|
10094
10095
|
});
|
|
10095
10096
|
}), f.addAssign(j(1));
|
|
10096
10097
|
}), p(g.and(o.greaterThan(A(0))), () => {
|
|
10097
|
-
let e = u.mul(j(
|
|
10098
|
+
let e = u.mul(j(Kd)), f = i.element(e), h = i.element(e.add(j(2))), g = j(h.x), _ = j(h.y), v = N(f.w, A(1e-10)), y = A(0).toVar();
|
|
10098
10099
|
m({
|
|
10099
10100
|
start: j(0),
|
|
10100
10101
|
end: _
|
|
10101
10102
|
}, ({ i: e }) => {
|
|
10102
|
-
let t = g.add(e), n = i.element(a.add(t.mul(j(
|
|
10103
|
+
let t = g.add(e), n = i.element(a.add(t.mul(j(qd))));
|
|
10103
10104
|
p(j(n.r).equal(l), () => {
|
|
10104
10105
|
y.assign(N(n.g, A(0))), d();
|
|
10105
10106
|
});
|
|
10106
10107
|
}), o.mulAssign(y.div(v));
|
|
10107
|
-
let b =
|
|
10108
|
-
p(
|
|
10109
|
-
let e =
|
|
10108
|
+
let b = zd.wrap(Bd(l, s));
|
|
10109
|
+
p(jd(b.v0, b.v1, b.v2, r), () => {
|
|
10110
|
+
let e = Ad(b.v0, b.v1, b.v2, r);
|
|
10110
10111
|
c.assign(o.div(N(e, A(1e-10))));
|
|
10111
10112
|
}).Else(() => {
|
|
10112
|
-
let e = F(O(b.v1.sub(b.v0), b.v2.sub(b.v0))), r = N(k(n.negate(), e), A(.001)), i =
|
|
10113
|
+
let e = F(O(b.v1.sub(b.v0), b.v2.sub(b.v0))), r = N(k(n.negate(), e), A(.001)), i = kd(b.v0, b.v1, b.v2), a = t.mul(t), s = o.div(N(i, A(1e-10)));
|
|
10113
10114
|
c.assign(s.mul(a).div(r));
|
|
10114
10115
|
});
|
|
10115
10116
|
});
|
|
10116
10117
|
}), N(c, ka);
|
|
10117
|
-
}),
|
|
10118
|
-
function
|
|
10118
|
+
}), ef = 0x8ac7230489e80000, tf = 1e-4, nf = 1e-4, rf = .001;
|
|
10119
|
+
function af(e) {
|
|
10119
10120
|
let { bvhBuffer: t, triangleBuffer: n, materialBuffer: r, envCDFTexture: i, lightBuffer: a, rayBufferRW: o, rngBufferRW: s, hitBufferRO: c, gBufferRW: l, counters: u, activeIndicesRO: d, envTexture: g, environmentIntensity: _, envMatrix: v, enableEnvironmentLight: y, groundProjectionEnabled: b, groundProjectionRadius: x, groundProjectionHeight: w, groundProjectionLevel: D, enableGroundCatcher: O, groundCatcherHeight: ee, envTotalSum: ne, envCompensationDelta: re, envResolution: ie, directionalLightsBuffer: ae, numDirectionalLights: M, areaLightsBuffer: ce, numAreaLights: le, pointLightsBuffer: de, numPointLights: fe, spotLightsBuffer: pe, numSpotLights: me, maxBounceCount: he, maxSubsurfaceSteps: ge, maxTransparentBounces: _e, currentBounce: ve, transparentBackground: ye, backgroundIntensity: be, backgroundColor: Se, backgroundBlurriness: Ce, backgroundBlurSamples: Te, showBackground: Ee, globalIlluminationIntensity: De, cameraProjectionMatrix: Oe, cameraViewMatrix: ke, fireflyThreshold: Ae, frame: je, resolution: Me, accumFrame: L, chunkRowBase: Ne, emissiveTriangleCount: Pe, emissiveVec4Offset: Fe, emissiveTotalPower: z, emissiveBoost: Ie, totalTriangleCount: B, enableEmissiveTriangleSampling: Le, lightBVHNodeCount: Re, reverseMapVec4Offset: ze, maxRayCount: Be, auxGBufferEnabled: W } = e, Ve = W.greaterThan(R(0)), He = a !== void 0, Ue = (e, t, n, r, i) => {
|
|
10120
10121
|
let a = F(e).toVar(), o = N(n, j(1)).toVar(), s = H(0).toVar();
|
|
10121
10122
|
return m({
|
|
@@ -10125,7 +10126,7 @@ function rf(e) {
|
|
|
10125
10126
|
condition: "<"
|
|
10126
10127
|
}, ({ i: e }) => {
|
|
10127
10128
|
let n = tc(a, t, or(i, j(0), j(Xn).add(e), r, Me, je).toVar()).toVar();
|
|
10128
|
-
s.addAssign(
|
|
10129
|
+
s.addAssign(Xu({
|
|
10129
10130
|
tex: g,
|
|
10130
10131
|
samp: xe(g),
|
|
10131
10132
|
direction: n,
|
|
@@ -10138,32 +10139,32 @@ function rf(e) {
|
|
|
10138
10139
|
return f(() => {
|
|
10139
10140
|
let e = oe;
|
|
10140
10141
|
u && p(e.equal(R(0)), () => {
|
|
10141
|
-
C(u.element(R(_u.ACTIVE_RAY_COUNT)), R(0));
|
|
10142
|
+
C(u.element(R(_u.ACTIVE_RAY_COUNT)), R(0)), C(u.element(R(_u.ACTIVE_ENERGY)), R(0));
|
|
10142
10143
|
});
|
|
10143
10144
|
let m = u ? S(u.element(R(_u.ENTERING_COUNT))) : Be;
|
|
10144
10145
|
p(e.greaterThanEqual(m), () => {
|
|
10145
10146
|
h();
|
|
10146
10147
|
});
|
|
10147
10148
|
let B = d.element(e), W = Il(o, B).toVar();
|
|
10148
|
-
p(W.bitAnd(R(
|
|
10149
|
+
p(W.bitAnd(R(yu.ACTIVE)).equal(R(0)), () => {
|
|
10149
10150
|
h();
|
|
10150
10151
|
});
|
|
10151
|
-
let We = W.bitAnd(R(
|
|
10152
|
+
let We = W.bitAnd(R(yu.REDIRECTED)).equal(R(0)).toVar(), Ge = Pl(o, B).toVar(), Ke = Fl(o, B).toVar(), qe = Ll(o, B).toVar(), Je = zl(o, B).toVar(), Ye = B, Xe = s.element(B).toVar(), Ze = j(Me.x).toVar(), Qe = j(Ye).add(Ne.mul(Ze)), $e = V(A(Qe.mod(Ze)).add(.5), A(Qe.div(Ze)).add(.5)), et = j(ve).mul(j(32)), tt = lu(o, B).toVar(), nt = Zl(c, B).toVar(), rt = eu(c, B).toVar(), it = $l(c, B).toVar(), at = tu(c, B).toVar(), ot = Ql(c, B).toVar(), st = du(o, B).toVar(), ct = j(ve).toVar(), lt = fu(o, B).toVar(), ut = pu(o, B).toVar();
|
|
10152
10153
|
p(O.and(ct.equal(0)), () => {
|
|
10153
10154
|
let e = Ke.y.toVar();
|
|
10154
10155
|
p(e.abs().greaterThan(A(Ea)), () => {
|
|
10155
10156
|
let a = ee.sub(Ge.y).div(e).toVar();
|
|
10156
|
-
p(a.greaterThan(A(
|
|
10157
|
-
let e = Ge.add(Ke.mul(a)).toVar(), c = H(0, 1, 0), u = Ke.negate().toVar(), d = la.wrap(Ja()).toVar(), f = jo(c, or($e, j(0), et.add(j(7)), Xe, Me, je).toVar()).toVar(), m = f.y.mul(wa).toVar(), S = H(wa), C = fa.wrap(
|
|
10158
|
-
p(ee.lessThan(A(
|
|
10157
|
+
p(a.greaterThan(A(tf)).and(a.lessThan(nt)), () => {
|
|
10158
|
+
let e = Ge.add(Ke.mul(a)).toVar(), c = H(0, 1, 0), u = Ke.negate().toVar(), d = la.wrap(Ja()).toVar(), f = jo(c, or($e, j(0), et.add(j(7)), Xe, Me, je).toVar()).toVar(), m = f.y.mul(wa).toVar(), S = H(wa), C = fa.wrap(fd(e, c, c, d, u, f, m, S, ct, Xe, $e, Me, je, et, ae, M, ce, le, de, fe, pe, me, t, n, r, g, _, v, i, ne, re, ie, y, T(!0))).toVar(), O = N(k(C.shadowed, Aa), A(0)), ee = N(k(C.unoccluded, Aa), A(0)).toVar(), te = E(O.div(N(ee, A(nf))), 0, 1).toVar();
|
|
10159
|
+
p(ee.lessThan(A(rf)), () => {
|
|
10159
10160
|
te.assign(1);
|
|
10160
10161
|
});
|
|
10161
|
-
let oe =
|
|
10162
|
+
let oe = Qu(Ge, Ke, b, x, w, D).toVar(), se = H(0).toVar();
|
|
10162
10163
|
p(Ee, () => {
|
|
10163
10164
|
p(Ce.greaterThan(0), () => {
|
|
10164
10165
|
se.assign(Ue(oe, Ce.mul(1.3), Te, Xe, $e));
|
|
10165
10166
|
}).Else(() => {
|
|
10166
|
-
se.assign(
|
|
10167
|
+
se.assign(Xu({
|
|
10167
10168
|
tex: g,
|
|
10168
10169
|
samp: xe(g),
|
|
10169
10170
|
direction: oe,
|
|
@@ -10175,26 +10176,26 @@ function rf(e) {
|
|
|
10175
10176
|
});
|
|
10176
10177
|
let ue = I(Ee, se.mul(be), Se), P = I(ye, H(0), ue.mul(te)), F = I(ye, A(1).sub(te), A(1));
|
|
10177
10178
|
p(Ve, () => {
|
|
10178
|
-
Vl(l, Ye, c,
|
|
10179
|
+
Vl(l, Ye, c, gd({
|
|
10179
10180
|
worldPos: e,
|
|
10180
10181
|
cameraProjectionMatrix: Oe,
|
|
10181
10182
|
cameraViewMatrix: ke
|
|
10182
10183
|
}), H(1));
|
|
10183
|
-
}), Xl(o, B, U(P, F)), Jl(o, B, Ke, W.bitOr(R(
|
|
10184
|
+
}), Xl(o, B, U(P, F)), Jl(o, B, Ke, W.bitOr(R(yu.AUX_LOCKED)).bitAnd(R(~yu.ACTIVE))), s.element(B).assign(Xe), h();
|
|
10184
10185
|
});
|
|
10185
10186
|
});
|
|
10186
|
-
}), p(nt.greaterThan(
|
|
10187
|
+
}), p(nt.greaterThan(ef), () => {
|
|
10187
10188
|
let e = We.and(Ee), t = We.not().and(y), n = H(0).toVar();
|
|
10188
10189
|
p(e.or(t), () => {
|
|
10189
10190
|
let e = Ke.toVar();
|
|
10190
10191
|
p(We, () => {
|
|
10191
|
-
e.assign(
|
|
10192
|
+
e.assign(Qu(Ge, Ke, b, x, w, D));
|
|
10192
10193
|
});
|
|
10193
10194
|
let t = H(0).toVar();
|
|
10194
10195
|
p(We.and(Ce.greaterThan(0)), () => {
|
|
10195
10196
|
t.assign(Ue(e, Ce.mul(1.3), Te, Xe, $e));
|
|
10196
10197
|
}).Else(() => {
|
|
10197
|
-
t.assign(
|
|
10198
|
+
t.assign(Xu({
|
|
10198
10199
|
tex: g,
|
|
10199
10200
|
samp: xe(g),
|
|
10200
10201
|
direction: e,
|
|
@@ -10207,7 +10208,7 @@ function rf(e) {
|
|
|
10207
10208
|
p(We.not(), () => {
|
|
10208
10209
|
let e = Rl(o, B);
|
|
10209
10210
|
p(e.greaterThan(0), () => {
|
|
10210
|
-
let t =
|
|
10211
|
+
let t = Ju(g, Ke, v, ne, re, ie).w;
|
|
10211
10212
|
p(t.greaterThan(0), () => {
|
|
10212
10213
|
r.assign(Ra({
|
|
10213
10214
|
pdf1: e,
|
|
@@ -10217,22 +10218,22 @@ function rf(e) {
|
|
|
10217
10218
|
});
|
|
10218
10219
|
});
|
|
10219
10220
|
let i = I(We.not(), De, A(1)), a = I(We, be, r.mul(i)), s = I(We, A(0), A(ct));
|
|
10220
|
-
Je.assign(U(Je.xyz.add(
|
|
10221
|
+
Je.assign(U(Je.xyz.add(hd(qe.mul(t).mul(a), s, Ae, j(L))), Je.w));
|
|
10221
10222
|
}), p(We.and(Ee.not()).and(ye.not()), () => {
|
|
10222
10223
|
Je.assign(U(Je.xyz.add(qe.mul(Se)), Je.w));
|
|
10223
|
-
}), p(W.bitAnd(R(
|
|
10224
|
+
}), p(W.bitAnd(R(yu.HAS_HIT_OPAQUE)).equal(R(0)), () => {
|
|
10224
10225
|
Je.w.assign(0);
|
|
10225
|
-
}), p(Ve.and(W.bitAnd(R(
|
|
10226
|
+
}), p(Ve.and(W.bitAnd(R(yu.AUX_LOCKED)).equal(R(0))).and(W.bitAnd(R(yu.REDIRECTED)).notEqual(R(0))), () => {
|
|
10226
10227
|
let e = Hl(l, Ye);
|
|
10227
10228
|
Vl(l, Ye, F(Ke), Ul(e).w, E(n.mul(tt), H(0), H(1)));
|
|
10228
|
-
}), Xl(o, B, Je), Jl(o, B, Ke, W.bitAnd(R(~
|
|
10229
|
+
}), Xl(o, B, Je), Jl(o, B, Ke, W.bitAnd(R(~yu.ACTIVE))), h();
|
|
10229
10230
|
});
|
|
10230
10231
|
let dt = Ge.add(Ke.mul(nt)).toVar(), ft = F(rt).toVar(), pt = ru(o, B), mt = j(pt.stackDepth).toVar(), ht = pt.ior1.toVar(), gt = pt.ior2.toVar(), _t = pt.ior3.toVar(), G = j(pt.transTraversals).toVar(), vt = A(pt.wavelength).toVar();
|
|
10231
10232
|
p(mt.greaterThan(0), () => {
|
|
10232
10233
|
let e = au(o, B).toVar(), t = mu(o, B), n = t.sigmaS.toVar(), r = t.g.toVar();
|
|
10233
10234
|
p(N(N(n.x, n.y), n.z).lessThanEqual(0), () => {
|
|
10234
10235
|
let t = te(e.mul(nt).negate()).toVar();
|
|
10235
|
-
qe.mulAssign(t), p(Ve.and(W.bitAnd(R(
|
|
10236
|
+
qe.mulAssign(t), p(Ve.and(W.bitAnd(R(yu.AUX_LOCKED)).equal(R(0))), () => {
|
|
10236
10237
|
tt.mulAssign(t);
|
|
10237
10238
|
});
|
|
10238
10239
|
}).Else(() => {
|
|
@@ -10242,8 +10243,8 @@ function rf(e) {
|
|
|
10242
10243
|
lt.addAssign(1);
|
|
10243
10244
|
let a = E(N(N(qe.x, qe.y), qe.z), .02, 1).toVar();
|
|
10244
10245
|
p(lt.greaterThanEqual(ge).or(sr($e, j(0), et.add(j(12)), Xe, Me, je).greaterThan(a)).toVar(), () => {
|
|
10245
|
-
Xl(o, B, Je), Jl(o, B, Ke, W.bitAnd(R(~
|
|
10246
|
-
}), qe.divAssign(a), W.assign(W.bitOr(R(
|
|
10246
|
+
Xl(o, B, Je), Jl(o, B, Ke, W.bitAnd(R(~yu.ACTIVE))), s.element(B).assign(Xe), h();
|
|
10247
|
+
}), qe.divAssign(a), W.assign(W.bitOr(R(yu.REDIRECTED))), ql(o, B, t, st, lt, ut), Jl(o, B, n, W), Yl(o, B, qe, Rl(o, B)), Xl(o, B, Je), s.element(B).assign(Xe), h();
|
|
10247
10248
|
});
|
|
10248
10249
|
});
|
|
10249
10250
|
});
|
|
@@ -10263,7 +10264,7 @@ function rf(e) {
|
|
|
10263
10264
|
triangleIndex: j(ot),
|
|
10264
10265
|
boxTests: j(0),
|
|
10265
10266
|
triTests: j(0)
|
|
10266
|
-
}), r =
|
|
10267
|
+
}), r = wd.wrap(Td(e, t, n, K, ct)).toVar();
|
|
10267
10268
|
yt.assign(r.uv), bt.assign(r.normal), dt.assign(r.hitPoint);
|
|
10268
10269
|
});
|
|
10269
10270
|
let xt = U(0).toVar();
|
|
@@ -10289,15 +10290,15 @@ function rf(e) {
|
|
|
10289
10290
|
ft.assign(St.normal);
|
|
10290
10291
|
});
|
|
10291
10292
|
let Dt = K.metalness.toVar(), Ot = K.transmission.toVar(), kt = we(A(0), A(.15), Ct).toVar(), At = E(A(1).sub(Dt).mul(A(1).sub(Ot)).add(kt.mul(Dt.mul(A(1).sub(Ot)).add(Ot))), 0, 1).greaterThanEqual(A(.25)).toVar(), jt = tt.toVar(), Mt = (e) => {
|
|
10292
|
-
p(Ve.and(W.bitAnd(R(
|
|
10293
|
+
p(Ve.and(W.bitAnd(R(yu.AUX_LOCKED)).equal(R(0))), () => {
|
|
10293
10294
|
let t = Ul(Hl(l, Ye)).w;
|
|
10294
10295
|
Vl(l, Ye, e, t, E(Et.mul(jt), H(0), H(1)));
|
|
10295
10296
|
});
|
|
10296
10297
|
}, Nt = () => {
|
|
10297
|
-
Xl(o, B, Je), Jl(o, B, Ke, W.bitAnd(R(~
|
|
10298
|
+
Xl(o, B, Je), Jl(o, B, Ke, W.bitAnd(R(~yu.ACTIVE))), s.element(B).assign(Xe);
|
|
10298
10299
|
};
|
|
10299
10300
|
p(ct.equal(0).and(Ve), () => {
|
|
10300
|
-
let e =
|
|
10301
|
+
let e = gd({
|
|
10301
10302
|
worldPos: dt,
|
|
10302
10303
|
cameraProjectionMatrix: Oe,
|
|
10303
10304
|
cameraViewMatrix: ke
|
|
@@ -10316,15 +10317,15 @@ function rf(e) {
|
|
|
10316
10317
|
origin: Ge,
|
|
10317
10318
|
direction: Ke
|
|
10318
10319
|
}), Lt = Ho.wrap(Qo(It, ft, K, Xe, $e, Me, je, et, j(G), Pt, Ft, vt)).toVar();
|
|
10319
|
-
vt.assign(Lt.pathWavelength), p(Ve.and(W.bitAnd(R(
|
|
10320
|
+
vt.assign(Lt.pathWavelength), p(Ve.and(W.bitAnd(R(yu.AUX_LOCKED)).equal(R(0))), () => {
|
|
10320
10321
|
let e = Ul(Hl(l, Ye)).w, t = I(k(ft, Ke.negate()).lessThan(0), ft.negate(), ft).toVar(), n = E(Et.mul(jt), H(0), H(1)).toVar();
|
|
10321
10322
|
p(K.alphaMode.equal(j(2)), () => {
|
|
10322
|
-
Vl(l, Ye, t, e, n), W.assign(W.bitOr(R(
|
|
10323
|
+
Vl(l, Ye, t, e, n), W.assign(W.bitOr(R(yu.AUX_LOCKED)));
|
|
10323
10324
|
}).ElseIf(Lt.isAlphaSkip, () => {}).ElseIf(Lt.isSubsurface, () => {
|
|
10324
|
-
Vl(l, Ye, t, e, n), W.assign(W.bitOr(R(
|
|
10325
|
+
Vl(l, Ye, t, e, n), W.assign(W.bitOr(R(yu.AUX_LOCKED)));
|
|
10325
10326
|
}).ElseIf(Lt.isTransmissive, () => {
|
|
10326
10327
|
p(At.or(K.dispersion.greaterThan(0)), () => {
|
|
10327
|
-
Vl(l, Ye, t, e, n), W.assign(W.bitOr(R(
|
|
10328
|
+
Vl(l, Ye, t, e, n), W.assign(W.bitOr(R(yu.AUX_LOCKED)));
|
|
10328
10329
|
}).Else(() => {
|
|
10329
10330
|
tt.mulAssign(E(Et, H(0), H(1)));
|
|
10330
10331
|
});
|
|
@@ -10369,15 +10370,15 @@ function rf(e) {
|
|
|
10369
10370
|
}), qe.mulAssign(Lt.throughput);
|
|
10370
10371
|
let e = I(Lt.entering, ft, ft.negate()), t = I(Lt.didReflect, e, Ke), n = dt.add(t.mul(.001));
|
|
10371
10372
|
p(Lt.isAlphaSkip.not(), () => {
|
|
10372
|
-
W.assign(W.bitOr(R(
|
|
10373
|
+
W.assign(W.bitOr(R(yu.REDIRECTED)));
|
|
10373
10374
|
}).Else(() => {
|
|
10374
10375
|
ut.addAssign(1), p(ut.greaterThan(_e), () => {
|
|
10375
10376
|
Mt(I(k(ft, Ke.negate()).lessThan(0), ft.negate(), ft)), Nt(), h();
|
|
10376
10377
|
});
|
|
10377
|
-
}), ql(o, B, n, st, lt, ut, I(Lt.isAlphaSkip, Kl(o, B).add(nt), A(0))), Jl(o, B, Lt.direction, W), Yl(o, B, qe, Rl(o, B)), Xl(o, B, Je), iu(o, B, R(mt), R(G), ht, gt, _t, R(vt.add(.5))), p(Ve.and(W.bitAnd(R(
|
|
10378
|
+
}), ql(o, B, n, st, lt, ut, I(Lt.isAlphaSkip, Kl(o, B).add(nt), A(0))), Jl(o, B, Lt.direction, W), Yl(o, B, qe, Rl(o, B)), Xl(o, B, Je), iu(o, B, R(mt), R(G), ht, gt, _t, R(vt.add(.5))), p(Ve.and(W.bitAnd(R(yu.AUX_LOCKED)).equal(R(0))), () => {
|
|
10378
10379
|
uu(o, B, tt);
|
|
10379
10380
|
}), s.element(B).assign(Xe), h();
|
|
10380
|
-
}), W.assign(W.bitOr(R(
|
|
10381
|
+
}), W.assign(W.bitOr(R(yu.HAS_HIT_OPAQUE | yu.REDIRECTED)));
|
|
10381
10382
|
let Rt = St.emissive.toVar();
|
|
10382
10383
|
p(se(Rt).greaterThan(0), () => {
|
|
10383
10384
|
let e = I(We.not(), De, A(1)), t = A(1).toVar();
|
|
@@ -10386,23 +10387,23 @@ function rf(e) {
|
|
|
10386
10387
|
p(e.greaterThan(0), () => {
|
|
10387
10388
|
let i = Kl(o, B).toVar(), s = Ge.sub(Ke.mul(i)).toVar(), c = nt.add(i).toVar(), l = A(0).toVar();
|
|
10388
10389
|
p(Re.greaterThan(j(0)), () => {
|
|
10389
|
-
l.assign(
|
|
10390
|
+
l.assign($d(j(ot), c, Ke, s, a, Fe, ze, n));
|
|
10390
10391
|
}).Else(() => {
|
|
10391
|
-
l.assign(
|
|
10392
|
+
l.assign(Vd(j(ot), c, Ke, s, n, r, z));
|
|
10392
10393
|
}), t.assign(La({
|
|
10393
10394
|
pdf1: e,
|
|
10394
10395
|
pdf2: l
|
|
10395
10396
|
}));
|
|
10396
10397
|
});
|
|
10397
|
-
}), Je.assign(U(Je.xyz.add(
|
|
10398
|
+
}), Je.assign(U(Je.xyz.add(hd(Rt.mul(qe).mul(e).mul(t), A(ct), Ae, j(L))), Je.w));
|
|
10398
10399
|
});
|
|
10399
10400
|
let zt = Ke.negate().toVar(), Bt = F(rt), q = I(k(Bt, zt).lessThan(0), Bt.negate(), Bt).toVar();
|
|
10400
10401
|
p(k(Bt, zt).lessThan(0), () => {
|
|
10401
10402
|
ft.assign(ft.negate());
|
|
10402
|
-
}), p(Ve.and(W.bitAnd(R(
|
|
10403
|
+
}), p(Ve.and(W.bitAnd(R(yu.AUX_LOCKED)).equal(R(0))), () => {
|
|
10403
10404
|
let e = Ul(Hl(l, Ye)).w;
|
|
10404
10405
|
p(At, () => {
|
|
10405
|
-
Vl(l, Ye, ft, e, E(Et.mul(jt), H(0), H(1))), W.assign(W.bitOr(R(
|
|
10406
|
+
Vl(l, Ye, ft, e, E(Et.mul(jt), H(0), H(1))), W.assign(W.bitOr(R(yu.AUX_LOCKED)));
|
|
10406
10407
|
}).Else(() => {
|
|
10407
10408
|
let e = N(k(ft, zt), A(.001)), t = E(P(ro(K.ior).mul(K.specularColor), Et, K.metalness).mul(K.specularIntensity), H(0), H(1));
|
|
10408
10409
|
tt.mulAssign(va.wrap(go(t, e, N(Ct, A(.02)))).E_total);
|
|
@@ -10436,54 +10437,58 @@ function rf(e) {
|
|
|
10436
10437
|
triangleIndex: j(0),
|
|
10437
10438
|
boxTests: j(0),
|
|
10438
10439
|
triTests: j(0)
|
|
10439
|
-
}), n =
|
|
10440
|
+
}), n = vd.wrap(yd(e, t, K, Ht, Xe, $e, Me, je, et));
|
|
10440
10441
|
Kt.assign(n.L), qt.assign(n.brdf), Jt.assign(n.pdf);
|
|
10441
10442
|
}).Else(() => {
|
|
10442
|
-
let e = ma.wrap(
|
|
10443
|
+
let e = ma.wrap(md(zt, ft, K, Ht, Ut, Xe, $e, Me, je, et, Vt, !1, Wt, !1, Gt));
|
|
10443
10444
|
Kt.assign(e.direction), qt.assign(e.value), Jt.assign(e.pdf), Yt.assign(e.isTransmission), Xt.assign(e.colorWeight);
|
|
10444
10445
|
});
|
|
10445
|
-
let Zt = fa.wrap(
|
|
10446
|
-
Je.assign(U(Je.xyz.add(
|
|
10447
|
-
let e = f(([e, i, a]) => ks(e, i, a,
|
|
10446
|
+
let Zt = fa.wrap(fd(dt, ft, q, K, zt, Kt, Jt, qt, ct, Xe, $e, Me, je, et, ae, M, ce, le, de, fe, pe, me, t, n, r, g, _, v, i, ne, re, ie, y, T(!1))).shadowed.toVar(), Qt = I(ct.greaterThan(0), De, A(1));
|
|
10447
|
+
Je.assign(U(Je.xyz.add(hd(qe.mul(Zt).mul(Qt), A(ct), Ae, j(L))), Je.w)), He && p(Le.equal(j(1)).and(Pe.greaterThan(j(0))), () => {
|
|
10448
|
+
let e = f(([e, i, a]) => ks(e, i, a, Wu, t, n, r));
|
|
10448
10449
|
p(Re.greaterThan(j(0)), () => {
|
|
10449
|
-
let t =
|
|
10450
|
+
let t = Ed.wrap(Qd(dt, ft, Xe, $e, Me, je, et, a, a, Fe, n));
|
|
10450
10451
|
p(t.valid.and(t.pdf.greaterThan(0)), () => {
|
|
10451
10452
|
let n = N(A(0), k(ft, t.direction));
|
|
10452
10453
|
p(n.greaterThan(0).and(k(t.direction, q).greaterThan(0)), () => {
|
|
10453
10454
|
let r = As(dt, q, K), i = dt.add(r), a = t.distance.sub(.001), o = e(i, t.direction, a);
|
|
10454
10455
|
p(o.greaterThan(0), () => {
|
|
10455
|
-
let e =
|
|
10456
|
+
let e = ed(zt, t.direction, ft, K), r = dd(zt, t.direction, ft, K), i = I(r.greaterThan(0), La({
|
|
10456
10457
|
pdf1: t.pdf,
|
|
10457
10458
|
pdf2: r
|
|
10458
10459
|
}), A(1)), a = t.emission.mul(e).mul(n).div(t.pdf).mul(o).mul(Ie).mul(i);
|
|
10459
|
-
Je.assign(U(Je.xyz.add(
|
|
10460
|
+
Je.assign(U(Je.xyz.add(hd(a.mul(qe).mul(Qt), A(ct), Ae, j(L))), Je.w));
|
|
10460
10461
|
});
|
|
10461
10462
|
});
|
|
10462
10463
|
});
|
|
10463
10464
|
}).Else(() => {
|
|
10464
|
-
let t =
|
|
10465
|
-
Je.assign(U(Je.xyz.add(
|
|
10465
|
+
let t = Gd(dt, ft, q, zt, K, ct, Xe, $e, Me, je, et, Ie, a, Fe, Pe, z, n, e, As);
|
|
10466
|
+
Je.assign(U(Je.xyz.add(hd(t.mul(qe).mul(Qt), A(ct), Ae, j(L))), Je.w));
|
|
10466
10467
|
});
|
|
10467
10468
|
});
|
|
10468
|
-
let $t = Bs.wrap(
|
|
10469
|
+
let $t = Bs.wrap(pd(ft, K, Kt, Jt, qt, Yt, Xt, Xe, $e, Me, je, et)).toVar(), en = $t.direction.toVar();
|
|
10469
10470
|
p(Yt.not().and(k(en, q).lessThanEqual(0)), () => {
|
|
10470
10471
|
Mt(ft), Nt(), h();
|
|
10471
10472
|
});
|
|
10472
10473
|
let tn = N($t.combinedPdf, .001).toVar();
|
|
10473
10474
|
qe.mulAssign($t.throughput);
|
|
10474
|
-
let nn =
|
|
10475
|
+
let nn = _d(ct, qe, Vt, en, Xe, $e, Me, je, et, y).toVar();
|
|
10475
10476
|
p(nn.lessThanEqual(0), () => {
|
|
10476
10477
|
Mt(ft), Nt(), h();
|
|
10477
10478
|
}), qe.divAssign(nn), p(st.greaterThanEqual(he), () => {
|
|
10478
10479
|
Mt(ft), Nt(), h();
|
|
10479
|
-
}), ql(o, B, dt.add(ft.mul(.001)), st.add(1), lt, ut), Jl(o, B, en, W), Yl(o, B, qe, tn), Xl(o, B, Je), iu(o, B, R(mt), R(G), ht, gt, _t, R(vt.add(.5))), p(Ve.and(W.bitAnd(R(
|
|
10480
|
+
}), ql(o, B, dt.add(ft.mul(.001)), st.add(1), lt, ut), Jl(o, B, en, W), Yl(o, B, qe, tn), Xl(o, B, Je), iu(o, B, R(mt), R(G), ht, gt, _t, R(vt.add(.5))), p(Ve.and(W.bitAnd(R(yu.AUX_LOCKED)).equal(R(0))), () => {
|
|
10480
10481
|
uu(o, B, tt);
|
|
10481
10482
|
}), s.element(B).assign(Xe);
|
|
10482
10483
|
});
|
|
10483
10484
|
}
|
|
10484
10485
|
//#endregion
|
|
10485
10486
|
//#region src/TSL/CompactKernel.js
|
|
10486
|
-
|
|
10487
|
+
var of = (e, t) => {
|
|
10488
|
+
let n = Ll(e, t);
|
|
10489
|
+
return pe(R(N(N(n.x, n.y), n.z).max(0).mul(64).add(.5)), R(vu));
|
|
10490
|
+
};
|
|
10491
|
+
function sf(e) {
|
|
10487
10492
|
let { rayBufferRO: t, activeIndicesReadRO: n, activeIndicesWriteRW: r, counters: i, currentActiveCount: a } = e;
|
|
10488
10493
|
return f(() => {
|
|
10489
10494
|
let e = oe, o = i ? S(i.element(R(_u.ENTERING_COUNT))) : a;
|
|
@@ -10491,27 +10496,27 @@ function af(e) {
|
|
|
10491
10496
|
h();
|
|
10492
10497
|
});
|
|
10493
10498
|
let s = n.element(e);
|
|
10494
|
-
p(Il(t, s).bitAnd(R(
|
|
10499
|
+
p(Il(t, s).bitAnd(R(yu.ACTIVE)).notEqual(R(0)), () => {
|
|
10495
10500
|
let e = x(i.element(R(_u.ACTIVE_RAY_COUNT)), R(1));
|
|
10496
|
-
r.element(e).assign(s);
|
|
10501
|
+
r.element(e).assign(s), x(i.element(R(_u.ACTIVE_ENERGY)), of(t, s));
|
|
10497
10502
|
});
|
|
10498
10503
|
});
|
|
10499
10504
|
}
|
|
10500
|
-
function
|
|
10505
|
+
function cf(e) {
|
|
10501
10506
|
let { rayBufferRO: t, activeIndicesReadRO: n, activeIndicesWriteRW: r, counters: i, currentActiveCount: a } = e;
|
|
10502
10507
|
return f(() => {
|
|
10503
|
-
let e = oe, o = i ? S(i.element(R(_u.ENTERING_COUNT))) : a, s = e.lessThan(o), c = n.element(e), l = Il(t, c), u = s.and(l.bitAnd(R(
|
|
10504
|
-
p(
|
|
10505
|
-
|
|
10508
|
+
let e = oe, o = i ? S(i.element(R(_u.ENTERING_COUNT))) : a, s = e.lessThan(o), c = n.element(e), l = Il(t, c), u = s.and(l.bitAnd(R(yu.ACTIVE)).notEqual(R(0))), d = I(u, R(1), R(0)), f = I(u, of(t, c), R(0)), m = Ae(d).toVar(), h = Oe(d).toVar(), g = Oe(f).toVar(), _ = Ae(R(1)).toVar(), v = R(0).toVar();
|
|
10509
|
+
p(_.equal(R(0)), () => {
|
|
10510
|
+
v.assign(x(i.element(R(_u.ACTIVE_RAY_COUNT)), h)), x(i.element(R(_u.ACTIVE_ENERGY)), g);
|
|
10506
10511
|
});
|
|
10507
|
-
let
|
|
10512
|
+
let y = ke(v, R(0)).toVar();
|
|
10508
10513
|
p(u, () => {
|
|
10509
|
-
r.element(
|
|
10514
|
+
r.element(y.add(m)).assign(c);
|
|
10510
10515
|
});
|
|
10511
10516
|
});
|
|
10512
10517
|
}
|
|
10513
|
-
var
|
|
10514
|
-
function
|
|
10518
|
+
var lf = /* @__PURE__ */ W("\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");
|
|
10519
|
+
function uf(e) {
|
|
10515
10520
|
let { rayBufferRO: t, gBufferRO: n, writeColorTex: r, writeNDTex: i, writeAlbedoTex: a, resolution: o, frame: s, enableAccumulation: c, hasPreviousAccumulated: l, accumulationAlpha: u, cameraIsMoving: d, hasPreviousAux: m, auxAccumulationAlpha: h, transparentBackground: g, prevAccumTexture: _, prevAlbedoTexture: v, prevNormalDepthTexture: y, renderWidth: b, chunkRowBase: x, chunkRows: S, visMode: C, auxGBufferEnabled: w, cleanAuxNormalEnabled: T, m2BufferRW: E, useAdaptiveSampling: D, noiseThreshold: O, adaptiveMinSamples: ee, usePixelFreeze: k, pixelFreezeThreshold: te, streakBufferRW: ne, frozenMaskRO: re, convergenceOverlay: ie } = e, ae = w.greaterThan(R(0)), oe = T.greaterThan(R(0)), M = D.greaterThan(j(0)), ce = k.greaterThan(j(0)), ue = M.or(ce).or(ie.greaterThan(j(0)));
|
|
10516
10521
|
return f(() => {
|
|
10517
10522
|
let e = j(Ue.x).mul(16).add(j(le.x)), f = j(Ue.y).mul(16).add(j(le.y));
|
|
@@ -10548,7 +10553,7 @@ function cf(e) {
|
|
|
10548
10553
|
}), ne.element(T).assign(i.bitOr(I(e, R(2147483648), R(0))).bitOr(u));
|
|
10549
10554
|
});
|
|
10550
10555
|
}), p(C.equal(j(11)), () => {
|
|
10551
|
-
k.assign(
|
|
10556
|
+
k.assign(lf(k));
|
|
10552
10557
|
});
|
|
10553
10558
|
let pe = ze(R(e), R(S));
|
|
10554
10559
|
Pe(r, pe, U(k, ie)).toWriteOnly(), p(ae, () => {
|
|
@@ -10559,11 +10564,11 @@ function cf(e) {
|
|
|
10559
10564
|
}
|
|
10560
10565
|
//#endregion
|
|
10561
10566
|
//#region src/TSL/Debugger.js
|
|
10562
|
-
var
|
|
10567
|
+
var df = /* @__PURE__ */ W("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n return vec3f( 1.0f - depth );\n }\n"), ff = /* @__PURE__ */ W("\n fn visualizeNormal( normal: vec3f ) -> vec3f {\n return normal * 0.5f + 0.5f;\n }\n"), pf = /* @__PURE__ */ W("\n fn computeNDCDepthLocal( 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"), mf = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m, h, g]) => {
|
|
10563
10568
|
let _ = U(1, 0, 1, 1).toVar(), v = ca({
|
|
10564
10569
|
origin: e,
|
|
10565
10570
|
direction: t
|
|
10566
|
-
}), y = pa.wrap(
|
|
10571
|
+
}), y = pa.wrap(Uu(v, n, r).toVar());
|
|
10567
10572
|
return p(l.equal(j(7)), () => {
|
|
10568
10573
|
let e = A(y.triTests).div(u);
|
|
10569
10574
|
_.assign(I(e.lessThan(1), U(H(e), 1), U(1, 0, 0, 1)));
|
|
@@ -10572,7 +10577,7 @@ var lf = /* @__PURE__ */ W("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
10572
10577
|
_.assign(I(e.lessThan(1), U(H(e), 1), U(1, 0, 0, 1)));
|
|
10573
10578
|
}), p(l.equal(j(10)), () => {
|
|
10574
10579
|
p(c, () => {
|
|
10575
|
-
let e =
|
|
10580
|
+
let e = Xu({
|
|
10576
10581
|
tex: a,
|
|
10577
10582
|
samp: xe(a),
|
|
10578
10583
|
direction: t,
|
|
@@ -10620,18 +10625,18 @@ var lf = /* @__PURE__ */ W("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
10620
10625
|
_.assign(U(.5, .5, 1, 1));
|
|
10621
10626
|
}).Else(() => {
|
|
10622
10627
|
let e = la.wrap(qa(y.materialIndex, i)).toVar(), t = F(ya.wrap(Cs(e, y.uv, y.normal, U(0))).toVar().normal);
|
|
10623
|
-
_.assign(U(
|
|
10628
|
+
_.assign(U(ff({ normal: t }), 1));
|
|
10624
10629
|
});
|
|
10625
10630
|
}), p(l.equal(j(2)), () => {
|
|
10626
10631
|
p(y.didHit.not(), () => {
|
|
10627
10632
|
_.assign(U(H(1), 1));
|
|
10628
10633
|
}).Else(() => {
|
|
10629
|
-
let e =
|
|
10634
|
+
let e = pf({
|
|
10630
10635
|
worldPos: y.hitPoint,
|
|
10631
10636
|
cameraProjectionMatrix: m,
|
|
10632
10637
|
cameraViewMatrix: h
|
|
10633
10638
|
});
|
|
10634
|
-
_.assign(U(
|
|
10639
|
+
_.assign(U(df({ depth: e }), 1));
|
|
10635
10640
|
});
|
|
10636
10641
|
}), p(l.equal(j(3)), () => {
|
|
10637
10642
|
p(y.didHit.not(), () => {
|
|
@@ -10650,10 +10655,10 @@ var lf = /* @__PURE__ */ W("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
10650
10655
|
}).toVar(), h = ca({
|
|
10651
10656
|
origin: y.hitPoint.add(u.mul(.001)),
|
|
10652
10657
|
direction: m
|
|
10653
|
-
}), v = pa.wrap(
|
|
10658
|
+
}), v = pa.wrap(Uu(h, n, r).toVar()), b = H(0).toVar();
|
|
10654
10659
|
p(v.didHit.not(), () => {
|
|
10655
10660
|
p(c, () => {
|
|
10656
|
-
b.assign(
|
|
10661
|
+
b.assign(Xu({
|
|
10657
10662
|
tex: a,
|
|
10658
10663
|
samp: xe(a),
|
|
10659
10664
|
direction: m,
|
|
@@ -10665,7 +10670,7 @@ var lf = /* @__PURE__ */ W("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
10665
10670
|
}).Else(() => {
|
|
10666
10671
|
let e = la.wrap(qa(v.materialIndex, i)).toVar(), t = ya.wrap(Cs(e, v.uv, v.normal, U(0))).toVar();
|
|
10667
10672
|
b.assign(t.emissive), p(c, () => {
|
|
10668
|
-
let e = F(t.normal).toVar(), n =
|
|
10673
|
+
let e = F(t.normal).toVar(), n = Xu({
|
|
10669
10674
|
tex: a,
|
|
10670
10675
|
samp: xe(a),
|
|
10671
10676
|
direction: e,
|
|
@@ -10681,7 +10686,7 @@ var lf = /* @__PURE__ */ W("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
10681
10686
|
});
|
|
10682
10687
|
}), p(l.equal(j(6)), () => {
|
|
10683
10688
|
p(y.didHit, () => {
|
|
10684
|
-
let e = y.normal.toVar(), n = F(t.sub(e.mul(k(t, e).mul(2)))).toVar(), r =
|
|
10689
|
+
let e = y.normal.toVar(), n = F(t.sub(e.mul(k(t, e).mul(2)))).toVar(), r = Xu({
|
|
10685
10690
|
tex: a,
|
|
10686
10691
|
samp: xe(a),
|
|
10687
10692
|
direction: n,
|
|
@@ -10691,7 +10696,7 @@ var lf = /* @__PURE__ */ W("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
10691
10696
|
}).xyz, i = r.div(r.add(1));
|
|
10692
10697
|
_.assign(U(i, 1));
|
|
10693
10698
|
}).Else(() => {
|
|
10694
|
-
let e =
|
|
10699
|
+
let e = Xu({
|
|
10695
10700
|
tex: a,
|
|
10696
10701
|
samp: xe(a),
|
|
10697
10702
|
direction: t,
|
|
@@ -10703,31 +10708,31 @@ var lf = /* @__PURE__ */ W("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
10703
10708
|
});
|
|
10704
10709
|
}), _;
|
|
10705
10710
|
});
|
|
10706
|
-
function
|
|
10711
|
+
function hf(e) {
|
|
10707
10712
|
let { writeColorTex: t, writeNDTex: n, writeAlbedoTex: r, resolution: i, renderWidth: a, renderHeight: o, cameraWorldMatrix: s, cameraProjectionMatrixInverse: c, cameraProjectionMatrix: l, cameraViewMatrix: u, cameraProjection: d, panoLonRange: m, panoLatRange: h, panoLevelHorizon: g, enableDOF: _, focalLength: v, aperture: y, focusDistance: b, sceneScale: x, apertureScale: S, anamorphicRatio: C, bvhBuffer: w, triangleBuffer: T, materialBuffer: E, envTexture: D, environmentMatrix: O, environmentIntensity: ee, enableEnvironmentLight: k, visMode: te, debugVisScale: ne, frame: re } = e;
|
|
10708
10713
|
return f(() => {
|
|
10709
10714
|
let e = j(Ue.x).mul(16).add(j(le.x)), f = j(Ue.y).mul(16).add(j(le.y));
|
|
10710
10715
|
p(e.lessThan(a).and(f.lessThan(o)), () => {
|
|
10711
|
-
let a = V(A(e).add(.5), A(f).add(.5)), o = Gn({ state: R(f.mul(j(i.x)).add(e)).add(R(1)) }).toVar(), ie = ca.wrap(
|
|
10716
|
+
let a = V(A(e).add(.5), A(f).add(.5)), o = Gn({ state: R(f.mul(j(i.x)).add(e)).add(R(1)) }).toVar(), ie = ca.wrap(Au(a.div(i), o, s, c, d, m, h, g, _, v, y, b, x, S, C)), ae = U(1, 0, 1, 1).toVar();
|
|
10712
10717
|
p(te.equal(j(9)), () => {
|
|
10713
10718
|
let e = cr(a, j(0), j(1), o, i, re);
|
|
10714
10719
|
ae.assign(U(e, 1, 1));
|
|
10715
10720
|
}).Else(() => {
|
|
10716
|
-
ae.assign(
|
|
10721
|
+
ae.assign(mf(ie.origin, ie.direction, w, T, E, D, O, ee, k, te, ne, a, i, l, u, re));
|
|
10717
10722
|
});
|
|
10718
10723
|
let oe = ze(R(e), R(f));
|
|
10719
10724
|
Pe(t, oe, ae).toWriteOnly(), Pe(n, oe, U(.5, .5, 1, 1)).toWriteOnly(), Pe(r, oe, U(ae.xyz, 1)).toWriteOnly();
|
|
10720
10725
|
});
|
|
10721
10726
|
});
|
|
10722
10727
|
}
|
|
10723
|
-
function
|
|
10728
|
+
function gf({ sortGlobalHistogram: e, bins: t = 256 }) {
|
|
10724
10729
|
return f(() => {
|
|
10725
10730
|
p(oe.lessThan(R(t)), () => {
|
|
10726
10731
|
C(e.element(oe), R(0));
|
|
10727
10732
|
});
|
|
10728
10733
|
});
|
|
10729
10734
|
}
|
|
10730
|
-
function
|
|
10735
|
+
function _f({ hitBufferRO: e, activeIndicesReadRO: t, sortGlobalHistogram: n, counters: r, bins: i = 256 }) {
|
|
10731
10736
|
return f(() => {
|
|
10732
10737
|
let a = oe, o = le.x, s = Nn("uint", i);
|
|
10733
10738
|
p(o.lessThan(R(i)), () => {
|
|
@@ -10745,7 +10750,7 @@ function hf({ hitBufferRO: e, activeIndicesReadRO: t, sortGlobalHistogram: n, co
|
|
|
10745
10750
|
});
|
|
10746
10751
|
});
|
|
10747
10752
|
}
|
|
10748
|
-
function
|
|
10753
|
+
function vf({ sortGlobalHistogram: e, bins: t = 256 }) {
|
|
10749
10754
|
return f(() => {
|
|
10750
10755
|
p(oe.equal(R(0)), () => {
|
|
10751
10756
|
let n = R(0).toVar();
|
|
@@ -10760,7 +10765,7 @@ function gf({ sortGlobalHistogram: e, bins: t = 256 }) {
|
|
|
10760
10765
|
});
|
|
10761
10766
|
});
|
|
10762
10767
|
}
|
|
10763
|
-
function
|
|
10768
|
+
function yf({ hitBufferRO: e, activeIndicesReadRO: t, sortedIndicesRW: n, sortGlobalHistogram: r, counters: i, bins: a = 256 }) {
|
|
10764
10769
|
return f(() => {
|
|
10765
10770
|
let o = oe, s = le.x, c = Nn("uint", a);
|
|
10766
10771
|
p(s.lessThan(R(a)), () => {
|
|
@@ -10781,16 +10786,16 @@ function _f({ hitBufferRO: e, activeIndicesReadRO: t, sortedIndicesRW: n, sortGl
|
|
|
10781
10786
|
}
|
|
10782
10787
|
//#endregion
|
|
10783
10788
|
//#region src/Stages/PathTracer.js
|
|
10784
|
-
var
|
|
10789
|
+
var bf = fi("wavefront"), xf = 256, Sf = [
|
|
10785
10790
|
"extend",
|
|
10786
10791
|
"shade",
|
|
10787
10792
|
"globalHist",
|
|
10788
10793
|
"globalScatter",
|
|
10789
10794
|
"compact",
|
|
10790
10795
|
"compactCopyback"
|
|
10791
|
-
],
|
|
10796
|
+
], Cf = class extends El {
|
|
10792
10797
|
constructor(e, t, n, r = {}) {
|
|
10793
|
-
super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._m2Attr = null, this._streakAttr = null, this._frozenMaskAttr = null, this._convDebugSource = null, this._dilateFrozenUniform = z(1, "int"), this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = z(0, "uint"), this._cleanAuxNormalEnabled = !1, this._cleanAuxNormalUniform = z(0, "uint"), this._auxSamples = 0, this._auxSeedPending = !1, this._useDynamicDispatch = !0, this._sortMaterials = !1, this._useSubgroupCompact = !1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._curveSizingValid = !1, this._bounceEarlyExitThreshold =
|
|
10798
|
+
super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._m2Attr = null, this._streakAttr = null, this._frozenMaskAttr = null, this._convDebugSource = null, this._dilateFrozenUniform = z(1, "int"), this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = z(0, "uint"), this._cleanAuxNormalEnabled = !1, this._cleanAuxNormalUniform = z(0, "uint"), this._auxSamples = 0, this._auxSeedPending = !1, this._useDynamicDispatch = !0, this._sortMaterials = !1, this._useSubgroupCompact = !1, this._lastBounceCounts = null, this._lastBounceEnergy = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._curveSizingValid = !1, this._bounceEarlyExitThreshold = 1e-4, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._geometryPixelCount = 0, this._convergedReadbackPending = !1, this._lastActivePixelCount = 0, this._wfRenderWidth = z(1920, "int"), this._wfRenderHeight = z(1080, "int"), this._wfMaxRayCount = z(0, "uint"), this._wfCurrentBounce = z(0, "int"), this._wfChunkRowBase = z(0, "int"), this._wfChunkRows = z(0, "int"), this._wfIsFirstChunk = z(1, "uint"), this._pathBudget = 0, this._pathBudgetOverride = 0, this._chunkRows = 0, this._numChunks = 1, this.vramTracker = new Eu(this.renderer), this._registerVRAMProviders(), bf.debug("initialized (wavefront)");
|
|
10794
10799
|
}
|
|
10795
10800
|
_registerVRAMProviders() {
|
|
10796
10801
|
let e = this.vramTracker;
|
|
@@ -10869,6 +10874,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
10869
10874
|
o.setDispatchForCount("generateList", e), o.dispatch("resetFrameCounters"), o.dispatch("buildActivePixels"), o.dispatch("seedEnter"), o.dispatch("generateList");
|
|
10870
10875
|
} else o.dispatch("generate"), o.dispatch("initActiveIndices");
|
|
10871
10876
|
e === 0 && t > 0 && this.useAdaptiveSampling.value > 0 && this._willReadCountersThisFrame() && o.dispatch("countConvergedDilated");
|
|
10877
|
+
let m = this._lastBounceEnergy, h = this._bounceEarlyExitThreshold >= 0 ? this._bounceEarlyExitThreshold * i * 64 : -1;
|
|
10872
10878
|
for (let e = 0; e <= c; e++) {
|
|
10873
10879
|
this._wfCurrentBounce.value = e;
|
|
10874
10880
|
let t = this._useDynamicDispatch;
|
|
@@ -10879,12 +10885,12 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
10879
10885
|
n < p && f[n] !== void 0 ? r = f[n] : p > 0 && (r = f[p - 1]), t = r > 0 ? r : i;
|
|
10880
10886
|
} else e === 0 && a && (t = s);
|
|
10881
10887
|
let n = Math.min(i, Math.ceil(t * 1.5) + 1024);
|
|
10882
|
-
for (let e of
|
|
10888
|
+
for (let e of Sf) o.setDispatchForCount(e, n);
|
|
10883
10889
|
} else {
|
|
10884
10890
|
o.dispatch("enterFull");
|
|
10885
|
-
for (let e of
|
|
10891
|
+
for (let e of Sf) o.setDispatchForCount(e, i);
|
|
10886
10892
|
}
|
|
10887
|
-
if (o.dispatch("extend"), this._sortMaterials && (o.dispatch("resetGlobalHist"), o.dispatch("globalHist"), o.dispatch("globalPrefix"), o.dispatch("globalScatter")), o.dispatch("shade"), o.dispatch("compact"), t ? o.dispatch("compactCopyback") : o.dispatch("snapshotBounceCount"), e < p && e < c &&
|
|
10893
|
+
if (o.dispatch("extend"), this._sortMaterials && (o.dispatch("resetGlobalHist"), o.dispatch("globalHist"), o.dispatch("globalPrefix"), o.dispatch("globalScatter")), o.dispatch("shade"), o.dispatch("compact"), t ? o.dispatch("compactCopyback") : o.dispatch("snapshotBounceCount"), h >= 0 && e < p && e < c && m?.[e] !== void 0 && m[e] <= h) break;
|
|
10888
10894
|
}
|
|
10889
10895
|
o.dispatch("finalWrite");
|
|
10890
10896
|
}
|
|
@@ -10956,11 +10962,15 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
10956
10962
|
let e = this._queueManager?.getBounceCountsAttribute();
|
|
10957
10963
|
if (!e) return;
|
|
10958
10964
|
this._readbackPending = !0;
|
|
10959
|
-
let t = this._readbackGeneration, n = this.maxBounces.value;
|
|
10965
|
+
let t = this._readbackGeneration, n = this.maxBounces.value, r = this._queueManager.MAX_BOUNCE_SNAPSHOTS;
|
|
10960
10966
|
if (this.renderer.getArrayBufferAsync(e).then((e) => {
|
|
10961
|
-
t === this._readbackGeneration
|
|
10967
|
+
if (t === this._readbackGeneration) {
|
|
10968
|
+
let t = new Uint32Array(e.slice(0));
|
|
10969
|
+
this._lastBounceCounts = t.subarray(0, r), this._lastBounceEnergy = t.subarray(r, 2 * r), this._lastBounceCountsBudget = n, this._curveSizingValid = !0;
|
|
10970
|
+
}
|
|
10971
|
+
this._readbackPending = !1;
|
|
10962
10972
|
}).catch((e) => {
|
|
10963
|
-
|
|
10973
|
+
bf.warn("bounceCounts readback failed:", e), this._readbackPending = !1;
|
|
10964
10974
|
}), !this._convergedReadbackPending) {
|
|
10965
10975
|
let e = this._queueManager?.getCountersAttribute();
|
|
10966
10976
|
if (e) {
|
|
@@ -10990,10 +11000,10 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
10990
11000
|
}
|
|
10991
11001
|
_rebuildKernelsIfResized(e, t) {
|
|
10992
11002
|
let n = this.storageTextures.renderWidth, r = this.storageTextures.renderHeight;
|
|
10993
|
-
n === e && r === t || !(this.materialData?.materialCount > 0) || (this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._curveSizingValid = !1, this._readbackFrameCounter = 0, this._readbackGeneration++, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._lastActivePixelCount = 0, this._packedBuffers ? this._resizeWavefrontInPlace(n, r) : (this._kernelManager && this._kernelManager.dispose(), this._wavefrontReady = !1, this._buildWavefrontKernels()));
|
|
11003
|
+
n === e && r === t || !(this.materialData?.materialCount > 0) || (this._lastBounceCounts = null, this._lastBounceEnergy = null, this._lastBounceCountsBudget = -1, this._curveSizingValid = !1, this._readbackFrameCounter = 0, this._readbackGeneration++, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._lastActivePixelCount = 0, this._packedBuffers ? this._resizeWavefrontInPlace(n, r) : (this._kernelManager && this._kernelManager.dispose(), this._wavefrontReady = !1, this._buildWavefrontKernels()));
|
|
10994
11004
|
}
|
|
10995
11005
|
_resizeWavefrontInPlace(e, t) {
|
|
10996
|
-
this._wfRenderWidth.value = e, this._wfRenderHeight.value = t, this._updateChunkLayout()
|
|
11006
|
+
this._wfRenderWidth.value = e, this._wfRenderHeight.value = t, this._updateChunkLayout();
|
|
10997
11007
|
}
|
|
10998
11008
|
_computePathBudget() {
|
|
10999
11009
|
if (this._pathBudgetOverride > 0) return this._pathBudgetOverride;
|
|
@@ -11018,18 +11028,18 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11018
11028
|
let r = this._pathBudget;
|
|
11019
11029
|
this._updateChunkLayout();
|
|
11020
11030
|
let i = this._chunkRows * t;
|
|
11021
|
-
this.
|
|
11031
|
+
this._packedBuffers ? this._packedBuffers.resize(r) : this._packedBuffers = new Nl(r, this.renderer);
|
|
11022
11032
|
let a = r * 1;
|
|
11023
11033
|
Ml(this.renderer, this._gBufferAttr), this._gBufferAttr = new o(new Uint32Array(a * 4), 4);
|
|
11024
11034
|
let s = Ee(this._gBufferAttr, "uvec4"), c = Ee(this._gBufferAttr, "uvec4").toReadOnly(), l = Y * Y;
|
|
11025
11035
|
(!this._m2Attr || this._m2Attr.count < l) && (Ml(this.renderer, this._m2Attr), this._m2Attr = new o(new Float32Array(l), 1), Ml(this.renderer, this._streakAttr), this._streakAttr = new o(new Uint32Array(l), 1), Ml(this.renderer, this._frozenMaskAttr), this._frozenMaskAttr = new o(new Uint32Array(l), 1));
|
|
11026
11036
|
let u = Ee(this._m2Attr, "float"), d = Ee(this._streakAttr, "uint"), m = Ee(this._streakAttr, "uint").toReadOnly(), g = Ee(this._frozenMaskAttr, "uint"), _ = Ee(this._frozenMaskAttr, "uint").toReadOnly();
|
|
11027
|
-
this._queueManager ? this._queueManager.resize(this._packedBuffers.capacity) : this._queueManager = new
|
|
11037
|
+
this._queueManager ? this._queueManager.resize(this._packedBuffers.capacity) : this._queueManager = new bu(this._packedBuffers.capacity, this.renderer), this._kernelManager ||= new Ou(this.renderer);
|
|
11028
11038
|
let v = this._packedBuffers, y = this._queueManager;
|
|
11029
11039
|
this._wfRenderWidth.value = t, this._wfRenderHeight.value = n, this._wfMaxRayCount.value = Math.min(r, this._chunkRows * t);
|
|
11030
11040
|
let b = this.shaderBuilder.prevColorTexNode, w = this.shaderBuilder.prevAlbedoTexNode, T = this.shaderBuilder.prevNormalDepthTexNode, E = this.storageTextures.getWriteTextures(), D = y.getCounters(), O = y.getBounceCounts(), ee = this._wfCurrentBounce, k = f(() => {
|
|
11031
11041
|
let e = S(D.element(R(_u.ACTIVE_RAY_COUNT))), t = R(ee).clamp(R(0), R(y.MAX_BOUNCE_SNAPSHOTS - 1));
|
|
11032
|
-
O.element(t).assign(e), C(D.element(R(_u.ENTERING_COUNT)), e);
|
|
11042
|
+
O.element(t).assign(e), O.element(t.add(R(y.MAX_BOUNCE_SNAPSHOTS))).assign(S(D.element(R(_u.ACTIVE_ENERGY)))), C(D.element(R(_u.ENTERING_COUNT)), e);
|
|
11033
11043
|
});
|
|
11034
11044
|
this._kernelManager.register("snapshotBounceCount", k().compute([
|
|
11035
11045
|
1,
|
|
@@ -11051,11 +11061,11 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11051
11061
|
});
|
|
11052
11062
|
});
|
|
11053
11063
|
this._kernelManager.register("initActiveIndices", ne().compute([
|
|
11054
|
-
Math.ceil(this._chunkRows * t /
|
|
11064
|
+
Math.ceil(this._chunkRows * t / xf),
|
|
11055
11065
|
1,
|
|
11056
11066
|
1
|
|
11057
11067
|
], [
|
|
11058
|
-
|
|
11068
|
+
xf,
|
|
11059
11069
|
1,
|
|
11060
11070
|
1
|
|
11061
11071
|
]));
|
|
@@ -11085,7 +11095,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11085
11095
|
transmissiveBounces: this.transmissiveBounces,
|
|
11086
11096
|
transparentBackground: this.transparentBackground,
|
|
11087
11097
|
auxGBufferEnabled: this._auxGBufferUniform
|
|
11088
|
-
}, re =
|
|
11098
|
+
}, re = ju(A);
|
|
11089
11099
|
this._kernelManager.register("generate", re().compute([
|
|
11090
11100
|
Math.ceil(t / 16),
|
|
11091
11101
|
Math.ceil(this._chunkRows / 16),
|
|
@@ -11141,11 +11151,11 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11141
11151
|
});
|
|
11142
11152
|
});
|
|
11143
11153
|
this._kernelManager.register("buildActivePixels", M().compute([
|
|
11144
|
-
Math.ceil(this._chunkRows * t /
|
|
11154
|
+
Math.ceil(this._chunkRows * t / xf),
|
|
11145
11155
|
1,
|
|
11146
11156
|
1
|
|
11147
11157
|
], [
|
|
11148
|
-
|
|
11158
|
+
xf,
|
|
11149
11159
|
1,
|
|
11150
11160
|
1
|
|
11151
11161
|
]));
|
|
@@ -11181,11 +11191,11 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11181
11191
|
});
|
|
11182
11192
|
});
|
|
11183
11193
|
this._kernelManager.register("countConvergedDilated", se().compute([
|
|
11184
|
-
Math.ceil(t * n /
|
|
11194
|
+
Math.ceil(t * n / xf),
|
|
11185
11195
|
1,
|
|
11186
11196
|
1
|
|
11187
11197
|
], [
|
|
11188
|
-
|
|
11198
|
+
xf,
|
|
11189
11199
|
1,
|
|
11190
11200
|
1
|
|
11191
11201
|
]));
|
|
@@ -11202,18 +11212,18 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11202
11212
|
1,
|
|
11203
11213
|
1
|
|
11204
11214
|
]));
|
|
11205
|
-
let le =
|
|
11215
|
+
let le = ju({
|
|
11206
11216
|
...A,
|
|
11207
11217
|
listDriven: !0,
|
|
11208
11218
|
activeIndicesRO: y.activeIndicesRO.a,
|
|
11209
11219
|
counters: D
|
|
11210
11220
|
});
|
|
11211
11221
|
this._kernelManager.register("generateList", le().compute([
|
|
11212
|
-
Math.ceil(i /
|
|
11222
|
+
Math.ceil(i / xf),
|
|
11213
11223
|
1,
|
|
11214
11224
|
1
|
|
11215
11225
|
], [
|
|
11216
|
-
|
|
11226
|
+
xf,
|
|
11217
11227
|
1,
|
|
11218
11228
|
1
|
|
11219
11229
|
]));
|
|
@@ -11226,7 +11236,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11226
11236
|
srgbBuckets: F,
|
|
11227
11237
|
linearBuckets: he
|
|
11228
11238
|
}, this._sortMaterials = (J.wavefrontSortMaterials ?? !1) && (this.materialData?.materialCount ?? 0) > 8;
|
|
11229
|
-
let _e =
|
|
11239
|
+
let _e = Gu({
|
|
11230
11240
|
bvhBuffer: ue,
|
|
11231
11241
|
triangleBuffer: de,
|
|
11232
11242
|
rayBufferRO: v.rayBuffer.ro,
|
|
@@ -11245,7 +11255,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11245
11255
|
1
|
|
11246
11256
|
])), this._sortMaterials) {
|
|
11247
11257
|
let e = y.getSortGlobalHistogram(), t = Math.min(256, this.materialData?.materialCount ?? 256);
|
|
11248
|
-
this._kernelManager.register("resetGlobalHist",
|
|
11258
|
+
this._kernelManager.register("resetGlobalHist", gf({
|
|
11249
11259
|
sortGlobalHistogram: e,
|
|
11250
11260
|
bins: t
|
|
11251
11261
|
})().compute([
|
|
@@ -11256,7 +11266,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11256
11266
|
256,
|
|
11257
11267
|
1,
|
|
11258
11268
|
1
|
|
11259
|
-
])), this._kernelManager.register("globalHist",
|
|
11269
|
+
])), this._kernelManager.register("globalHist", _f({
|
|
11260
11270
|
hitBufferRO: v.hitBuffer.ro,
|
|
11261
11271
|
activeIndicesReadRO: y.getActiveReadRO(),
|
|
11262
11272
|
sortGlobalHistogram: e,
|
|
@@ -11270,7 +11280,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11270
11280
|
256,
|
|
11271
11281
|
1,
|
|
11272
11282
|
1
|
|
11273
|
-
])), this._kernelManager.register("globalPrefix",
|
|
11283
|
+
])), this._kernelManager.register("globalPrefix", vf({
|
|
11274
11284
|
sortGlobalHistogram: e,
|
|
11275
11285
|
bins: t
|
|
11276
11286
|
})().compute([
|
|
@@ -11281,7 +11291,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11281
11291
|
1,
|
|
11282
11292
|
1,
|
|
11283
11293
|
1
|
|
11284
|
-
])), this._kernelManager.register("globalScatter",
|
|
11294
|
+
])), this._kernelManager.register("globalScatter", yf({
|
|
11285
11295
|
hitBufferRO: v.hitBuffer.ro,
|
|
11286
11296
|
activeIndicesReadRO: y.getActiveReadRO(),
|
|
11287
11297
|
sortedIndicesRW: y.getSortedRW(),
|
|
@@ -11298,7 +11308,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11298
11308
|
1
|
|
11299
11309
|
]));
|
|
11300
11310
|
}
|
|
11301
|
-
let ve =
|
|
11311
|
+
let ve = af({
|
|
11302
11312
|
gBufferRW: s,
|
|
11303
11313
|
envCompensationDelta: this.envCompensationDelta,
|
|
11304
11314
|
bvhBuffer: ue,
|
|
@@ -11371,7 +11381,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11371
11381
|
]));
|
|
11372
11382
|
let ye = this._useSubgroupCompact && (this.renderer.hasFeature ? this.renderer.hasFeature("subgroups") : !1);
|
|
11373
11383
|
this._compactIsSubgroup = ye;
|
|
11374
|
-
let be = (ye ?
|
|
11384
|
+
let be = (ye ? cf : sf)({
|
|
11375
11385
|
rayBufferRO: v.rayBuffer.ro,
|
|
11376
11386
|
activeIndicesReadRO: y.getActiveReadRO(),
|
|
11377
11387
|
activeIndicesWriteRW: y.getActiveWrite(),
|
|
@@ -11403,21 +11413,21 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11403
11413
|
let e = oe, t = S(D.element(R(_u.ACTIVE_RAY_COUNT)));
|
|
11404
11414
|
p(e.equal(R(0)), () => {
|
|
11405
11415
|
let e = R(ee).clamp(R(0), R(y.MAX_BOUNCE_SNAPSHOTS - 1));
|
|
11406
|
-
O.element(e).assign(t), C(D.element(R(_u.ENTERING_COUNT)), t);
|
|
11416
|
+
O.element(e).assign(t), O.element(e.add(R(y.MAX_BOUNCE_SNAPSHOTS))).assign(S(D.element(R(_u.ACTIVE_ENERGY)))), C(D.element(R(_u.ENTERING_COUNT)), t);
|
|
11407
11417
|
}), p(e.greaterThanEqual(t), () => {
|
|
11408
11418
|
h();
|
|
11409
11419
|
}), Se.element(e).assign(I.element(e));
|
|
11410
11420
|
});
|
|
11411
11421
|
this._kernelManager.register("compactCopyback", Ce().compute([
|
|
11412
|
-
Math.ceil(i /
|
|
11422
|
+
Math.ceil(i / xf),
|
|
11413
11423
|
1,
|
|
11414
11424
|
1
|
|
11415
11425
|
], [
|
|
11416
|
-
|
|
11426
|
+
xf,
|
|
11417
11427
|
1,
|
|
11418
11428
|
1
|
|
11419
11429
|
]));
|
|
11420
|
-
let we =
|
|
11430
|
+
let we = uf({
|
|
11421
11431
|
rayBufferRO: v.rayBuffer.ro,
|
|
11422
11432
|
gBufferRO: c,
|
|
11423
11433
|
writeColorTex: E.color,
|
|
@@ -11461,7 +11471,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11461
11471
|
16,
|
|
11462
11472
|
1
|
|
11463
11473
|
]));
|
|
11464
|
-
let Te =
|
|
11474
|
+
let Te = hf({
|
|
11465
11475
|
writeColorTex: E.color,
|
|
11466
11476
|
writeNDTex: E.normalDepth,
|
|
11467
11477
|
writeAlbedoTex: E.albedo,
|
|
@@ -11504,7 +11514,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11504
11514
|
1
|
|
11505
11515
|
])), this._wavefrontReady = !0;
|
|
11506
11516
|
let De = (this._packedBuffers?.totalBytes ?? 0) + (this._queueManager?.totalBytes ?? 0);
|
|
11507
|
-
|
|
11517
|
+
bf.info(Q.list([
|
|
11508
11518
|
Q.px(t, n),
|
|
11509
11519
|
`${Q.mb(De)} wavefront buffers`,
|
|
11510
11520
|
`budget ${Q.n(r)} paths`,
|
|
@@ -11524,7 +11534,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11524
11534
|
dispose() {
|
|
11525
11535
|
super.dispose(), this._packedBuffers?.dispose(), this._queueManager?.dispose(), this._kernelManager?.dispose(), this._gBufferAttr?.dispose?.(), this._m2Attr?.dispose?.(), this._streakAttr?.dispose?.(), this._frozenMaskAttr?.dispose?.(), this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._m2Attr = null, this._streakAttr = null, this._frozenMaskAttr = null, this._convDebugSource = null, this._wavefrontReady = !1;
|
|
11526
11536
|
}
|
|
11527
|
-
},
|
|
11537
|
+
}, wf = class extends dr {
|
|
11528
11538
|
constructor(e, t = {}) {
|
|
11529
11539
|
super("NormalDepth", {
|
|
11530
11540
|
...t,
|
|
@@ -11569,10 +11579,10 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11569
11579
|
this._computeNode = f(([r, i]) => {
|
|
11570
11580
|
let l = j(Ue.x).mul(8).add(j(le.x)), u = j(Ue.y).mul(8).add(j(le.y));
|
|
11571
11581
|
p(l.lessThan(j(a)).and(u.lessThan(j(o))), () => {
|
|
11572
|
-
let d =
|
|
11582
|
+
let d = ku(V(A(l).add(.5).div(a), A(u).add(.5).div(o)), r, i, this.cameraProjection, this.panoLonRange, this.panoLatRange, this.panoLevelHorizon), f = ca({
|
|
11573
11583
|
origin: H(r[3]),
|
|
11574
11584
|
direction: d
|
|
11575
|
-
}), m = pa.wrap(
|
|
11585
|
+
}), m = pa.wrap(Hu(f, t, e)), h = m.normal.mul(.5).add(.5), g = pe(m.dst, A(65504)), _ = m.didHit.select(U(h, g), U(0, 0, 0, A(65504)));
|
|
11576
11586
|
Pe(s, ze(R(l), R(u)), _).toWriteOnly();
|
|
11577
11587
|
let v = m.normal.toVar();
|
|
11578
11588
|
p(m.didHit, () => {
|
|
@@ -11638,7 +11648,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11638
11648
|
dispose() {
|
|
11639
11649
|
this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose(), this._shadingRT?.dispose(), this._rtA?.dispose(), this._rtB?.dispose();
|
|
11640
11650
|
}
|
|
11641
|
-
},
|
|
11651
|
+
}, Tf = class extends dr {
|
|
11642
11652
|
constructor(e, t, n = {}) {
|
|
11643
11653
|
super("MotionVector", {
|
|
11644
11654
|
...n,
|
|
@@ -11758,7 +11768,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11758
11768
|
dispose() {
|
|
11759
11769
|
this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose(), this.screenSpaceTarget?.dispose(), this.worldSpaceTarget?.dispose(), this._normalDepthTexNode?.dispose();
|
|
11760
11770
|
}
|
|
11761
|
-
},
|
|
11771
|
+
}, Ef = (e) => I(e.equal(e), e, A(0)).clamp(0, 1e7), Df = (e) => H(Ef(e.x), Ef(e.y), Ef(e.z)), Of = class extends dr {
|
|
11762
11772
|
constructor(e, t = {}) {
|
|
11763
11773
|
super("ASVGF", {
|
|
11764
11774
|
...t,
|
|
@@ -11799,7 +11809,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11799
11809
|
let e = this._colorTexNode, t = this._albedoTexNode, n = this._motionTexNode, r = this._readTemporalTexNode, i = this.gradientNoiseFloor, a = this.gradientSigmaScale, o = this._gradientStorageTex, s = this.resW, c = this.resH, l = Ve("float", 144), u = Ve("float", 144);
|
|
11800
11810
|
this._gradientNode = f(() => {
|
|
11801
11811
|
let d = le.x, f = le.y, m = f.mul(8).add(d), h = j(Ue.x).mul(8).sub(2).toVar(), g = j(Ue.y).mul(8).sub(2).toVar(), v = (i) => {
|
|
11802
|
-
let a = i.mod(R(12)), o = i.div(R(12)), d = h.add(j(a)).clamp(j(0), j(s).sub(1)), f = g.add(j(o)).clamp(j(0), j(c).sub(1)), p = L(e, M(d, f)).xyz, m = L(t, M(d, f)).xyz, _ = Ia(
|
|
11812
|
+
let a = i.mod(R(12)), o = i.div(R(12)), d = h.add(j(a)).clamp(j(0), j(s).sub(1)), f = g.add(j(o)).clamp(j(0), j(c).sub(1)), p = L(e, M(d, f)).xyz, m = L(t, M(d, f)).xyz, _ = Ia(Df(p.div(N(m, H(Mr))))).toVar();
|
|
11803
11813
|
l.element(i).assign(_);
|
|
11804
11814
|
let v = L(n, M(d, f)), y = A(d).sub(v.x.mul(s)), b = A(f).sub(v.y.mul(c)), x = j(y.add(.5)).clamp(j(0), j(s).sub(1)), S = j(b.add(.5)).clamp(j(0), j(c).sub(1)), C = v.w.greaterThan(.5), w = L(r, M(x, S)).xyz, T = C.select(Ia(w), _);
|
|
11805
11815
|
u.element(i).assign(T);
|
|
@@ -11846,7 +11856,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11846
11856
|
return f(() => {
|
|
11847
11857
|
let f = j(Ue.x).mul(8).add(j(le.x)), y = j(Ue.y).mul(8).add(j(le.y));
|
|
11848
11858
|
p(f.lessThan(j(g)).and(y.lessThan(j(v))), () => {
|
|
11849
|
-
let b = M(f, y), x = L(t, b), S = x.xyz, C = x.w, w = L(n, b).xyz, T = N(w, H(Mr)), E =
|
|
11859
|
+
let b = M(f, y), x = L(t, b), S = x.xyz, C = x.w, w = L(n, b).xyz, T = N(w, H(Mr)), E = Df(S.div(T)), D = U(E, 1).toVar(), O = U(S, C).toVar();
|
|
11850
11860
|
p(m.greaterThan(.5).and(h.lessThan(.5)), () => {
|
|
11851
11861
|
let e = L(r, b), t = e.w.greaterThan(.5), n = A(f).sub(e.x.mul(g)), c = A(y).sub(e.y.mul(v)), m = n.greaterThanEqual(0).and(n.lessThan(A(g))).and(c.greaterThanEqual(0)).and(c.lessThan(A(v)));
|
|
11852
11862
|
p(t.and(m), () => {
|
|
@@ -11855,7 +11865,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11855
11865
|
return i.mul(l).mul(u);
|
|
11856
11866
|
}, le = ce(w, ne, ie), ue = ce(ee, ne, ae), de = ce(w, re, oe), fe = ce(ee, re, se), me = le.add(ue).add(de).add(fe);
|
|
11857
11867
|
p(me.greaterThan(A(.01)), () => {
|
|
11858
|
-
let e = L(o, M(w, ne)), t = L(o, M(ee, ne)), n = L(o, M(w, re)), r = L(o, M(ee, re)), i = A(1).div(me), a = e.xyz.mul(le).add(t.xyz.mul(ue)).add(n.xyz.mul(de)).add(r.xyz.mul(fe)).mul(i), c = e.w.mul(le).add(t.w.mul(ue)).add(n.w.mul(de)).add(r.w.mul(fe)).mul(i), f = L(s, b).x.mul(d).clamp(0, 1), p =
|
|
11868
|
+
let e = L(o, M(w, ne)), t = L(o, M(ee, ne)), n = L(o, M(w, re)), r = L(o, M(ee, re)), i = A(1).div(me), a = e.xyz.mul(le).add(t.xyz.mul(ue)).add(n.xyz.mul(de)).add(r.xyz.mul(fe)).mul(i), c = e.w.mul(le).add(t.w.mul(ue)).add(n.w.mul(de)).add(r.w.mul(fe)).mul(i), f = L(s, b).x.mul(d).clamp(0, 1), p = Df(P(a, E, P(N(A(1).div(c.add(1)), u), A(1), f))), m = pe(c.add(1), l);
|
|
11859
11869
|
D.assign(U(p, m)), O.assign(U(p.mul(T), C));
|
|
11860
11870
|
});
|
|
11861
11871
|
});
|
|
@@ -11973,7 +11983,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11973
11983
|
dispose() {
|
|
11974
11984
|
this._gradientNode?.dispose(), this._temporalNodeA?.dispose(), this._temporalNodeB?.dispose(), this._temporalTexA?.dispose(), this._temporalTexB?.dispose(), this._outputModulatedTex?.dispose(), this._gradientStorageTex?.dispose(), this._demodulatedRT?.dispose(), this._outputRT?.dispose(), this._gradientRT?.dispose(), this._heatmapComputeNode?.dispose(), this._heatmapStorageTex?.dispose(), this.heatmapTarget?.dispose(), this._colorTexNode?.dispose(), this._albedoTexNode?.dispose(), this._motionTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._prevNormalDepthTexNode?.dispose(), this._readTemporalTexNode?.dispose(), this._gradientReadTexNode?.dispose(), this._heatmapRawColorTexNode?.dispose(), this._heatmapColorTexNode?.dispose(), this._heatmapTemporalTexNode?.dispose(), this._heatmapNDTexNode?.dispose(), this._heatmapMotionTexNode?.dispose(), this._heatmapGradientTexNode?.dispose();
|
|
11975
11985
|
}
|
|
11976
|
-
},
|
|
11986
|
+
}, kf = (e) => I(e.equal(e), e, A(0)).clamp(0, 1e7), Af = /* @__PURE__ */ W("\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"), jf = class extends dr {
|
|
11977
11987
|
constructor(e, t = {}) {
|
|
11978
11988
|
super("VarianceEstimation", {
|
|
11979
11989
|
...t,
|
|
@@ -11999,9 +12009,9 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
11999
12009
|
let n = this._colorTexNode, r = this.temporalAlpha, i = this.varianceBoost, a = this.resW, o = this.resH, s = Ve("float", 100);
|
|
12000
12010
|
return f(() => {
|
|
12001
12011
|
let c = le.x, l = le.y, u = l.mul(8).add(c), d = j(Ue.x).mul(8).sub(1), f = j(Ue.y).mul(8).sub(1), m = u.mod(10), h = u.div(10), g = L(n, M(d.add(j(m)).clamp(j(0), j(a).sub(1)), f.add(j(h)).clamp(j(0), j(o).sub(1)))).xyz;
|
|
12002
|
-
s.element(u).assign(
|
|
12012
|
+
s.element(u).assign(kf(Ia(g))), p(u.lessThan(R(36)), () => {
|
|
12003
12013
|
let e = u.add(R(64)), t = e.mod(10), r = e.div(10), i = L(n, M(d.add(j(t)).clamp(j(0), j(a).sub(1)), f.add(j(r)).clamp(j(0), j(o).sub(1)))).xyz;
|
|
12004
|
-
s.element(e).assign(
|
|
12014
|
+
s.element(e).assign(kf(Ia(i)));
|
|
12005
12015
|
}), He();
|
|
12006
12016
|
let _ = j(Ue.x).mul(8).add(j(c)), v = j(Ue.y).mul(8).add(j(l));
|
|
12007
12017
|
p(_.lessThan(j(a)).and(v.lessThan(j(o))), () => {
|
|
@@ -12012,7 +12022,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12012
12022
|
}
|
|
12013
12023
|
n.divAssign(9), a.divAssign(9);
|
|
12014
12024
|
let o = N(a.sub(n.mul(n)), A(0)), u = s.element(l.add(1).mul(10).add(c.add(1))), d = L(t, M(_, v));
|
|
12015
|
-
Pe(e, ze(R(_), R(v)),
|
|
12025
|
+
Pe(e, ze(R(_), R(v)), Af(u, d.x, d.y, r, o, i)).toWriteOnly();
|
|
12016
12026
|
});
|
|
12017
12027
|
})().compute([
|
|
12018
12028
|
this._dispatchX,
|
|
@@ -12066,7 +12076,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12066
12076
|
dispose() {
|
|
12067
12077
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._colorTexNode?.dispose(), this._readTexNodeA?.dispose(), this._readTexNodeB?.dispose();
|
|
12068
12078
|
}
|
|
12069
|
-
},
|
|
12079
|
+
}, Mf = /* @__PURE__ */ W("\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 sigmaL: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) / sigmaL );\n // clamp dot to [0,1]: miss-ray normals decode to (-1,-1,-1) with\n // dot=3 → pow saturates to +inf → inf*0 = NaN. See project_tsl_pitfalls.\n // max(phiNorm, 1e-6): pow(0.0, 0.0) is undefined in WGSL and returned NaN on ~12%\n // of pixels when phiNormal was set to 0.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), max( phiNorm, 1e-6 ) );\n let depW = exp( -abs( centerDepth - sDepth ) / max( centerDepth * 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 avgLum = max( ( centerLum + sLum ) * 0.5, 0.0001 );\n let colW = exp( -( maxDiff / avgLum ) / max( phiCol, 0.0001 ) );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), Nf = class extends dr {
|
|
12070
12080
|
constructor(e, t = {}) {
|
|
12071
12081
|
super("BilateralFiltering", {
|
|
12072
12082
|
...t,
|
|
@@ -12121,7 +12131,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12121
12131
|
return P(t.z, N(t.z, t.w), d);
|
|
12122
12132
|
}, te = ee.select(k(p), x.w.mul(x.w)).toVar(), ne = u.mul(Te(N(te, A(0)))).div(O).add(A(1e-4)), re = H(0).toVar(), ie = A(0).toVar(), ae = A(0).toVar();
|
|
12123
12133
|
for (let e = 0; e < 5; e++) for (let i = 0; i < 5; i++) {
|
|
12124
|
-
let a = i - 2, o = e - 2, u = y[e * 5 + i], d = f.add(m.mul(a)).clamp(j(0), j(_).sub(1)), p = b.add(m.mul(o)).clamp(j(0), j(v).sub(1)), h = L(t, M(d, p)), g = h.xyz, x = L(n, M(d, p)), C = L(r, M(d, p)).xyz.mul(2).sub(1), D = x.w, O =
|
|
12134
|
+
let a = i - 2, o = e - 2, u = y[e * 5 + i], d = f.add(m.mul(a)).clamp(j(0), j(_).sub(1)), p = b.add(m.mul(o)).clamp(j(0), j(v).sub(1)), h = L(t, M(d, p)), g = h.xyz, x = L(n, M(d, p)), C = L(r, M(d, p)).xyz.mul(2).sub(1), D = x.w, O = Mf(E, Ia(g), w, C, T, D, S, g, A(u), ne, c, l, s), te = ee.select(k(M(d, p)), h.w.mul(h.w));
|
|
12125
12135
|
re.addAssign(g.mul(O)), ie.addAssign(O), ae.addAssign(O.mul(O).mul(N(te, A(0))));
|
|
12126
12136
|
}
|
|
12127
12137
|
let oe = re.div(N(ie, A(1e-4))), se = ae.div(N(ie.mul(ie), A(1e-8))), ce = h.equal(j(1)), le = ce.select(oe.mul(D), oe), ue = ce.select(L(o, p).w, Te(N(se, A(0))));
|
|
@@ -12180,7 +12190,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12180
12190
|
dispose() {
|
|
12181
12191
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._readTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._shadingNormalTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varianceTexNode?.dispose(), this._srcAlphaTexNode?.dispose();
|
|
12182
12192
|
}
|
|
12183
|
-
},
|
|
12193
|
+
}, Pf = 6e4, Ff = (e) => I(e.equal(e), e, A(0)).clamp(0, 1e7), If = (e) => H(Ff(e.x), Ff(e.y), Ff(e.z)), Lf = 4, Rf = [
|
|
12184
12194
|
1 / 256,
|
|
12185
12195
|
4 / 256,
|
|
12186
12196
|
6 / 256,
|
|
@@ -12206,7 +12216,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12206
12216
|
6 / 256,
|
|
12207
12217
|
4 / 256,
|
|
12208
12218
|
1 / 256
|
|
12209
|
-
],
|
|
12219
|
+
], zf = class extends dr {
|
|
12210
12220
|
constructor(e, t = {}) {
|
|
12211
12221
|
super("EdgeAwareFiltering", {
|
|
12212
12222
|
...t,
|
|
@@ -12234,7 +12244,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12234
12244
|
return f(() => {
|
|
12235
12245
|
let o = j(Ue.x).mul(16).add(j(le.x)), s = j(Ue.y).mul(16).add(j(le.y));
|
|
12236
12246
|
p(o.lessThan(j(i)).and(s.lessThan(j(a))), () => {
|
|
12237
|
-
let i = M(o, s), a = L(e, i).xyz, c = L(t, i).w.lessThan(A(
|
|
12247
|
+
let i = M(o, s), a = L(e, i).xyz, c = L(t, i).w.lessThan(A(Pf)), l = L(n, i).xyz, u = I(c, N(l, H(Mr)), H(1)), d = If(a.div(u));
|
|
12238
12248
|
Pe(r, ze(R(o), R(s)), U(d, 1)).toWriteOnly();
|
|
12239
12249
|
});
|
|
12240
12250
|
})().compute([
|
|
@@ -12252,12 +12262,12 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12252
12262
|
return f(() => {
|
|
12253
12263
|
let f = j(Ue.x).mul(16).add(j(le.x)), y = j(Ue.y).mul(16).add(j(le.y));
|
|
12254
12264
|
p(f.lessThan(j(_)).and(y.lessThan(j(v))), () => {
|
|
12255
|
-
let p = M(f, y), b = L(t, p), x = b.xyz, S = Ia(x), C = L(r, p).w, w = L(i, p).xyz.mul(2).sub(1), T = C.lessThan(A(
|
|
12265
|
+
let p = M(f, y), b = L(t, p), x = b.xyz, S = Ia(x), C = L(r, p).w, w = L(i, p).xyz.mul(2).sub(1), T = C.lessThan(A(Pf)), E = I(T, A(1), A(0)), D = L(a, p).xyz, O = I(T, N(D, H(Mr)), H(1)), ee = N(Ia(O), A(Mr)), te = h.equal(j(1)), ne = g.lessThan(j(Lf)), re = (e) => {
|
|
12256
12266
|
let t = L(o, e);
|
|
12257
12267
|
return I(ne, N(t.z, t.w), t.z);
|
|
12258
12268
|
}, ie = te.select(re(p), b.w.mul(b.w)).toVar(), ae = c.mul(Te(N(ie, A(0)))).div(ee).add(A(1e-4)), oe = H(0).toVar(), se = A(0).toVar(), ce = A(0).toVar();
|
|
12259
12269
|
for (let e = 0; e < 5; e++) for (let n = 0; n < 5; n++) {
|
|
12260
|
-
let a = n - 2, o = e - 2, s =
|
|
12270
|
+
let a = n - 2, o = e - 2, s = Rf[e * 5 + n], c = M(f.add(d.mul(a)).clamp(j(0), j(_).sub(1)), y.add(d.mul(o)).clamp(j(0), j(v).sub(1))), p = L(t, c), m = p.xyz, h = Ia(m), g = L(r, c).w, b = L(i, c).xyz.mul(2).sub(1), x = I(g.lessThan(A(Pf)), A(1), A(0)), T = S.sub(h).abs().div(ae).negate().exp(), D = ve(k(w, b).clamp(0, 1), l), O = C.sub(g).abs().div(N(C.mul(u), A(.001))).negate().exp(), ee = E.mul(x), ne = E.oneMinus().mul(x.oneMinus()), ie = ee.add(ne), le = P(A(1), D.mul(O), ee), ue = A(s).mul(T).mul(le).mul(ie), de = te.select(re(c), p.w.mul(p.w));
|
|
12261
12271
|
oe.addAssign(m.mul(ue)), se.addAssign(ue), ce.addAssign(ue.mul(ue).mul(N(de, A(0))));
|
|
12262
12272
|
}
|
|
12263
12273
|
let le = oe.div(N(se, A(1e-4))), ue = ce.div(N(se.mul(se), A(1e-8))), de = m.equal(j(1)), fe = L(n, p).xyz, pe = P(fe, le.mul(O), s), me = de.select(pe, le), F = de.select(L(n, p).w, Te(N(ue, A(0))));
|
|
@@ -12319,7 +12329,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12319
12329
|
dispose() {
|
|
12320
12330
|
this._computeDemod?.dispose(), this._computeAtrousA?.dispose(), this._computeAtrousB?.dispose(), this._demodTex?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this.outputTarget?.dispose(), this._colorTexNode?.dispose(), this._ndTexNode?.dispose(), this._snTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varTexNode?.dispose(), this._readTexNode?.dispose();
|
|
12321
12331
|
}
|
|
12322
|
-
},
|
|
12332
|
+
}, Bf = 256, Vf = -8, Hf = 6 - Vf, Uf = Hf / Bf, Wf = 1e4, Gf = /* @__PURE__ */ W("\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"), Kf = class extends dr {
|
|
12323
12333
|
constructor(e, t = {}) {
|
|
12324
12334
|
super("AutoExposure", {
|
|
12325
12335
|
...t,
|
|
@@ -12335,7 +12345,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12335
12345
|
depthBuffer: !1,
|
|
12336
12346
|
stencilBuffer: !1
|
|
12337
12347
|
};
|
|
12338
|
-
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = pt, this._downsampleStorageTex.format = q, this._downsampleStorageTex.minFilter = kt, this._downsampleStorageTex.magFilter = kt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = pt, this._reductionStorageTex.format = q, this._reductionStorageTex.minFilter = kt, this._reductionStorageTex.magFilter = kt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(
|
|
12348
|
+
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = pt, this._downsampleStorageTex.format = q, this._downsampleStorageTex.minFilter = kt, this._downsampleStorageTex.magFilter = kt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = pt, this._reductionStorageTex.format = q, this._reductionStorageTex.minFilter = kt, this._reductionStorageTex.magFilter = kt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(Bf, "uint").toAtomic();
|
|
12339
12349
|
}
|
|
12340
12350
|
_buildCompute() {
|
|
12341
12351
|
this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
|
|
@@ -12369,7 +12379,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12369
12379
|
for (let i = 0; i < 16; i++) {
|
|
12370
12380
|
let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = L(e, M(j(o), j(s))), l = c.x, u = c.y;
|
|
12371
12381
|
p(u.greaterThan(0), () => {
|
|
12372
|
-
let e = R(l.div(u).sub(A(
|
|
12382
|
+
let e = R(l.div(u).sub(A(Vf)).div(A(Hf)).mul(A(Bf)).floor().clamp(0, A(Bf - 1))), r = A(o).add(.5).div(A(64)), i = A(s).add(.5).div(A(64)), a = r.sub(.5), c = i.sub(.5), d = R(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(A(Wf)));
|
|
12373
12383
|
x(t.element(e), d);
|
|
12374
12384
|
});
|
|
12375
12385
|
}
|
|
@@ -12387,14 +12397,14 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12387
12397
|
let e = this._histogramBuffer, t = this._reductionStorageTex, n = this.lowPercentileU, r = this.highPercentileU;
|
|
12388
12398
|
this._histogramAnalyzeNode = f(() => {
|
|
12389
12399
|
let i = A(0).toVar();
|
|
12390
|
-
m(
|
|
12400
|
+
m(Bf, ({ i: t }) => {
|
|
12391
12401
|
i.addAssign(A(S(e.element(t))));
|
|
12392
12402
|
});
|
|
12393
12403
|
let a = i.mul(n), o = i.mul(r), s = A(0).toVar(), c = A(0).toVar(), l = A(0).toVar(), u = A(0).toVar();
|
|
12394
|
-
m(
|
|
12404
|
+
m(Bf, ({ i: t }) => {
|
|
12395
12405
|
let n = A(S(e.element(t)));
|
|
12396
12406
|
u.assign(s), s.addAssign(n), p(u.lessThan(o).and(s.greaterThan(a)), () => {
|
|
12397
|
-
let e = A(
|
|
12407
|
+
let e = A(Vf).add(A(t).add(.5).mul(A(Uf)));
|
|
12398
12408
|
c.addAssign(e.mul(n)), l.addAssign(n);
|
|
12399
12409
|
});
|
|
12400
12410
|
});
|
|
@@ -12409,7 +12419,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12409
12419
|
_buildAdaptationCompute() {
|
|
12410
12420
|
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;
|
|
12411
12421
|
this._adaptationComputeNode = f(() => {
|
|
12412
|
-
let u = L(e, M(j(0), j(0))).x, d =
|
|
12422
|
+
let u = L(e, M(j(0), j(0))).x, d = Gf(u, l, n, r, i, a, o, s, c);
|
|
12413
12423
|
t.element(R(0)).assign(d);
|
|
12414
12424
|
})().compute(1, [
|
|
12415
12425
|
1,
|
|
@@ -12473,7 +12483,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12473
12483
|
dispose() {
|
|
12474
12484
|
this._downsampleComputeNode?.dispose(), this._histogramComputeNode?.dispose(), this._histogramAnalyzeNode?.dispose(), this._adaptationComputeNode?.dispose(), this._downsampleTarget?.dispose(), this._downsampleStorageTex?.dispose(), this._reductionStorageTex?.dispose(), this._reductionReadTarget?.dispose(), this._readbackBuffer?.dispose(), this._inputTexNode?.dispose(), this._reductionReadTexNode?.dispose();
|
|
12475
12485
|
}
|
|
12476
|
-
},
|
|
12486
|
+
}, qf = class extends dr {
|
|
12477
12487
|
constructor(n, r = {}) {
|
|
12478
12488
|
super("Compositor", {
|
|
12479
12489
|
...r,
|
|
@@ -12527,7 +12537,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12527
12537
|
dispose() {
|
|
12528
12538
|
this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugMaterial?.dispose(), this.compositorQuad = null, this._debugQuad = null, this._debugMaterial = null, this._debugTexNode = null, this._pathTracer = null;
|
|
12529
12539
|
}
|
|
12530
|
-
},
|
|
12540
|
+
}, Jf = class {
|
|
12531
12541
|
constructor() {
|
|
12532
12542
|
this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
|
|
12533
12543
|
frame: 0,
|
|
@@ -12649,7 +12659,7 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12649
12659
|
dispose() {
|
|
12650
12660
|
this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
|
|
12651
12661
|
}
|
|
12652
|
-
},
|
|
12662
|
+
}, Yf = class extends dt {
|
|
12653
12663
|
constructor() {
|
|
12654
12664
|
super(), this._onceCallbacks = /* @__PURE__ */ new Map();
|
|
12655
12665
|
}
|
|
@@ -12687,38 +12697,38 @@ var vf = fi("wavefront"), yf = 256, bf = [
|
|
|
12687
12697
|
eventNames() {
|
|
12688
12698
|
return this._listeners ? Object.keys(this._listeners) : [];
|
|
12689
12699
|
}
|
|
12690
|
-
},
|
|
12691
|
-
function
|
|
12692
|
-
|
|
12700
|
+
}, Xf = !1, Zf = [], Qf = /* @__PURE__ */ new WeakMap();
|
|
12701
|
+
function $f(e) {
|
|
12702
|
+
Xf = !!e;
|
|
12693
12703
|
}
|
|
12694
|
-
function
|
|
12695
|
-
return
|
|
12704
|
+
function ep() {
|
|
12705
|
+
return Zf.slice();
|
|
12696
12706
|
}
|
|
12697
|
-
function
|
|
12698
|
-
|
|
12707
|
+
function tp() {
|
|
12708
|
+
Zf.length = 0;
|
|
12699
12709
|
}
|
|
12700
|
-
function
|
|
12710
|
+
function np(e) {
|
|
12701
12711
|
let t = [];
|
|
12702
12712
|
for (let n of Object.keys(e)) e[n]?.isTextureNode === !0 && t.push(n);
|
|
12703
12713
|
return t;
|
|
12704
12714
|
}
|
|
12705
|
-
var
|
|
12706
|
-
function
|
|
12707
|
-
if (!
|
|
12715
|
+
var rp = (e) => !e || !e.image || !(e.image.width > 0);
|
|
12716
|
+
function ip(e, t, n) {
|
|
12717
|
+
if (!Xf) {
|
|
12708
12718
|
n();
|
|
12709
12719
|
return;
|
|
12710
12720
|
}
|
|
12711
|
-
let r =
|
|
12721
|
+
let r = Qf.get(e);
|
|
12712
12722
|
if (r || (r = {
|
|
12713
12723
|
phase: "pending",
|
|
12714
12724
|
unboundAtCompile: []
|
|
12715
|
-
},
|
|
12716
|
-
n(), r.phase === "watch" &&
|
|
12725
|
+
}, Qf.set(e, r)), r.phase !== "pending") {
|
|
12726
|
+
n(), r.phase === "watch" && ap(e, r);
|
|
12717
12727
|
return;
|
|
12718
12728
|
}
|
|
12719
12729
|
let i = Object.prototype.hasOwnProperty.call(t, "compute"), a = t.compute;
|
|
12720
12730
|
t.compute = function(...t) {
|
|
12721
|
-
return r.phase === "pending" && (r.unboundAtCompile =
|
|
12731
|
+
return r.phase === "pending" && (r.unboundAtCompile = np(e).filter((t) => rp(e[t].value)), r.phase = r.unboundAtCompile.length < 2 ? "done" : "watch"), a.apply(this, t);
|
|
12722
12732
|
};
|
|
12723
12733
|
try {
|
|
12724
12734
|
n();
|
|
@@ -12726,14 +12736,14 @@ function np(e, t, n) {
|
|
|
12726
12736
|
i ? t.compute = a : delete t.compute;
|
|
12727
12737
|
}
|
|
12728
12738
|
}
|
|
12729
|
-
function
|
|
12739
|
+
function ap(e, t) {
|
|
12730
12740
|
let n = [];
|
|
12731
12741
|
for (let r of t.unboundAtCompile) {
|
|
12732
12742
|
let t = e[r]?.value;
|
|
12733
|
-
if (
|
|
12743
|
+
if (rp(t)) return;
|
|
12734
12744
|
t.isStorageTexture !== !0 && n.push(r);
|
|
12735
12745
|
}
|
|
12736
|
-
t.phase = "done", n.length !== 0 &&
|
|
12746
|
+
t.phase = "done", n.length !== 0 && Zf.push({
|
|
12737
12747
|
stage: e.name,
|
|
12738
12748
|
nodes: n,
|
|
12739
12749
|
unboundAtCompile: t.unboundAtCompile.slice(),
|
|
@@ -12742,7 +12752,7 @@ function rp(e, t) {
|
|
|
12742
12752
|
}
|
|
12743
12753
|
//#endregion
|
|
12744
12754
|
//#region src/Pipeline/RenderPipeline.js
|
|
12745
|
-
var
|
|
12755
|
+
var op = class {
|
|
12746
12756
|
_reportStageFailure(e, t, n) {
|
|
12747
12757
|
console.error(`[Pipeline] Error in stage '${e}' (${t}):`, n);
|
|
12748
12758
|
let r = `${e}:${t}`;
|
|
@@ -12753,7 +12763,7 @@ var ip = class {
|
|
|
12753
12763
|
}));
|
|
12754
12764
|
}
|
|
12755
12765
|
constructor(e, t, n, { issues: r = null } = {}) {
|
|
12756
|
-
this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new
|
|
12766
|
+
this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new Jf(), this.eventBus = new Yf(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
|
|
12757
12767
|
enabled: !1,
|
|
12758
12768
|
logSkipped: !1,
|
|
12759
12769
|
timings: /* @__PURE__ */ new Map(),
|
|
@@ -12787,7 +12797,7 @@ var ip = class {
|
|
|
12787
12797
|
}
|
|
12788
12798
|
try {
|
|
12789
12799
|
let n = this.stats.enabled ? performance.now() : 0;
|
|
12790
|
-
if (
|
|
12800
|
+
if (ip(t, this.renderer, () => t.render(this.context, e)), this.stats.enabled) {
|
|
12791
12801
|
let e = performance.now() - n;
|
|
12792
12802
|
this.stats.timings.has(t.name) || this.stats.timings.set(t.name, []);
|
|
12793
12803
|
let r = this.stats.timings.get(t.name);
|
|
@@ -12885,7 +12895,7 @@ var ip = class {
|
|
|
12885
12895
|
let e = this.getInfo();
|
|
12886
12896
|
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();
|
|
12887
12897
|
}
|
|
12888
|
-
},
|
|
12898
|
+
}, sp = fi("engine"), cp = class {
|
|
12889
12899
|
constructor() {
|
|
12890
12900
|
this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1, this.budgetOverrun = !1, this._budgetHeldWarned = !1;
|
|
12891
12901
|
}
|
|
@@ -12893,7 +12903,7 @@ var ip = class {
|
|
|
12893
12903
|
this.timeElapsed = (performance.now() - this.lastResetTime) / 1e3;
|
|
12894
12904
|
}
|
|
12895
12905
|
isTimeLimitReached(e, t, n) {
|
|
12896
|
-
return t !== "time" || !(n > 0) || this.timeElapsed < n ? !1 : e?.frameCount > 0 ? (this.budgetOverrun = !0, !0) : (this._budgetHeldWarned || (this._budgetHeldWarned = !0,
|
|
12906
|
+
return t !== "time" || !(n > 0) || this.timeElapsed < n ? !1 : e?.frameCount > 0 ? (this.budgetOverrun = !0, !0) : (this._budgetHeldWarned || (this._budgetHeldWarned = !0, sp.warn(`render time limit (${n}s) expired before the first sample landed — holding the deadline open to avoid capturing an empty frame`)), !1);
|
|
12897
12907
|
}
|
|
12898
12908
|
isLimitReached(e, t, n) {
|
|
12899
12909
|
return e ? this.isTimeLimitReached(e, t, n) ? !0 : this.stopCondition(e) !== null : !1;
|
|
@@ -12910,7 +12920,7 @@ var ip = class {
|
|
|
12910
12920
|
resumeFromPause() {
|
|
12911
12921
|
this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
|
|
12912
12922
|
}
|
|
12913
|
-
},
|
|
12923
|
+
}, lp = class extends dt {
|
|
12914
12924
|
constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
|
|
12915
12925
|
super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new Ut(), 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, this._helperScene = null;
|
|
12916
12926
|
}
|
|
@@ -13146,7 +13156,7 @@ var ip = class {
|
|
|
13146
13156
|
dispose() {
|
|
13147
13157
|
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;
|
|
13148
13158
|
}
|
|
13149
|
-
},
|
|
13159
|
+
}, up = {
|
|
13150
13160
|
maxBounces: {
|
|
13151
13161
|
uniform: "maxBounces",
|
|
13152
13162
|
reset: !0
|
|
@@ -13337,15 +13347,15 @@ var ip = class {
|
|
|
13337
13347
|
},
|
|
13338
13348
|
renderMode: { handler: "handleRenderMode" },
|
|
13339
13349
|
environmentRotation: { handler: "handleEnvironmentRotation" }
|
|
13340
|
-
},
|
|
13350
|
+
}, dp = Object.freeze({
|
|
13341
13351
|
DEFAULT: "default",
|
|
13342
13352
|
HOST: "host",
|
|
13343
13353
|
SCENE_METADATA: "scene-metadata",
|
|
13344
13354
|
MODE_PRESET: "mode-preset"
|
|
13345
|
-
}),
|
|
13355
|
+
}), fp = {
|
|
13346
13356
|
bounces: "maxBounces",
|
|
13347
13357
|
debugMode: "visMode"
|
|
13348
|
-
},
|
|
13358
|
+
}, pp = class extends dt {
|
|
13349
13359
|
constructor(e = J, { issues: t = null } = {}) {
|
|
13350
13360
|
super(), this._issues = t, this._values = /* @__PURE__ */ new Map(), this._sources = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._delegates = {}, this._initDefaults(e);
|
|
13351
13361
|
}
|
|
@@ -13399,7 +13409,7 @@ var ip = class {
|
|
|
13399
13409
|
}
|
|
13400
13410
|
};
|
|
13401
13411
|
}
|
|
13402
|
-
set(e, t, { reset: n, silent: r, source: i =
|
|
13412
|
+
set(e, t, { reset: n, silent: r, source: i = dp.HOST } = {}) {
|
|
13403
13413
|
let a = this._applyOne(e, t, i);
|
|
13404
13414
|
a?.route && ((n === void 0 ? a.route.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
13405
13415
|
type: pr.SETTING_CHANGED,
|
|
@@ -13408,7 +13418,7 @@ var ip = class {
|
|
|
13408
13418
|
prev: a.prev
|
|
13409
13419
|
}));
|
|
13410
13420
|
}
|
|
13411
|
-
setMany(e, { silent: t, reset: n, source: r =
|
|
13421
|
+
setMany(e, { silent: t, reset: n, source: r = dp.HOST } = {}) {
|
|
13412
13422
|
let i = !1;
|
|
13413
13423
|
for (let [n, a] of Object.entries(e)) {
|
|
13414
13424
|
let e = this._applyOne(n, a, r);
|
|
@@ -13425,7 +13435,7 @@ var ip = class {
|
|
|
13425
13435
|
let r = this._values.get(e);
|
|
13426
13436
|
if (r === t) return null;
|
|
13427
13437
|
this._values.set(e, t), this._sources.set(e, n);
|
|
13428
|
-
let i =
|
|
13438
|
+
let i = up[e];
|
|
13429
13439
|
return i ? (this._applyRoute(i, t, r), {
|
|
13430
13440
|
route: i,
|
|
13431
13441
|
prev: r
|
|
@@ -13444,8 +13454,8 @@ var ip = class {
|
|
|
13444
13454
|
let e = {};
|
|
13445
13455
|
for (let [t, n] of this._values) e[t] = {
|
|
13446
13456
|
value: n,
|
|
13447
|
-
source: this._sources.get(t) ??
|
|
13448
|
-
routed:
|
|
13457
|
+
source: this._sources.get(t) ?? dp.DEFAULT,
|
|
13458
|
+
routed: up[t] !== void 0
|
|
13449
13459
|
};
|
|
13450
13460
|
return e;
|
|
13451
13461
|
}
|
|
@@ -13454,7 +13464,7 @@ var ip = class {
|
|
|
13454
13464
|
}
|
|
13455
13465
|
applyAll() {
|
|
13456
13466
|
for (let [e, t] of this._values) {
|
|
13457
|
-
let n =
|
|
13467
|
+
let n = up[e];
|
|
13458
13468
|
n && this._applyRoute(n, t, void 0);
|
|
13459
13469
|
}
|
|
13460
13470
|
}
|
|
@@ -13462,42 +13472,42 @@ var ip = class {
|
|
|
13462
13472
|
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);
|
|
13463
13473
|
}
|
|
13464
13474
|
_initDefaults(e) {
|
|
13465
|
-
for (let t of Object.keys(
|
|
13466
|
-
for (let [t, n] of Object.entries(
|
|
13475
|
+
for (let t of Object.keys(up)) t in e && (this._values.set(t, e[t]), this._sources.set(t, dp.DEFAULT));
|
|
13476
|
+
for (let [t, n] of Object.entries(fp)) t in e && (this._values.set(n, e[t]), this._sources.set(n, dp.DEFAULT));
|
|
13467
13477
|
}
|
|
13468
|
-
},
|
|
13469
|
-
function pp(e, t, n, r, i) {
|
|
13470
|
-
i[0] = fp(e), i[1] = fp(t), i[2] = fp(n);
|
|
13471
|
-
}
|
|
13472
|
-
function mp(e, t, n, r, i) {
|
|
13473
|
-
i[0] = fp(e * r), i[1] = fp(t * r), i[2] = fp(n * r);
|
|
13474
|
-
}
|
|
13478
|
+
}, mp = (e) => Math.min(Math.max(e, 0), 1);
|
|
13475
13479
|
function hp(e, t, n, r, i) {
|
|
13476
|
-
|
|
13480
|
+
i[0] = mp(e), i[1] = mp(t), i[2] = mp(n);
|
|
13477
13481
|
}
|
|
13478
13482
|
function gp(e, t, n, r, i) {
|
|
13483
|
+
i[0] = mp(e * r), i[1] = mp(t * r), i[2] = mp(n * r);
|
|
13484
|
+
}
|
|
13485
|
+
function _p(e, t, n, r, i) {
|
|
13486
|
+
e *= r, t *= r, n *= r, i[0] = mp(e / (e + 1)), i[1] = mp(t / (t + 1)), i[2] = mp(n / (n + 1));
|
|
13487
|
+
}
|
|
13488
|
+
function vp(e, t, n, r, i) {
|
|
13479
13489
|
e = Math.max(e * r - .004, 0), t = Math.max(t * r - .004, 0), n = Math.max(n * r - .004, 0);
|
|
13480
13490
|
let a = (e) => (e * (6.2 * e + .5) / (e * (6.2 * e + 1.7) + .06)) ** 2.2;
|
|
13481
13491
|
i[0] = a(e), i[1] = a(t), i[2] = a(n);
|
|
13482
13492
|
}
|
|
13483
|
-
function
|
|
13493
|
+
function yp(e, t, n, r, i) {
|
|
13484
13494
|
e = e * r / .6, t = t * r / .6, n = n * r / .6;
|
|
13485
13495
|
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);
|
|
13486
|
-
a = c(a), o = c(o), s = c(s), i[0] =
|
|
13496
|
+
a = c(a), o = c(o), s = c(s), i[0] = mp(1.60475 * a - .53108 * o - .07367 * s), i[1] = mp(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = mp(-.00327 * a - .07276 * o + 1.07602 * s);
|
|
13487
13497
|
}
|
|
13488
|
-
function
|
|
13498
|
+
function bp(e, t, n, r, i) {
|
|
13489
13499
|
e *= r, t *= r, n *= r;
|
|
13490
13500
|
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;
|
|
13491
|
-
c =
|
|
13501
|
+
c = mp((Math.log2(Math.max(c, 1e-10)) - d) / f), l = mp((Math.log2(Math.max(l, 1e-10)) - d) / f), u = mp((Math.log2(Math.max(u, 1e-10)) - d) / f);
|
|
13492
13502
|
let p = (e) => {
|
|
13493
13503
|
let t = e * e, n = t * t;
|
|
13494
13504
|
return 15.5 * n * t - 40.14 * n * e + 31.96 * n - 6.868 * t * e + .4298 * t + .1191 * e - .00232;
|
|
13495
13505
|
};
|
|
13496
13506
|
c = p(c), l = p(l), u = p(u);
|
|
13497
13507
|
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;
|
|
13498
|
-
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] =
|
|
13508
|
+
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = mp(1.6605 * m - .5876 * h - .0728 * g), i[1] = mp(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = mp(-.0182 * m - .1006 * h + 1.1187 * g);
|
|
13499
13509
|
}
|
|
13500
|
-
function
|
|
13510
|
+
function xp(e, t, n, r, i) {
|
|
13501
13511
|
let a = .76;
|
|
13502
13512
|
e *= r, t *= r, n *= r;
|
|
13503
13513
|
let o = Math.min(e, Math.min(t, n)), s = o < .08 ? o - 6.25 * o * o : .04;
|
|
@@ -13512,50 +13522,50 @@ function yp(e, t, n, r, i) {
|
|
|
13512
13522
|
let f = 1 - 1 / (.15 * (c - u) + 1);
|
|
13513
13523
|
i[0] = e + (u - e) * f, i[1] = t + (u - t) * f, i[2] = n + (u - n) * f;
|
|
13514
13524
|
}
|
|
13515
|
-
var
|
|
13516
|
-
[Mt,
|
|
13517
|
-
[K,
|
|
13518
|
-
[Kt,
|
|
13519
|
-
[$e,
|
|
13520
|
-
[We,
|
|
13521
|
-
[Ke, bp
|
|
13522
|
-
[At,
|
|
13523
|
-
]),
|
|
13524
|
-
function
|
|
13525
|
+
var Sp = (e) => (t, n, r, i, a) => e(t > 0 ? t : 0, n > 0 ? n : 0, r > 0 ? r : 0, i, a), Cp = new Map([
|
|
13526
|
+
[Mt, Sp(hp)],
|
|
13527
|
+
[K, Sp(gp)],
|
|
13528
|
+
[Kt, Sp(_p)],
|
|
13529
|
+
[$e, Sp(vp)],
|
|
13530
|
+
[We, Sp(yp)],
|
|
13531
|
+
[Ke, Sp(bp)],
|
|
13532
|
+
[At, Sp(xp)]
|
|
13533
|
+
]), wp = 1 / 2.2;
|
|
13534
|
+
function Tp(e) {
|
|
13525
13535
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
13526
13536
|
}
|
|
13527
|
-
function
|
|
13537
|
+
function Ep(e, t) {
|
|
13528
13538
|
return t === Mt ? 1 : e;
|
|
13529
13539
|
}
|
|
13530
|
-
var
|
|
13531
|
-
function
|
|
13540
|
+
var Dp = .2126, Op = .7152, kp = .0722;
|
|
13541
|
+
function Ap(e, t) {
|
|
13532
13542
|
if (t === 1) return;
|
|
13533
|
-
let n = e[0] *
|
|
13543
|
+
let n = e[0] * Dp + e[1] * Op + e[2] * kp;
|
|
13534
13544
|
e[0] = n + (e[0] - n) * t, e[1] = n + (e[1] - n) * t, e[2] = n + (e[2] - n) * t;
|
|
13535
13545
|
}
|
|
13536
|
-
function
|
|
13537
|
-
let a =
|
|
13546
|
+
function jp(e, { exposure: t, toneMapping: n, saturation: r = 1, preserveAlpha: i = !1 }) {
|
|
13547
|
+
let a = Cp.get(n) ?? Cp.get(Mt), o = Ep(t, n), s = new Uint8ClampedArray(e.length), c = [
|
|
13538
13548
|
0,
|
|
13539
13549
|
0,
|
|
13540
13550
|
0
|
|
13541
13551
|
];
|
|
13542
|
-
for (let t = 0; t < e.length; t += 4) c[0] = e[t] * o, c[1] = e[t + 1] * o, c[2] = e[t + 2] * o,
|
|
13552
|
+
for (let t = 0; t < e.length; t += 4) c[0] = e[t] * o, c[1] = e[t + 1] * o, c[2] = e[t + 2] * o, Ap(c, r), a(c[0], c[1], c[2], 1, c), s[t] = Tp(c[0]) * 255 + .5, s[t + 1] = Tp(c[1]) * 255 + .5, s[t + 2] = Tp(c[2]) * 255 + .5, s[t + 3] = i ? e[t + 3] * 255 + .5 : 255;
|
|
13543
13553
|
return s;
|
|
13544
13554
|
}
|
|
13545
13555
|
//#endregion
|
|
13546
13556
|
//#region src/Processor/PBRT/PBRTTokenizer.js
|
|
13547
|
-
var
|
|
13557
|
+
var Mp = {
|
|
13548
13558
|
STRING: "string",
|
|
13549
13559
|
NUMBER: "number",
|
|
13550
13560
|
WORD: "word",
|
|
13551
13561
|
LBRACKET: "[",
|
|
13552
13562
|
RBRACKET: "]"
|
|
13553
|
-
},
|
|
13554
|
-
function
|
|
13563
|
+
}, Np = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f", Pp = (e) => e >= "0" && e <= "9", Fp = (e, t, n) => !!(Pp(e) || e === "." && Pp(t) || (e === "-" || e === "+") && (Pp(t) || t === "." && Pp(n)));
|
|
13564
|
+
function Ip(e) {
|
|
13555
13565
|
let t = [], n = e.length, r = 0;
|
|
13556
13566
|
for (; r < n;) {
|
|
13557
13567
|
let i = e[r];
|
|
13558
|
-
if (
|
|
13568
|
+
if (Np(i)) {
|
|
13559
13569
|
r++;
|
|
13560
13570
|
continue;
|
|
13561
13571
|
}
|
|
@@ -13564,11 +13574,11 @@ function Pp(e) {
|
|
|
13564
13574
|
continue;
|
|
13565
13575
|
}
|
|
13566
13576
|
if (i === "[") {
|
|
13567
|
-
t.push({ type:
|
|
13577
|
+
t.push({ type: Mp.LBRACKET }), r++;
|
|
13568
13578
|
continue;
|
|
13569
13579
|
}
|
|
13570
13580
|
if (i === "]") {
|
|
13571
|
-
t.push({ type:
|
|
13581
|
+
t.push({ type: Mp.RBRACKET }), r++;
|
|
13572
13582
|
continue;
|
|
13573
13583
|
}
|
|
13574
13584
|
if (i === "\"") {
|
|
@@ -13577,12 +13587,12 @@ function Pp(e) {
|
|
|
13577
13587
|
for (; r < n && e[r] !== "\"";) r++;
|
|
13578
13588
|
if (r >= n) throw Error("PBRT tokenizer: unterminated string literal");
|
|
13579
13589
|
t.push({
|
|
13580
|
-
type:
|
|
13590
|
+
type: Mp.STRING,
|
|
13581
13591
|
value: e.slice(i, r)
|
|
13582
13592
|
}), r++;
|
|
13583
13593
|
continue;
|
|
13584
13594
|
}
|
|
13585
|
-
if (
|
|
13595
|
+
if (Fp(i, e[r + 1], e[r + 2])) {
|
|
13586
13596
|
let i = r;
|
|
13587
13597
|
for (r++; r < n;) {
|
|
13588
13598
|
let t = e[r];
|
|
@@ -13592,16 +13602,16 @@ function Pp(e) {
|
|
|
13592
13602
|
let a = e.slice(i, r), o = Number(a);
|
|
13593
13603
|
if (Number.isNaN(o)) throw Error(`PBRT tokenizer: invalid number "${a}"`);
|
|
13594
13604
|
t.push({
|
|
13595
|
-
type:
|
|
13605
|
+
type: Mp.NUMBER,
|
|
13596
13606
|
value: o
|
|
13597
13607
|
});
|
|
13598
13608
|
continue;
|
|
13599
13609
|
}
|
|
13600
13610
|
{
|
|
13601
13611
|
let i = r;
|
|
13602
|
-
for (; r < n && !
|
|
13612
|
+
for (; r < n && !Np(e[r]) && e[r] !== "\"" && e[r] !== "[" && e[r] !== "]" && e[r] !== "#";) r++;
|
|
13603
13613
|
t.push({
|
|
13604
|
-
type:
|
|
13614
|
+
type: Mp.WORD,
|
|
13605
13615
|
value: e.slice(i, r)
|
|
13606
13616
|
});
|
|
13607
13617
|
}
|
|
@@ -13610,7 +13620,7 @@ function Pp(e) {
|
|
|
13610
13620
|
}
|
|
13611
13621
|
//#endregion
|
|
13612
13622
|
//#region src/Processor/PBRT/PBRTMath.js
|
|
13613
|
-
function
|
|
13623
|
+
function Lp() {
|
|
13614
13624
|
return [
|
|
13615
13625
|
1,
|
|
13616
13626
|
0,
|
|
@@ -13630,7 +13640,7 @@ function Fp() {
|
|
|
13630
13640
|
1
|
|
13631
13641
|
];
|
|
13632
13642
|
}
|
|
13633
|
-
function
|
|
13643
|
+
function Rp(e, t) {
|
|
13634
13644
|
let n = e[0], r = e[1], i = e[2], a = e[3], o = e[4], s = e[5], c = e[6], l = e[7], u = e[8], d = e[9], f = e[10], p = e[11], m = e[12], h = e[13], g = e[14], _ = e[15], v = t[0], y = t[1], b = t[2], x = t[3], S = t[4], C = t[5], w = t[6], T = t[7], E = t[8], D = t[9], O = t[10], ee = t[11], k = t[12], te = t[13], ne = t[14], A = t[15];
|
|
13635
13645
|
return [
|
|
13636
13646
|
n * v + o * y + u * b + m * x,
|
|
@@ -13651,7 +13661,7 @@ function Ip(e, t) {
|
|
|
13651
13661
|
a * k + l * te + p * ne + _ * A
|
|
13652
13662
|
];
|
|
13653
13663
|
}
|
|
13654
|
-
function
|
|
13664
|
+
function zp(e, t, n) {
|
|
13655
13665
|
return [
|
|
13656
13666
|
1,
|
|
13657
13667
|
0,
|
|
@@ -13671,7 +13681,7 @@ function Lp(e, t, n) {
|
|
|
13671
13681
|
1
|
|
13672
13682
|
];
|
|
13673
13683
|
}
|
|
13674
|
-
function
|
|
13684
|
+
function Bp(e, t, n) {
|
|
13675
13685
|
return [
|
|
13676
13686
|
e,
|
|
13677
13687
|
0,
|
|
@@ -13691,7 +13701,7 @@ function Rp(e, t, n) {
|
|
|
13691
13701
|
1
|
|
13692
13702
|
];
|
|
13693
13703
|
}
|
|
13694
|
-
function
|
|
13704
|
+
function Vp(e, t, n, r) {
|
|
13695
13705
|
let i = Math.hypot(t, n, r) || 1;
|
|
13696
13706
|
t /= i, n /= i, r /= i;
|
|
13697
13707
|
let a = e * Math.PI / 180, o = Math.cos(a), s = Math.sin(a), c = 1 - o, l = c * t * t + o, u = c * t * n - s * r, d = c * t * r + s * n, f = c * t * n + s * r, p = c * n * n + o, m = c * n * r - s * t;
|
|
@@ -13714,21 +13724,21 @@ function zp(e, t, n, r) {
|
|
|
13714
13724
|
1
|
|
13715
13725
|
];
|
|
13716
13726
|
}
|
|
13717
|
-
function
|
|
13727
|
+
function Hp(e, t) {
|
|
13718
13728
|
return [
|
|
13719
13729
|
e[0] - t[0],
|
|
13720
13730
|
e[1] - t[1],
|
|
13721
13731
|
e[2] - t[2]
|
|
13722
13732
|
];
|
|
13723
13733
|
}
|
|
13724
|
-
function
|
|
13734
|
+
function Up(e, t) {
|
|
13725
13735
|
return [
|
|
13726
13736
|
e[1] * t[2] - e[2] * t[1],
|
|
13727
13737
|
e[2] * t[0] - e[0] * t[2],
|
|
13728
13738
|
e[0] * t[1] - e[1] * t[0]
|
|
13729
13739
|
];
|
|
13730
13740
|
}
|
|
13731
|
-
function
|
|
13741
|
+
function Wp(e) {
|
|
13732
13742
|
let t = Math.hypot(e[0], e[1], e[2]) || 1;
|
|
13733
13743
|
return [
|
|
13734
13744
|
e[0] / t,
|
|
@@ -13736,8 +13746,8 @@ function Hp(e) {
|
|
|
13736
13746
|
e[2] / t
|
|
13737
13747
|
];
|
|
13738
13748
|
}
|
|
13739
|
-
function
|
|
13740
|
-
let r = Hp(
|
|
13749
|
+
function Gp(e, t, n) {
|
|
13750
|
+
let r = Wp(Hp(t, e)), i = Wp(Up(Wp(n), r)), a = Up(r, i);
|
|
13741
13751
|
return [
|
|
13742
13752
|
i[0],
|
|
13743
13753
|
i[1],
|
|
@@ -13757,9 +13767,9 @@ function Up(e, t, n) {
|
|
|
13757
13767
|
1
|
|
13758
13768
|
];
|
|
13759
13769
|
}
|
|
13760
|
-
function
|
|
13770
|
+
function Kp(e) {
|
|
13761
13771
|
let t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8], u = e[9], d = e[10], f = e[11], p = e[12], m = e[13], h = e[14], g = e[15], _ = u * h * c - m * d * c + m * s * f - o * h * f - u * s * g + o * d * g, v = p * d * c - l * h * c - p * s * f + a * h * f + l * s * g - a * d * g, y = l * m * c - p * u * c + p * o * f - a * m * f - l * o * g + a * u * g, b = p * u * s - l * m * s - p * o * d + a * m * d + l * o * h - a * u * h, x = t * _ + n * v + r * y + i * b;
|
|
13762
|
-
if (x === 0) return
|
|
13772
|
+
if (x === 0) return Lp();
|
|
13763
13773
|
let S = 1 / x;
|
|
13764
13774
|
return [
|
|
13765
13775
|
_ * S,
|
|
@@ -13782,7 +13792,7 @@ function Wp(e) {
|
|
|
13782
13792
|
}
|
|
13783
13793
|
//#endregion
|
|
13784
13794
|
//#region src/Processor/PBRT/PBRTParser.js
|
|
13785
|
-
var
|
|
13795
|
+
var qp = class {
|
|
13786
13796
|
constructor(e = {}) {
|
|
13787
13797
|
this.resolveInclude = e.resolveInclude || (() => {
|
|
13788
13798
|
throw Error("PBRTParser: Include used but no resolveInclude provided");
|
|
@@ -13796,14 +13806,14 @@ var Gp = class {
|
|
|
13796
13806
|
instances: [],
|
|
13797
13807
|
objects: /* @__PURE__ */ new Map(),
|
|
13798
13808
|
warnings: []
|
|
13799
|
-
}, this.ctm =
|
|
13809
|
+
}, this.ctm = Lp(), this.state = {
|
|
13800
13810
|
material: null,
|
|
13801
13811
|
areaLight: null,
|
|
13802
13812
|
reverseOrientation: !1
|
|
13803
13813
|
}, this.attributeStack = [], this.transformStack = [], this.coordSystems = /* @__PURE__ */ new Map(), this.currentObject = null, this.objectBeginCTM = null, this.dirStack = [""], this.tokens = [], this.pos = 0, this._warnedUnknown = /* @__PURE__ */ new Set();
|
|
13804
13814
|
}
|
|
13805
13815
|
parse(e, t = "") {
|
|
13806
|
-
return this.dirStack = [t], this._run(
|
|
13816
|
+
return this.dirStack = [t], this._run(Ip(e)), this.ir;
|
|
13807
13817
|
}
|
|
13808
13818
|
_peek() {
|
|
13809
13819
|
return this.tokens[this.pos];
|
|
@@ -13813,12 +13823,12 @@ var Gp = class {
|
|
|
13813
13823
|
}
|
|
13814
13824
|
_expectNumber(e) {
|
|
13815
13825
|
let t = this._next();
|
|
13816
|
-
if (!t || t.type !==
|
|
13826
|
+
if (!t || t.type !== Mp.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
|
|
13817
13827
|
return t.value;
|
|
13818
13828
|
}
|
|
13819
13829
|
_expectString(e) {
|
|
13820
13830
|
let t = this._next();
|
|
13821
|
-
if (!t || t.type !==
|
|
13831
|
+
if (!t || t.type !== Mp.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
|
|
13822
13832
|
return t.value;
|
|
13823
13833
|
}
|
|
13824
13834
|
_readNumbers(e) {
|
|
@@ -13827,17 +13837,17 @@ var Gp = class {
|
|
|
13827
13837
|
return t;
|
|
13828
13838
|
}
|
|
13829
13839
|
_readBracketedOrBareNumbers(e) {
|
|
13830
|
-
if (this._peek() && this._peek().type ===
|
|
13840
|
+
if (this._peek() && this._peek().type === Mp.LBRACKET) {
|
|
13831
13841
|
this._next();
|
|
13832
13842
|
let e = [];
|
|
13833
|
-
for (; this._peek() && this._peek().type !==
|
|
13843
|
+
for (; this._peek() && this._peek().type !== Mp.RBRACKET;) e.push(this._expectNumber("transform element"));
|
|
13834
13844
|
return this._next(), e;
|
|
13835
13845
|
}
|
|
13836
13846
|
return this._readNumbers(e);
|
|
13837
13847
|
}
|
|
13838
13848
|
_parseParams() {
|
|
13839
13849
|
let e = {};
|
|
13840
|
-
for (; this._peek() && this._peek().type ===
|
|
13850
|
+
for (; this._peek() && this._peek().type === Mp.STRING;) {
|
|
13841
13851
|
let t = this._next().value.trim().split(/\s+/), n = t[0], r = t[1] === void 0 ? t[0] : t[1];
|
|
13842
13852
|
e[r] = {
|
|
13843
13853
|
type: n,
|
|
@@ -13848,23 +13858,23 @@ var Gp = class {
|
|
|
13848
13858
|
}
|
|
13849
13859
|
_parseParamValue() {
|
|
13850
13860
|
let e = [];
|
|
13851
|
-
if (this._peek() && this._peek().type ===
|
|
13852
|
-
for (this._next(); this._peek() && this._peek().type !==
|
|
13861
|
+
if (this._peek() && this._peek().type === Mp.LBRACKET) {
|
|
13862
|
+
for (this._next(); this._peek() && this._peek().type !== Mp.RBRACKET;) e.push(this._coerceValueToken(this._next()));
|
|
13853
13863
|
this._next();
|
|
13854
13864
|
} else e.push(this._coerceValueToken(this._next()));
|
|
13855
13865
|
return e;
|
|
13856
13866
|
}
|
|
13857
13867
|
_coerceValueToken(e) {
|
|
13858
13868
|
if (!e) throw Error("PBRT parser: unexpected EOF in parameter value");
|
|
13859
|
-
if (e.type ===
|
|
13860
|
-
if (e.type ===
|
|
13869
|
+
if (e.type === Mp.NUMBER || e.type === Mp.STRING) return e.value;
|
|
13870
|
+
if (e.type === Mp.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
|
|
13861
13871
|
throw Error(`PBRT parser: unexpected token in parameter value: ${e.type}`);
|
|
13862
13872
|
}
|
|
13863
13873
|
_run(e) {
|
|
13864
13874
|
let t = this.tokens, n = this.pos;
|
|
13865
13875
|
for (this.tokens = e, this.pos = 0; this.pos < this.tokens.length;) {
|
|
13866
13876
|
let e = this._next();
|
|
13867
|
-
if (e.type !==
|
|
13877
|
+
if (e.type !== Mp.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
|
|
13868
13878
|
this._directive(e.value);
|
|
13869
13879
|
}
|
|
13870
13880
|
this.tokens = t, this.pos = n;
|
|
@@ -13872,25 +13882,25 @@ var Gp = class {
|
|
|
13872
13882
|
_directive(e) {
|
|
13873
13883
|
switch (e) {
|
|
13874
13884
|
case "Identity":
|
|
13875
|
-
this.ctm =
|
|
13885
|
+
this.ctm = Lp();
|
|
13876
13886
|
break;
|
|
13877
13887
|
case "Translate": {
|
|
13878
13888
|
let [e, t, n] = this._readNumbers(3);
|
|
13879
|
-
this.ctm =
|
|
13889
|
+
this.ctm = Rp(this.ctm, zp(e, t, n));
|
|
13880
13890
|
break;
|
|
13881
13891
|
}
|
|
13882
13892
|
case "Scale": {
|
|
13883
13893
|
let [e, t, n] = this._readNumbers(3);
|
|
13884
|
-
this.ctm =
|
|
13894
|
+
this.ctm = Rp(this.ctm, Bp(e, t, n));
|
|
13885
13895
|
break;
|
|
13886
13896
|
}
|
|
13887
13897
|
case "Rotate": {
|
|
13888
13898
|
let [e, t, n, r] = this._readNumbers(4);
|
|
13889
|
-
this.ctm =
|
|
13899
|
+
this.ctm = Rp(this.ctm, Vp(e, t, n, r));
|
|
13890
13900
|
break;
|
|
13891
13901
|
}
|
|
13892
13902
|
case "LookAt": {
|
|
13893
|
-
let e = this._readNumbers(9), t =
|
|
13903
|
+
let e = this._readNumbers(9), t = Gp([
|
|
13894
13904
|
e[0],
|
|
13895
13905
|
e[1],
|
|
13896
13906
|
e[2]
|
|
@@ -13903,7 +13913,7 @@ var Gp = class {
|
|
|
13903
13913
|
e[7],
|
|
13904
13914
|
e[8]
|
|
13905
13915
|
]);
|
|
13906
|
-
this.ctm =
|
|
13916
|
+
this.ctm = Rp(this.ctm, Kp(t));
|
|
13907
13917
|
break;
|
|
13908
13918
|
}
|
|
13909
13919
|
case "Transform":
|
|
@@ -13911,7 +13921,7 @@ var Gp = class {
|
|
|
13911
13921
|
break;
|
|
13912
13922
|
case "ConcatTransform": {
|
|
13913
13923
|
let e = this._readBracketedOrBareNumbers(16);
|
|
13914
|
-
this.ctm =
|
|
13924
|
+
this.ctm = Rp(this.ctm, e);
|
|
13915
13925
|
break;
|
|
13916
13926
|
}
|
|
13917
13927
|
case "CoordinateSystem":
|
|
@@ -13927,7 +13937,7 @@ var Gp = class {
|
|
|
13927
13937
|
this.ir.camera = {
|
|
13928
13938
|
type: e,
|
|
13929
13939
|
params: t,
|
|
13930
|
-
cameraToWorld:
|
|
13940
|
+
cameraToWorld: Kp(this.ctm)
|
|
13931
13941
|
};
|
|
13932
13942
|
break;
|
|
13933
13943
|
}
|
|
@@ -13951,7 +13961,7 @@ var Gp = class {
|
|
|
13951
13961
|
this._skipTypeAndParams();
|
|
13952
13962
|
break;
|
|
13953
13963
|
case "WorldBegin":
|
|
13954
|
-
this.ctm =
|
|
13964
|
+
this.ctm = Lp(), this.state = {
|
|
13955
13965
|
material: null,
|
|
13956
13966
|
areaLight: null,
|
|
13957
13967
|
reverseOrientation: !1
|
|
@@ -13996,7 +14006,7 @@ var Gp = class {
|
|
|
13996
14006
|
this._readNumbers(2);
|
|
13997
14007
|
break;
|
|
13998
14008
|
case "MediumInterface":
|
|
13999
|
-
this._peek() && this._peek().type ===
|
|
14009
|
+
this._peek() && this._peek().type === Mp.STRING && this._next(), this._peek() && this._peek().type === Mp.STRING && this._next();
|
|
14000
14010
|
break;
|
|
14001
14011
|
case "MakeNamedMedium":
|
|
14002
14012
|
this._skipNamedAndParams();
|
|
@@ -14104,7 +14114,7 @@ var Gp = class {
|
|
|
14104
14114
|
}
|
|
14105
14115
|
}
|
|
14106
14116
|
_emitShape(e) {
|
|
14107
|
-
this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM =
|
|
14117
|
+
this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM = Rp(Kp(this.objectBeginCTM), e.ctm), this.ir.objects.get(this.currentObject).push(e));
|
|
14108
14118
|
}
|
|
14109
14119
|
_include(e) {
|
|
14110
14120
|
let t = this.resolveInclude(e, this.dirStack[this.dirStack.length - 1]);
|
|
@@ -14113,13 +14123,13 @@ var Gp = class {
|
|
|
14113
14123
|
return;
|
|
14114
14124
|
}
|
|
14115
14125
|
let n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
|
|
14116
|
-
this.dirStack.push(n), this._run(
|
|
14126
|
+
this.dirStack.push(n), this._run(Ip(t)), this.dirStack.pop();
|
|
14117
14127
|
}
|
|
14118
14128
|
_skipTypeAndParams() {
|
|
14119
|
-
this._peek() && this._peek().type ===
|
|
14129
|
+
this._peek() && this._peek().type === Mp.STRING && this._next(), this._parseParams();
|
|
14120
14130
|
}
|
|
14121
14131
|
_skipNamedAndParams() {
|
|
14122
|
-
this._peek() && this._peek().type ===
|
|
14132
|
+
this._peek() && this._peek().type === Mp.STRING && this._next(), this._parseParams();
|
|
14123
14133
|
}
|
|
14124
14134
|
_num(e, t) {
|
|
14125
14135
|
return e && e.value.length ? e.value[0] : t;
|
|
@@ -14133,7 +14143,7 @@ var Gp = class {
|
|
|
14133
14143
|
_warnUnknown(e) {
|
|
14134
14144
|
this._warnedUnknown.has(e) || (this._warnedUnknown.add(e), this._warn(`Unsupported directive ignored: ${e}`));
|
|
14135
14145
|
}
|
|
14136
|
-
},
|
|
14146
|
+
}, Jp = {
|
|
14137
14147
|
au: [
|
|
14138
14148
|
1,
|
|
14139
14149
|
.78,
|
|
@@ -14189,12 +14199,12 @@ var Gp = class {
|
|
|
14189
14199
|
.9,
|
|
14190
14200
|
.9
|
|
14191
14201
|
]
|
|
14192
|
-
},
|
|
14202
|
+
}, Yp = [
|
|
14193
14203
|
.92,
|
|
14194
14204
|
.92,
|
|
14195
14205
|
.92
|
|
14196
14206
|
];
|
|
14197
|
-
function
|
|
14207
|
+
function Xp(e) {
|
|
14198
14208
|
let t = Math.max(1e3, Math.min(4e4, e)) / 100, n, r, i;
|
|
14199
14209
|
t <= 66 ? (n = 255, r = 99.47 * Math.log(t) - 161.12) : (n = 329.7 * (t - 60) ** -.1332, r = 288.12 * (t - 60) ** -.0755), i = t >= 66 ? 255 : t <= 19 ? 0 : 138.52 * Math.log(t - 10) - 305.04;
|
|
14200
14210
|
let a = (e) => Math.max(0, Math.min(255, e)) / 255;
|
|
@@ -14204,15 +14214,15 @@ function Jp(e) {
|
|
|
14204
14214
|
a(i) ** 2.2
|
|
14205
14215
|
];
|
|
14206
14216
|
}
|
|
14207
|
-
function
|
|
14217
|
+
function Zp(e, t, n) {
|
|
14208
14218
|
let r = e[t];
|
|
14209
14219
|
return r && typeof r.value[0] == "number" ? r.value[0] : n;
|
|
14210
14220
|
}
|
|
14211
|
-
function
|
|
14221
|
+
function Qp(e, t, n) {
|
|
14212
14222
|
let r = e[t];
|
|
14213
14223
|
return r && typeof r.value[0] == "string" ? r.value[0] : n;
|
|
14214
14224
|
}
|
|
14215
|
-
async function
|
|
14225
|
+
async function $p(e, t, n, r = null) {
|
|
14216
14226
|
let i = e[t];
|
|
14217
14227
|
if (!i) return {
|
|
14218
14228
|
rgb: r,
|
|
@@ -14251,14 +14261,14 @@ async function Zp(e, t, n, r = null) {
|
|
|
14251
14261
|
};
|
|
14252
14262
|
}
|
|
14253
14263
|
if (i.type === "blackbody") return {
|
|
14254
|
-
rgb:
|
|
14264
|
+
rgb: Xp(i.value[0]),
|
|
14255
14265
|
texture: null
|
|
14256
14266
|
};
|
|
14257
14267
|
if (i.type === "spectrum") {
|
|
14258
14268
|
if (typeof i.value[0] == "string") {
|
|
14259
|
-
let e =
|
|
14260
|
-
return e &&
|
|
14261
|
-
rgb:
|
|
14269
|
+
let e = em(i.value[0]);
|
|
14270
|
+
return e && Jp[e] ? {
|
|
14271
|
+
rgb: Jp[e].slice(),
|
|
14262
14272
|
texture: null
|
|
14263
14273
|
} : (n.warn(`named spectrum "${i.value[0]}" approximated to gray`), {
|
|
14264
14274
|
rgb: [
|
|
@@ -14286,18 +14296,18 @@ async function Zp(e, t, n, r = null) {
|
|
|
14286
14296
|
texture: null
|
|
14287
14297
|
};
|
|
14288
14298
|
}
|
|
14289
|
-
function
|
|
14299
|
+
function em(e) {
|
|
14290
14300
|
let t = e.toLowerCase().match(/metal-([a-z]+)/);
|
|
14291
14301
|
if (t) return t[1];
|
|
14292
|
-
for (let t of Object.keys(
|
|
14302
|
+
for (let t of Object.keys(Jp)) if (e.toLowerCase().includes(t)) return t;
|
|
14293
14303
|
return null;
|
|
14294
14304
|
}
|
|
14295
|
-
function
|
|
14305
|
+
function tm(e, t) {
|
|
14296
14306
|
if (e.roughness && typeof e.roughness.value[0] == "number") return e.roughness.value[0];
|
|
14297
|
-
let n =
|
|
14307
|
+
let n = Zp(e, "uroughness", null), r = Zp(e, "vroughness", null);
|
|
14298
14308
|
return n !== null && r !== null ? (n + r) / 2 : n === null ? t : n;
|
|
14299
14309
|
}
|
|
14300
|
-
async function
|
|
14310
|
+
async function nm(e, t) {
|
|
14301
14311
|
let n = e?.type || "diffuse", r = e?.params || {}, i = new Dt({
|
|
14302
14312
|
side: lt,
|
|
14303
14313
|
roughness: 1,
|
|
@@ -14309,7 +14319,7 @@ async function em(e, t) {
|
|
|
14309
14319
|
};
|
|
14310
14320
|
switch (n) {
|
|
14311
14321
|
case "diffuse":
|
|
14312
|
-
o(await
|
|
14322
|
+
o(await $p(r, "reflectance", t, [
|
|
14313
14323
|
.5,
|
|
14314
14324
|
.5,
|
|
14315
14325
|
.5
|
|
@@ -14317,14 +14327,14 @@ async function em(e, t) {
|
|
|
14317
14327
|
break;
|
|
14318
14328
|
case "conductor":
|
|
14319
14329
|
case "metal": {
|
|
14320
|
-
let e = await
|
|
14330
|
+
let e = await $p(r, "reflectance", t, null), n = r.eta, s = r.k, c = n && n.type === "spectrum" && typeof n.value[0] == "string";
|
|
14321
14331
|
if (e.rgb || e.texture) o(e);
|
|
14322
14332
|
else if (n && s && !c) {
|
|
14323
|
-
let e = (await
|
|
14333
|
+
let e = (await $p(r, "eta", t, [
|
|
14324
14334
|
.2,
|
|
14325
14335
|
.92,
|
|
14326
14336
|
1.1
|
|
14327
|
-
])).rgb, n = (await
|
|
14337
|
+
])).rgb, n = (await $p(r, "k", t, [
|
|
14328
14338
|
3.9,
|
|
14329
14339
|
2.45,
|
|
14330
14340
|
2.14
|
|
@@ -14334,28 +14344,28 @@ async function em(e, t) {
|
|
|
14334
14344
|
i(e[1], n[1]),
|
|
14335
14345
|
i(e[2], n[2])
|
|
14336
14346
|
]);
|
|
14337
|
-
} else a(n ? (await
|
|
14338
|
-
i.metalness = 1, i.roughness =
|
|
14347
|
+
} else a(n ? (await $p(r, "eta", t, Yp)).rgb || Yp : Jp.cu);
|
|
14348
|
+
i.metalness = 1, i.roughness = tm(r, .1);
|
|
14339
14349
|
break;
|
|
14340
14350
|
}
|
|
14341
14351
|
case "dielectric":
|
|
14342
14352
|
case "thindielectric":
|
|
14343
|
-
i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior =
|
|
14353
|
+
i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = Zp(r, "eta", 1.5), i.roughness = tm(r, 0), i.thickness = n === "thindielectric" ? 0 : Zp(r, "thickness", 0);
|
|
14344
14354
|
break;
|
|
14345
14355
|
case "coateddiffuse":
|
|
14346
|
-
o(await
|
|
14356
|
+
o(await $p(r, "reflectance", t, [
|
|
14347
14357
|
.5,
|
|
14348
14358
|
.5,
|
|
14349
14359
|
.5
|
|
14350
|
-
])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness =
|
|
14360
|
+
])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness = tm(r, 0);
|
|
14351
14361
|
break;
|
|
14352
14362
|
case "diffusetransmission": {
|
|
14353
|
-
let e = await
|
|
14363
|
+
let e = await $p(r, "transmittance", t, [
|
|
14354
14364
|
.25,
|
|
14355
14365
|
.25,
|
|
14356
14366
|
.25
|
|
14357
14367
|
]);
|
|
14358
|
-
o(await
|
|
14368
|
+
o(await $p(r, "reflectance", t, [
|
|
14359
14369
|
.25,
|
|
14360
14370
|
.25,
|
|
14361
14371
|
.25
|
|
@@ -14368,9 +14378,9 @@ async function em(e, t) {
|
|
|
14368
14378
|
i.transmission = 1, i.ior = 1, i.roughness = 0, i.color.setRGB(1, 1, 1);
|
|
14369
14379
|
break;
|
|
14370
14380
|
case "mix": {
|
|
14371
|
-
let e = r.materials?.value || [], n = Math.max(0, Math.min(1,
|
|
14381
|
+
let e = r.materials?.value || [], n = Math.max(0, Math.min(1, Zp(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
|
|
14372
14382
|
if (a && o) {
|
|
14373
|
-
let [e, r] = await Promise.all([
|
|
14383
|
+
let [e, r] = await Promise.all([nm(a, t), nm(o, t)]), s = (e, t) => e * (1 - n) + t * n;
|
|
14374
14384
|
i.color.lerpColors(e.color, r.color, n), i.roughness = s(e.roughness, r.roughness), i.metalness = s(e.metalness, r.metalness), i.ior = s(e.ior ?? 1.5, r.ior ?? 1.5), i.transmission = s(e.transmission ?? 0, r.transmission ?? 0), i.thickness = s(e.thickness ?? 0, r.thickness ?? 0), i.clearcoat = s(e.clearcoat ?? 0, r.clearcoat ?? 0), i.clearcoatRoughness = s(e.clearcoatRoughness ?? 0, r.clearcoatRoughness ?? 0), i.emissive.lerpColors(e.emissive, r.emissive, n), i.emissiveIntensity = s(e.emissiveIntensity ?? 0, r.emissiveIntensity ?? 0), i.map = (n < .5 ? e.map : r.map) || null;
|
|
14375
14385
|
break;
|
|
14376
14386
|
}
|
|
@@ -14380,7 +14390,7 @@ async function em(e, t) {
|
|
|
14380
14390
|
case "subsurface":
|
|
14381
14391
|
case "hair":
|
|
14382
14392
|
case "measured":
|
|
14383
|
-
t.warn(`material "${n}" not supported — using diffuse approximation`), a((await
|
|
14393
|
+
t.warn(`material "${n}" not supported — using diffuse approximation`), a((await $p(r, "reflectance", t, [
|
|
14384
14394
|
.5,
|
|
14385
14395
|
.5,
|
|
14386
14396
|
.5
|
|
@@ -14394,7 +14404,7 @@ async function em(e, t) {
|
|
|
14394
14404
|
}
|
|
14395
14405
|
//#endregion
|
|
14396
14406
|
//#region src/Processor/PBRT/PBRTSceneBuilder.js
|
|
14397
|
-
var
|
|
14407
|
+
var rm = [
|
|
14398
14408
|
1,
|
|
14399
14409
|
0,
|
|
14400
14410
|
0,
|
|
@@ -14411,7 +14421,7 @@ var tm = [
|
|
|
14411
14421
|
0,
|
|
14412
14422
|
0,
|
|
14413
14423
|
1
|
|
14414
|
-
],
|
|
14424
|
+
], im = class {
|
|
14415
14425
|
constructor(e = {}) {
|
|
14416
14426
|
this.resolvePLY = e.resolvePLY || (async () => null), this.resolveImage = e.resolveImage || (async () => null), this.resolveEnvironment = e.resolveEnvironment || e.resolveImage || (async () => null), this.convertHandedness = e.convertHandedness === !0, this.warnings = [], this.report = [], this._materialCache = /* @__PURE__ */ new Map(), this._textureCache = /* @__PURE__ */ new Map();
|
|
14417
14427
|
}
|
|
@@ -14447,7 +14457,7 @@ var tm = [
|
|
|
14447
14457
|
continue;
|
|
14448
14458
|
}
|
|
14449
14459
|
for (let e of i) {
|
|
14450
|
-
let i =
|
|
14460
|
+
let i = Rp(r.ctm, e.relativeCTM || e.ctm), a = await this._buildShapeMesh(e, i, `instance_${n++}`);
|
|
14451
14461
|
a && t.add(a);
|
|
14452
14462
|
}
|
|
14453
14463
|
}
|
|
@@ -14459,7 +14469,7 @@ var tm = [
|
|
|
14459
14469
|
i.map && !a && (this.warn(`${n} (${e.type}, "${e.material?.type || "diffuse"}") has a texture map but no UVs — dropping map, using base color`), o = i.clone(), o.map = null);
|
|
14460
14470
|
let s = new Tt(r, o);
|
|
14461
14471
|
s.name = n;
|
|
14462
|
-
let c = this.convertHandedness ?
|
|
14472
|
+
let c = this.convertHandedness ? Rp(rm, t) : t;
|
|
14463
14473
|
new wt().fromArray(c).decompose(s.position, s.quaternion, s.scale), s.updateMatrix(), r.computeBoundingBox();
|
|
14464
14474
|
let l = r.boundingBox ? r.boundingBox.clone().applyMatrix4(s.matrix).getSize(new cn()) : new cn();
|
|
14465
14475
|
return this.report.push({
|
|
@@ -14514,7 +14524,7 @@ var tm = [
|
|
|
14514
14524
|
return i.setAttribute("position", new ft(Float32Array.from(t), 3)), i.setIndex(r), i.computeVertexNormals(), i;
|
|
14515
14525
|
}
|
|
14516
14526
|
async _plyMesh(e) {
|
|
14517
|
-
let t =
|
|
14527
|
+
let t = Qp(e, "filename", null);
|
|
14518
14528
|
if (!t) return this.warn("plymesh missing filename"), null;
|
|
14519
14529
|
try {
|
|
14520
14530
|
let e = await this.resolvePLY(t);
|
|
@@ -14524,10 +14534,10 @@ var tm = [
|
|
|
14524
14534
|
}
|
|
14525
14535
|
}
|
|
14526
14536
|
_sphere(e) {
|
|
14527
|
-
return new Zt(
|
|
14537
|
+
return new Zt(Zp(e, "radius", 1), 48, 32);
|
|
14528
14538
|
}
|
|
14529
14539
|
_disk(e) {
|
|
14530
|
-
let t =
|
|
14540
|
+
let t = Zp(e, "radius", 1), n = Zp(e, "innerradius", 0), r = Zp(e, "height", 0), i = [], a = [];
|
|
14531
14541
|
for (let e = 0; e < 48; e++) {
|
|
14532
14542
|
let o = e / 48 * Math.PI * 2, s = (e + 1) / 48 * Math.PI * 2, c = i.length / 3;
|
|
14533
14543
|
i.push(Math.cos(o) * n, Math.sin(o) * n, r), i.push(Math.cos(o) * t, Math.sin(o) * t, r), i.push(Math.cos(s) * t, Math.sin(s) * t, r), i.push(Math.cos(s) * n, Math.sin(s) * n, r), a.push(c, c + 1, c + 2, c, c + 2, c + 3);
|
|
@@ -14542,15 +14552,15 @@ var tm = [
|
|
|
14542
14552
|
resolveNamedTexture: (e) => this._resolveNamedTexture(e),
|
|
14543
14553
|
namedMaterials: this.ir.namedMaterials,
|
|
14544
14554
|
warn: (e) => this.warn(e)
|
|
14545
|
-
}, r = await
|
|
14555
|
+
}, r = await nm(e.material, n);
|
|
14546
14556
|
return e.areaLight && await this._applyAreaLight(r, e.areaLight, n), t.set(e.areaLight, r), r;
|
|
14547
14557
|
}
|
|
14548
14558
|
async _applyAreaLight(e, t, n) {
|
|
14549
|
-
let r = await
|
|
14559
|
+
let r = await $p(t.params, "L", n, [
|
|
14550
14560
|
1,
|
|
14551
14561
|
1,
|
|
14552
14562
|
1
|
|
14553
|
-
]), i =
|
|
14563
|
+
]), i = Zp(t.params, "scale", 1), a = r.rgb || [
|
|
14554
14564
|
1,
|
|
14555
14565
|
1,
|
|
14556
14566
|
1
|
|
@@ -14562,7 +14572,7 @@ var tm = [
|
|
|
14562
14572
|
let t = this.ir.namedTextures.get(e), n = null;
|
|
14563
14573
|
if (!t) this.warn(`named texture "${e}" not defined`);
|
|
14564
14574
|
else if (t.class === "imagemap") {
|
|
14565
|
-
let r =
|
|
14575
|
+
let r = Qp(t.params, "filename", null);
|
|
14566
14576
|
if (r) try {
|
|
14567
14577
|
let t = await this.resolveImage(r);
|
|
14568
14578
|
t ? n = { texture: t } : this.warn(`image not found for texture "${e}": ${r}`);
|
|
@@ -14650,7 +14660,7 @@ var tm = [
|
|
|
14650
14660
|
return c.name = "PBRT Camera", c.up.copy(a.normalize()), c.position.copy(r), c.lookAt(o), c.updateMatrixWorld(!0), c;
|
|
14651
14661
|
}
|
|
14652
14662
|
_verticalFov(e, t) {
|
|
14653
|
-
let n =
|
|
14663
|
+
let n = Zp(e, "fov", 90);
|
|
14654
14664
|
if (t >= 1) return n;
|
|
14655
14665
|
let r = n * Math.PI / 180;
|
|
14656
14666
|
return 2 * Math.atan(Math.tan(r / 2) / t) * 180 / Math.PI;
|
|
@@ -14658,7 +14668,7 @@ var tm = [
|
|
|
14658
14668
|
async _buildEnvironment(e) {
|
|
14659
14669
|
let t = e.find((e) => e.type === "infinite");
|
|
14660
14670
|
if (!t) return null;
|
|
14661
|
-
let n =
|
|
14671
|
+
let n = Zp(t.params, "scale", 1), r = Qp(t.params, "filename", null);
|
|
14662
14672
|
if (r) try {
|
|
14663
14673
|
let e = await this.resolveEnvironment(r);
|
|
14664
14674
|
if (e) return e.mapping = ut, { texture: e };
|
|
@@ -14666,7 +14676,7 @@ var tm = [
|
|
|
14666
14676
|
} catch (e) {
|
|
14667
14677
|
this.warn(`failed to load infinite-light image ${r}: ${e.message}`);
|
|
14668
14678
|
}
|
|
14669
|
-
let i = ((await
|
|
14679
|
+
let i = ((await $p(t.params, "L", {
|
|
14670
14680
|
resolveNamedTexture: async () => null,
|
|
14671
14681
|
warn: (e) => this.warn(e)
|
|
14672
14682
|
}, [
|
|
@@ -14685,20 +14695,20 @@ var tm = [
|
|
|
14685
14695
|
_reportUnsupportedLights(e) {
|
|
14686
14696
|
for (let t of e) t.type !== "infinite" && this.warn(`light "${t.type}" not supported (only infinite lights and emissive area lights are mapped)`);
|
|
14687
14697
|
}
|
|
14688
|
-
},
|
|
14689
|
-
function
|
|
14698
|
+
}, am = new TextDecoder();
|
|
14699
|
+
function om(e) {
|
|
14690
14700
|
let t = e.replace(/\\/g, "/").split("/"), n = [];
|
|
14691
14701
|
for (let e of t) e === "" || e === "." || (e === ".." ? n.pop() : n.push(e));
|
|
14692
14702
|
return n.join("/");
|
|
14693
14703
|
}
|
|
14694
|
-
function
|
|
14695
|
-
return !e || t.startsWith("/") ?
|
|
14704
|
+
function sm(e, t) {
|
|
14705
|
+
return !e || t.startsWith("/") ? om(t) : om(`${e}/${t}`);
|
|
14696
14706
|
}
|
|
14697
|
-
var
|
|
14707
|
+
var cm = class {
|
|
14698
14708
|
constructor(e) {
|
|
14699
14709
|
this.byPath = /* @__PURE__ */ new Map(), this.byBase = /* @__PURE__ */ new Map();
|
|
14700
14710
|
for (let t in e) {
|
|
14701
|
-
let n =
|
|
14711
|
+
let n = om(t).toLowerCase(), r = {
|
|
14702
14712
|
norm: n,
|
|
14703
14713
|
bytes: e[t]
|
|
14704
14714
|
};
|
|
@@ -14708,13 +14718,13 @@ var om = class {
|
|
|
14708
14718
|
}
|
|
14709
14719
|
}
|
|
14710
14720
|
find(e) {
|
|
14711
|
-
let t =
|
|
14721
|
+
let t = om(e).toLowerCase();
|
|
14712
14722
|
if (this.byPath.has(t)) return this.byPath.get(t).bytes;
|
|
14713
14723
|
let n = this.byBase.get(t.split("/").pop());
|
|
14714
14724
|
return n ? (n.find((e) => e.norm.endsWith("/" + t)) || n[0]).bytes : null;
|
|
14715
14725
|
}
|
|
14716
14726
|
};
|
|
14717
|
-
function
|
|
14727
|
+
function lm(e) {
|
|
14718
14728
|
let t = Object.keys(e).filter((e) => e.toLowerCase().endsWith(".pbrt"));
|
|
14719
14729
|
if (t.length === 0) return null;
|
|
14720
14730
|
let n = t.filter((e) => /(^|\/)(scene|main)\.pbrt$/i.test(e)), r = n.length ? n : t;
|
|
@@ -14723,17 +14733,17 @@ function sm(e) {
|
|
|
14723
14733
|
return n === r ? e.length - t.length : n - r;
|
|
14724
14734
|
}), r[0];
|
|
14725
14735
|
}
|
|
14726
|
-
async function
|
|
14727
|
-
let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new
|
|
14736
|
+
async function um(e) {
|
|
14737
|
+
let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new cm(t), s = e.entryPath || lm(t);
|
|
14728
14738
|
if (!s) throw Error("PBRT loader: no .pbrt file found in archive");
|
|
14729
14739
|
let c = o.find(s);
|
|
14730
14740
|
if (!c) throw Error(`PBRT loader: entry "${s}" not readable`);
|
|
14731
|
-
let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new
|
|
14732
|
-
let n = o.find(
|
|
14733
|
-
return n ?
|
|
14734
|
-
} }).parse(
|
|
14741
|
+
let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new qp({ resolveInclude: (e, t) => {
|
|
14742
|
+
let n = o.find(sm(t, e)) || o.find(e);
|
|
14743
|
+
return n ? am.decode(n) : null;
|
|
14744
|
+
} }).parse(am.decode(c), l), d = (e) => e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
|
|
14735
14745
|
return {
|
|
14736
|
-
...await new
|
|
14746
|
+
...await new im({
|
|
14737
14747
|
convertHandedness: a,
|
|
14738
14748
|
resolvePLY: async (e) => {
|
|
14739
14749
|
let t = o.find(e);
|
|
@@ -14753,12 +14763,12 @@ async function cm(e) {
|
|
|
14753
14763
|
}
|
|
14754
14764
|
//#endregion
|
|
14755
14765
|
//#region src/Processor/SceneMetadata.js
|
|
14756
|
-
var
|
|
14766
|
+
var dm = [
|
|
14757
14767
|
"sourceFile",
|
|
14758
14768
|
"url",
|
|
14759
14769
|
"file"
|
|
14760
14770
|
];
|
|
14761
|
-
function
|
|
14771
|
+
function fm(e) {
|
|
14762
14772
|
if (typeof e == "string") try {
|
|
14763
14773
|
let t = JSON.parse(e);
|
|
14764
14774
|
return t && typeof t == "object" ? t : null;
|
|
@@ -14767,31 +14777,31 @@ function um(e) {
|
|
|
14767
14777
|
}
|
|
14768
14778
|
return e && typeof e == "object" ? e : null;
|
|
14769
14779
|
}
|
|
14770
|
-
function
|
|
14780
|
+
function pm(e) {
|
|
14771
14781
|
let t = typeof e == "string" ? parseFloat(e) : e;
|
|
14772
14782
|
return Number.isFinite(t) ? t : void 0;
|
|
14773
14783
|
}
|
|
14774
|
-
function
|
|
14775
|
-
let t =
|
|
14784
|
+
function mm(e) {
|
|
14785
|
+
let t = fm(e);
|
|
14776
14786
|
if (!t) return null;
|
|
14777
|
-
let n =
|
|
14787
|
+
let n = fm(t.rayzee);
|
|
14778
14788
|
return n && n.environment !== void 0 ? n : t.environment === void 0 ? null : t;
|
|
14779
14789
|
}
|
|
14780
|
-
function
|
|
14781
|
-
let t =
|
|
14790
|
+
function hm(e) {
|
|
14791
|
+
let t = fm(e);
|
|
14782
14792
|
if (!t) return null;
|
|
14783
|
-
let n =
|
|
14793
|
+
let n = dm.map((e) => t[e]).find((e) => typeof e == "string" && e.trim());
|
|
14784
14794
|
if (!n) return null;
|
|
14785
|
-
let r =
|
|
14795
|
+
let r = pm(t.rotation), i = pm(t.intensity), a = { sourceFile: n.trim() };
|
|
14786
14796
|
return r !== void 0 && (a.rotation = r), i !== void 0 && (a.intensity = Math.max(0, i)), a;
|
|
14787
14797
|
}
|
|
14788
|
-
function
|
|
14789
|
-
let t =
|
|
14798
|
+
function gm(e) {
|
|
14799
|
+
let t = mm(e);
|
|
14790
14800
|
if (!t) return null;
|
|
14791
|
-
let n =
|
|
14801
|
+
let n = hm(t.environment);
|
|
14792
14802
|
return n ? { environment: n } : null;
|
|
14793
14803
|
}
|
|
14794
|
-
function
|
|
14804
|
+
function _m(e) {
|
|
14795
14805
|
if (!e) return null;
|
|
14796
14806
|
let t = [
|
|
14797
14807
|
e.userData,
|
|
@@ -14800,14 +14810,14 @@ function hm(e) {
|
|
|
14800
14810
|
];
|
|
14801
14811
|
Array.isArray(e.scenes) && t.push(...e.scenes.map((e) => e?.userData));
|
|
14802
14812
|
for (let e of t) {
|
|
14803
|
-
let t =
|
|
14813
|
+
let t = gm(e);
|
|
14804
14814
|
if (t) return t;
|
|
14805
14815
|
}
|
|
14806
14816
|
return null;
|
|
14807
14817
|
}
|
|
14808
14818
|
//#endregion
|
|
14809
14819
|
//#region src/Processor/AssetLoader.js
|
|
14810
|
-
var
|
|
14820
|
+
var vm = {
|
|
14811
14821
|
glb: {
|
|
14812
14822
|
type: "model",
|
|
14813
14823
|
name: "GLB (GLTF Binary)"
|
|
@@ -14884,15 +14894,20 @@ var gm = {
|
|
|
14884
14894
|
type: "archive",
|
|
14885
14895
|
name: "ZIP Archive"
|
|
14886
14896
|
}
|
|
14887
|
-
},
|
|
14888
|
-
function
|
|
14897
|
+
}, ym = /\.(usd|usda|usdc)$/i, bm = /\.(png|jpg|jpeg|avif)$/i;
|
|
14898
|
+
function xm(e) {
|
|
14889
14899
|
let t = new Ze();
|
|
14890
14900
|
for (let n in e.attributes) t.setAttribute(n, e.attributes[n]);
|
|
14891
14901
|
e.index && t.setIndex(e.index);
|
|
14892
14902
|
for (let n of e.groups) t.addGroup(n.start, n.count, n.materialIndex);
|
|
14893
14903
|
return t;
|
|
14894
14904
|
}
|
|
14895
|
-
|
|
14905
|
+
function Sm(e, t, n, r) {
|
|
14906
|
+
if (!(r.normalize ?? !0)) return Math.PI;
|
|
14907
|
+
let i = r.shape === "ellipse" || r.shape === "disk" ? Math.PI / 4 : 1, a = e.getWorldScale(new cn()), o = Math.PI * i * Math.abs(t * a.x * n * a.y);
|
|
14908
|
+
return Number.isFinite(o) ? o : Math.PI;
|
|
14909
|
+
}
|
|
14910
|
+
var Cm = class e extends dt {
|
|
14896
14911
|
constructor(e, t, n, { issues: r = null, profile: i = null } = {}) {
|
|
14897
14912
|
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new yt(), this._loadCancelled = !1, this._issues = r, this._profile = i ?? jr(), this._loadingManager.onError = (e) => {
|
|
14898
14913
|
this._loadCancelled || this._issues?.record(Wc.ASSET_UNREACHABLE, `asset "${e}" could not be fetched — anything depending on it renders without it`, { url: e });
|
|
@@ -14949,7 +14964,7 @@ var bm = class e extends dt {
|
|
|
14949
14964
|
this.renderer = e;
|
|
14950
14965
|
}
|
|
14951
14966
|
getFileFormat(e) {
|
|
14952
|
-
return
|
|
14967
|
+
return vm[e.split(".").pop().toLowerCase()] || null;
|
|
14953
14968
|
}
|
|
14954
14969
|
readFileAsArrayBuffer(e) {
|
|
14955
14970
|
return new Promise((t, n) => {
|
|
@@ -15089,7 +15104,7 @@ var bm = class e extends dt {
|
|
|
15089
15104
|
async loadArchiveFromFile(e, t) {
|
|
15090
15105
|
try {
|
|
15091
15106
|
let n = await this.readFileAsArrayBuffer(e), r = bn(new Uint8Array(n));
|
|
15092
|
-
return
|
|
15107
|
+
return lm(r) ? await this.loadPBRTFromZip(r, t) : await this.processObjMtlPairsInZip(r, t) || await this.findAndLoadModelFromZip(r, t);
|
|
15093
15108
|
} catch (e) {
|
|
15094
15109
|
throw console.error("Error loading ZIP archive:", e), e;
|
|
15095
15110
|
}
|
|
@@ -15103,7 +15118,7 @@ var bm = class e extends dt {
|
|
|
15103
15118
|
let { PLYLoader: e } = await import("three/examples/jsm/loaders/PLYLoader.js");
|
|
15104
15119
|
this.loaderCache.ply = new e();
|
|
15105
15120
|
}
|
|
15106
|
-
let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await
|
|
15121
|
+
let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await um({
|
|
15107
15122
|
vfs: e,
|
|
15108
15123
|
plyParser: (e) => this.loaderCache.ply.parse(e),
|
|
15109
15124
|
imageFromBytes: (e, t) => this._pbrtTextureFromBytes(e, t),
|
|
@@ -15202,24 +15217,24 @@ var bm = class e extends dt {
|
|
|
15202
15217
|
}
|
|
15203
15218
|
for (let t in e) {
|
|
15204
15219
|
let n = t.split(".").pop().toLowerCase();
|
|
15205
|
-
if (
|
|
15220
|
+
if (vm[n] && vm[n].type === "model") return ym.test(t) ? await this.loadUSDHierarchyFromZip(e) : (console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e));
|
|
15206
15221
|
}
|
|
15207
15222
|
throw Error("No supported model files found in the ZIP archive");
|
|
15208
15223
|
}
|
|
15209
15224
|
async loadUSDHierarchyFromZip(t) {
|
|
15210
|
-
let n = Object.keys(t).filter((e) =>
|
|
15225
|
+
let n = Object.keys(t).filter((e) => ym.test(e));
|
|
15211
15226
|
if (n.length === 0) throw Error("No USD layers found in the ZIP archive");
|
|
15212
15227
|
let r = e._pickUSDRootLayer(n);
|
|
15213
15228
|
console.log(`Loading USD scene from ZIP: ${r} (${n.length} layers)`);
|
|
15214
15229
|
let i = { [r]: [t[r], { level: 0 }] };
|
|
15215
|
-
for (let e of Object.keys(t)) e !== r && (
|
|
15230
|
+
for (let e of Object.keys(t)) e !== r && (ym.test(e) || bm.test(e)) && (i[e] = [t[e], { level: 0 }]);
|
|
15216
15231
|
return await this.loadUSDFromArrayBuffer(xn(i), r);
|
|
15217
15232
|
}
|
|
15218
15233
|
static _pickUSDRootLayer(e) {
|
|
15219
15234
|
let t = (e) => e.split("/").length, n = Math.min(...e.map(t)), r = e.filter((e) => t(e) === n);
|
|
15220
15235
|
return r.find((e) => {
|
|
15221
15236
|
let t = e.split("/");
|
|
15222
|
-
return t.length > 1 && t[t.length - 1].replace(
|
|
15237
|
+
return t.length > 1 && t[t.length - 1].replace(ym, "") === t[t.length - 2];
|
|
15223
15238
|
}) || r[0];
|
|
15224
15239
|
}
|
|
15225
15240
|
async loadModelFromZipEntry(e, t, n, r) {
|
|
@@ -15286,7 +15301,7 @@ var bm = class e extends dt {
|
|
|
15286
15301
|
try {
|
|
15287
15302
|
return await new Promise((t, n) => {
|
|
15288
15303
|
o.parse(e, "", (e) => {
|
|
15289
|
-
this.releaseTargetModel(), this.targetModel = e.scene, this.sceneMetadata =
|
|
15304
|
+
this.releaseTargetModel(), this.targetModel = e.scene, this.sceneMetadata = _m(e), this.onModelLoad(this.targetModel).then(() => t(e));
|
|
15290
15305
|
}, (e) => n(e));
|
|
15291
15306
|
});
|
|
15292
15307
|
} finally {
|
|
@@ -15414,7 +15429,7 @@ var bm = class e extends dt {
|
|
|
15414
15429
|
totalBytes: 0
|
|
15415
15430
|
});
|
|
15416
15431
|
let e = await n.loadAsync(t, this._downloadProgress("Downloading Model...", r));
|
|
15417
|
-
return this._downloadComplete(), this.releaseTargetModel(), this.targetModel = e.scene, this.animations = e.animations || [], this.sceneMetadata =
|
|
15432
|
+
return this._downloadComplete(), this.releaseTargetModel(), this.targetModel = e.scene, this.animations = e.animations || [], this.sceneMetadata = _m(e), await this.onModelLoad(this.targetModel), this.dispatchEvent({
|
|
15418
15433
|
type: "load",
|
|
15419
15434
|
model: e.scene,
|
|
15420
15435
|
filename: t.split("/").pop()
|
|
@@ -15471,7 +15486,7 @@ var bm = class e extends dt {
|
|
|
15471
15486
|
progress: 5
|
|
15472
15487
|
}), await new Promise((e) => setTimeout(e, 0));
|
|
15473
15488
|
let r = await n.parseAsync(e, "");
|
|
15474
|
-
return this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata =
|
|
15489
|
+
return this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = _m(r), vr({
|
|
15475
15490
|
isLoading: !0,
|
|
15476
15491
|
status: "Processing Data...",
|
|
15477
15492
|
progress: 10
|
|
@@ -15747,19 +15762,19 @@ var bm = class e extends dt {
|
|
|
15747
15762
|
}), t;
|
|
15748
15763
|
}
|
|
15749
15764
|
processModelObjects(e) {
|
|
15750
|
-
let t = []
|
|
15765
|
+
let t = [];
|
|
15751
15766
|
e.traverse((e) => {
|
|
15752
|
-
let
|
|
15753
|
-
if (e.isRectAreaLight && !
|
|
15754
|
-
let
|
|
15755
|
-
|
|
15767
|
+
let n = e.userData;
|
|
15768
|
+
if (e.isRectAreaLight && !n.__radianceConverted && (e.intensity *= Sm(e, e.width, e.height, n), n.__radianceConverted = !0), (e.isPointLight || e.isSpotLight) && !n.__candelaConverted && (e.intensity *= 4 * Math.PI, n.__candelaConverted = !0), e.name.startsWith("RectAreaLightPlaceholder") && n.name && n.type === "RectAreaLight") {
|
|
15769
|
+
let t = n.normalize ?? !0, r = n.shape ?? "rectangle", i = n.intensity * Sm(e, n.width, n.height, n), a = new Wt(new nt(...n.color), i * this._profile.areaLightIntensityScale, n.width, n.height);
|
|
15770
|
+
a.userData.normalize = t, a.userData.spread = Number.isFinite(n.spread) ? n.spread : Math.PI, a.userData.shape = r, a.userData.__radianceConverted = !0, a.name = n.name, e.add(a);
|
|
15756
15771
|
}
|
|
15757
|
-
e.isMesh && Array.isArray(e.material) &&
|
|
15772
|
+
e.isMesh && Array.isArray(e.material) && t.push(e);
|
|
15758
15773
|
});
|
|
15759
|
-
let
|
|
15760
|
-
for (let e of
|
|
15774
|
+
let n = e.userData.__rayzeeExternal === !0;
|
|
15775
|
+
for (let e of t) {
|
|
15761
15776
|
if (!e.parent) continue;
|
|
15762
|
-
console.log("Found multi-material mesh:", e.name),
|
|
15777
|
+
console.log("Found multi-material mesh:", e.name), n && (e.geometry = xm(e.geometry));
|
|
15763
15778
|
let t = gn(e);
|
|
15764
15779
|
for (let e of t.children) e.geometry.userData.__rayzeeOwned = !0;
|
|
15765
15780
|
e.parent.add(t), e.parent.remove(e);
|
|
@@ -15790,10 +15805,10 @@ var bm = class e extends dt {
|
|
|
15790
15805
|
getSupportedFormats(e = null) {
|
|
15791
15806
|
if (e) {
|
|
15792
15807
|
let t = {};
|
|
15793
|
-
for (let [n, r] of Object.entries(
|
|
15808
|
+
for (let [n, r] of Object.entries(vm)) r.type === e && (t[n] = r);
|
|
15794
15809
|
return t;
|
|
15795
15810
|
}
|
|
15796
|
-
return
|
|
15811
|
+
return vm;
|
|
15797
15812
|
}
|
|
15798
15813
|
dispose() {
|
|
15799
15814
|
for (let e in this.loaderCache) {
|
|
@@ -15805,7 +15820,7 @@ var bm = class e extends dt {
|
|
|
15805
15820
|
removeAllEventListeners() {
|
|
15806
15821
|
this._listeners = void 0;
|
|
15807
15822
|
}
|
|
15808
|
-
},
|
|
15823
|
+
}, wm = class extends dt {
|
|
15809
15824
|
constructor(e) {
|
|
15810
15825
|
super();
|
|
15811
15826
|
let t = e.clientWidth, n = e.clientHeight;
|
|
@@ -15971,7 +15986,7 @@ var bm = class e extends dt {
|
|
|
15971
15986
|
dispose() {
|
|
15972
15987
|
this.controls?.dispose();
|
|
15973
15988
|
}
|
|
15974
|
-
},
|
|
15989
|
+
}, Tm = class extends dt {
|
|
15975
15990
|
constructor(e, t, n, r = {}) {
|
|
15976
15991
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null;
|
|
15977
15992
|
}
|
|
@@ -16131,14 +16146,14 @@ var bm = class e extends dt {
|
|
|
16131
16146
|
], 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);
|
|
16132
16147
|
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;
|
|
16133
16148
|
}
|
|
16134
|
-
},
|
|
16149
|
+
}, Em = class {
|
|
16135
16150
|
constructor(e, t = {}) {
|
|
16136
16151
|
this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._size = 256;
|
|
16137
16152
|
}
|
|
16138
16153
|
async loadLibrary(e, { size: t = 256 } = {}) {
|
|
16139
16154
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
16140
16155
|
this._size = t;
|
|
16141
|
-
let n = await Promise.all(e.map((e) =>
|
|
16156
|
+
let n = await Promise.all(e.map((e) => Dm(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
|
|
16142
16157
|
s.width = r, s.height = i;
|
|
16143
16158
|
let c = s.getContext("2d", { willReadFrequently: !0 });
|
|
16144
16159
|
for (let e = 0; e < a; e++) {
|
|
@@ -16167,7 +16182,7 @@ var bm = class e extends dt {
|
|
|
16167
16182
|
o.userData.gobo = {
|
|
16168
16183
|
name: e.name,
|
|
16169
16184
|
index: e.index,
|
|
16170
|
-
intensity:
|
|
16185
|
+
intensity: Om(r),
|
|
16171
16186
|
inverted: !!i,
|
|
16172
16187
|
scale: Math.max(1e-4, a)
|
|
16173
16188
|
};
|
|
@@ -16209,28 +16224,28 @@ var bm = class e extends dt {
|
|
|
16209
16224
|
return t && t.isSpotLight ? t : null;
|
|
16210
16225
|
}
|
|
16211
16226
|
};
|
|
16212
|
-
function
|
|
16227
|
+
function Dm(e) {
|
|
16213
16228
|
return new Promise((t, n) => {
|
|
16214
16229
|
let r = new Image();
|
|
16215
16230
|
r.crossOrigin = "anonymous", r.onload = () => t(r), r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load gobo image: ${e}`)), r.src = e;
|
|
16216
16231
|
});
|
|
16217
16232
|
}
|
|
16218
|
-
function
|
|
16233
|
+
function Om(e) {
|
|
16219
16234
|
return Math.max(0, Math.min(1, e));
|
|
16220
16235
|
}
|
|
16221
16236
|
//#endregion
|
|
16222
16237
|
//#region src/Processor/IESParser.js
|
|
16223
|
-
function
|
|
16238
|
+
function km(e, t = "ies") {
|
|
16224
16239
|
let n = e.search(/TILT\s*=/i);
|
|
16225
16240
|
if (n < 0) throw Error(`IES (${t}): missing TILT line`);
|
|
16226
16241
|
let r = e.indexOf("\n", n);
|
|
16227
16242
|
if (r < 0) throw Error(`IES (${t}): truncated TILT line`);
|
|
16228
16243
|
let i = e.slice(n, r).match(/TILT\s*=\s*(\w+)/i), a = i ? i[1].toUpperCase() : "NONE", o = e.slice(r);
|
|
16229
16244
|
if (a === "INCLUDE") {
|
|
16230
|
-
let e =
|
|
16231
|
-
o =
|
|
16245
|
+
let e = Nm(o), t = 2 + 2 * Number(e[1]);
|
|
16246
|
+
o = Pm(o, t);
|
|
16232
16247
|
}
|
|
16233
|
-
let s =
|
|
16248
|
+
let s = Nm(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
|
|
16234
16249
|
l(), l(), l(), l();
|
|
16235
16250
|
let g = l();
|
|
16236
16251
|
if (l(), l(), !Number.isFinite(p) || p <= 0) throw Error(`IES (${t}): invalid vertical angle count ${p}`);
|
|
@@ -16256,18 +16271,18 @@ function Em(e, t = "ies") {
|
|
|
16256
16271
|
name: t
|
|
16257
16272
|
};
|
|
16258
16273
|
}
|
|
16259
|
-
function
|
|
16274
|
+
function Am(e, t, n) {
|
|
16260
16275
|
let r = new Uint8Array(t * n), { verticalAngles: i, horizontalAngles: a, candela: o, maxCandela: s } = e;
|
|
16261
16276
|
if (s <= 0) return r;
|
|
16262
16277
|
let c = i[i.length - 1], l = a[a.length - 1], u = a[0], d = a.length === 1 || l === u;
|
|
16263
16278
|
for (let e = 0; e < n; e++) {
|
|
16264
|
-
let f = (e + .5) / n * c, p =
|
|
16279
|
+
let f = (e + .5) / n * c, p = Fm(i, f), m = Math.min(p + 1, i.length - 1), h = i[m] - i[p], g = h > 0 ? (f - i[p]) / h : 0;
|
|
16265
16280
|
for (let n = 0; n < t; n++) {
|
|
16266
16281
|
let i;
|
|
16267
|
-
if (d) i =
|
|
16282
|
+
if (d) i = Im(o[p][0], o[m][0], g);
|
|
16268
16283
|
else {
|
|
16269
|
-
let e = u + (n + .5) / t * (l - u), r =
|
|
16270
|
-
i =
|
|
16284
|
+
let e = u + (n + .5) / t * (l - u), r = Fm(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];
|
|
16285
|
+
i = Im(Im(f, h, d), Im(_, v, d), g);
|
|
16271
16286
|
}
|
|
16272
16287
|
let c = Math.min(1, Math.max(0, i / s));
|
|
16273
16288
|
r[e * t + n] = Math.round(c * 255);
|
|
@@ -16275,7 +16290,7 @@ function Dm(e, t, n) {
|
|
|
16275
16290
|
}
|
|
16276
16291
|
return r;
|
|
16277
16292
|
}
|
|
16278
|
-
function
|
|
16293
|
+
function jm(e, t = .1) {
|
|
16279
16294
|
let { verticalAngles: n, horizontalAngles: r, candela: i, maxCandela: a } = e, o = Math.PI / 4;
|
|
16280
16295
|
if (a <= 0 || !n?.length) return o;
|
|
16281
16296
|
let s = a * t, c = r.length, l = n[n.length - 1], u = !1;
|
|
@@ -16290,7 +16305,7 @@ function Om(e, t = .1) {
|
|
|
16290
16305
|
let d = l * Math.PI / 180;
|
|
16291
16306
|
return Math.min(Math.max(d, 5 * Math.PI / 180), 89 * Math.PI / 180);
|
|
16292
16307
|
}
|
|
16293
|
-
function
|
|
16308
|
+
function Mm(e, t, n = .7) {
|
|
16294
16309
|
let { verticalAngles: r, horizontalAngles: i, candela: a, maxCandela: o } = e;
|
|
16295
16310
|
if (o <= 0 || !r?.length || t <= 0) return 0;
|
|
16296
16311
|
let s = o * n, c = i.length, l = 0;
|
|
@@ -16303,15 +16318,15 @@ function km(e, t, n = .7) {
|
|
|
16303
16318
|
let u = t * 180 / Math.PI, d = u > 0 ? 1 - l / u : 0;
|
|
16304
16319
|
return Math.min(Math.max(d, 0), 1);
|
|
16305
16320
|
}
|
|
16306
|
-
function
|
|
16321
|
+
function Nm(e) {
|
|
16307
16322
|
return e.split(/\s+/).filter((e) => e.length > 0);
|
|
16308
16323
|
}
|
|
16309
|
-
function
|
|
16324
|
+
function Pm(e, t) {
|
|
16310
16325
|
let n = /\S+/g, r = 0;
|
|
16311
16326
|
for (; n.exec(e) !== null;) if (r++, r === t) return e.slice(n.lastIndex);
|
|
16312
16327
|
return "";
|
|
16313
16328
|
}
|
|
16314
|
-
function
|
|
16329
|
+
function Fm(e, t) {
|
|
16315
16330
|
if (t <= e[0]) return 0;
|
|
16316
16331
|
if (t >= e[e.length - 1]) return e.length - 1;
|
|
16317
16332
|
let n = 0, r = e.length - 1;
|
|
@@ -16321,12 +16336,12 @@ function Mm(e, t) {
|
|
|
16321
16336
|
}
|
|
16322
16337
|
return n;
|
|
16323
16338
|
}
|
|
16324
|
-
function
|
|
16339
|
+
function Im(e, t, n) {
|
|
16325
16340
|
return e + (t - e) * n;
|
|
16326
16341
|
}
|
|
16327
16342
|
//#endregion
|
|
16328
16343
|
//#region src/managers/IESManager.js
|
|
16329
|
-
var
|
|
16344
|
+
var Lm = class {
|
|
16330
16345
|
constructor(e, t = {}) {
|
|
16331
16346
|
this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._gridWidth = 128, this._gridHeight = 128;
|
|
16332
16347
|
}
|
|
@@ -16337,11 +16352,11 @@ var Pm = class {
|
|
|
16337
16352
|
try {
|
|
16338
16353
|
let r = await fetch(e.url);
|
|
16339
16354
|
if (!r.ok) throw Error(`HTTP ${r.status}`);
|
|
16340
|
-
let i =
|
|
16355
|
+
let i = km(await r.text(), e.name);
|
|
16341
16356
|
return {
|
|
16342
16357
|
it: e,
|
|
16343
16358
|
profile: i,
|
|
16344
|
-
grid:
|
|
16359
|
+
grid: Am(i, t, n)
|
|
16345
16360
|
};
|
|
16346
16361
|
} catch (t) {
|
|
16347
16362
|
return console.warn(`IESManager: failed to load "${e.name}": ${t.message}`), null;
|
|
@@ -16355,14 +16370,14 @@ var Pm = class {
|
|
|
16355
16370
|
let r = t[e];
|
|
16356
16371
|
o[n + e * 4 + 0] = r, o[n + e * 4 + 1] = r, o[n + e * 4 + 2] = r, o[n + e * 4 + 3] = 255;
|
|
16357
16372
|
}
|
|
16358
|
-
let i = r[e].profile, c =
|
|
16373
|
+
let i = r[e].profile, c = jm(i);
|
|
16359
16374
|
s.push({
|
|
16360
16375
|
name: r[e].it.name,
|
|
16361
16376
|
index: e,
|
|
16362
16377
|
maxCandela: i.maxCandela,
|
|
16363
16378
|
photometricType: i.photometricType,
|
|
16364
16379
|
suggestedAngle: c,
|
|
16365
|
-
suggestedPenumbra:
|
|
16380
|
+
suggestedPenumbra: Mm(i, c),
|
|
16366
16381
|
lumens: i.lumens
|
|
16367
16382
|
});
|
|
16368
16383
|
}
|
|
@@ -16395,7 +16410,7 @@ var Pm = class {
|
|
|
16395
16410
|
l = Number.isFinite(e.lumens) ? e.lumens : null, i.userData.ies = {
|
|
16396
16411
|
name: e.name,
|
|
16397
16412
|
index: e.index,
|
|
16398
|
-
intensity:
|
|
16413
|
+
intensity: Rm(n),
|
|
16399
16414
|
fixtureLumens: l
|
|
16400
16415
|
}, 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);
|
|
16401
16416
|
}
|
|
@@ -16418,16 +16433,16 @@ var Pm = class {
|
|
|
16418
16433
|
return t && t.isSpotLight ? t : null;
|
|
16419
16434
|
}
|
|
16420
16435
|
};
|
|
16421
|
-
function
|
|
16436
|
+
function Rm(e) {
|
|
16422
16437
|
return Math.max(0, Math.min(1, e));
|
|
16423
16438
|
}
|
|
16424
16439
|
//#endregion
|
|
16425
16440
|
//#region src/Passes/OIDNDenoiser.js
|
|
16426
|
-
var
|
|
16427
|
-
async function
|
|
16428
|
-
return
|
|
16441
|
+
var zm = fi("oidn"), Bm = null;
|
|
16442
|
+
async function Vm() {
|
|
16443
|
+
return Bm ||= (await import("oidn-web")).initUNetFromURL, Bm;
|
|
16429
16444
|
}
|
|
16430
|
-
var
|
|
16445
|
+
var Hm = new Float32Array(3), Um = {
|
|
16431
16446
|
QUALITY_MODELS: {
|
|
16432
16447
|
fast: {
|
|
16433
16448
|
model: "rt_hdr_alb_nrm_small",
|
|
@@ -16452,17 +16467,17 @@ var zm = new Float32Array(3), Bm = {
|
|
|
16452
16467
|
debugGbufferMaps: !0,
|
|
16453
16468
|
tileSize: 1024
|
|
16454
16469
|
}
|
|
16455
|
-
},
|
|
16456
|
-
function
|
|
16470
|
+
}, Wm = "\n@group(0) @binding(0) var<storage, read_write> col: array<vec4<f32>>;\n@group(0) @binding(1) var<uniform> scale: f32;\n\n@compute @workgroup_size(64)\nfn main( @builtin(global_invocation_id) gid: vec3<u32>,\n @builtin(num_workgroups) nwg: vec3<u32> ) {\n let i = gid.y * nwg.x * 64u + gid.x;\n if ( i >= arrayLength( &col ) ) { return; }\n let c = col[ i ];\n col[ i ] = vec4<f32>( c.xyz * scale, c.w );\n}\n", Gm = 64, Km = 32768, qm = .18;
|
|
16471
|
+
function Jm(e, t) {
|
|
16457
16472
|
let n = 0;
|
|
16458
16473
|
for (let r = 0; r < t; r++) {
|
|
16459
16474
|
let t = r * 4, i = .212671 * e[t] + .71516 * e[t + 1] + .072169 * e[t + 2];
|
|
16460
16475
|
n += Math.log2(Math.max(i, 0) + 1e-4);
|
|
16461
16476
|
}
|
|
16462
|
-
let r =
|
|
16477
|
+
let r = qm / 2 ** (n / t);
|
|
16463
16478
|
return Number.isFinite(r) && r > 0 ? r : 1;
|
|
16464
16479
|
}
|
|
16465
|
-
var
|
|
16480
|
+
var Ym = class extends dt {
|
|
16466
16481
|
constructor(e, t, n, r, i = {}) {
|
|
16467
16482
|
if (super(), !e || !t || !n || !r) throw Error("OIDNDenoiser requires output canvas, renderer, scene, and camera");
|
|
16468
16483
|
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.refreshInput = i.refreshInput || null, this.getExposure = i.getExposure || (() => 1), this.getToneMapping = i.getToneMapping || (() => We), this.getSaturation = i.getSaturation || (() => 1), this.getTransparentBackground = i.getTransparentBackground || (() => !1), this.isGPUMode = !!this.backendParamsGetter, this.gpuDevice = null, this._gpuInputBuffers = {
|
|
@@ -16473,14 +16488,14 @@ var Km = class extends dt {
|
|
|
16473
16488
|
width: 0,
|
|
16474
16489
|
height: 0
|
|
16475
16490
|
}, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._colorScalePipeline = null, this._colorScaleBindGroup = null, this._colorScaleUniform = null, this._oidnInputScale = 1, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
|
|
16476
|
-
...
|
|
16491
|
+
...Um.DEFAULT_OPTIONS,
|
|
16477
16492
|
...i
|
|
16478
16493
|
}, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.maxTileSize = this.config.tileSize, this._activeTileSize = 0, this.state = {
|
|
16479
16494
|
isDenoising: !1,
|
|
16480
16495
|
isLoading: !1,
|
|
16481
16496
|
abortController: null
|
|
16482
16497
|
}, this._pendingStagingBuffers = /* @__PURE__ */ new Set(), this._pendingTileBlits = [], this.currentTZAUrl = null, this.unet = null, this._pendingStart = !1, this._initialize().catch((e) => {
|
|
16483
|
-
|
|
16498
|
+
zm.error("init failed:", e), this.dispatchEvent({
|
|
16484
16499
|
type: "error",
|
|
16485
16500
|
error: e
|
|
16486
16501
|
});
|
|
@@ -16509,7 +16524,7 @@ var Km = class extends dt {
|
|
|
16509
16524
|
});
|
|
16510
16525
|
}
|
|
16511
16526
|
expectsCleanAux(e = this.quality) {
|
|
16512
|
-
let { QUALITY_MODELS: t } =
|
|
16527
|
+
let { QUALITY_MODELS: t } = Um;
|
|
16513
16528
|
return (t[e] || t.balance).cleanAux;
|
|
16514
16529
|
}
|
|
16515
16530
|
getRuntimeInfo() {
|
|
@@ -16543,14 +16558,14 @@ var Km = class extends dt {
|
|
|
16543
16558
|
let e = this.backendParamsGetter();
|
|
16544
16559
|
this.gpuDevice = e?.device ?? null, n = e?.device ? e : void 0;
|
|
16545
16560
|
}
|
|
16546
|
-
this.unet = await (await
|
|
16561
|
+
this.unet = await (await Vm())(e, n, {
|
|
16547
16562
|
aux: !0,
|
|
16548
16563
|
hdr: !0,
|
|
16549
16564
|
maxTileSize: t,
|
|
16550
16565
|
dynamicTile: !1
|
|
16551
|
-
}), this.currentTZAUrl = e, this._activeTileSize = t, this.dispatchEvent({ type: "loaded" }),
|
|
16566
|
+
}), this.currentTZAUrl = e, this._activeTileSize = t, this.dispatchEvent({ type: "loaded" }), zm.debug("UNet weights loaded:", e);
|
|
16552
16567
|
} catch (e) {
|
|
16553
|
-
|
|
16568
|
+
zm.error("UNet weights failed to load:", e), this.dispatchEvent({
|
|
16554
16569
|
type: "error",
|
|
16555
16570
|
error: /* @__PURE__ */ Error(`Denoiser loading failed: ${e.message}`)
|
|
16556
16571
|
});
|
|
@@ -16559,14 +16574,14 @@ var Km = class extends dt {
|
|
|
16559
16574
|
}
|
|
16560
16575
|
}
|
|
16561
16576
|
_generateTzaUrl() {
|
|
16562
|
-
let { oidnWeightsBaseUrl: e } = Cl(), { QUALITY_MODELS: t } =
|
|
16577
|
+
let { oidnWeightsBaseUrl: e } = Cl(), { QUALITY_MODELS: t } = Um;
|
|
16563
16578
|
return `${e}${(t[this.quality] || t.balance).model}.tza`;
|
|
16564
16579
|
}
|
|
16565
16580
|
async updateConfiguration(e) {
|
|
16566
16581
|
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.maxTileSize = this.config.tileSize, await this._setupUNetDenoiser());
|
|
16567
16582
|
}
|
|
16568
16583
|
async updateQuality(e) {
|
|
16569
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
16584
|
+
if (!Object.prototype.hasOwnProperty.call(Um.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(Um.QUALITY_MODELS).join(", ")}`);
|
|
16570
16585
|
await this.updateConfiguration({ oidnQuality: e });
|
|
16571
16586
|
}
|
|
16572
16587
|
async start() {
|
|
@@ -16577,7 +16592,7 @@ var Km = class extends dt {
|
|
|
16577
16592
|
if (t) {
|
|
16578
16593
|
this.renderer?.resetState?.(), this.input.style.opacity = "0";
|
|
16579
16594
|
let t = performance.now() - e;
|
|
16580
|
-
|
|
16595
|
+
zm.debug(`denoise complete in ${Q.ms(t)} · quality ${this.quality}`);
|
|
16581
16596
|
}
|
|
16582
16597
|
return t;
|
|
16583
16598
|
}
|
|
@@ -16590,7 +16605,7 @@ var Km = class extends dt {
|
|
|
16590
16605
|
try {
|
|
16591
16606
|
return await this._executeUNet(), !0;
|
|
16592
16607
|
} catch (e) {
|
|
16593
|
-
return e.name === "AbortError" ?
|
|
16608
|
+
return e.name === "AbortError" ? zm.debug("denoise aborted") : zm.error("denoise error:", e), this.input.style.opacity = "1", !1;
|
|
16594
16609
|
} finally {
|
|
16595
16610
|
this.state.isDenoising = !1, this.state.abortController = null, this.dispatchEvent({ type: "end" });
|
|
16596
16611
|
}
|
|
@@ -16600,11 +16615,11 @@ var Km = class extends dt {
|
|
|
16600
16615
|
}
|
|
16601
16616
|
async _executeUNetGPU() {
|
|
16602
16617
|
let { width: e, height: t } = this.output;
|
|
16603
|
-
if (!this.getGPUTextures) return
|
|
16618
|
+
if (!this.getGPUTextures) return zm.warn("GPU mode enabled but getGPUTextures not provided"), !1;
|
|
16604
16619
|
let n = this.getGPUTextures();
|
|
16605
|
-
if (!n?.color) return
|
|
16620
|
+
if (!n?.color) return zm.warn("GPU textures not ready yet"), !1;
|
|
16606
16621
|
let r = this.gpuDevice;
|
|
16607
|
-
if (!r) return
|
|
16622
|
+
if (!r) return zm.warn("gpuDevice not available"), !1;
|
|
16608
16623
|
this.refreshInput?.(), this.ctx.drawImage(this.input, 0, 0, e, t), this._revealOutput(), this._ensureGPUInputBuffers(e, t);
|
|
16609
16624
|
let i = r.createCommandEncoder({ label: "oidn-tex-to-buf" }), a = e * 16, o = this._gpuInputPaddedRowBytes, s = o > a, c = this._gpuInputPadBuffer, l = (n, r) => {
|
|
16610
16625
|
if (!s) i.copyTextureToBuffer({
|
|
@@ -16714,7 +16729,7 @@ var Km = class extends dt {
|
|
|
16714
16729
|
return;
|
|
16715
16730
|
}
|
|
16716
16731
|
let o = new Float32Array(i.getMappedRange()), s = t * n;
|
|
16717
|
-
this._oidnInputScale =
|
|
16732
|
+
this._oidnInputScale = Jm(o, s);
|
|
16718
16733
|
let c = null;
|
|
16719
16734
|
if (this.getTransparentBackground()) {
|
|
16720
16735
|
c = new Uint8Array(s);
|
|
@@ -16723,13 +16738,13 @@ var Km = class extends dt {
|
|
|
16723
16738
|
i.unmap(), this._alphaReadbackMapped = !1, this._cachedAlpha = c, this._cachedAlphaWidth = t;
|
|
16724
16739
|
}
|
|
16725
16740
|
_outputExposure() {
|
|
16726
|
-
return
|
|
16741
|
+
return Ep(this.getExposure(), this.getToneMapping()) / this._oidnInputScale;
|
|
16727
16742
|
}
|
|
16728
16743
|
_applyColorScale(e, t) {
|
|
16729
16744
|
let n = this._oidnInputScale;
|
|
16730
16745
|
if (!this._ensureColorScalePipeline(e)) return;
|
|
16731
16746
|
e.queue.writeBuffer(this._colorScaleUniform, 0, new Float32Array([n]));
|
|
16732
|
-
let r = Math.ceil(t /
|
|
16747
|
+
let r = Math.ceil(t / Gm), i = Math.min(r, Km), a = Math.ceil(r / i), o = e.createCommandEncoder({ label: "oidn-color-scale" }), s = o.beginComputePass({ label: "oidn-color-scale" });
|
|
16733
16748
|
s.setPipeline(this._colorScalePipeline), s.setBindGroup(0, this._colorScaleBindGroup), s.dispatchWorkgroups(i, a, 1), s.end(), e.queue.submit([o.finish()]);
|
|
16734
16749
|
}
|
|
16735
16750
|
_ensureColorScalePipeline(e) {
|
|
@@ -16740,7 +16755,7 @@ var Km = class extends dt {
|
|
|
16740
16755
|
compute: {
|
|
16741
16756
|
module: e.createShaderModule({
|
|
16742
16757
|
label: "oidn-color-scale",
|
|
16743
|
-
code:
|
|
16758
|
+
code: Wm
|
|
16744
16759
|
}),
|
|
16745
16760
|
entryPoint: "main"
|
|
16746
16761
|
}
|
|
@@ -16797,10 +16812,10 @@ var Km = class extends dt {
|
|
|
16797
16812
|
}
|
|
16798
16813
|
r.queue.submit([d.finish()]);
|
|
16799
16814
|
let f = u.mapAsync(GPUMapMode.READ).then(() => {
|
|
16800
|
-
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this._outputExposure(), c = this.getSaturation(), l =
|
|
16815
|
+
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this._outputExposure(), c = this.getSaturation(), l = Cp.get(this.getToneMapping()) || Cp.get(We), d = this._cachedAlpha, f = this._cachedAlphaWidth;
|
|
16801
16816
|
for (let i = 0, a = e.length; i < a; i += 4) {
|
|
16802
16817
|
let a = e[i] * r, s = e[i + 1] * r, u = e[i + 2] * r;
|
|
16803
|
-
if (c !== 1 && (
|
|
16818
|
+
if (c !== 1 && (Hm[0] = a, Hm[1] = s, Hm[2] = u, Ap(Hm, c), a = Hm[0], s = Hm[1], u = Hm[2]), l(a, s, u, 1, Hm), t.data[i] = Tp(Hm[0]) * 255 + .5 | 0, t.data[i + 1] = Tp(Hm[1]) * 255 + .5 | 0, t.data[i + 2] = Tp(Hm[2]) * 255 + .5 | 0, d) {
|
|
16804
16819
|
let e = (i >> 2) % o, r = (i >> 2) / o | 0;
|
|
16805
16820
|
t.data[i + 3] = d[(n.y + r) * f + n.x + e];
|
|
16806
16821
|
} else t.data[i + 3] = 255;
|
|
@@ -16827,7 +16842,7 @@ var Km = class extends dt {
|
|
|
16827
16842
|
async _displayGPUOutput({ data: e, width: t, height: n }) {
|
|
16828
16843
|
let r = this.gpuDevice;
|
|
16829
16844
|
if (!r) {
|
|
16830
|
-
|
|
16845
|
+
zm.error("gpuDevice not available for output readback");
|
|
16831
16846
|
return;
|
|
16832
16847
|
}
|
|
16833
16848
|
let i = t * n * 4 * 4, a = r.createBuffer({
|
|
@@ -16838,10 +16853,10 @@ var Km = class extends dt {
|
|
|
16838
16853
|
try {
|
|
16839
16854
|
let o = r.createCommandEncoder({ label: "oidn-readback" });
|
|
16840
16855
|
o.copyBufferToBuffer(e, 0, a, 0, i), r.queue.submit([o.finish()]), await a.mapAsync(GPUMapMode.READ);
|
|
16841
|
-
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this._outputExposure(), u = this.getSaturation(), d =
|
|
16856
|
+
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this._outputExposure(), u = this.getSaturation(), d = Cp.get(this.getToneMapping()) || Cp.get(We), f = this._cachedAlpha;
|
|
16842
16857
|
for (let e = 0, t = s.length; e < t; e += 4) {
|
|
16843
16858
|
let t = s[e] * l, n = s[e + 1] * l, r = s[e + 2] * l;
|
|
16844
|
-
u !== 1 && (
|
|
16859
|
+
u !== 1 && (Hm[0] = t, Hm[1] = n, Hm[2] = r, Ap(Hm, u), t = Hm[0], n = Hm[1], r = Hm[2]), d(t, n, r, 1, Hm), c.data[e] = Tp(Hm[0]) * 255 + .5 | 0, c.data[e + 1] = Tp(Hm[1]) * 255 + .5 | 0, c.data[e + 2] = Tp(Hm[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
|
|
16845
16860
|
}
|
|
16846
16861
|
a.unmap(), this.ctx.putImageData(c, 0, 0);
|
|
16847
16862
|
} finally {
|
|
@@ -16849,12 +16864,12 @@ var Km = class extends dt {
|
|
|
16849
16864
|
}
|
|
16850
16865
|
}
|
|
16851
16866
|
abort() {
|
|
16852
|
-
this._pendingStart = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this._destroyPendingStagingBuffers(), this.input.style.opacity = "1", this.state.isDenoising = !1, this.dispatchEvent({ type: "end" }),
|
|
16867
|
+
this._pendingStart = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this._destroyPendingStagingBuffers(), this.input.style.opacity = "1", this.state.isDenoising = !1, this.dispatchEvent({ type: "end" }), zm.debug("denoise aborted"));
|
|
16853
16868
|
}
|
|
16854
16869
|
setSize(e, t) {
|
|
16855
16870
|
if (e <= 0 || t <= 0) throw Error(`Invalid dimensions: ${e}x${t}`);
|
|
16856
16871
|
this.output.width = e, this.output.height = t, this._setupUNetDenoiser().catch((e) => {
|
|
16857
|
-
|
|
16872
|
+
zm.error("reinitialize after size change failed:", e);
|
|
16858
16873
|
});
|
|
16859
16874
|
}
|
|
16860
16875
|
_destroyPendingStagingBuffers() {
|
|
@@ -16862,13 +16877,13 @@ var Km = class extends dt {
|
|
|
16862
16877
|
this._pendingStagingBuffers.clear();
|
|
16863
16878
|
}
|
|
16864
16879
|
dispose() {
|
|
16865
|
-
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), this._destroyGPUInputBuffers(), this._colorScalePipeline = null, this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(),
|
|
16880
|
+
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), this._destroyGPUInputBuffers(), this._colorScalePipeline = null, this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), zm.debug("disposed");
|
|
16866
16881
|
}
|
|
16867
|
-
},
|
|
16868
|
-
function
|
|
16882
|
+
}, Xm = "let e={ortRuntimeUrl:`https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/ort.webgpu.bundle.min.mjs`,ortWasmPaths:`https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/`,cacheNamespace:`rayzee`},t=null;async function n(){return t||(t=await import(e.ortRuntimeUrl),t.env.wasm.wasmPaths=e.ortWasmPaths,t.env.logLevel=`error`,t)}function r(){return`${e.cacheNamespace}:ai-upscaler-models`}const i=`models`;let a=null,o=null;function s(){return new Promise((e,t)=>{let n=indexedDB.open(r(),1);n.onupgradeneeded=()=>n.result.createObjectStore(i),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function c(e){try{let t=await s();return await new Promise((n,r)=>{let a=t.transaction(i,`readonly`).objectStore(i).get(e);a.onsuccess=()=>n(a.result||null),a.onerror=()=>r(a.error)})}catch{return null}}async function l(e,t){try{let n=await s();await new Promise((r,a)=>{let o=n.transaction(i,`readwrite`);o.objectStore(i).put(t,e),o.oncomplete=()=>r(),o.onerror=()=>a(o.error)})}catch{}}async function u(e){let t=await c(e);if(t)return console.log(`AI Upscaler Worker: model loaded from cache (${(t.byteLength/1024/1024).toFixed(1)}MB)`),t;let n=await fetch(e);if(!n.ok)throw Error(`Failed to fetch model: ${n.status}`);let r=await n.arrayBuffer();return l(e,r.slice(0)),r}async function d(e,t){if(a&&o===e){self.postMessage({type:`loaded`,backend:`webgpu`});return}a&&=(await a.release(),null);let[r,i]=await Promise.all([u(e),n()]);a=await i.InferenceSession.create(r,t),o=e;let s=512;try{let e=await navigator.gpu?.requestAdapter(),t=await e?.requestAdapterInfo?.()||e?.info,n=/apple|swiftshader|llvmpipe/i.test(t?.vendor||``)||/apple|swiftshader/i.test(t?.architecture||``),r=t?.device?.toLowerCase?.()?.includes(`integrated`)||/intel.*iris|intel.*uhd|intel.*hd|amd.*vega|radeon.*graphics/i.test(t?.description||``);s=n?128:r?256:512,console.log(`AI Upscaler Worker: GPU=\"${t?.description||t?.device||`unknown`}\", tileSize=${s}`)}catch{}let c=(r.byteLength/1024/1024).toFixed(1);console.log(`AI Upscaler Worker: model loaded (${c}MB), backend: webgpu`),self.postMessage({type:`loaded`,backend:`webgpu`,tileSize:s})}async function f(e,t,r,i){let o=await n(),s=a.inputNames[0],c=a.outputNames[0],l=new o.Tensor(`float32`,e,[1,3,r,t]),u=(await a.run({[s]:l}))[c].data;self.postMessage({type:`inferred`,outputData:u,id:i},[u.buffer])}self.onmessage=async t=>{let{type:n}=t.data;try{n===`load`?(t.data.ortRuntimeUrl&&(e.ortRuntimeUrl=t.data.ortRuntimeUrl),t.data.ortWasmPaths&&(e.ortWasmPaths=t.data.ortWasmPaths),t.data.cacheNamespace&&(e.cacheNamespace=t.data.cacheNamespace),await d(t.data.url,t.data.sessionOptions)):n===`infer`?await f(t.data.tileData,t.data.width,t.data.height,t.data.id):n===`dispose`&&a&&(await a.release(),a=null,o=null)}catch(e){self.postMessage({type:`error`,message:e.message,id:t.data?.id})}};", Zm = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", Xm], { type: "text/javascript;charset=utf-8" });
|
|
16883
|
+
function Qm(e) {
|
|
16869
16884
|
let t;
|
|
16870
16885
|
try {
|
|
16871
|
-
if (t =
|
|
16886
|
+
if (t = Zm && (self.URL || self.webkitURL).createObjectURL(Zm), !t) throw "";
|
|
16872
16887
|
let n = new Worker(t, {
|
|
16873
16888
|
type: "module",
|
|
16874
16889
|
name: e?.name
|
|
@@ -16877,7 +16892,7 @@ function Ym(e) {
|
|
|
16877
16892
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
16878
16893
|
}), n;
|
|
16879
16894
|
} catch {
|
|
16880
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
16895
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(Xm), {
|
|
16881
16896
|
type: "module",
|
|
16882
16897
|
name: e?.name
|
|
16883
16898
|
});
|
|
@@ -16885,7 +16900,7 @@ function Ym(e) {
|
|
|
16885
16900
|
}
|
|
16886
16901
|
//#endregion
|
|
16887
16902
|
//#region src/Passes/AIUpscaler.js
|
|
16888
|
-
var
|
|
16903
|
+
var $m = {
|
|
16889
16904
|
fast: {
|
|
16890
16905
|
2: "2x-spanx2-ch48.onnx",
|
|
16891
16906
|
4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
|
|
@@ -16899,17 +16914,17 @@ var Xm = {
|
|
|
16899
16914
|
4: "4xNomos2_hq_mosr_fp32.onnx"
|
|
16900
16915
|
}
|
|
16901
16916
|
};
|
|
16902
|
-
function
|
|
16917
|
+
function eh() {
|
|
16903
16918
|
let { upscalerModelBaseUrl: e } = Cl(), t = {};
|
|
16904
|
-
for (let n in
|
|
16919
|
+
for (let n in $m) {
|
|
16905
16920
|
t[n] = {};
|
|
16906
|
-
for (let r in
|
|
16921
|
+
for (let r in $m[n]) t[n][r] = e + $m[n][r];
|
|
16907
16922
|
}
|
|
16908
16923
|
return t;
|
|
16909
16924
|
}
|
|
16910
|
-
var
|
|
16925
|
+
var th = {
|
|
16911
16926
|
get QUALITY_PRESETS() {
|
|
16912
|
-
return
|
|
16927
|
+
return eh();
|
|
16913
16928
|
},
|
|
16914
16929
|
TILE_SIZE: 512,
|
|
16915
16930
|
TILE_OVERLAP: 16,
|
|
@@ -16920,17 +16935,17 @@ var Qm = {
|
|
|
16920
16935
|
}],
|
|
16921
16936
|
graphOptimizationLevel: "all"
|
|
16922
16937
|
}
|
|
16923
|
-
},
|
|
16938
|
+
}, nh = class extends dt {
|
|
16924
16939
|
constructor(e, t, n = {}) {
|
|
16925
16940
|
if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
|
|
16926
|
-
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 || (() => We), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.refreshInput = n.refreshInput || null, this.tileSize = n.tileSize ||
|
|
16941
|
+
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 || (() => We), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.refreshInput = n.refreshInput || null, this.tileSize = n.tileSize || th.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
|
|
16927
16942
|
isUpscaling: !1,
|
|
16928
16943
|
isLoading: !1,
|
|
16929
16944
|
abortController: null
|
|
16930
16945
|
}, 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;
|
|
16931
16946
|
}
|
|
16932
16947
|
async _ensureSession() {
|
|
16933
|
-
let e =
|
|
16948
|
+
let e = th.QUALITY_PRESETS[this.quality];
|
|
16934
16949
|
if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
|
|
16935
16950
|
let t = e[this.scaleFactor];
|
|
16936
16951
|
if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
|
|
@@ -16940,14 +16955,14 @@ var Qm = {
|
|
|
16940
16955
|
message: `Loading ${this.scaleFactor}x upscale model...`
|
|
16941
16956
|
});
|
|
16942
16957
|
try {
|
|
16943
|
-
this._worker ||= new
|
|
16958
|
+
this._worker ||= new Qm(), await new Promise((e, n) => {
|
|
16944
16959
|
let r = (t) => {
|
|
16945
16960
|
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)));
|
|
16946
16961
|
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } = Cl();
|
|
16947
16962
|
this._worker.addEventListener("message", r), this._worker.postMessage({
|
|
16948
16963
|
type: "load",
|
|
16949
16964
|
url: t,
|
|
16950
|
-
sessionOptions:
|
|
16965
|
+
sessionOptions: th.SESSION_OPTIONS,
|
|
16951
16966
|
ortRuntimeUrl: i,
|
|
16952
16967
|
ortWasmPaths: a,
|
|
16953
16968
|
cacheNamespace: o
|
|
@@ -17020,8 +17035,8 @@ var Qm = {
|
|
|
17020
17035
|
willReadFrequently: !0,
|
|
17021
17036
|
alpha: !0
|
|
17022
17037
|
});
|
|
17023
|
-
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn =
|
|
17024
|
-
let o =
|
|
17038
|
+
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = Cp.get(this.getToneMapping()) || Cp.get(We), this._hdrExposure = Ep(this.getExposure(), this.getToneMapping()), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
|
|
17039
|
+
let o = th.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
|
|
17025
17040
|
for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
|
|
17026
17041
|
if (e.aborted) throw new DOMException("Aborted", "AbortError");
|
|
17027
17042
|
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);
|
|
@@ -17095,7 +17110,7 @@ var Qm = {
|
|
|
17095
17110
|
let u = ((n + e) * o + (t + i)) * 4, d = e * r + i;
|
|
17096
17111
|
if (s) {
|
|
17097
17112
|
let e = this._hdrToneMapFn, t = this._hdrExposure, n = this._hdrSaturation, r = a[u] * t, i = a[u + 1] * t, o = a[u + 2] * t;
|
|
17098
|
-
n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o,
|
|
17113
|
+
n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, Ap(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] ** +wp, l[c + d] = this._tmOut[1] ** +wp, l[2 * c + d] = this._tmOut[2] ** +wp;
|
|
17099
17114
|
} else l[d] = a[u] / 255, l[c + d] = a[u + 1] / 255, l[2 * c + d] = a[u + 2] / 255;
|
|
17100
17115
|
}
|
|
17101
17116
|
return l;
|
|
@@ -17153,10 +17168,10 @@ var Qm = {
|
|
|
17153
17168
|
this._backupCanvas = document.createElement("canvas"), this._backupCanvas.width = e.width, this._backupCanvas.height = e.height;
|
|
17154
17169
|
let t = this._backupCanvas.getContext("2d");
|
|
17155
17170
|
if (e.isHDR) {
|
|
17156
|
-
let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s =
|
|
17171
|
+
let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = Cp.get(this.getToneMapping()) || Cp.get(We), c = Ep(this.getExposure(), this.getToneMapping()), l = this.getSaturation(), u = new Float32Array(3);
|
|
17157
17172
|
for (let e = 0, t = r * i; e < t; e++) {
|
|
17158
17173
|
let t = e * 4, r = n[t] * c, i = n[t + 1] * c, a = n[t + 2] * c;
|
|
17159
|
-
l !== 1 && (u[0] = r, u[1] = i, u[2] = a,
|
|
17174
|
+
l !== 1 && (u[0] = r, u[1] = i, u[2] = a, Ap(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +wp * 255 + .5 | 0, o[t + 1] = u[1] ** +wp * 255 + .5 | 0, o[t + 2] = u[2] ** +wp * 255 + .5 | 0, o[t + 3] = 255;
|
|
17160
17175
|
}
|
|
17161
17176
|
t.putImageData(a, 0, 0);
|
|
17162
17177
|
} else t.putImageData(e, 0, 0);
|
|
@@ -17168,7 +17183,7 @@ var Qm = {
|
|
|
17168
17183
|
this.hdr = !!e;
|
|
17169
17184
|
}
|
|
17170
17185
|
setQuality(e) {
|
|
17171
|
-
if (!
|
|
17186
|
+
if (!th.QUALITY_PRESETS[e]) {
|
|
17172
17187
|
console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
|
|
17173
17188
|
return;
|
|
17174
17189
|
}
|
|
@@ -17191,7 +17206,7 @@ var Qm = {
|
|
|
17191
17206
|
async dispose() {
|
|
17192
17207
|
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");
|
|
17193
17208
|
}
|
|
17194
|
-
},
|
|
17209
|
+
}, rh = class extends dt {
|
|
17195
17210
|
constructor({ renderer: e, mainCanvas: t, scene: n, camera: r, stages: i, pipeline: a, getExposure: o, getSaturation: s, getTransparentBg: c }) {
|
|
17196
17211
|
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._onReset = null, this._onPostProcessRefresh = 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;
|
|
17197
17212
|
}
|
|
@@ -17212,7 +17227,7 @@ var Qm = {
|
|
|
17212
17227
|
setupDenoiser() {
|
|
17213
17228
|
if (!this.denoiserCanvas) return;
|
|
17214
17229
|
let e = this._stages.pathTracer;
|
|
17215
|
-
this.denoiser = new
|
|
17230
|
+
this.denoiser = new Ym(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
|
|
17216
17231
|
...J,
|
|
17217
17232
|
backendParams: () => ({
|
|
17218
17233
|
device: this.renderer.backend.device,
|
|
@@ -17241,7 +17256,7 @@ var Qm = {
|
|
|
17241
17256
|
setupUpscaler() {
|
|
17242
17257
|
if (!this.denoiserCanvas) return;
|
|
17243
17258
|
let e = this._stages.pathTracer;
|
|
17244
|
-
this.upscaler = new
|
|
17259
|
+
this.upscaler = new nh(this.denoiserCanvas, this.renderer, {
|
|
17245
17260
|
scaleFactor: J.upscalerScale || 2,
|
|
17246
17261
|
quality: J.upscalerQuality || "fast",
|
|
17247
17262
|
getSourceCanvas: () => this.denoiser?.enabled ? null : this.renderer.domElement,
|
|
@@ -17396,7 +17411,7 @@ var Qm = {
|
|
|
17396
17411
|
let t = Fr[e];
|
|
17397
17412
|
t && (this._stages.asvgf?.updateParameters(t), this._stages.bilateralFilter?.updateParameters(t), this._stages.variance && t.varianceBoost !== void 0 && (this._stages.variance.varianceBoost.value = t.varianceBoost));
|
|
17398
17413
|
}
|
|
17399
|
-
},
|
|
17414
|
+
}, ih = class {
|
|
17400
17415
|
constructor() {
|
|
17401
17416
|
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;
|
|
17402
17417
|
}
|
|
@@ -17420,7 +17435,7 @@ var Qm = {
|
|
|
17420
17435
|
dispose() {
|
|
17421
17436
|
this.visible = !1;
|
|
17422
17437
|
}
|
|
17423
|
-
},
|
|
17438
|
+
}, ah = class {
|
|
17424
17439
|
constructor(n, r) {
|
|
17425
17440
|
this.layer = "scene", this._enabled = !0, this._outlineNode = Cn(n, r, {
|
|
17426
17441
|
selectedObjects: [],
|
|
@@ -17451,11 +17466,11 @@ var Qm = {
|
|
|
17451
17466
|
this._enabled = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
|
|
17452
17467
|
}
|
|
17453
17468
|
};
|
|
17454
|
-
function
|
|
17469
|
+
function oh(e = !1) {
|
|
17455
17470
|
let t = document.createElement("canvas");
|
|
17456
17471
|
return t.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;" + (e ? "display:none;" : ""), t;
|
|
17457
17472
|
}
|
|
17458
|
-
function
|
|
17473
|
+
function sh(e, t = Infinity) {
|
|
17459
17474
|
let n = e?.getBoundingClientRect();
|
|
17460
17475
|
if (!n || n.width === 0 || n.height === 0) return null;
|
|
17461
17476
|
let r = Math.min(window.devicePixelRatio || 1, 2), i = Math.round(n.width * r), a = Math.round(n.height * r), o = t / Math.max(i, a);
|
|
@@ -17466,9 +17481,9 @@ function ih(e, t = Infinity) {
|
|
|
17466
17481
|
}
|
|
17467
17482
|
//#endregion
|
|
17468
17483
|
//#region src/managers/helpers/ViewOverlayRenderer.js
|
|
17469
|
-
var
|
|
17484
|
+
var ch = 4096, lh = class {
|
|
17470
17485
|
constructor() {
|
|
17471
|
-
this.canvas =
|
|
17486
|
+
this.canvas = oh(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
|
|
17472
17487
|
}
|
|
17473
17488
|
async init({ device: e, sizeSource: t }) {
|
|
17474
17489
|
this._sizeSource = t;
|
|
@@ -17485,7 +17500,7 @@ var ah = 4096, oh = class {
|
|
|
17485
17500
|
}
|
|
17486
17501
|
syncSize() {
|
|
17487
17502
|
if (!this.renderer) return;
|
|
17488
|
-
let e =
|
|
17503
|
+
let e = sh(this._sizeSource, ch);
|
|
17489
17504
|
!e || e.width === this.canvas.width && e.height === this.canvas.height || this.renderer.setSize(e.width, e.height, !1);
|
|
17490
17505
|
}
|
|
17491
17506
|
begin() {
|
|
@@ -17497,18 +17512,18 @@ var ah = 4096, oh = class {
|
|
|
17497
17512
|
dispose() {
|
|
17498
17513
|
wr(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
|
|
17499
17514
|
}
|
|
17500
|
-
},
|
|
17515
|
+
}, uh = fi("overlay"), dh = (e, t) => e.visible && e.layer === t && e.render, fh = class {
|
|
17501
17516
|
constructor(e) {
|
|
17502
|
-
this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas =
|
|
17517
|
+
this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = oh(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
|
|
17503
17518
|
}
|
|
17504
17519
|
async initViewRenderer({ device: e, sizeSource: t }) {
|
|
17505
17520
|
if (!(!e || !t)) try {
|
|
17506
|
-
this._viewOverlay = await new
|
|
17521
|
+
this._viewOverlay = await new lh().init({
|
|
17507
17522
|
device: e,
|
|
17508
17523
|
sizeSource: t
|
|
17509
17524
|
});
|
|
17510
17525
|
} catch (e) {
|
|
17511
|
-
|
|
17526
|
+
uh.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
|
|
17512
17527
|
}
|
|
17513
17528
|
}
|
|
17514
17529
|
setHelperScene(e) {
|
|
@@ -17524,11 +17539,11 @@ var ah = 4096, oh = class {
|
|
|
17524
17539
|
}
|
|
17525
17540
|
setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
|
|
17526
17541
|
this.setHelperScene(e);
|
|
17527
|
-
let s = new
|
|
17542
|
+
let s = new ih();
|
|
17528
17543
|
this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener("resolution_changed", (e) => {
|
|
17529
17544
|
s.setRenderSize(e.width, e.height);
|
|
17530
17545
|
}), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
|
|
17531
|
-
let c = new
|
|
17546
|
+
let c = new ah(t, this.camera);
|
|
17532
17547
|
this.register("outline", c);
|
|
17533
17548
|
}
|
|
17534
17549
|
_wireDenoiserTileEvents(e, t) {
|
|
@@ -17540,7 +17555,7 @@ var ah = 4096, oh = class {
|
|
|
17540
17555
|
}));
|
|
17541
17556
|
}
|
|
17542
17557
|
register(e, t) {
|
|
17543
|
-
this._helpers.has(e) && (
|
|
17558
|
+
this._helpers.has(e) && (uh.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
|
|
17544
17559
|
}
|
|
17545
17560
|
unregister(e) {
|
|
17546
17561
|
let t = this._helpers.get(e);
|
|
@@ -17578,16 +17593,16 @@ var ah = 4096, oh = class {
|
|
|
17578
17593
|
}
|
|
17579
17594
|
_renderSceneLayer(e) {
|
|
17580
17595
|
this._helperScene?.render(e, this.camera);
|
|
17581
|
-
for (let t of this._helpers.values())
|
|
17596
|
+
for (let t of this._helpers.values()) dh(t, "scene") && t.render(e, this.camera);
|
|
17582
17597
|
}
|
|
17583
17598
|
_hasVisibleSceneOverlay() {
|
|
17584
17599
|
if (this._helperScene?.isDrawing) return !0;
|
|
17585
|
-
for (let e of this._helpers.values()) if (
|
|
17600
|
+
for (let e of this._helpers.values()) if (dh(e, "scene")) return !0;
|
|
17586
17601
|
return !1;
|
|
17587
17602
|
}
|
|
17588
17603
|
refreshHUD() {
|
|
17589
17604
|
let e = this._hudCanvas, t = this._hudCtx, n = !1;
|
|
17590
|
-
for (let e of this._helpers.values()) if (
|
|
17605
|
+
for (let e of this._helpers.values()) if (dh(e, "hud")) {
|
|
17591
17606
|
n = !0;
|
|
17592
17607
|
break;
|
|
17593
17608
|
}
|
|
@@ -17596,10 +17611,10 @@ var ah = 4096, oh = class {
|
|
|
17596
17611
|
return;
|
|
17597
17612
|
}
|
|
17598
17613
|
e.style.display !== "" && (e.style.display = "");
|
|
17599
|
-
let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ?
|
|
17614
|
+
let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? sh(e) : null;
|
|
17600
17615
|
if (a) {
|
|
17601
17616
|
(e.width !== a.width || e.height !== a.height) && (e.width = a.width, e.height = a.height), t.clearRect(0, 0, a.width, a.height), t.save(), t.scale(a.width / r, a.height / i);
|
|
17602
|
-
for (let e of this._helpers.values())
|
|
17617
|
+
for (let e of this._helpers.values()) dh(e, "hud") && e.render(t, r, i);
|
|
17603
17618
|
t.restore(), e.style.display !== "" && (e.style.display = "");
|
|
17604
17619
|
}
|
|
17605
17620
|
}
|
|
@@ -17607,7 +17622,7 @@ var ah = 4096, oh = class {
|
|
|
17607
17622
|
for (let e of this._helpers.values()) e.dispose?.();
|
|
17608
17623
|
this._helpers.clear(), this._viewOverlay?.dispose(), this._viewOverlay = null, this._hudCanvas.parentElement && this._hudCanvas.parentElement.removeChild(this._hudCanvas);
|
|
17609
17624
|
}
|
|
17610
|
-
},
|
|
17625
|
+
}, ph = class extends dt {
|
|
17611
17626
|
constructor() {
|
|
17612
17627
|
super(), this.mixer = null, this.timer = new nn(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._tempVec = new cn(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this.wakeCallback = null;
|
|
17613
17628
|
}
|
|
@@ -17707,7 +17722,7 @@ var ah = 4096, oh = class {
|
|
|
17707
17722
|
dispose() {
|
|
17708
17723
|
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;
|
|
17709
17724
|
}
|
|
17710
|
-
},
|
|
17725
|
+
}, mh = new cn(0, 0, -1), hh = class {
|
|
17711
17726
|
constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
|
|
17712
17727
|
this._app = r, this._orbitControls = n, this._camera = e, this._controls = new wn(e, t), this._gizmoScene = new Yt(), 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 cn(), this._normalMatrix = new Ct(), this._refitInFlight = !1, this._baselineComputed = !1, this._tempForward = new cn(), this._lightTargetDistance = null, this._lastLightPosition = null, 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);
|
|
17713
17728
|
}
|
|
@@ -17728,7 +17743,7 @@ var ah = 4096, oh = class {
|
|
|
17728
17743
|
attach(e) {
|
|
17729
17744
|
if (this._attached !== e && (this._controls.attach(e), this._attached = e, this._lightTargetDistance = null, this._lastLightPosition = null, e.isLight && e.target)) {
|
|
17730
17745
|
let t = e.target.position.clone().sub(e.position), n = t.length();
|
|
17731
|
-
n > 1e-4 ? (e.quaternion.setFromUnitVectors(
|
|
17746
|
+
n > 1e-4 ? (e.quaternion.setFromUnitVectors(mh, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1, this._lastLightPosition = e.position.clone();
|
|
17732
17747
|
}
|
|
17733
17748
|
}
|
|
17734
17749
|
detach() {
|
|
@@ -17840,7 +17855,7 @@ var ah = 4096, oh = class {
|
|
|
17840
17855
|
dispose() {
|
|
17841
17856
|
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._tempForward = null, this._lightTargetDistance = null, this._lastLightPosition = null, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
|
|
17842
17857
|
}
|
|
17843
|
-
},
|
|
17858
|
+
}, gh = class {
|
|
17844
17859
|
constructor(e) {
|
|
17845
17860
|
this.layer = "scene", this._transformManager = e, this._enabled = !0;
|
|
17846
17861
|
}
|
|
@@ -17859,42 +17874,42 @@ var ah = 4096, oh = class {
|
|
|
17859
17874
|
dispose() {
|
|
17860
17875
|
this._enabled = !1;
|
|
17861
17876
|
}
|
|
17862
|
-
},
|
|
17863
|
-
function
|
|
17877
|
+
}, _h = /* @__PURE__ */ new WeakMap(), vh = fi("engine");
|
|
17878
|
+
function yh(e, t) {
|
|
17864
17879
|
e.lost.then((e) => {
|
|
17865
17880
|
t.app && t.app._handleDeviceLost(e);
|
|
17866
17881
|
});
|
|
17867
17882
|
}
|
|
17868
|
-
var
|
|
17869
|
-
function
|
|
17883
|
+
var bh = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
|
|
17884
|
+
function xh(e) {
|
|
17870
17885
|
let t = e.info ?? {}, n = `${t.vendor ?? ""} ${t.architecture ?? ""} ${t.device ?? ""} ${t.description ?? ""}`;
|
|
17871
17886
|
return {
|
|
17872
17887
|
vendor: t.vendor ?? "",
|
|
17873
17888
|
architecture: t.architecture ?? "",
|
|
17874
17889
|
device: t.device ?? "",
|
|
17875
17890
|
description: t.description ?? "",
|
|
17876
|
-
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 ||
|
|
17891
|
+
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || bh.test(n)
|
|
17877
17892
|
};
|
|
17878
17893
|
}
|
|
17879
|
-
var
|
|
17894
|
+
var Sh = class extends dt {
|
|
17880
17895
|
constructor(e, t = {}) {
|
|
17881
17896
|
super();
|
|
17882
17897
|
try {
|
|
17883
|
-
|
|
17898
|
+
_h.get(e)?.dispose();
|
|
17884
17899
|
} catch (e) {
|
|
17885
|
-
|
|
17900
|
+
vh.warn("prior canvas owner dispose failed", e);
|
|
17886
17901
|
}
|
|
17887
|
-
|
|
17902
|
+
_h.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this._applySceneMetadataEnabled = t.applySceneMetadata !== !1, this._applyingSceneMetadata = !1, this._profile = jr(t.profile), this._issues = new qc({
|
|
17888
17903
|
strict: t.strict === !0,
|
|
17889
17904
|
onIssue: (e) => this.dispatchEvent({
|
|
17890
17905
|
type: pr.ISSUE,
|
|
17891
17906
|
issue: e
|
|
17892
17907
|
})
|
|
17893
|
-
}), this.settings = new
|
|
17908
|
+
}), this.settings = new pp({
|
|
17894
17909
|
...J,
|
|
17895
17910
|
environmentRotation: this._profile.environmentRotation,
|
|
17896
17911
|
saturation: this._profile.saturation
|
|
17897
|
-
}, { issues: this._issues }), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = J.maxTextureSize, this.pipeline = null, this._pendingReservedRenderSize = 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
|
|
17912
|
+
}, { issues: this._issues }), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = J.maxTextureSize, this.pipeline = null, this._pendingReservedRenderSize = 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 ph(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this._pathTracerEnabled = !0, this._rasterPrecompile = null, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new cp(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._gpuDevice = null, this._deviceLostHolder = null, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null, this.adapterInfo = null;
|
|
17898
17913
|
}
|
|
17899
17914
|
_addTrackedListener(e, t, n) {
|
|
17900
17915
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -17907,12 +17922,12 @@ var yh = class extends dt {
|
|
|
17907
17922
|
for (let { target: e, type: t, handler: n } of this._trackedListeners) try {
|
|
17908
17923
|
e.removeEventListener(t, n);
|
|
17909
17924
|
} catch (e) {
|
|
17910
|
-
|
|
17925
|
+
vh.warn("failed to remove listener", t, e);
|
|
17911
17926
|
}
|
|
17912
17927
|
this._trackedListeners.length = 0;
|
|
17913
17928
|
}
|
|
17914
17929
|
async init() {
|
|
17915
|
-
return await this._initRenderer(), this._applyPendingReservedRenderSize(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), this.stages.pathTracer.setTriangleData(new Float32Array(32), 0), this.stages.pathTracer.setBVHData(new Float32Array(16)), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0,
|
|
17930
|
+
return await this._initRenderer(), this._applyPendingReservedRenderSize(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), this.stages.pathTracer.setTriangleData(new Float32Array(32), 0), this.stages.pathTracer.setBVHData(new Float32Array(16)), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, vh.debug("WebGPU path tracer app initialized"), this;
|
|
17916
17931
|
}
|
|
17917
17932
|
animate() {
|
|
17918
17933
|
if (!this._deviceLost) {
|
|
@@ -17922,7 +17937,7 @@ var yh = class extends dt {
|
|
|
17922
17937
|
}
|
|
17923
17938
|
if (this.cameraManager.controls && this.cameraManager.controls.update(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
|
|
17924
17939
|
let e = this.animationManager.update();
|
|
17925
|
-
e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) =>
|
|
17940
|
+
e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => vh.error("animation refit error:", e)).finally(() => {
|
|
17926
17941
|
this._animRefitInFlight = !1;
|
|
17927
17942
|
}));
|
|
17928
17943
|
}
|
|
@@ -17971,7 +17986,7 @@ var yh = class extends dt {
|
|
|
17971
17986
|
this.animationManagerId &&= (cancelAnimationFrame(this.animationManagerId), null);
|
|
17972
17987
|
}
|
|
17973
17988
|
_handleDeviceLost(e) {
|
|
17974
|
-
this._deviceLost || (this._deviceLost = !0,
|
|
17989
|
+
this._deviceLost || (this._deviceLost = !0, vh.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
|
|
17975
17990
|
type: pr.DEVICE_LOST,
|
|
17976
17991
|
reason: e?.reason,
|
|
17977
17992
|
message: e?.message
|
|
@@ -18001,9 +18016,9 @@ var yh = class extends dt {
|
|
|
18001
18016
|
let e = Me().value, t = ee().value;
|
|
18002
18017
|
e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
|
|
18003
18018
|
} catch (e) {
|
|
18004
|
-
|
|
18019
|
+
vh.warn("failed to clear TSL texture singleton listeners", e);
|
|
18005
18020
|
}
|
|
18006
|
-
this.canvas &&
|
|
18021
|
+
this.canvas && _h.get(this.canvas) === this && _h.delete(this.canvas), this._gpuDevice &&= (this._gpuDevice.onuncapturederror = null, null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), wr(this.renderer), this.renderer = null, this.stages = {}, this.isInitialized = !1;
|
|
18007
18022
|
}
|
|
18008
18023
|
}
|
|
18009
18024
|
unloadScene() {
|
|
@@ -18119,7 +18134,7 @@ var yh = class extends dt {
|
|
|
18119
18134
|
};
|
|
18120
18135
|
n.intensity !== void 0 && (r.environmentIntensity = n.intensity, r.backgroundIntensity = n.intensity), n.rotation !== void 0 && (r.environmentRotation = n.rotation), this.settings.setMany(r, {
|
|
18121
18136
|
reset: !1,
|
|
18122
|
-
source:
|
|
18137
|
+
source: dp.SCENE_METADATA
|
|
18123
18138
|
}), this.scene && (this.scene.background = e), this.dispatchEvent({
|
|
18124
18139
|
type: pr.SCENE_METADATA_APPLIED,
|
|
18125
18140
|
metadata: t,
|
|
@@ -18346,7 +18361,7 @@ var yh = class extends dt {
|
|
|
18346
18361
|
pixelFreezeStability: r.pixelFreezeStability ?? J.pixelFreezeStability
|
|
18347
18362
|
}, {
|
|
18348
18363
|
silent: !0,
|
|
18349
|
-
source:
|
|
18364
|
+
source: dp.MODE_PRESET
|
|
18350
18365
|
}), this.stages.pathTracer?.setUniform("renderMode", parseInt(r.renderMode)), this.stages.pathTracer?.updateCompletionThreshold?.();
|
|
18351
18366
|
let i = this.denoisingManager?.denoiser;
|
|
18352
18367
|
if (i && (i.abort(), i.enabled = r.enableOIDN, i.updateQuality(r.oidnQuality)), this.denoisingManager?._syncGBufferStages?.(), this.denoisingManager?.upscaler?.abort(), t.canvasWidth && t.canvasHeight && (this.setReservedRenderResolution(Math.max(t.canvasWidth, t.canvasHeight)), this.setCanvasSize(t.canvasWidth, t.canvasHeight)), this.needsReset = !1, this.pauseRendering = !1, n) {
|
|
@@ -18448,7 +18463,7 @@ var yh = class extends dt {
|
|
|
18448
18463
|
height: a,
|
|
18449
18464
|
colorSpace: e
|
|
18450
18465
|
} : {
|
|
18451
|
-
data:
|
|
18466
|
+
data: jp(o, {
|
|
18452
18467
|
exposure: this.renderer.toneMappingExposure,
|
|
18453
18468
|
toneMapping: this.renderer.toneMapping,
|
|
18454
18469
|
saturation: this.settings.get("saturation") ?? 1,
|
|
@@ -18540,7 +18555,7 @@ var yh = class extends dt {
|
|
|
18540
18555
|
this._pathTracerEnabled = e, e || this.precompileRaster();
|
|
18541
18556
|
}
|
|
18542
18557
|
precompileRaster() {
|
|
18543
|
-
return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) =>
|
|
18558
|
+
return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) => vh.warn("raster fallback precompile failed", e)), this._rasterPrecompile);
|
|
18544
18559
|
}
|
|
18545
18560
|
get isLoading() {
|
|
18546
18561
|
return this._loadingInProgress;
|
|
@@ -18635,7 +18650,7 @@ var yh = class extends dt {
|
|
|
18635
18650
|
if (gr((e) => this.dispatchEvent(e)), !navigator.gpu) throw Error("WebGPU is not supported in this browser");
|
|
18636
18651
|
let e = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
|
|
18637
18652
|
if (!e) throw Error("Failed to get WebGPU adapter");
|
|
18638
|
-
this.adapterInfo =
|
|
18653
|
+
this.adapterInfo = xh(e), this.adapterInfo.isSoftware && (this._issues.warn(Wc.ADAPTER_SOFTWARE, `software GPU adapter "${this.adapterInfo.description || this.adapterInfo.vendor}" — renders are correct but orders of magnitude slower than hardware`, { ...this.adapterInfo }), vh.warn(`software GPU adapter — check app.adapterInfo.isSoftware. ${this.adapterInfo.description}`));
|
|
18639
18654
|
let t = e.limits;
|
|
18640
18655
|
if (this.renderer = new u({
|
|
18641
18656
|
canvas: this.canvas,
|
|
@@ -18649,16 +18664,16 @@ var yh = class extends dt {
|
|
|
18649
18664
|
}
|
|
18650
18665
|
}), await this.renderer.init(), !this.renderer.backend?.isWebGPUBackend) throw Error("WebGPU backend unavailable — three.js fell back to WebGL2, which cannot run the path tracer's compute kernels. Check GPU process flags and driver support.");
|
|
18651
18666
|
let n = this.renderer.backend?.device;
|
|
18652
|
-
n?.lost && (this._gpuDevice = n, this._deviceLostHolder = { app: this },
|
|
18667
|
+
n?.lost && (this._gpuDevice = n, this._deviceLostHolder = { app: this }, yh(n, this._deviceLostHolder), n.onuncapturederror = (e) => vh.error("WebGPU uncaptured error:", e.error)), r.setLTC(ln.init()), this.renderer.outputColorSpace = a, this.renderer.toneMapping = this._profile.toneMapping, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
|
|
18653
18668
|
}
|
|
18654
18669
|
_initCameraManager() {
|
|
18655
|
-
this.cameraManager = new
|
|
18670
|
+
this.cameraManager = new wm(this.canvas);
|
|
18656
18671
|
}
|
|
18657
18672
|
_initScenes() {
|
|
18658
18673
|
this.scene = new Yt(), this.meshScene = new Yt(), this._sceneHelpers = new In();
|
|
18659
18674
|
}
|
|
18660
18675
|
_initAssetPipeline() {
|
|
18661
|
-
this._sdf = new pl({ issues: this._issues }), this.assetLoader = new
|
|
18676
|
+
this._sdf = new pl({ issues: this._issues }), this.assetLoader = new Cm(this.meshScene, this.cameraManager.camera, this.cameraManager.controls, {
|
|
18662
18677
|
issues: this._issues,
|
|
18663
18678
|
profile: this._profile
|
|
18664
18679
|
}), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
|
|
@@ -18668,24 +18683,24 @@ var yh = class extends dt {
|
|
|
18668
18683
|
_initPipeline() {
|
|
18669
18684
|
this._createStages();
|
|
18670
18685
|
let { clientWidth: e, clientHeight: t } = this.canvas;
|
|
18671
|
-
this.pipeline = new
|
|
18686
|
+
this.pipeline = new op(this.renderer, e || 1, t || 1, { issues: this._issues }), this.pipeline.addStage(this.stages.pathTracer), this.pipeline.addStage(this.stages.normalDepth), this.pipeline.addStage(this.stages.motionVector), this.pipeline.addStage(this.stages.asvgf), this.pipeline.addStage(this.stages.variance), this.pipeline.addStage(this.stages.bilateralFilter), this.pipeline.addStage(this.stages.edgeFilter), this.pipeline.addStage(this.stages.autoExposure), this.pipeline.addStage(this.stages.compositor);
|
|
18672
18687
|
let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
|
|
18673
18688
|
this.pipeline.setSize(n, r);
|
|
18674
18689
|
}
|
|
18675
18690
|
async _initManagers() {
|
|
18676
|
-
this.interactionManager = new
|
|
18691
|
+
this.interactionManager = new lp({
|
|
18677
18692
|
scene: this.meshScene,
|
|
18678
18693
|
camera: this.cameraManager.camera,
|
|
18679
18694
|
canvas: this.canvas,
|
|
18680
18695
|
assetLoader: this.assetLoader,
|
|
18681
18696
|
pathTracer: null,
|
|
18682
18697
|
floorPlane: this.assetLoader.floorPlane
|
|
18683
|
-
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new
|
|
18698
|
+
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new Tm(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new Em(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Lm(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), await this._setupOverlayManager(), this.transformManager = new hh({
|
|
18684
18699
|
camera: this.cameraManager.camera,
|
|
18685
18700
|
canvas: this.canvas,
|
|
18686
18701
|
orbitControls: this.cameraManager.controls,
|
|
18687
18702
|
app: this
|
|
18688
|
-
}), this.overlayManager.register("transform", new
|
|
18703
|
+
}), this.overlayManager.register("transform", new gh(this.transformManager)), this.interactionManager.setDependencies({
|
|
18689
18704
|
overlayManager: this.overlayManager,
|
|
18690
18705
|
transformManager: this.transformManager,
|
|
18691
18706
|
appDispatch: (e) => this.dispatchEvent(e),
|
|
@@ -18757,13 +18772,13 @@ var yh = class extends dt {
|
|
|
18757
18772
|
this.transformManager?.setMeshData(this._sdf.meshes);
|
|
18758
18773
|
}
|
|
18759
18774
|
_createStages() {
|
|
18760
|
-
this.stages.pathTracer = new
|
|
18775
|
+
this.stages.pathTracer = new Cf(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new wf(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new Tf(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.asvgf = new Of(this.renderer, { enabled: !1 }), this.stages.variance = new jf(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new Nf(this.renderer, { enabled: !1 }), this.stages.edgeFilter = new zf(this.renderer, { enabled: !1 }), this.stages.autoExposure = new Kf(this.renderer, { enabled: J.autoExposure ?? !1 }), this.stages.compositor = new qf(this.renderer, {
|
|
18761
18776
|
saturation: this.settings.get("saturation") ?? J.saturation,
|
|
18762
18777
|
pathTracer: this.stages.pathTracer
|
|
18763
18778
|
});
|
|
18764
18779
|
}
|
|
18765
18780
|
_setupDenoisingManager() {
|
|
18766
|
-
this.denoisingManager = new
|
|
18781
|
+
this.denoisingManager = new rh({
|
|
18767
18782
|
renderer: this.renderer,
|
|
18768
18783
|
mainCanvas: this.canvas,
|
|
18769
18784
|
scene: this.scene,
|
|
@@ -18806,7 +18821,7 @@ var yh = class extends dt {
|
|
|
18806
18821
|
this.scene.updateMatrixWorld(), this.overlayManager?.render();
|
|
18807
18822
|
}
|
|
18808
18823
|
async _setupOverlayManager() {
|
|
18809
|
-
this.overlayManager = new
|
|
18824
|
+
this.overlayManager = new fh(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
|
|
18810
18825
|
helperScene: this._sceneHelpers,
|
|
18811
18826
|
meshScene: this.meshScene,
|
|
18812
18827
|
pipeline: this.pipeline,
|
|
@@ -18840,15 +18855,15 @@ var yh = class extends dt {
|
|
|
18840
18855
|
};
|
|
18841
18856
|
//#endregion
|
|
18842
18857
|
//#region src/Headless.js
|
|
18843
|
-
async function
|
|
18844
|
-
let t = await
|
|
18858
|
+
async function Ch(e) {
|
|
18859
|
+
let t = await Th(e);
|
|
18845
18860
|
try {
|
|
18846
|
-
return await
|
|
18861
|
+
return await wh(t, e);
|
|
18847
18862
|
} finally {
|
|
18848
18863
|
t.dispose();
|
|
18849
18864
|
}
|
|
18850
18865
|
}
|
|
18851
|
-
async function
|
|
18866
|
+
async function wh(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire: r = !1, onProgress: i = void 0 } = {}) {
|
|
18852
18867
|
let a = await e.renderFrames(t, {
|
|
18853
18868
|
onProgress: i,
|
|
18854
18869
|
allowEarlyRetire: r
|
|
@@ -18861,9 +18876,9 @@ async function xh(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire
|
|
|
18861
18876
|
adapter: e.adapterInfo
|
|
18862
18877
|
};
|
|
18863
18878
|
}
|
|
18864
|
-
async function
|
|
18879
|
+
async function Th({ canvas: e, model: t = null, width: n = 1920, height: r = 1080, strict: i = !0, profile: a = "physical", deterministic: o = !0, settings: s = null } = {}) {
|
|
18865
18880
|
if (!e) throw Error("openHeadless: a canvas is required");
|
|
18866
|
-
let c = new
|
|
18881
|
+
let c = new Sh(e, {
|
|
18867
18882
|
autoResize: !1,
|
|
18868
18883
|
strict: i,
|
|
18869
18884
|
profile: a
|
|
@@ -18876,7 +18891,7 @@ async function Sh({ canvas: e, model: t = null, width: n = 1920, height: r = 108
|
|
|
18876
18891
|
}
|
|
18877
18892
|
//#endregion
|
|
18878
18893
|
//#region src/managers/VideoRenderManager.js
|
|
18879
|
-
var
|
|
18894
|
+
var Eh = class {
|
|
18880
18895
|
constructor(e) {
|
|
18881
18896
|
this._app = e, this._cancelled = !1, this._rendering = !1;
|
|
18882
18897
|
}
|
|
@@ -18974,4 +18989,4 @@ var Ch = class {
|
|
|
18974
18989
|
}
|
|
18975
18990
|
};
|
|
18976
18991
|
//#endregion
|
|
18977
|
-
export { Br as AF_DEFAULTS, Fr as ASVGF_QUALITY_PRESETS, zr as AUTO_FOCUS_MODES,
|
|
18992
|
+
export { Br as AF_DEFAULTS, Fr as ASVGF_QUALITY_PRESETS, zr as AUTO_FOCUS_MODES, ph as AnimationManager, Hr as BVH_LEAF_MARKERS, Rr as CAMERA_PRESETS, Ir as CAMERA_RANGES, wm as CameraManager, qr as DEFAULT_TEXTURE_MATRIX, rh as DenoisingManager, J as ENGINE_DEFAULTS, pr as EngineEvents, Kc as EngineIssueError, Em as GoboManager, Lm as IESManager, Yr as INTERACTIVE_RENDER_CONFIG, Wc as ISSUE_CODES, Gc as ISSUE_SEVERITY, lp as InteractionManager, qc as IssueLog, Zr as LOG_LEVELS, Tm as LightManager, di as Logger, Nr as MAX_RESERVABLE_RENDER_SIZE, Xr as MEMORY_CONSTANTS, fh as OverlayManager, Jr as PRODUCTION_RENDER_CONFIG, Sh as PathTracerApp, Jf as PipelineContext, Ar as RENDER_PROFILES, op as RenderPipeline, pp as RenderSettings, dr as RenderStage, dp as SETTING_SOURCE, Lr as SKY_PRESETS, ur as StageExecutionMode, Ur as TEXTURE_CONSTANTS, X as TRIANGLE_DATA_LAYOUT, hh as TransformManager, Eu as VRAMTracker, Eh as VideoRenderManager, wu as bufferBytes, wh as captureHeadless, tp as clearBindingAuditFindings, Sl as configureAssets, fi as createLogger, tl as deriveAlphaMode, xh as describeAdapter, _m as extractSceneMetadata, Q as fmt, Cl as getAssetConfig, ep as getBindingAuditFindings, jr as getRenderProfile, Th as openHeadless, gm as parseSceneMetadata, Ch as renderHeadless, $f as setBindingAudit, Tu as textureBytes };
|