rayzee 7.4.1 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/rayzee.es.js +967 -734
- package/dist/rayzee.es.js.map +1 -1
- package/dist/rayzee.umd.js +112 -21
- package/dist/rayzee.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/Processor/AssetLoader.js +7 -1
- package/src/Processor/LightSerializer.js +56 -12
- package/src/Processor/blackbody.js +74 -0
- package/src/Stages/PathTracerStage.js +2 -2
- package/src/TSL/LightsCore.js +139 -12
- package/src/TSL/LightsSampling.js +210 -17
- package/src/managers/LightManager.js +26 -4
- package/src/managers/UniformManager.js +1 -1
package/dist/rayzee.es.js
CHANGED
|
@@ -1051,7 +1051,7 @@ var wr = class {
|
|
|
1051
1051
|
}, r = (e, t) => (this._booleans.add(e), n(e, +!!t, "int"));
|
|
1052
1052
|
n("frame", 0, "uint"), n("maxBounces", X.bounces, "int"), n("maxSamples", X.maxSamples, "int"), n("transmissiveBounces", X.transmissiveBounces, "int"), n("maxSubsurfaceSteps", X.maxSubsurfaceSteps, "int"), n("visMode", X.debugMode, "int"), n("debugVisScale", X.debugVisScale, "float"), r("enableAccumulation", !0), n("accumulationAlpha", 0, "float"), r("cameraIsMoving", !1), r("hasPreviousAccumulated", !1), n("environmentIntensity", X.environmentIntensity, "float"), n("backgroundIntensity", X.backgroundIntensity, "float"), n("backgroundColor", new Qe(0, 0, 0), "color"), n("backgroundBlurriness", X.backgroundBlurriness, "float"), n("backgroundBlurSamples", X.backgroundBlurSamples, "int"), r("showBackground", X.showBackground), r("transparentBackground", X.transparentBackground), r("enableEnvironment", X.enableEnvironment), n("environmentMatrix", new yt(), "mat4"), r("useEnvMapIS", X.useImportanceSampledEnvironment), n("envTotalSum", 0, "float"), n("envCompensationDelta", 0, "float"), n("envResolution", new tn(1, 1), "vec2"), r("groundProjectionEnabled", X.groundProjectionEnabled), n("groundProjectionRadius", X.groundProjectionRadius, "float"), n("groundProjectionHeight", X.groundProjectionHeight, "float"), n("groundProjectionLevel", X.groundProjectionLevel, "float"), r("enableGroundCatcher", X.enableGroundCatcher), n("groundCatcherHeight", X.groundCatcherHeight, "float"), n("sunDirection", new nn(0, 1, 0), "vec3"), n("sunAngularSize", .0087, "float"), r("hasSun", !1), n("globalIlluminationIntensity", X.globalIlluminationIntensity, "float"), n("exposure", X.exposure, "float"), n("numDirectionalLights", 0, "int"), n("numAreaLights", 0, "int"), n("numPointLights", 0, "int"), n("numSpotLights", 0, "int"), this._lightBuffers = {
|
|
1053
1053
|
directional: Me(new Float32Array(192), "float"),
|
|
1054
|
-
area: Me(new Float32Array(
|
|
1054
|
+
area: Me(new Float32Array(256), "float"),
|
|
1055
1055
|
point: Me(new Float32Array(144), "float"),
|
|
1056
1056
|
spot: Me(new Float32Array(320), "float")
|
|
1057
1057
|
}, n("cameraWorldMatrix", new yt(), "mat4"), n("cameraProjectionMatrixInverse", new yt(), "mat4"), n("cameraViewMatrix", new yt(), "mat4"), n("cameraProjectionMatrix", new yt(), "mat4"), r("enableDOF", X.enableDOF), n("focusDistance", X.focusDistance, "float"), n("focalLength", X.focalLength, "float"), n("aperture", X.aperture, "float"), n("apertureScale", 1, "float"), n("anamorphicRatio", X.anamorphicRatio ?? 1, "float"), n("sceneScale", 1, "float"), this._uniforms.set("samplingTechnique", Tn), Tn.value = X.samplingTechnique, n("fireflyThreshold", X.fireflyThreshold, "float"), r("enableEmissiveTriangleSampling", X.enableEmissiveTriangleSampling), n("emissiveBoost", X.emissiveBoost, "float"), n("emissiveTriangleCount", 0, "int"), n("emissiveTotalPower", 0, "float"), n("lightBVHNodeCount", 0, "int"), n("emissiveVec4Offset", 0, "int"), n("reverseMapVec4Offset", 0, "int"), n("renderMode", X.renderMode, "int"), r("enableAlphaShadows", X.enableAlphaShadows), n("resolution", new tn(e, t), "vec2");
|
|
@@ -2958,6 +2958,9 @@ var ro = f(([e, t, n, r, i, a, o]) => {
|
|
|
2958
2958
|
v: "vec3",
|
|
2959
2959
|
color: "vec3",
|
|
2960
2960
|
intensity: "float",
|
|
2961
|
+
normalize: "float",
|
|
2962
|
+
spread: "float",
|
|
2963
|
+
shape: "float",
|
|
2961
2964
|
normal: "vec3",
|
|
2962
2965
|
area: "float"
|
|
2963
2966
|
}), fo = Cn({
|
|
@@ -3004,15 +3007,18 @@ var ro = f(([e, t, n, r, i, a, o]) => {
|
|
|
3004
3007
|
goboScale: e.element(n.add(10))
|
|
3005
3008
|
});
|
|
3006
3009
|
}), _o = f(([e, t]) => {
|
|
3007
|
-
let n = t.mul(
|
|
3010
|
+
let n = t.mul(16), r = W(e.element(n.add(3)), e.element(n.add(4)), e.element(n.add(5))).toVar(), i = W(e.element(n.add(6)), e.element(n.add(7)), e.element(n.add(8))).toVar(), a = O(r, i), o = e.element(n.add(15)), s = ie(a).mul(4);
|
|
3008
3011
|
return uo({
|
|
3009
3012
|
position: W(e.element(n), e.element(n.add(1)), e.element(n.add(2))),
|
|
3010
3013
|
u: r,
|
|
3011
3014
|
v: i,
|
|
3012
3015
|
color: W(e.element(n.add(9)), e.element(n.add(10)), e.element(n.add(11))),
|
|
3013
3016
|
intensity: e.element(n.add(12)),
|
|
3017
|
+
normalize: e.element(n.add(13)),
|
|
3018
|
+
spread: e.element(n.add(14)),
|
|
3019
|
+
shape: o,
|
|
3014
3020
|
normal: L(a),
|
|
3015
|
-
area:
|
|
3021
|
+
area: R(o.greaterThan(.5), s.mul(.7853981633974483), s)
|
|
3016
3022
|
});
|
|
3017
3023
|
}), vo = f(([e, t]) => {
|
|
3018
3024
|
let n = t.mul(9);
|
|
@@ -3084,13 +3090,13 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3084
3090
|
return p(i.lessThan(-1e-4), () => {
|
|
3085
3091
|
let o = M(1).div(i), s = A(e.position.sub(t), r).mul(o).toVar();
|
|
3086
3092
|
p(s.greaterThan(.001), () => {
|
|
3087
|
-
let r = t.add(n.mul(s)).sub(e.position), i = ie(e.u), o = ie(e.v), c = e.u.div(i), l = e.v.div(o), u = A(r, c), d = A(r, l);
|
|
3088
|
-
p(_(u).lessThanEqual(
|
|
3093
|
+
let r = t.add(n.mul(s)).sub(e.position), i = ie(e.u), o = ie(e.v), c = e.u.div(i), l = e.v.div(o), u = A(r, c).div(i), d = A(r, l).div(o);
|
|
3094
|
+
p(R(e.shape.greaterThan(.5), u.mul(u).add(d.mul(d)).lessThanEqual(1), _(u).lessThanEqual(1).and(_(d).lessThanEqual(1))), () => {
|
|
3089
3095
|
a.assign(s);
|
|
3090
3096
|
});
|
|
3091
3097
|
});
|
|
3092
3098
|
}), a;
|
|
3093
|
-
}), Mo = class {
|
|
3099
|
+
}), Mo = /* @__PURE__ */ K("\n fn sphQuadSolidAngle( o: vec3f, s: vec3f, ex: vec3f, ey: vec3f ) -> f32 {\n let PI = 3.141592653589793f;\n let exl = length( ex );\n let eyl = length( ey );\n let x = ex / max( exl, 1e-12f );\n let y = ey / max( eyl, 1e-12f );\n var z = cross( x, y );\n let d = s - o;\n var z0 = dot( d, z );\n if ( z0 > 0.0f ) { z = -z; z0 = -z0; }\n let x0 = dot( d, x );\n let y0 = dot( d, y );\n let x1 = x0 + exl;\n let y1 = y0 + eyl;\n let v00 = vec3f( x0, y0, z0 );\n let v01 = vec3f( x0, y1, z0 );\n let v10 = vec3f( x1, y0, z0 );\n let v11 = vec3f( x1, y1, z0 );\n let n0 = normalize( cross( v00, v10 ) );\n let n1 = normalize( cross( v10, v11 ) );\n let n2 = normalize( cross( v11, v01 ) );\n let n3 = normalize( cross( v01, v00 ) );\n let g0 = acos( clamp( -dot( n0, n1 ), -1.0f, 1.0f ) );\n let g1 = acos( clamp( -dot( n1, n2 ), -1.0f, 1.0f ) );\n let g2 = acos( clamp( -dot( n2, n3 ), -1.0f, 1.0f ) );\n let g3 = acos( clamp( -dot( n3, n0 ), -1.0f, 1.0f ) );\n return g0 + g1 + g2 + g3 - 2.0f * PI;\n }\n"), No = /* @__PURE__ */ K("\n fn sampleSphQuad( o: vec3f, s: vec3f, ex: vec3f, ey: vec3f, uv: vec2f ) -> vec4f {\n let PI = 3.141592653589793f;\n let exl = length( ex );\n let eyl = length( ey );\n let x = ex / max( exl, 1e-12f );\n let y = ey / max( eyl, 1e-12f );\n var z = cross( x, y );\n let d = s - o;\n var z0 = dot( d, z );\n if ( z0 > 0.0f ) { z = -z; z0 = -z0; }\n let z0sq = z0 * z0;\n let x0 = dot( d, x );\n let y0 = dot( d, y );\n let x1 = x0 + exl;\n let y1 = y0 + eyl;\n let y0sq = y0 * y0;\n let y1sq = y1 * y1;\n let v00 = vec3f( x0, y0, z0 );\n let v01 = vec3f( x0, y1, z0 );\n let v10 = vec3f( x1, y0, z0 );\n let v11 = vec3f( x1, y1, z0 );\n let n0 = normalize( cross( v00, v10 ) );\n let n1 = normalize( cross( v10, v11 ) );\n let n2 = normalize( cross( v11, v01 ) );\n let n3 = normalize( cross( v01, v00 ) );\n let g0 = acos( clamp( -dot( n0, n1 ), -1.0f, 1.0f ) );\n let g1 = acos( clamp( -dot( n1, n2 ), -1.0f, 1.0f ) );\n let g2 = acos( clamp( -dot( n2, n3 ), -1.0f, 1.0f ) );\n let g3 = acos( clamp( -dot( n3, n0 ), -1.0f, 1.0f ) );\n let b0 = n0.z;\n let b1 = n2.z;\n let b0sq = b0 * b0;\n let k = 2.0f * PI - g2 - g3;\n let S = g0 + g1 + g2 + g3 - 2.0f * PI;\n\n if ( S <= 1e-5f ) {\n return vec4f( 0.0f, 0.0f, 0.0f, -1.0f );\n }\n\n let au = uv.x * S + k;\n let sinAu = sin( au );\n let fu = ( cos( au ) * b0 - b1 ) / max( abs( sinAu ), 1e-7f ) * sign( sinAu );\n var cu = select( -1.0f, 1.0f, fu >= 0.0f ) / sqrt( fu * fu + b0sq );\n cu = clamp( cu, -1.0f, 1.0f );\n\n var xu = -( cu * z0 ) / max( sqrt( 1.0f - cu * cu ), 1e-7f );\n xu = clamp( xu, x0, x1 );\n\n let dd = sqrt( xu * xu + z0sq );\n let h0 = y0 / sqrt( dd * dd + y0sq );\n let h1 = y1 / sqrt( dd * dd + y1sq );\n let hv = h0 + uv.y * ( h1 - h0 );\n let hv2 = hv * hv;\n var yv = y1;\n if ( hv2 < 1.0f - 1e-6f ) {\n yv = ( hv * dd ) / sqrt( 1.0f - hv2 );\n }\n\n let p = o + xu * x + yv * y + z0 * z;\n return vec4f( p, 1.0f / S );\n }\n"), Po = class {
|
|
3094
3100
|
constructor() {
|
|
3095
3101
|
this.prevColorTexNode = null, this.prevNormalDepthTexNode = null, this.prevAlbedoTexNode = null, this._sceneTextureNodes = null;
|
|
3096
3102
|
}
|
|
@@ -3147,7 +3153,7 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3147
3153
|
dispose() {
|
|
3148
3154
|
this.prevColorTexNode = null, this.prevNormalDepthTexNode = null, this.prevAlbedoTexNode = null, this._sceneTextureNodes = null;
|
|
3149
3155
|
}
|
|
3150
|
-
},
|
|
3156
|
+
}, Fo = class {
|
|
3151
3157
|
constructor(e, t) {
|
|
3152
3158
|
this.traversalCost = e, this.intersectionCost = t, this.maxTreeletLeaves = 7, this.minImprovement = .02, this.topologyCache = /* @__PURE__ */ new Map();
|
|
3153
3159
|
for (let e = 3; e <= this.maxTreeletLeaves; e++) this.topologyCache.set(e, this.generateTopologies(e));
|
|
@@ -3338,10 +3344,10 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3338
3344
|
}
|
|
3339
3345
|
buildSubtree(e, t, n) {
|
|
3340
3346
|
if (typeof e == "number") {
|
|
3341
|
-
let r = t[n[e]], i = new
|
|
3347
|
+
let r = t[n[e]], i = new Io();
|
|
3342
3348
|
return i.minX = r.minX, i.minY = r.minY, i.minZ = r.minZ, i.maxX = r.maxX, i.maxY = r.maxY, i.maxZ = r.maxZ, i.triangleOffset = r.triangleOffset, i.triangleCount = r.triangleCount, i;
|
|
3343
3349
|
}
|
|
3344
|
-
let r = this.buildSubtree(e[0], t, n), i = this.buildSubtree(e[1], t, n), a = new
|
|
3350
|
+
let r = this.buildSubtree(e[0], t, n), i = this.buildSubtree(e[1], t, n), a = new Io();
|
|
3345
3351
|
return a.leftChild = r, a.rightChild = i, a.minX = Math.min(r.minX, i.minX), a.minY = Math.min(r.minY, i.minY), a.minZ = Math.min(r.minZ, i.minZ), a.maxX = Math.max(r.maxX, i.maxX), a.maxY = Math.max(r.maxY, i.maxY), a.maxZ = Math.max(r.maxZ, i.maxZ), a;
|
|
3346
3352
|
}
|
|
3347
3353
|
setTreeletSize(e) {
|
|
@@ -3355,11 +3361,11 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3355
3361
|
getStatistics() {
|
|
3356
3362
|
return { ...this.stats };
|
|
3357
3363
|
}
|
|
3358
|
-
},
|
|
3364
|
+
}, Io = class {
|
|
3359
3365
|
constructor() {
|
|
3360
3366
|
this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.leftChild = null, this.rightChild = null, this.triangleOffset = 0, this.triangleCount = 0;
|
|
3361
3367
|
}
|
|
3362
|
-
},
|
|
3368
|
+
}, Lo = class {
|
|
3363
3369
|
constructor(e, t) {
|
|
3364
3370
|
this.traversalCost = e, this.intersectionCost = t, this.batchSizeRatio = .02, this.maxIterations = 2, this.timeBudgetMs = 15e3, this.stats = {
|
|
3365
3371
|
reinsertionsApplied: 0,
|
|
@@ -3524,7 +3530,7 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3524
3530
|
}
|
|
3525
3531
|
return this.stats.timeMs = performance.now() - n, this.stats;
|
|
3526
3532
|
}
|
|
3527
|
-
},
|
|
3533
|
+
}, Ro = "" + new URL("assets/BVHWorker-CNJ0UBQz.js", import.meta.url).href, zo = {
|
|
3528
3534
|
FLOATS_PER_TRIANGLE: 32,
|
|
3529
3535
|
POSITION_A_OFFSET: 0,
|
|
3530
3536
|
POSITION_B_OFFSET: 4,
|
|
@@ -3534,11 +3540,11 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3534
3540
|
NORMAL_C_OFFSET: 20,
|
|
3535
3541
|
UV_AB_OFFSET: 24,
|
|
3536
3542
|
UV_C_MAT_OFFSET: 28
|
|
3537
|
-
},
|
|
3543
|
+
}, Bo = zo.FLOATS_PER_TRIANGLE, Vo = class {
|
|
3538
3544
|
constructor() {
|
|
3539
3545
|
this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.leftChild = null, this.rightChild = null, this.triangleOffset = 0, this.triangleCount = 0;
|
|
3540
3546
|
}
|
|
3541
|
-
},
|
|
3547
|
+
}, Ho = class {
|
|
3542
3548
|
constructor() {
|
|
3543
3549
|
this.useWorker = !0, this.maxLeafSize = 8, this.numBins = 32, this.minBins = 8, this.maxBins = 64, this.totalNodes = 0, this.processedTriangles = 0, this.totalTriangles = 0, this.lastProgressUpdate = 0, this.progressUpdateInterval = 100, this.traversalCost = 1, this.intersectionCost = 2.5, this.useMortonCodes = !0, this.mortonBits = 10, this.mortonClusterThreshold = 128, this.enableObjectMedianFallback = !0, this.enableSpatialMedianFallback = !0, this.splitStats = {
|
|
3544
3550
|
sahSplits: 0,
|
|
@@ -3598,9 +3604,9 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3598
3604
|
e.enabled !== void 0 && (this.enableReinsertionOptimization = e.enabled), e.batchSizeRatio !== void 0 && (this.reinsertionBatchSizeRatio = Math.max(.005, Math.min(.1, e.batchSizeRatio))), e.maxIterations !== void 0 && (this.reinsertionMaxIterations = Math.max(1, Math.min(5, e.maxIterations)));
|
|
3599
3605
|
}
|
|
3600
3606
|
initializeTriangleArrays() {
|
|
3601
|
-
let e = this.totalTriangles, t = this.triangles, n =
|
|
3607
|
+
let e = this.totalTriangles, t = this.triangles, n = zo.POSITION_A_OFFSET, r = zo.POSITION_B_OFFSET, i = zo.POSITION_C_OFFSET;
|
|
3602
3608
|
for (let a = 0; a < e; a++) {
|
|
3603
|
-
let e = a *
|
|
3609
|
+
let e = a * Bo, o = t[e + n], s = t[e + n + 1], c = t[e + n + 2], l = t[e + r], u = t[e + r + 1], d = t[e + r + 2], f = t[e + i], p = t[e + i + 1], m = t[e + i + 2], h = a * 3;
|
|
3604
3610
|
this.centroids[h] = (o + l + f) / 3, this.centroids[h + 1] = (s + u + p) / 3, this.centroids[h + 2] = (c + d + m) / 3, this.bMin[h] = o < l ? o < f ? o : f : l < f ? l : f, this.bMin[h + 1] = s < u ? s < p ? s : p : u < p ? u : p, this.bMin[h + 2] = c < d ? c < m ? c : m : d < m ? d : m, this.bMax[h] = o > l ? o > f ? o : f : l > f ? l : f, this.bMax[h + 1] = s > u ? s > p ? s : p : u > p ? u : p, this.bMax[h + 2] = c > d ? c > m ? c : m : d > m ? d : m, this.indices[a] = a;
|
|
3605
3611
|
}
|
|
3606
3612
|
}
|
|
@@ -3645,11 +3651,11 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3645
3651
|
this.splitStats.mortonSortTime += performance.now() - t;
|
|
3646
3652
|
}
|
|
3647
3653
|
build(e, t = 30, n = null) {
|
|
3648
|
-
return this.totalTriangles = e.byteLength / (
|
|
3654
|
+
return this.totalTriangles = e.byteLength / (Bo * 4), this.processedTriangles = 0, this.lastProgressUpdate = performance.now(), this.useWorker && typeof Worker < "u" ? new Promise((r, i) => {
|
|
3649
3655
|
let a = (a) => {
|
|
3650
3656
|
let o = this.totalTriangles, s = typeof SharedArrayBuffer < "u";
|
|
3651
3657
|
console.log(`[BVHBuilder] SharedArrayBuffer: ${s ? "enabled" : "unavailable (using transfer fallback)"}`);
|
|
3652
|
-
let c = s ? new SharedArrayBuffer(o *
|
|
3658
|
+
let c = s ? new SharedArrayBuffer(o * Bo * 4) : null;
|
|
3653
3659
|
a.onmessage = (e) => {
|
|
3654
3660
|
let { bvhData: t, triangles: o, originalToBvh: s, error: l, progress: u, treeletStats: d } = e.data;
|
|
3655
3661
|
if (l) {
|
|
@@ -3692,9 +3698,9 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3692
3698
|
a.postMessage(u, [l]);
|
|
3693
3699
|
};
|
|
3694
3700
|
try {
|
|
3695
|
-
a(new Worker(
|
|
3701
|
+
a(new Worker(Ro, { type: "module" }));
|
|
3696
3702
|
} catch (i) {
|
|
3697
|
-
i.name === "SecurityError" ? Nr(
|
|
3703
|
+
i.name === "SecurityError" ? Nr(Ro).then(a).catch(() => {
|
|
3698
3704
|
console.warn("Worker fetch fallback failed, using synchronous build"), r(this._buildSyncAndFlatten(e, t, n));
|
|
3699
3705
|
}) : (console.warn("Worker creation failed, falling back to synchronous build:", i), r(this._buildSyncAndFlatten(e, t, n)));
|
|
3700
3706
|
}
|
|
@@ -3713,7 +3719,7 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3713
3719
|
}
|
|
3714
3720
|
buildSync(e, t = 30, n = null, r = null) {
|
|
3715
3721
|
let i = performance.now();
|
|
3716
|
-
this.totalNodes = 0, this.processedTriangles = 0, this.triangles = e, this.totalTriangles = e.byteLength / (
|
|
3722
|
+
this.totalNodes = 0, this.processedTriangles = 0, this.triangles = e, this.totalTriangles = e.byteLength / (Bo * 4), this.lastProgressUpdate = performance.now(), this.splitStats = {
|
|
3717
3723
|
sahSplits: 0,
|
|
3718
3724
|
objectMedianSplits: 0,
|
|
3719
3725
|
spatialMedianSplits: 0,
|
|
@@ -3738,7 +3744,7 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3738
3744
|
this.centroids = new Float32Array(a * 3), this.bMin = new Float32Array(a * 3), this.bMax = new Float32Array(a * 3), this.indices = new Uint32Array(a), this.mortonCodes = new Uint32Array(a), this.initializeTriangleArrays(), this.splitStats.initTime = performance.now() - o, this.sortTrianglesByMortonCode();
|
|
3739
3745
|
let s = performance.now(), c = this.buildNodeRecursive(0, a, t, n);
|
|
3740
3746
|
if (this.splitStats.sahBuildTime = performance.now() - s, this.enableTreeletOptimization && this.totalTriangles > 1e3) {
|
|
3741
|
-
let e = this.totalTriangles > this.treeletComplexityThreshold, t = e ? 3 : this.treeletSize, r = e ? 10 : this.maxTreeletsPerScene, i = new
|
|
3747
|
+
let e = this.totalTriangles > this.treeletComplexityThreshold, t = e ? 3 : this.treeletSize, r = e ? 10 : this.maxTreeletsPerScene, i = new Fo(this.traversalCost, this.intersectionCost);
|
|
3742
3748
|
i.setTreeletSize(t), i.setMinImprovement(this.treeletMinImprovement), i.setMaxTreelets(r);
|
|
3743
3749
|
let a = performance.now();
|
|
3744
3750
|
for (let e = 0; e < this.treeletOptimizationPasses; e++) {
|
|
@@ -3760,7 +3766,7 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3760
3766
|
this.splitStats.treeletsProcessed = s.treeletsProcessed, this.splitStats.treeletsImproved = s.treeletsImproved, this.splitStats.averageSAHImprovement = s.averageSAHImprovement;
|
|
3761
3767
|
}
|
|
3762
3768
|
if (this.enableReinsertionOptimization && this.totalTriangles > 1e3) {
|
|
3763
|
-
let e = new
|
|
3769
|
+
let e = new Lo(this.traversalCost, this.intersectionCost);
|
|
3764
3770
|
e.setBatchSizeRatio(this.reinsertionBatchSizeRatio), e.setMaxIterations(this.reinsertionMaxIterations);
|
|
3765
3771
|
let t = n ? (e) => {
|
|
3766
3772
|
n(e);
|
|
@@ -3775,10 +3781,10 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3775
3781
|
}
|
|
3776
3782
|
let l = performance.now();
|
|
3777
3783
|
this.applySAOrdering(c), this.splitStats.saOrderTime = performance.now() - l;
|
|
3778
|
-
let u = performance.now(), d = this.triangles, f = r || new Float32Array(a *
|
|
3784
|
+
let u = performance.now(), d = this.triangles, f = r || new Float32Array(a * Bo);
|
|
3779
3785
|
for (let e = 0; e < a; e++) {
|
|
3780
|
-
let t = this.indices[e] *
|
|
3781
|
-
f.set(d.subarray(t, t +
|
|
3786
|
+
let t = this.indices[e] * Bo, n = e * Bo;
|
|
3787
|
+
f.set(d.subarray(t, t + Bo), n);
|
|
3782
3788
|
}
|
|
3783
3789
|
this.reorderedTriangleData = f;
|
|
3784
3790
|
let p = new Uint32Array(a);
|
|
@@ -3794,7 +3800,7 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3794
3800
|
n - this.lastProgressUpdate < this.progressUpdateInterval || (this.lastProgressUpdate = n, t(Math.min(Math.floor(this.processedTriangles / this.totalTriangles * 100), 99)));
|
|
3795
3801
|
}
|
|
3796
3802
|
buildNodeRecursiveToDepth(e, t, n, r, i, a, o, s, c, l, u) {
|
|
3797
|
-
let d = new
|
|
3803
|
+
let d = new Vo();
|
|
3798
3804
|
this.totalNodes++;
|
|
3799
3805
|
let f = t - e;
|
|
3800
3806
|
if (a === void 0 ? this.updateNodeBounds(d, e, t) : (d.minX = a, d.minY = o, d.minZ = s, d.maxX = c, d.maxY = l, d.maxZ = u), f <= this.maxLeafSize || n <= 0) return d.triangleOffset = e, d.triangleCount = f, this.updateProgress(f, i), d;
|
|
@@ -3835,7 +3841,7 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
3835
3841
|
return h === e || h === t ? (d.triangleOffset = e, d.triangleCount = f, this.updateProgress(f, i), d) : (d.leftChild = this.buildNodeRecursiveToDepth(e, h, n - 1, r - 1, i, g, _, v, y, b, x), d.rightChild = this.buildNodeRecursiveToDepth(h, t, n - 1, r - 1, i, S, C, w, T, E, D), d);
|
|
3836
3842
|
}
|
|
3837
3843
|
buildNodeRecursive(e, t, n, r, i, a, o, s, c, l) {
|
|
3838
|
-
let u = new
|
|
3844
|
+
let u = new Vo();
|
|
3839
3845
|
this.totalNodes++;
|
|
3840
3846
|
let d = t - e;
|
|
3841
3847
|
if (i === void 0 ? this.updateNodeBounds(u, e, t) : (u.minX = i, u.minY = a, u.minZ = o, u.maxX = s, u.maxY = c, u.maxZ = l), d <= this.maxLeafSize || n <= 0) return u.triangleOffset = e, u.triangleCount = d, this.updateProgress(d, r), u;
|
|
@@ -4133,7 +4139,7 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
4133
4139
|
let o = r - e, s = i - t, c = a - n;
|
|
4134
4140
|
return 2 * (o * s + s * c + c * o);
|
|
4135
4141
|
}
|
|
4136
|
-
},
|
|
4142
|
+
}, Uo = {
|
|
4137
4143
|
FLOATS_PER_TRIANGLE: 32,
|
|
4138
4144
|
POSITION_A_OFFSET: 0,
|
|
4139
4145
|
POSITION_B_OFFSET: 4,
|
|
@@ -4141,28 +4147,28 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
4141
4147
|
NORMAL_A_OFFSET: 12,
|
|
4142
4148
|
NORMAL_B_OFFSET: 16,
|
|
4143
4149
|
NORMAL_C_OFFSET: 20
|
|
4144
|
-
},
|
|
4150
|
+
}, Wo = Uo.FLOATS_PER_TRIANGLE, Go = 16, Ko = -1, qo = -2, Jo = class {
|
|
4145
4151
|
constructor() {
|
|
4146
4152
|
this._bounds = null, this._boundsNodeCount = 0;
|
|
4147
4153
|
}
|
|
4148
4154
|
updateTrianglePositions(e, t, n) {
|
|
4149
4155
|
let r = n.length;
|
|
4150
4156
|
for (let i = 0; i < r; i++) {
|
|
4151
|
-
let r = n[i], a = i *
|
|
4152
|
-
e[a +
|
|
4157
|
+
let r = n[i], a = i * Wo, o = r * 9, s = t[o], c = t[o + 1], l = t[o + 2], u = t[o + 3], d = t[o + 4], f = t[o + 5], p = t[o + 6], m = t[o + 7], h = t[o + 8];
|
|
4158
|
+
e[a + Uo.POSITION_A_OFFSET] = s, e[a + Uo.POSITION_A_OFFSET + 1] = c, e[a + Uo.POSITION_A_OFFSET + 2] = l, e[a + Uo.POSITION_B_OFFSET] = u, e[a + Uo.POSITION_B_OFFSET + 1] = d, e[a + Uo.POSITION_B_OFFSET + 2] = f, e[a + Uo.POSITION_C_OFFSET] = p, e[a + Uo.POSITION_C_OFFSET + 1] = m, e[a + Uo.POSITION_C_OFFSET + 2] = h;
|
|
4153
4159
|
let g = u - s, _ = d - c, v = f - l, y = p - s, b = m - c, x = h - l, S = _ * x - v * b, C = v * y - g * x, w = g * b - _ * y;
|
|
4154
|
-
e[a +
|
|
4160
|
+
e[a + Uo.NORMAL_A_OFFSET] = S, e[a + Uo.NORMAL_A_OFFSET + 1] = C, e[a + Uo.NORMAL_A_OFFSET + 2] = w, e[a + Uo.NORMAL_B_OFFSET] = S, e[a + Uo.NORMAL_B_OFFSET + 1] = C, e[a + Uo.NORMAL_B_OFFSET + 2] = w, e[a + Uo.NORMAL_C_OFFSET] = S, e[a + Uo.NORMAL_C_OFFSET + 1] = C, e[a + Uo.NORMAL_C_OFFSET + 2] = w;
|
|
4155
4161
|
}
|
|
4156
4162
|
}
|
|
4157
4163
|
refitRange(e, t, n, r) {
|
|
4158
4164
|
r > this._boundsNodeCount && (this._bounds = new Float32Array(r * 6), this._boundsNodeCount = r);
|
|
4159
4165
|
let i = this._bounds, a = n + r;
|
|
4160
4166
|
for (let r = a - 1; r >= n; r--) {
|
|
4161
|
-
let a = r *
|
|
4162
|
-
if (e[a + 3] ===
|
|
4167
|
+
let a = r * Go, o = (r - n) * 6;
|
|
4168
|
+
if (e[a + 3] === Ko) {
|
|
4163
4169
|
let n = e[a], r = e[a + 1], s = Infinity, c = Infinity, l = Infinity, u = -Infinity, d = -Infinity, f = -Infinity;
|
|
4164
4170
|
for (let e = 0; e < r; e++) {
|
|
4165
|
-
let r = (n + e) *
|
|
4171
|
+
let r = (n + e) * Wo, i = t[r + Uo.POSITION_A_OFFSET], a = t[r + Uo.POSITION_A_OFFSET + 1], o = t[r + Uo.POSITION_A_OFFSET + 2], p = t[r + Uo.POSITION_B_OFFSET], m = t[r + Uo.POSITION_B_OFFSET + 1], h = t[r + Uo.POSITION_B_OFFSET + 2], g = t[r + Uo.POSITION_C_OFFSET], _ = t[r + Uo.POSITION_C_OFFSET + 1], v = t[r + Uo.POSITION_C_OFFSET + 2];
|
|
4166
4172
|
s = Math.min(s, i, p, g), c = Math.min(c, a, m, _), l = Math.min(l, o, h, v), u = Math.max(u, i, p, g), d = Math.max(d, a, m, _), f = Math.max(f, o, h, v);
|
|
4167
4173
|
}
|
|
4168
4174
|
i[o] = s, i[o + 1] = c, i[o + 2] = l, i[o + 3] = u, i[o + 4] = d, i[o + 5] = f;
|
|
@@ -4176,15 +4182,15 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
4176
4182
|
n !== this._boundsNodeCount && (this._bounds = new Float32Array(n * 6), this._boundsNodeCount = n);
|
|
4177
4183
|
let r = this._bounds;
|
|
4178
4184
|
for (let i = n - 1; i >= 0; i--) {
|
|
4179
|
-
let n = i *
|
|
4180
|
-
if (o ===
|
|
4185
|
+
let n = i * Go, a = i * 6, o = e[n + 3];
|
|
4186
|
+
if (o === Ko) {
|
|
4181
4187
|
let i = e[n], o = e[n + 1], s = Infinity, c = Infinity, l = Infinity, u = -Infinity, d = -Infinity, f = -Infinity;
|
|
4182
4188
|
for (let e = 0; e < o; e++) {
|
|
4183
|
-
let n = (i + e) *
|
|
4189
|
+
let n = (i + e) * Wo, r = t[n + Uo.POSITION_A_OFFSET], a = t[n + Uo.POSITION_A_OFFSET + 1], o = t[n + Uo.POSITION_A_OFFSET + 2], p = t[n + Uo.POSITION_B_OFFSET], m = t[n + Uo.POSITION_B_OFFSET + 1], h = t[n + Uo.POSITION_B_OFFSET + 2], g = t[n + Uo.POSITION_C_OFFSET], _ = t[n + Uo.POSITION_C_OFFSET + 1], v = t[n + Uo.POSITION_C_OFFSET + 2];
|
|
4184
4190
|
s = Math.min(s, r, p, g), c = Math.min(c, a, m, _), l = Math.min(l, o, h, v), u = Math.max(u, r, p, g), d = Math.max(d, a, m, _), f = Math.max(f, o, h, v);
|
|
4185
4191
|
}
|
|
4186
4192
|
r[a] = s, r[a + 1] = c, r[a + 2] = l, r[a + 3] = u, r[a + 4] = d, r[a + 5] = f;
|
|
4187
|
-
} else if (o ===
|
|
4193
|
+
} else if (o === qo) {
|
|
4188
4194
|
let t = e[n] * 6;
|
|
4189
4195
|
r[a] = r[t], r[a + 1] = r[t + 1], r[a + 2] = r[t + 2], r[a + 3] = r[t + 3], r[a + 4] = r[t + 4], r[a + 5] = r[t + 5];
|
|
4190
4196
|
} else {
|
|
@@ -4193,19 +4199,19 @@ var ko = /* @__PURE__ */ f(([e, t]) => {
|
|
|
4193
4199
|
}
|
|
4194
4200
|
}
|
|
4195
4201
|
}
|
|
4196
|
-
},
|
|
4197
|
-
function
|
|
4198
|
-
let i = e.byteLength / (
|
|
4202
|
+
}, Yo = "" + new URL("assets/BVHSubtreeWorker-D9GImjGj.js", import.meta.url).href, Xo = 32, Zo = 5e4, Qo = 8;
|
|
4203
|
+
function $o(e, t, n, r) {
|
|
4204
|
+
let i = e.byteLength / (Xo * 4), a = Math.min(navigator.hardwareConcurrency || 4, Qo), o = Math.ceil(Math.log2(a * 2.5 + 1));
|
|
4199
4205
|
return console.log(`[ParallelBVH] Parallel build: ${i.toLocaleString()} triangles, ${a} workers, parallelDepth=${o}`), new Promise((s, c) => {
|
|
4200
4206
|
(async () => {
|
|
4201
4207
|
let c = new SharedArrayBuffer(e.byteLength);
|
|
4202
4208
|
new Float32Array(c).set(e);
|
|
4203
|
-
let l = new SharedArrayBuffer(i * 3 * 4), u = new SharedArrayBuffer(i * 3 * 4), d = new SharedArrayBuffer(i * 3 * 4), f = new SharedArrayBuffer(i * 4), p = new SharedArrayBuffer(i * 4), m = new SharedArrayBuffer(i *
|
|
4209
|
+
let l = new SharedArrayBuffer(i * 3 * 4), u = new SharedArrayBuffer(i * 3 * 4), d = new SharedArrayBuffer(i * 3 * 4), f = new SharedArrayBuffer(i * 4), p = new SharedArrayBuffer(i * 4), m = new SharedArrayBuffer(i * Xo * 4), h;
|
|
4204
4210
|
try {
|
|
4205
|
-
h = new Worker(
|
|
4211
|
+
h = new Worker(Ro, { type: "module" });
|
|
4206
4212
|
} catch (e) {
|
|
4207
4213
|
if (e.name !== "SecurityError") throw e;
|
|
4208
|
-
h = await Nr(
|
|
4214
|
+
h = await Nr(Ro);
|
|
4209
4215
|
}
|
|
4210
4216
|
let g = null, _ = [h], v = { id: null }, y = !1, b = () => {
|
|
4211
4217
|
v.id &&= (clearTimeout(v.id), null);
|
|
@@ -4216,7 +4222,7 @@ function Zo(e, t, n, r) {
|
|
|
4216
4222
|
if (y) return;
|
|
4217
4223
|
y = !0, console.warn(`[ParallelBVH] Parallel build failed (${e}), falling back to single worker`), b();
|
|
4218
4224
|
let i = new ArrayBuffer(c.byteLength);
|
|
4219
|
-
new Float32Array(i).set(new Float32Array(c)), s(
|
|
4225
|
+
new Float32Array(i).set(new Float32Array(c)), s(ts(new Float32Array(i), t, n, r));
|
|
4220
4226
|
};
|
|
4221
4227
|
h.onerror = (e) => {
|
|
4222
4228
|
x(`coordinator error: ${e.message}`);
|
|
@@ -4231,7 +4237,7 @@ function Zo(e, t, n, r) {
|
|
|
4231
4237
|
return;
|
|
4232
4238
|
}
|
|
4233
4239
|
if (t.type === "phase1Result") {
|
|
4234
|
-
g = t.splitStats,
|
|
4240
|
+
g = t.splitStats, es(t, a, c, l, u, d, f, m, i, n, h, _, b, x, s, v, r).catch((e) => x(e.message));
|
|
4235
4241
|
return;
|
|
4236
4242
|
}
|
|
4237
4243
|
if (t.type === "assembleResult") {
|
|
@@ -4265,7 +4271,7 @@ function Zo(e, t, n, r) {
|
|
|
4265
4271
|
});
|
|
4266
4272
|
});
|
|
4267
4273
|
}
|
|
4268
|
-
async function
|
|
4274
|
+
async function es(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g) {
|
|
4269
4275
|
let { topFlatData: _, topNodeCount: v, frontierTasks: y, frontierMap: b } = e;
|
|
4270
4276
|
if (!y || y.length === 0) {
|
|
4271
4277
|
console.log("[ParallelBVH] No frontier tasks, assembling with top-level tree only"), u.postMessage({
|
|
@@ -4314,10 +4320,10 @@ async function Qo(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g) {
|
|
|
4314
4320
|
if (t.length === 0) continue;
|
|
4315
4321
|
let s;
|
|
4316
4322
|
try {
|
|
4317
|
-
s = new Worker(
|
|
4323
|
+
s = new Worker(Yo, { type: "module" });
|
|
4318
4324
|
} catch (e) {
|
|
4319
4325
|
if (e.name !== "SecurityError") throw e;
|
|
4320
|
-
s = await Nr(
|
|
4326
|
+
s = await Nr(Yo);
|
|
4321
4327
|
}
|
|
4322
4328
|
d.push(s), s.onerror = (e) => {
|
|
4323
4329
|
p(`subtree worker error: ${e.message}`);
|
|
@@ -4368,17 +4374,17 @@ async function Qo(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g) {
|
|
|
4368
4374
|
});
|
|
4369
4375
|
}
|
|
4370
4376
|
}
|
|
4371
|
-
function
|
|
4377
|
+
function ts(e, t, n, r) {
|
|
4372
4378
|
return new Promise((i, a) => {
|
|
4373
4379
|
(async () => {
|
|
4374
4380
|
let o;
|
|
4375
4381
|
try {
|
|
4376
|
-
o = new Worker(
|
|
4382
|
+
o = new Worker(Ro, { type: "module" });
|
|
4377
4383
|
} catch (e) {
|
|
4378
4384
|
if (e.name !== "SecurityError") throw e;
|
|
4379
|
-
o = await Nr(
|
|
4385
|
+
o = await Nr(Ro);
|
|
4380
4386
|
}
|
|
4381
|
-
let s = e.byteLength / (
|
|
4387
|
+
let s = e.byteLength / (Xo * 4), c = typeof SharedArrayBuffer < "u" ? new SharedArrayBuffer(s * Xo * 4) : null;
|
|
4382
4388
|
o.onmessage = (e) => {
|
|
4383
4389
|
let { bvhData: t, triangles: r, originalToBvh: s, error: l, progress: u, treeletStats: d } = e.data;
|
|
4384
4390
|
if (l) {
|
|
@@ -4416,16 +4422,16 @@ function $o(e, t, n, r) {
|
|
|
4416
4422
|
});
|
|
4417
4423
|
});
|
|
4418
4424
|
}
|
|
4419
|
-
function
|
|
4420
|
-
return typeof Worker < "u" && typeof SharedArrayBuffer < "u" && e >=
|
|
4425
|
+
function ns(e) {
|
|
4426
|
+
return typeof Worker < "u" && typeof SharedArrayBuffer < "u" && e >= Zo;
|
|
4421
4427
|
}
|
|
4422
4428
|
//#endregion
|
|
4423
4429
|
//#region src/Processor/TLASBuilder.js
|
|
4424
|
-
var
|
|
4430
|
+
var rs = 16, is = class {
|
|
4425
4431
|
constructor() {
|
|
4426
4432
|
this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.leftChild = null, this.rightChild = null, this.entryIndex = -1;
|
|
4427
4433
|
}
|
|
4428
|
-
},
|
|
4434
|
+
}, as = class {
|
|
4429
4435
|
constructor() {
|
|
4430
4436
|
this._flatBuffer = null, this._flatBufferCapacity = 0;
|
|
4431
4437
|
}
|
|
@@ -4443,7 +4449,7 @@ var ts = 16, ns = class {
|
|
|
4443
4449
|
};
|
|
4444
4450
|
}
|
|
4445
4451
|
_buildRecursive(e, t) {
|
|
4446
|
-
let n = new
|
|
4452
|
+
let n = new is();
|
|
4447
4453
|
if (t.length === 1) {
|
|
4448
4454
|
let r = e[t[0]].worldAABB;
|
|
4449
4455
|
return n.minX = r.minX, n.minY = r.minY, n.minZ = r.minZ, n.maxX = r.maxX, n.maxY = r.maxY, n.maxZ = r.maxZ, n.entryIndex = t[0], n;
|
|
@@ -4480,12 +4486,12 @@ var ts = 16, ns = class {
|
|
|
4480
4486
|
let e = r.pop();
|
|
4481
4487
|
e._flatIndex = n.length, n.push(e), e.rightChild && r.push(e.rightChild), e.leftChild && r.push(e.leftChild);
|
|
4482
4488
|
}
|
|
4483
|
-
let i = n.length *
|
|
4489
|
+
let i = n.length * rs;
|
|
4484
4490
|
i > this._flatBufferCapacity && (this._flatBuffer = new Float32Array(i), this._flatBufferCapacity = i);
|
|
4485
4491
|
let a = this._flatBuffer;
|
|
4486
4492
|
a.fill(0, 0, i);
|
|
4487
4493
|
for (let e = 0; e < n.length; e++) {
|
|
4488
|
-
let r = n[e], i = e *
|
|
4494
|
+
let r = n[e], i = e * rs;
|
|
4489
4495
|
if (r.leftChild) {
|
|
4490
4496
|
let e = r.leftChild, t = r.rightChild;
|
|
4491
4497
|
a[i] = e.minX, a[i + 1] = e.minY, a[i + 2] = e.minZ, a[i + 3] = e._flatIndex, a[i + 4] = e.maxX, a[i + 5] = e.maxY, a[i + 6] = e.maxZ, a[i + 7] = t._flatIndex, a[i + 8] = t.minX, a[i + 9] = t.minY, a[i + 10] = t.minZ, a[i + 12] = t.maxX, a[i + 13] = t.maxY, a[i + 14] = t.maxZ;
|
|
@@ -4527,7 +4533,7 @@ var ts = 16, ns = class {
|
|
|
4527
4533
|
}
|
|
4528
4534
|
return t;
|
|
4529
4535
|
}
|
|
4530
|
-
},
|
|
4536
|
+
}, os = class {
|
|
4531
4537
|
constructor() {
|
|
4532
4538
|
this.entries = [], this.totalBLASNodes = 0, this.tlasNodeCount = 0;
|
|
4533
4539
|
}
|
|
@@ -4604,7 +4610,7 @@ var ts = 16, ns = class {
|
|
|
4604
4610
|
clear() {
|
|
4605
4611
|
this.entries = [], this.totalBLASNodes = 0, this.tlasNodeCount = 0;
|
|
4606
4612
|
}
|
|
4607
|
-
},
|
|
4613
|
+
}, ss = "" + new URL("assets/TexturesWorker-DBqGmVdR.js", import.meta.url).href, cs = class {
|
|
4608
4614
|
constructor() {
|
|
4609
4615
|
this.canvasContextPairs = [], this.maxPoolSize = vr.CANVAS_POOL_SIZE;
|
|
4610
4616
|
}
|
|
@@ -4644,7 +4650,7 @@ var ts = 16, ns = class {
|
|
|
4644
4650
|
dispose() {
|
|
4645
4651
|
this.canvasContextPairs = [];
|
|
4646
4652
|
}
|
|
4647
|
-
},
|
|
4653
|
+
}, ls = class {
|
|
4648
4654
|
constructor(e = {}) {
|
|
4649
4655
|
this.pools = /* @__PURE__ */ new Map(), this.memoryUsage = 0, this.maxMemoryUsage = e.maxMemory || Sr.MAX_BUFFER_MEMORY, this.allocatedBuffers = /* @__PURE__ */ new WeakMap(), this.sizeStrategy = e.sizeStrategy || "adaptive";
|
|
4650
4656
|
}
|
|
@@ -4702,7 +4708,7 @@ var ts = 16, ns = class {
|
|
|
4702
4708
|
let e = this.getMemoryStats();
|
|
4703
4709
|
return e.utilizationPercentage > 90 ? (console.warn(`Memory pool critical: ${e.utilizationPercentage.toFixed(1)}% used (${(e.currentUsage / (1024 * 1024)).toFixed(1)}MB / ${(e.maxUsage / (1024 * 1024)).toFixed(1)}MB)`), "critical") : e.utilizationPercentage > 70 ? (console.warn(`Memory pool high: ${e.utilizationPercentage.toFixed(1)}% used (${(e.currentUsage / (1024 * 1024)).toFixed(1)}MB / ${(e.maxUsage / (1024 * 1024)).toFixed(1)}MB)`), "high") : "normal";
|
|
4704
4710
|
}
|
|
4705
|
-
},
|
|
4711
|
+
}, us = class {
|
|
4706
4712
|
constructor(e = vr.CACHE_SIZE_LIMIT) {
|
|
4707
4713
|
this.cache = /* @__PURE__ */ new Map(), this.accessOrder = [], this.maxSize = e;
|
|
4708
4714
|
}
|
|
@@ -4739,12 +4745,12 @@ var ts = 16, ns = class {
|
|
|
4739
4745
|
e && e.dispose && e.dispose();
|
|
4740
4746
|
}), this.cache.clear(), this.accessOrder = [];
|
|
4741
4747
|
}
|
|
4742
|
-
},
|
|
4748
|
+
}, ds = class {
|
|
4743
4749
|
constructor(e = {}) {
|
|
4744
|
-
this.useWorkers = typeof Worker < "u", this.maxConcurrentWorkers = vr.MAX_CONCURRENT_WORKERS, this.activeWorkers = 0, this.canvasPool = new
|
|
4750
|
+
this.useWorkers = typeof Worker < "u", this.maxConcurrentWorkers = vr.MAX_CONCURRENT_WORKERS, this.activeWorkers = 0, this.canvasPool = new cs(), this.bufferPool = new ls({
|
|
4745
4751
|
maxMemory: e.maxBufferMemory || Sr.MAX_BUFFER_MEMORY,
|
|
4746
4752
|
sizeStrategy: e.bufferSizeStrategy || "adaptive"
|
|
4747
|
-
}), this.textureCache = new
|
|
4753
|
+
}), this.textureCache = new us(), this.capabilities = this.detectCapabilities(), this.optimalMethod = this.selectOptimalMethod();
|
|
4748
4754
|
}
|
|
4749
4755
|
detectCapabilities() {
|
|
4750
4756
|
return {
|
|
@@ -4801,10 +4807,10 @@ var ts = 16, ns = class {
|
|
|
4801
4807
|
try {
|
|
4802
4808
|
let t;
|
|
4803
4809
|
try {
|
|
4804
|
-
t = new Worker(
|
|
4810
|
+
t = new Worker(ss, { type: "module" });
|
|
4805
4811
|
} catch (e) {
|
|
4806
4812
|
if (e.name !== "SecurityError") throw e;
|
|
4807
|
-
t = await Nr(
|
|
4813
|
+
t = await Nr(ss);
|
|
4808
4814
|
}
|
|
4809
4815
|
let n = await this.prepareTexturesForWorkerDirect(e), r = await new Promise((e, r) => {
|
|
4810
4816
|
t.onmessage = (t) => {
|
|
@@ -5083,7 +5089,7 @@ var ts = 16, ns = class {
|
|
|
5083
5089
|
let l = performance.now();
|
|
5084
5090
|
try {
|
|
5085
5091
|
if (!t || t.length === 0) throw Error("No materials provided for texture creation");
|
|
5086
|
-
this.textureCache.dispose(), this.textureCache = new
|
|
5092
|
+
this.textureCache.dispose(), this.textureCache = new us();
|
|
5087
5093
|
let e = [];
|
|
5088
5094
|
n && n.length > 0 && e.push(this.createTexturesToDataTexture(n).then((e) => ({
|
|
5089
5095
|
type: "albedo",
|
|
@@ -5195,7 +5201,7 @@ var ts = 16, ns = class {
|
|
|
5195
5201
|
t.push(null), r.push({
|
|
5196
5202
|
index: i,
|
|
5197
5203
|
flipY: n.flipY,
|
|
5198
|
-
promise:
|
|
5204
|
+
promise: fs(e.data, e.width, e.height)
|
|
5199
5205
|
});
|
|
5200
5206
|
continue;
|
|
5201
5207
|
}
|
|
@@ -5208,7 +5214,7 @@ var ts = 16, ns = class {
|
|
|
5208
5214
|
t.push(null), r.push({
|
|
5209
5215
|
index: e,
|
|
5210
5216
|
flipY: n.flipY,
|
|
5211
|
-
promise:
|
|
5217
|
+
promise: fs(n.image.data, n.image.width, n.image.height)
|
|
5212
5218
|
});
|
|
5213
5219
|
continue;
|
|
5214
5220
|
}
|
|
@@ -5260,13 +5266,13 @@ var ts = 16, ns = class {
|
|
|
5260
5266
|
this.canvasPool.dispose(), this.bufferPool.dispose(), this.textureCache.dispose();
|
|
5261
5267
|
}
|
|
5262
5268
|
};
|
|
5263
|
-
function
|
|
5269
|
+
function fs(e, t, n) {
|
|
5264
5270
|
let r = new Uint8ClampedArray(e.buffer, e.byteOffset, e.byteLength);
|
|
5265
5271
|
return createImageBitmap(new ImageData(r, t, n));
|
|
5266
5272
|
}
|
|
5267
5273
|
//#endregion
|
|
5268
5274
|
//#region src/Processor/GeometryExtractor.js
|
|
5269
|
-
var
|
|
5275
|
+
var ps = 128, ms = class {
|
|
5270
5276
|
constructor() {
|
|
5271
5277
|
this._vectorPool = {
|
|
5272
5278
|
vec3: Array(9).fill().map(() => new nn()),
|
|
@@ -5495,7 +5501,7 @@ var ds = 128, fs = class {
|
|
|
5495
5501
|
n || (n = /* @__PURE__ */ new Map(), this._textureIndexCache.set(t, n));
|
|
5496
5502
|
let r = e.source.uuid, i = n.get(r);
|
|
5497
5503
|
if (i !== void 0) return i;
|
|
5498
|
-
if (t.length <
|
|
5504
|
+
if (t.length < ps) {
|
|
5499
5505
|
t.push(e);
|
|
5500
5506
|
let i = t.length - 1;
|
|
5501
5507
|
return n.set(r, i), i;
|
|
@@ -5588,7 +5594,7 @@ var ds = 128, fs = class {
|
|
|
5588
5594
|
sceneFeatures: this.sceneFeatures
|
|
5589
5595
|
};
|
|
5590
5596
|
}
|
|
5591
|
-
},
|
|
5597
|
+
}, hs = class {
|
|
5592
5598
|
constructor() {
|
|
5593
5599
|
this.maxLeafSize = 8;
|
|
5594
5600
|
}
|
|
@@ -5617,7 +5623,7 @@ var ds = 128, fs = class {
|
|
|
5617
5623
|
i[d + 7] = 1, i[d + 8] = t, i[d + 9] = T, i[d + 10] = 0, i[d + 11] = 0, E = null;
|
|
5618
5624
|
for (let i = t; i < r; i++) {
|
|
5619
5625
|
let t = e[n[i]];
|
|
5620
|
-
E =
|
|
5626
|
+
E = _s(E, gs(t)), o[i] = c;
|
|
5621
5627
|
}
|
|
5622
5628
|
E ||= {
|
|
5623
5629
|
ax: 0,
|
|
@@ -5635,7 +5641,7 @@ var ds = 128, fs = class {
|
|
|
5635
5641
|
][f], m = t + r >> 1;
|
|
5636
5642
|
this._nthElement(n, e, t, r, m, p), i[d + 7] = 0;
|
|
5637
5643
|
let h = s(t, m, c, l + 1), g = s(m, r, c + 2 ** l, l + 1);
|
|
5638
|
-
i[d + 8] = h.nodeIndex, i[d + 9] = g.nodeIndex, i[d + 10] = 0, i[d + 11] = 0, E =
|
|
5644
|
+
i[d + 8] = h.nodeIndex, i[d + 9] = g.nodeIndex, i[d + 10] = 0, i[d + 11] = 0, E = _s(h.cone, g.cone);
|
|
5639
5645
|
}
|
|
5640
5646
|
return i[d + 12] = E.ax, i[d + 13] = E.ay, i[d + 14] = E.az, i[d + 15] = E.cosO, {
|
|
5641
5647
|
nodeIndex: u,
|
|
@@ -5664,7 +5670,7 @@ var ds = 128, fs = class {
|
|
|
5664
5670
|
}
|
|
5665
5671
|
}
|
|
5666
5672
|
};
|
|
5667
|
-
function
|
|
5673
|
+
function gs(e) {
|
|
5668
5674
|
return e.twoSided ? {
|
|
5669
5675
|
ax: e.nx,
|
|
5670
5676
|
ay: e.ny,
|
|
@@ -5677,7 +5683,7 @@ function ms(e) {
|
|
|
5677
5683
|
cosO: 1
|
|
5678
5684
|
};
|
|
5679
5685
|
}
|
|
5680
|
-
function
|
|
5686
|
+
function _s(e, t) {
|
|
5681
5687
|
if (!e) return t;
|
|
5682
5688
|
if (!t || e.cosO <= -1) return e;
|
|
5683
5689
|
if (t.cosO <= -1) return t;
|
|
@@ -5709,7 +5715,7 @@ function hs(e, t) {
|
|
|
5709
5715
|
}
|
|
5710
5716
|
//#endregion
|
|
5711
5717
|
//#region src/Processor/EmissiveTriangleBuilder.js
|
|
5712
|
-
var
|
|
5718
|
+
var vs = class {
|
|
5713
5719
|
constructor() {
|
|
5714
5720
|
this.emissiveTriangles = [], this.emissiveCount = 0, this.totalEmissivePower = 0, this.emissiveIndicesArray = null, this.emissivePowerArray = null, this.cdfArray = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0, this.emissiveBitTrailMap = null, this._totalTriangleCount = 0;
|
|
5715
5721
|
}
|
|
@@ -5859,7 +5865,7 @@ var gs = class {
|
|
|
5859
5865
|
}
|
|
5860
5866
|
buildLightBVH() {
|
|
5861
5867
|
if (this.emissiveCount === 0) return this.lightBVHNodeData = new Float32Array(16), this.lightBVHNodeData[7] = 1, this.lightBVHNodeData[14] = 1, this.lightBVHNodeData[15] = -1, this.lightBVHNodeCount = 1, this.emissiveBitTrailMap = new Float32Array(Math.max(this._totalTriangleCount, 1)).fill(-1), 1;
|
|
5862
|
-
let { nodeData: e, nodeCount: t, sortedPerm: n, bitTrails: r } = new
|
|
5868
|
+
let { nodeData: e, nodeCount: t, sortedPerm: n, bitTrails: r } = new hs().build(this.emissiveTriangles);
|
|
5863
5869
|
this.lightBVHNodeData = e, this.lightBVHNodeCount = t, this._rebuildSortedEmissiveData(n), this.emissiveBitTrailMap = new Float32Array(Math.max(this._totalTriangleCount, 1)).fill(-1);
|
|
5864
5870
|
for (let e = 0; e < n.length; e++) {
|
|
5865
5871
|
let t = this.emissiveTriangles[n[e]].triangleIndex;
|
|
@@ -5885,7 +5891,7 @@ var gs = class {
|
|
|
5885
5891
|
clear() {
|
|
5886
5892
|
this.emissiveTriangles = [], this.emissiveCount = 0, this.totalEmissivePower = 0, this.emissiveIndicesArray = null, this.emissivePowerArray = null, this.cdfArray = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0, this.emissiveBitTrailMap = null, this._totalTriangleCount = 0;
|
|
5887
5893
|
}
|
|
5888
|
-
},
|
|
5894
|
+
}, ys = class {
|
|
5889
5895
|
constructor(e = "Build") {
|
|
5890
5896
|
this.label = e, this.entries = /* @__PURE__ */ new Map(), this.order = [], this.totalStart = performance.now();
|
|
5891
5897
|
}
|
|
@@ -5912,7 +5918,7 @@ var gs = class {
|
|
|
5912
5918
|
total: Math.round(e)
|
|
5913
5919
|
};
|
|
5914
5920
|
}
|
|
5915
|
-
},
|
|
5921
|
+
}, bs = "" + new URL("assets/BVHRefitWorker-GkmNJYvb.js", import.meta.url).href, xs = class {
|
|
5916
5922
|
constructor(e = {}) {
|
|
5917
5923
|
this.config = {
|
|
5918
5924
|
useWorkers: !0,
|
|
@@ -5935,12 +5941,12 @@ var gs = class {
|
|
|
5935
5941
|
};
|
|
5936
5942
|
}
|
|
5937
5943
|
_initProcessors() {
|
|
5938
|
-
this.geometryExtractor = new
|
|
5944
|
+
this.geometryExtractor = new ms(), this.bvhBuilder = new Ho(), this.bvhBuilder.maxLeafSize = this.config.maxLeafSize, this.bvhBuilder.setTreeletConfig({
|
|
5939
5945
|
enabled: this.config.enableTreeletOptimization,
|
|
5940
5946
|
size: this.config.treeletSize,
|
|
5941
5947
|
passes: this.config.treeletOptimizationPasses,
|
|
5942
5948
|
minImprovement: this.config.treeletMinImprovement
|
|
5943
|
-
}), this.textureCreator = new
|
|
5949
|
+
}), this.textureCreator = new ds(), this.emissiveTriangleBuilder = new vs(), this.tlasBuilder = new as();
|
|
5944
5950
|
}
|
|
5945
5951
|
_log(e, t) {
|
|
5946
5952
|
this.config.verbose && console.log(`[SceneProcessor] ${e}`, t || "");
|
|
@@ -5948,7 +5954,7 @@ var gs = class {
|
|
|
5948
5954
|
async buildBVH(e) {
|
|
5949
5955
|
if (this.isProcessing) throw Error("Already processing a scene. Call dispose() first.");
|
|
5950
5956
|
this.isProcessing = !0, this.processingStage = "init";
|
|
5951
|
-
let t = new
|
|
5957
|
+
let t = new ys(`SceneProcessor (${e.name || "scene"})`);
|
|
5952
5958
|
try {
|
|
5953
5959
|
this._reset(), this._log("Starting scene processing"), this.processingStage = "extraction", t.start("Geometry extraction"), await this._extractGeometry(e), t.end("Geometry extraction"), this.performanceMetrics.geometryExtractionTime = t.getDuration("Geometry extraction"), this.processingStage = "bvh", t.start("BVH construction (worker)"), t.start("Material textures (parallel)");
|
|
5954
5960
|
let n = !1, r = this._buildBVH().then(() => t.end("BVH construction (worker)")), i = this._createMaterialTextures().then(() => {
|
|
@@ -6009,11 +6015,11 @@ var gs = class {
|
|
|
6009
6015
|
try {
|
|
6010
6016
|
let t = Z.FLOATS_PER_TRIANGLE, n = this.meshTriangleRanges;
|
|
6011
6017
|
if (!n || n.length === 0) throw Error("No mesh triangle ranges available for TLAS/BLAS build");
|
|
6012
|
-
this.instanceTable = new
|
|
6018
|
+
this.instanceTable = new os(), this.instanceTable.allocate(n.length);
|
|
6013
6019
|
let r = n.length, i = this.config.enableTreeletOptimization, a = [], o = [];
|
|
6014
6020
|
for (let e = 0; e < r; e++) {
|
|
6015
6021
|
let t = n[e];
|
|
6016
|
-
t.count !== 0 && (t.count >= 2e5 &&
|
|
6022
|
+
t.count !== 0 && (t.count >= 2e5 && ns(t.count) ? o.push({
|
|
6017
6023
|
m: e,
|
|
6018
6024
|
range: t
|
|
6019
6025
|
}) : a.push({
|
|
@@ -6039,7 +6045,7 @@ var gs = class {
|
|
|
6039
6045
|
status: `Building BLAS ${e + o.length}/${c}...`,
|
|
6040
6046
|
progress: 25 + Math.floor(e / c * 45)
|
|
6041
6047
|
});
|
|
6042
|
-
}), u = o.map(({ m: e, range: n }) =>
|
|
6048
|
+
}), u = o.map(({ m: e, range: n }) => $o(this.triangleData.slice(n.start * t, (n.start + n.count) * t), this.config.bvhDepth, null, {
|
|
6043
6049
|
maxLeafSize: this.bvhBuilder.maxLeafSize,
|
|
6044
6050
|
numBins: this.bvhBuilder.numBins,
|
|
6045
6051
|
maxBins: this.bvhBuilder.maxBins,
|
|
@@ -6145,13 +6151,13 @@ var gs = class {
|
|
|
6145
6151
|
for (let e = 0; e < i; e++) {
|
|
6146
6152
|
let e;
|
|
6147
6153
|
try {
|
|
6148
|
-
e = new Worker(
|
|
6154
|
+
e = new Worker(Ro, { type: "module" });
|
|
6149
6155
|
} catch (t) {
|
|
6150
6156
|
if (t.name !== "SecurityError") {
|
|
6151
6157
|
l(t);
|
|
6152
6158
|
return;
|
|
6153
6159
|
}
|
|
6154
|
-
e = await Nr(
|
|
6160
|
+
e = await Nr(Ro);
|
|
6155
6161
|
}
|
|
6156
6162
|
e.onmessage = (t) => f(e, t), e.onerror = (e) => {
|
|
6157
6163
|
u.forEach((e) => e.terminate()), l(e);
|
|
@@ -6324,10 +6330,10 @@ var gs = class {
|
|
|
6324
6330
|
async refitBVH(e, t) {
|
|
6325
6331
|
if (!this.bvhData || !this.triangleData || !this.originalToBvhMap) throw Error("No BVH data available for refit. Run buildBVH() first.");
|
|
6326
6332
|
if (!this._refitWorker) try {
|
|
6327
|
-
this._refitWorker = new Worker(
|
|
6333
|
+
this._refitWorker = new Worker(bs, { type: "module" });
|
|
6328
6334
|
} catch (e) {
|
|
6329
6335
|
if (e.name !== "SecurityError") throw e;
|
|
6330
|
-
this._refitWorker = await Nr(
|
|
6336
|
+
this._refitWorker = await Nr(bs);
|
|
6331
6337
|
}
|
|
6332
6338
|
if (!this._refitSharedBuffers) {
|
|
6333
6339
|
let t = new SharedArrayBuffer(this.bvhData.byteLength), n = new SharedArrayBuffer(this.triangleData.byteLength), r = new SharedArrayBuffer(e.byteLength), i = new Float32Array(t), a = new Float32Array(n);
|
|
@@ -6360,7 +6366,7 @@ var gs = class {
|
|
|
6360
6366
|
refitBLASes(e, t, n) {
|
|
6361
6367
|
if (!this.instanceTable || !this.bvhData || !this.triangleData) throw Error("No TLAS/BLAS data available. Run buildBVH() first.");
|
|
6362
6368
|
let r = performance.now();
|
|
6363
|
-
this._blasRefitter ||= new
|
|
6369
|
+
this._blasRefitter ||= new Jo();
|
|
6364
6370
|
for (let r of e) {
|
|
6365
6371
|
let e = this.instanceTable.entries[r];
|
|
6366
6372
|
e && (this._updateMeshTrianglePositions(e, t), n && this._patchMeshSmoothNormals(e, n), this._blasRefitter.refitRange(this.bvhData, this.triangleData, e.blasOffset, e.blasNodeCount), this.instanceTable.recomputeAABB(r, this.bvhData, this.triangleData));
|
|
@@ -6494,10 +6500,10 @@ var gs = class {
|
|
|
6494
6500
|
n && n.terminate();
|
|
6495
6501
|
let r;
|
|
6496
6502
|
try {
|
|
6497
|
-
r = new Worker(
|
|
6503
|
+
r = new Worker(Ro, { type: "module" }), i(t, e, r);
|
|
6498
6504
|
} catch (n) {
|
|
6499
6505
|
if (n.name !== "SecurityError") throw n;
|
|
6500
|
-
Nr(
|
|
6506
|
+
Nr(Ro).then((n) => i(t, e, n));
|
|
6501
6507
|
}
|
|
6502
6508
|
}
|
|
6503
6509
|
}
|
|
@@ -6530,7 +6536,153 @@ var gs = class {
|
|
|
6530
6536
|
dispose() {
|
|
6531
6537
|
this._log("Disposing resources"), this._disposeRefitWorker(), this._disposeTextures(), this._reset(), this.textureCreator &&= (this.textureCreator.dispose(), null), this.geometryExtractor = null, this.bvhBuilder = null, this.tlasBuilder = null, this._blasRefitter = null;
|
|
6532
6538
|
}
|
|
6533
|
-
},
|
|
6539
|
+
}, Ss = [
|
|
6540
|
+
[
|
|
6541
|
+
1619.19106,
|
|
6542
|
+
-.00205010916,
|
|
6543
|
+
5.02995757
|
|
6544
|
+
],
|
|
6545
|
+
[
|
|
6546
|
+
2488.45471,
|
|
6547
|
+
-.00111330907,
|
|
6548
|
+
3.22621544
|
|
6549
|
+
],
|
|
6550
|
+
[
|
|
6551
|
+
3341.43193,
|
|
6552
|
+
-.000486551192,
|
|
6553
|
+
1.76486769
|
|
6554
|
+
],
|
|
6555
|
+
[
|
|
6556
|
+
4094.61742,
|
|
6557
|
+
-.000127446582,
|
|
6558
|
+
.725731635
|
|
6559
|
+
],
|
|
6560
|
+
[
|
|
6561
|
+
4670.28036,
|
|
6562
|
+
291258199e-13,
|
|
6563
|
+
.126703442
|
|
6564
|
+
],
|
|
6565
|
+
[
|
|
6566
|
+
4595.09185,
|
|
6567
|
+
287495649e-13,
|
|
6568
|
+
.15034502
|
|
6569
|
+
],
|
|
6570
|
+
[
|
|
6571
|
+
3787.1745,
|
|
6572
|
+
935907826e-14,
|
|
6573
|
+
.399075871
|
|
6574
|
+
]
|
|
6575
|
+
], Cs = [
|
|
6576
|
+
[
|
|
6577
|
+
-488.999748,
|
|
6578
|
+
.000604330754,
|
|
6579
|
+
-.0755807526
|
|
6580
|
+
],
|
|
6581
|
+
[
|
|
6582
|
+
-755.994277,
|
|
6583
|
+
.000316730098,
|
|
6584
|
+
.478306139
|
|
6585
|
+
],
|
|
6586
|
+
[
|
|
6587
|
+
-1023.63977,
|
|
6588
|
+
.00012022347,
|
|
6589
|
+
.936662319
|
|
6590
|
+
],
|
|
6591
|
+
[
|
|
6592
|
+
-1265.71316,
|
|
6593
|
+
487340896e-14,
|
|
6594
|
+
1.27054498
|
|
6595
|
+
],
|
|
6596
|
+
[
|
|
6597
|
+
-1425.29332,
|
|
6598
|
+
-401150431e-13,
|
|
6599
|
+
1.43972784
|
|
6600
|
+
],
|
|
6601
|
+
[
|
|
6602
|
+
-1175.54822,
|
|
6603
|
+
-216378048e-13,
|
|
6604
|
+
1.30408023
|
|
6605
|
+
],
|
|
6606
|
+
[
|
|
6607
|
+
-500.799571,
|
|
6608
|
+
-459832026e-14,
|
|
6609
|
+
1.09098763
|
|
6610
|
+
]
|
|
6611
|
+
], ws = [
|
|
6612
|
+
[
|
|
6613
|
+
596945309e-19,
|
|
6614
|
+
-4.85742887e-8,
|
|
6615
|
+
-970622247e-13,
|
|
6616
|
+
-.00407936148
|
|
6617
|
+
],
|
|
6618
|
+
[
|
|
6619
|
+
240430366e-19,
|
|
6620
|
+
5.55021075e-8,
|
|
6621
|
+
-.000198503712,
|
|
6622
|
+
.0289312858
|
|
6623
|
+
],
|
|
6624
|
+
[
|
|
6625
|
+
-140949732e-19,
|
|
6626
|
+
1.89878968e-7,
|
|
6627
|
+
-.000356632824,
|
|
6628
|
+
.0910767778
|
|
6629
|
+
],
|
|
6630
|
+
[
|
|
6631
|
+
-361460868e-19,
|
|
6632
|
+
2.84822009e-7,
|
|
6633
|
+
-.000493211319,
|
|
6634
|
+
.15672344
|
|
6635
|
+
],
|
|
6636
|
+
[
|
|
6637
|
+
-197075738e-19,
|
|
6638
|
+
1.75359352e-7,
|
|
6639
|
+
-.000250542825,
|
|
6640
|
+
-.0222783266
|
|
6641
|
+
],
|
|
6642
|
+
[
|
|
6643
|
+
-161997957e-21,
|
|
6644
|
+
-1.64216008e-8,
|
|
6645
|
+
.000386216271,
|
|
6646
|
+
-.738077418
|
|
6647
|
+
],
|
|
6648
|
+
[
|
|
6649
|
+
672650283e-21,
|
|
6650
|
+
-2.73078809e-8,
|
|
6651
|
+
.000424098264,
|
|
6652
|
+
-.752335691
|
|
6653
|
+
]
|
|
6654
|
+
];
|
|
6655
|
+
function Ts(e) {
|
|
6656
|
+
let t, n, r;
|
|
6657
|
+
if (e >= 12e3) t = .8262954810464208, n = .9945080501520986, r = 1.566307710274283;
|
|
6658
|
+
else if (e < 800) t = 5.413294490189271, n = -.20319390035873933, r = -.0822535242887164;
|
|
6659
|
+
else {
|
|
6660
|
+
let i = e >= 6365 ? 6 : e >= 3315 ? 5 : e >= 1902 ? 4 : e >= 1449 ? 3 : e >= 1167 ? 2 : +(e >= 965), a = Ss[i], o = Cs[i], s = ws[i], c = 1 / e;
|
|
6661
|
+
t = a[0] * c + a[1] * e + a[2], n = o[0] * c + o[1] * e + o[2], r = ((s[0] * e + s[1]) * e + s[2]) * e + s[3];
|
|
6662
|
+
}
|
|
6663
|
+
return [
|
|
6664
|
+
Math.max(0, t),
|
|
6665
|
+
Math.max(0, n),
|
|
6666
|
+
Math.max(0, r)
|
|
6667
|
+
];
|
|
6668
|
+
}
|
|
6669
|
+
//#endregion
|
|
6670
|
+
//#region src/Processor/LightSerializer.js
|
|
6671
|
+
var Es = 1 / (4 * Math.PI);
|
|
6672
|
+
function Ds(e) {
|
|
6673
|
+
let t = e.userData || {}, n = Number.isFinite(t.exposure) ? t.exposure : 0, r = e.intensity * 2 ** n, i = e.color.r, a = e.color.g, o = e.color.b;
|
|
6674
|
+
if (t.useTemperature) {
|
|
6675
|
+
let [e, n, r] = Ts(t.temperature ?? 6500);
|
|
6676
|
+
i *= e, a *= n, o *= r;
|
|
6677
|
+
}
|
|
6678
|
+
return {
|
|
6679
|
+
r: i,
|
|
6680
|
+
g: a,
|
|
6681
|
+
b: o,
|
|
6682
|
+
intensity: r
|
|
6683
|
+
};
|
|
6684
|
+
}
|
|
6685
|
+
var Os = class {
|
|
6534
6686
|
constructor() {
|
|
6535
6687
|
this.lightData = {
|
|
6536
6688
|
directional: [],
|
|
@@ -6563,20 +6715,20 @@ var gs = class {
|
|
|
6563
6715
|
let r = e.target.getWorldPosition(new nn());
|
|
6564
6716
|
n = t.sub(r).normalize();
|
|
6565
6717
|
} else n = t.normalize();
|
|
6566
|
-
let r = this.calculateLightImportance(e, "directional"), i = e.userData.angle || e.angle || 0, a = e.userData?.gobo,
|
|
6718
|
+
let r = this.calculateLightImportance(e, "directional"), i = e.userData.angle || e.angle || 0, a = Ds(e), o = e.userData?.gobo, s = o && Number.isInteger(o.index) ? o.index : -1, c = o && typeof o.intensity == "number" ? o.intensity : 1, l = o && o.inverted ? -Math.abs(c) : Math.abs(c), u = o && typeof o.scale == "number" ? o.scale : 5;
|
|
6567
6719
|
this.directionalLightCache.push({
|
|
6568
6720
|
data: [
|
|
6569
6721
|
n.x,
|
|
6570
6722
|
n.y,
|
|
6571
6723
|
n.z,
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6724
|
+
a.r,
|
|
6725
|
+
a.g,
|
|
6726
|
+
a.b,
|
|
6727
|
+
a.intensity,
|
|
6576
6728
|
i,
|
|
6577
|
-
|
|
6578
|
-
c,
|
|
6729
|
+
s,
|
|
6579
6730
|
l,
|
|
6731
|
+
u,
|
|
6580
6732
|
0
|
|
6581
6733
|
],
|
|
6582
6734
|
importance: r,
|
|
@@ -6586,7 +6738,7 @@ var gs = class {
|
|
|
6586
6738
|
addRectAreaLight(e) {
|
|
6587
6739
|
if (e.intensity <= 0) return;
|
|
6588
6740
|
e.updateMatrixWorld();
|
|
6589
|
-
let t = e.getWorldPosition(new nn()), n = e.getWorldQuaternion(new Pt()), r = e.getWorldScale(new nn()), i = e.width * r.x * .5, a = e.height * r.y * .5, o = new nn(i, 0, 0).applyQuaternion(n), s = new nn(0, -a, 0).applyQuaternion(n), c = this.calculateLightImportance(e, "area");
|
|
6741
|
+
let t = e.getWorldPosition(new nn()), n = e.getWorldQuaternion(new Pt()), r = e.getWorldScale(new nn()), i = e.width * r.x * .5, a = e.height * r.y * .5, o = new nn(i, 0, 0).applyQuaternion(n), s = new nn(0, -a, 0).applyQuaternion(n), c = this.calculateLightImportance(e, "area"), l = e.userData?.normalize ?? !0 ? 1 : 0, u = Number.isFinite(e.userData?.spread) ? e.userData.spread : Math.PI, d = +(e.userData?.shape === "ellipse" || e.userData?.shape === "disk" || e.userData?.shape === 1), f = Ds(e);
|
|
6590
6742
|
this.areaLightCache.push({
|
|
6591
6743
|
data: [
|
|
6592
6744
|
t.x,
|
|
@@ -6598,10 +6750,13 @@ var gs = class {
|
|
|
6598
6750
|
s.x,
|
|
6599
6751
|
s.y,
|
|
6600
6752
|
s.z,
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6753
|
+
f.r,
|
|
6754
|
+
f.g,
|
|
6755
|
+
f.b,
|
|
6756
|
+
f.intensity,
|
|
6757
|
+
l,
|
|
6758
|
+
u,
|
|
6759
|
+
d
|
|
6605
6760
|
],
|
|
6606
6761
|
importance: c,
|
|
6607
6762
|
light: e
|
|
@@ -6610,16 +6765,16 @@ var gs = class {
|
|
|
6610
6765
|
addPointLight(e) {
|
|
6611
6766
|
if (e.intensity <= 0) return;
|
|
6612
6767
|
e.updateMatrixWorld();
|
|
6613
|
-
let t = e.getWorldPosition(new nn()), n = this.calculateLightImportance(e, "point");
|
|
6768
|
+
let t = e.getWorldPosition(new nn()), n = this.calculateLightImportance(e, "point"), r = Ds(e);
|
|
6614
6769
|
this.pointLightCache.push({
|
|
6615
6770
|
data: [
|
|
6616
6771
|
t.x,
|
|
6617
6772
|
t.y,
|
|
6618
6773
|
t.z,
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6774
|
+
r.r,
|
|
6775
|
+
r.g,
|
|
6776
|
+
r.b,
|
|
6777
|
+
r.intensity * Es,
|
|
6623
6778
|
e.distance || 0,
|
|
6624
6779
|
e.decay === void 0 ? 2 : e.decay
|
|
6625
6780
|
],
|
|
@@ -6630,7 +6785,7 @@ var gs = class {
|
|
|
6630
6785
|
addSpotLight(e) {
|
|
6631
6786
|
if (e.intensity <= 0) return;
|
|
6632
6787
|
e.updateMatrixWorld();
|
|
6633
|
-
let t = e.getWorldPosition(new nn()), n = (e.target ? e.target.getWorldPosition(new nn()) : new nn(0, 0, -1)).sub(t).normalize(), r = this.calculateLightImportance(e, "spot"), i = e.userData?.gobo, a = i && Number.isInteger(i.index) ? i.index : -1, o = i && typeof i.intensity == "number" ? i.intensity : 1, s = i && i.inverted ? -Math.abs(o) : Math.abs(o), c = e.userData?.ies, l = c && Number.isInteger(c.index) ? c.index : -1, u = c && typeof c.intensity == "number" ? c.intensity : 1;
|
|
6788
|
+
let t = e.getWorldPosition(new nn()), n = (e.target ? e.target.getWorldPosition(new nn()) : new nn(0, 0, -1)).sub(t).normalize(), r = this.calculateLightImportance(e, "spot"), i = e.userData?.gobo, a = i && Number.isInteger(i.index) ? i.index : -1, o = i && typeof i.intensity == "number" ? i.intensity : 1, s = i && i.inverted ? -Math.abs(o) : Math.abs(o), c = e.userData?.ies, l = c && Number.isInteger(c.index) ? c.index : -1, u = c && typeof c.intensity == "number" ? c.intensity : 1, d = Ds(e);
|
|
6634
6789
|
this.spotLightCache.push({
|
|
6635
6790
|
data: [
|
|
6636
6791
|
t.x,
|
|
@@ -6639,10 +6794,10 @@ var gs = class {
|
|
|
6639
6794
|
n.x,
|
|
6640
6795
|
n.y,
|
|
6641
6796
|
n.z,
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6797
|
+
d.r,
|
|
6798
|
+
d.g,
|
|
6799
|
+
d.b,
|
|
6800
|
+
d.intensity * Es,
|
|
6646
6801
|
e.angle || Math.PI / 4,
|
|
6647
6802
|
e.penumbra || 0,
|
|
6648
6803
|
e.distance || 0,
|
|
@@ -6670,7 +6825,7 @@ var gs = class {
|
|
|
6670
6825
|
}), this.areaLightCache.length > 0 && console.log(`Preprocessed ${this.areaLightCache.length} area lights by importance`), this.pointLightCache.length > 0 && console.log(`Preprocessed ${this.pointLightCache.length} point lights by importance`), this.spotLightCache.length > 0 && console.log(`Preprocessed ${this.spotLightCache.length} spot lights by importance`);
|
|
6671
6826
|
}
|
|
6672
6827
|
updateShaderUniforms(e) {
|
|
6673
|
-
let t = Math.floor(this.lightData.directional.length / 12), n = Math.floor(this.lightData.rectArea.length /
|
|
6828
|
+
let t = Math.floor(this.lightData.directional.length / 12), n = Math.floor(this.lightData.rectArea.length / 16), r = Math.floor(this.lightData.point.length / 9), i = Math.floor(this.lightData.spot.length / 20);
|
|
6674
6829
|
e.defines.MAX_DIRECTIONAL_LIGHTS = t, e.defines.MAX_AREA_LIGHTS = n, e.defines.MAX_POINT_LIGHTS = r, e.defines.MAX_SPOT_LIGHTS = i, e.uniforms.directionalLights.value = new Float32Array(this.lightData.directional), e.uniforms.areaLights.value = new Float32Array(this.lightData.rectArea), e.uniforms.pointLights.value = new Float32Array(this.lightData.point), e.uniforms.spotLights.value = new Float32Array(this.lightData.spot), e.needsUpdate = !0;
|
|
6675
6830
|
}
|
|
6676
6831
|
processSceneLights(e, t) {
|
|
@@ -6693,7 +6848,7 @@ var gs = class {
|
|
|
6693
6848
|
}))
|
|
6694
6849
|
};
|
|
6695
6850
|
}
|
|
6696
|
-
},
|
|
6851
|
+
}, ks = {
|
|
6697
6852
|
stbnScalarAtlas: "https://assets.rayzee.atulmourya.com/noise/stbn_scalar_atlas.png",
|
|
6698
6853
|
stbnVec2Atlas: "https://assets.rayzee.atulmourya.com/noise/stbn_vec2_atlas.png",
|
|
6699
6854
|
ortRuntimeUrl: "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/ort.webgpu.bundle.min.mjs",
|
|
@@ -6704,27 +6859,27 @@ var gs = class {
|
|
|
6704
6859
|
upscalerModelBaseUrl: "https://huggingface.co/notaneimu/onnx-image-models/resolve/main/",
|
|
6705
6860
|
cacheNamespace: "rayzee"
|
|
6706
6861
|
};
|
|
6707
|
-
function
|
|
6708
|
-
e && Object.assign(
|
|
6862
|
+
function As(e) {
|
|
6863
|
+
e && Object.assign(ks, e);
|
|
6709
6864
|
}
|
|
6710
|
-
function
|
|
6711
|
-
return { ...
|
|
6865
|
+
function js() {
|
|
6866
|
+
return { ...ks };
|
|
6712
6867
|
}
|
|
6713
6868
|
//#endregion
|
|
6714
6869
|
//#region src/Stages/PathTracerStage.js
|
|
6715
|
-
var
|
|
6870
|
+
var Ms = 4, Ns = class extends qn {
|
|
6716
6871
|
constructor(e, t, n, r = {}) {
|
|
6717
6872
|
super("PathTracer", {
|
|
6718
6873
|
...r,
|
|
6719
6874
|
executionMode: Kn.ALWAYS
|
|
6720
6875
|
});
|
|
6721
6876
|
let i = r.width || 1920, a = r.height || 1080;
|
|
6722
|
-
this.camera = n, this.width = i, this.height = a, this.renderer = e, this.scene = t, this.sdfs = new
|
|
6877
|
+
this.camera = n, this.width = i, this.height = a, this.renderer = e, this.scene = t, this.sdfs = new xs(), this.lightSerializer = new Os(), this.accumulationEnabled = !0, this.isComplete = !1, this.cameras = [], this.performanceMonitor = cr(), this.completionThreshold = 0, this.renderLimitMode = "frames", this._initDataTextures(), this.storageTextures = new wr(0, 0), this.uniforms = new Er(i, a), this._defineUniformGetters(), this.materialData = new Mr(this.sdfs), this.materialData.callbacks.onReset = () => this.reset(), this.materialData.callbacks.getTriangleData = () => ({
|
|
6723
6878
|
array: this.triangleStorageAttr?.array,
|
|
6724
6879
|
count: this.triangleCount
|
|
6725
6880
|
}), this.materialData.callbacks.onTriangleDataChanged = () => {
|
|
6726
6881
|
this.triangleStorageAttr && (this.triangleStorageAttr.needsUpdate = !0);
|
|
6727
|
-
}, this.environment = new li(this.scene, this.uniforms), this.environment.callbacks.onReset = () => this.reset(), this.environment.callbacks.getSceneTextureNodes = () => this.shaderBuilder.getSceneTextureNodes(), this.shaderBuilder = new
|
|
6882
|
+
}, this.environment = new li(this.scene, this.uniforms), this.environment.callbacks.onReset = () => this.reset(), this.environment.callbacks.getSceneTextureNodes = () => this.shaderBuilder.getSceneTextureNodes(), this.shaderBuilder = new Po(), this._initRenderingState(), this.setupBlueNoise(), this.tempVector2 = new tn(), this.lastCameraMatrix = new yt(), this.lastProjectionMatrix = new yt(), this.lastRenderMode = -1, this.renderModeChangeTimeout = null, this.renderModeChangeDelay = 50, this.pendingRenderMode = null, this.lastInteractionModeState = !1, this.cameraChanged = !1, this.updateCompletionThreshold();
|
|
6728
6883
|
}
|
|
6729
6884
|
_initDataTextures() {
|
|
6730
6885
|
this.triangleStorageAttr = null, this.triangleStorageNode = null, this.triangleCount = 0, this.bvhStorageAttr = null, this.bvhStorageNode = null, this.bvhNodeCount = 0, this.directionalLightsData = null, this.pointLightsData = null, this.spotLightsData = null, this.areaLightsData = null, this.goboMaps = null, this.iesProfiles = null, this.stbnScalarTexture = null, this.stbnVec2Texture = null, this.lightStorageAttr = new o(new Float32Array(16), 4), this.lightStorageNode = Ce(this.lightStorageAttr, "vec4", 1).toReadOnly(), this._lbvhDataCache = null, this._emissiveDataCache = null, this._bitTrailMapCache = null, this._instanceTable = null, this.spheres = [];
|
|
@@ -6803,7 +6958,7 @@ var ws = 4, Ts = class extends qn {
|
|
|
6803
6958
|
setupBlueNoise() {
|
|
6804
6959
|
let e = new Xt();
|
|
6805
6960
|
e.setCrossOrigin("anonymous");
|
|
6806
|
-
let t = (e) => (e.minFilter = wt, e.magFilter = wt, e.wrapS = Ht, e.wrapT = Ht, e.generateMipmaps = !1, e), { stbnScalarAtlas: n, stbnVec2Atlas: r } =
|
|
6961
|
+
let t = (e) => (e.minFilter = wt, e.magFilter = wt, e.wrapS = Ht, e.wrapT = Ht, e.generateMipmaps = !1, e), { stbnScalarAtlas: n, stbnVec2Atlas: r } = js();
|
|
6807
6962
|
e.load(n, (e) => {
|
|
6808
6963
|
this.stbnScalarTexture = t(e), kn.value = e, console.log(`PathTracer: STBN scalar atlas loaded ${e.image.width}x${e.image.height}`);
|
|
6809
6964
|
}), e.load(r, (e) => {
|
|
@@ -6855,7 +7010,7 @@ var ws = 4, Ts = class extends qn {
|
|
|
6855
7010
|
this._updateLightBufferNodes();
|
|
6856
7011
|
}
|
|
6857
7012
|
_updateLightBufferNodes() {
|
|
6858
|
-
this.directionalLightsData && this.directionalLightsData.length > 0 ? (this.directionalLightsBufferNode.array = Array.from(this.directionalLightsData), this.numDirectionalLights.value = Math.floor(this.directionalLightsData.length / 12)) : this.numDirectionalLights.value = 0, this.areaLightsData && this.areaLightsData.length > 0 ? (this.areaLightsBufferNode.array = Array.from(this.areaLightsData), this.numAreaLights.value = Math.floor(this.areaLightsData.length /
|
|
7013
|
+
this.directionalLightsData && this.directionalLightsData.length > 0 ? (this.directionalLightsBufferNode.array = Array.from(this.directionalLightsData), this.numDirectionalLights.value = Math.floor(this.directionalLightsData.length / 12)) : this.numDirectionalLights.value = 0, this.areaLightsData && this.areaLightsData.length > 0 ? (this.areaLightsBufferNode.array = Array.from(this.areaLightsData), this.numAreaLights.value = Math.floor(this.areaLightsData.length / 16)) : this.numAreaLights.value = 0, this.pointLightsData && this.pointLightsData.length > 0 ? (this.pointLightsBufferNode.array = Array.from(this.pointLightsData), this.numPointLights.value = Math.floor(this.pointLightsData.length / 9)) : this.numPointLights.value = 0, this.spotLightsData && this.spotLightsData.length > 0 ? (this.spotLightsBufferNode.array = Array.from(this.spotLightsData), this.numSpotLights.value = Math.floor(this.spotLightsData.length / 20)) : this.numSpotLights.value = 0;
|
|
6859
7014
|
}
|
|
6860
7015
|
reset() {
|
|
6861
7016
|
this.frameCount = 0, this.frame.value = 0, this.hasPreviousAccumulated.value = 0, this.storageTextures.currentTarget = 0, this.updateCompletionThreshold(), this.isComplete = !1, this.performanceMonitor?.reset(), this.lastRenderMode = -1, this.lastInteractionModeState = !1;
|
|
@@ -6883,7 +7038,7 @@ var ws = 4, Ts = class extends qn {
|
|
|
6883
7038
|
setBVHData(e) {
|
|
6884
7039
|
if (!e) return;
|
|
6885
7040
|
let t = e.length / 4;
|
|
6886
|
-
this.bvhStorageNode ? (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode.value = this.bvhStorageAttr, this.bvhStorageNode.bufferCount = t) : (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode = Ce(this.bvhStorageAttr, "vec4", t).toReadOnly()), this.bvhNodeCount = Math.floor(t /
|
|
7041
|
+
this.bvhStorageNode ? (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode.value = this.bvhStorageAttr, this.bvhStorageNode.bufferCount = t) : (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode = Ce(this.bvhStorageAttr, "vec4", t).toReadOnly()), this.bvhNodeCount = Math.floor(t / Ms), console.log(`PathTracer: ${this.bvhNodeCount} BVH nodes (storage buffer)`);
|
|
6887
7042
|
}
|
|
6888
7043
|
setInstanceTable(e) {
|
|
6889
7044
|
this._instanceTable = e;
|
|
@@ -7048,7 +7203,7 @@ var ws = 4, Ts = class extends qn {
|
|
|
7048
7203
|
dispose() {
|
|
7049
7204
|
this.renderModeChangeTimeout &&= (clearTimeout(this.renderModeChangeTimeout), null), this.cameraOptimizer?.dispose(), this.materialData?.dispose(), this.environment?.dispose(), this.shaderBuilder?.dispose(), this.uniforms?.dispose(), this.storageTextures?.dispose(), this.stbnScalarTexture?.dispose(), this.stbnVec2Texture?.dispose(), this.placeholderTexture?.dispose(), this.triangleStorageAttr = null, this.triangleStorageNode = null, this.bvhStorageAttr = null, this.bvhStorageNode = null, this.placeholderTexture = null, this.isReady = !1;
|
|
7050
7205
|
}
|
|
7051
|
-
},
|
|
7206
|
+
}, Ps = {
|
|
7052
7207
|
ORIGIN_META: 0,
|
|
7053
7208
|
DIR_FLAGS: 1,
|
|
7054
7209
|
THROUGHPUT_PDF: 2,
|
|
@@ -7056,10 +7211,10 @@ var ws = 4, Ts = class extends qn {
|
|
|
7056
7211
|
MEDIUM_STACK: 4,
|
|
7057
7212
|
MEDIUM_SIGMA_A: 5,
|
|
7058
7213
|
SSS_SIGMA_S: 6
|
|
7059
|
-
},
|
|
7214
|
+
}, Fs = {
|
|
7060
7215
|
DIST_TRI_BARY: 0,
|
|
7061
7216
|
NORMAL_MAT: 1
|
|
7062
|
-
},
|
|
7217
|
+
}, Is = 0, Ls = (e, t) => t === 0 ? e : e.add(t * Is), Rs = class {
|
|
7063
7218
|
static requiredCapacity(e) {
|
|
7064
7219
|
return Math.ceil(e * 1.25);
|
|
7065
7220
|
}
|
|
@@ -7069,7 +7224,7 @@ var ws = 4, Ts = class extends qn {
|
|
|
7069
7224
|
allocate(e) {
|
|
7070
7225
|
this.dispose();
|
|
7071
7226
|
let t = Math.ceil(e * 1.25);
|
|
7072
|
-
this.capacity = t,
|
|
7227
|
+
this.capacity = t, Is = t;
|
|
7073
7228
|
let n = t * 7, r = new o(new Float32Array(n * 4), 4);
|
|
7074
7229
|
this._attrs.ray = r, this.rayBuffer = {
|
|
7075
7230
|
rw: Ce(r, "vec4"),
|
|
@@ -7094,13 +7249,13 @@ var ws = 4, Ts = class extends qn {
|
|
|
7094
7249
|
dispose() {
|
|
7095
7250
|
this._attrs = {}, this.rayBuffer = null, this.rngBuffer = null, this.hitBuffer = null, this.capacity = 0;
|
|
7096
7251
|
}
|
|
7097
|
-
},
|
|
7252
|
+
}, zs = (e, t) => e.element(Ls(t, Ps.ORIGIN_META)).xyz, Bs = (e, t) => e.element(Ls(t, Ps.DIR_FLAGS)).xyz, Vs = (e, t) => ee(e.element(Ls(t, Ps.DIR_FLAGS)).w), Hs = (e, t) => e.element(Ls(t, Ps.THROUGHPUT_PDF)).xyz, Us = (e, t) => e.element(Ls(t, Ps.THROUGHPUT_PDF)).w, Ws = (e, t) => e.element(Ls(t, Ps.RADIANCE_ALPHA)), Gs = (e) => B(e).mul(1), Ks = (e, t, n, r, i) => e.element(Gs(t)).assign(H(fe(U(n.x, n.y)), fe(U(n.z, r)), pe(U(i.x, i.y)), pe(U(i.z, 0)))), qs = (e, t) => e.element(Gs(t)), Js = (e) => {
|
|
7098
7253
|
let t = Ne(e.x), n = Ne(e.y);
|
|
7099
7254
|
return G(W(t.x, t.y, n.x).mul(.5).add(.5), n.y);
|
|
7100
|
-
},
|
|
7101
|
-
e.element(
|
|
7102
|
-
},
|
|
7103
|
-
let n = e.element(
|
|
7255
|
+
}, Ys = (e) => W(Pe(e.z), Pe(e.w).x), Xs = (e, t, n, r, i) => e.element(Ls(t, Ps.ORIGIN_META)).assign(G(n, je(B(r).bitOr(B(i).shiftLeft(8))))), Zs = (e, t, n, r) => e.element(Ls(t, Ps.DIR_FLAGS)).assign(G(n, je(r))), Qs = (e, t, n, r) => e.element(Ls(t, Ps.THROUGHPUT_PDF)).assign(G(n, r)), $s = (e, t, n) => e.element(Ls(t, Ps.RADIANCE_ALPHA)).assign(n), ec = (e, t) => e.element(Ls(t, Fs.DIST_TRI_BARY)).x, tc = (e, t) => ee(e.element(Ls(t, Fs.DIST_TRI_BARY)).y), nc = (e, t) => e.element(Ls(t, Fs.DIST_TRI_BARY)).zw, rc = (e, t) => e.element(Ls(t, Fs.NORMAL_MAT)).xyz, ic = (e, t) => B(ee(e.element(Ls(t, Fs.NORMAL_MAT)).w).bitAnd(65535)), ac = (e, t, n, r, i, a, o, s, c) => {
|
|
7256
|
+
e.element(Ls(t, Fs.DIST_TRI_BARY)).assign(G(n, je(r), i, a)), e.element(Ls(t, Fs.NORMAL_MAT)).assign(G(o, je(s.bitOr(c.shiftLeft(16)))));
|
|
7257
|
+
}, oc = (e, t) => {
|
|
7258
|
+
let n = e.element(Ls(t, Ps.MEDIUM_STACK)), r = ee(n.x);
|
|
7104
7259
|
return {
|
|
7105
7260
|
stackDepth: r.bitAnd(255),
|
|
7106
7261
|
transTraversals: r.shiftRight(8).bitAnd(255),
|
|
@@ -7109,17 +7264,17 @@ var ws = 4, Ts = class extends qn {
|
|
|
7109
7264
|
ior2: n.z,
|
|
7110
7265
|
ior3: n.w
|
|
7111
7266
|
};
|
|
7112
|
-
},
|
|
7113
|
-
let n = e.element(
|
|
7267
|
+
}, sc = (e, t, n, r, i, a, o, s = B(0)) => e.element(Ls(t, Ps.MEDIUM_STACK)).assign(G(je(n.bitOr(r.shiftLeft(8)).bitOr(s.shiftLeft(16))), i, a, o)), cc = (e, t) => e.element(Ls(t, Ps.MEDIUM_SIGMA_A)).xyz, lc = (e, t, n) => e.element(Ls(t, Ps.MEDIUM_SIGMA_A)).assign(G(n, 0)), uc = (e, t) => N(ee(e.element(Ls(t, Ps.ORIGIN_META)).w).bitAnd(255)), dc = (e, t) => N(ee(e.element(Ls(t, Ps.ORIGIN_META)).w).shiftRight(8).bitAnd(255)), fc = (e, t) => {
|
|
7268
|
+
let n = e.element(Ls(t, Ps.SSS_SIGMA_S));
|
|
7114
7269
|
return {
|
|
7115
7270
|
sigmaS: n.xyz,
|
|
7116
7271
|
g: n.w
|
|
7117
7272
|
};
|
|
7118
|
-
},
|
|
7273
|
+
}, pc = (e, t, n, r) => e.element(Ls(t, Ps.SSS_SIGMA_S)).assign(G(n, r)), mc = {
|
|
7119
7274
|
ACTIVE_RAY_COUNT: 0,
|
|
7120
7275
|
ENTERING_COUNT: 1,
|
|
7121
7276
|
COUNT: 2
|
|
7122
|
-
},
|
|
7277
|
+
}, hc = {
|
|
7123
7278
|
BOUNCE_MASK: 255,
|
|
7124
7279
|
ACTIVE: 256,
|
|
7125
7280
|
SPECULAR: 512,
|
|
@@ -7129,12 +7284,12 @@ var ws = 4, Ts = class extends qn {
|
|
|
7129
7284
|
HAS_HIT_OPAQUE: 65536,
|
|
7130
7285
|
AUX_LOCKED: 1 << 17,
|
|
7131
7286
|
REDIRECTED: 1 << 18
|
|
7132
|
-
},
|
|
7287
|
+
}, gc = class {
|
|
7133
7288
|
constructor(e = 0) {
|
|
7134
7289
|
this.capacity = 0, this.counters = null, this.activeIndices = null, this.activeIndicesRO = null, this.pingPong = 0, e > 0 && this.allocate(e);
|
|
7135
7290
|
}
|
|
7136
7291
|
allocate(e) {
|
|
7137
|
-
this.dispose(), this.capacity = e, this._countersAttr = new o(new Uint32Array(
|
|
7292
|
+
this.dispose(), this.capacity = e, this._countersAttr = new o(new Uint32Array(mc.COUNT), 1), this.counters = Ce(this._countersAttr, "uint").toAtomic(), this.MAX_BOUNCE_SNAPSHOTS = 32, this._bounceCountsAttr = new o(new Uint32Array(this.MAX_BOUNCE_SNAPSHOTS), 1), this.bounceCounts = Ce(this._bounceCountsAttr, "uint");
|
|
7138
7293
|
let t = new o(new Uint32Array(e), 1), n = new o(new Uint32Array(e), 1);
|
|
7139
7294
|
this._attrA = t, this._attrB = n, this.activeIndices = {
|
|
7140
7295
|
a: Ce(t, "uint"),
|
|
@@ -7143,7 +7298,7 @@ var ws = 4, Ts = class extends qn {
|
|
|
7143
7298
|
a: Ce(t, "uint").toReadOnly(),
|
|
7144
7299
|
b: Ce(n, "uint").toReadOnly()
|
|
7145
7300
|
}, this.pingPong = 0;
|
|
7146
|
-
let r =
|
|
7301
|
+
let r = mc.COUNT * 4 + e * 4 * 2;
|
|
7147
7302
|
console.log(`QueueManager: Allocated capacity=${e}, total=${(r / (1024 * 1024)).toFixed(1)} MB`);
|
|
7148
7303
|
}
|
|
7149
7304
|
resize(e) {
|
|
@@ -7179,12 +7334,12 @@ var ws = 4, Ts = class extends qn {
|
|
|
7179
7334
|
dispose() {
|
|
7180
7335
|
this.counters = null, this.activeIndices = null, this.activeIndicesRO = null, this.capacity = 0;
|
|
7181
7336
|
}
|
|
7182
|
-
},
|
|
7337
|
+
}, _c = {
|
|
7183
7338
|
[Ft]: 4,
|
|
7184
7339
|
[It]: 3,
|
|
7185
7340
|
[Lt]: 2,
|
|
7186
7341
|
[Bt]: 1
|
|
7187
|
-
},
|
|
7342
|
+
}, vc = {
|
|
7188
7343
|
[q]: 4,
|
|
7189
7344
|
[ut]: 2,
|
|
7190
7345
|
[Qt]: 1,
|
|
@@ -7194,23 +7349,23 @@ var ws = 4, Ts = class extends qn {
|
|
|
7194
7349
|
[$t]: 4,
|
|
7195
7350
|
[dt]: 4
|
|
7196
7351
|
};
|
|
7197
|
-
function
|
|
7198
|
-
return (
|
|
7352
|
+
function yc(e) {
|
|
7353
|
+
return (_c[e.format] ?? 4) * (vc[e.type] ?? 4);
|
|
7199
7354
|
}
|
|
7200
|
-
function
|
|
7355
|
+
function bc(e) {
|
|
7201
7356
|
return e?.array?.byteLength || 0;
|
|
7202
7357
|
}
|
|
7203
|
-
function
|
|
7358
|
+
function xc(e) {
|
|
7204
7359
|
if (!e) return 0;
|
|
7205
7360
|
if (e.isRenderTarget) {
|
|
7206
7361
|
let t = e.textures?.length ? e.textures : [e.texture], n = e.width || 0, r = e.height || 0, i = e.depth || 1, a = 0;
|
|
7207
|
-
for (let e of t) e && (a += n * r * i *
|
|
7362
|
+
for (let e of t) e && (a += n * r * i * yc(e));
|
|
7208
7363
|
return a;
|
|
7209
7364
|
}
|
|
7210
7365
|
let t = e.image || {}, n = t.width ?? e.width ?? 0, r = t.height ?? e.height ?? 0, i = t.depth ?? 1;
|
|
7211
|
-
return n * r * i *
|
|
7366
|
+
return n * r * i * yc(e);
|
|
7212
7367
|
}
|
|
7213
|
-
var
|
|
7368
|
+
var Sc = class {
|
|
7214
7369
|
constructor(e = null) {
|
|
7215
7370
|
this._providers = [], this._renderer = e, this.current = 0, this.peak = 0, this.byCategory = {};
|
|
7216
7371
|
}
|
|
@@ -7256,10 +7411,10 @@ var mc = class {
|
|
|
7256
7411
|
_residentTextureBytes(e) {
|
|
7257
7412
|
if (e.isRenderTarget) {
|
|
7258
7413
|
let t = e.textures?.length ? e.textures : [e.texture], n = e.width || 0, r = e.height || 0, i = e.depth || 1, a = 0;
|
|
7259
|
-
for (let e of t) e && this._isResident(e) && (a += n * r * i *
|
|
7414
|
+
for (let e of t) e && this._isResident(e) && (a += n * r * i * yc(e));
|
|
7260
7415
|
return a;
|
|
7261
7416
|
}
|
|
7262
|
-
return this._isResident(e) ?
|
|
7417
|
+
return this._isResident(e) ? xc(e) : 0;
|
|
7263
7418
|
}
|
|
7264
7419
|
resetPeak() {
|
|
7265
7420
|
this.peak = this.current;
|
|
@@ -7268,7 +7423,7 @@ var mc = class {
|
|
|
7268
7423
|
let e = (e) => (e / 1048576).toFixed(1), t = Object.entries(this.byCategory).map(([t, n]) => `${t}=${e(n)}`);
|
|
7269
7424
|
return `VRAM current=${e(this.current)}MB peak=${e(this.peak)}MB [${t.join(" ")}]`;
|
|
7270
7425
|
}
|
|
7271
|
-
},
|
|
7426
|
+
}, Cc = {
|
|
7272
7427
|
generate: [
|
|
7273
7428
|
16,
|
|
7274
7429
|
16,
|
|
@@ -7314,10 +7469,10 @@ var mc = class {
|
|
|
7314
7469
|
16,
|
|
7315
7470
|
1
|
|
7316
7471
|
]
|
|
7317
|
-
},
|
|
7472
|
+
}, wc = class {
|
|
7318
7473
|
constructor(e) {
|
|
7319
7474
|
this.renderer = e, this.kernels = /* @__PURE__ */ new Map(), this.workgroupSizes = /* @__PURE__ */ new Map(), this.timing = /* @__PURE__ */ new Map(), this.profiling = !1, this.profile = /* @__PURE__ */ new Map();
|
|
7320
|
-
for (let [e, t] of Object.entries(
|
|
7475
|
+
for (let [e, t] of Object.entries(Cc)) this.workgroupSizes.set(e, t);
|
|
7321
7476
|
}
|
|
7322
7477
|
register(e, t) {
|
|
7323
7478
|
this.kernels.set(e, t), this.timing.set(e, {
|
|
@@ -7411,7 +7566,7 @@ var mc = class {
|
|
|
7411
7566
|
dispose() {
|
|
7412
7567
|
this.kernels.clear(), this.timing.clear(), this.profile.clear();
|
|
7413
7568
|
}
|
|
7414
|
-
},
|
|
7569
|
+
}, Tc = 32, Ec = 512, Dc = 4, Oc = 8, kc = 1e8, Ac = () => y("int", Tc).toVar(), jc = K("\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"), Mc = K("\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"), Nc = K("\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"), Pc = f(([e, t, n, r]) => {
|
|
7415
7570
|
let i = r ?? T(!1), a = mi({
|
|
7416
7571
|
didHit: !1,
|
|
7417
7572
|
dst: M(0x56bc75e2d63100000),
|
|
@@ -7422,12 +7577,12 @@ var mc = class {
|
|
|
7422
7577
|
meshIndex: N(-1),
|
|
7423
7578
|
boxTests: N(0),
|
|
7424
7579
|
triTests: N(0)
|
|
7425
|
-
}).toVar(), o = N(-1).toVar(), s = M(0).toVar(), c = M(0).toVar(), l =
|
|
7580
|
+
}).toVar(), o = N(-1).toVar(), s = M(0).toVar(), c = M(0).toVar(), l = Ac(), u = N(1).toVar();
|
|
7426
7581
|
l.element(N(0)).assign(N(0));
|
|
7427
|
-
let f = I(W(1), ve(e.direction), de(e.direction, W(0))), h = I(W(1).div(e.direction), W(
|
|
7428
|
-
return m(u.greaterThan(N(0)).and(b.lessThan(N(
|
|
7582
|
+
let f = I(W(1), ve(e.direction), de(e.direction, W(0))), h = I(W(1).div(e.direction), W(kc).mul(f), ae(_(e.direction), W(1e-8))).toVar(), g = e.origin, v = e.direction, y = Mc({ rayDir: v }).toVar(), b = N(0).toVar();
|
|
7583
|
+
return m(u.greaterThan(N(0)).and(b.lessThan(N(Ec))), () => {
|
|
7429
7584
|
b.addAssign(1), u.subAssign(1);
|
|
7430
|
-
let e = l.element(u).toVar(), r = $(t, e, N(0), N(
|
|
7585
|
+
let e = l.element(u).toVar(), r = $(t, e, N(0), N(Dc));
|
|
7431
7586
|
a.boxTests.addAssign(1), p(r.w.lessThan(0), () => {
|
|
7432
7587
|
p(r.w.greaterThan(M(-1.5)), () => {
|
|
7433
7588
|
let e = N(r.x).toVar(), t = N(r.y).toVar();
|
|
@@ -7436,7 +7591,7 @@ var mc = class {
|
|
|
7436
7591
|
end: t
|
|
7437
7592
|
}, ({ i: t }) => {
|
|
7438
7593
|
a.triTests.addAssign(1);
|
|
7439
|
-
let r = e.add(t).toVar(), l = $(n, r, N(0), N(
|
|
7594
|
+
let r = e.add(t).toVar(), l = $(n, r, N(0), N(Oc)).xyz, u = $(n, r, N(1), N(Oc)).xyz, d = $(n, r, N(2), N(Oc)).xyz, f = jc({
|
|
7440
7595
|
rayOrigin: g,
|
|
7441
7596
|
rayDir: v,
|
|
7442
7597
|
pA: l,
|
|
@@ -7446,7 +7601,7 @@ var mc = class {
|
|
|
7446
7601
|
woopParams: y
|
|
7447
7602
|
});
|
|
7448
7603
|
p(f.w.greaterThan(.5), () => {
|
|
7449
|
-
let e = f.x, t = f.y, l = f.z, u = $(n, r, N(3), N(
|
|
7604
|
+
let e = f.x, t = f.y, l = f.z, u = $(n, r, N(3), N(Oc)).xyz, d = $(n, r, N(4), N(Oc)).xyz, m = $(n, r, N(5), N(Oc)), h = m.xyz, g = N(m.w).toVar(), _ = M(1).sub(t).sub(l), y = v.dot(L(u.mul(_).add(d.mul(t)).add(h.mul(l))));
|
|
7450
7605
|
p(i.or(g.equal(N(2))).or(g.equal(N(0)).and(y.lessThan(-1e-4))).or(g.equal(N(1)).and(y.greaterThan(1e-4))), () => {
|
|
7451
7606
|
a.didHit.assign(!0), a.dst.assign(e), o.assign(r), s.assign(t), c.assign(l);
|
|
7452
7607
|
});
|
|
@@ -7455,17 +7610,17 @@ var mc = class {
|
|
|
7455
7610
|
d();
|
|
7456
7611
|
});
|
|
7457
7612
|
}).Else(() => {
|
|
7458
|
-
p(r.z.greaterThan(.5).and(u.lessThan(N(
|
|
7613
|
+
p(r.z.greaterThan(.5).and(u.lessThan(N(Tc))), () => {
|
|
7459
7614
|
l.element(u).assign(N(r.x)), u.addAssign(1);
|
|
7460
7615
|
});
|
|
7461
7616
|
});
|
|
7462
7617
|
}).Else(() => {
|
|
7463
|
-
let n = $(t, e, N(1), N(
|
|
7618
|
+
let n = $(t, e, N(1), N(Dc)), i = $(t, e, N(2), N(Dc)), o = $(t, e, N(3), N(Dc)), s = N(r.w).toVar(), c = N(n.w).toVar(), d = Nc({
|
|
7464
7619
|
rayOrigin: g,
|
|
7465
7620
|
invDir: h,
|
|
7466
7621
|
boxMin: r.xyz,
|
|
7467
7622
|
boxMax: n.xyz
|
|
7468
|
-
}).toVar(), f =
|
|
7623
|
+
}).toVar(), f = Nc({
|
|
7469
7624
|
rayOrigin: g,
|
|
7470
7625
|
invDir: h,
|
|
7471
7626
|
boxMin: i.xyz,
|
|
@@ -7473,21 +7628,21 @@ var mc = class {
|
|
|
7473
7628
|
}).toVar();
|
|
7474
7629
|
p(le(d, f).lessThan(a.dst), () => {
|
|
7475
7630
|
let e = d.lessThan(f);
|
|
7476
|
-
p(R(e, f, d).lessThan(a.dst).and(u.lessThan(N(
|
|
7631
|
+
p(R(e, f, d).lessThan(a.dst).and(u.lessThan(N(Tc))), () => {
|
|
7477
7632
|
l.element(u).assign(R(e, c, s)), u.addAssign(1);
|
|
7478
|
-
}), p(u.lessThan(N(
|
|
7633
|
+
}), p(u.lessThan(N(Tc)), () => {
|
|
7479
7634
|
l.element(u).assign(R(e, s, c)), u.addAssign(1);
|
|
7480
7635
|
});
|
|
7481
7636
|
});
|
|
7482
7637
|
});
|
|
7483
7638
|
}), p(a.didHit, () => {
|
|
7484
7639
|
a.hitPoint.assign(e.origin.add(e.direction.mul(a.dst)));
|
|
7485
|
-
let t = M(1).sub(s).sub(c), r = $(n, o, N(3), N(
|
|
7640
|
+
let t = M(1).sub(s).sub(c), r = $(n, o, N(3), N(Oc)).xyz, i = $(n, o, N(4), N(Oc)).xyz, l = $(n, o, N(5), N(Oc)).xyz;
|
|
7486
7641
|
a.normal.assign(L(r.mul(t).add(i.mul(s)).add(l.mul(c))));
|
|
7487
|
-
let u = $(n, o, N(6), N(
|
|
7642
|
+
let u = $(n, o, N(6), N(Oc)), d = $(n, o, N(7), N(Oc));
|
|
7488
7643
|
a.uv.assign(u.xy.mul(t).add(u.zw.mul(s)).add(d.xy.mul(c))), a.materialIndex.assign(N(d.z)), a.meshIndex.assign(N(d.w)), a.triangleIndex.assign(o);
|
|
7489
7644
|
}), a;
|
|
7490
|
-
}),
|
|
7645
|
+
}), Fc = f(([e, t, n, r]) => {
|
|
7491
7646
|
let i = mi({
|
|
7492
7647
|
didHit: !1,
|
|
7493
7648
|
dst: r,
|
|
@@ -7498,12 +7653,12 @@ var mc = class {
|
|
|
7498
7653
|
meshIndex: N(-1),
|
|
7499
7654
|
boxTests: N(0),
|
|
7500
7655
|
triTests: N(0)
|
|
7501
|
-
}).toVar(), a =
|
|
7656
|
+
}).toVar(), a = Ac(), o = N(1).toVar();
|
|
7502
7657
|
a.element(N(0)).assign(N(0));
|
|
7503
|
-
let s = I(W(1), ve(e.direction), de(e.direction, W(0))), c = I(W(1).div(e.direction), W(
|
|
7504
|
-
return m(o.greaterThan(N(0)).and(i.didHit.not()).and(u.lessThan(N(
|
|
7658
|
+
let s = I(W(1), ve(e.direction), de(e.direction, W(0))), c = I(W(1).div(e.direction), W(kc).mul(s), ae(_(e.direction), W(1e-8))).toVar(), l = Mc({ rayDir: e.direction }).toVar(), u = N(0).toVar();
|
|
7659
|
+
return m(o.greaterThan(N(0)).and(i.didHit.not()).and(u.lessThan(N(Ec))), () => {
|
|
7505
7660
|
u.addAssign(1), o.subAssign(1);
|
|
7506
|
-
let r = a.element(o).toVar(), s = $(t, r, N(0), N(
|
|
7661
|
+
let r = a.element(o).toVar(), s = $(t, r, N(0), N(Dc));
|
|
7507
7662
|
p(s.w.lessThan(0), () => {
|
|
7508
7663
|
p(s.w.greaterThan(M(-1.5)), () => {
|
|
7509
7664
|
let t = N(s.x).toVar(), r = N(s.y).toVar();
|
|
@@ -7511,7 +7666,7 @@ var mc = class {
|
|
|
7511
7666
|
start: N(0),
|
|
7512
7667
|
end: r
|
|
7513
7668
|
}, ({ i: r }) => {
|
|
7514
|
-
let a = t.add(r).toVar(), o = $(n, a, N(0), N(
|
|
7669
|
+
let a = t.add(r).toVar(), o = $(n, a, N(0), N(Oc)).xyz, s = $(n, a, N(1), N(Oc)).xyz, c = $(n, a, N(2), N(Oc)).xyz, u = jc({
|
|
7515
7670
|
rayOrigin: e.origin,
|
|
7516
7671
|
rayDir: e.direction,
|
|
7517
7672
|
pA: o,
|
|
@@ -7521,22 +7676,22 @@ var mc = class {
|
|
|
7521
7676
|
woopParams: l
|
|
7522
7677
|
});
|
|
7523
7678
|
p(u.w.greaterThan(.5), () => {
|
|
7524
|
-
let t = $(n, a, N(7), N(
|
|
7679
|
+
let t = $(n, a, N(7), N(Oc));
|
|
7525
7680
|
i.didHit.assign(!0), i.dst.assign(u.x), i.materialIndex.assign(N(t.z)), i.meshIndex.assign(N(t.w)), i.hitPoint.assign(e.origin.add(e.direction.mul(u.x))), i.uv.assign(U(u.y, u.z)), i.triangleIndex.assign(a), d();
|
|
7526
7681
|
});
|
|
7527
7682
|
});
|
|
7528
7683
|
}).Else(() => {
|
|
7529
|
-
p(s.z.greaterThan(.5).and(o.lessThan(N(
|
|
7684
|
+
p(s.z.greaterThan(.5).and(o.lessThan(N(Tc))), () => {
|
|
7530
7685
|
a.element(o).assign(N(s.x)), o.addAssign(1);
|
|
7531
7686
|
});
|
|
7532
7687
|
});
|
|
7533
7688
|
}).Else(() => {
|
|
7534
|
-
let n = $(t, r, N(1), N(
|
|
7689
|
+
let n = $(t, r, N(1), N(Dc)), l = $(t, r, N(2), N(Dc)), u = $(t, r, N(3), N(Dc)), d = N(s.w).toVar(), f = N(n.w).toVar(), m = Nc({
|
|
7535
7690
|
rayOrigin: e.origin,
|
|
7536
7691
|
invDir: c,
|
|
7537
7692
|
boxMin: s.xyz,
|
|
7538
7693
|
boxMax: n.xyz
|
|
7539
|
-
}).toVar(), h =
|
|
7694
|
+
}).toVar(), h = Nc({
|
|
7540
7695
|
rayOrigin: e.origin,
|
|
7541
7696
|
invDir: c,
|
|
7542
7697
|
boxMin: l.xyz,
|
|
@@ -7544,15 +7699,15 @@ var mc = class {
|
|
|
7544
7699
|
}).toVar();
|
|
7545
7700
|
p(le(m, h).lessThan(i.dst), () => {
|
|
7546
7701
|
let e = m.lessThan(h);
|
|
7547
|
-
p(R(e, h, m).lessThan(i.dst).and(o.lessThan(N(
|
|
7702
|
+
p(R(e, h, m).lessThan(i.dst).and(o.lessThan(N(Tc))), () => {
|
|
7548
7703
|
a.element(o).assign(R(e, f, d)), o.addAssign(1);
|
|
7549
|
-
}), p(o.lessThan(N(
|
|
7704
|
+
}), p(o.lessThan(N(Tc)), () => {
|
|
7550
7705
|
a.element(o).assign(R(e, d, f)), o.addAssign(1);
|
|
7551
7706
|
});
|
|
7552
7707
|
});
|
|
7553
7708
|
});
|
|
7554
7709
|
}), i;
|
|
7555
|
-
}),
|
|
7710
|
+
}), Ic = f(([e, t, n, r, i, a, o, s, c, l, u]) => {
|
|
7556
7711
|
let d = W(e.xy, 1), f = r.mul(G(d, 1)), m = L(ce(n[0].xyz, n[1].xyz, n[2].xyz).mul(f.xyz.div(f.w))).toVar(), h = W(n[3]).toVar(), g = h.toVar(), _ = m.toVar();
|
|
7557
7712
|
return p(i.and(a.greaterThan(0)).and(o.lessThan(64)).and(s.greaterThan(.001)), () => {
|
|
7558
7713
|
let e = a.div(o).mul(.001).mul(c).mul(l), r = Ln(t), i = r.x.mul(u.max(.01)), d = r.y, f = L(W(n[0])), p = L(W(n[1])), v = f.mul(i).add(p.mul(d)).mul(e);
|
|
@@ -7562,7 +7717,7 @@ var mc = class {
|
|
|
7562
7717
|
direction: _
|
|
7563
7718
|
});
|
|
7564
7719
|
});
|
|
7565
|
-
function
|
|
7720
|
+
function Lc(e) {
|
|
7566
7721
|
let { rayBufferRW: t, rngBufferRW: n, gBufferRW: r, resolution: i, frame: a, cameraWorldMatrix: o, cameraProjectionMatrixInverse: s, enableDOF: c, focalLength: l, aperture: u, focusDistance: d, sceneScale: m, apertureScale: h, anamorphicRatio: g, renderWidth: _, renderHeight: v, transmissiveBounces: y, transparentBackground: b, auxGBufferEnabled: x } = e, S = x.greaterThan(B(0));
|
|
7567
7722
|
return f(() => {
|
|
7568
7723
|
let e = N(ze.x).mul(16).add(N(oe.x)), f = N(ze.y).mul(16).add(N(oe.y));
|
|
@@ -7573,51 +7728,51 @@ function kc(e) {
|
|
|
7573
7728
|
pixelCoord: _,
|
|
7574
7729
|
rayIndex: N(0),
|
|
7575
7730
|
frame: a
|
|
7576
|
-
}).toVar() }).toVar(), T = Wn(_, N(0), N(1), w, i, a).toVar(), E = U(2).div(i), D = T.sub(.5).mul(E), O = C.add(D), k = ui.wrap(
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
}),
|
|
7731
|
+
}).toVar() }).toVar(), T = Wn(_, N(0), N(1), w, i, a).toVar(), E = U(2).div(i), D = T.sub(.5).mul(E), O = C.add(D), k = ui.wrap(Ic(O, w, o, s, c, l, u, d, m, h, g));
|
|
7732
|
+
Xs(t, x, k.origin, N(0), N(0)), Zs(t, x, k.direction, B(hc.ACTIVE)), Qs(t, x, G(1, 1, 1, 0).xyz, M(0)), $s(t, x, G(W(0), R(b, M(1), M(0)))), p(S, () => {
|
|
7733
|
+
Ks(r, B(v), W(0, 0, 1), M(1), W(0));
|
|
7734
|
+
}), sc(t, x, B(0), B(y), M(1), M(1), M(1)), n.element(x).assign(w);
|
|
7580
7735
|
});
|
|
7581
7736
|
});
|
|
7582
7737
|
}
|
|
7583
7738
|
//#endregion
|
|
7584
7739
|
//#region src/TSL/ExtendKernel.js
|
|
7585
|
-
function
|
|
7740
|
+
function Rc(e) {
|
|
7586
7741
|
let { bvhBuffer: t, triangleBuffer: n, materialBuffer: r, rayBufferRO: i, hitBufferRW: a, activeIndicesRO: o, counters: s, maxRayCount: c } = e;
|
|
7587
7742
|
return f(() => {
|
|
7588
|
-
let e = re, r = s ? S(s.element(B(
|
|
7743
|
+
let e = re, r = s ? S(s.element(B(mc.ENTERING_COUNT))) : c;
|
|
7589
7744
|
p(e.greaterThanEqual(r), () => {
|
|
7590
7745
|
h();
|
|
7591
7746
|
});
|
|
7592
7747
|
let l = o.element(e), u = ui({
|
|
7593
|
-
origin:
|
|
7594
|
-
direction:
|
|
7595
|
-
}), d =
|
|
7596
|
-
|
|
7748
|
+
origin: zs(i, l).toVar(),
|
|
7749
|
+
direction: Bs(i, l).toVar()
|
|
7750
|
+
}), d = oc(i, l).stackDepth.greaterThan(B(0)), f = mi.wrap(Pc(u, t, n, d)).toVar();
|
|
7751
|
+
ac(a, l, f.dst, B(f.triangleIndex), f.uv.x, f.uv.y, f.normal, B(f.materialIndex), B(f.meshIndex));
|
|
7597
7752
|
});
|
|
7598
7753
|
}
|
|
7599
7754
|
//#endregion
|
|
7600
7755
|
//#region src/TSL/Environment.js
|
|
7601
|
-
var
|
|
7756
|
+
var zc = /* @__PURE__ */ K("\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"), Bc = /* @__PURE__ */ K("\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"), Vc = f(([e, t, n, r, i, a]) => {
|
|
7602
7757
|
let o = G(0).toVar();
|
|
7603
7758
|
return p(r.equal(0), () => {
|
|
7604
7759
|
o.assign(G(0));
|
|
7605
7760
|
}).Else(() => {
|
|
7606
|
-
let s =
|
|
7761
|
+
let s = zc({
|
|
7607
7762
|
direction: t,
|
|
7608
7763
|
environmentMatrix: n
|
|
7609
7764
|
}).toVar(), c = ke(e, s, 0).rgb.toVar(), l = ye(s.y.mul(Math.PI)).toVar(), u = A(c, Ni).mul(l), d = F(M(0), u.sub(i)).div(r), f = l.greaterThan(0).select(M(1).div(M(2 * Math.PI * Math.PI).mul(l)), M(0)), p = M(a.x).mul(M(a.y)).mul(d).mul(f);
|
|
7610
7765
|
o.assign(G(c, p));
|
|
7611
7766
|
}), o;
|
|
7612
|
-
}),
|
|
7613
|
-
let l = N(o.x).toVar(), u = o.y, d = E(s.x.mul(u.sub(1)), 0, u.sub(1)), f = N(te(d)), p = le(f.add(1), N(u).sub(1)), m = ne(d), h = I(t.load(P(l, f)).x, t.load(P(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 = N(te(v)), x = N(te(y)), S = le(b.add(1), N(g).sub(1)), C = le(x.add(1), N(_).sub(1)), w = ne(v), T = ne(y), D = t.load(P(b, x)).x, O = t.load(P(S, x)).x, k = t.load(P(b, C)).x, j = t.load(P(S, C)).x, ee = U(I(I(D, O, w), I(k, j, w), T).toVar(), h).toVar(), re =
|
|
7767
|
+
}), Hc = f(([e, t, n, r, i, a, o, s, c]) => {
|
|
7768
|
+
let l = N(o.x).toVar(), u = o.y, d = E(s.x.mul(u.sub(1)), 0, u.sub(1)), f = N(te(d)), p = le(f.add(1), N(u).sub(1)), m = ne(d), h = I(t.load(P(l, f)).x, t.load(P(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 = N(te(v)), x = N(te(y)), S = le(b.add(1), N(g).sub(1)), C = le(x.add(1), N(_).sub(1)), w = ne(v), T = ne(y), D = t.load(P(b, x)).x, O = t.load(P(S, x)).x, k = t.load(P(b, C)).x, j = t.load(P(S, C)).x, ee = U(I(I(D, O, w), I(k, j, w), T).toVar(), h).toVar(), re = Bc({
|
|
7614
7769
|
uv: ee,
|
|
7615
7770
|
environmentMatrix: n
|
|
7616
7771
|
}).toVar(), ie = ke(e, ee, 0).rgb.mul(r).toVar();
|
|
7617
7772
|
c.assign(ie);
|
|
7618
7773
|
let ae = ye(ee.y.mul(Math.PI)).toVar(), oe = A(ie.div(r), Ni).mul(ae), se = F(M(0), oe.sub(a)).div(i), ce = ae.greaterThan(0).select(M(1).div(M(2 * Math.PI * Math.PI).mul(ae)), M(0));
|
|
7619
7774
|
return G(re, M(o.x).mul(M(o.y)).mul(se).mul(ce));
|
|
7620
|
-
}),
|
|
7775
|
+
}), Uc = /* @__PURE__ */ K("\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", [zc]), Wc = f(([e, t, n, r]) => {
|
|
7621
7776
|
let i = t.toConst(), a = e.toVar();
|
|
7622
7777
|
a.y.subAssign(r);
|
|
7623
7778
|
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();
|
|
@@ -7632,13 +7787,13 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7632
7787
|
u.assign(a.add(i.mul(le(t, r))).div(n));
|
|
7633
7788
|
});
|
|
7634
7789
|
}), u;
|
|
7635
|
-
}),
|
|
7790
|
+
}), Gc = f(([e, t, n, r, i, a]) => {
|
|
7636
7791
|
let o = t.toVar();
|
|
7637
7792
|
return p(n, () => {
|
|
7638
7793
|
let n = W(e.x, e.y.sub(a), e.z);
|
|
7639
|
-
o.assign(
|
|
7794
|
+
o.assign(Wc(n, t, r, i));
|
|
7640
7795
|
}), o;
|
|
7641
|
-
}),
|
|
7796
|
+
}), Kc = f(([e, t]) => {
|
|
7642
7797
|
let n = W(0).toVar();
|
|
7643
7798
|
return p(e.roughness.greaterThan(.98).and(e.metalness.lessThan(.02)).and(e.transmission.equal(0)).and(e.clearcoat.equal(0)).and(e.iridescence.equal(0)), () => {
|
|
7644
7799
|
n.assign(e.color.rgb.mul(M(1).sub(e.metalness)).mul(Di));
|
|
@@ -7662,16 +7817,39 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7662
7817
|
n.assign(d);
|
|
7663
7818
|
});
|
|
7664
7819
|
}), n;
|
|
7665
|
-
}),
|
|
7820
|
+
}), qc = f(([e, t, n, r]) => Kc(r, vi.wrap(Wi(n, e, t)))), Jc = f(([e, t]) => {
|
|
7666
7821
|
let n = E(I(ca(t.ior).mul(t.specularColor), t.color.rgb, t.metalness).mul(t.specularIntensity), W(0), W(1)).toVar(), r = la(e.NoH, t.roughness), i = fa(e.NoV, e.NoL, t.roughness), a = ia(e.VoH, n), o = r.mul(i).mul(a).div(F(M(4).mul(e.NoV).mul(e.NoL), ki)), s = yi.wrap(pa(n, e.NoV, t.roughness)), c = o.mul(s.compensation), l = W(1).sub(s.E_total).mul(M(1).sub(t.metalness)).mul(t.color.rgb).div(Ei).add(c), u = F(t.clearcoatRoughness, ji), d = la(e.NoH, u), f = fa(e.NoV, e.NoL, u), p = ra(e.VoH, M(.04)), m = d.mul(f).mul(p).div(F(M(4).mul(e.NoV).mul(e.NoL), ki)), h = M(1).sub(t.clearcoat.mul(p).mul(M(2).sub(p)));
|
|
7667
7822
|
return l.mul(h).add(W(m).mul(t.clearcoat));
|
|
7668
|
-
}),
|
|
7823
|
+
}), Yc = 2 * Ei, Xc = f(([e, t]) => {
|
|
7824
|
+
let n = M(1).toVar();
|
|
7825
|
+
return p(t.lessThan(M(Ei).sub(.001)).and(e.greaterThan(0)), () => {
|
|
7826
|
+
let r = t.mul(.5).toVar(), i = Oe(r).toVar(), a = xe(F(M(1).sub(e.mul(e)), 0)).div(F(e, 1e-4)), o = R(r.greaterThan(.05), M(1).div(F(i.sub(r), 1e-6)), M(3).div(F(r.mul(r).mul(r), 1e-9)));
|
|
7827
|
+
n.assign(F(i.sub(a).mul(o), 0));
|
|
7828
|
+
}), n;
|
|
7829
|
+
}), Zc = f(([e]) => {
|
|
7830
|
+
let t = R(e.normalize.greaterThan(.5), M(1).div(F(e.area, 1e-10)), M(1));
|
|
7831
|
+
return e.color.mul(e.intensity).mul(Di).mul(t);
|
|
7832
|
+
}), Qc = f(([e, t, n, r]) => {
|
|
7669
7833
|
let i = T(!1).toVar(), a = W(0, 1, 0).toVar(), o = W(0).toVar(), s = M(0).toVar(), c = M(0).toVar(), l = N(2).toVar();
|
|
7670
7834
|
return p(e.area.greaterThan(0), () => {
|
|
7671
|
-
let u =
|
|
7672
|
-
p(
|
|
7673
|
-
let t = xe(
|
|
7674
|
-
|
|
7835
|
+
let u = W(0).toVar(), d = M(-1).toVar();
|
|
7836
|
+
p(e.shape.greaterThan(.5), () => {
|
|
7837
|
+
let t = xe(n.x).toVar(), r = M(Yc).mul(n.y).toVar();
|
|
7838
|
+
u.assign(e.position.add(e.u.mul(t.mul(D(r)))).add(e.v.mul(t.mul(ye(r)))));
|
|
7839
|
+
}).Else(() => {
|
|
7840
|
+
let r = No(t, e.position.sub(e.u).sub(e.v), e.u.mul(2), e.v.mul(2), n).toVar();
|
|
7841
|
+
p(r.w.greaterThan(0), () => {
|
|
7842
|
+
u.assign(r.xyz), d.assign(r.w);
|
|
7843
|
+
}).Else(() => {
|
|
7844
|
+
u.assign(e.position.add(e.u.mul(n.x.mul(2).sub(1))).add(e.v.mul(n.y.mul(2).sub(1))));
|
|
7845
|
+
});
|
|
7846
|
+
});
|
|
7847
|
+
let f = u.sub(t).toVar(), m = A(f, f).toVar();
|
|
7848
|
+
p(m.greaterThanEqual(1e-10), () => {
|
|
7849
|
+
let t = xe(m).toVar(), n = f.div(t).toVar(), u = A(n.negate(), e.normal).toVar();
|
|
7850
|
+
l.assign(N(1)), s.assign(t), a.assign(n), o.assign(Zc(e).mul(Xc(u, e.spread)));
|
|
7851
|
+
let p = m.div(F(e.area.mul(F(u, .001)), 1e-10)), h = R(d.greaterThan(0), d, p);
|
|
7852
|
+
c.assign(h.mul(r)), i.assign(u.greaterThan(0));
|
|
7675
7853
|
});
|
|
7676
7854
|
}), mo({
|
|
7677
7855
|
valid: i,
|
|
@@ -7681,7 +7859,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7681
7859
|
pdf: c,
|
|
7682
7860
|
lightType: l
|
|
7683
7861
|
});
|
|
7684
|
-
}),
|
|
7862
|
+
}), $c = f(([e, t, n]) => {
|
|
7685
7863
|
let r = T(!1).toVar(), i = W(0, 1, 0).toVar(), a = W(0).toVar(), o = M(0).toVar(), s = M(0).toVar(), c = N(3).toVar(), l = e.position.sub(t).toVar(), u = A(l, l).toVar();
|
|
7686
7864
|
return p(u.greaterThanEqual(1e-20), () => {
|
|
7687
7865
|
let t = xe(u).toVar(), c = l.div(t).toVar(), d = A(c.negate(), e.direction).toVar(), f = D(e.angle).toVar();
|
|
@@ -7705,7 +7883,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7705
7883
|
pdf: s,
|
|
7706
7884
|
lightType: c
|
|
7707
7885
|
});
|
|
7708
|
-
}),
|
|
7886
|
+
}), el = f(([e, t, n]) => {
|
|
7709
7887
|
let r = T(!1).toVar(), i = W(0, 1, 0).toVar(), a = W(0).toVar(), o = M(0).toVar(), s = M(0).toVar(), c = N(2).toVar(), l = e.position.sub(t).toVar(), u = A(l, l).toVar();
|
|
7710
7888
|
return p(u.greaterThanEqual(1e-20), () => {
|
|
7711
7889
|
let t = xe(u).toVar(), d = l.div(t), f = xo({
|
|
@@ -7722,7 +7900,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7722
7900
|
pdf: s,
|
|
7723
7901
|
lightType: c
|
|
7724
7902
|
});
|
|
7725
|
-
}),
|
|
7903
|
+
}), tl = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, h]) => {
|
|
7726
7904
|
let g = T(!1).toVar(), v = W(0, 1, 0).toVar(), y = W(0).toVar(), b = M(0).toVar(), x = M(0).toVar(), S = N(2).toVar(), C = s.add(l).add(d).add(h).toVar();
|
|
7727
7905
|
return p(C.greaterThan(N(0)), () => {
|
|
7728
7906
|
let w = M(0).toVar(), E = N(0).toVar(), k = N(-1).toVar(), A = N(-1).toVar(), j = M(0).toVar();
|
|
@@ -7798,7 +7976,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7798
7976
|
p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(l))), () => {
|
|
7799
7977
|
let o = uo.wrap(_o(c, t.sub(m)));
|
|
7800
7978
|
p(o.intensity.greaterThan(0), () => {
|
|
7801
|
-
let t = U(r.y, Y(a)).toVar(), s = mo.wrap(
|
|
7979
|
+
let t = U(r.y, Y(a)).toVar(), s = mo.wrap(Qc(o, e, t, n));
|
|
7802
7980
|
g.assign(s.valid), v.assign(s.direction), y.assign(s.emission), b.assign(s.distance), x.assign(s.pdf), S.assign(s.lightType), i.assign(T(!0));
|
|
7803
7981
|
});
|
|
7804
7982
|
}), m.addAssign(l);
|
|
@@ -7806,7 +7984,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7806
7984
|
p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(d))), () => {
|
|
7807
7985
|
let r = fo.wrap(vo(u, t.sub(m)));
|
|
7808
7986
|
p(r.intensity.greaterThan(0), () => {
|
|
7809
|
-
let t = mo.wrap(
|
|
7987
|
+
let t = mo.wrap(el(r, e, n));
|
|
7810
7988
|
g.assign(t.valid), v.assign(t.direction), y.assign(t.emission), b.assign(t.distance), x.assign(t.pdf), S.assign(t.lightType), i.assign(T(!0));
|
|
7811
7989
|
});
|
|
7812
7990
|
}), m.addAssign(d);
|
|
@@ -7814,7 +7992,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7814
7992
|
p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(h))), () => {
|
|
7815
7993
|
let r = po.wrap(yo(f, t.sub(m)));
|
|
7816
7994
|
p(r.intensity.greaterThan(0), () => {
|
|
7817
|
-
let t = mo.wrap(
|
|
7995
|
+
let t = mo.wrap($c(r, e, n));
|
|
7818
7996
|
g.assign(t.valid), v.assign(t.direction), y.assign(t.emission), b.assign(t.distance), x.assign(t.pdf), S.assign(t.lightType), i.assign(T(!0));
|
|
7819
7997
|
});
|
|
7820
7998
|
});
|
|
@@ -7824,21 +8002,21 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7824
8002
|
p(k.equal(N(0)).and(A.greaterThanEqual(N(0))), () => {
|
|
7825
8003
|
let n = lo.wrap(go(o, A)), i = L(n.direction).toVar(), s = M(1).toVar();
|
|
7826
8004
|
p(n.angle.greaterThan(0), () => {
|
|
7827
|
-
let e = D(n.angle.mul(.5)).toVar(), t = I(e, M(1), r.y).toVar(), o = xe(F(M(0), M(1).sub(t.mul(t)))).toVar(), c = M(
|
|
8005
|
+
let e = D(n.angle.mul(.5)).toVar(), t = I(e, M(1), r.y).toVar(), o = xe(F(M(0), M(1).sub(t.mul(t)))).toVar(), c = M(Yc).mul(Y(a)).toVar(), l = L(n.direction).toVar(), u = L(O(R(_(l.x).greaterThan(.9), W(0, 1, 0), W(1, 0, 0)), l)).toVar(), d = O(l, u).toVar();
|
|
7828
8006
|
i.assign(L(l.mul(t).add(u.mul(D(c)).add(d.mul(ye(c))).mul(o))));
|
|
7829
|
-
let f = M(
|
|
8007
|
+
let f = M(Yc).mul(F(M(1).sub(e), 1e-10));
|
|
7830
8008
|
s.assign(M(1).div(f));
|
|
7831
8009
|
});
|
|
7832
8010
|
let c = Eo(n, e);
|
|
7833
8011
|
v.assign(i), y.assign(n.color.mul(n.intensity).mul(c)), b.assign(1e6), x.assign(s.mul(t)), S.assign(N(0)), g.assign(T(!0));
|
|
7834
8012
|
}), p(k.equal(N(1)).and(A.greaterThanEqual(N(0))), () => {
|
|
7835
|
-
let n = uo.wrap(_o(c, A)), i = U(r.y, Y(a)).toVar(), o = mo.wrap(
|
|
8013
|
+
let n = uo.wrap(_o(c, A)), i = U(r.y, Y(a)).toVar(), o = mo.wrap(Qc(n, e, i, t));
|
|
7836
8014
|
g.assign(o.valid), v.assign(o.direction), y.assign(o.emission), b.assign(o.distance), x.assign(o.pdf), S.assign(o.lightType);
|
|
7837
8015
|
}), p(k.equal(N(2)).and(A.greaterThanEqual(N(0))), () => {
|
|
7838
|
-
let n = fo.wrap(vo(u, A)), r = mo.wrap(
|
|
8016
|
+
let n = fo.wrap(vo(u, A)), r = mo.wrap(el(n, e, t));
|
|
7839
8017
|
g.assign(r.valid), v.assign(r.direction), y.assign(r.emission), b.assign(r.distance), x.assign(r.pdf), S.assign(r.lightType);
|
|
7840
8018
|
}), p(k.equal(N(3)).and(A.greaterThanEqual(N(0))), () => {
|
|
7841
|
-
let n = po.wrap(yo(f, A)), r = mo.wrap(
|
|
8019
|
+
let n = po.wrap(yo(f, A)), r = mo.wrap($c(n, e, t));
|
|
7842
8020
|
g.assign(r.valid), v.assign(r.direction), y.assign(r.emission), b.assign(r.distance), x.assign(r.pdf), S.assign(r.lightType);
|
|
7843
8021
|
});
|
|
7844
8022
|
});
|
|
@@ -7850,7 +8028,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7850
8028
|
pdf: x,
|
|
7851
8029
|
lightType: S
|
|
7852
8030
|
});
|
|
7853
|
-
}),
|
|
8031
|
+
}), nl = f(([e, t]) => {
|
|
7854
8032
|
let n = t.NoV, r = t.NoL.toVar(), i = t.NoH, a = M(1).sub(e.metalness).mul(M(1).sub(e.transmission)).toVar(), o = M(1).sub(a.mul(M(1).sub(e.metalness))).toVar(), s = a.add(o).toVar(), c = M(0).toVar();
|
|
7855
8033
|
return p(s.greaterThan(0), () => {
|
|
7856
8034
|
let t = M(1).div(F(s, 1e-10)).toVar();
|
|
@@ -7861,8 +8039,59 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7861
8039
|
c.addAssign(o.mul(ma(i, n, t)));
|
|
7862
8040
|
});
|
|
7863
8041
|
}), F(c, 1e-8);
|
|
7864
|
-
}),
|
|
7865
|
-
let
|
|
8042
|
+
}), rl = f(([e, t, n, r]) => nl(r, vi.wrap(Wi(n, e, t)))), il = f(([e, t, n, r, i, a, o, s, c, l, u, d]) => {
|
|
8043
|
+
let f = M(0).toVar(), h = N(0).toVar();
|
|
8044
|
+
return p(a.greaterThan(N(0)), () => {
|
|
8045
|
+
m({
|
|
8046
|
+
start: N(0),
|
|
8047
|
+
end: a,
|
|
8048
|
+
type: "int",
|
|
8049
|
+
condition: "<"
|
|
8050
|
+
}, ({ i: e }) => {
|
|
8051
|
+
p(h.lessThan(N(16)), () => {
|
|
8052
|
+
let a = lo.wrap(go(i, e));
|
|
8053
|
+
f.addAssign(ao(a, t, n, r)), h.addAssign(1);
|
|
8054
|
+
});
|
|
8055
|
+
});
|
|
8056
|
+
}), p(s.greaterThan(N(0)), () => {
|
|
8057
|
+
m({
|
|
8058
|
+
start: N(0),
|
|
8059
|
+
end: s,
|
|
8060
|
+
type: "int",
|
|
8061
|
+
condition: "<"
|
|
8062
|
+
}, ({ i: r }) => {
|
|
8063
|
+
p(h.lessThan(N(16)), () => {
|
|
8064
|
+
let i = uo.wrap(_o(o, r));
|
|
8065
|
+
f.addAssign(R(i.intensity.greaterThan(0), oo(i, e, t, n), M(0))), h.addAssign(1);
|
|
8066
|
+
});
|
|
8067
|
+
});
|
|
8068
|
+
}), p(l.greaterThan(N(0)), () => {
|
|
8069
|
+
m({
|
|
8070
|
+
start: N(0),
|
|
8071
|
+
end: l,
|
|
8072
|
+
type: "int",
|
|
8073
|
+
condition: "<"
|
|
8074
|
+
}, ({ i: r }) => {
|
|
8075
|
+
p(h.lessThan(N(16)), () => {
|
|
8076
|
+
let i = fo.wrap(vo(c, r));
|
|
8077
|
+
f.addAssign(so(i, e, t, n)), h.addAssign(1);
|
|
8078
|
+
});
|
|
8079
|
+
});
|
|
8080
|
+
}), p(d.greaterThan(N(0)), () => {
|
|
8081
|
+
m({
|
|
8082
|
+
start: N(0),
|
|
8083
|
+
end: d,
|
|
8084
|
+
type: "int",
|
|
8085
|
+
condition: "<"
|
|
8086
|
+
}, ({ i: r }) => {
|
|
8087
|
+
p(h.lessThan(N(16)), () => {
|
|
8088
|
+
let i = po.wrap(yo(u, r));
|
|
8089
|
+
f.addAssign(co(i, e, t, n)), h.addAssign(1);
|
|
8090
|
+
});
|
|
8091
|
+
});
|
|
8092
|
+
}), f;
|
|
8093
|
+
}), al = f(([e, t, n, r, i, a, o, s, c, l, u, d, h, g, _, v, y, b, x, S, C, w, E, D, O, k, j, ee, te]) => {
|
|
8094
|
+
let ne = W(0).toVar(), re = W(0).toVar(), P = e.add(t.mul(.001)).toVar(), ie = f(([e, t, n]) => ro(e, t, n, Fc, b, x, S));
|
|
7866
8095
|
return p(n.emissiveIntensity.lessThanEqual(10), () => {
|
|
7867
8096
|
let f = W(1).toVar(), b = Ti.wrap(Yi(n.roughness, n.metalness, s, f)), x = b.useBRDFSampling.toVar(), S = b.useLightSampling.toVar(), ae = b.brdfWeight.toVar(), oe = b.lightWeight.toVar(), se = u.add(h).add(_).add(y).toVar(), ce = M(.001).mul(M(1).add(M(s).mul(.5))).toVar(), I = se.greaterThan(N(0)).toVar(), ue = M(0).toVar();
|
|
7868
8097
|
p(S.and(I), () => {
|
|
@@ -7880,7 +8109,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7880
8109
|
}).ElseIf(I, () => {
|
|
7881
8110
|
pe.assign(T(!0));
|
|
7882
8111
|
}), p(pe, () => {
|
|
7883
|
-
let e = U(de, Y(c)).toVar(), i = mo.wrap(
|
|
8112
|
+
let e = U(de, Y(c)).toVar(), i = mo.wrap(tl(P, t, n, e, s, c, l, u, d, h, g, _, v, y));
|
|
7884
8113
|
p(i.valid.and(i.pdf.greaterThan(0)), () => {
|
|
7885
8114
|
let e = F(M(0), A(t, i.direction)).toVar(), a = i.emission.x.add(i.emission.y).add(i.emission.z);
|
|
7886
8115
|
p(e.greaterThan(0).and(a.mul(e).greaterThan(ce)).and(bo({
|
|
@@ -7889,7 +8118,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7889
8118
|
})), () => {
|
|
7890
8119
|
let a = le(i.distance.sub(.001), M(1e3)), o = ie(P, i.direction, a);
|
|
7891
8120
|
p(o.greaterThan(0).or(te), () => {
|
|
7892
|
-
let a = vi.wrap(Wi(t, r, i.direction)), s =
|
|
8121
|
+
let a = vi.wrap(Wi(t, r, i.direction)), s = Kc(n, a), c = nl(n, a).toVar(), l = M(1).toVar();
|
|
7893
8122
|
p(c.greaterThan(0).and(x), () => {
|
|
7894
8123
|
let e = i.pdf.mul(oe), t = c.mul(ae);
|
|
7895
8124
|
p(i.lightType.equal(N(1)), () => {
|
|
@@ -7914,7 +8143,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7914
8143
|
surfaceNormal: t
|
|
7915
8144
|
})), () => {
|
|
7916
8145
|
p(h.greaterThan(N(0)), () => {
|
|
7917
|
-
let
|
|
8146
|
+
let c = T(!1).toVar(), f = M(0).toVar(), b = N(-1).toVar();
|
|
7918
8147
|
m({
|
|
7919
8148
|
start: N(0),
|
|
7920
8149
|
end: h,
|
|
@@ -7926,27 +8155,25 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7926
8155
|
let o = oo(a, e, t, n).toVar();
|
|
7927
8156
|
p(o.greaterThanEqual(ce), () => {
|
|
7928
8157
|
p(jo(a, P, i).toVar().greaterThan(0), () => {
|
|
7929
|
-
p(o.greaterThan(
|
|
7930
|
-
|
|
7931
|
-
}),
|
|
8158
|
+
p(o.greaterThan(f), () => {
|
|
8159
|
+
f.assign(o), b.assign(r);
|
|
8160
|
+
}), c.assign(T(!0));
|
|
7932
8161
|
});
|
|
7933
8162
|
});
|
|
7934
8163
|
});
|
|
7935
|
-
}), p(
|
|
7936
|
-
let e = uo.wrap(_o(d,
|
|
7937
|
-
p(
|
|
7938
|
-
let
|
|
7939
|
-
p(
|
|
7940
|
-
let
|
|
7941
|
-
p(
|
|
7942
|
-
let i =
|
|
7943
|
-
i.divAssign(F(M(se), 1));
|
|
7944
|
-
let c = Vi({
|
|
8164
|
+
}), p(c.and(b.greaterThanEqual(N(0))), () => {
|
|
8165
|
+
let e = uo.wrap(_o(d, b)), c = jo(e, P, i).toVar();
|
|
8166
|
+
p(c.greaterThan(0), () => {
|
|
8167
|
+
let f = ie(P, i, le(c.sub(.001), M(1e3)));
|
|
8168
|
+
p(f.greaterThan(0).or(te), () => {
|
|
8169
|
+
let m = F(M(0), A(i, e.normal).negate()).toVar();
|
|
8170
|
+
p(m.greaterThan(0), () => {
|
|
8171
|
+
let i = c.mul(c), b = Mo(P, e.position.sub(e.u).sub(e.v), e.u.mul(2), e.v.mul(2)).toVar(), x = i.div(F(e.area.mul(m), ki)), S = R(e.shape.lessThan(.5).and(b.greaterThan(1e-5)), M(1).div(F(b, 1e-10)), x).toVar(), C = oo(e, P, t, n), w = il(P, t, n, s, l, u, d, h, g, _, v, y).toVar(), T = R(w.greaterThan(0), C.div(F(w, 1e-10)), M(1).div(F(M(se), 1))), E = S.mul(T).toVar(), D = Vi({
|
|
7945
8172
|
pdf1: a.mul(ae),
|
|
7946
|
-
pdf2:
|
|
7947
|
-
}).toVar(),
|
|
7948
|
-
ne.addAssign(
|
|
7949
|
-
re.addAssign(
|
|
8173
|
+
pdf2: E.mul(oe)
|
|
8174
|
+
}).toVar(), O = Zc(e).mul(Xc(m, e.spread)).mul(o).mul(r).mul(D).div(F(a, 1e-10)).mul(ue).div(F(ae, 1e-10));
|
|
8175
|
+
ne.addAssign(O.mul(f)), p(te, () => {
|
|
8176
|
+
re.addAssign(O);
|
|
7950
8177
|
});
|
|
7951
8178
|
});
|
|
7952
8179
|
});
|
|
@@ -7956,7 +8183,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7956
8183
|
});
|
|
7957
8184
|
});
|
|
7958
8185
|
}), p(ee, () => {
|
|
7959
|
-
let e = U(Y(c).toVar(), Y(c).toVar()).toVar(), i = W(0).toVar(), a =
|
|
8186
|
+
let e = U(Y(c).toVar(), Y(c).toVar()).toVar(), i = W(0).toVar(), a = Hc(C, D, E, w, O, k, j, e, i).toVar(), o = a.xyz.toVar(), s = a.w.toVar();
|
|
7960
8187
|
p(s.greaterThan(0), () => {
|
|
7961
8188
|
let e = F(M(0), A(t, o)).toVar();
|
|
7962
8189
|
p(e.greaterThan(0).and(bo({
|
|
@@ -7965,7 +8192,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7965
8192
|
})), () => {
|
|
7966
8193
|
let a = ie(P, o, M(1e3));
|
|
7967
8194
|
p(a.greaterThan(0).or(te), () => {
|
|
7968
|
-
let c = vi.wrap(Wi(t, r, o)), l =
|
|
8195
|
+
let c = vi.wrap(Wi(t, r, o)), l = Kc(n, c), u = nl(n, c).toVar(), d = R(u.greaterThan(0), Hi({
|
|
7969
8196
|
pdf1: s,
|
|
7970
8197
|
pdf2: u
|
|
7971
8198
|
}), M(1)).toVar(), f = i.mul(l).mul(e).mul(d).div(F(s, 1e-10));
|
|
@@ -7980,17 +8207,17 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7980
8207
|
shadowed: ne,
|
|
7981
8208
|
unoccluded: re
|
|
7982
8209
|
});
|
|
7983
|
-
}),
|
|
8210
|
+
}), ol = f(([e, t, n, r, i, a]) => {
|
|
7984
8211
|
let o = R(a, r, M(1).div(r)).toVar(), s = e.add(t.mul(o)).toVar(), c = A(s, s).toVar(), l = R(c.greaterThan(ki), s.div(xe(c)), n).toVar();
|
|
7985
8212
|
p(A(l, n).lessThan(0), () => {
|
|
7986
8213
|
l.assign(l.negate());
|
|
7987
8214
|
});
|
|
7988
8215
|
let u = _(A(e, l)), d = _(A(t, l)).toVar(), f = _(A(n, l)).toVar(), m = la(f, i), h = u.add(d.mul(o)).toVar(), g = h.mul(h), v = d.mul(o).mul(o).div(F(g, ki));
|
|
7989
8216
|
return m.mul(f).mul(v);
|
|
7990
|
-
}),
|
|
8217
|
+
}), sl = f(([e, t, n, r]) => {
|
|
7991
8218
|
let i = e.add(t).toVar(), a = A(i, i).toVar();
|
|
7992
8219
|
return ma(F(A(n, R(a.greaterThan(ki), i.div(xe(a)), n)), 0), F(A(n, e), 0), r);
|
|
7993
|
-
}),
|
|
8220
|
+
}), cl = f(([e]) => {
|
|
7994
8221
|
let t = e.specularImportance.toVar(), n = t.greaterThan(.001).toVar(), r = e.diffuseImportance.toVar(), i = r.greaterThan(.001).toVar(), a = e.transmissionImportance.toVar(), o = a.greaterThan(.001).toVar(), s = e.clearcoatImportance.toVar(), c = s.greaterThan(.001).toVar(), l = t.add(r).add(a).add(s).toVar();
|
|
7995
8222
|
return p(l.lessThan(.001), () => {
|
|
7996
8223
|
t.assign(0), r.assign(1), a.assign(0), s.assign(0), l.assign(1), n.assign(T(!1)), i.assign(T(!0)), o.assign(T(!1)), c.assign(T(!1));
|
|
@@ -8010,7 +8237,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8010
8237
|
useTransmission: o,
|
|
8011
8238
|
useClearcoat: c
|
|
8012
8239
|
});
|
|
8013
|
-
}),
|
|
8240
|
+
}), ll = f(([e, t]) => {
|
|
8014
8241
|
let n = N(2).toVar(), r = M(0).toVar(), i = T(!1).toVar();
|
|
8015
8242
|
return p(e.useSpecular.and(i.not()), () => {
|
|
8016
8243
|
r.addAssign(e.specularWeight), p(t.lessThan(r), () => {
|
|
@@ -8027,20 +8254,20 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8027
8254
|
}), p(e.useClearcoat.and(i.not()), () => {
|
|
8028
8255
|
n.assign(4);
|
|
8029
8256
|
}), n;
|
|
8030
|
-
}),
|
|
8257
|
+
}), ul = f(([e]) => F(e, 0).mul(Di)), dl = f(([e, t, n, r, i, a, o, s]) => {
|
|
8031
8258
|
let c = W(0).toVar(), l = W(0).toVar(), u = M(0).toVar(), d = M(0).toVar(), f = M(0).toVar();
|
|
8032
8259
|
return p(s.diffuseImportance.greaterThanEqual(0).and(s.specularImportance.greaterThanEqual(0)).and(s.transmissionImportance.greaterThanEqual(0)).and(s.clearcoatImportance.greaterThanEqual(0)).not(), () => {
|
|
8033
8260
|
let e = U(Y(o).toVar(), Y(o).toVar());
|
|
8034
8261
|
c.assign(xa(t, e)), l.assign(n.color.xyz), u.assign(1), d.assign(1);
|
|
8035
8262
|
}).Else(() => {
|
|
8036
|
-
let m = wi.wrap(
|
|
8263
|
+
let m = wi.wrap(cl(s).toVar()), h = Y(o).toVar(), g = U(Y(o).toVar(), Y(o).toVar()).toVar(), v = ll(m, h).toVar(), y = W(0).toVar(), b = M(0).toVar(), x = W(0).toVar();
|
|
8037
8264
|
p(v.equal(N(1)), () => {
|
|
8038
8265
|
y.assign(r), b.assign(i), x.assign(a);
|
|
8039
8266
|
}).ElseIf(v.equal(N(2)), () => {
|
|
8040
|
-
y.assign(xa(t, g)), b.assign(
|
|
8267
|
+
y.assign(xa(t, g)), b.assign(ul(F(A(t, y), 0))), x.assign(qc(e, y, t, n));
|
|
8041
8268
|
}).ElseIf(v.equal(N(3)), () => {
|
|
8042
8269
|
let r = A(e, t).greaterThan(0), i = Na.wrap(za(e, t, n.ior, n.roughness, r, n.dispersion, g, o, M(0)).toVar());
|
|
8043
|
-
y.assign(i.direction), b.assign(i.pdf), x.assign(
|
|
8270
|
+
y.assign(i.direction), b.assign(i.pdf), x.assign(qc(e, y, t, n));
|
|
8044
8271
|
}).Else(() => {
|
|
8045
8272
|
y.assign(r), b.assign(i), x.assign(a);
|
|
8046
8273
|
});
|
|
@@ -8049,12 +8276,12 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8049
8276
|
let r = ma(F(A(t, L(e.add(y))), .001), F(A(t, e), .001), n.roughness);
|
|
8050
8277
|
T.addAssign(m.specularWeight.mul(r));
|
|
8051
8278
|
}), p(m.useDiffuse, () => {
|
|
8052
|
-
T.addAssign(m.diffuseWeight.mul(
|
|
8279
|
+
T.addAssign(m.diffuseWeight.mul(ul(C)));
|
|
8053
8280
|
}), p(m.useTransmission.and(n.transmission.greaterThan(0)), () => {
|
|
8054
8281
|
let r = A(e, t).greaterThan(0);
|
|
8055
|
-
T.addAssign(m.transmissionWeight.mul(
|
|
8282
|
+
T.addAssign(m.transmissionWeight.mul(ol(e, y, t, n.ior, n.roughness, r)));
|
|
8056
8283
|
}), p(m.useClearcoat.and(n.clearcoat.greaterThan(0)), () => {
|
|
8057
|
-
T.addAssign(m.clearcoatWeight.mul(
|
|
8284
|
+
T.addAssign(m.clearcoatWeight.mul(sl(e, y, t, n.clearcoatRoughness)));
|
|
8058
8285
|
}), b.assign(F(b, Mi)), T.assign(F(T, Mi));
|
|
8059
8286
|
let E = b.div(T).toVar(), D = R(v.equal(N(3)), w, C);
|
|
8060
8287
|
c.assign(y), l.assign(x.mul(D).mul(E).div(b)), u.assign(E), d.assign(b), f.assign(T);
|
|
@@ -8065,7 +8292,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8065
8292
|
pdf: d,
|
|
8066
8293
|
combinedPdf: f
|
|
8067
8294
|
});
|
|
8068
|
-
}),
|
|
8295
|
+
}), fl = f(([e, t, n, r, i, a, o, s, c, l]) => {
|
|
8069
8296
|
let u = W(0).toVar(), d = W(0).toVar(), f = M(0).toVar(), m = s.toVar();
|
|
8070
8297
|
p(o.not(), () => {
|
|
8071
8298
|
p(c, () => {
|
|
@@ -8094,7 +8321,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8094
8321
|
xi: g
|
|
8095
8322
|
}));
|
|
8096
8323
|
let r = E(A(t, u), 0, 1);
|
|
8097
|
-
f.assign(r.mul(Di)), d.assign(
|
|
8324
|
+
f.assign(r.mul(Di)), d.assign(qc(e, u, t, n));
|
|
8098
8325
|
}).ElseIf(h.lessThan(y), () => {
|
|
8099
8326
|
let i = Ui({ N: t }), a = Sa({
|
|
8100
8327
|
V: i.transpose().mul(e),
|
|
@@ -8103,7 +8330,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8103
8330
|
});
|
|
8104
8331
|
_.assign(i.mul(a));
|
|
8105
8332
|
let o = E(A(t, _), .001, 1);
|
|
8106
|
-
u.assign(he(e.negate(), _)), f.assign(ma(o, S, n.roughness)), d.assign(
|
|
8333
|
+
u.assign(he(e.negate(), _)), f.assign(ma(o, S, n.roughness)), d.assign(qc(e, u, t, n));
|
|
8107
8334
|
}).ElseIf(h.lessThan(b), () => {
|
|
8108
8335
|
_.assign(ya({
|
|
8109
8336
|
N: t,
|
|
@@ -8117,9 +8344,9 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8117
8344
|
u.assign(ba({
|
|
8118
8345
|
N: t,
|
|
8119
8346
|
xi: r
|
|
8120
|
-
})), o.assign(E(A(t, u), 0, 1)), f.assign(o.mul(Di)), d.assign(
|
|
8347
|
+
})), o.assign(E(A(t, u), 0, 1)), f.assign(o.mul(Di)), d.assign(qc(e, u, t, n));
|
|
8121
8348
|
}).Else(() => {
|
|
8122
|
-
f.assign(ua(i, n.sheenRoughness).mul(i).div(M(4).mul(a))), f.assign(F(f, Mi)), d.assign(
|
|
8349
|
+
f.assign(ua(i, n.sheenRoughness).mul(i).div(M(4).mul(a))), f.assign(F(f, Mi)), d.assign(qc(e, u, t, n));
|
|
8123
8350
|
});
|
|
8124
8351
|
}).ElseIf(h.lessThan(x), () => {
|
|
8125
8352
|
let i = E(n.clearcoatRoughness, ji, 1);
|
|
@@ -8129,16 +8356,16 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8129
8356
|
Xi: r
|
|
8130
8357
|
}));
|
|
8131
8358
|
let a = E(A(t, _), 0, 1);
|
|
8132
|
-
u.assign(he(e.negate(), _)), f.assign(ma(a, S, i)), f.assign(F(f, Mi)), d.assign(
|
|
8359
|
+
u.assign(he(e.negate(), _)), f.assign(ma(a, S, i)), f.assign(F(f, Mi)), d.assign(qc(e, u, t, n));
|
|
8133
8360
|
}).Else(() => {
|
|
8134
8361
|
let a = A(e, t).greaterThan(0), o = Na.wrap(za(e, t, n.ior, n.roughness, a, n.dispersion, r, i, M(0)));
|
|
8135
|
-
u.assign(o.direction), f.assign(F(o.pdf, Mi)), d.assign(
|
|
8362
|
+
u.assign(o.direction), f.assign(F(o.pdf, Mi)), d.assign(qc(e, u, t, n));
|
|
8136
8363
|
}), f.assign(F(f, Mi)), hi({
|
|
8137
8364
|
direction: u,
|
|
8138
8365
|
value: d,
|
|
8139
8366
|
pdf: f
|
|
8140
8367
|
});
|
|
8141
|
-
}),
|
|
8368
|
+
}), pl = /* @__PURE__ */ K("\n fn regularizePathContribution( contribution: vec3f, pathLength: f32, fireflyThreshold: f32, frame: i32 ) -> vec3f {\n let threshold = calculateFireflyThreshold( fireflyThreshold, i32( pathLength ), frame );\n return applySoftSuppressionRGB( contribution, threshold, 0.5f );\n }\n", [Gi, qi]), ml = /* @__PURE__ */ K("\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"), hl = f(([e, t, n, r, i, a, o]) => {
|
|
8142
8369
|
let s = M(1).toVar();
|
|
8143
8370
|
return p(e.greaterThanEqual(N(3)), () => {
|
|
8144
8371
|
let c = F(F(F(t.x, t.y), t.z), 0).toVar();
|
|
@@ -8189,11 +8416,11 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8189
8416
|
});
|
|
8190
8417
|
});
|
|
8191
8418
|
}), s;
|
|
8192
|
-
}),
|
|
8419
|
+
}), gl = Cn({
|
|
8193
8420
|
brdf: "vec3",
|
|
8194
8421
|
L: "vec3",
|
|
8195
8422
|
pdf: "float"
|
|
8196
|
-
}),
|
|
8423
|
+
}), _l = f(([e, t, n, r, i]) => {
|
|
8197
8424
|
let a = t.normal, o = e.direction.negate(), s = F(n.clearcoatRoughness, ji), c = F(n.roughness, ji), l = M(1).sub(c).mul(M(.5).add(M(.5).mul(n.metalness))).toVar(), u = n.clearcoat.mul(M(1).sub(s)).toVar(), d = M(1).sub(l).mul(M(1).sub(n.metalness)).toVar(), f = l.add(u).add(d);
|
|
8198
8425
|
l.divAssign(f), u.divAssign(f), d.divAssign(f);
|
|
8199
8426
|
let m = Y(i), h = W(0).toVar(), g = W(0).toVar();
|
|
@@ -8216,22 +8443,22 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8216
8443
|
})), g.assign(L(o.add(h)));
|
|
8217
8444
|
});
|
|
8218
8445
|
let _ = vi.wrap(Wi(a, o, h)), v = la(_.NoH, s).mul(_.NoH).div(M(4).mul(_.VoH)).mul(u), y = la(_.NoH, c).mul(_.NoH).div(M(4).mul(_.VoH)).mul(l), b = _.NoL.div(Ei).mul(d), x = F(v.add(y).add(b), .001);
|
|
8219
|
-
return
|
|
8220
|
-
brdf:
|
|
8446
|
+
return gl({
|
|
8447
|
+
brdf: Jc(_, n),
|
|
8221
8448
|
L: h,
|
|
8222
8449
|
pdf: x
|
|
8223
8450
|
});
|
|
8224
|
-
}),
|
|
8451
|
+
}), vl = 32, yl = 16, bl = 5, xl = 1 / 1024, Sl = 8, Cl = Cn({
|
|
8225
8452
|
hitPoint: "vec3",
|
|
8226
8453
|
uv: "vec2",
|
|
8227
8454
|
normal: "vec3",
|
|
8228
8455
|
height: "float"
|
|
8229
|
-
}),
|
|
8230
|
-
let o = t.hitPoint.toVar(), s = t.uv.toVar(), c = t.normal.toVar(), l = M(0).toVar(), u = t.triangleIndex, d = $(n, u, N(0), N(
|
|
8456
|
+
}), wl = f(([e, t, n, r, i, a]) => {
|
|
8457
|
+
let o = t.hitPoint.toVar(), s = t.uv.toVar(), c = t.normal.toVar(), l = M(0).toVar(), u = t.triangleIndex, d = $(n, u, N(0), N(Sl)).xyz.toVar(), f = $(n, u, N(1), N(Sl)).xyz, h = $(n, u, N(2), N(Sl)).xyz, g = $(n, u, N(6), N(Sl)).toVar(), v = $(n, u, N(7), N(Sl)), y = g.xy.toVar(), b = g.zw, x = v.xy, S = f.sub(d).toVar(), C = h.sub(d).toVar(), w = b.sub(y).toVar(), T = x.sub(y).toVar(), E = w.x.mul(T.y).sub(T.x.mul(w.y)).toVar();
|
|
8231
8458
|
return p(_(E).greaterThan(1e-8), () => {
|
|
8232
8459
|
let n = M(1).div(E), u = S.mul(T.y).sub(C.mul(w.y)).mul(n).toVar(), d = C.mul(w.x).sub(S.mul(T.x)).mul(n).toVar(), f = t.normal.toVar(), h = i.displacementScale.div(M(10)), g = e.direction, v = A(g, f).toVar(), y = g.sub(f.mul(v)).toVar(), b = A(u, u), x = A(u, d), D = A(d, d), O = b.mul(D).sub(x.mul(x)).toVar();
|
|
8233
8460
|
p(_(O).greaterThan(1e-10), () => {
|
|
8234
|
-
let e = M(1).div(O), n = A(y, u), S = A(y, d), C = U(D.mul(n).sub(x.mul(S)).mul(e), b.mul(S).sub(x.mul(n)).mul(e)).toVar(), w = v.toVar(), T = F(_(w), .001), E = h.div(T).toVar(), k = N(a.equal(N(0)).select(N(
|
|
8461
|
+
let e = M(1).div(O), n = A(y, u), S = A(y, d), C = U(D.mul(n).sub(x.mul(S)).mul(e), b.mul(S).sub(x.mul(n)).mul(e)).toVar(), w = v.toVar(), T = F(_(w), .001), E = h.div(T).toVar(), k = N(a.equal(N(0)).select(N(vl), N(yl))).toVar(), j = E.negate().toVar(), ee = E.sub(j).div(M(k)).toVar(), te = j.toVar(), ne = j.toVar(), re = N(0).toVar();
|
|
8235
8462
|
m({
|
|
8236
8463
|
start: N(0),
|
|
8237
8464
|
end: k,
|
|
@@ -8250,7 +8477,7 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8250
8477
|
let e = te.toVar(), n = ne.toVar();
|
|
8251
8478
|
m({
|
|
8252
8479
|
start: N(0),
|
|
8253
|
-
end: N(
|
|
8480
|
+
end: N(bl),
|
|
8254
8481
|
type: "int",
|
|
8255
8482
|
condition: "<"
|
|
8256
8483
|
}, () => {
|
|
@@ -8261,17 +8488,17 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8261
8488
|
e.assign(a);
|
|
8262
8489
|
});
|
|
8263
8490
|
});
|
|
8264
|
-
let a = e.add(n).mul(.5).toVar(), _ = t.uv.add(C.mul(a)).toVar(), v = t.hitPoint.add(g.mul(a)), y = Qa(r, i.displacementMapIndex, _, i.displacementTransform), b = y.sub(.5).mul(h), x = M(
|
|
8491
|
+
let a = e.add(n).mul(.5).toVar(), _ = t.uv.add(C.mul(a)).toVar(), v = t.hitPoint.add(g.mul(a)), y = Qa(r, i.displacementMapIndex, _, i.displacementTransform), b = y.sub(.5).mul(h), x = M(xl), S = y, T = Qa(r, i.displacementMapIndex, _.add(U(x, 0)), i.displacementTransform), E = Qa(r, i.displacementMapIndex, _.add(U(0, x)), i.displacementTransform), D = L(u).toVar(), O = L(d).toVar(), k = T.sub(S).mul(h), A = E.sub(S).mul(h), j = L(f.sub(D.mul(k)).sub(O.mul(A)));
|
|
8265
8492
|
o.assign(v), s.assign(_), c.assign(j), l.assign(b);
|
|
8266
8493
|
});
|
|
8267
8494
|
});
|
|
8268
|
-
}),
|
|
8495
|
+
}), Cl({
|
|
8269
8496
|
hitPoint: o,
|
|
8270
8497
|
uv: s,
|
|
8271
8498
|
normal: c,
|
|
8272
8499
|
height: l
|
|
8273
8500
|
});
|
|
8274
|
-
}),
|
|
8501
|
+
}), Tl = Cn({
|
|
8275
8502
|
position: "vec3",
|
|
8276
8503
|
normal: "vec3",
|
|
8277
8504
|
emission: "vec3",
|
|
@@ -8281,40 +8508,40 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8281
8508
|
area: "float",
|
|
8282
8509
|
cosThetaLight: "float",
|
|
8283
8510
|
valid: "bool"
|
|
8284
|
-
}),
|
|
8511
|
+
}), El = Cn({
|
|
8285
8512
|
contribution: "vec3",
|
|
8286
8513
|
hasEmissive: "bool",
|
|
8287
8514
|
emissionOnly: "vec3",
|
|
8288
8515
|
distance: "float"
|
|
8289
|
-
}),
|
|
8516
|
+
}), Dl = f(([e, t, n, r]) => {
|
|
8290
8517
|
let i = xe(r.x), a = M(1).sub(i), o = r.y.mul(i), s = M(1).sub(a).sub(o);
|
|
8291
8518
|
return e.mul(a).add(t.mul(o)).add(n.mul(s));
|
|
8292
|
-
}),
|
|
8519
|
+
}), Ol = f(([e, t, n]) => ie(O(t.sub(e), n.sub(e))).mul(.5)), kl = f(([e, t, n, r]) => {
|
|
8293
8520
|
let i = L(e.sub(r)), a = L(t.sub(r)), o = L(n.sub(r)), s = _(A(i, O(a, o))), c = M(1).add(A(a, o)).add(A(i, o)).add(A(i, a));
|
|
8294
8521
|
return F(M(2).mul(b(s, F(c, M(1e-10)))), M(0));
|
|
8295
|
-
}),
|
|
8522
|
+
}), Al = f(([e, t, n, r]) => {
|
|
8296
8523
|
let i = t.sub(e), a = n.sub(e), o = n.sub(t), s = F(A(i, i), F(A(a, a), A(o, o))), c = O(i, a), l = A(c, c), u = T(!1).toVar();
|
|
8297
8524
|
return p(l.greaterThan(1e-20), () => {
|
|
8298
8525
|
let t = A(c, r.sub(e)), n = t.mul(t).div(l);
|
|
8299
8526
|
u.assign(s.greaterThan(n));
|
|
8300
8527
|
}), u;
|
|
8301
|
-
}),
|
|
8528
|
+
}), jl = Cn({
|
|
8302
8529
|
direction: "vec3",
|
|
8303
8530
|
position: "vec3",
|
|
8304
8531
|
solidAngle: "float",
|
|
8305
8532
|
valid: "bool"
|
|
8306
|
-
}),
|
|
8533
|
+
}), Ml = f(([e]) => {
|
|
8307
8534
|
let t = ie(e);
|
|
8308
8535
|
return R(t.greaterThan(1e-10), e.div(t), W(0));
|
|
8309
|
-
}),
|
|
8310
|
-
let a =
|
|
8536
|
+
}), Nl = f(([e, t, n, r, i]) => {
|
|
8537
|
+
let a = jl({
|
|
8311
8538
|
direction: W(0),
|
|
8312
8539
|
position: W(0),
|
|
8313
8540
|
solidAngle: M(0),
|
|
8314
8541
|
valid: !1
|
|
8315
|
-
}).toVar(), o = L(e.sub(r)), s = L(t.sub(r)), c = L(n.sub(r)), l =
|
|
8542
|
+
}).toVar(), o = L(e.sub(r)), s = L(t.sub(r)), c = L(n.sub(r)), l = kl(e, t, n, r);
|
|
8316
8543
|
return a.solidAngle.assign(l), p(l.greaterThan(1e-7), () => {
|
|
8317
|
-
let u = E(A(
|
|
8544
|
+
let u = E(A(Ml(O(o, s)), Ml(O(o, c))), -1, 1), d = xe(F(M(1).sub(u.mul(u)), 0)), f = v(u), m = i.x.mul(l).sub(f), h = ye(m), g = D(m), y = E(A(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(R(_(C).greaterThan(1e-10), S.div(C), M(1)), -1, 1), T = A(c, o), k = Ml(c.sub(o.mul(T))), j = xe(F(M(1).sub(w.mul(w)), 0)), ee = L(o.mul(w).add(k.mul(j))), te = A(ee, s), ne = M(1).sub(i.y.mul(M(1).sub(te))), re = xe(F(M(1).sub(ne.mul(ne)), 0)), N = Ml(ee.sub(s.mul(te))), P = L(s.mul(ne).add(N.mul(re))), ie = L(O(t.sub(e), n.sub(e))), ae = A(ie, P);
|
|
8318
8545
|
p(_(ae).greaterThan(1e-10), () => {
|
|
8319
8546
|
let t = A(ie, e.sub(r)).div(ae);
|
|
8320
8547
|
p(t.greaterThan(0), () => {
|
|
@@ -8322,15 +8549,15 @@ var jc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8322
8549
|
});
|
|
8323
8550
|
});
|
|
8324
8551
|
}), a;
|
|
8325
|
-
}),
|
|
8552
|
+
}), Pl = f(([e, t, n, r]) => {
|
|
8326
8553
|
let i = n.sub(t), a = r.sub(t), o = e.sub(t), s = A(i, i), c = A(i, a), l = A(a, a), u = A(o, i), d = A(o, a), f = M(1).div(F(s.mul(l).sub(c.mul(c)), M(1e-10))), p = l.mul(u).sub(c.mul(d)).mul(f), m = s.mul(d).sub(c.mul(u)).mul(f);
|
|
8327
8554
|
return W(M(1).sub(p).sub(m), p, m);
|
|
8328
|
-
}),
|
|
8555
|
+
}), Fl = f(([e, t, n, r]) => {
|
|
8329
8556
|
let i = xe(r.x), a = M(1).sub(i), o = r.y.mul(i), s = M(1).sub(a).sub(o);
|
|
8330
8557
|
return L(e.mul(a).add(t.mul(o)).add(n.mul(s)));
|
|
8331
8558
|
});
|
|
8332
8559
|
f(([e]) => e.emissiveIntensity.greaterThan(0).and(ie(e.emissive).greaterThan(0)));
|
|
8333
|
-
var
|
|
8560
|
+
var Il = 8, Ll = 2, Rl = Cn({
|
|
8334
8561
|
v0: "vec3",
|
|
8335
8562
|
v1: "vec3",
|
|
8336
8563
|
v2: "vec3",
|
|
@@ -8338,9 +8565,9 @@ var Tl = 8, El = 2, Dl = Cn({
|
|
|
8338
8565
|
n1: "vec3",
|
|
8339
8566
|
n2: "vec3",
|
|
8340
8567
|
materialIndex: "int"
|
|
8341
|
-
}),
|
|
8342
|
-
let n = $(t, e, N(0), N(
|
|
8343
|
-
return
|
|
8568
|
+
}), zl = f(([e, t]) => {
|
|
8569
|
+
let n = $(t, e, N(0), N(Il)), r = $(t, e, N(1), N(Il)), i = $(t, e, N(2), N(Il)), a = $(t, e, N(3), N(Il)), o = $(t, e, N(4), N(Il)), s = $(t, e, N(5), N(Il)), c = $(t, e, N(7), N(Il));
|
|
8570
|
+
return Rl({
|
|
8344
8571
|
v0: n.xyz,
|
|
8345
8572
|
v1: r.xyz,
|
|
8346
8573
|
v2: i.xyz,
|
|
@@ -8349,27 +8576,27 @@ var Tl = 8, El = 2, Dl = Cn({
|
|
|
8349
8576
|
n2: s.xyz,
|
|
8350
8577
|
materialIndex: N(c.z)
|
|
8351
8578
|
});
|
|
8352
|
-
}),
|
|
8353
|
-
let s =
|
|
8354
|
-
return p(
|
|
8355
|
-
let e =
|
|
8579
|
+
}), Bl = f(([e, t, n, r, i, a, o]) => {
|
|
8580
|
+
let s = Rl.wrap(zl(e, i)), c = Ol(s.v0, s.v1, s.v2), l = $(a, s.materialIndex, N(Fi.EMISSIVE_ROUGHNESS), Pi), u = $(a, s.materialIndex, N(Fi.IOR_TRANSMISSION), Pi), d = F(l.x.mul(.2126).add(l.y.mul(.7152)).add(l.z.mul(.0722)).mul(u.a).mul(c), M(1e-10)).div(F(o, M(1e-10))), f = M(0).toVar();
|
|
8581
|
+
return p(Al(s.v0, s.v1, s.v2, r), () => {
|
|
8582
|
+
let e = kl(s.v0, s.v1, s.v2, r);
|
|
8356
8583
|
f.assign(d.div(F(e, M(1e-10))));
|
|
8357
8584
|
}).Else(() => {
|
|
8358
8585
|
let e = L(O(s.v1.sub(s.v0), s.v2.sub(s.v0))), r = F(A(n.negate(), e), .001), i = t.mul(t), a = d.div(c);
|
|
8359
8586
|
f.assign(a.mul(i).div(r));
|
|
8360
8587
|
}), F(f, Mi);
|
|
8361
|
-
}),
|
|
8588
|
+
}), Vl = f(([e, t, n, r]) => {
|
|
8362
8589
|
let i = N(0).toVar(), a = n.sub(1).toVar();
|
|
8363
8590
|
return m(i.lessThan(a), () => {
|
|
8364
|
-
let n = i.add(a).div(2).toVar(), o = e.element(t.add(n.mul(N(
|
|
8591
|
+
let n = i.add(a).div(2).toVar(), o = e.element(t.add(n.mul(N(Ll)))).b;
|
|
8365
8592
|
p(o.lessThan(r), () => {
|
|
8366
8593
|
i.assign(n.add(1));
|
|
8367
8594
|
}).Else(() => {
|
|
8368
8595
|
a.assign(n);
|
|
8369
8596
|
});
|
|
8370
8597
|
}), i;
|
|
8371
|
-
}),
|
|
8372
|
-
let c =
|
|
8598
|
+
}), Hl = f(([e, t, n, r, i, a, o, s]) => {
|
|
8599
|
+
let c = Tl({
|
|
8373
8600
|
position: W(0),
|
|
8374
8601
|
normal: W(0),
|
|
8375
8602
|
emission: W(0),
|
|
@@ -8381,40 +8608,40 @@ var Tl = 8, El = 2, Dl = Cn({
|
|
|
8381
8608
|
valid: !1
|
|
8382
8609
|
}).toVar();
|
|
8383
8610
|
return p(a.greaterThan(N(0)), () => {
|
|
8384
|
-
let l =
|
|
8385
|
-
p(
|
|
8386
|
-
let n =
|
|
8611
|
+
let l = Vl(r, i, a, Y(n)).toVar(), u = i.add(l.mul(N(Ll))), d = r.element(u), f = r.element(u.add(1)), m = N(d.r), h = F(d.g, M(1e-10)), g = f.xyz, _ = f.w, v = Rl.wrap(zl(m, s)), y = U(Y(n).toVar(), Y(n).toVar()), b = L(O(v.v1.sub(v.v0), v.v2.sub(v.v0)));
|
|
8612
|
+
p(Al(v.v0, v.v1, v.v2, e), () => {
|
|
8613
|
+
let n = jl.wrap(Nl(v.v0, v.v1, v.v2, e, y));
|
|
8387
8614
|
p(n.valid.and(n.solidAngle.greaterThan(1e-7)), () => {
|
|
8388
8615
|
let r = n.direction, i = n.position, a = A(r, t), s = A(r, b.negate());
|
|
8389
8616
|
p(a.greaterThan(0).and(s.greaterThan(0)), () => {
|
|
8390
|
-
let t =
|
|
8617
|
+
let t = Pl(i, v.v0, v.v1, v.v2), a = L(v.n0.mul(t.x).add(v.n1.mul(t.y)).add(v.n2.mul(t.z))), l = ie(i.sub(e)), u = h.div(F(o, M(1e-10))).div(n.solidAngle);
|
|
8391
8618
|
c.position.assign(i), c.normal.assign(a), c.emission.assign(g), c.direction.assign(r), c.distance.assign(l), c.pdf.assign(F(u, Mi)), c.area.assign(_), c.cosThetaLight.assign(s), c.valid.assign(!0);
|
|
8392
8619
|
});
|
|
8393
8620
|
});
|
|
8394
8621
|
}).Else(() => {
|
|
8395
|
-
let n =
|
|
8622
|
+
let n = Dl(v.v0, v.v1, v.v2, y), r = Fl(v.n0, v.n1, v.n2, y), i = n.sub(e), a = A(i, i), s = xe(a), l = i.div(s), u = A(l, t), d = A(l, r.negate());
|
|
8396
8623
|
p(u.greaterThan(0).and(d.greaterThan(0)), () => {
|
|
8397
8624
|
let e = h.div(F(o, M(1e-10)).mul(_)).mul(a).div(d);
|
|
8398
8625
|
c.position.assign(n), c.normal.assign(r), c.emission.assign(g), c.direction.assign(l), c.distance.assign(s), c.pdf.assign(F(e, Mi)), c.area.assign(_), c.cosThetaLight.assign(d), c.valid.assign(!0);
|
|
8399
8626
|
});
|
|
8400
8627
|
});
|
|
8401
8628
|
}), c;
|
|
8402
|
-
}),
|
|
8403
|
-
let h =
|
|
8629
|
+
}), Ul = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m]) => {
|
|
8630
|
+
let h = El({
|
|
8404
8631
|
contribution: W(0),
|
|
8405
8632
|
hasEmissive: !1,
|
|
8406
8633
|
emissionOnly: W(0),
|
|
8407
8634
|
distance: M(0)
|
|
8408
8635
|
}).toVar();
|
|
8409
8636
|
return p(i.greaterThan(N(1)).and(r.roughness.greaterThan(.9)).and(r.metalness.lessThan(.1)).not(), () => {
|
|
8410
|
-
let i =
|
|
8637
|
+
let i = Tl.wrap(Hl(e, t, a, s, c, l, u, d));
|
|
8411
8638
|
p(i.valid.and(i.pdf.greaterThan(0)), () => {
|
|
8412
8639
|
h.hasEmissive.assign(!0), h.emissionOnly.assign(i.emission), h.distance.assign(i.distance);
|
|
8413
8640
|
let a = F(M(0), A(t, i.direction));
|
|
8414
8641
|
p(a.greaterThan(0), () => {
|
|
8415
8642
|
let s = m(e, t, r), c = e.add(s), l = i.distance.sub(.001), u = f(c, i.direction, l);
|
|
8416
8643
|
p(u.greaterThan(0), () => {
|
|
8417
|
-
let e = vi.wrap(Wi(t, n, i.direction)), s =
|
|
8644
|
+
let e = vi.wrap(Wi(t, n, i.direction)), s = Kc(r, e), c = nl(r, e), l = R(c.greaterThan(0), Vi({
|
|
8418
8645
|
pdf1: i.pdf,
|
|
8419
8646
|
pdf2: c
|
|
8420
8647
|
}), M(1));
|
|
@@ -8423,11 +8650,11 @@ var Tl = 8, El = 2, Dl = Cn({
|
|
|
8423
8650
|
});
|
|
8424
8651
|
});
|
|
8425
8652
|
}), h;
|
|
8426
|
-
}),
|
|
8427
|
-
let o = e.add(n).mul(.5), s = ie(n.sub(e)), c = a.sub(o), l = F(A(c, c), M(1e-12)), u = F(l, s.mul(.5)), d = A(r, c.div(xe(l))), f = xe(F(M(1).sub(d.mul(d)), M(0))), p = s.mul(s).mul(.25), m = E(p.div(l), M(0), M(1)), h = R(l.lessThan(p), M(-1), xe(F(M(1).sub(m), M(0)))), g = xe(F(M(1).sub(h.mul(h)), M(0))), _ = xe(F(M(1).sub(i.mul(i)), M(0))), v =
|
|
8653
|
+
}), Wl = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, p]) => El.wrap(Ul(e, t, n, r, i, a, o, s, c, l, u, d, f, p)).contribution), Gl = 4, Kl = 2, ql = 32, Jl = f(([e, t, n, r]) => R(t.greaterThan(r), M(1), t.mul(r).add(e.mul(n)))), Yl = f(([e, t, n, r]) => R(t.greaterThan(r), M(0), e.mul(r).sub(t.mul(n)))), Xl = f(([e, t, n, r, i, a]) => {
|
|
8654
|
+
let o = e.add(n).mul(.5), s = ie(n.sub(e)), c = a.sub(o), l = F(A(c, c), M(1e-12)), u = F(l, s.mul(.5)), d = A(r, c.div(xe(l))), f = xe(F(M(1).sub(d.mul(d)), M(0))), p = s.mul(s).mul(.25), m = E(p.div(l), M(0), M(1)), h = R(l.lessThan(p), M(-1), xe(F(M(1).sub(m), M(0)))), g = xe(F(M(1).sub(h.mul(h)), M(0))), _ = xe(F(M(1).sub(i.mul(i)), M(0))), v = Jl(f, d, _, i), y = Jl(Yl(f, d, _, i), v, g, h);
|
|
8428
8655
|
return F(R(y.greaterThan(M(0)), t.mul(y).div(u), M(0)), M(0));
|
|
8429
|
-
}),
|
|
8430
|
-
let s =
|
|
8656
|
+
}), Zl = f(([e, t, n, r, i, a, o]) => {
|
|
8657
|
+
let s = Tl({
|
|
8431
8658
|
position: W(0),
|
|
8432
8659
|
normal: W(0),
|
|
8433
8660
|
emission: W(0),
|
|
@@ -8438,12 +8665,12 @@ var Tl = 8, El = 2, Dl = Cn({
|
|
|
8438
8665
|
cosThetaLight: M(0),
|
|
8439
8666
|
valid: !1
|
|
8440
8667
|
}).toVar(), c = M(1).toVar(), l = N(0).toVar(), u = T(!1).toVar();
|
|
8441
|
-
return m(
|
|
8442
|
-
let t = l.mul(N(
|
|
8668
|
+
return m(ql, () => {
|
|
8669
|
+
let t = l.mul(N(Gl)), i = r.element(t.add(N(1))), a = r.element(t.add(N(2)));
|
|
8443
8670
|
p(i.w.greaterThan(.5), () => {
|
|
8444
8671
|
u.assign(T(!0)), d();
|
|
8445
8672
|
});
|
|
8446
|
-
let o = N(a.x), s = N(a.y), f = o.mul(N(
|
|
8673
|
+
let o = N(a.x), s = N(a.y), f = o.mul(N(Gl)), m = r.element(f), h = r.element(f.add(N(1))), g = s.mul(N(Gl)), _ = r.element(g), v = r.element(g.add(N(1))), y = r.element(f.add(N(3))), b = r.element(g.add(N(3))), x = Xl(m.xyz, m.w, h.xyz, y.xyz, y.w, e), S = Xl(_.xyz, _.w, v.xyz, b.xyz, b.w, e), C = x.add(S);
|
|
8447
8674
|
p(C.lessThanEqual(M(0)), () => {
|
|
8448
8675
|
l.assign(o);
|
|
8449
8676
|
}).Else(() => {
|
|
@@ -8455,44 +8682,44 @@ var Tl = 8, El = 2, Dl = Cn({
|
|
|
8455
8682
|
});
|
|
8456
8683
|
});
|
|
8457
8684
|
}), p(u, () => {
|
|
8458
|
-
let u = l.mul(N(
|
|
8685
|
+
let u = l.mul(N(Gl)), f = r.element(u), h = r.element(u.add(N(2))), g = N(h.x), _ = N(h.y), v = F(f.w, M(1e-10)), y = Y(n).mul(v), b = M(0).toVar(), x = g.add(_.sub(N(1))).toVar(), S = M(1e-10).toVar();
|
|
8459
8686
|
m({
|
|
8460
8687
|
start: N(0),
|
|
8461
8688
|
end: _
|
|
8462
8689
|
}, ({ i: e }) => {
|
|
8463
|
-
let t = g.add(e), n = a.add(t.mul(N(
|
|
8690
|
+
let t = g.add(e), n = a.add(t.mul(N(Kl))), r = F(i.element(n).g, M(0));
|
|
8464
8691
|
b.addAssign(r), p(b.greaterThanEqual(y).and(r.greaterThan(M(0))), () => {
|
|
8465
8692
|
x.assign(t), S.assign(r), d();
|
|
8466
8693
|
});
|
|
8467
8694
|
}), c.mulAssign(S.div(v));
|
|
8468
|
-
let C = a.add(x.mul(N(
|
|
8469
|
-
p(
|
|
8470
|
-
let n =
|
|
8695
|
+
let C = a.add(x.mul(N(Kl))), w = i.element(C), T = i.element(C.add(N(1))), E = N(w.r), D = T.xyz, k = T.w, j = Rl.wrap(zl(E, o)), ee = U(Y(n).toVar(), Y(n).toVar()), te = L(O(j.v1.sub(j.v0), j.v2.sub(j.v0)));
|
|
8696
|
+
p(Al(j.v0, j.v1, j.v2, e), () => {
|
|
8697
|
+
let n = jl.wrap(Nl(j.v0, j.v1, j.v2, e, ee));
|
|
8471
8698
|
p(n.valid.and(n.solidAngle.greaterThan(M(1e-7))), () => {
|
|
8472
8699
|
let r = n.direction, i = n.position, a = A(r, t), o = A(r, te.negate());
|
|
8473
8700
|
p(a.greaterThan(M(0)).and(o.greaterThan(M(0))), () => {
|
|
8474
|
-
let t =
|
|
8701
|
+
let t = Pl(i, j.v0, j.v1, j.v2), a = L(j.n0.mul(t.x).add(j.n1.mul(t.y)).add(j.n2.mul(t.z))), l = ie(i.sub(e)), u = c.div(F(n.solidAngle, M(1e-10)));
|
|
8475
8702
|
s.position.assign(i), s.normal.assign(a), s.emission.assign(D), s.direction.assign(r), s.distance.assign(l), s.pdf.assign(F(u, Mi)), s.area.assign(k), s.cosThetaLight.assign(o), s.valid.assign(!0);
|
|
8476
8703
|
});
|
|
8477
8704
|
});
|
|
8478
8705
|
}).Else(() => {
|
|
8479
|
-
let n =
|
|
8706
|
+
let n = Dl(j.v0, j.v1, j.v2, ee), r = Fl(j.n0, j.n1, j.n2, ee), i = n.sub(e), a = A(i, i), o = xe(a), l = i.div(o), u = A(l, t), d = A(l, r.negate());
|
|
8480
8707
|
p(u.greaterThan(M(0)).and(d.greaterThan(M(0))), () => {
|
|
8481
8708
|
let e = c.div(F(k, M(1e-10))).mul(a).div(d);
|
|
8482
8709
|
s.position.assign(n), s.normal.assign(r), s.emission.assign(D), s.direction.assign(l), s.distance.assign(o), s.pdf.assign(F(e, Mi)), s.area.assign(k), s.cosThetaLight.assign(d), s.valid.assign(!0);
|
|
8483
8710
|
});
|
|
8484
8711
|
});
|
|
8485
8712
|
}), s;
|
|
8486
|
-
}),
|
|
8713
|
+
}), Ql = f(([e, t, n, r, i, a, o, s]) => {
|
|
8487
8714
|
let c = M(0).toVar(), l = N(e).toVar(), u = i.element(o.add(l.shiftRight(N(2)))), f = l.bitAnd(N(3)), h = R(f.equal(N(0)), u.x, R(f.equal(N(1)), u.y, R(f.equal(N(2)), u.z, u.w))).toVar();
|
|
8488
8715
|
return p(h.greaterThanEqual(M(0)), () => {
|
|
8489
8716
|
let e = N(h).toVar(), o = M(1).toVar(), u = N(0).toVar(), f = N(0).toVar(), g = T(!1).toVar();
|
|
8490
|
-
m(
|
|
8491
|
-
let t = u.mul(N(
|
|
8717
|
+
m(ql, () => {
|
|
8718
|
+
let t = u.mul(N(Gl));
|
|
8492
8719
|
p(i.element(t.add(N(1))).w.greaterThan(.5), () => {
|
|
8493
8720
|
g.assign(T(!0)), d();
|
|
8494
8721
|
});
|
|
8495
|
-
let n = i.element(t.add(N(2))), a = N(n.x), s = N(n.y), c = a.mul(N(
|
|
8722
|
+
let n = i.element(t.add(N(2))), a = N(n.x), s = N(n.y), c = a.mul(N(Gl)), l = i.element(c), m = i.element(c.add(N(1))), h = i.element(c.add(N(3))), _ = s.mul(N(Gl)), v = i.element(_), y = i.element(_.add(N(1))), b = i.element(_.add(N(3))), x = Xl(l.xyz, l.w, m.xyz, h.xyz, h.w, r), S = Xl(v.xyz, v.w, y.xyz, b.xyz, b.w, r), C = x.add(S), w = e.shiftRight(f).bitAnd(N(1)).equal(N(1));
|
|
8496
8723
|
p(C.lessThanEqual(M(0)), () => {
|
|
8497
8724
|
p(w, () => {
|
|
8498
8725
|
o.assign(M(0)), u.assign(s);
|
|
@@ -8508,28 +8735,28 @@ var Tl = 8, El = 2, Dl = Cn({
|
|
|
8508
8735
|
});
|
|
8509
8736
|
}), f.addAssign(N(1));
|
|
8510
8737
|
}), p(g.and(o.greaterThan(M(0))), () => {
|
|
8511
|
-
let e = u.mul(N(
|
|
8738
|
+
let e = u.mul(N(Gl)), f = i.element(e), h = i.element(e.add(N(2))), g = N(h.x), _ = N(h.y), v = F(f.w, M(1e-10)), y = M(0).toVar();
|
|
8512
8739
|
m({
|
|
8513
8740
|
start: N(0),
|
|
8514
8741
|
end: _
|
|
8515
8742
|
}, ({ i: e }) => {
|
|
8516
|
-
let t = g.add(e), n = i.element(a.add(t.mul(N(
|
|
8743
|
+
let t = g.add(e), n = i.element(a.add(t.mul(N(Kl))));
|
|
8517
8744
|
p(N(n.r).equal(l), () => {
|
|
8518
8745
|
y.assign(F(n.g, M(0))), d();
|
|
8519
8746
|
});
|
|
8520
8747
|
}), o.mulAssign(y.div(v));
|
|
8521
|
-
let b =
|
|
8522
|
-
p(
|
|
8523
|
-
let e =
|
|
8748
|
+
let b = Rl.wrap(zl(l, s));
|
|
8749
|
+
p(Al(b.v0, b.v1, b.v2, r), () => {
|
|
8750
|
+
let e = kl(b.v0, b.v1, b.v2, r);
|
|
8524
8751
|
c.assign(o.div(F(e, M(1e-10))));
|
|
8525
8752
|
}).Else(() => {
|
|
8526
|
-
let e = L(O(b.v1.sub(b.v0), b.v2.sub(b.v0))), r = F(A(n.negate(), e), M(.001)), i =
|
|
8753
|
+
let e = L(O(b.v1.sub(b.v0), b.v2.sub(b.v0))), r = F(A(n.negate(), e), M(.001)), i = Ol(b.v0, b.v1, b.v2), a = t.mul(t), s = o.div(F(i, M(1e-10)));
|
|
8527
8754
|
c.assign(s.mul(a).div(r));
|
|
8528
8755
|
});
|
|
8529
8756
|
});
|
|
8530
8757
|
}), F(c, Mi);
|
|
8531
|
-
}),
|
|
8532
|
-
function
|
|
8758
|
+
}), $l = 0x8ac7230489e80000, eu = 1e-4, tu = 1e-4, nu = .001;
|
|
8759
|
+
function ru(e) {
|
|
8533
8760
|
let { bvhBuffer: t, triangleBuffer: n, materialBuffer: r, envCDFTexture: i, lightBuffer: a, rayBufferRW: o, rngBufferRW: s, hitBufferRO: c, gBufferRW: l, counters: u, activeIndicesRO: d, albedoMaps: g, normalMaps: _, bumpMaps: v, metalnessMaps: y, roughnessMaps: b, emissiveMaps: x, displacementMaps: C, envTexture: w, environmentIntensity: D, envMatrix: O, enableEnvironmentLight: k, useEnvMapIS: ee, groundProjectionEnabled: te, groundProjectionRadius: ne, groundProjectionHeight: P, groundProjectionLevel: ae, enableGroundCatcher: oe, groundCatcherHeight: ce, envTotalSum: le, envCompensationDelta: I, envResolution: ue, directionalLightsBuffer: de, numDirectionalLights: fe, areaLightsBuffer: pe, numAreaLights: me, pointLightsBuffer: he, numPointLights: ge, spotLightsBuffer: ve, numSpotLights: ye, maxBounceCount: be, maxSubsurfaceSteps: xe, currentBounce: Se, transparentBackground: Ce, backgroundIntensity: we, backgroundColor: Te, backgroundBlurriness: Ee, backgroundBlurSamples: De, showBackground: Oe, globalIlluminationIntensity: ke, cameraProjectionMatrix: z, cameraViewMatrix: Ae, fireflyThreshold: je, frame: V, resolution: Me, emissiveTriangleCount: Ne, emissiveVec4Offset: Pe, emissiveTotalPower: Fe, emissiveBoost: Ie, totalTriangleCount: H, enableEmissiveTriangleSampling: K, lightBVHNodeCount: Le, reverseMapVec4Offset: Re, maxRayCount: ze, auxGBufferEnabled: Be } = e, Ve = Be.greaterThan(B(0)), He = a !== void 0, Ue = (e, t, n, r) => {
|
|
8534
8761
|
let i = L(e).toVar(), a = F(n, N(1)).toVar(), o = W(0).toVar();
|
|
8535
8762
|
return m({
|
|
@@ -8539,7 +8766,7 @@ function Kl(e) {
|
|
|
8539
8766
|
condition: "<"
|
|
8540
8767
|
}, () => {
|
|
8541
8768
|
let e = Ao(i, t, U(Y(r).toVar(), Y(r).toVar())).toVar();
|
|
8542
|
-
o.addAssign(
|
|
8769
|
+
o.addAssign(Uc({
|
|
8543
8770
|
tex: w,
|
|
8544
8771
|
samp: _e(w),
|
|
8545
8772
|
direction: e,
|
|
@@ -8550,30 +8777,30 @@ function Kl(e) {
|
|
|
8550
8777
|
}), o.div(M(a));
|
|
8551
8778
|
};
|
|
8552
8779
|
return f(() => {
|
|
8553
|
-
let e = re, m = u ? S(u.element(B(
|
|
8780
|
+
let e = re, m = u ? S(u.element(B(mc.ENTERING_COUNT))) : ze;
|
|
8554
8781
|
p(e.greaterThanEqual(m), () => {
|
|
8555
8782
|
h();
|
|
8556
8783
|
});
|
|
8557
|
-
let H = d.element(e), Be =
|
|
8558
|
-
p(Be.bitAnd(B(
|
|
8784
|
+
let H = d.element(e), Be = Vs(o, H).toVar();
|
|
8785
|
+
p(Be.bitAnd(B(hc.ACTIVE)).equal(B(0)), () => {
|
|
8559
8786
|
h();
|
|
8560
8787
|
});
|
|
8561
|
-
let We = Be.bitAnd(B(
|
|
8788
|
+
let We = Be.bitAnd(B(hc.REDIRECTED)).equal(B(0)).toVar(), Ge = zs(o, H).toVar(), Ke = Bs(o, H).toVar(), qe = Hs(o, H).toVar(), Je = Ws(o, H).toVar(), Ye = H, Xe = s.element(H).toVar(), Ze = ec(c, H).toVar(), Qe = rc(c, H).toVar(), $e = nc(c, H).toVar(), et = ic(c, H).toVar(), tt = tc(c, H).toVar(), nt = uc(o, H).toVar(), rt = N(Se).toVar(), it = dc(o, H).toVar();
|
|
8562
8789
|
p(oe.and(rt.equal(0)), () => {
|
|
8563
8790
|
let e = Ke.y.toVar();
|
|
8564
8791
|
p(e.abs().greaterThan(M(ki)), () => {
|
|
8565
8792
|
let a = ce.sub(Ge.y).div(e).toVar();
|
|
8566
|
-
p(a.greaterThan(M(
|
|
8567
|
-
let e = Ge.add(Ke.mul(a)).toVar(), c = W(0, 1, 0), u = Ke.negate().toVar(), d = di.wrap(Qi()).toVar(), f = xa(c, U(Y(Xe).toVar(), Y(Xe).toVar())).toVar(), m = f.y.mul(Di).toVar(), g = W(Di), _ = pi.wrap(
|
|
8568
|
-
p(y.lessThan(M(
|
|
8793
|
+
p(a.greaterThan(M(eu)).and(a.lessThan(Ze)), () => {
|
|
8794
|
+
let e = Ge.add(Ke.mul(a)).toVar(), c = W(0, 1, 0), u = Ke.negate().toVar(), d = di.wrap(Qi()).toVar(), f = xa(c, U(Y(Xe).toVar(), Y(Xe).toVar())).toVar(), m = f.y.mul(Di).toVar(), g = W(Di), _ = pi.wrap(al(e, c, d, u, f, m, g, rt, Xe, de, fe, pe, me, he, ge, ve, ye, t, n, r, w, D, O, i, le, I, ue, k, T(!0))).toVar(), v = F(A(_.shadowed, Ni), M(0)), y = F(A(_.unoccluded, Ni), M(0)).toVar(), b = E(v.div(F(y, M(tu))), 0, 1).toVar();
|
|
8795
|
+
p(y.lessThan(M(nu)), () => {
|
|
8569
8796
|
b.assign(1);
|
|
8570
8797
|
});
|
|
8571
|
-
let x =
|
|
8798
|
+
let x = Gc(Ge, Ke, te, ne, P, ae).toVar(), S = W(0).toVar();
|
|
8572
8799
|
p(Oe, () => {
|
|
8573
8800
|
p(Ee.greaterThan(0), () => {
|
|
8574
8801
|
S.assign(Ue(x, Ee.mul(1.3), De, Xe));
|
|
8575
8802
|
}).Else(() => {
|
|
8576
|
-
S.assign(
|
|
8803
|
+
S.assign(Uc({
|
|
8577
8804
|
tex: w,
|
|
8578
8805
|
samp: _e(w),
|
|
8579
8806
|
direction: x,
|
|
@@ -8585,26 +8812,26 @@ function Kl(e) {
|
|
|
8585
8812
|
});
|
|
8586
8813
|
let C = R(Oe, S.mul(we), Te), j = R(Ce, W(0), C.mul(b)), ee = R(Ce, M(1).sub(b), M(1));
|
|
8587
8814
|
p(Ve, () => {
|
|
8588
|
-
|
|
8815
|
+
Ks(l, Ye, c, ml({
|
|
8589
8816
|
worldPos: e,
|
|
8590
8817
|
cameraProjectionMatrix: z,
|
|
8591
8818
|
cameraViewMatrix: Ae
|
|
8592
8819
|
}), W(1));
|
|
8593
|
-
}),
|
|
8820
|
+
}), $s(o, H, G(j, ee)), Zs(o, H, Ke, Be.bitAnd(B(~hc.ACTIVE))), s.element(H).assign(Xe), h();
|
|
8594
8821
|
});
|
|
8595
8822
|
});
|
|
8596
|
-
}), p(Ze.greaterThan(
|
|
8823
|
+
}), p(Ze.greaterThan($l), () => {
|
|
8597
8824
|
let e = We.and(Oe), t = We.not().and(k);
|
|
8598
8825
|
p(e.or(t), () => {
|
|
8599
8826
|
let e = Ke.toVar();
|
|
8600
8827
|
p(We, () => {
|
|
8601
|
-
e.assign(
|
|
8828
|
+
e.assign(Gc(Ge, Ke, te, ne, P, ae));
|
|
8602
8829
|
});
|
|
8603
8830
|
let t = W(0).toVar();
|
|
8604
8831
|
p(We.and(Ee.greaterThan(0)), () => {
|
|
8605
8832
|
t.assign(Ue(e, Ee.mul(1.3), De, Xe));
|
|
8606
8833
|
}).Else(() => {
|
|
8607
|
-
t.assign(
|
|
8834
|
+
t.assign(Uc({
|
|
8608
8835
|
tex: w,
|
|
8609
8836
|
samp: _e(w),
|
|
8610
8837
|
direction: e,
|
|
@@ -8615,9 +8842,9 @@ function Kl(e) {
|
|
|
8615
8842
|
});
|
|
8616
8843
|
let n = M(1).toVar();
|
|
8617
8844
|
p(We.not().and(ee), () => {
|
|
8618
|
-
let e =
|
|
8845
|
+
let e = Us(o, H);
|
|
8619
8846
|
p(e.greaterThan(0), () => {
|
|
8620
|
-
let t =
|
|
8847
|
+
let t = Vc(w, Ke, O, le, I, ue).w;
|
|
8621
8848
|
p(t.greaterThan(0), () => {
|
|
8622
8849
|
n.assign(Hi({
|
|
8623
8850
|
pdf1: e,
|
|
@@ -8627,16 +8854,16 @@ function Kl(e) {
|
|
|
8627
8854
|
});
|
|
8628
8855
|
});
|
|
8629
8856
|
let r = R(We.not(), ke, M(1)), i = R(We, we, n.mul(r)), a = R(We, M(0), M(rt));
|
|
8630
|
-
Je.assign(G(Je.xyz.add(
|
|
8857
|
+
Je.assign(G(Je.xyz.add(pl(qe.mul(t).mul(i), a, je, N(V))), Je.w));
|
|
8631
8858
|
}), p(We.and(Oe.not()).and(Ce.not()), () => {
|
|
8632
8859
|
Je.assign(G(Je.xyz.add(qe.mul(Te)), Je.w));
|
|
8633
|
-
}), p(Ce.and(Be.bitAnd(B(
|
|
8860
|
+
}), p(Ce.and(Be.bitAnd(B(hc.HAS_HIT_OPAQUE)).equal(B(0))), () => {
|
|
8634
8861
|
Je.w.assign(0);
|
|
8635
|
-
}),
|
|
8862
|
+
}), $s(o, H, Je), Zs(o, H, Ke, Be.bitAnd(B(~hc.ACTIVE))), h();
|
|
8636
8863
|
});
|
|
8637
|
-
let at = Ge.add(Ke.mul(Ze)).toVar(), ot = L(Qe).toVar(), st =
|
|
8864
|
+
let at = Ge.add(Ke.mul(Ze)).toVar(), ot = L(Qe).toVar(), st = oc(o, H), q = N(st.stackDepth).toVar(), ct = st.ior1.toVar(), lt = st.ior2.toVar(), ut = st.ior3.toVar(), dt = N(st.transTraversals).toVar(), J = M(st.wavelength).toVar();
|
|
8638
8865
|
p(q.greaterThan(0), () => {
|
|
8639
|
-
let e =
|
|
8866
|
+
let e = cc(o, H).toVar(), t = fc(o, H), n = t.sigmaS.toVar(), r = t.g.toVar();
|
|
8640
8867
|
p(F(F(n.x, n.y), n.z).lessThanEqual(0), () => {
|
|
8641
8868
|
qe.mulAssign(j(e.mul(Ze).negate()));
|
|
8642
8869
|
}).Else(() => {
|
|
@@ -8646,8 +8873,8 @@ function Kl(e) {
|
|
|
8646
8873
|
it.addAssign(1);
|
|
8647
8874
|
let a = E(F(F(qe.x, qe.y), qe.z), .02, 1).toVar();
|
|
8648
8875
|
p(it.greaterThanEqual(xe).or(Y(Xe).greaterThan(a)).toVar(), () => {
|
|
8649
|
-
|
|
8650
|
-
}), qe.divAssign(a), Be.assign(Be.bitOr(B(
|
|
8876
|
+
$s(o, H, Je), Zs(o, H, Ke, Be.bitAnd(B(~hc.ACTIVE))), s.element(H).assign(Xe), h();
|
|
8877
|
+
}), qe.divAssign(a), Be.assign(Be.bitOr(B(hc.REDIRECTED))), Xs(o, H, t, nt, it), Zs(o, H, n, Be), Qs(o, H, qe, Us(o, H)), $s(o, H, Je), s.element(H).assign(Xe), h();
|
|
8651
8878
|
});
|
|
8652
8879
|
});
|
|
8653
8880
|
});
|
|
@@ -8667,7 +8894,7 @@ function Kl(e) {
|
|
|
8667
8894
|
triangleIndex: N(tt),
|
|
8668
8895
|
boxTests: N(0),
|
|
8669
8896
|
triTests: N(0)
|
|
8670
|
-
}), r =
|
|
8897
|
+
}), r = Cl.wrap(wl(e, t, n, C, ft, rt)).toVar();
|
|
8671
8898
|
pt.assign(r.uv), mt.assign(r.normal), at.assign(r.hitPoint);
|
|
8672
8899
|
});
|
|
8673
8900
|
let ht = bi.wrap(Za(g, _, v, y, b, x, ft, pt, ot)).toVar();
|
|
@@ -8678,12 +8905,12 @@ function Kl(e) {
|
|
|
8678
8905
|
}).Else(() => {
|
|
8679
8906
|
ot.assign(ht.normal);
|
|
8680
8907
|
}), p(rt.equal(0).and(Ve), () => {
|
|
8681
|
-
let e =
|
|
8908
|
+
let e = ml({
|
|
8682
8909
|
worldPos: at,
|
|
8683
8910
|
cameraProjectionMatrix: z,
|
|
8684
8911
|
cameraViewMatrix: Ae
|
|
8685
8912
|
});
|
|
8686
|
-
|
|
8913
|
+
Ks(l, Ye, W(0, 0, 1), e, W(0));
|
|
8687
8914
|
});
|
|
8688
8915
|
let _t = M(1).toVar(), vt = M(1).toVar();
|
|
8689
8916
|
p(q.equal(1), () => {
|
|
@@ -8707,7 +8934,7 @@ function Kl(e) {
|
|
|
8707
8934
|
lt.assign(ft.ior);
|
|
8708
8935
|
}), p(q.equal(3), () => {
|
|
8709
8936
|
ut.assign(ft.ior);
|
|
8710
|
-
}),
|
|
8937
|
+
}), lc(o, H, R(ft.attenuationDistance.greaterThan(0), se(F(ft.attenuationColor, W(.001))).negate().div(ft.attenuationDistance), W(0))), pc(o, H, W(0), M(0));
|
|
8711
8938
|
});
|
|
8712
8939
|
}).Else(() => {
|
|
8713
8940
|
p(q.greaterThan(0), () => {
|
|
@@ -8725,7 +8952,7 @@ function Kl(e) {
|
|
|
8725
8952
|
ut.assign(ft.ior);
|
|
8726
8953
|
});
|
|
8727
8954
|
let e = wa.wrap(Oa(ft.subsurfaceColor, ft.subsurfaceRadius, ft.subsurfaceRadiusScale)).toVar();
|
|
8728
|
-
|
|
8955
|
+
lc(o, H, e.sigmaT.sub(e.sigmaS)), pc(o, H, e.sigmaS, E(ft.subsurfaceAnisotropy, -.99, .99));
|
|
8729
8956
|
});
|
|
8730
8957
|
}).Else(() => {
|
|
8731
8958
|
p(q.greaterThan(0), () => {
|
|
@@ -8737,36 +8964,36 @@ function Kl(e) {
|
|
|
8737
8964
|
}), qe.mulAssign(bt.throughput);
|
|
8738
8965
|
let e = R(bt.entering, ot, ot.negate()), t = R(bt.didReflect, e, Ke), n = at.add(t.mul(.001));
|
|
8739
8966
|
p(bt.isAlphaSkip.not(), () => {
|
|
8740
|
-
Be.assign(Be.bitOr(B(
|
|
8741
|
-
}),
|
|
8742
|
-
}), Be.assign(Be.bitOr(B(
|
|
8967
|
+
Be.assign(Be.bitOr(B(hc.REDIRECTED)));
|
|
8968
|
+
}), Xs(o, H, n, nt, it), Zs(o, H, bt.direction, Be), Qs(o, H, qe, Us(o, H)), $s(o, H, Je), sc(o, H, B(q), B(dt), ct, lt, ut, B(J.add(.5))), s.element(H).assign(Xe), h();
|
|
8969
|
+
}), Be.assign(Be.bitOr(B(hc.HAS_HIT_OPAQUE | hc.REDIRECTED)));
|
|
8743
8970
|
let xt = ht.emissive.toVar();
|
|
8744
8971
|
p(ie(xt).greaterThan(0), () => {
|
|
8745
8972
|
let e = R(We.not(), ke, M(1)), t = M(1).toVar();
|
|
8746
8973
|
He && p(K.equal(N(1)).and(Ne.greaterThan(N(0))).and(rt.greaterThan(0)), () => {
|
|
8747
|
-
let e =
|
|
8974
|
+
let e = Us(o, H);
|
|
8748
8975
|
p(e.greaterThan(0), () => {
|
|
8749
8976
|
let i = M(0).toVar();
|
|
8750
8977
|
p(Le.greaterThan(N(0)), () => {
|
|
8751
|
-
i.assign(
|
|
8978
|
+
i.assign(Ql(N(tt), Ze, Ke, Ge, a, Pe, Re, n));
|
|
8752
8979
|
}).Else(() => {
|
|
8753
|
-
i.assign(
|
|
8980
|
+
i.assign(Bl(N(tt), Ze, Ke, Ge, n, r, Fe));
|
|
8754
8981
|
}), t.assign(Vi({
|
|
8755
8982
|
pdf1: e,
|
|
8756
8983
|
pdf2: i
|
|
8757
8984
|
}));
|
|
8758
8985
|
});
|
|
8759
|
-
}), Je.assign(G(Je.xyz.add(
|
|
8986
|
+
}), Je.assign(G(Je.xyz.add(pl(xt.mul(qe).mul(e).mul(t), M(rt), je, N(V))), Je.w));
|
|
8760
8987
|
});
|
|
8761
8988
|
let St = Ke.negate().toVar();
|
|
8762
8989
|
p(A(ot, St).lessThan(0), () => {
|
|
8763
8990
|
ot.assign(ot.negate());
|
|
8764
|
-
}), p(Be.bitAnd(B(
|
|
8765
|
-
let e =
|
|
8766
|
-
|
|
8991
|
+
}), p(Be.bitAnd(B(hc.AUX_LOCKED)).equal(B(0)).and(Ve), () => {
|
|
8992
|
+
let e = Js(qs(l, Ye)).w;
|
|
8993
|
+
Ks(l, Ye, ot, e, gt.xyz);
|
|
8767
8994
|
let t = ft.metalness.greaterThan(.7).and(ft.roughness.lessThan(.3)), n = ft.transmission.greaterThan(.5);
|
|
8768
8995
|
p(t.or(n).not(), () => {
|
|
8769
|
-
Be.assign(Be.bitOr(B(
|
|
8996
|
+
Be.assign(Be.bitOr(B(hc.AUX_LOCKED)));
|
|
8770
8997
|
});
|
|
8771
8998
|
});
|
|
8772
8999
|
let Ct = xi.wrap(Ji(ft.metalness, ft.roughness, ft.transmission, ft.clearcoat, ft.emissive, ft.subsurface)).toVar(), wt = N(Me.x).toVar(), Tt = Un(U(M(N(Ye).mod(wt)).add(.5), M(N(Ye).div(wt)).add(.5)), N(0), rt, Xe, N(-1), Me, V).toVar(), Et = gi({
|
|
@@ -8804,67 +9031,67 @@ function Kl(e) {
|
|
|
8804
9031
|
triangleIndex: N(0),
|
|
8805
9032
|
boxTests: N(0),
|
|
8806
9033
|
triTests: N(0)
|
|
8807
|
-
}), n =
|
|
9034
|
+
}), n = gl.wrap(_l(e, t, ft, Tt, Xe));
|
|
8808
9035
|
Ot.assign(n.L), kt.assign(n.brdf), At.assign(n.pdf);
|
|
8809
9036
|
}).Else(() => {
|
|
8810
|
-
let e = hi.wrap(
|
|
9037
|
+
let e = hi.wrap(fl(St, ot, ft, Tt, Xe, Ct, !1, Et, !1, Dt));
|
|
8811
9038
|
Ot.assign(e.direction), kt.assign(e.value), At.assign(e.pdf);
|
|
8812
9039
|
});
|
|
8813
|
-
let jt = pi.wrap(
|
|
8814
|
-
Je.assign(G(Je.xyz.add(
|
|
8815
|
-
let e = f(([e, i, a]) => ro(e, i, a,
|
|
9040
|
+
let jt = pi.wrap(al(at, ot, ft, St, Ot, At, kt, rt, Xe, de, fe, pe, me, he, ge, ve, ye, t, n, r, w, D, O, i, le, I, ue, k, T(!1))).shadowed.toVar(), Mt = R(rt.greaterThan(0), ke, M(1));
|
|
9041
|
+
Je.assign(G(Je.xyz.add(pl(qe.mul(jt).mul(Mt), M(rt), je, N(V))), Je.w)), He && p(K.equal(N(1)).and(Ne.greaterThan(N(0))), () => {
|
|
9042
|
+
let e = f(([e, i, a]) => ro(e, i, a, Fc, t, n, r));
|
|
8816
9043
|
p(Le.greaterThan(N(0)), () => {
|
|
8817
|
-
let t =
|
|
9044
|
+
let t = Tl.wrap(Zl(at, ot, Xe, a, a, Pe, n));
|
|
8818
9045
|
p(rt.greaterThan(N(1)).and(ft.roughness.greaterThan(.9)).and(ft.metalness.lessThan(.1)).not().and(t.valid).and(t.pdf.greaterThan(0)), () => {
|
|
8819
9046
|
let n = F(M(0), A(ot, t.direction));
|
|
8820
9047
|
p(n.greaterThan(0), () => {
|
|
8821
9048
|
let r = io(at, ot, ft), i = at.add(r), a = t.distance.sub(.001), o = e(i, t.direction, a);
|
|
8822
9049
|
p(o.greaterThan(0), () => {
|
|
8823
|
-
let e =
|
|
9050
|
+
let e = qc(St, t.direction, ot, ft), r = rl(St, t.direction, ot, ft), i = R(r.greaterThan(0), Vi({
|
|
8824
9051
|
pdf1: t.pdf,
|
|
8825
9052
|
pdf2: r
|
|
8826
9053
|
}), M(1)), a = t.emission.mul(e).mul(n).div(t.pdf).mul(o).mul(Ie).mul(i);
|
|
8827
|
-
Je.assign(G(Je.xyz.add(
|
|
9054
|
+
Je.assign(G(Je.xyz.add(pl(a.mul(qe).mul(Mt), M(rt), je, N(V))), Je.w));
|
|
8828
9055
|
});
|
|
8829
9056
|
});
|
|
8830
9057
|
});
|
|
8831
9058
|
}).Else(() => {
|
|
8832
|
-
let t =
|
|
8833
|
-
Je.assign(G(Je.xyz.add(
|
|
9059
|
+
let t = Wl(at, ot, St, ft, rt, Xe, Ie, a, Pe, Ne, Fe, n, e, io);
|
|
9060
|
+
Je.assign(G(Je.xyz.add(pl(t.mul(qe).mul(Mt), M(rt), je, N(V))), Je.w));
|
|
8834
9061
|
});
|
|
8835
9062
|
});
|
|
8836
|
-
let Nt = _i.wrap(va(ft, rt, Ct)).toVar(), Pt = ho.wrap(
|
|
9063
|
+
let Nt = _i.wrap(va(ft, rt, Ct)).toVar(), Pt = ho.wrap(dl(St, ot, ft, Ot, At, kt, Xe, Nt)).toVar(), Ft = Pt.direction.toVar(), It = F(Pt.combinedPdf, .001).toVar();
|
|
8837
9064
|
qe.mulAssign(Pt.throughput);
|
|
8838
|
-
let Lt =
|
|
9065
|
+
let Lt = hl(rt, qe, Ct, Ft, Xe, k, ee).toVar();
|
|
8839
9066
|
p(Lt.lessThanEqual(0), () => {
|
|
8840
|
-
|
|
9067
|
+
$s(o, H, Je), Zs(o, H, Ke, Be.bitAnd(B(~hc.ACTIVE))), s.element(H).assign(Xe), h();
|
|
8841
9068
|
}), qe.divAssign(Lt), p(nt.greaterThanEqual(be), () => {
|
|
8842
|
-
|
|
8843
|
-
}),
|
|
9069
|
+
$s(o, H, Je), Zs(o, H, Ke, Be.bitAnd(B(~hc.ACTIVE))), s.element(H).assign(Xe), h();
|
|
9070
|
+
}), Xs(o, H, at.add(ot.mul(.001)), nt.add(1), it), Zs(o, H, Ft, Be), Qs(o, H, qe, It), $s(o, H, Je), sc(o, H, B(q), B(dt), ct, lt, ut, B(J.add(.5))), s.element(H).assign(Xe);
|
|
8844
9071
|
});
|
|
8845
9072
|
}
|
|
8846
9073
|
//#endregion
|
|
8847
9074
|
//#region src/TSL/CompactKernel.js
|
|
8848
|
-
function
|
|
9075
|
+
function iu(e) {
|
|
8849
9076
|
let { rayBufferRO: t, activeIndicesReadRO: n, activeIndicesWriteRW: r, counters: i, currentActiveCount: a } = e;
|
|
8850
9077
|
return f(() => {
|
|
8851
|
-
let e = re, o = i ? S(i.element(B(
|
|
9078
|
+
let e = re, o = i ? S(i.element(B(mc.ENTERING_COUNT))) : a;
|
|
8852
9079
|
p(e.greaterThanEqual(o), () => {
|
|
8853
9080
|
h();
|
|
8854
9081
|
});
|
|
8855
9082
|
let s = n.element(e);
|
|
8856
|
-
p(
|
|
8857
|
-
let e = x(i.element(B(
|
|
9083
|
+
p(Vs(t, s).bitAnd(B(hc.ACTIVE)).notEqual(B(0)), () => {
|
|
9084
|
+
let e = x(i.element(B(mc.ACTIVE_RAY_COUNT)), B(1));
|
|
8858
9085
|
r.element(e).assign(s);
|
|
8859
9086
|
});
|
|
8860
9087
|
});
|
|
8861
9088
|
}
|
|
8862
|
-
function
|
|
9089
|
+
function au(e) {
|
|
8863
9090
|
let { rayBufferRO: t, activeIndicesReadRO: n, activeIndicesWriteRW: r, counters: i, currentActiveCount: a } = e;
|
|
8864
9091
|
return f(() => {
|
|
8865
|
-
let e = re, o = i ? S(i.element(B(
|
|
9092
|
+
let e = re, o = i ? S(i.element(B(mc.ENTERING_COUNT))) : a, s = e.lessThan(o), c = n.element(e), l = Vs(t, c), u = s.and(l.bitAnd(B(hc.ACTIVE)).notEqual(B(0))), d = R(u, B(1), B(0)), f = De(d).toVar(), m = Te(d).toVar(), h = De(B(1)).toVar(), g = B(0).toVar();
|
|
8866
9093
|
p(h.equal(B(0)), () => {
|
|
8867
|
-
g.assign(x(i.element(B(
|
|
9094
|
+
g.assign(x(i.element(B(mc.ACTIVE_RAY_COUNT)), m));
|
|
8868
9095
|
});
|
|
8869
9096
|
let _ = Ee(g, B(0)).toVar();
|
|
8870
9097
|
p(u, () => {
|
|
@@ -8872,16 +9099,16 @@ function Jl(e) {
|
|
|
8872
9099
|
});
|
|
8873
9100
|
});
|
|
8874
9101
|
}
|
|
8875
|
-
var
|
|
8876
|
-
function
|
|
9102
|
+
var ou = /* @__PURE__ */ K("\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");
|
|
9103
|
+
function su(e) {
|
|
8877
9104
|
let { rayBufferRO: t, gBufferRO: n, writeColorTex: r, writeNDTex: i, writeAlbedoTex: a, resolution: o, frame: s, enableAccumulation: c, hasPreviousAccumulated: l, accumulationAlpha: u, cameraIsMoving: d, transparentBackground: m, prevAccumTexture: h, prevNormalDepthTexture: g, prevAlbedoTexture: _, renderWidth: v, renderHeight: y, visMode: b, auxGBufferEnabled: x } = e, S = x.greaterThan(B(0));
|
|
8878
9105
|
return f(() => {
|
|
8879
9106
|
let e = N(ze.x).mul(16).add(N(oe.x)), f = N(ze.y).mul(16).add(N(oe.y));
|
|
8880
9107
|
p(e.lessThan(v).and(f.lessThan(y)), () => {
|
|
8881
|
-
let v = B(f.mul(N(o.x)).add(e)), y =
|
|
9108
|
+
let v = B(f.mul(N(o.x)).add(e)), y = Ws(t, v), x = y.xyz.toVar(), C = R(m, y.w, M(1)).toVar(), w = G(0).toVar(), T = G(0).xyz.toVar();
|
|
8882
9109
|
p(S, () => {
|
|
8883
|
-
let e =
|
|
8884
|
-
w.assign(
|
|
9110
|
+
let e = qs(n, v);
|
|
9111
|
+
w.assign(Js(e)), T.assign(G(Ys(e), 0).xyz);
|
|
8885
9112
|
});
|
|
8886
9113
|
let E = U(M(e).add(.5), M(f).add(.5)).div(o);
|
|
8887
9114
|
p(c.and(d.not()).and(s.greaterThan(B(0))).and(l).and(b.notEqual(N(11))), () => {
|
|
@@ -8892,7 +9119,7 @@ function Xl(e) {
|
|
|
8892
9119
|
C.assign(I(e.w, y.w, u));
|
|
8893
9120
|
});
|
|
8894
9121
|
}), p(b.equal(N(11)), () => {
|
|
8895
|
-
x.assign(
|
|
9122
|
+
x.assign(ou(x));
|
|
8896
9123
|
});
|
|
8897
9124
|
let D = Ie(B(e), B(f));
|
|
8898
9125
|
Ae(r, D, G(x, C)).toWriteOnly(), p(S, () => {
|
|
@@ -8903,11 +9130,11 @@ function Xl(e) {
|
|
|
8903
9130
|
}
|
|
8904
9131
|
//#endregion
|
|
8905
9132
|
//#region src/TSL/Debugger.js
|
|
8906
|
-
var
|
|
9133
|
+
var cu = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n return vec3f( 1.0f - depth );\n }\n"), lu = /* @__PURE__ */ K("\n fn visualizeNormal( normal: vec3f ) -> vec3f {\n return normal * 0.5f + 0.5f;\n }\n"), uu = /* @__PURE__ */ K("\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"), du = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m, h, g, _, v, y, b, x, S]) => {
|
|
8907
9134
|
let C = G(1, 0, 1, 1).toVar(), w = ui({
|
|
8908
9135
|
origin: e,
|
|
8909
9136
|
direction: t
|
|
8910
|
-
}), T = mi.wrap(
|
|
9137
|
+
}), T = mi.wrap(Pc(w, n, r).toVar());
|
|
8911
9138
|
return p(l.equal(N(7)), () => {
|
|
8912
9139
|
let e = M(T.triTests).div(u);
|
|
8913
9140
|
C.assign(R(e.lessThan(1), G(W(e), 1), G(1, 0, 0, 1)));
|
|
@@ -8916,7 +9143,7 @@ var Zl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
8916
9143
|
C.assign(R(e.lessThan(1), G(W(e), 1), G(1, 0, 0, 1)));
|
|
8917
9144
|
}), p(l.equal(N(10)), () => {
|
|
8918
9145
|
p(c, () => {
|
|
8919
|
-
let e =
|
|
9146
|
+
let e = Uc({
|
|
8920
9147
|
tex: a,
|
|
8921
9148
|
samp: _e(a),
|
|
8922
9149
|
direction: t,
|
|
@@ -8964,18 +9191,18 @@ var Zl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
8964
9191
|
C.assign(G(.5, .5, 1, 1));
|
|
8965
9192
|
}).Else(() => {
|
|
8966
9193
|
let e = di.wrap(Zi(T.materialIndex, i)).toVar(), t = L(bi.wrap(Za(m, h, g, _, v, y, e, T.uv, T.normal)).toVar().normal);
|
|
8967
|
-
C.assign(G(
|
|
9194
|
+
C.assign(G(lu({ normal: t }), 1));
|
|
8968
9195
|
});
|
|
8969
9196
|
}), p(l.equal(N(2)), () => {
|
|
8970
9197
|
p(T.didHit.not(), () => {
|
|
8971
9198
|
C.assign(G(W(1), 1));
|
|
8972
9199
|
}).Else(() => {
|
|
8973
|
-
let e =
|
|
9200
|
+
let e = uu({
|
|
8974
9201
|
worldPos: T.hitPoint,
|
|
8975
9202
|
cameraProjectionMatrix: b,
|
|
8976
9203
|
cameraViewMatrix: x
|
|
8977
9204
|
});
|
|
8978
|
-
C.assign(G(
|
|
9205
|
+
C.assign(G(cu({ depth: e }), 1));
|
|
8979
9206
|
});
|
|
8980
9207
|
}), p(l.equal(N(3)), () => {
|
|
8981
9208
|
p(T.didHit.not(), () => {
|
|
@@ -8994,10 +9221,10 @@ var Zl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
8994
9221
|
}).toVar(), x = ui({
|
|
8995
9222
|
origin: T.hitPoint.add(u.mul(.001)),
|
|
8996
9223
|
direction: b
|
|
8997
|
-
}), w = mi.wrap(
|
|
9224
|
+
}), w = mi.wrap(Pc(x, n, r).toVar()), E = W(0).toVar();
|
|
8998
9225
|
p(w.didHit.not(), () => {
|
|
8999
9226
|
p(c, () => {
|
|
9000
|
-
E.assign(
|
|
9227
|
+
E.assign(Uc({
|
|
9001
9228
|
tex: a,
|
|
9002
9229
|
samp: _e(a),
|
|
9003
9230
|
direction: b,
|
|
@@ -9009,7 +9236,7 @@ var Zl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
9009
9236
|
}).Else(() => {
|
|
9010
9237
|
let e = di.wrap(Zi(w.materialIndex, i)).toVar(), t = bi.wrap(Za(m, h, g, _, v, y, e, w.uv, w.normal)).toVar();
|
|
9011
9238
|
E.assign(t.emissive), p(c, () => {
|
|
9012
|
-
let e = L(t.normal).toVar(), n =
|
|
9239
|
+
let e = L(t.normal).toVar(), n = Uc({
|
|
9013
9240
|
tex: a,
|
|
9014
9241
|
samp: _e(a),
|
|
9015
9242
|
direction: e,
|
|
@@ -9025,7 +9252,7 @@ var Zl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
9025
9252
|
});
|
|
9026
9253
|
}), p(l.equal(N(6)), () => {
|
|
9027
9254
|
p(T.didHit, () => {
|
|
9028
|
-
let e = T.normal.toVar(), n = L(t.sub(e.mul(A(t, e).mul(2)))).toVar(), r =
|
|
9255
|
+
let e = T.normal.toVar(), n = L(t.sub(e.mul(A(t, e).mul(2)))).toVar(), r = Uc({
|
|
9029
9256
|
tex: a,
|
|
9030
9257
|
samp: _e(a),
|
|
9031
9258
|
direction: n,
|
|
@@ -9035,7 +9262,7 @@ var Zl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
9035
9262
|
}).xyz, i = r.div(r.add(1));
|
|
9036
9263
|
C.assign(G(i, 1));
|
|
9037
9264
|
}).Else(() => {
|
|
9038
|
-
let e =
|
|
9265
|
+
let e = Uc({
|
|
9039
9266
|
tex: a,
|
|
9040
9267
|
samp: _e(a),
|
|
9041
9268
|
direction: t,
|
|
@@ -9047,19 +9274,19 @@ var Zl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
9047
9274
|
});
|
|
9048
9275
|
}), C;
|
|
9049
9276
|
});
|
|
9050
|
-
function
|
|
9277
|
+
function fu(e) {
|
|
9051
9278
|
let { writeColorTex: t, writeNDTex: n, writeAlbedoTex: r, resolution: i, renderWidth: a, renderHeight: o, cameraWorldMatrix: s, cameraProjectionMatrixInverse: c, cameraProjectionMatrix: l, cameraViewMatrix: u, enableDOF: d, focalLength: m, aperture: h, focusDistance: g, sceneScale: _, apertureScale: v, anamorphicRatio: y, bvhBuffer: b, triangleBuffer: x, materialBuffer: S, envTexture: C, environmentMatrix: w, environmentIntensity: T, enableEnvironmentLight: E, visMode: D, debugVisScale: O, albedoMaps: k, normalMaps: A, bumpMaps: j, metalnessMaps: ee, roughnessMaps: te, emissiveMaps: ne, frame: re } = e;
|
|
9052
9279
|
return f(() => {
|
|
9053
9280
|
let e = N(ze.x).mul(16).add(N(oe.x)), f = N(ze.y).mul(16).add(N(oe.y));
|
|
9054
9281
|
p(e.lessThan(a).and(f.lessThan(o)), () => {
|
|
9055
9282
|
let a = U(M(e).add(.5), M(f).add(.5)), o = Pn({ state: B(f.mul(N(i.x)).add(e)).add(B(1)) }).toVar(), P = a.div(i).mul(2).sub(1).toVar();
|
|
9056
9283
|
P.y.assign(P.y.negate());
|
|
9057
|
-
let ie = ui.wrap(
|
|
9284
|
+
let ie = ui.wrap(Ic(P, o, s, c, d, m, h, g, _, v, y)), ae = G(1, 0, 1, 1).toVar();
|
|
9058
9285
|
p(D.equal(N(9)), () => {
|
|
9059
9286
|
let e = Wn(a, N(0), N(1), o, i, re);
|
|
9060
9287
|
ae.assign(G(e, 1, 1));
|
|
9061
9288
|
}).Else(() => {
|
|
9062
|
-
ae.assign(
|
|
9289
|
+
ae.assign(du(ie.origin, ie.direction, b, x, S, C, w, T, E, D, O, a, i, k, A, j, ee, te, ne, l, u, re));
|
|
9063
9290
|
});
|
|
9064
9291
|
let oe = Ie(B(e), B(f));
|
|
9065
9292
|
Ae(t, oe, ae).toWriteOnly(), Ae(n, oe, G(.5, .5, 1, 1)).toWriteOnly(), Ae(r, oe, G(ae.xyz, 1)).toWriteOnly();
|
|
@@ -9068,9 +9295,9 @@ function tu(e) {
|
|
|
9068
9295
|
}
|
|
9069
9296
|
//#endregion
|
|
9070
9297
|
//#region src/Stages/PathTracer.js
|
|
9071
|
-
var
|
|
9298
|
+
var pu = class extends Ns {
|
|
9072
9299
|
constructor(e, t, n, r = {}) {
|
|
9073
|
-
super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = V(0, "uint"), this._useDynamicDispatch = !0, this._useSubgroupCompact = !1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._bounceEarlyExitThreshold = 100, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this.vramTracker = new
|
|
9300
|
+
super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = V(0, "uint"), this._useDynamicDispatch = !0, this._useSubgroupCompact = !1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._bounceEarlyExitThreshold = 100, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this.vramTracker = new Sc(this.renderer), this._registerVRAMProviders(), console.log("PathTracer: initialized (wavefront)");
|
|
9074
9301
|
}
|
|
9075
9302
|
_registerVRAMProviders() {
|
|
9076
9303
|
let e = this.vramTracker;
|
|
@@ -9207,7 +9434,7 @@ var nu = class extends Ts {
|
|
|
9207
9434
|
let n = this.storageTextures.renderWidth, r = this.storageTextures.renderHeight;
|
|
9208
9435
|
if (n === e && r === t || !(this.materialData?.materialCount > 0)) return;
|
|
9209
9436
|
this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackFrameCounter = 0, this._readbackGeneration++;
|
|
9210
|
-
let i =
|
|
9437
|
+
let i = Rs.requiredCapacity(n * r);
|
|
9211
9438
|
!this._packedBuffers || i > this._packedBuffers.capacity ? (this._kernelManager && this._kernelManager.dispose(), this._wavefrontReady = !1, this._buildWavefrontKernels()) : this._resizeWavefrontInPlace(n, r);
|
|
9212
9439
|
}
|
|
9213
9440
|
_resizeWavefrontInPlace(e, t) {
|
|
@@ -9222,15 +9449,15 @@ var nu = class extends Ts {
|
|
|
9222
9449
|
let e = this.shaderBuilder.getSceneTextureNodes();
|
|
9223
9450
|
if (!e) return;
|
|
9224
9451
|
let t = this.storageTextures.renderWidth, n = this.storageTextures.renderHeight, r = t * n;
|
|
9225
|
-
this._bounceEarlyExitThreshold !== -1 && (this._bounceEarlyExitThreshold = Math.max(100, Math.floor(r / 1e3))), this._packedBuffers ? this._packedBuffers.resize(r) : this._packedBuffers = new
|
|
9226
|
-
let i =
|
|
9452
|
+
this._bounceEarlyExitThreshold !== -1 && (this._bounceEarlyExitThreshold = Math.max(100, Math.floor(r / 1e3))), this._packedBuffers ? this._packedBuffers.resize(r) : this._packedBuffers = new Rs(r);
|
|
9453
|
+
let i = Rs.requiredCapacity(r) * 1;
|
|
9227
9454
|
this._gBufferAttr = new o(new Uint32Array(i * 4), 4);
|
|
9228
9455
|
let a = Ce(this._gBufferAttr, "uvec4"), s = Ce(this._gBufferAttr, "uvec4").toReadOnly();
|
|
9229
|
-
this._queueManager ? this._queueManager.resize(this._packedBuffers.capacity) : this._queueManager = new
|
|
9456
|
+
this._queueManager ? this._queueManager.resize(this._packedBuffers.capacity) : this._queueManager = new gc(this._packedBuffers.capacity), this._kernelManager ||= new wc(this.renderer);
|
|
9230
9457
|
let c = this._packedBuffers, l = this._queueManager;
|
|
9231
9458
|
this._wfRenderWidth.value = t, this._wfRenderHeight.value = n, this._wfMaxRayCount.value = r;
|
|
9232
9459
|
let u = this.shaderBuilder.prevColorTexNode, d = this.shaderBuilder.prevNormalDepthTexNode, m = this.shaderBuilder.prevAlbedoTexNode, g = this.storageTextures.getWriteTextures(), _ = l.getCounters(), v = f(() => {
|
|
9233
|
-
C(_.element(B(
|
|
9460
|
+
C(_.element(B(mc.ACTIVE_RAY_COUNT)), B(0));
|
|
9234
9461
|
});
|
|
9235
9462
|
this._kernelManager.register("resetCounters", v().compute([
|
|
9236
9463
|
1,
|
|
@@ -9242,7 +9469,7 @@ var nu = class extends Ts {
|
|
|
9242
9469
|
1
|
|
9243
9470
|
]));
|
|
9244
9471
|
let y = f(() => {
|
|
9245
|
-
C(_.element(B(
|
|
9472
|
+
C(_.element(B(mc.ACTIVE_RAY_COUNT)), B(0));
|
|
9246
9473
|
});
|
|
9247
9474
|
this._kernelManager.register("resetActiveCounter", y().compute([
|
|
9248
9475
|
1,
|
|
@@ -9254,8 +9481,8 @@ var nu = class extends Ts {
|
|
|
9254
9481
|
1
|
|
9255
9482
|
]));
|
|
9256
9483
|
let b = l.getBounceCounts(), x = this._wfCurrentBounce, w = f(() => {
|
|
9257
|
-
let e = S(_.element(B(
|
|
9258
|
-
b.element(t).assign(e), C(_.element(B(
|
|
9484
|
+
let e = S(_.element(B(mc.ACTIVE_RAY_COUNT))), t = B(x).clamp(B(0), B(l.MAX_BOUNCE_SNAPSHOTS - 1));
|
|
9485
|
+
b.element(t).assign(e), C(_.element(B(mc.ENTERING_COUNT)), e);
|
|
9259
9486
|
});
|
|
9260
9487
|
this._kernelManager.register("snapshotBounceCount", w().compute([
|
|
9261
9488
|
1,
|
|
@@ -9269,7 +9496,7 @@ var nu = class extends Ts {
|
|
|
9269
9496
|
let T = l.activeIndices.a, E = f(() => {
|
|
9270
9497
|
let e = re;
|
|
9271
9498
|
T.element(e).assign(e), p(e.equal(B(0)), () => {
|
|
9272
|
-
C(_.element(B(
|
|
9499
|
+
C(_.element(B(mc.ACTIVE_RAY_COUNT)), this._wfMaxRayCount), C(_.element(B(mc.ENTERING_COUNT)), this._wfMaxRayCount);
|
|
9273
9500
|
});
|
|
9274
9501
|
});
|
|
9275
9502
|
this._kernelManager.register("initActiveIndices", E().compute([
|
|
@@ -9281,7 +9508,7 @@ var nu = class extends Ts {
|
|
|
9281
9508
|
1,
|
|
9282
9509
|
1
|
|
9283
9510
|
]));
|
|
9284
|
-
let D =
|
|
9511
|
+
let D = Lc({
|
|
9285
9512
|
rayBufferRW: c.rayBuffer.rw,
|
|
9286
9513
|
rngBufferRW: c.rngBuffer.rw,
|
|
9287
9514
|
gBufferRW: a,
|
|
@@ -9323,7 +9550,7 @@ var nu = class extends Ts {
|
|
|
9323
9550
|
emissiveMaps: se,
|
|
9324
9551
|
displacementMaps: ce
|
|
9325
9552
|
};
|
|
9326
|
-
let le =
|
|
9553
|
+
let le = Rc({
|
|
9327
9554
|
bvhBuffer: O,
|
|
9328
9555
|
triangleBuffer: k,
|
|
9329
9556
|
materialBuffer: A,
|
|
@@ -9342,7 +9569,7 @@ var nu = class extends Ts {
|
|
|
9342
9569
|
1,
|
|
9343
9570
|
1
|
|
9344
9571
|
]));
|
|
9345
|
-
let I =
|
|
9572
|
+
let I = ru({
|
|
9346
9573
|
gBufferRW: a,
|
|
9347
9574
|
envCompensationDelta: this.envCompensationDelta,
|
|
9348
9575
|
bvhBuffer: O,
|
|
@@ -9420,7 +9647,7 @@ var nu = class extends Ts {
|
|
|
9420
9647
|
]));
|
|
9421
9648
|
let ue = this._useSubgroupCompact && (this.renderer.hasFeature ? this.renderer.hasFeature("subgroups") : !1);
|
|
9422
9649
|
this._compactIsSubgroup = ue;
|
|
9423
|
-
let L = (ue ?
|
|
9650
|
+
let L = (ue ? au : iu)({
|
|
9424
9651
|
rayBufferRO: c.rayBuffer.ro,
|
|
9425
9652
|
activeIndicesReadRO: l.getActiveReadRO(),
|
|
9426
9653
|
activeIndicesWriteRW: l.getActiveWrite(),
|
|
@@ -9437,7 +9664,7 @@ var nu = class extends Ts {
|
|
|
9437
9664
|
1
|
|
9438
9665
|
]));
|
|
9439
9666
|
let de = f(() => {
|
|
9440
|
-
C(_.element(B(
|
|
9667
|
+
C(_.element(B(mc.ENTERING_COUNT)), this._wfMaxRayCount);
|
|
9441
9668
|
});
|
|
9442
9669
|
this._kernelManager.register("enterFull", de().compute([
|
|
9443
9670
|
1,
|
|
@@ -9450,7 +9677,7 @@ var nu = class extends Ts {
|
|
|
9450
9677
|
]));
|
|
9451
9678
|
let fe = l.activeIndicesRO.b, pe = l.activeIndices.a, me = f(() => {
|
|
9452
9679
|
let e = re;
|
|
9453
|
-
p(e.greaterThanEqual(S(_.element(B(
|
|
9680
|
+
p(e.greaterThanEqual(S(_.element(B(mc.ACTIVE_RAY_COUNT)))), () => {
|
|
9454
9681
|
h();
|
|
9455
9682
|
}), pe.element(e).assign(fe.element(e));
|
|
9456
9683
|
});
|
|
@@ -9463,7 +9690,7 @@ var nu = class extends Ts {
|
|
|
9463
9690
|
1,
|
|
9464
9691
|
1
|
|
9465
9692
|
]));
|
|
9466
|
-
let he =
|
|
9693
|
+
let he = su({
|
|
9467
9694
|
rayBufferRO: c.rayBuffer.ro,
|
|
9468
9695
|
gBufferRO: s,
|
|
9469
9696
|
writeColorTex: g.color,
|
|
@@ -9493,7 +9720,7 @@ var nu = class extends Ts {
|
|
|
9493
9720
|
16,
|
|
9494
9721
|
1
|
|
9495
9722
|
]));
|
|
9496
|
-
let ge =
|
|
9723
|
+
let ge = fu({
|
|
9497
9724
|
writeColorTex: g.color,
|
|
9498
9725
|
writeNDTex: g.normalDepth,
|
|
9499
9726
|
writeAlbedoTex: g.albedo,
|
|
@@ -9557,7 +9784,7 @@ var nu = class extends Ts {
|
|
|
9557
9784
|
dispose() {
|
|
9558
9785
|
super.dispose(), this._packedBuffers?.dispose(), this._queueManager?.dispose(), this._kernelManager?.dispose(), this._gBufferAttr?.dispose?.(), this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1;
|
|
9559
9786
|
}
|
|
9560
|
-
},
|
|
9787
|
+
}, mu = class extends qn {
|
|
9561
9788
|
constructor(e, t = {}) {
|
|
9562
9789
|
super("NormalDepth", {
|
|
9563
9790
|
...t,
|
|
@@ -9614,7 +9841,7 @@ var nu = class extends Ts {
|
|
|
9614
9841
|
let m = W(M(d).add(.5).div(s).mul(2).sub(1), M(f).add(.5).div(c).mul(2).sub(1).negate(), 1), h = o.mul(G(m, 1)), g = L(ce(a[0].xyz, a[1].xyz, a[2].xyz).mul(h.xyz.div(h.w))), _ = ui({
|
|
9615
9842
|
origin: W(a[3]),
|
|
9616
9843
|
direction: g
|
|
9617
|
-
}), v = mi.wrap(
|
|
9844
|
+
}), v = mi.wrap(Pc(_, t, e)), y = v.normal.mul(.5).add(.5), b = v.dst, x = v.didHit.select(G(y, b), G(0, 0, 0, M(1e6)));
|
|
9618
9845
|
Ae(l, Ie(B(d), B(f)), x).toWriteOnly();
|
|
9619
9846
|
let S = v.normal.toVar();
|
|
9620
9847
|
p(v.didHit, () => {
|
|
@@ -9668,7 +9895,7 @@ var nu = class extends Ts {
|
|
|
9668
9895
|
dispose() {
|
|
9669
9896
|
this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose(), this._shadingRT?.dispose(), this._rtA?.dispose(), this._rtB?.dispose();
|
|
9670
9897
|
}
|
|
9671
|
-
},
|
|
9898
|
+
}, hu = class extends qn {
|
|
9672
9899
|
constructor(e, t, n = {}) {
|
|
9673
9900
|
super("MotionVector", {
|
|
9674
9901
|
...n,
|
|
@@ -9780,7 +10007,7 @@ var nu = class extends Ts {
|
|
|
9780
10007
|
dispose() {
|
|
9781
10008
|
this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose(), this.screenSpaceTarget?.dispose(), this.worldSpaceTarget?.dispose(), this._normalDepthTexNode?.dispose();
|
|
9782
10009
|
}
|
|
9783
|
-
},
|
|
10010
|
+
}, gu = (e) => R(e.equal(e), e, M(0)).clamp(0, 1e7), _u = (e) => W(gu(e.x), gu(e.y), gu(e.z)), vu = class extends qn {
|
|
9784
10011
|
constructor(e, t = {}) {
|
|
9785
10012
|
super("ASVGF", {
|
|
9786
10013
|
...t,
|
|
@@ -9821,7 +10048,7 @@ var nu = class extends Ts {
|
|
|
9821
10048
|
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 = Le("float", 144), u = Le("float", 144);
|
|
9822
10049
|
this._gradientNode = f(() => {
|
|
9823
10050
|
let d = oe.x, f = oe.y, m = f.mul(8).add(d), h = N(ze.x).mul(8).sub(2).toVar(), g = N(ze.y).mul(8).sub(2).toVar(), v = (i) => {
|
|
9824
|
-
let a = i.mod(B(12)), o = i.div(B(12)), d = h.add(N(a)).clamp(N(0), N(s).sub(1)), f = g.add(N(o)).clamp(N(0), N(c).sub(1)), p = z(e, P(d, f)).xyz, m = z(t, P(d, f)).xyz, _ = Bi(
|
|
10051
|
+
let a = i.mod(B(12)), o = i.div(B(12)), d = h.add(N(a)).clamp(N(0), N(s).sub(1)), f = g.add(N(o)).clamp(N(0), N(c).sub(1)), p = z(e, P(d, f)).xyz, m = z(t, P(d, f)).xyz, _ = Bi(_u(p.div(F(m, W(lr))))).toVar();
|
|
9825
10052
|
l.element(i).assign(_);
|
|
9826
10053
|
let v = z(n, P(d, f)), y = M(d).sub(v.x.mul(s)), b = M(f).sub(v.y.mul(c)), x = N(y.add(.5)).clamp(N(0), N(s).sub(1)), S = N(b.add(.5)).clamp(N(0), N(c).sub(1)), C = v.w.greaterThan(.5), w = z(r, P(x, S)).xyz, T = C.select(Bi(w), _);
|
|
9827
10054
|
u.element(i).assign(T);
|
|
@@ -9868,7 +10095,7 @@ var nu = class extends Ts {
|
|
|
9868
10095
|
return f(() => {
|
|
9869
10096
|
let f = N(ze.x).mul(8).add(N(oe.x)), y = N(ze.y).mul(8).add(N(oe.y));
|
|
9870
10097
|
p(f.lessThan(N(g)).and(y.lessThan(N(v))), () => {
|
|
9871
|
-
let b = P(f, y), x = z(t, b).xyz, S = z(n, b).xyz, C = F(S, W(lr)), w =
|
|
10098
|
+
let b = P(f, y), x = z(t, b).xyz, S = z(n, b).xyz, C = F(S, W(lr)), w = _u(x.div(C)), T = G(w, 1).toVar(), E = G(x, 1).toVar();
|
|
9872
10099
|
p(m.greaterThan(.5).and(h.lessThan(.5)), () => {
|
|
9873
10100
|
let e = z(r, b), t = e.w.greaterThan(.5), n = M(f).sub(e.x.mul(g)), c = M(y).sub(e.y.mul(v)), m = n.greaterThanEqual(0).and(n.lessThan(M(g))).and(c.greaterThanEqual(0)).and(c.lessThan(M(v)));
|
|
9874
10101
|
p(t.and(m), () => {
|
|
@@ -9877,7 +10104,7 @@ var nu = class extends Ts {
|
|
|
9877
10104
|
return i.mul(l).mul(u);
|
|
9878
10105
|
}, oe = ae(D, k, te), se = ae(O, k, ne), ce = ae(D, ee, re), ue = ae(O, ee, ie), L = oe.add(se).add(ce).add(ue);
|
|
9879
10106
|
p(L.greaterThan(M(.01)), () => {
|
|
9880
|
-
let e = z(o, P(D, k)), t = z(o, P(O, k)), n = z(o, P(D, ee)), r = z(o, P(O, ee)), i = M(1).div(L), a = e.xyz.mul(oe).add(t.xyz.mul(se)).add(n.xyz.mul(ce)).add(r.xyz.mul(ue)).mul(i), c = e.w.mul(oe).add(t.w.mul(se)).add(n.w.mul(ce)).add(r.w.mul(ue)).mul(i), f = z(s, b).x.mul(d).clamp(0, 1), p =
|
|
10107
|
+
let e = z(o, P(D, k)), t = z(o, P(O, k)), n = z(o, P(D, ee)), r = z(o, P(O, ee)), i = M(1).div(L), a = e.xyz.mul(oe).add(t.xyz.mul(se)).add(n.xyz.mul(ce)).add(r.xyz.mul(ue)).mul(i), c = e.w.mul(oe).add(t.w.mul(se)).add(n.w.mul(ce)).add(r.w.mul(ue)).mul(i), f = z(s, b).x.mul(d).clamp(0, 1), p = _u(I(a, w, I(F(M(1).div(c.add(1)), u), M(1), f))), m = le(c.add(1), l);
|
|
9881
10108
|
T.assign(G(p, m)), E.assign(G(p.mul(C), 1));
|
|
9882
10109
|
});
|
|
9883
10110
|
});
|
|
@@ -9989,7 +10216,7 @@ var nu = class extends Ts {
|
|
|
9989
10216
|
dispose() {
|
|
9990
10217
|
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();
|
|
9991
10218
|
}
|
|
9992
|
-
},
|
|
10219
|
+
}, yu = (e) => R(e.equal(e), e, M(0)).clamp(0, 1e7), bu = /* @__PURE__ */ K("\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"), xu = class extends qn {
|
|
9993
10220
|
constructor(e, t = {}) {
|
|
9994
10221
|
super("VarianceEstimation", {
|
|
9995
10222
|
...t,
|
|
@@ -10015,9 +10242,9 @@ var nu = class extends Ts {
|
|
|
10015
10242
|
let n = this._colorTexNode, r = this.temporalAlpha, i = this.varianceBoost, a = this.resW, o = this.resH, s = Le("float", 100);
|
|
10016
10243
|
return f(() => {
|
|
10017
10244
|
let c = oe.x, l = oe.y, u = l.mul(8).add(c), d = N(ze.x).mul(8).sub(1), f = N(ze.y).mul(8).sub(1), m = u.mod(10), h = u.div(10), g = z(n, P(d.add(N(m)).clamp(N(0), N(a).sub(1)), f.add(N(h)).clamp(N(0), N(o).sub(1)))).xyz;
|
|
10018
|
-
s.element(u).assign(
|
|
10245
|
+
s.element(u).assign(yu(Bi(g))), p(u.lessThan(B(36)), () => {
|
|
10019
10246
|
let e = u.add(B(64)), t = e.mod(10), r = e.div(10), i = z(n, P(d.add(N(t)).clamp(N(0), N(a).sub(1)), f.add(N(r)).clamp(N(0), N(o).sub(1)))).xyz;
|
|
10020
|
-
s.element(e).assign(
|
|
10247
|
+
s.element(e).assign(yu(Bi(i)));
|
|
10021
10248
|
}), Re();
|
|
10022
10249
|
let _ = N(ze.x).mul(8).add(N(c)), v = N(ze.y).mul(8).add(N(l));
|
|
10023
10250
|
p(_.lessThan(N(a)).and(v.lessThan(N(o))), () => {
|
|
@@ -10028,7 +10255,7 @@ var nu = class extends Ts {
|
|
|
10028
10255
|
}
|
|
10029
10256
|
n.divAssign(9), a.divAssign(9);
|
|
10030
10257
|
let o = F(a.sub(n.mul(n)), M(0)), u = s.element(l.add(1).mul(10).add(c.add(1))), d = z(t, P(_, v));
|
|
10031
|
-
Ae(e, Ie(B(_), B(v)),
|
|
10258
|
+
Ae(e, Ie(B(_), B(v)), bu(u, d.x, d.y, r, o, i)).toWriteOnly();
|
|
10032
10259
|
});
|
|
10033
10260
|
})().compute([
|
|
10034
10261
|
this._dispatchX,
|
|
@@ -10074,7 +10301,7 @@ var nu = class extends Ts {
|
|
|
10074
10301
|
dispose() {
|
|
10075
10302
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._colorTexNode?.dispose(), this._readTexNodeA?.dispose(), this._readTexNodeB?.dispose();
|
|
10076
10303
|
}
|
|
10077
|
-
},
|
|
10304
|
+
}, Su = /* @__PURE__ */ K("\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 let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), phiNorm );\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"), Cu = class extends qn {
|
|
10078
10305
|
constructor(e, t = {}) {
|
|
10079
10306
|
super("BilateralFiltering", {
|
|
10080
10307
|
...t,
|
|
@@ -10126,7 +10353,7 @@ var nu = class extends Ts {
|
|
|
10126
10353
|
p(f.lessThan(N(h)).and(v.lessThan(N(g))), () => {
|
|
10127
10354
|
let p = P(f, v), y = z(t, p).xyz, b = z(n, p), x = z(r, p).xyz.mul(2).sub(1), S = b.w, C = Bi(y), w = F(z(i, p).xyz, W(lr)), T = F(Bi(w), M(lr)).toVar(), E = z(a, p), D = I(E.z, F(E.z, E.w), u), O = l.mul(xe(F(D, M(0)))).div(T).add(M(1e-4)), k = W(0).toVar(), A = M(0).toVar();
|
|
10128
10355
|
for (let e = 0; e < 5; e++) for (let i = 0; i < 5; i++) {
|
|
10129
|
-
let a = i - 2, l = e - 2, u = _[e * 5 + i], p = f.add(d.mul(a)).clamp(N(0), N(h).sub(1)), m = v.add(d.mul(l)).clamp(N(0), N(g).sub(1)), b = z(t, P(p, m)).xyz, w = z(n, P(p, m)), T = z(r, P(p, m)).xyz.mul(2).sub(1), E = w.w, D =
|
|
10356
|
+
let a = i - 2, l = e - 2, u = _[e * 5 + i], p = f.add(d.mul(a)).clamp(N(0), N(h).sub(1)), m = v.add(d.mul(l)).clamp(N(0), N(g).sub(1)), b = z(t, P(p, m)).xyz, w = z(n, P(p, m)), T = z(r, P(p, m)).xyz.mul(2).sub(1), E = w.w, D = Su(C, Bi(b), x, T, S, E, y, b, M(u), O, s, c, o);
|
|
10130
10357
|
k.addAssign(b.mul(D)), A.addAssign(D);
|
|
10131
10358
|
}
|
|
10132
10359
|
let j = k.div(F(A, M(1e-4))), ee = m.equal(N(1)).select(j.mul(w), j);
|
|
@@ -10177,7 +10404,7 @@ var nu = class extends Ts {
|
|
|
10177
10404
|
dispose() {
|
|
10178
10405
|
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();
|
|
10179
10406
|
}
|
|
10180
|
-
},
|
|
10407
|
+
}, wu = class extends qn {
|
|
10181
10408
|
constructor(e, t = {}) {
|
|
10182
10409
|
super("EdgeAwareFiltering", {
|
|
10183
10410
|
...t,
|
|
@@ -10263,7 +10490,7 @@ var nu = class extends Ts {
|
|
|
10263
10490
|
dispose() {
|
|
10264
10491
|
this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this.outputTarget?.dispose(), this._inputTexNode?.dispose(), this._ndTexNode?.dispose();
|
|
10265
10492
|
}
|
|
10266
|
-
},
|
|
10493
|
+
}, Tu = 256, Eu = -8, Du = 6 - Eu, Ou = Du / Tu, ku = 1e4, Au = /* @__PURE__ */ K("\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"), ju = class extends qn {
|
|
10267
10494
|
constructor(e, t = {}) {
|
|
10268
10495
|
super("AutoExposure", {
|
|
10269
10496
|
...t,
|
|
@@ -10279,7 +10506,7 @@ var nu = class extends Ts {
|
|
|
10279
10506
|
depthBuffer: !1,
|
|
10280
10507
|
stencilBuffer: !1
|
|
10281
10508
|
};
|
|
10282
|
-
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = q, this._downsampleStorageTex.format = Ft, this._downsampleStorageTex.minFilter = wt, this._downsampleStorageTex.magFilter = wt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = q, this._reductionStorageTex.format = Ft, this._reductionStorageTex.minFilter = wt, this._reductionStorageTex.magFilter = wt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(
|
|
10509
|
+
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = q, this._downsampleStorageTex.format = Ft, this._downsampleStorageTex.minFilter = wt, this._downsampleStorageTex.magFilter = wt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = q, this._reductionStorageTex.format = Ft, this._reductionStorageTex.minFilter = wt, this._reductionStorageTex.magFilter = wt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(Tu, "uint").toAtomic();
|
|
10283
10510
|
}
|
|
10284
10511
|
_buildCompute() {
|
|
10285
10512
|
this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
|
|
@@ -10313,7 +10540,7 @@ var nu = class extends Ts {
|
|
|
10313
10540
|
for (let i = 0; i < 16; i++) {
|
|
10314
10541
|
let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = z(e, P(N(o), N(s))), l = c.x, u = c.y;
|
|
10315
10542
|
p(u.greaterThan(0), () => {
|
|
10316
|
-
let e = B(l.div(u).sub(M(
|
|
10543
|
+
let e = B(l.div(u).sub(M(Eu)).div(M(Du)).mul(M(Tu)).floor().clamp(0, M(Tu - 1))), r = M(o).add(.5).div(M(64)), i = M(s).add(.5).div(M(64)), a = r.sub(.5), c = i.sub(.5), d = B(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(M(ku)));
|
|
10317
10544
|
x(t.element(e), d);
|
|
10318
10545
|
});
|
|
10319
10546
|
}
|
|
@@ -10331,14 +10558,14 @@ var nu = class extends Ts {
|
|
|
10331
10558
|
let e = this._histogramBuffer, t = this._reductionStorageTex, n = this.lowPercentileU, r = this.highPercentileU;
|
|
10332
10559
|
this._histogramAnalyzeNode = f(() => {
|
|
10333
10560
|
let i = M(0).toVar();
|
|
10334
|
-
m(
|
|
10561
|
+
m(Tu, ({ i: t }) => {
|
|
10335
10562
|
i.addAssign(M(S(e.element(t))));
|
|
10336
10563
|
});
|
|
10337
10564
|
let a = i.mul(n), o = i.mul(r), s = M(0).toVar(), c = M(0).toVar(), l = M(0).toVar(), u = M(0).toVar();
|
|
10338
|
-
m(
|
|
10565
|
+
m(Tu, ({ i: t }) => {
|
|
10339
10566
|
let n = M(S(e.element(t)));
|
|
10340
10567
|
u.assign(s), s.addAssign(n), p(u.lessThan(o).and(s.greaterThan(a)), () => {
|
|
10341
|
-
let e = M(
|
|
10568
|
+
let e = M(Eu).add(M(t).add(.5).mul(M(Ou)));
|
|
10342
10569
|
c.addAssign(e.mul(n)), l.addAssign(n);
|
|
10343
10570
|
});
|
|
10344
10571
|
});
|
|
@@ -10353,7 +10580,7 @@ var nu = class extends Ts {
|
|
|
10353
10580
|
_buildAdaptationCompute() {
|
|
10354
10581
|
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;
|
|
10355
10582
|
this._adaptationComputeNode = f(() => {
|
|
10356
|
-
let u = z(e, P(N(0), N(0))).x, d =
|
|
10583
|
+
let u = z(e, P(N(0), N(0))).x, d = Au(u, l, n, r, i, a, o, s, c);
|
|
10357
10584
|
t.element(B(0)).assign(d);
|
|
10358
10585
|
})().compute(1, [
|
|
10359
10586
|
1,
|
|
@@ -10420,7 +10647,7 @@ var nu = class extends Ts {
|
|
|
10420
10647
|
};
|
|
10421
10648
|
//#endregion
|
|
10422
10649
|
//#region src/TSL/SSRC.js
|
|
10423
|
-
function
|
|
10650
|
+
function Mu({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode: r, readPrevNDTexNode: i, writeCacheTex: a, writePrevNDTex: o, resW: s, resH: c, temporalAlpha: l, phiNormal: u, phiDepth: d, maxHistory: m, framesSinceReset: h }) {
|
|
10424
10651
|
return f(() => {
|
|
10425
10652
|
let f = N(ze.x).mul(8).add(N(oe.x)), g = N(ze.y).mul(8).add(N(oe.y));
|
|
10426
10653
|
p(f.lessThan(N(s)).and(g.lessThan(N(c))), () => {
|
|
@@ -10442,7 +10669,7 @@ function xu({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode:
|
|
|
10442
10669
|
});
|
|
10443
10670
|
});
|
|
10444
10671
|
}
|
|
10445
|
-
function
|
|
10672
|
+
function Nu({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r, resW: i, resH: a, spatialRadius: o, spatialWeight: s, phiNormal: c, phiDepth: l }) {
|
|
10446
10673
|
let u = [
|
|
10447
10674
|
[1, 0],
|
|
10448
10675
|
[-1, 0],
|
|
@@ -10468,7 +10695,7 @@ function Su({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r,
|
|
|
10468
10695
|
}
|
|
10469
10696
|
//#endregion
|
|
10470
10697
|
//#region src/Stages/SSRC.js
|
|
10471
|
-
var
|
|
10698
|
+
var Pu = class extends qn {
|
|
10472
10699
|
constructor(e, t = {}) {
|
|
10473
10700
|
super("SSRC", {
|
|
10474
10701
|
...t,
|
|
@@ -10553,12 +10780,12 @@ var Cu = class extends qn {
|
|
|
10553
10780
|
phiNormal: this.phiNormal,
|
|
10554
10781
|
phiDepth: this.phiDepth,
|
|
10555
10782
|
maxHistory: this.maxHistory
|
|
10556
|
-
}, t =
|
|
10783
|
+
}, t = Mu({
|
|
10557
10784
|
...e,
|
|
10558
10785
|
writeCacheTex: this._cacheTexA,
|
|
10559
10786
|
writePrevNDTex: this._prevNDTexA,
|
|
10560
10787
|
framesSinceReset: this._framesSinceReset
|
|
10561
|
-
}), n =
|
|
10788
|
+
}), n = Mu({
|
|
10562
10789
|
...e,
|
|
10563
10790
|
writeCacheTex: this._cacheTexB,
|
|
10564
10791
|
writePrevNDTex: this._prevNDTexB,
|
|
@@ -10572,7 +10799,7 @@ var Cu = class extends qn {
|
|
|
10572
10799
|
8,
|
|
10573
10800
|
1
|
|
10574
10801
|
];
|
|
10575
|
-
this._pass1NodeA = t().compute(r, i), this._pass1NodeB = n().compute(r, i), this._pass2Node =
|
|
10802
|
+
this._pass1NodeA = t().compute(r, i), this._pass1NodeB = n().compute(r, i), this._pass2Node = Nu({
|
|
10576
10803
|
colorTexNode: this._colorTexNode,
|
|
10577
10804
|
ndTexNode: this._ndTexNode,
|
|
10578
10805
|
readCacheTexNode: this._readPass1CacheTexNode,
|
|
@@ -10585,7 +10812,7 @@ var Cu = class extends qn {
|
|
|
10585
10812
|
phiDepth: this.phiDepth
|
|
10586
10813
|
})().compute(r, i);
|
|
10587
10814
|
}
|
|
10588
|
-
},
|
|
10815
|
+
}, Fu = class extends qn {
|
|
10589
10816
|
constructor(n, r = {}) {
|
|
10590
10817
|
super("Compositor", {
|
|
10591
10818
|
...r,
|
|
@@ -10611,7 +10838,7 @@ var Cu = class extends qn {
|
|
|
10611
10838
|
dispose() {
|
|
10612
10839
|
this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this.compositorQuad = null;
|
|
10613
10840
|
}
|
|
10614
|
-
},
|
|
10841
|
+
}, Iu = class {
|
|
10615
10842
|
constructor() {
|
|
10616
10843
|
this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
|
|
10617
10844
|
frame: 0,
|
|
@@ -10733,7 +10960,7 @@ var Cu = class extends qn {
|
|
|
10733
10960
|
dispose() {
|
|
10734
10961
|
this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
|
|
10735
10962
|
}
|
|
10736
|
-
},
|
|
10963
|
+
}, Lu = class extends ot {
|
|
10737
10964
|
constructor() {
|
|
10738
10965
|
super(), this._onceCallbacks = /* @__PURE__ */ new Map();
|
|
10739
10966
|
}
|
|
@@ -10771,9 +10998,9 @@ var Cu = class extends qn {
|
|
|
10771
10998
|
eventNames() {
|
|
10772
10999
|
return this._listeners ? Object.keys(this._listeners) : [];
|
|
10773
11000
|
}
|
|
10774
|
-
},
|
|
11001
|
+
}, Ru = class {
|
|
10775
11002
|
constructor(e, t, n) {
|
|
10776
|
-
this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new
|
|
11003
|
+
this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new Iu(), this.eventBus = new Lu(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
|
|
10777
11004
|
enabled: !1,
|
|
10778
11005
|
logSkipped: !1,
|
|
10779
11006
|
timings: /* @__PURE__ */ new Map(),
|
|
@@ -10905,7 +11132,7 @@ var Cu = class extends qn {
|
|
|
10905
11132
|
let e = this.getInfo();
|
|
10906
11133
|
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();
|
|
10907
11134
|
}
|
|
10908
|
-
},
|
|
11135
|
+
}, zu = class {
|
|
10909
11136
|
constructor() {
|
|
10910
11137
|
this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1;
|
|
10911
11138
|
}
|
|
@@ -10927,7 +11154,7 @@ var Cu = class extends qn {
|
|
|
10927
11154
|
resumeFromPause() {
|
|
10928
11155
|
this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
|
|
10929
11156
|
}
|
|
10930
|
-
},
|
|
11157
|
+
}, Bu = class extends ot {
|
|
10931
11158
|
constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
|
|
10932
11159
|
super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new Rt(), 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;
|
|
10933
11160
|
}
|
|
@@ -11148,18 +11375,18 @@ var Cu = class extends qn {
|
|
|
11148
11375
|
dispose() {
|
|
11149
11376
|
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;
|
|
11150
11377
|
}
|
|
11151
|
-
},
|
|
11378
|
+
}, Vu = {
|
|
11152
11379
|
STRING: "string",
|
|
11153
11380
|
NUMBER: "number",
|
|
11154
11381
|
WORD: "word",
|
|
11155
11382
|
LBRACKET: "[",
|
|
11156
11383
|
RBRACKET: "]"
|
|
11157
|
-
},
|
|
11158
|
-
function
|
|
11384
|
+
}, Hu = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f", Uu = (e) => e >= "0" && e <= "9", Wu = (e, t, n) => !!(Uu(e) || e === "." && Uu(t) || (e === "-" || e === "+") && (Uu(t) || t === "." && Uu(n)));
|
|
11385
|
+
function Gu(e) {
|
|
11159
11386
|
let t = [], n = e.length, r = 0;
|
|
11160
11387
|
for (; r < n;) {
|
|
11161
11388
|
let i = e[r];
|
|
11162
|
-
if (
|
|
11389
|
+
if (Hu(i)) {
|
|
11163
11390
|
r++;
|
|
11164
11391
|
continue;
|
|
11165
11392
|
}
|
|
@@ -11168,11 +11395,11 @@ function Pu(e) {
|
|
|
11168
11395
|
continue;
|
|
11169
11396
|
}
|
|
11170
11397
|
if (i === "[") {
|
|
11171
|
-
t.push({ type:
|
|
11398
|
+
t.push({ type: Vu.LBRACKET }), r++;
|
|
11172
11399
|
continue;
|
|
11173
11400
|
}
|
|
11174
11401
|
if (i === "]") {
|
|
11175
|
-
t.push({ type:
|
|
11402
|
+
t.push({ type: Vu.RBRACKET }), r++;
|
|
11176
11403
|
continue;
|
|
11177
11404
|
}
|
|
11178
11405
|
if (i === "\"") {
|
|
@@ -11181,12 +11408,12 @@ function Pu(e) {
|
|
|
11181
11408
|
for (; r < n && e[r] !== "\"";) r++;
|
|
11182
11409
|
if (r >= n) throw Error("PBRT tokenizer: unterminated string literal");
|
|
11183
11410
|
t.push({
|
|
11184
|
-
type:
|
|
11411
|
+
type: Vu.STRING,
|
|
11185
11412
|
value: e.slice(i, r)
|
|
11186
11413
|
}), r++;
|
|
11187
11414
|
continue;
|
|
11188
11415
|
}
|
|
11189
|
-
if (
|
|
11416
|
+
if (Wu(i, e[r + 1], e[r + 2])) {
|
|
11190
11417
|
let i = r;
|
|
11191
11418
|
for (r++; r < n;) {
|
|
11192
11419
|
let t = e[r];
|
|
@@ -11196,16 +11423,16 @@ function Pu(e) {
|
|
|
11196
11423
|
let a = e.slice(i, r), o = Number(a);
|
|
11197
11424
|
if (Number.isNaN(o)) throw Error(`PBRT tokenizer: invalid number "${a}"`);
|
|
11198
11425
|
t.push({
|
|
11199
|
-
type:
|
|
11426
|
+
type: Vu.NUMBER,
|
|
11200
11427
|
value: o
|
|
11201
11428
|
});
|
|
11202
11429
|
continue;
|
|
11203
11430
|
}
|
|
11204
11431
|
{
|
|
11205
11432
|
let i = r;
|
|
11206
|
-
for (; r < n && !
|
|
11433
|
+
for (; r < n && !Hu(e[r]) && e[r] !== "\"" && e[r] !== "[" && e[r] !== "]" && e[r] !== "#";) r++;
|
|
11207
11434
|
t.push({
|
|
11208
|
-
type:
|
|
11435
|
+
type: Vu.WORD,
|
|
11209
11436
|
value: e.slice(i, r)
|
|
11210
11437
|
});
|
|
11211
11438
|
}
|
|
@@ -11214,7 +11441,7 @@ function Pu(e) {
|
|
|
11214
11441
|
}
|
|
11215
11442
|
//#endregion
|
|
11216
11443
|
//#region src/Processor/PBRT/PBRTMath.js
|
|
11217
|
-
function
|
|
11444
|
+
function Ku() {
|
|
11218
11445
|
return [
|
|
11219
11446
|
1,
|
|
11220
11447
|
0,
|
|
@@ -11234,7 +11461,7 @@ function Fu() {
|
|
|
11234
11461
|
1
|
|
11235
11462
|
];
|
|
11236
11463
|
}
|
|
11237
|
-
function
|
|
11464
|
+
function qu(e, t) {
|
|
11238
11465
|
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], k = t[11], A = t[12], j = t[13], M = t[14], ee = t[15];
|
|
11239
11466
|
return [
|
|
11240
11467
|
n * v + o * y + u * b + m * x,
|
|
@@ -11255,7 +11482,7 @@ function Iu(e, t) {
|
|
|
11255
11482
|
a * A + l * j + p * M + _ * ee
|
|
11256
11483
|
];
|
|
11257
11484
|
}
|
|
11258
|
-
function
|
|
11485
|
+
function Ju(e, t, n) {
|
|
11259
11486
|
return [
|
|
11260
11487
|
1,
|
|
11261
11488
|
0,
|
|
@@ -11275,7 +11502,7 @@ function Lu(e, t, n) {
|
|
|
11275
11502
|
1
|
|
11276
11503
|
];
|
|
11277
11504
|
}
|
|
11278
|
-
function
|
|
11505
|
+
function Yu(e, t, n) {
|
|
11279
11506
|
return [
|
|
11280
11507
|
e,
|
|
11281
11508
|
0,
|
|
@@ -11295,7 +11522,7 @@ function Ru(e, t, n) {
|
|
|
11295
11522
|
1
|
|
11296
11523
|
];
|
|
11297
11524
|
}
|
|
11298
|
-
function
|
|
11525
|
+
function Xu(e, t, n, r) {
|
|
11299
11526
|
let i = Math.hypot(t, n, r) || 1;
|
|
11300
11527
|
t /= i, n /= i, r /= i;
|
|
11301
11528
|
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;
|
|
@@ -11318,21 +11545,21 @@ function zu(e, t, n, r) {
|
|
|
11318
11545
|
1
|
|
11319
11546
|
];
|
|
11320
11547
|
}
|
|
11321
|
-
function
|
|
11548
|
+
function Zu(e, t) {
|
|
11322
11549
|
return [
|
|
11323
11550
|
e[0] - t[0],
|
|
11324
11551
|
e[1] - t[1],
|
|
11325
11552
|
e[2] - t[2]
|
|
11326
11553
|
];
|
|
11327
11554
|
}
|
|
11328
|
-
function
|
|
11555
|
+
function Qu(e, t) {
|
|
11329
11556
|
return [
|
|
11330
11557
|
e[1] * t[2] - e[2] * t[1],
|
|
11331
11558
|
e[2] * t[0] - e[0] * t[2],
|
|
11332
11559
|
e[0] * t[1] - e[1] * t[0]
|
|
11333
11560
|
];
|
|
11334
11561
|
}
|
|
11335
|
-
function
|
|
11562
|
+
function $u(e) {
|
|
11336
11563
|
let t = Math.hypot(e[0], e[1], e[2]) || 1;
|
|
11337
11564
|
return [
|
|
11338
11565
|
e[0] / t,
|
|
@@ -11340,8 +11567,8 @@ function Hu(e) {
|
|
|
11340
11567
|
e[2] / t
|
|
11341
11568
|
];
|
|
11342
11569
|
}
|
|
11343
|
-
function
|
|
11344
|
-
let r =
|
|
11570
|
+
function ed(e, t, n) {
|
|
11571
|
+
let r = $u(Zu(t, e)), i = $u(Qu($u(n), r)), a = Qu(r, i);
|
|
11345
11572
|
return [
|
|
11346
11573
|
i[0],
|
|
11347
11574
|
i[1],
|
|
@@ -11361,9 +11588,9 @@ function Uu(e, t, n) {
|
|
|
11361
11588
|
1
|
|
11362
11589
|
];
|
|
11363
11590
|
}
|
|
11364
|
-
function
|
|
11591
|
+
function td(e) {
|
|
11365
11592
|
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;
|
|
11366
|
-
if (x === 0) return
|
|
11593
|
+
if (x === 0) return Ku();
|
|
11367
11594
|
let S = 1 / x;
|
|
11368
11595
|
return [
|
|
11369
11596
|
_ * S,
|
|
@@ -11386,7 +11613,7 @@ function Wu(e) {
|
|
|
11386
11613
|
}
|
|
11387
11614
|
//#endregion
|
|
11388
11615
|
//#region src/Processor/PBRT/PBRTParser.js
|
|
11389
|
-
var
|
|
11616
|
+
var nd = class {
|
|
11390
11617
|
constructor(e = {}) {
|
|
11391
11618
|
this.resolveInclude = e.resolveInclude || (() => {
|
|
11392
11619
|
throw Error("PBRTParser: Include used but no resolveInclude provided");
|
|
@@ -11400,14 +11627,14 @@ var Gu = class {
|
|
|
11400
11627
|
instances: [],
|
|
11401
11628
|
objects: /* @__PURE__ */ new Map(),
|
|
11402
11629
|
warnings: []
|
|
11403
|
-
}, this.ctm =
|
|
11630
|
+
}, this.ctm = Ku(), this.state = {
|
|
11404
11631
|
material: null,
|
|
11405
11632
|
areaLight: null,
|
|
11406
11633
|
reverseOrientation: !1
|
|
11407
11634
|
}, 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();
|
|
11408
11635
|
}
|
|
11409
11636
|
parse(e, t = "") {
|
|
11410
|
-
return this.dirStack = [t], this._run(
|
|
11637
|
+
return this.dirStack = [t], this._run(Gu(e)), this.ir;
|
|
11411
11638
|
}
|
|
11412
11639
|
_peek() {
|
|
11413
11640
|
return this.tokens[this.pos];
|
|
@@ -11417,12 +11644,12 @@ var Gu = class {
|
|
|
11417
11644
|
}
|
|
11418
11645
|
_expectNumber(e) {
|
|
11419
11646
|
let t = this._next();
|
|
11420
|
-
if (!t || t.type !==
|
|
11647
|
+
if (!t || t.type !== Vu.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
|
|
11421
11648
|
return t.value;
|
|
11422
11649
|
}
|
|
11423
11650
|
_expectString(e) {
|
|
11424
11651
|
let t = this._next();
|
|
11425
|
-
if (!t || t.type !==
|
|
11652
|
+
if (!t || t.type !== Vu.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
|
|
11426
11653
|
return t.value;
|
|
11427
11654
|
}
|
|
11428
11655
|
_readNumbers(e) {
|
|
@@ -11431,17 +11658,17 @@ var Gu = class {
|
|
|
11431
11658
|
return t;
|
|
11432
11659
|
}
|
|
11433
11660
|
_readBracketedOrBareNumbers(e) {
|
|
11434
|
-
if (this._peek() && this._peek().type ===
|
|
11661
|
+
if (this._peek() && this._peek().type === Vu.LBRACKET) {
|
|
11435
11662
|
this._next();
|
|
11436
11663
|
let e = [];
|
|
11437
|
-
for (; this._peek() && this._peek().type !==
|
|
11664
|
+
for (; this._peek() && this._peek().type !== Vu.RBRACKET;) e.push(this._expectNumber("transform element"));
|
|
11438
11665
|
return this._next(), e;
|
|
11439
11666
|
}
|
|
11440
11667
|
return this._readNumbers(e);
|
|
11441
11668
|
}
|
|
11442
11669
|
_parseParams() {
|
|
11443
11670
|
let e = {};
|
|
11444
|
-
for (; this._peek() && this._peek().type ===
|
|
11671
|
+
for (; this._peek() && this._peek().type === Vu.STRING;) {
|
|
11445
11672
|
let t = this._next().value.trim().split(/\s+/), n = t[0], r = t[1] === void 0 ? t[0] : t[1];
|
|
11446
11673
|
e[r] = {
|
|
11447
11674
|
type: n,
|
|
@@ -11452,23 +11679,23 @@ var Gu = class {
|
|
|
11452
11679
|
}
|
|
11453
11680
|
_parseParamValue() {
|
|
11454
11681
|
let e = [];
|
|
11455
|
-
if (this._peek() && this._peek().type ===
|
|
11456
|
-
for (this._next(); this._peek() && this._peek().type !==
|
|
11682
|
+
if (this._peek() && this._peek().type === Vu.LBRACKET) {
|
|
11683
|
+
for (this._next(); this._peek() && this._peek().type !== Vu.RBRACKET;) e.push(this._coerceValueToken(this._next()));
|
|
11457
11684
|
this._next();
|
|
11458
11685
|
} else e.push(this._coerceValueToken(this._next()));
|
|
11459
11686
|
return e;
|
|
11460
11687
|
}
|
|
11461
11688
|
_coerceValueToken(e) {
|
|
11462
11689
|
if (!e) throw Error("PBRT parser: unexpected EOF in parameter value");
|
|
11463
|
-
if (e.type ===
|
|
11464
|
-
if (e.type ===
|
|
11690
|
+
if (e.type === Vu.NUMBER || e.type === Vu.STRING) return e.value;
|
|
11691
|
+
if (e.type === Vu.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
|
|
11465
11692
|
throw Error(`PBRT parser: unexpected token in parameter value: ${e.type}`);
|
|
11466
11693
|
}
|
|
11467
11694
|
_run(e) {
|
|
11468
11695
|
let t = this.tokens, n = this.pos;
|
|
11469
11696
|
for (this.tokens = e, this.pos = 0; this.pos < this.tokens.length;) {
|
|
11470
11697
|
let e = this._next();
|
|
11471
|
-
if (e.type !==
|
|
11698
|
+
if (e.type !== Vu.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
|
|
11472
11699
|
this._directive(e.value);
|
|
11473
11700
|
}
|
|
11474
11701
|
this.tokens = t, this.pos = n;
|
|
@@ -11476,25 +11703,25 @@ var Gu = class {
|
|
|
11476
11703
|
_directive(e) {
|
|
11477
11704
|
switch (e) {
|
|
11478
11705
|
case "Identity":
|
|
11479
|
-
this.ctm =
|
|
11706
|
+
this.ctm = Ku();
|
|
11480
11707
|
break;
|
|
11481
11708
|
case "Translate": {
|
|
11482
11709
|
let [e, t, n] = this._readNumbers(3);
|
|
11483
|
-
this.ctm =
|
|
11710
|
+
this.ctm = qu(this.ctm, Ju(e, t, n));
|
|
11484
11711
|
break;
|
|
11485
11712
|
}
|
|
11486
11713
|
case "Scale": {
|
|
11487
11714
|
let [e, t, n] = this._readNumbers(3);
|
|
11488
|
-
this.ctm =
|
|
11715
|
+
this.ctm = qu(this.ctm, Yu(e, t, n));
|
|
11489
11716
|
break;
|
|
11490
11717
|
}
|
|
11491
11718
|
case "Rotate": {
|
|
11492
11719
|
let [e, t, n, r] = this._readNumbers(4);
|
|
11493
|
-
this.ctm =
|
|
11720
|
+
this.ctm = qu(this.ctm, Xu(e, t, n, r));
|
|
11494
11721
|
break;
|
|
11495
11722
|
}
|
|
11496
11723
|
case "LookAt": {
|
|
11497
|
-
let e = this._readNumbers(9), t =
|
|
11724
|
+
let e = this._readNumbers(9), t = ed([
|
|
11498
11725
|
e[0],
|
|
11499
11726
|
e[1],
|
|
11500
11727
|
e[2]
|
|
@@ -11507,7 +11734,7 @@ var Gu = class {
|
|
|
11507
11734
|
e[7],
|
|
11508
11735
|
e[8]
|
|
11509
11736
|
]);
|
|
11510
|
-
this.ctm =
|
|
11737
|
+
this.ctm = qu(this.ctm, td(t));
|
|
11511
11738
|
break;
|
|
11512
11739
|
}
|
|
11513
11740
|
case "Transform":
|
|
@@ -11515,7 +11742,7 @@ var Gu = class {
|
|
|
11515
11742
|
break;
|
|
11516
11743
|
case "ConcatTransform": {
|
|
11517
11744
|
let e = this._readBracketedOrBareNumbers(16);
|
|
11518
|
-
this.ctm =
|
|
11745
|
+
this.ctm = qu(this.ctm, e);
|
|
11519
11746
|
break;
|
|
11520
11747
|
}
|
|
11521
11748
|
case "CoordinateSystem":
|
|
@@ -11531,7 +11758,7 @@ var Gu = class {
|
|
|
11531
11758
|
this.ir.camera = {
|
|
11532
11759
|
type: e,
|
|
11533
11760
|
params: t,
|
|
11534
|
-
cameraToWorld:
|
|
11761
|
+
cameraToWorld: td(this.ctm)
|
|
11535
11762
|
};
|
|
11536
11763
|
break;
|
|
11537
11764
|
}
|
|
@@ -11555,7 +11782,7 @@ var Gu = class {
|
|
|
11555
11782
|
this._skipTypeAndParams();
|
|
11556
11783
|
break;
|
|
11557
11784
|
case "WorldBegin":
|
|
11558
|
-
this.ctm =
|
|
11785
|
+
this.ctm = Ku(), this.state = {
|
|
11559
11786
|
material: null,
|
|
11560
11787
|
areaLight: null,
|
|
11561
11788
|
reverseOrientation: !1
|
|
@@ -11600,7 +11827,7 @@ var Gu = class {
|
|
|
11600
11827
|
this._readNumbers(2);
|
|
11601
11828
|
break;
|
|
11602
11829
|
case "MediumInterface":
|
|
11603
|
-
this._peek() && this._peek().type ===
|
|
11830
|
+
this._peek() && this._peek().type === Vu.STRING && this._next(), this._peek() && this._peek().type === Vu.STRING && this._next();
|
|
11604
11831
|
break;
|
|
11605
11832
|
case "MakeNamedMedium":
|
|
11606
11833
|
this._skipNamedAndParams();
|
|
@@ -11708,7 +11935,7 @@ var Gu = class {
|
|
|
11708
11935
|
}
|
|
11709
11936
|
}
|
|
11710
11937
|
_emitShape(e) {
|
|
11711
|
-
this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM =
|
|
11938
|
+
this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM = qu(td(this.objectBeginCTM), e.ctm), this.ir.objects.get(this.currentObject).push(e));
|
|
11712
11939
|
}
|
|
11713
11940
|
_include(e) {
|
|
11714
11941
|
let t = this.resolveInclude(e, this.dirStack[this.dirStack.length - 1]);
|
|
@@ -11717,13 +11944,13 @@ var Gu = class {
|
|
|
11717
11944
|
return;
|
|
11718
11945
|
}
|
|
11719
11946
|
let n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
|
|
11720
|
-
this.dirStack.push(n), this._run(
|
|
11947
|
+
this.dirStack.push(n), this._run(Gu(t)), this.dirStack.pop();
|
|
11721
11948
|
}
|
|
11722
11949
|
_skipTypeAndParams() {
|
|
11723
|
-
this._peek() && this._peek().type ===
|
|
11950
|
+
this._peek() && this._peek().type === Vu.STRING && this._next(), this._parseParams();
|
|
11724
11951
|
}
|
|
11725
11952
|
_skipNamedAndParams() {
|
|
11726
|
-
this._peek() && this._peek().type ===
|
|
11953
|
+
this._peek() && this._peek().type === Vu.STRING && this._next(), this._parseParams();
|
|
11727
11954
|
}
|
|
11728
11955
|
_num(e, t) {
|
|
11729
11956
|
return e && e.value.length ? e.value[0] : t;
|
|
@@ -11737,7 +11964,7 @@ var Gu = class {
|
|
|
11737
11964
|
_warnUnknown(e) {
|
|
11738
11965
|
this._warnedUnknown.has(e) || (this._warnedUnknown.add(e), this._warn(`Unsupported directive ignored: ${e}`));
|
|
11739
11966
|
}
|
|
11740
|
-
},
|
|
11967
|
+
}, rd = {
|
|
11741
11968
|
au: [
|
|
11742
11969
|
1,
|
|
11743
11970
|
.78,
|
|
@@ -11793,12 +12020,12 @@ var Gu = class {
|
|
|
11793
12020
|
.9,
|
|
11794
12021
|
.9
|
|
11795
12022
|
]
|
|
11796
|
-
},
|
|
12023
|
+
}, id = [
|
|
11797
12024
|
.92,
|
|
11798
12025
|
.92,
|
|
11799
12026
|
.92
|
|
11800
12027
|
];
|
|
11801
|
-
function
|
|
12028
|
+
function ad(e) {
|
|
11802
12029
|
let t = Math.max(1e3, Math.min(4e4, e)) / 100, n, r, i;
|
|
11803
12030
|
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;
|
|
11804
12031
|
let a = (e) => Math.max(0, Math.min(255, e)) / 255;
|
|
@@ -11808,15 +12035,15 @@ function Ju(e) {
|
|
|
11808
12035
|
a(i) ** 2.2
|
|
11809
12036
|
];
|
|
11810
12037
|
}
|
|
11811
|
-
function
|
|
12038
|
+
function od(e, t, n) {
|
|
11812
12039
|
let r = e[t];
|
|
11813
12040
|
return r && typeof r.value[0] == "number" ? r.value[0] : n;
|
|
11814
12041
|
}
|
|
11815
|
-
function
|
|
12042
|
+
function sd(e, t, n) {
|
|
11816
12043
|
let r = e[t];
|
|
11817
12044
|
return r && typeof r.value[0] == "string" ? r.value[0] : n;
|
|
11818
12045
|
}
|
|
11819
|
-
async function
|
|
12046
|
+
async function cd(e, t, n, r = null) {
|
|
11820
12047
|
let i = e[t];
|
|
11821
12048
|
if (!i) return {
|
|
11822
12049
|
rgb: r,
|
|
@@ -11855,14 +12082,14 @@ async function Zu(e, t, n, r = null) {
|
|
|
11855
12082
|
};
|
|
11856
12083
|
}
|
|
11857
12084
|
if (i.type === "blackbody") return {
|
|
11858
|
-
rgb:
|
|
12085
|
+
rgb: ad(i.value[0]),
|
|
11859
12086
|
texture: null
|
|
11860
12087
|
};
|
|
11861
12088
|
if (i.type === "spectrum") {
|
|
11862
12089
|
if (typeof i.value[0] == "string") {
|
|
11863
|
-
let e =
|
|
11864
|
-
return e &&
|
|
11865
|
-
rgb:
|
|
12090
|
+
let e = ld(i.value[0]);
|
|
12091
|
+
return e && rd[e] ? {
|
|
12092
|
+
rgb: rd[e].slice(),
|
|
11866
12093
|
texture: null
|
|
11867
12094
|
} : (n.warn(`named spectrum "${i.value[0]}" approximated to gray`), {
|
|
11868
12095
|
rgb: [
|
|
@@ -11890,18 +12117,18 @@ async function Zu(e, t, n, r = null) {
|
|
|
11890
12117
|
texture: null
|
|
11891
12118
|
};
|
|
11892
12119
|
}
|
|
11893
|
-
function
|
|
12120
|
+
function ld(e) {
|
|
11894
12121
|
let t = e.toLowerCase().match(/metal-([a-z]+)/);
|
|
11895
12122
|
if (t) return t[1];
|
|
11896
|
-
for (let t of Object.keys(
|
|
12123
|
+
for (let t of Object.keys(rd)) if (e.toLowerCase().includes(t)) return t;
|
|
11897
12124
|
return null;
|
|
11898
12125
|
}
|
|
11899
|
-
function
|
|
12126
|
+
function ud(e, t) {
|
|
11900
12127
|
if (e.roughness && typeof e.roughness.value[0] == "number") return e.roughness.value[0];
|
|
11901
|
-
let n =
|
|
12128
|
+
let n = od(e, "uroughness", null), r = od(e, "vroughness", null);
|
|
11902
12129
|
return n !== null && r !== null ? (n + r) / 2 : n === null ? t : n;
|
|
11903
12130
|
}
|
|
11904
|
-
async function
|
|
12131
|
+
async function dd(e, t) {
|
|
11905
12132
|
let n = e?.type || "diffuse", r = e?.params || {}, i = new St({
|
|
11906
12133
|
side: it,
|
|
11907
12134
|
roughness: 1,
|
|
@@ -11913,7 +12140,7 @@ async function ed(e, t) {
|
|
|
11913
12140
|
};
|
|
11914
12141
|
switch (n) {
|
|
11915
12142
|
case "diffuse":
|
|
11916
|
-
o(await
|
|
12143
|
+
o(await cd(r, "reflectance", t, [
|
|
11917
12144
|
.5,
|
|
11918
12145
|
.5,
|
|
11919
12146
|
.5
|
|
@@ -11921,14 +12148,14 @@ async function ed(e, t) {
|
|
|
11921
12148
|
break;
|
|
11922
12149
|
case "conductor":
|
|
11923
12150
|
case "metal": {
|
|
11924
|
-
let e = await
|
|
12151
|
+
let e = await cd(r, "reflectance", t, null), n = r.eta, s = r.k, c = n && n.type === "spectrum" && typeof n.value[0] == "string";
|
|
11925
12152
|
if (e.rgb || e.texture) o(e);
|
|
11926
12153
|
else if (n && s && !c) {
|
|
11927
|
-
let e = (await
|
|
12154
|
+
let e = (await cd(r, "eta", t, [
|
|
11928
12155
|
.2,
|
|
11929
12156
|
.92,
|
|
11930
12157
|
1.1
|
|
11931
|
-
])).rgb, n = (await
|
|
12158
|
+
])).rgb, n = (await cd(r, "k", t, [
|
|
11932
12159
|
3.9,
|
|
11933
12160
|
2.45,
|
|
11934
12161
|
2.14
|
|
@@ -11938,28 +12165,28 @@ async function ed(e, t) {
|
|
|
11938
12165
|
i(e[1], n[1]),
|
|
11939
12166
|
i(e[2], n[2])
|
|
11940
12167
|
]);
|
|
11941
|
-
} else a(n ? (await
|
|
11942
|
-
i.metalness = 1, i.roughness =
|
|
12168
|
+
} else a(n ? (await cd(r, "eta", t, id)).rgb || id : rd.cu);
|
|
12169
|
+
i.metalness = 1, i.roughness = ud(r, .1);
|
|
11943
12170
|
break;
|
|
11944
12171
|
}
|
|
11945
12172
|
case "dielectric":
|
|
11946
12173
|
case "thindielectric":
|
|
11947
|
-
i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior =
|
|
12174
|
+
i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = od(r, "eta", 1.5), i.roughness = ud(r, 0), i.thickness = n === "thindielectric" ? 0 : od(r, "thickness", 0);
|
|
11948
12175
|
break;
|
|
11949
12176
|
case "coateddiffuse":
|
|
11950
|
-
o(await
|
|
12177
|
+
o(await cd(r, "reflectance", t, [
|
|
11951
12178
|
.5,
|
|
11952
12179
|
.5,
|
|
11953
12180
|
.5
|
|
11954
|
-
])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness =
|
|
12181
|
+
])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness = ud(r, 0);
|
|
11955
12182
|
break;
|
|
11956
12183
|
case "diffusetransmission": {
|
|
11957
|
-
let e = await
|
|
12184
|
+
let e = await cd(r, "transmittance", t, [
|
|
11958
12185
|
.25,
|
|
11959
12186
|
.25,
|
|
11960
12187
|
.25
|
|
11961
12188
|
]);
|
|
11962
|
-
o(await
|
|
12189
|
+
o(await cd(r, "reflectance", t, [
|
|
11963
12190
|
.25,
|
|
11964
12191
|
.25,
|
|
11965
12192
|
.25
|
|
@@ -11972,9 +12199,9 @@ async function ed(e, t) {
|
|
|
11972
12199
|
i.transmission = 1, i.ior = 1, i.roughness = 0, i.color.setRGB(1, 1, 1);
|
|
11973
12200
|
break;
|
|
11974
12201
|
case "mix": {
|
|
11975
|
-
let e = r.materials?.value || [], n = Math.max(0, Math.min(1,
|
|
12202
|
+
let e = r.materials?.value || [], n = Math.max(0, Math.min(1, od(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
|
|
11976
12203
|
if (a && o) {
|
|
11977
|
-
let [e, r] = await Promise.all([
|
|
12204
|
+
let [e, r] = await Promise.all([dd(a, t), dd(o, t)]), s = (e, t) => e * (1 - n) + t * n;
|
|
11978
12205
|
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;
|
|
11979
12206
|
break;
|
|
11980
12207
|
}
|
|
@@ -11984,7 +12211,7 @@ async function ed(e, t) {
|
|
|
11984
12211
|
case "subsurface":
|
|
11985
12212
|
case "hair":
|
|
11986
12213
|
case "measured":
|
|
11987
|
-
t.warn(`material "${n}" not supported — using diffuse approximation`), a((await
|
|
12214
|
+
t.warn(`material "${n}" not supported — using diffuse approximation`), a((await cd(r, "reflectance", t, [
|
|
11988
12215
|
.5,
|
|
11989
12216
|
.5,
|
|
11990
12217
|
.5
|
|
@@ -11998,7 +12225,7 @@ async function ed(e, t) {
|
|
|
11998
12225
|
}
|
|
11999
12226
|
//#endregion
|
|
12000
12227
|
//#region src/Processor/PBRT/PBRTSceneBuilder.js
|
|
12001
|
-
var
|
|
12228
|
+
var fd = [
|
|
12002
12229
|
1,
|
|
12003
12230
|
0,
|
|
12004
12231
|
0,
|
|
@@ -12015,7 +12242,7 @@ var td = [
|
|
|
12015
12242
|
0,
|
|
12016
12243
|
0,
|
|
12017
12244
|
1
|
|
12018
|
-
],
|
|
12245
|
+
], pd = class {
|
|
12019
12246
|
constructor(e = {}) {
|
|
12020
12247
|
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();
|
|
12021
12248
|
}
|
|
@@ -12051,7 +12278,7 @@ var td = [
|
|
|
12051
12278
|
continue;
|
|
12052
12279
|
}
|
|
12053
12280
|
for (let e of i) {
|
|
12054
|
-
let i =
|
|
12281
|
+
let i = qu(r.ctm, e.relativeCTM || e.ctm), a = await this._buildShapeMesh(e, i, `instance_${n++}`);
|
|
12055
12282
|
a && t.add(a);
|
|
12056
12283
|
}
|
|
12057
12284
|
}
|
|
@@ -12063,7 +12290,7 @@ var td = [
|
|
|
12063
12290
|
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);
|
|
12064
12291
|
let s = new bt(r, o);
|
|
12065
12292
|
s.name = n;
|
|
12066
|
-
let c = this.convertHandedness ?
|
|
12293
|
+
let c = this.convertHandedness ? qu(fd, t) : t;
|
|
12067
12294
|
new yt().fromArray(c).decompose(s.position, s.quaternion, s.scale), s.updateMatrix(), r.computeBoundingBox();
|
|
12068
12295
|
let l = r.boundingBox ? r.boundingBox.clone().applyMatrix4(s.matrix).getSize(new nn()) : new nn();
|
|
12069
12296
|
return this.report.push({
|
|
@@ -12118,7 +12345,7 @@ var td = [
|
|
|
12118
12345
|
return i.setAttribute("position", new st(Float32Array.from(t), 3)), i.setIndex(r), i.computeVertexNormals(), i;
|
|
12119
12346
|
}
|
|
12120
12347
|
async _plyMesh(e) {
|
|
12121
|
-
let t =
|
|
12348
|
+
let t = sd(e, "filename", null);
|
|
12122
12349
|
if (!t) return this.warn("plymesh missing filename"), null;
|
|
12123
12350
|
try {
|
|
12124
12351
|
let e = await this.resolvePLY(t);
|
|
@@ -12128,10 +12355,10 @@ var td = [
|
|
|
12128
12355
|
}
|
|
12129
12356
|
}
|
|
12130
12357
|
_sphere(e) {
|
|
12131
|
-
return new Kt(
|
|
12358
|
+
return new Kt(od(e, "radius", 1), 48, 32);
|
|
12132
12359
|
}
|
|
12133
12360
|
_disk(e) {
|
|
12134
|
-
let t =
|
|
12361
|
+
let t = od(e, "radius", 1), n = od(e, "innerradius", 0), r = od(e, "height", 0), i = [], a = [];
|
|
12135
12362
|
for (let e = 0; e < 48; e++) {
|
|
12136
12363
|
let o = e / 48 * Math.PI * 2, s = (e + 1) / 48 * Math.PI * 2, c = i.length / 3;
|
|
12137
12364
|
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);
|
|
@@ -12146,15 +12373,15 @@ var td = [
|
|
|
12146
12373
|
resolveNamedTexture: (e) => this._resolveNamedTexture(e),
|
|
12147
12374
|
namedMaterials: this.ir.namedMaterials,
|
|
12148
12375
|
warn: (e) => this.warn(e)
|
|
12149
|
-
}, r = await
|
|
12376
|
+
}, r = await dd(e.material, n);
|
|
12150
12377
|
return e.areaLight && await this._applyAreaLight(r, e.areaLight, n), t.set(e.areaLight, r), r;
|
|
12151
12378
|
}
|
|
12152
12379
|
async _applyAreaLight(e, t, n) {
|
|
12153
|
-
let r = await
|
|
12380
|
+
let r = await cd(t.params, "L", n, [
|
|
12154
12381
|
1,
|
|
12155
12382
|
1,
|
|
12156
12383
|
1
|
|
12157
|
-
]), i =
|
|
12384
|
+
]), i = od(t.params, "scale", 1), a = r.rgb || [
|
|
12158
12385
|
1,
|
|
12159
12386
|
1,
|
|
12160
12387
|
1
|
|
@@ -12166,7 +12393,7 @@ var td = [
|
|
|
12166
12393
|
let t = this.ir.namedTextures.get(e), n = null;
|
|
12167
12394
|
if (!t) this.warn(`named texture "${e}" not defined`);
|
|
12168
12395
|
else if (t.class === "imagemap") {
|
|
12169
|
-
let r =
|
|
12396
|
+
let r = sd(t.params, "filename", null);
|
|
12170
12397
|
if (r) try {
|
|
12171
12398
|
let t = await this.resolveImage(r);
|
|
12172
12399
|
t ? n = { texture: t } : this.warn(`image not found for texture "${e}": ${r}`);
|
|
@@ -12254,7 +12481,7 @@ var td = [
|
|
|
12254
12481
|
return c.name = "PBRT Camera", c.up.copy(a.normalize()), c.position.copy(r), c.lookAt(o), c.updateMatrixWorld(!0), c;
|
|
12255
12482
|
}
|
|
12256
12483
|
_verticalFov(e, t) {
|
|
12257
|
-
let n =
|
|
12484
|
+
let n = od(e, "fov", 90);
|
|
12258
12485
|
if (t >= 1) return n;
|
|
12259
12486
|
let r = n * Math.PI / 180;
|
|
12260
12487
|
return 2 * Math.atan(Math.tan(r / 2) / t) * 180 / Math.PI;
|
|
@@ -12262,7 +12489,7 @@ var td = [
|
|
|
12262
12489
|
async _buildEnvironment(e) {
|
|
12263
12490
|
let t = e.find((e) => e.type === "infinite");
|
|
12264
12491
|
if (!t) return null;
|
|
12265
|
-
let n =
|
|
12492
|
+
let n = od(t.params, "scale", 1), r = sd(t.params, "filename", null);
|
|
12266
12493
|
if (r) try {
|
|
12267
12494
|
let e = await this.resolveEnvironment(r);
|
|
12268
12495
|
if (e) return e.mapping = at, { texture: e };
|
|
@@ -12270,7 +12497,7 @@ var td = [
|
|
|
12270
12497
|
} catch (e) {
|
|
12271
12498
|
this.warn(`failed to load infinite-light image ${r}: ${e.message}`);
|
|
12272
12499
|
}
|
|
12273
|
-
let i = ((await
|
|
12500
|
+
let i = ((await cd(t.params, "L", {
|
|
12274
12501
|
resolveNamedTexture: async () => null,
|
|
12275
12502
|
warn: (e) => this.warn(e)
|
|
12276
12503
|
}, [
|
|
@@ -12289,20 +12516,20 @@ var td = [
|
|
|
12289
12516
|
_reportUnsupportedLights(e) {
|
|
12290
12517
|
for (let t of e) t.type !== "infinite" && this.warn(`light "${t.type}" not supported (only infinite lights and emissive area lights are mapped)`);
|
|
12291
12518
|
}
|
|
12292
|
-
},
|
|
12293
|
-
function
|
|
12519
|
+
}, md = new TextDecoder();
|
|
12520
|
+
function hd(e) {
|
|
12294
12521
|
let t = e.replace(/\\/g, "/").split("/"), n = [];
|
|
12295
12522
|
for (let e of t) e === "" || e === "." || (e === ".." ? n.pop() : n.push(e));
|
|
12296
12523
|
return n.join("/");
|
|
12297
12524
|
}
|
|
12298
|
-
function
|
|
12299
|
-
return !e || t.startsWith("/") ?
|
|
12525
|
+
function gd(e, t) {
|
|
12526
|
+
return !e || t.startsWith("/") ? hd(t) : hd(`${e}/${t}`);
|
|
12300
12527
|
}
|
|
12301
|
-
var
|
|
12528
|
+
var _d = class {
|
|
12302
12529
|
constructor(e) {
|
|
12303
12530
|
this.byPath = /* @__PURE__ */ new Map(), this.byBase = /* @__PURE__ */ new Map();
|
|
12304
12531
|
for (let t in e) {
|
|
12305
|
-
let n =
|
|
12532
|
+
let n = hd(t).toLowerCase(), r = {
|
|
12306
12533
|
norm: n,
|
|
12307
12534
|
bytes: e[t]
|
|
12308
12535
|
};
|
|
@@ -12312,13 +12539,13 @@ var od = class {
|
|
|
12312
12539
|
}
|
|
12313
12540
|
}
|
|
12314
12541
|
find(e) {
|
|
12315
|
-
let t =
|
|
12542
|
+
let t = hd(e).toLowerCase();
|
|
12316
12543
|
if (this.byPath.has(t)) return this.byPath.get(t).bytes;
|
|
12317
12544
|
let n = this.byBase.get(t.split("/").pop());
|
|
12318
12545
|
return n ? (n.find((e) => e.norm.endsWith("/" + t)) || n[0]).bytes : null;
|
|
12319
12546
|
}
|
|
12320
12547
|
};
|
|
12321
|
-
function
|
|
12548
|
+
function vd(e) {
|
|
12322
12549
|
let t = Object.keys(e).filter((e) => e.toLowerCase().endsWith(".pbrt"));
|
|
12323
12550
|
if (t.length === 0) return null;
|
|
12324
12551
|
let n = t.filter((e) => /(^|\/)(scene|main)\.pbrt$/i.test(e)), r = n.length ? n : t;
|
|
@@ -12327,17 +12554,17 @@ function sd(e) {
|
|
|
12327
12554
|
return n === r ? e.length - t.length : n - r;
|
|
12328
12555
|
}), r[0];
|
|
12329
12556
|
}
|
|
12330
|
-
async function
|
|
12331
|
-
let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new
|
|
12557
|
+
async function yd(e) {
|
|
12558
|
+
let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new _d(t), s = e.entryPath || vd(t);
|
|
12332
12559
|
if (!s) throw Error("PBRT loader: no .pbrt file found in archive");
|
|
12333
12560
|
let c = o.find(s);
|
|
12334
12561
|
if (!c) throw Error(`PBRT loader: entry "${s}" not readable`);
|
|
12335
|
-
let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new
|
|
12336
|
-
let n = o.find(
|
|
12337
|
-
return n ?
|
|
12338
|
-
} }).parse(
|
|
12562
|
+
let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new nd({ resolveInclude: (e, t) => {
|
|
12563
|
+
let n = o.find(gd(t, e)) || o.find(e);
|
|
12564
|
+
return n ? md.decode(n) : null;
|
|
12565
|
+
} }).parse(md.decode(c), l), d = (e) => e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
|
|
12339
12566
|
return {
|
|
12340
|
-
...await new
|
|
12567
|
+
...await new pd({
|
|
12341
12568
|
convertHandedness: a,
|
|
12342
12569
|
resolvePLY: async (e) => {
|
|
12343
12570
|
let t = o.find(e);
|
|
@@ -12357,7 +12584,7 @@ async function cd(e) {
|
|
|
12357
12584
|
}
|
|
12358
12585
|
//#endregion
|
|
12359
12586
|
//#region src/Processor/AssetLoader.js
|
|
12360
|
-
var
|
|
12587
|
+
var bd = {
|
|
12361
12588
|
glb: {
|
|
12362
12589
|
type: "model",
|
|
12363
12590
|
name: "GLB (GLTF Binary)"
|
|
@@ -12422,7 +12649,7 @@ var ld = {
|
|
|
12422
12649
|
type: "archive",
|
|
12423
12650
|
name: "ZIP Archive"
|
|
12424
12651
|
}
|
|
12425
|
-
},
|
|
12652
|
+
}, xd = class extends ot {
|
|
12426
12653
|
constructor(e, t, n) {
|
|
12427
12654
|
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this._externalModel = null, this.floorPlane = null, this.sceneScale = 1, this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null;
|
|
12428
12655
|
}
|
|
@@ -12433,7 +12660,7 @@ var ld = {
|
|
|
12433
12660
|
this.renderer = e;
|
|
12434
12661
|
}
|
|
12435
12662
|
getFileFormat(e) {
|
|
12436
|
-
return
|
|
12663
|
+
return bd[e.split(".").pop().toLowerCase()] || null;
|
|
12437
12664
|
}
|
|
12438
12665
|
readFileAsArrayBuffer(e) {
|
|
12439
12666
|
return new Promise((t, n) => {
|
|
@@ -12567,7 +12794,7 @@ var ld = {
|
|
|
12567
12794
|
async loadArchiveFromFile(e, t) {
|
|
12568
12795
|
try {
|
|
12569
12796
|
let n = await this.readFileAsArrayBuffer(e), r = mn(new Uint8Array(n));
|
|
12570
|
-
return
|
|
12797
|
+
return vd(r) ? await this.loadPBRTFromZip(r, t) : await this.processObjMtlPairsInZip(r, t) || await this.findAndLoadModelFromZip(r, t);
|
|
12571
12798
|
} catch (e) {
|
|
12572
12799
|
throw console.error("Error loading ZIP archive:", e), e;
|
|
12573
12800
|
}
|
|
@@ -12581,7 +12808,7 @@ var ld = {
|
|
|
12581
12808
|
let { PLYLoader: e } = await import("three/examples/jsm/loaders/PLYLoader.js");
|
|
12582
12809
|
this.loaderCache.ply = new e();
|
|
12583
12810
|
}
|
|
12584
|
-
let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await
|
|
12811
|
+
let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await yd({
|
|
12585
12812
|
vfs: e,
|
|
12586
12813
|
plyParser: (e) => this.loaderCache.ply.parse(e),
|
|
12587
12814
|
imageFromBytes: (e, t) => this._pbrtTextureFromBytes(e, t),
|
|
@@ -12680,7 +12907,7 @@ var ld = {
|
|
|
12680
12907
|
}
|
|
12681
12908
|
for (let t in e) {
|
|
12682
12909
|
let n = t.split(".").pop().toLowerCase();
|
|
12683
|
-
if (
|
|
12910
|
+
if (bd[n] && bd[n].type === "model") return console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e);
|
|
12684
12911
|
}
|
|
12685
12912
|
throw Error("No supported model files found in the ZIP archive");
|
|
12686
12913
|
}
|
|
@@ -12838,7 +13065,7 @@ var ld = {
|
|
|
12838
13065
|
return null;
|
|
12839
13066
|
}
|
|
12840
13067
|
async createGLTFLoader() {
|
|
12841
|
-
let { dracoDecoderPath: e, ktx2TranscoderPath: t } =
|
|
13068
|
+
let { dracoDecoderPath: e, ktx2TranscoderPath: t } = js(), n = new cn();
|
|
12842
13069
|
n.setDecoderConfig({ type: "js" }), n.setDecoderPath(e);
|
|
12843
13070
|
let r = new ln();
|
|
12844
13071
|
r.setTranscoderPath(t), this.renderer && (r.detectSupport(this.renderer), r.workerConfig = {
|
|
@@ -13127,7 +13354,7 @@ var ld = {
|
|
|
13127
13354
|
}), e;
|
|
13128
13355
|
}
|
|
13129
13356
|
async onModelLoad(e) {
|
|
13130
|
-
let t = new
|
|
13357
|
+
let t = new ys("onModelLoad");
|
|
13131
13358
|
t.start("Camera extraction");
|
|
13132
13359
|
let n = this.extractCamerasFromModel(e);
|
|
13133
13360
|
t.end("Camera extraction"), t.start("Camera setup");
|
|
@@ -13171,8 +13398,8 @@ var ld = {
|
|
|
13171
13398
|
e.traverse((e) => {
|
|
13172
13399
|
let n = e.userData;
|
|
13173
13400
|
if (e.isRectAreaLight && !t.includes(e.uuid) && t.push(e.uuid), e.name.startsWith("RectAreaLightPlaceholder") && n.name && n.type === "RectAreaLight") {
|
|
13174
|
-
let r = new zt(new Qe(...n.color), n.intensity * .1
|
|
13175
|
-
r.position.z = -2, r.name = n.name, e.add(r), t.push(r.uuid);
|
|
13401
|
+
let r = new zt(new Qe(...n.color), n.intensity * .1, n.width, n.height);
|
|
13402
|
+
r.userData.normalize = n.normalize ?? !0, r.userData.spread = Number.isFinite(n.spread) ? n.spread : Math.PI, r.userData.shape = n.shape ?? "rectangle", r.position.z = -2, r.name = n.name, e.add(r), t.push(r.uuid);
|
|
13176
13403
|
}
|
|
13177
13404
|
if (e.isMesh && Array.isArray(e.material)) {
|
|
13178
13405
|
console.log("Found multi-material mesh:", e.name);
|
|
@@ -13206,10 +13433,10 @@ var ld = {
|
|
|
13206
13433
|
getSupportedFormats(e = null) {
|
|
13207
13434
|
if (e) {
|
|
13208
13435
|
let t = {};
|
|
13209
|
-
for (let [n, r] of Object.entries(
|
|
13436
|
+
for (let [n, r] of Object.entries(bd)) r.type === e && (t[n] = r);
|
|
13210
13437
|
return t;
|
|
13211
13438
|
}
|
|
13212
|
-
return
|
|
13439
|
+
return bd;
|
|
13213
13440
|
}
|
|
13214
13441
|
dispose() {
|
|
13215
13442
|
for (let e in this.loaderCache) {
|
|
@@ -13221,7 +13448,7 @@ var ld = {
|
|
|
13221
13448
|
removeAllEventListeners() {
|
|
13222
13449
|
this._listeners = void 0;
|
|
13223
13450
|
}
|
|
13224
|
-
},
|
|
13451
|
+
}, Sd = {
|
|
13225
13452
|
maxBounces: {
|
|
13226
13453
|
uniform: "maxBounces",
|
|
13227
13454
|
reset: !0
|
|
@@ -13360,10 +13587,10 @@ var ld = {
|
|
|
13360
13587
|
},
|
|
13361
13588
|
renderMode: { handler: "handleRenderMode" },
|
|
13362
13589
|
environmentRotation: { handler: "handleEnvironmentRotation" }
|
|
13363
|
-
},
|
|
13590
|
+
}, Cd = {
|
|
13364
13591
|
bounces: "maxBounces",
|
|
13365
13592
|
debugMode: "visMode"
|
|
13366
|
-
},
|
|
13593
|
+
}, wd = class extends ot {
|
|
13367
13594
|
constructor(e = X) {
|
|
13368
13595
|
super(), this._values = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._delegates = {}, this._initDefaults(e);
|
|
13369
13596
|
}
|
|
@@ -13409,7 +13636,7 @@ var ld = {
|
|
|
13409
13636
|
let i = this._values.get(e);
|
|
13410
13637
|
if (i === t) return;
|
|
13411
13638
|
this._values.set(e, t);
|
|
13412
|
-
let a =
|
|
13639
|
+
let a = Sd[e];
|
|
13413
13640
|
a && (this._applyRoute(a, t, i), (n === void 0 ? a.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
13414
13641
|
type: Yn.SETTING_CHANGED,
|
|
13415
13642
|
key: e,
|
|
@@ -13423,7 +13650,7 @@ var ld = {
|
|
|
13423
13650
|
let e = this._values.get(r);
|
|
13424
13651
|
if (e === i) continue;
|
|
13425
13652
|
this._values.set(r, i);
|
|
13426
|
-
let a =
|
|
13653
|
+
let a = Sd[r];
|
|
13427
13654
|
a && (this._applyRoute(a, i, e), (a.reset ?? !0) && (n = !0), t || this.dispatchEvent({
|
|
13428
13655
|
type: Yn.SETTING_CHANGED,
|
|
13429
13656
|
key: r,
|
|
@@ -13441,7 +13668,7 @@ var ld = {
|
|
|
13441
13668
|
}
|
|
13442
13669
|
applyAll() {
|
|
13443
13670
|
for (let [e, t] of this._values) {
|
|
13444
|
-
let n =
|
|
13671
|
+
let n = Sd[e];
|
|
13445
13672
|
n && this._applyRoute(n, t, void 0);
|
|
13446
13673
|
}
|
|
13447
13674
|
}
|
|
@@ -13449,10 +13676,10 @@ var ld = {
|
|
|
13449
13676
|
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);
|
|
13450
13677
|
}
|
|
13451
13678
|
_initDefaults(e) {
|
|
13452
|
-
for (let t of Object.keys(
|
|
13453
|
-
for (let [t, n] of Object.entries(
|
|
13679
|
+
for (let t of Object.keys(Sd)) t in e && this._values.set(t, e[t]);
|
|
13680
|
+
for (let [t, n] of Object.entries(Cd)) t in e && this._values.set(n, e[t]);
|
|
13454
13681
|
}
|
|
13455
|
-
},
|
|
13682
|
+
}, Td = class extends ot {
|
|
13456
13683
|
constructor(e) {
|
|
13457
13684
|
super();
|
|
13458
13685
|
let t = e.clientWidth, n = e.clientHeight;
|
|
@@ -13573,7 +13800,7 @@ var ld = {
|
|
|
13573
13800
|
dispose() {
|
|
13574
13801
|
this.controls?.dispose();
|
|
13575
13802
|
}
|
|
13576
|
-
},
|
|
13803
|
+
}, Ed = class extends ot {
|
|
13577
13804
|
constructor(e, t, n, r = {}) {
|
|
13578
13805
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null;
|
|
13579
13806
|
}
|
|
@@ -13594,7 +13821,7 @@ var ld = {
|
|
|
13594
13821
|
2,
|
|
13595
13822
|
0
|
|
13596
13823
|
],
|
|
13597
|
-
intensity:
|
|
13824
|
+
intensity: 1e3,
|
|
13598
13825
|
color: "#ffffff"
|
|
13599
13826
|
},
|
|
13600
13827
|
SpotLight: {
|
|
@@ -13603,7 +13830,7 @@ var ld = {
|
|
|
13603
13830
|
1,
|
|
13604
13831
|
0
|
|
13605
13832
|
],
|
|
13606
|
-
intensity:
|
|
13833
|
+
intensity: 1e3,
|
|
13607
13834
|
color: "#ffffff",
|
|
13608
13835
|
angle: 15
|
|
13609
13836
|
},
|
|
@@ -13613,7 +13840,7 @@ var ld = {
|
|
|
13613
13840
|
2,
|
|
13614
13841
|
0
|
|
13615
13842
|
],
|
|
13616
|
-
intensity:
|
|
13843
|
+
intensity: 100,
|
|
13617
13844
|
color: "#ffffff",
|
|
13618
13845
|
width: 2,
|
|
13619
13846
|
height: 2
|
|
@@ -13627,7 +13854,8 @@ var ld = {
|
|
|
13627
13854
|
n = new qt(t.color, t.intensity), n.position.fromArray(t.position), n.angle = _t.degToRad(t.angle);
|
|
13628
13855
|
let e = new Ot();
|
|
13629
13856
|
this.scene.add(e), n.target = e;
|
|
13630
|
-
} else e === "RectAreaLight" && (n = new zt(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0));
|
|
13857
|
+
} else e === "RectAreaLight" && (n = new zt(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0), n.userData.normalize = !0, n.userData.spread = Math.PI, n.userData.shape = "rectangle");
|
|
13858
|
+
n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
|
|
13631
13859
|
let r = this.scene.getObjectsByProperty("isLight", !0).length;
|
|
13632
13860
|
return n.name = `${e.replace("Light", "")} ${r + 1}`, this.scene.add(n), this.updateLights(), this._syncHelpers(), this._onReset?.(), this._buildDescriptor(n);
|
|
13633
13861
|
}
|
|
@@ -13709,15 +13937,20 @@ var ld = {
|
|
|
13709
13937
|
e.position.y,
|
|
13710
13938
|
e.position.z
|
|
13711
13939
|
],
|
|
13712
|
-
angle: t
|
|
13940
|
+
angle: t,
|
|
13941
|
+
temperature: e.userData?.temperature ?? 6500,
|
|
13942
|
+
useTemperature: e.userData?.useTemperature ?? !1,
|
|
13943
|
+
exposure: e.userData?.exposure ?? 0
|
|
13713
13944
|
};
|
|
13714
13945
|
if (e.type === "RectAreaLight") {
|
|
13715
|
-
n.width = e.width, n.height = e.height;
|
|
13716
|
-
let t = e.
|
|
13946
|
+
n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread = _t.radToDeg(e.userData?.spread ?? Math.PI);
|
|
13947
|
+
let t = e.userData?.shape;
|
|
13948
|
+
n.shape = t === "square" || t === "rectangle" || t === "disk" || t === "ellipse" ? t : t === 1 ? "ellipse" : "rectangle";
|
|
13949
|
+
let r = e.getWorldDirection(e.position.clone());
|
|
13717
13950
|
n.target = [
|
|
13718
|
-
e.position.x +
|
|
13719
|
-
e.position.y +
|
|
13720
|
-
e.position.z +
|
|
13951
|
+
e.position.x + r.x,
|
|
13952
|
+
e.position.y + r.y,
|
|
13953
|
+
e.position.z + r.z
|
|
13721
13954
|
];
|
|
13722
13955
|
} else e.type === "SpotLight" && e.target ? (n.target = [
|
|
13723
13956
|
e.target.position.x,
|
|
@@ -13726,14 +13959,14 @@ var ld = {
|
|
|
13726
13959
|
], 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);
|
|
13727
13960
|
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;
|
|
13728
13961
|
}
|
|
13729
|
-
},
|
|
13962
|
+
}, Dd = class {
|
|
13730
13963
|
constructor(e, t = {}) {
|
|
13731
13964
|
this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._size = 256;
|
|
13732
13965
|
}
|
|
13733
13966
|
async loadLibrary(e, { size: t = 256 } = {}) {
|
|
13734
13967
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
13735
13968
|
this._size = t;
|
|
13736
|
-
let n = await Promise.all(e.map((e) =>
|
|
13969
|
+
let n = await Promise.all(e.map((e) => Od(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
|
|
13737
13970
|
s.width = r, s.height = i;
|
|
13738
13971
|
let c = s.getContext("2d", { willReadFrequently: !0 });
|
|
13739
13972
|
for (let e = 0; e < a; e++) {
|
|
@@ -13762,7 +13995,7 @@ var ld = {
|
|
|
13762
13995
|
o.userData.gobo = {
|
|
13763
13996
|
name: e.name,
|
|
13764
13997
|
index: e.index,
|
|
13765
|
-
intensity:
|
|
13998
|
+
intensity: kd(r),
|
|
13766
13999
|
inverted: !!i,
|
|
13767
14000
|
scale: Math.max(1e-4, a)
|
|
13768
14001
|
};
|
|
@@ -13804,28 +14037,28 @@ var ld = {
|
|
|
13804
14037
|
return t && t.isSpotLight ? t : null;
|
|
13805
14038
|
}
|
|
13806
14039
|
};
|
|
13807
|
-
function
|
|
14040
|
+
function Od(e) {
|
|
13808
14041
|
return new Promise((t, n) => {
|
|
13809
14042
|
let r = new Image();
|
|
13810
14043
|
r.crossOrigin = "anonymous", r.onload = () => t(r), r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load gobo image: ${e}`)), r.src = e;
|
|
13811
14044
|
});
|
|
13812
14045
|
}
|
|
13813
|
-
function
|
|
14046
|
+
function kd(e) {
|
|
13814
14047
|
return Math.max(0, Math.min(1, e));
|
|
13815
14048
|
}
|
|
13816
14049
|
//#endregion
|
|
13817
14050
|
//#region src/Processor/IESParser.js
|
|
13818
|
-
function
|
|
14051
|
+
function Ad(e, t = "ies") {
|
|
13819
14052
|
let n = e.search(/TILT\s*=/i);
|
|
13820
14053
|
if (n < 0) throw Error(`IES (${t}): missing TILT line`);
|
|
13821
14054
|
let r = e.indexOf("\n", n);
|
|
13822
14055
|
if (r < 0) throw Error(`IES (${t}): truncated TILT line`);
|
|
13823
14056
|
let i = e.slice(n, r).match(/TILT\s*=\s*(\w+)/i), a = i ? i[1].toUpperCase() : "NONE", o = e.slice(r);
|
|
13824
14057
|
if (a === "INCLUDE") {
|
|
13825
|
-
let e =
|
|
13826
|
-
o =
|
|
14058
|
+
let e = Pd(o), t = 2 + 2 * Number(e[1]);
|
|
14059
|
+
o = Fd(o, t);
|
|
13827
14060
|
}
|
|
13828
|
-
let s =
|
|
14061
|
+
let s = Pd(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
|
|
13829
14062
|
l(), l(), l(), l();
|
|
13830
14063
|
let g = l();
|
|
13831
14064
|
if (l(), l(), !Number.isFinite(p) || p <= 0) throw Error(`IES (${t}): invalid vertical angle count ${p}`);
|
|
@@ -13851,18 +14084,18 @@ function yd(e, t = "ies") {
|
|
|
13851
14084
|
name: t
|
|
13852
14085
|
};
|
|
13853
14086
|
}
|
|
13854
|
-
function
|
|
14087
|
+
function jd(e, t, n) {
|
|
13855
14088
|
let r = new Uint8Array(t * n), { verticalAngles: i, horizontalAngles: a, candela: o, maxCandela: s } = e;
|
|
13856
14089
|
if (s <= 0) return r;
|
|
13857
14090
|
let c = i[i.length - 1], l = a[a.length - 1], u = a[0], d = a.length === 1 || l === u;
|
|
13858
14091
|
for (let e = 0; e < n; e++) {
|
|
13859
|
-
let f = (e + .5) / n * c, p =
|
|
14092
|
+
let f = (e + .5) / n * c, p = Id(i, f), m = Math.min(p + 1, i.length - 1), h = i[m] - i[p], g = h > 0 ? (f - i[p]) / h : 0;
|
|
13860
14093
|
for (let n = 0; n < t; n++) {
|
|
13861
14094
|
let i;
|
|
13862
|
-
if (d) i =
|
|
14095
|
+
if (d) i = Ld(o[p][0], o[m][0], g);
|
|
13863
14096
|
else {
|
|
13864
|
-
let e = u + (n + .5) / t * (l - u), r =
|
|
13865
|
-
i =
|
|
14097
|
+
let e = u + (n + .5) / t * (l - u), r = Id(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];
|
|
14098
|
+
i = Ld(Ld(f, h, d), Ld(_, v, d), g);
|
|
13866
14099
|
}
|
|
13867
14100
|
let c = Math.min(1, Math.max(0, i / s));
|
|
13868
14101
|
r[e * t + n] = Math.round(c * 255);
|
|
@@ -13870,7 +14103,7 @@ function bd(e, t, n) {
|
|
|
13870
14103
|
}
|
|
13871
14104
|
return r;
|
|
13872
14105
|
}
|
|
13873
|
-
function
|
|
14106
|
+
function Md(e, t = .1) {
|
|
13874
14107
|
let { verticalAngles: n, horizontalAngles: r, candela: i, maxCandela: a } = e, o = Math.PI / 4;
|
|
13875
14108
|
if (a <= 0 || !n?.length) return o;
|
|
13876
14109
|
let s = a * t, c = r.length, l = n[n.length - 1], u = !1;
|
|
@@ -13885,7 +14118,7 @@ function xd(e, t = .1) {
|
|
|
13885
14118
|
let d = l * Math.PI / 180;
|
|
13886
14119
|
return Math.min(Math.max(d, 5 * Math.PI / 180), 89 * Math.PI / 180);
|
|
13887
14120
|
}
|
|
13888
|
-
function
|
|
14121
|
+
function Nd(e, t, n = .7) {
|
|
13889
14122
|
let { verticalAngles: r, horizontalAngles: i, candela: a, maxCandela: o } = e;
|
|
13890
14123
|
if (o <= 0 || !r?.length || t <= 0) return 0;
|
|
13891
14124
|
let s = o * n, c = i.length, l = 0;
|
|
@@ -13898,15 +14131,15 @@ function Sd(e, t, n = .7) {
|
|
|
13898
14131
|
let u = t * 180 / Math.PI, d = u > 0 ? 1 - l / u : 0;
|
|
13899
14132
|
return Math.min(Math.max(d, 0), 1);
|
|
13900
14133
|
}
|
|
13901
|
-
function
|
|
14134
|
+
function Pd(e) {
|
|
13902
14135
|
return e.split(/\s+/).filter((e) => e.length > 0);
|
|
13903
14136
|
}
|
|
13904
|
-
function
|
|
14137
|
+
function Fd(e, t) {
|
|
13905
14138
|
let n = /\S+/g, r = 0;
|
|
13906
14139
|
for (; n.exec(e) !== null;) if (r++, r === t) return e.slice(n.lastIndex);
|
|
13907
14140
|
return "";
|
|
13908
14141
|
}
|
|
13909
|
-
function
|
|
14142
|
+
function Id(e, t) {
|
|
13910
14143
|
if (t <= e[0]) return 0;
|
|
13911
14144
|
if (t >= e[e.length - 1]) return e.length - 1;
|
|
13912
14145
|
let n = 0, r = e.length - 1;
|
|
@@ -13916,12 +14149,12 @@ function Td(e, t) {
|
|
|
13916
14149
|
}
|
|
13917
14150
|
return n;
|
|
13918
14151
|
}
|
|
13919
|
-
function
|
|
14152
|
+
function Ld(e, t, n) {
|
|
13920
14153
|
return e + (t - e) * n;
|
|
13921
14154
|
}
|
|
13922
14155
|
//#endregion
|
|
13923
14156
|
//#region src/managers/IESManager.js
|
|
13924
|
-
var
|
|
14157
|
+
var Rd = class {
|
|
13925
14158
|
constructor(e, t = {}) {
|
|
13926
14159
|
this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._gridWidth = 128, this._gridHeight = 128;
|
|
13927
14160
|
}
|
|
@@ -13932,11 +14165,11 @@ var Dd = class {
|
|
|
13932
14165
|
try {
|
|
13933
14166
|
let r = await fetch(e.url);
|
|
13934
14167
|
if (!r.ok) throw Error(`HTTP ${r.status}`);
|
|
13935
|
-
let i =
|
|
14168
|
+
let i = Ad(await r.text(), e.name);
|
|
13936
14169
|
return {
|
|
13937
14170
|
it: e,
|
|
13938
14171
|
profile: i,
|
|
13939
|
-
grid:
|
|
14172
|
+
grid: jd(i, t, n)
|
|
13940
14173
|
};
|
|
13941
14174
|
} catch (t) {
|
|
13942
14175
|
return console.warn(`IESManager: failed to load "${e.name}": ${t.message}`), null;
|
|
@@ -13950,14 +14183,14 @@ var Dd = class {
|
|
|
13950
14183
|
let r = t[e];
|
|
13951
14184
|
o[n + e * 4 + 0] = r, o[n + e * 4 + 1] = r, o[n + e * 4 + 2] = r, o[n + e * 4 + 3] = 255;
|
|
13952
14185
|
}
|
|
13953
|
-
let i = r[e].profile, c =
|
|
14186
|
+
let i = r[e].profile, c = Md(i);
|
|
13954
14187
|
s.push({
|
|
13955
14188
|
name: r[e].it.name,
|
|
13956
14189
|
index: e,
|
|
13957
14190
|
maxCandela: i.maxCandela,
|
|
13958
14191
|
photometricType: i.photometricType,
|
|
13959
14192
|
suggestedAngle: c,
|
|
13960
|
-
suggestedPenumbra:
|
|
14193
|
+
suggestedPenumbra: Nd(i, c),
|
|
13961
14194
|
lumens: i.lumens
|
|
13962
14195
|
});
|
|
13963
14196
|
}
|
|
@@ -13990,7 +14223,7 @@ var Dd = class {
|
|
|
13990
14223
|
l = Number.isFinite(e.lumens) ? e.lumens : null, i.userData.ies = {
|
|
13991
14224
|
name: e.name,
|
|
13992
14225
|
index: e.index,
|
|
13993
|
-
intensity:
|
|
14226
|
+
intensity: zd(n),
|
|
13994
14227
|
fixtureLumens: l
|
|
13995
14228
|
}, 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);
|
|
13996
14229
|
}
|
|
@@ -14013,44 +14246,44 @@ var Dd = class {
|
|
|
14013
14246
|
return t && t.isSpotLight ? t : null;
|
|
14014
14247
|
}
|
|
14015
14248
|
};
|
|
14016
|
-
function
|
|
14249
|
+
function zd(e) {
|
|
14017
14250
|
return Math.max(0, Math.min(1, e));
|
|
14018
14251
|
}
|
|
14019
14252
|
//#endregion
|
|
14020
14253
|
//#region src/Processor/ToneMapCPU.js
|
|
14021
|
-
var
|
|
14022
|
-
function
|
|
14023
|
-
i[0] =
|
|
14254
|
+
var Bd = (e) => Math.min(Math.max(e, 0), 1);
|
|
14255
|
+
function Vd(e, t, n, r, i) {
|
|
14256
|
+
i[0] = Bd(e), i[1] = Bd(t), i[2] = Bd(n);
|
|
14024
14257
|
}
|
|
14025
|
-
function
|
|
14026
|
-
i[0] =
|
|
14258
|
+
function Hd(e, t, n, r, i) {
|
|
14259
|
+
i[0] = Bd(e * r), i[1] = Bd(t * r), i[2] = Bd(n * r);
|
|
14027
14260
|
}
|
|
14028
|
-
function
|
|
14029
|
-
e *= r, t *= r, n *= r, i[0] =
|
|
14261
|
+
function Ud(e, t, n, r, i) {
|
|
14262
|
+
e *= r, t *= r, n *= r, i[0] = Bd(e / (e + 1)), i[1] = Bd(t / (t + 1)), i[2] = Bd(n / (n + 1));
|
|
14030
14263
|
}
|
|
14031
|
-
function
|
|
14264
|
+
function Wd(e, t, n, r, i) {
|
|
14032
14265
|
e = Math.max(e * r - .004, 0), t = Math.max(t * r - .004, 0), n = Math.max(n * r - .004, 0);
|
|
14033
14266
|
let a = (e) => (e * (6.2 * e + .5) / (e * (6.2 * e + 1.7) + .06)) ** 2.2;
|
|
14034
14267
|
i[0] = a(e), i[1] = a(t), i[2] = a(n);
|
|
14035
14268
|
}
|
|
14036
|
-
function
|
|
14269
|
+
function Gd(e, t, n, r, i) {
|
|
14037
14270
|
e = e * r / .6, t = t * r / .6, n = n * r / .6;
|
|
14038
14271
|
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);
|
|
14039
|
-
a = c(a), o = c(o), s = c(s), i[0] =
|
|
14272
|
+
a = c(a), o = c(o), s = c(s), i[0] = Bd(1.60475 * a - .53108 * o - .07367 * s), i[1] = Bd(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = Bd(-.00327 * a - .07276 * o + 1.07602 * s);
|
|
14040
14273
|
}
|
|
14041
|
-
function
|
|
14274
|
+
function Kd(e, t, n, r, i) {
|
|
14042
14275
|
e *= r, t *= r, n *= r;
|
|
14043
14276
|
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;
|
|
14044
|
-
c =
|
|
14277
|
+
c = Bd((Math.log2(Math.max(c, 1e-10)) - d) / f), l = Bd((Math.log2(Math.max(l, 1e-10)) - d) / f), u = Bd((Math.log2(Math.max(u, 1e-10)) - d) / f);
|
|
14045
14278
|
let p = (e) => {
|
|
14046
14279
|
let t = e * e, n = t * t;
|
|
14047
14280
|
return 15.5 * n * t - 40.14 * n * e + 31.96 * n - 6.868 * t * e + .4298 * t + .1191 * e - .00232;
|
|
14048
14281
|
};
|
|
14049
14282
|
c = p(c), l = p(l), u = p(u);
|
|
14050
14283
|
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;
|
|
14051
|
-
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] =
|
|
14284
|
+
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = Bd(1.6605 * m - .5876 * h - .0728 * g), i[1] = Bd(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = Bd(-.0182 * m - .1006 * h + 1.1187 * g);
|
|
14052
14285
|
}
|
|
14053
|
-
function
|
|
14286
|
+
function qd(e, t, n, r, i) {
|
|
14054
14287
|
let a = .76;
|
|
14055
14288
|
e *= r, t *= r, n *= r;
|
|
14056
14289
|
let o = Math.min(e, Math.min(t, n)), s = o < .08 ? o - 6.25 * o * o : .04;
|
|
@@ -14065,43 +14298,43 @@ function Id(e, t, n, r, i) {
|
|
|
14065
14298
|
let f = 1 - 1 / (.15 * (c - u) + 1);
|
|
14066
14299
|
i[0] = e + (u - e) * f, i[1] = t + (u - t) * f, i[2] = n + (u - n) * f;
|
|
14067
14300
|
}
|
|
14068
|
-
var
|
|
14069
|
-
[Dt,
|
|
14070
|
-
[pt,
|
|
14071
|
-
[Vt,
|
|
14072
|
-
[Ye,
|
|
14073
|
-
[Be,
|
|
14074
|
-
[He,
|
|
14075
|
-
[Tt,
|
|
14076
|
-
]),
|
|
14077
|
-
function
|
|
14301
|
+
var Jd = new Map([
|
|
14302
|
+
[Dt, Vd],
|
|
14303
|
+
[pt, Hd],
|
|
14304
|
+
[Vt, Ud],
|
|
14305
|
+
[Ye, Wd],
|
|
14306
|
+
[Be, Gd],
|
|
14307
|
+
[He, Kd],
|
|
14308
|
+
[Tt, qd]
|
|
14309
|
+
]), Yd = 1 / 2.2;
|
|
14310
|
+
function Xd(e) {
|
|
14078
14311
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
14079
14312
|
}
|
|
14080
|
-
var
|
|
14081
|
-
function
|
|
14313
|
+
var Zd = .2126, Qd = .7152, $d = .0722;
|
|
14314
|
+
function ef(e, t) {
|
|
14082
14315
|
if (t === 1) return;
|
|
14083
|
-
let n = e[0] *
|
|
14316
|
+
let n = e[0] * Zd + e[1] * Qd + e[2] * $d;
|
|
14084
14317
|
e[0] = n + (e[0] - n) * t, e[1] = n + (e[1] - n) * t, e[2] = n + (e[2] - n) * t;
|
|
14085
14318
|
}
|
|
14086
14319
|
//#endregion
|
|
14087
14320
|
//#region src/Passes/OIDNDenoiser.js
|
|
14088
|
-
var
|
|
14089
|
-
async function
|
|
14090
|
-
if (!
|
|
14321
|
+
var tf = null, nf = null;
|
|
14322
|
+
async function rf() {
|
|
14323
|
+
if (!tf) {
|
|
14091
14324
|
let [e, t] = await Promise.all([import("oidn-web"), import("@tensorflow/tfjs-core")]);
|
|
14092
|
-
|
|
14325
|
+
tf = e.initUNetFromURL, nf = t.engine;
|
|
14093
14326
|
}
|
|
14094
|
-
return
|
|
14327
|
+
return tf;
|
|
14095
14328
|
}
|
|
14096
|
-
function
|
|
14097
|
-
if (
|
|
14098
|
-
let e =
|
|
14329
|
+
function af() {
|
|
14330
|
+
if (nf) try {
|
|
14331
|
+
let e = nf();
|
|
14099
14332
|
e?.registryFactory && "webgpu-oidn" in e.registryFactory && e.removeBackend("webgpu-oidn");
|
|
14100
14333
|
} catch (e) {
|
|
14101
14334
|
console.warn("OIDNDenoiser: failed to clear cached TFJS backend", e);
|
|
14102
14335
|
}
|
|
14103
14336
|
}
|
|
14104
|
-
var
|
|
14337
|
+
var of = new Float32Array(3), sf = {
|
|
14105
14338
|
QUALITY_MODELS: {
|
|
14106
14339
|
fast: "rt_hdr_alb_nrm_small",
|
|
14107
14340
|
balance: "rt_hdr_alb_nrm",
|
|
@@ -14113,7 +14346,7 @@ var Jd = new Float32Array(3), Yd = {
|
|
|
14113
14346
|
debugGbufferMaps: !0,
|
|
14114
14347
|
tileSize: 256
|
|
14115
14348
|
}
|
|
14116
|
-
},
|
|
14349
|
+
}, cf = class extends ot {
|
|
14117
14350
|
constructor(e, t, n, r, i = {}) {
|
|
14118
14351
|
if (super(), !e || !t || !n || !r) throw Error("OIDNDenoiser requires output canvas, renderer, scene, and camera");
|
|
14119
14352
|
this.renderer = t, this.scene = n, this.camera = r, this.input = t.domElement, this.output = e, this.extractGBufferData = i.extractGBufferData || null, this.getMRTRenderTarget = i.getMRTRenderTarget || null, this.backendParamsGetter = i.backendParams || null, this.getGPUTextures = i.getGPUTextures || null, this.getExposure = i.getExposure || (() => 1), this.getToneMapping = i.getToneMapping || (() => Be), this.getSaturation = i.getSaturation || (() => 1), this.getTransparentBackground = i.getTransparentBackground || (() => !1), this.isGPUMode = !!this.backendParamsGetter, this.gpuDevice = null, this._gpuInputBuffers = {
|
|
@@ -14124,7 +14357,7 @@ var Jd = new Float32Array(3), Yd = {
|
|
|
14124
14357
|
width: 0,
|
|
14125
14358
|
height: 0
|
|
14126
14359
|
}, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
|
|
14127
|
-
...
|
|
14360
|
+
...sf.DEFAULT_OPTIONS,
|
|
14128
14361
|
...i
|
|
14129
14362
|
}, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this.state = {
|
|
14130
14363
|
isDenoising: !1,
|
|
@@ -14177,7 +14410,7 @@ var Jd = new Float32Array(3), Yd = {
|
|
|
14177
14410
|
let e = this.backendParamsGetter();
|
|
14178
14411
|
this.gpuDevice = e?.device ?? null, t = e?.device ? e : void 0;
|
|
14179
14412
|
}
|
|
14180
|
-
this.unet = await (await
|
|
14413
|
+
this.unet = await (await rf())(e, t, {
|
|
14181
14414
|
aux: !0,
|
|
14182
14415
|
hdr: !0,
|
|
14183
14416
|
maxTileSize: this.tileSize
|
|
@@ -14192,14 +14425,14 @@ var Jd = new Float32Array(3), Yd = {
|
|
|
14192
14425
|
}
|
|
14193
14426
|
}
|
|
14194
14427
|
_generateTzaUrl() {
|
|
14195
|
-
let { oidnWeightsBaseUrl: e } =
|
|
14428
|
+
let { oidnWeightsBaseUrl: e } = js(), { QUALITY_MODELS: t } = sf;
|
|
14196
14429
|
return `${e}${t[this.quality] || t.balance}.tza`;
|
|
14197
14430
|
}
|
|
14198
14431
|
async updateConfiguration(e) {
|
|
14199
14432
|
Object.keys(e).some((t) => this.config[t] !== e[t]) && (Object.assign(this.config, e), this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, await this._setupUNetDenoiser());
|
|
14200
14433
|
}
|
|
14201
14434
|
async updateQuality(e) {
|
|
14202
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
14435
|
+
if (!Object.prototype.hasOwnProperty.call(sf.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(sf.QUALITY_MODELS).join(", ")}`);
|
|
14203
14436
|
await this.updateConfiguration({ oidnQuality: e });
|
|
14204
14437
|
}
|
|
14205
14438
|
async start() {
|
|
@@ -14383,10 +14616,10 @@ var Jd = new Float32Array(3), Yd = {
|
|
|
14383
14616
|
}
|
|
14384
14617
|
r.queue.submit([d.finish()]);
|
|
14385
14618
|
let f = u.mapAsync(GPUMapMode.READ).then(() => {
|
|
14386
|
-
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l =
|
|
14619
|
+
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l = Jd.get(this.getToneMapping()) || Jd.get(Be), d = this._cachedAlpha, f = this._cachedAlphaWidth;
|
|
14387
14620
|
for (let i = 0, a = e.length; i < a; i += 4) {
|
|
14388
14621
|
let a = e[i] * r, s = e[i + 1] * r, u = e[i + 2] * r;
|
|
14389
|
-
if (c !== 1 && (
|
|
14622
|
+
if (c !== 1 && (of[0] = a, of[1] = s, of[2] = u, ef(of, c), a = of[0], s = of[1], u = of[2]), l(a, s, u, 1, of), t.data[i] = Xd(of[0]) * 255 + .5 | 0, t.data[i + 1] = Xd(of[1]) * 255 + .5 | 0, t.data[i + 2] = Xd(of[2]) * 255 + .5 | 0, d) {
|
|
14390
14623
|
let e = (i >> 2) % o, r = (i >> 2) / o | 0;
|
|
14391
14624
|
t.data[i + 3] = d[(n.y + r) * f + n.x + e];
|
|
14392
14625
|
} else t.data[i + 3] = 255;
|
|
@@ -14424,10 +14657,10 @@ var Jd = new Float32Array(3), Yd = {
|
|
|
14424
14657
|
try {
|
|
14425
14658
|
let o = r.createCommandEncoder({ label: "oidn-readback" });
|
|
14426
14659
|
o.copyBufferToBuffer(e, 0, a, 0, i), r.queue.submit([o.finish()]), await a.mapAsync(GPUMapMode.READ);
|
|
14427
|
-
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d =
|
|
14660
|
+
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d = Jd.get(this.getToneMapping()) || Jd.get(Be), f = this._cachedAlpha;
|
|
14428
14661
|
for (let e = 0, t = s.length; e < t; e += 4) {
|
|
14429
14662
|
let t = s[e] * l, n = s[e + 1] * l, r = s[e + 2] * l;
|
|
14430
|
-
u !== 1 && (
|
|
14663
|
+
u !== 1 && (of[0] = t, of[1] = n, of[2] = r, ef(of, u), t = of[0], n = of[1], r = of[2]), d(t, n, r, 1, of), c.data[e] = Xd(of[0]) * 255 + .5 | 0, c.data[e + 1] = Xd(of[1]) * 255 + .5 | 0, c.data[e + 2] = Xd(of[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
|
|
14431
14664
|
}
|
|
14432
14665
|
a.unmap(), this.ctx.putImageData(c, 0, 0);
|
|
14433
14666
|
} finally {
|
|
@@ -14448,9 +14681,9 @@ var Jd = new Float32Array(3), Yd = {
|
|
|
14448
14681
|
this._pendingStagingBuffers.clear();
|
|
14449
14682
|
}
|
|
14450
14683
|
dispose() {
|
|
14451
|
-
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(),
|
|
14684
|
+
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), af(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), console.log("OIDNDenoiser disposed");
|
|
14452
14685
|
}
|
|
14453
|
-
},
|
|
14686
|
+
}, lf = "" + new URL("assets/AIUpscalerWorker-AXN-lKWN.js", import.meta.url).href, uf = {
|
|
14454
14687
|
fast: {
|
|
14455
14688
|
2: "2x-spanx2-ch48.onnx",
|
|
14456
14689
|
4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
|
|
@@ -14464,17 +14697,17 @@ var Jd = new Float32Array(3), Yd = {
|
|
|
14464
14697
|
4: "4xNomos2_hq_mosr_fp32.onnx"
|
|
14465
14698
|
}
|
|
14466
14699
|
};
|
|
14467
|
-
function
|
|
14468
|
-
let { upscalerModelBaseUrl: e } =
|
|
14469
|
-
for (let n in
|
|
14700
|
+
function df() {
|
|
14701
|
+
let { upscalerModelBaseUrl: e } = js(), t = {};
|
|
14702
|
+
for (let n in uf) {
|
|
14470
14703
|
t[n] = {};
|
|
14471
|
-
for (let r in
|
|
14704
|
+
for (let r in uf[n]) t[n][r] = e + uf[n][r];
|
|
14472
14705
|
}
|
|
14473
14706
|
return t;
|
|
14474
14707
|
}
|
|
14475
|
-
var
|
|
14708
|
+
var ff = {
|
|
14476
14709
|
get QUALITY_PRESETS() {
|
|
14477
|
-
return
|
|
14710
|
+
return df();
|
|
14478
14711
|
},
|
|
14479
14712
|
TILE_SIZE: 512,
|
|
14480
14713
|
TILE_OVERLAP: 16,
|
|
@@ -14485,17 +14718,17 @@ var ef = {
|
|
|
14485
14718
|
}],
|
|
14486
14719
|
graphOptimizationLevel: "all"
|
|
14487
14720
|
}
|
|
14488
|
-
},
|
|
14721
|
+
}, pf = class extends ot {
|
|
14489
14722
|
constructor(e, t, n = {}) {
|
|
14490
14723
|
if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
|
|
14491
|
-
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 || (() => Be), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize ||
|
|
14724
|
+
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 || (() => Be), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize || ff.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
|
|
14492
14725
|
isUpscaling: !1,
|
|
14493
14726
|
isLoading: !1,
|
|
14494
14727
|
abortController: null
|
|
14495
14728
|
}, 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;
|
|
14496
14729
|
}
|
|
14497
14730
|
async _ensureSession() {
|
|
14498
|
-
let e =
|
|
14731
|
+
let e = ff.QUALITY_PRESETS[this.quality];
|
|
14499
14732
|
if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
|
|
14500
14733
|
let t = e[this.scaleFactor];
|
|
14501
14734
|
if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
|
|
@@ -14506,19 +14739,19 @@ var ef = {
|
|
|
14506
14739
|
});
|
|
14507
14740
|
try {
|
|
14508
14741
|
if (!this._worker) try {
|
|
14509
|
-
this._worker = new Worker(
|
|
14742
|
+
this._worker = new Worker(lf, { type: "module" });
|
|
14510
14743
|
} catch (e) {
|
|
14511
14744
|
if (e.name !== "SecurityError") throw e;
|
|
14512
|
-
this._worker = await Nr(
|
|
14745
|
+
this._worker = await Nr(lf);
|
|
14513
14746
|
}
|
|
14514
14747
|
await new Promise((e, n) => {
|
|
14515
14748
|
let r = (t) => {
|
|
14516
14749
|
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)));
|
|
14517
|
-
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } =
|
|
14750
|
+
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } = js();
|
|
14518
14751
|
this._worker.addEventListener("message", r), this._worker.postMessage({
|
|
14519
14752
|
type: "load",
|
|
14520
14753
|
url: t,
|
|
14521
|
-
sessionOptions:
|
|
14754
|
+
sessionOptions: ff.SESSION_OPTIONS,
|
|
14522
14755
|
ortRuntimeUrl: i,
|
|
14523
14756
|
ortWasmPaths: a,
|
|
14524
14757
|
cacheNamespace: o
|
|
@@ -14588,8 +14821,8 @@ var ef = {
|
|
|
14588
14821
|
willReadFrequently: !0,
|
|
14589
14822
|
alpha: !0
|
|
14590
14823
|
});
|
|
14591
|
-
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn =
|
|
14592
|
-
let o =
|
|
14824
|
+
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = Jd.get(this.getToneMapping()) || Jd.get(Be), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
|
|
14825
|
+
let o = ff.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
|
|
14593
14826
|
for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
|
|
14594
14827
|
if (e.aborted) throw new DOMException("Aborted", "AbortError");
|
|
14595
14828
|
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);
|
|
@@ -14662,7 +14895,7 @@ var ef = {
|
|
|
14662
14895
|
let u = ((n + e) * o + (t + i)) * 4, d = e * r + i;
|
|
14663
14896
|
if (s) {
|
|
14664
14897
|
let e = this._hdrToneMapFn, t = this._hdrExposure, n = this._hdrSaturation, r = a[u] * t, i = a[u + 1] * t, o = a[u + 2] * t;
|
|
14665
|
-
n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o,
|
|
14898
|
+
n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, ef(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] ** +Yd, l[c + d] = this._tmOut[1] ** +Yd, l[2 * c + d] = this._tmOut[2] ** +Yd;
|
|
14666
14899
|
} else l[d] = a[u] / 255, l[c + d] = a[u + 1] / 255, l[2 * c + d] = a[u + 2] / 255;
|
|
14667
14900
|
}
|
|
14668
14901
|
return l;
|
|
@@ -14720,10 +14953,10 @@ var ef = {
|
|
|
14720
14953
|
this._backupCanvas = document.createElement("canvas"), this._backupCanvas.width = e.width, this._backupCanvas.height = e.height;
|
|
14721
14954
|
let t = this._backupCanvas.getContext("2d");
|
|
14722
14955
|
if (e.isHDR) {
|
|
14723
|
-
let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s =
|
|
14956
|
+
let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = Jd.get(this.getToneMapping()) || Jd.get(Be), c = this.getExposure(), l = this.getSaturation(), u = new Float32Array(3);
|
|
14724
14957
|
for (let e = 0, t = r * i; e < t; e++) {
|
|
14725
14958
|
let t = e * 4, r = n[t] * c, i = n[t + 1] * c, a = n[t + 2] * c;
|
|
14726
|
-
l !== 1 && (u[0] = r, u[1] = i, u[2] = a,
|
|
14959
|
+
l !== 1 && (u[0] = r, u[1] = i, u[2] = a, ef(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +Yd * 255 + .5 | 0, o[t + 1] = u[1] ** +Yd * 255 + .5 | 0, o[t + 2] = u[2] ** +Yd * 255 + .5 | 0, o[t + 3] = 255;
|
|
14727
14960
|
}
|
|
14728
14961
|
t.putImageData(a, 0, 0);
|
|
14729
14962
|
} else t.putImageData(e, 0, 0);
|
|
@@ -14735,7 +14968,7 @@ var ef = {
|
|
|
14735
14968
|
this.hdr = !!e;
|
|
14736
14969
|
}
|
|
14737
14970
|
setQuality(e) {
|
|
14738
|
-
if (!
|
|
14971
|
+
if (!ff.QUALITY_PRESETS[e]) {
|
|
14739
14972
|
console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
|
|
14740
14973
|
return;
|
|
14741
14974
|
}
|
|
@@ -14758,7 +14991,7 @@ var ef = {
|
|
|
14758
14991
|
async dispose() {
|
|
14759
14992
|
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");
|
|
14760
14993
|
}
|
|
14761
|
-
},
|
|
14994
|
+
}, mf = class extends ot {
|
|
14762
14995
|
constructor({ renderer: e, mainCanvas: t, scene: n, camera: r, stages: i, pipeline: a, getExposure: o, getSaturation: s, getTransparentBg: c }) {
|
|
14763
14996
|
super(), this.renderer = e, this.mainCanvas = t, this.denoiserCanvas = this._createDenoiserCanvas(t), this.scene = n, this.camera = r, this.pipeline = a, this._stages = i, this._getExposure = o, this._getSaturation = s, this._getTransparentBg = c, this.denoiser = null, this.upscaler = null, this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._pendingStartUpscaler = null, this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null;
|
|
14764
14997
|
}
|
|
@@ -14779,7 +15012,7 @@ var ef = {
|
|
|
14779
15012
|
setupDenoiser() {
|
|
14780
15013
|
if (!this.denoiserCanvas) return;
|
|
14781
15014
|
let e = this._stages.pathTracer;
|
|
14782
|
-
this.denoiser = new
|
|
15015
|
+
this.denoiser = new cf(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
|
|
14783
15016
|
...X,
|
|
14784
15017
|
backendParams: () => ({
|
|
14785
15018
|
device: this.renderer.backend.device,
|
|
@@ -14804,7 +15037,7 @@ var ef = {
|
|
|
14804
15037
|
setupUpscaler() {
|
|
14805
15038
|
if (!this.denoiserCanvas) return;
|
|
14806
15039
|
let e = this._stages.pathTracer;
|
|
14807
|
-
this.upscaler = new
|
|
15040
|
+
this.upscaler = new pf(this.denoiserCanvas, this.renderer, {
|
|
14808
15041
|
scaleFactor: X.upscalerScale || 2,
|
|
14809
15042
|
quality: X.upscalerQuality || "fast",
|
|
14810
15043
|
getSourceCanvas: () => this.denoiser?.enabled ? null : this.renderer.domElement,
|
|
@@ -14957,7 +15190,7 @@ var ef = {
|
|
|
14957
15190
|
let t = dr[e];
|
|
14958
15191
|
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));
|
|
14959
15192
|
}
|
|
14960
|
-
},
|
|
15193
|
+
}, hf = class {
|
|
14961
15194
|
constructor() {
|
|
14962
15195
|
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;
|
|
14963
15196
|
}
|
|
@@ -14981,7 +15214,7 @@ var ef = {
|
|
|
14981
15214
|
dispose() {
|
|
14982
15215
|
this.visible = !1;
|
|
14983
15216
|
}
|
|
14984
|
-
},
|
|
15217
|
+
}, gf = class {
|
|
14985
15218
|
constructor(n, r, i) {
|
|
14986
15219
|
this.layer = "scene", this.visible = !0, this._outlineNode = gn(r, i, {
|
|
14987
15220
|
selectedObjects: [],
|
|
@@ -15015,7 +15248,7 @@ var ef = {
|
|
|
15015
15248
|
dispose() {
|
|
15016
15249
|
this.visible = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
|
|
15017
15250
|
}
|
|
15018
|
-
},
|
|
15251
|
+
}, _f = class {
|
|
15019
15252
|
constructor(e, t) {
|
|
15020
15253
|
this.renderer = e, this.camera = t, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = document.createElement("canvas"), this._hudCanvas.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;", this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null;
|
|
15021
15254
|
}
|
|
@@ -15030,11 +15263,11 @@ var ef = {
|
|
|
15030
15263
|
}
|
|
15031
15264
|
setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
|
|
15032
15265
|
this.setHelperScene(e);
|
|
15033
|
-
let s = new
|
|
15266
|
+
let s = new hf();
|
|
15034
15267
|
this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener("resolution_changed", (e) => {
|
|
15035
15268
|
s.setRenderSize(e.width, e.height);
|
|
15036
15269
|
}), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
|
|
15037
|
-
let c = new
|
|
15270
|
+
let c = new gf(this.renderer, t, this.camera);
|
|
15038
15271
|
this.register("outline", c);
|
|
15039
15272
|
}
|
|
15040
15273
|
_wireDenoiserTileEvents(e, t) {
|
|
@@ -15101,7 +15334,7 @@ var ef = {
|
|
|
15101
15334
|
for (let e of this._helpers.values()) e.dispose?.();
|
|
15102
15335
|
this._helpers.clear(), this._hudCanvas.parentElement && this._hudCanvas.parentElement.removeChild(this._hudCanvas);
|
|
15103
15336
|
}
|
|
15104
|
-
},
|
|
15337
|
+
}, vf = class extends ot {
|
|
15105
15338
|
constructor() {
|
|
15106
15339
|
super(), this.mixer = null, this.timer = new Zt(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._tempVec = new nn(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this.wakeCallback = null;
|
|
15107
15340
|
}
|
|
@@ -15201,7 +15434,7 @@ var ef = {
|
|
|
15201
15434
|
dispose() {
|
|
15202
15435
|
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;
|
|
15203
15436
|
}
|
|
15204
|
-
},
|
|
15437
|
+
}, yf = class {
|
|
15205
15438
|
constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
|
|
15206
15439
|
this._app = r, this._orbitControls = n, this._camera = e, this._controls = new _n(e, t), this._gizmoScene = new Wt(), 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 nn(), this._normalMatrix = new vt(), this._refitInFlight = !1, this._baselineComputed = !1, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
|
|
15207
15440
|
}
|
|
@@ -15312,15 +15545,15 @@ var ef = {
|
|
|
15312
15545
|
dispose() {
|
|
15313
15546
|
this._controls.removeEventListener("dragging-changed", this._onDraggingChanged), this._controls.removeEventListener("objectChange", this._onObjectChange), this.detach(), this._gizmoScene.remove(this._controls.getHelper()), this._controls.dispose(), this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._baselineComputed = !1, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
|
|
15314
15547
|
}
|
|
15315
|
-
},
|
|
15548
|
+
}, bf = /* @__PURE__ */ new WeakMap(), xf = class extends ot {
|
|
15316
15549
|
constructor(e, t = {}) {
|
|
15317
15550
|
super();
|
|
15318
15551
|
try {
|
|
15319
|
-
|
|
15552
|
+
bf.get(e)?.dispose();
|
|
15320
15553
|
} catch (e) {
|
|
15321
15554
|
console.warn("PathTracerApp: prior canvas owner dispose failed", e);
|
|
15322
15555
|
}
|
|
15323
|
-
|
|
15556
|
+
bf.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new wd(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new vf(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this.completion = new zu(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1;
|
|
15324
15557
|
}
|
|
15325
15558
|
_addTrackedListener(e, t, n) {
|
|
15326
15559
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -15469,7 +15702,7 @@ var ef = {
|
|
|
15469
15702
|
}
|
|
15470
15703
|
async loadSceneData() {
|
|
15471
15704
|
this.interactionManager?.deselect(), this.animationManager.dispose(), this._animRefitInFlight = !1;
|
|
15472
|
-
let e = new
|
|
15705
|
+
let e = new ys("loadSceneData"), t = this.meshScene.environment, n = null;
|
|
15473
15706
|
if (t?.image?.data && (e.start("Environment CDF build (worker)"), this.stages.pathTracer.scene.environment = t, n = this.stages.pathTracer.environment.buildEnvironmentCDF().then(() => e.end("Environment CDF build (worker)"))), e.start("BVH build (SceneProcessor)"), await this._sdf.buildBVH(this.meshScene), e.end("BVH build (SceneProcessor)"), $n({
|
|
15474
15707
|
status: "Transferring data to GPU...",
|
|
15475
15708
|
progress: 86
|
|
@@ -15647,32 +15880,32 @@ var ef = {
|
|
|
15647
15880
|
}), await this.renderer.init(), r.setLTC(rn.init()), this.renderer.outputColorSpace = a, this.renderer.toneMapping = Be, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
|
|
15648
15881
|
}
|
|
15649
15882
|
_initCameraManager() {
|
|
15650
|
-
this.cameraManager = new
|
|
15883
|
+
this.cameraManager = new Td(this.canvas);
|
|
15651
15884
|
}
|
|
15652
15885
|
_initScenes() {
|
|
15653
15886
|
this.scene = new Wt(), this.meshScene = new Wt(), this._sceneHelpers = new wn();
|
|
15654
15887
|
}
|
|
15655
15888
|
_initAssetPipeline() {
|
|
15656
|
-
this._sdf = new
|
|
15889
|
+
this._sdf = new xs(), this.assetLoader = new xd(this.meshScene, this.cameraManager.camera, this.cameraManager.controls), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
|
|
15657
15890
|
this.needsReset = !0, this.wake();
|
|
15658
15891
|
});
|
|
15659
15892
|
}
|
|
15660
15893
|
_initPipeline() {
|
|
15661
15894
|
this._createStages();
|
|
15662
15895
|
let { clientWidth: e, clientHeight: t } = this.canvas;
|
|
15663
|
-
this.pipeline = new
|
|
15896
|
+
this.pipeline = new Ru(this.renderer, e || 1, t || 1), this.pipeline.addStage(this.stages.pathTracer), this.pipeline.addStage(this.stages.normalDepth), this.pipeline.addStage(this.stages.motionVector), this.pipeline.addStage(this.stages.ssrc), this.pipeline.addStage(this.stages.asvgf), this.pipeline.addStage(this.stages.variance), this.pipeline.addStage(this.stages.bilateralFilter), this.pipeline.addStage(this.stages.edgeFilter), this.pipeline.addStage(this.stages.autoExposure), this.pipeline.addStage(this.stages.compositor);
|
|
15664
15897
|
let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
|
|
15665
15898
|
this.pipeline.setSize(n, r);
|
|
15666
15899
|
}
|
|
15667
15900
|
_initManagers() {
|
|
15668
|
-
this.interactionManager = new
|
|
15901
|
+
this.interactionManager = new Bu({
|
|
15669
15902
|
scene: this.meshScene,
|
|
15670
15903
|
camera: this.cameraManager.camera,
|
|
15671
15904
|
canvas: this.canvas,
|
|
15672
15905
|
assetLoader: this.assetLoader,
|
|
15673
15906
|
pathTracer: null,
|
|
15674
15907
|
floorPlane: this.assetLoader.floorPlane
|
|
15675
|
-
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new
|
|
15908
|
+
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new Ed(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new Dd(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Rd(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new yf({
|
|
15676
15909
|
camera: this.cameraManager.camera,
|
|
15677
15910
|
canvas: this.canvas,
|
|
15678
15911
|
orbitControls: this.cameraManager.controls,
|
|
@@ -15742,10 +15975,10 @@ var ef = {
|
|
|
15742
15975
|
this.transformManager?.setMeshData(this._sdf.meshes);
|
|
15743
15976
|
}
|
|
15744
15977
|
_createStages() {
|
|
15745
|
-
this.stages.pathTracer = new
|
|
15978
|
+
this.stages.pathTracer = new pu(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new mu(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new hu(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.ssrc = new Pu(this.renderer, { enabled: !1 }), this.stages.asvgf = new vu(this.renderer, { enabled: !1 }), this.stages.variance = new xu(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new Cu(this.renderer, { enabled: !1 }), this.stages.edgeFilter = new wu(this.renderer, { enabled: !1 }), this.stages.autoExposure = new ju(this.renderer, { enabled: X.autoExposure ?? !1 }), this.stages.compositor = new Fu(this.renderer, { saturation: this.settings.get("saturation") ?? X.saturation });
|
|
15746
15979
|
}
|
|
15747
15980
|
_setupDenoisingManager() {
|
|
15748
|
-
this.denoisingManager = new
|
|
15981
|
+
this.denoisingManager = new mf({
|
|
15749
15982
|
renderer: this.renderer,
|
|
15750
15983
|
mainCanvas: this.canvas,
|
|
15751
15984
|
scene: this.scene,
|
|
@@ -15789,7 +16022,7 @@ var ef = {
|
|
|
15789
16022
|
this.scene.updateMatrixWorld(), this.overlayManager?.render(), this.transformManager?.render(this.renderer);
|
|
15790
16023
|
}
|
|
15791
16024
|
_setupOverlayManager() {
|
|
15792
|
-
this.overlayManager = new
|
|
16025
|
+
this.overlayManager = new _f(this.renderer, this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
|
|
15793
16026
|
helperScene: this._sceneHelpers,
|
|
15794
16027
|
meshScene: this.meshScene,
|
|
15795
16028
|
pipeline: this.pipeline,
|
|
@@ -15805,7 +16038,7 @@ var ef = {
|
|
|
15805
16038
|
_forwardEvents(e, t) {
|
|
15806
16039
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
15807
16040
|
}
|
|
15808
|
-
},
|
|
16041
|
+
}, Sf = class {
|
|
15809
16042
|
constructor(e) {
|
|
15810
16043
|
this._app = e, this._cancelled = !1, this._rendering = !1;
|
|
15811
16044
|
}
|
|
@@ -15903,6 +16136,6 @@ var ef = {
|
|
|
15903
16136
|
}
|
|
15904
16137
|
};
|
|
15905
16138
|
//#endregion
|
|
15906
|
-
export { gr as AF_DEFAULTS, dr as ASVGF_QUALITY_PRESETS, hr as AUTO_FOCUS_MODES,
|
|
16139
|
+
export { gr as AF_DEFAULTS, dr as ASVGF_QUALITY_PRESETS, hr as AUTO_FOCUS_MODES, vf as AnimationManager, _r as BVH_LEAF_MARKERS, mr as CAMERA_PRESETS, fr as CAMERA_RANGES, Td as CameraManager, yr as DEFAULT_TEXTURE_MATRIX, mf as DenoisingManager, X as ENGINE_DEFAULTS, Yn as EngineEvents, Dd as GoboManager, Rd as IESManager, xr as INTERACTIVE_RENDER_CONFIG, Bu as InteractionManager, Ed as LightManager, Sr as MEMORY_CONSTANTS, _f as OverlayManager, br as PRODUCTION_RENDER_CONFIG, xf as PathTracerApp, Iu as PipelineContext, Ru as RenderPipeline, wd as RenderSettings, qn as RenderStage, pr as SKY_PRESETS, Kn as StageExecutionMode, vr as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, yf as TransformManager, Sc as VRAMTracker, Sf as VideoRenderManager, bc as bufferBytes, As as configureAssets, js as getAssetConfig, xc as textureBytes };
|
|
15907
16140
|
|
|
15908
16141
|
//# sourceMappingURL=rayzee.es.js.map
|