rayzee 7.22.6 → 7.22.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rayzee.es.js +224 -151
- package/dist/rayzee.umd.js +34 -22
- package/package.json +1 -1
- package/src/EngineDefaults.js +2 -1
- package/src/Passes/OIDNDenoiser.js +163 -26
- package/src/PathTracerApp.js +33 -10
- package/src/Stages/PathTracer.js +64 -8
- package/src/TSL/FinalWriteKernel.js +5 -3
- package/src/managers/DenoisingManager.js +12 -0
- package/src/managers/UniformManager.js +4 -0
package/dist/rayzee.es.js
CHANGED
|
@@ -1026,7 +1026,7 @@ var Br = [
|
|
|
1026
1026
|
renderMode: 1,
|
|
1027
1027
|
enableAlphaShadows: !0,
|
|
1028
1028
|
enableOIDN: !0,
|
|
1029
|
-
oidnQuality: "
|
|
1029
|
+
oidnQuality: "high",
|
|
1030
1030
|
interactionModeEnabled: !1,
|
|
1031
1031
|
useAdaptiveSampling: !0,
|
|
1032
1032
|
noiseThreshold: .02,
|
|
@@ -1244,7 +1244,7 @@ var di = class {
|
|
|
1244
1244
|
let r = V(t, n);
|
|
1245
1245
|
return this._uniforms.set(e, r), r;
|
|
1246
1246
|
}, r = (e, t) => (this._booleans.add(e), n(e, +!!t, "int"));
|
|
1247
|
-
n("frame", 0, "uint"), n("seedFrame", 0, "uint"), n("maxBounces", Y.bounces, "int"), n("maxSamples", Y.maxSamples, "int"), n("transmissiveBounces", Y.transmissiveBounces, "int"), n("maxSubsurfaceSteps", Y.maxSubsurfaceSteps, "int"), n("maxTransparentBounces", Y.maxTransparentBounces, "int"), n("visMode", Y.debugMode, "int"), n("debugVisScale", Y.debugVisScale, "float"), r("useAdaptiveSampling", Y.useAdaptiveSampling), n("noiseThreshold", Y.noiseThreshold, "float"), n("adaptiveMinSamples", Y.adaptiveMinSamples, "int"), n("adaptiveStopFraction", Y.adaptiveStopFraction, "float"), r("usePixelFreeze", Y.usePixelFreeze), n("pixelFreezeThreshold", Y.pixelFreezeThreshold, "float"), n("pixelFreezeStability", Y.pixelFreezeStability, "int"), r("convergenceOverlay", Y.convergenceOverlay), r("enableAccumulation", !0), n("accumulationAlpha", 0, "float"), r("cameraIsMoving", !1), r("hasPreviousAccumulated", !1), n("environmentIntensity", Y.environmentIntensity, "float"), n("backgroundIntensity", Y.backgroundIntensity, "float"), n("backgroundColor", new et(0, 0, 0), "color"), n("backgroundBlurriness", Y.backgroundBlurriness, "float"), n("backgroundBlurSamples", Y.backgroundBlurSamples, "int"), r("showBackground", Y.showBackground), r("transparentBackground", Y.transparentBackground), r("enableEnvironment", Y.enableEnvironment), n("environmentMatrix", new St(), "mat4"), n("envTotalSum", 0, "float"), n("envCompensationDelta", 0, "float"), n("envResolution", new on(1, 1), "vec2"), r("groundProjectionEnabled", Y.groundProjectionEnabled), n("groundProjectionRadius", Y.groundProjectionRadius, "float"), n("groundProjectionHeight", Y.groundProjectionHeight, "float"), n("groundProjectionLevel", Y.groundProjectionLevel, "float"), r("enableGroundCatcher", Y.enableGroundCatcher), n("groundCatcherHeight", Y.groundCatcherHeight, "float"), n("sunDirection", new sn(0, 1, 0), "vec3"), n("sunAngularSize", .0087, "float"), r("hasSun", !1), n("globalIlluminationIntensity", Y.globalIlluminationIntensity, "float"), n("exposure", Y.exposure, "float"), n("numDirectionalLights", 0, "int"), n("numAreaLights", 0, "int"), n("numPointLights", 0, "int"), n("numSpotLights", 0, "int"), this._lightBuffers = {
|
|
1247
|
+
n("frame", 0, "uint"), n("seedFrame", 0, "uint"), n("maxBounces", Y.bounces, "int"), n("maxSamples", Y.maxSamples, "int"), n("transmissiveBounces", Y.transmissiveBounces, "int"), n("maxSubsurfaceSteps", Y.maxSubsurfaceSteps, "int"), n("maxTransparentBounces", Y.maxTransparentBounces, "int"), n("visMode", Y.debugMode, "int"), n("debugVisScale", Y.debugVisScale, "float"), r("useAdaptiveSampling", Y.useAdaptiveSampling), n("noiseThreshold", Y.noiseThreshold, "float"), n("adaptiveMinSamples", Y.adaptiveMinSamples, "int"), n("adaptiveStopFraction", Y.adaptiveStopFraction, "float"), r("usePixelFreeze", Y.usePixelFreeze), n("pixelFreezeThreshold", Y.pixelFreezeThreshold, "float"), n("pixelFreezeStability", Y.pixelFreezeStability, "int"), r("convergenceOverlay", Y.convergenceOverlay), r("enableAccumulation", !0), n("accumulationAlpha", 0, "float"), r("cameraIsMoving", !1), r("hasPreviousAccumulated", !1), n("auxAccumulationAlpha", 1, "float"), r("hasPreviousAux", !1), n("environmentIntensity", Y.environmentIntensity, "float"), n("backgroundIntensity", Y.backgroundIntensity, "float"), n("backgroundColor", new et(0, 0, 0), "color"), n("backgroundBlurriness", Y.backgroundBlurriness, "float"), n("backgroundBlurSamples", Y.backgroundBlurSamples, "int"), r("showBackground", Y.showBackground), r("transparentBackground", Y.transparentBackground), r("enableEnvironment", Y.enableEnvironment), n("environmentMatrix", new St(), "mat4"), n("envTotalSum", 0, "float"), n("envCompensationDelta", 0, "float"), n("envResolution", new on(1, 1), "vec2"), r("groundProjectionEnabled", Y.groundProjectionEnabled), n("groundProjectionRadius", Y.groundProjectionRadius, "float"), n("groundProjectionHeight", Y.groundProjectionHeight, "float"), n("groundProjectionLevel", Y.groundProjectionLevel, "float"), r("enableGroundCatcher", Y.enableGroundCatcher), n("groundCatcherHeight", Y.groundCatcherHeight, "float"), n("sunDirection", new sn(0, 1, 0), "vec3"), n("sunAngularSize", .0087, "float"), r("hasSun", !1), n("globalIlluminationIntensity", Y.globalIlluminationIntensity, "float"), n("exposure", Y.exposure, "float"), n("numDirectionalLights", 0, "int"), n("numAreaLights", 0, "int"), n("numPointLights", 0, "int"), n("numSpotLights", 0, "int"), this._lightBuffers = {
|
|
1248
1248
|
directional: Pe(new Float32Array(192), "float"),
|
|
1249
1249
|
area: Pe(new Float32Array(256), "float"),
|
|
1250
1250
|
point: Pe(new Float32Array(144), "float"),
|
|
@@ -10468,47 +10468,47 @@ function Hd(e) {
|
|
|
10468
10468
|
}
|
|
10469
10469
|
var Ud = /* @__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");
|
|
10470
10470
|
function Wd(e) {
|
|
10471
|
-
let { rayBufferRO: t, gBufferRO: n, writeColorTex: r, writeNDTex: i, writeAlbedoTex: a, resolution: o, frame: s, enableAccumulation: c, hasPreviousAccumulated: l, accumulationAlpha: u, cameraIsMoving: d,
|
|
10471
|
+
let { rayBufferRO: t, gBufferRO: n, writeColorTex: r, writeNDTex: i, writeAlbedoTex: a, resolution: o, frame: s, enableAccumulation: c, hasPreviousAccumulated: l, accumulationAlpha: u, cameraIsMoving: d, hasPreviousAux: m, auxAccumulationAlpha: h, transparentBackground: g, prevAccumTexture: _, prevAlbedoTexture: v, prevNormalDepthTexture: y, renderWidth: b, chunkRowBase: x, chunkRows: S, visMode: C, auxGBufferEnabled: w, cleanAuxNormalEnabled: T, m2BufferRW: E, useAdaptiveSampling: D, noiseThreshold: O, adaptiveMinSamples: k, usePixelFreeze: A, pixelFreezeThreshold: ee, streakBufferRW: te, frozenMaskRO: ne, convergenceOverlay: re } = e, ie = w.greaterThan(B(0)), M = T.greaterThan(B(0)), P = D.greaterThan(N(0)), oe = A.greaterThan(N(0)), ce = P.or(oe).or(re.greaterThan(N(0)));
|
|
10472
10472
|
return f(() => {
|
|
10473
10473
|
let e = N(Ve.x).mul(16).add(N(se.x)), f = N(Ve.y).mul(16).add(N(se.y));
|
|
10474
|
-
p(e.lessThan(
|
|
10475
|
-
let
|
|
10476
|
-
p(
|
|
10477
|
-
let e = Dl(n,
|
|
10478
|
-
|
|
10474
|
+
p(e.lessThan(b).and(f.lessThan(S)), () => {
|
|
10475
|
+
let S = f.add(x), w = B(f.mul(b).add(e)), T = B(S.mul(b).add(e)), D = wl(t, w), A = D.xyz.toVar(), re = R(g, D.w, j(1)).toVar(), se = oe.and(s.greaterThan(B(0))).and(ne.element(T).equal(B(1))).toVar(), le = G(0).toVar(), ue = G(0).xyz.toVar();
|
|
10476
|
+
p(ie, () => {
|
|
10477
|
+
let e = Dl(n, w);
|
|
10478
|
+
le.assign(Ol(e)), ue.assign(G(kl(e), 0).xyz);
|
|
10479
10479
|
});
|
|
10480
|
-
let
|
|
10481
|
-
p(c.and(d.not()).and(s.greaterThan(B(0))).and(l).and(
|
|
10482
|
-
let e = Ae(
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
let e = Ae(
|
|
10486
|
-
|
|
10480
|
+
let F = U(j(e).add(.5), j(S).add(.5)).div(o);
|
|
10481
|
+
p(c.and(d.not()).and(s.greaterThan(B(0))).and(l).and(C.notEqual(N(11))), () => {
|
|
10482
|
+
let e = Ae(_, F, 0).toVar();
|
|
10483
|
+
A.assign(R(se, e.xyz, I(e.xyz, D.xyz, u))), p(ie.and(m), () => {
|
|
10484
|
+
ue.assign(I(Ae(v, F, 0).xyz, ue, h)), p(M, () => {
|
|
10485
|
+
let e = Ae(y, F, 0).xyz.mul(2).sub(1), t = le.xyz.mul(2).sub(1).toVar(), n = I(e, t, h).toVar(), r = ae(n), i = R(r.greaterThan(1e-4), n.div(r), t);
|
|
10486
|
+
le.assign(G(i.mul(.5).add(.5), le.w));
|
|
10487
10487
|
});
|
|
10488
|
-
}), p(
|
|
10489
|
-
|
|
10488
|
+
}), p(g, () => {
|
|
10489
|
+
re.assign(R(se, e.w, I(e.w, D.w, u)));
|
|
10490
10490
|
});
|
|
10491
|
-
}), p(
|
|
10492
|
-
let e = Oa(
|
|
10493
|
-
|
|
10494
|
-
let n = Oa(
|
|
10495
|
-
p(
|
|
10496
|
-
let e =
|
|
10497
|
-
p(
|
|
10491
|
+
}), p(ce, () => {
|
|
10492
|
+
let e = Oa(D.xyz), t = I(E.element(T).toVar(), e.mul(e), u).toVar();
|
|
10493
|
+
E.element(T).assign(t);
|
|
10494
|
+
let n = Oa(A).toVar(), r = t.sub(n.mul(n)).max(j(0)).div(j(s).add(1)).sqrt().toVar(), i = r.div(n.add(j(1e-4))), a = R(n.lessThan(j(1)), n.sqrt(), n), o = r.div(a.add(j(1e-4))).lessThan(O);
|
|
10495
|
+
p(P.or(oe), () => {
|
|
10496
|
+
let e = P.and(s.greaterThanEqual(B(k))).and(o), t = te.element(T).toVar(), r = t.bitAnd(B(1073741823)).toVar(), a = r.toVar(), c = D.w.greaterThan(j(.5)), l = t.bitAnd(B(1073741824)).notEqual(B(0)), u = R(s.equal(B(0)), R(c, B(1073741824), B(0)), R(c.or(l), B(1073741824), B(0))).toVar();
|
|
10497
|
+
p(oe, () => {
|
|
10498
10498
|
p(s.equal(B(0)), () => {
|
|
10499
10499
|
a.assign(B(0));
|
|
10500
|
-
}), p(
|
|
10501
|
-
let e = s.greaterThanEqual(B(
|
|
10500
|
+
}), p(se.not().and(s.greaterThan(B(0))), () => {
|
|
10501
|
+
let e = s.greaterThanEqual(B(k)).and(i.lessThan(ee)).and(n.greaterThan(j(0)));
|
|
10502
10502
|
a.assign(R(e, r.add(B(1)), B(0)));
|
|
10503
10503
|
});
|
|
10504
|
-
}),
|
|
10504
|
+
}), te.element(T).assign(a.bitOr(R(e, B(2147483648), B(0))).bitOr(u));
|
|
10505
10505
|
});
|
|
10506
|
-
}), p(
|
|
10507
|
-
|
|
10506
|
+
}), p(C.equal(N(11)), () => {
|
|
10507
|
+
A.assign(Ud(A));
|
|
10508
10508
|
});
|
|
10509
|
-
let
|
|
10510
|
-
Me(r,
|
|
10511
|
-
Me(i,
|
|
10509
|
+
let de = Le(B(e), B(S));
|
|
10510
|
+
Me(r, de, G(A, re)).toWriteOnly(), p(ie, () => {
|
|
10511
|
+
Me(i, de, le).toWriteOnly(), Me(a, de, G(ue, 1)).toWriteOnly();
|
|
10512
10512
|
});
|
|
10513
10513
|
});
|
|
10514
10514
|
});
|
|
@@ -10746,7 +10746,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
10746
10746
|
"compactCopyback"
|
|
10747
10747
|
], rf = class extends dl {
|
|
10748
10748
|
constructor(e, t, n, r = {}) {
|
|
10749
|
-
super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._m2Attr = null, this._streakAttr = null, this._frozenMaskAttr = null, this._convDebugSource = null, this._dilateFrozenUniform = V(1, "int"), this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = V(0, "uint"), this._cleanAuxNormalEnabled = !1, this._cleanAuxNormalUniform = V(0, "uint"), this._useDynamicDispatch = !0, this._sortMaterials = !1, this._useSubgroupCompact = !1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._curveSizingValid = !1, this._bounceEarlyExitThreshold = 100, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._geometryPixelCount = 0, this._convergedReadbackPending = !1, this._lastActivePixelCount = 0, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this._wfChunkRowBase = V(0, "int"), this._wfChunkRows = V(0, "int"), this._wfIsFirstChunk = V(1, "uint"), this._pathBudget = 0, this._pathBudgetOverride = 0, this._chunkRows = 0, this._numChunks = 1, this.vramTracker = new uu(this.renderer), this._registerVRAMProviders(), ef.debug("initialized (wavefront)");
|
|
10749
|
+
super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._m2Attr = null, this._streakAttr = null, this._frozenMaskAttr = null, this._convDebugSource = null, this._dilateFrozenUniform = V(1, "int"), this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = V(0, "uint"), this._cleanAuxNormalEnabled = !1, this._cleanAuxNormalUniform = V(0, "uint"), this._auxSamples = 0, this._auxSeedPending = !1, this._useDynamicDispatch = !0, this._sortMaterials = !1, this._useSubgroupCompact = !1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._curveSizingValid = !1, this._bounceEarlyExitThreshold = 100, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._geometryPixelCount = 0, this._convergedReadbackPending = !1, this._lastActivePixelCount = 0, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this._wfChunkRowBase = V(0, "int"), this._wfChunkRows = V(0, "int"), this._wfIsFirstChunk = V(1, "uint"), this._pathBudget = 0, this._pathBudgetOverride = 0, this._chunkRows = 0, this._numChunks = 1, this.vramTracker = new uu(this.renderer), this._registerVRAMProviders(), ef.debug("initialized (wavefront)");
|
|
10750
10750
|
}
|
|
10751
10751
|
_registerVRAMProviders() {
|
|
10752
10752
|
let e = this.vramTracker;
|
|
@@ -10798,58 +10798,61 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
10798
10798
|
}
|
|
10799
10799
|
render(e) {
|
|
10800
10800
|
if (!this.isReady || !this._wavefrontReady || this._lightBufferRealloc && (this._kernelManager && this._kernelManager.dispose(), this._wavefrontReady = !1, this._buildWavefrontKernels(), !this._wavefrontReady)) return;
|
|
10801
|
-
if (this.isComplete || this.frameCount >= this.completionThreshold || this._isConvergedComplete())
|
|
10801
|
+
if (this.isComplete || this.frameCount >= this.completionThreshold || this._isConvergedComplete()) if (this._auxSeedPending) this.isComplete = !1;
|
|
10802
|
+
else {
|
|
10802
10803
|
this.isComplete ||= !0;
|
|
10803
10804
|
return;
|
|
10804
10805
|
}
|
|
10805
10806
|
this.performanceMonitor?.start();
|
|
10806
10807
|
let t = this.frameCount, n = this.renderMode.value, r = null;
|
|
10807
|
-
n === 1 && t === 0 && (r = this.maxBounces.value, this.maxBounces.value = 1), this._handleResize(), this.manageASVGFForRenderMode(n), e && e.setState("tileRenderingComplete", !0), this.cameraChanged = this._updateCameraUniforms(), this.cameraOptimizer?.updateInteractionMode(this.cameraChanged), this.cameraChanged && (this._curveSizingValid = !1, this._readbackGeneration++, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._lastActivePixelCount = 0), this._updateAccumulationUniforms(t, n)
|
|
10808
|
-
let i = this.
|
|
10809
|
-
this.
|
|
10810
|
-
let a = this.
|
|
10808
|
+
n === 1 && t === 0 && (r = this.maxBounces.value, this.maxBounces.value = 1), this._handleResize(), this.manageASVGFForRenderMode(n), e && e.setState("tileRenderingComplete", !0), this.cameraChanged = this._updateCameraUniforms(), this.cameraOptimizer?.updateInteractionMode(this.cameraChanged), this.cameraChanged && (this._curveSizingValid = !1, this._readbackGeneration++, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._lastActivePixelCount = 0), this._updateAccumulationUniforms(t, n);
|
|
10809
|
+
let i = this._updateAuxAccumulationUniforms(t);
|
|
10810
|
+
this.frame.value = t, this.seedFrame.value = this._seedTick++, this._setWfDispatch();
|
|
10811
|
+
let a = this.storageTextures.getReadTextures();
|
|
10812
|
+
this.shaderBuilder.prevColorTexNode && (this.shaderBuilder.prevColorTexNode.value = a.color, this.shaderBuilder.prevAlbedoTexNode.value = a.albedo, this.shaderBuilder.prevNormalDepthTexNode.value = a.normalDepth), this._refreshWfTextureNodes();
|
|
10813
|
+
let o = this._kernelManager;
|
|
10811
10814
|
if ((this.visMode?.value | 0) > 0 && this.visMode.value !== 11) {
|
|
10812
|
-
|
|
10815
|
+
o.dispatch("debug"), this.storageTextures.copyToReadTargets(this.renderer);
|
|
10813
10816
|
let t = this.storageTextures.getReadTextures();
|
|
10814
10817
|
e && this._publishTexturesToContext(e, t), this._emitStateEvents(), this.cameraOptimizer?.isInInteractionMode() || this.frameCount++, r !== null && (this.maxBounces.value = r), this.performanceMonitor?.end();
|
|
10815
10818
|
return;
|
|
10816
10819
|
}
|
|
10817
|
-
let
|
|
10818
|
-
for (let e = 0, n = 0; n <
|
|
10819
|
-
let r = Math.min(
|
|
10820
|
-
if (
|
|
10821
|
-
let e = Math.min(i, Math.ceil(
|
|
10822
|
-
|
|
10823
|
-
} else
|
|
10824
|
-
e === 0 && t > 0 && this.useAdaptiveSampling.value > 0 && this._willReadCountersThisFrame() &&
|
|
10825
|
-
for (let e = 0; e <=
|
|
10820
|
+
let s = this.maxBounces.value, c = s + this.transmissiveBounces.value + this.maxSubsurfaceSteps.value, l = this._wfRenderHeight.value, u = this._chunkRows, d = this._numChunks <= 1, f = this._lastBounceCounts, p = d && f ? s <= this._lastBounceCountsBudget ? c + 1 : this._lastBounceCountsBudget : 0;
|
|
10821
|
+
for (let e = 0, n = 0; n < l; n += u, e++) {
|
|
10822
|
+
let r = Math.min(u, l - n), i = this._setChunk(n, r, e), a = this.usePixelFreeze.value > 0 && !this._auxSeedPending, s = d && a && this._curveSizingValid && this._lastActivePixelCount > 0 ? this._lastActivePixelCount : i;
|
|
10823
|
+
if (a) {
|
|
10824
|
+
let e = Math.min(i, Math.ceil(s * 1.5) + 1024);
|
|
10825
|
+
o.setDispatchForCount("generateList", e), o.dispatch("resetFrameCounters"), o.dispatch("buildActivePixels"), o.dispatch("seedEnter"), o.dispatch("generateList");
|
|
10826
|
+
} else o.dispatch("generate"), o.dispatch("initActiveIndices");
|
|
10827
|
+
e === 0 && t > 0 && this.useAdaptiveSampling.value > 0 && this._willReadCountersThisFrame() && o.dispatch("countConvergedDilated");
|
|
10828
|
+
for (let e = 0; e <= c; e++) {
|
|
10826
10829
|
this._wfCurrentBounce.value = e;
|
|
10827
10830
|
let t = this._useDynamicDispatch;
|
|
10828
10831
|
if (t) {
|
|
10829
10832
|
let t = i;
|
|
10830
|
-
if (
|
|
10833
|
+
if (d && e > 0 && this._curveSizingValid) {
|
|
10831
10834
|
let n = e - 1, r;
|
|
10832
|
-
n <
|
|
10833
|
-
} else e === 0 &&
|
|
10835
|
+
n < p && f[n] !== void 0 ? r = f[n] : p > 0 && (r = f[p - 1]), t = r > 0 ? r : i;
|
|
10836
|
+
} else e === 0 && a && (t = s);
|
|
10834
10837
|
let n = Math.min(i, Math.ceil(t * 1.5) + 1024);
|
|
10835
|
-
for (let e of nf)
|
|
10838
|
+
for (let e of nf) o.setDispatchForCount(e, n);
|
|
10836
10839
|
} else {
|
|
10837
|
-
|
|
10838
|
-
for (let e of nf)
|
|
10840
|
+
o.dispatch("enterFull");
|
|
10841
|
+
for (let e of nf) o.setDispatchForCount(e, i);
|
|
10839
10842
|
}
|
|
10840
|
-
if (
|
|
10843
|
+
if (o.dispatch("extend"), this._sortMaterials && (o.dispatch("resetGlobalHist"), o.dispatch("globalHist"), o.dispatch("globalPrefix"), o.dispatch("globalScatter")), o.dispatch("shade"), o.dispatch("compact"), t ? o.dispatch("compactCopyback") : o.dispatch("snapshotBounceCount"), e < p && e < c && f[e] !== void 0 && f[e] <= this._bounceEarlyExitThreshold) break;
|
|
10841
10844
|
}
|
|
10842
|
-
|
|
10845
|
+
o.dispatch("finalWrite");
|
|
10843
10846
|
}
|
|
10844
10847
|
this._maybeReadbackCounters(), this.storageTextures.copyToReadTargets(this.renderer, this._auxGBufferEnabled);
|
|
10845
|
-
let
|
|
10846
|
-
e && this._publishTexturesToContext(e,
|
|
10848
|
+
let m = this.storageTextures.getReadTextures();
|
|
10849
|
+
e && this._publishTexturesToContext(e, m), this._emitStateEvents(), this.cameraOptimizer?.isInInteractionMode() || this.frameCount++, this._auxGBufferEnabled && (this._auxSamples = i ? this._auxSamples + 1 : 1), this._auxSeedPending = !1, r !== null && (this.maxBounces.value = r), this.performanceMonitor?.end();
|
|
10847
10850
|
}
|
|
10848
10851
|
_isConvergedComplete() {
|
|
10849
10852
|
return this.useAdaptiveSampling.value > 0 && this.frameCount >= this.adaptiveMinSamples.value && this._convergedFraction >= this.adaptiveStopFraction.value && this._convergedGeometryFraction >= this.adaptiveStopFraction.value;
|
|
10850
10853
|
}
|
|
10851
10854
|
reset() {
|
|
10852
|
-
super.reset(), this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._lastActivePixelCount = 0;
|
|
10855
|
+
super.reset(), this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._lastActivePixelCount = 0, this._auxSamples = 0, this._auxSeedPending = !1;
|
|
10853
10856
|
}
|
|
10854
10857
|
getConvergenceDebugSource() {
|
|
10855
10858
|
return !this._m2Attr || !this._frozenMaskAttr ? null : (this._convDebugSource?.m2 === this._m2Attr && this._convDebugSource.frozenMask === this._frozenMaskAttr || (this._convDebugSource = {
|
|
@@ -10880,10 +10883,17 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
10880
10883
|
super._handleResize(), this._rebuildKernelsIfResized(e, t);
|
|
10881
10884
|
}
|
|
10882
10885
|
setAuxGBufferEnabled(e) {
|
|
10883
|
-
e = !!e, this._auxGBufferEnabled !== e && (this._auxGBufferEnabled = e, this._auxGBufferUniform.value = +!!e, this.
|
|
10886
|
+
e = !!e, this._auxGBufferEnabled !== e && (this._auxGBufferEnabled = e, this._auxGBufferUniform.value = +!!e, this.restartAuxAccumulation());
|
|
10884
10887
|
}
|
|
10885
10888
|
setCleanAuxNormal(e) {
|
|
10886
|
-
e = !!e, this._cleanAuxNormalEnabled !== e && (this._cleanAuxNormalEnabled = e, this._cleanAuxNormalUniform.value = +!!e, this.
|
|
10889
|
+
e = !!e, this._cleanAuxNormalEnabled !== e && (this._cleanAuxNormalEnabled = e, this._cleanAuxNormalUniform.value = +!!e, this.restartAuxAccumulation());
|
|
10890
|
+
}
|
|
10891
|
+
restartAuxAccumulation() {
|
|
10892
|
+
this._auxSamples = 0, this._auxSeedPending = this._auxGBufferEnabled;
|
|
10893
|
+
}
|
|
10894
|
+
_updateAuxAccumulationUniforms(e) {
|
|
10895
|
+
let t = this.accumulationEnabled && !this.cameraIsMoving.value && e > 0 && this.hasPreviousAccumulated.value > 0 && this.visMode.value !== 11, n = this._auxGBufferEnabled && t && !this._auxSeedPending && this._auxSamples > 0;
|
|
10896
|
+
return this.hasPreviousAux.value = +!!n, this.auxAccumulationAlpha.value = n ? 1 / (this._auxSamples + 1) : 1, n;
|
|
10887
10897
|
}
|
|
10888
10898
|
setSize(e, t) {
|
|
10889
10899
|
let n = this.storageTextures.renderWidth, r = this.storageTextures.renderHeight;
|
|
@@ -11374,6 +11384,8 @@ var ef = ai("wavefront"), tf = 256, nf = [
|
|
|
11374
11384
|
enableAccumulation: this.enableAccumulation,
|
|
11375
11385
|
hasPreviousAccumulated: this.hasPreviousAccumulated,
|
|
11376
11386
|
accumulationAlpha: this.accumulationAlpha,
|
|
11387
|
+
hasPreviousAux: this.hasPreviousAux,
|
|
11388
|
+
auxAccumulationAlpha: this.auxAccumulationAlpha,
|
|
11377
11389
|
cameraIsMoving: this.cameraIsMoving,
|
|
11378
11390
|
transparentBackground: this.transparentBackground,
|
|
11379
11391
|
prevAccumTexture: b,
|
|
@@ -16216,16 +16228,26 @@ function cm() {
|
|
|
16216
16228
|
var lm = new Float32Array(3), um = {
|
|
16217
16229
|
QUALITY_MODELS: {
|
|
16218
16230
|
fast: "rt_hdr_alb_nrm_small",
|
|
16219
|
-
balance: "
|
|
16231
|
+
balance: "rt_hdr_calb_cnrm",
|
|
16220
16232
|
high: "rt_hdr_calb_cnrm_large"
|
|
16221
16233
|
},
|
|
16222
16234
|
DEFAULT_OPTIONS: {
|
|
16223
16235
|
enableOIDN: !0,
|
|
16224
16236
|
oidnQuality: "fast",
|
|
16225
16237
|
debugGbufferMaps: !0,
|
|
16226
|
-
tileSize:
|
|
16238
|
+
tileSize: 512
|
|
16227
16239
|
}
|
|
16228
|
-
}, dm =
|
|
16240
|
+
}, dm = "\n@group(0) @binding(0) var<storage, read_write> col: array<vec4<f32>>;\n@group(0) @binding(1) var<uniform> scale: f32;\n\n@compute @workgroup_size(64)\nfn main( @builtin(global_invocation_id) gid: vec3<u32>,\n @builtin(num_workgroups) nwg: vec3<u32> ) {\n let i = gid.y * nwg.x * 64u + gid.x;\n if ( i >= arrayLength( &col ) ) { return; }\n let c = col[ i ];\n col[ i ] = vec4<f32>( c.xyz * scale, c.w );\n}\n", fm = 64, pm = 32768, mm = .18;
|
|
16241
|
+
function hm(e, t) {
|
|
16242
|
+
let n = 0;
|
|
16243
|
+
for (let r = 0; r < t; r++) {
|
|
16244
|
+
let t = r * 4, i = .212671 * e[t] + .71516 * e[t + 1] + .072169 * e[t + 2];
|
|
16245
|
+
n += Math.log2(Math.max(i, 0) + 1e-4);
|
|
16246
|
+
}
|
|
16247
|
+
let r = mm / 2 ** (n / t);
|
|
16248
|
+
return Number.isFinite(r) && r > 0 ? r : 1;
|
|
16249
|
+
}
|
|
16250
|
+
var gm = class extends lt {
|
|
16229
16251
|
constructor(e, t, n, r, i = {}) {
|
|
16230
16252
|
if (super(), !e || !t || !n || !r) throw Error("OIDNDenoiser requires output canvas, renderer, scene, and camera");
|
|
16231
16253
|
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 || (() => He), this.getSaturation = i.getSaturation || (() => 1), this.getTransparentBackground = i.getTransparentBackground || (() => !1), this.isGPUMode = !!this.backendParamsGetter, this.gpuDevice = null, this._gpuInputBuffers = {
|
|
@@ -16235,10 +16257,10 @@ var lm = new Float32Array(3), um = {
|
|
|
16235
16257
|
}, this._gpuInputBufferSize = {
|
|
16236
16258
|
width: 0,
|
|
16237
16259
|
height: 0
|
|
16238
|
-
}, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
|
|
16260
|
+
}, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._colorScalePipeline = null, this._colorScaleBindGroup = null, this._colorScaleUniform = null, this._oidnInputScale = 1, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
|
|
16239
16261
|
...um.DEFAULT_OPTIONS,
|
|
16240
16262
|
...i
|
|
16241
|
-
}, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this.state = {
|
|
16263
|
+
}, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this._activeTileSize = 0, this.state = {
|
|
16242
16264
|
isDenoising: !1,
|
|
16243
16265
|
isLoading: !1,
|
|
16244
16266
|
abortController: null
|
|
@@ -16275,7 +16297,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16275
16297
|
if (this.state.isLoading) return;
|
|
16276
16298
|
this.state.isLoading = !0;
|
|
16277
16299
|
let e = this._generateTzaUrl();
|
|
16278
|
-
if (this.currentTZAUrl === e && this.unet) {
|
|
16300
|
+
if (this.currentTZAUrl === e && this._activeTileSize === this.tileSize && this.unet) {
|
|
16279
16301
|
this.state.isLoading = !1;
|
|
16280
16302
|
return;
|
|
16281
16303
|
}
|
|
@@ -16293,7 +16315,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16293
16315
|
aux: !0,
|
|
16294
16316
|
hdr: !0,
|
|
16295
16317
|
maxTileSize: this.tileSize
|
|
16296
|
-
}), this.currentTZAUrl = e, this.dispatchEvent({ type: "loaded" }), im.debug("UNet weights loaded:", e);
|
|
16318
|
+
}), this.currentTZAUrl = e, this._activeTileSize = this.tileSize, this.dispatchEvent({ type: "loaded" }), im.debug("UNet weights loaded:", e);
|
|
16297
16319
|
} catch (e) {
|
|
16298
16320
|
im.error("UNet weights failed to load:", e), this.dispatchEvent({
|
|
16299
16321
|
type: "error",
|
|
@@ -16379,7 +16401,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16379
16401
|
for (let e = 0; e < t; e++) i.copyBufferToBuffer(c, e * o, r, e * a, a);
|
|
16380
16402
|
}
|
|
16381
16403
|
};
|
|
16382
|
-
l(n.color, this._gpuInputBuffers.color), l(n.albedo, this._gpuInputBuffers.albedo), l(n.normal, this._gpuInputBuffers.normal), r.queue.submit([i.finish()]),
|
|
16404
|
+
l(n.color, this._gpuInputBuffers.color), l(n.albedo, this._gpuInputBuffers.albedo), l(n.normal, this._gpuInputBuffers.normal), r.queue.submit([i.finish()]), await this._readbackColor(r, e, t), globalThis.__OIDN_NO_INPUT_SCALE && (this._oidnInputScale = 1), this._applyColorScale(r, e * t), this.ctx.drawImage(this.input, 0, 0, e, t);
|
|
16383
16405
|
let u = {
|
|
16384
16406
|
color: {
|
|
16385
16407
|
data: this._gpuInputBuffers.color,
|
|
@@ -16431,7 +16453,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16431
16453
|
if (this._gpuInputBuffers.color?.destroy(), this._gpuInputBuffers.albedo?.destroy(), this._gpuInputBuffers.normal?.destroy(), this._gpuInputPadBuffer?.destroy(), this._alphaReadbackMapped && this._alphaReadbackBuffer) try {
|
|
16432
16454
|
this._alphaReadbackBuffer.unmap();
|
|
16433
16455
|
} catch {}
|
|
16434
|
-
this._alphaReadbackBuffer?.destroy(), this._alphaReadbackMapped = !1, this._gpuInputBuffers = {
|
|
16456
|
+
this._alphaReadbackBuffer?.destroy(), this._alphaReadbackMapped = !1, this._colorScaleBindGroup = null, this._colorScaleUniform?.destroy(), this._colorScaleUniform = null, this._gpuInputBuffers = {
|
|
16435
16457
|
color: null,
|
|
16436
16458
|
albedo: null,
|
|
16437
16459
|
normal: null
|
|
@@ -16440,7 +16462,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16440
16462
|
height: 0
|
|
16441
16463
|
};
|
|
16442
16464
|
}
|
|
16443
|
-
async
|
|
16465
|
+
async _readbackColor(e, t, n) {
|
|
16444
16466
|
let r = t * n * 16;
|
|
16445
16467
|
this._alphaReadbackBuffer === null && (this._alphaReadbackBuffer = e.createBuffer({
|
|
16446
16468
|
label: "oidn-alpha-readback",
|
|
@@ -16455,10 +16477,53 @@ var lm = new Float32Array(3), um = {
|
|
|
16455
16477
|
this._alphaReadbackMapped = !1;
|
|
16456
16478
|
return;
|
|
16457
16479
|
}
|
|
16458
|
-
let o = new Float32Array(i.getMappedRange()), s = t * n
|
|
16459
|
-
|
|
16480
|
+
let o = new Float32Array(i.getMappedRange()), s = t * n;
|
|
16481
|
+
this._oidnInputScale = hm(o, s);
|
|
16482
|
+
let c = null;
|
|
16483
|
+
if (this.getTransparentBackground()) {
|
|
16484
|
+
c = new Uint8Array(s);
|
|
16485
|
+
for (let e = 0; e < s; e++) c[e] = Math.min(Math.max(o[e * 4 + 3] * 255, 0), 255) | 0;
|
|
16486
|
+
}
|
|
16460
16487
|
i.unmap(), this._alphaReadbackMapped = !1, this._cachedAlpha = c, this._cachedAlphaWidth = t;
|
|
16461
16488
|
}
|
|
16489
|
+
_outputExposure() {
|
|
16490
|
+
return this.getExposure() / this._oidnInputScale;
|
|
16491
|
+
}
|
|
16492
|
+
_applyColorScale(e, t) {
|
|
16493
|
+
let n = this._oidnInputScale;
|
|
16494
|
+
if (!this._ensureColorScalePipeline(e)) return;
|
|
16495
|
+
e.queue.writeBuffer(this._colorScaleUniform, 0, new Float32Array([n]));
|
|
16496
|
+
let r = Math.ceil(t / fm), i = Math.min(r, pm), a = Math.ceil(r / i), o = e.createCommandEncoder({ label: "oidn-color-scale" }), s = o.beginComputePass({ label: "oidn-color-scale" });
|
|
16497
|
+
s.setPipeline(this._colorScalePipeline), s.setBindGroup(0, this._colorScaleBindGroup), s.dispatchWorkgroups(i, a, 1), s.end(), e.queue.submit([o.finish()]);
|
|
16498
|
+
}
|
|
16499
|
+
_ensureColorScalePipeline(e) {
|
|
16500
|
+
let t = this._gpuInputBuffers.color;
|
|
16501
|
+
return !e || !t ? null : (this._colorScalePipeline ||= e.createComputePipeline({
|
|
16502
|
+
label: "oidn-color-scale",
|
|
16503
|
+
layout: "auto",
|
|
16504
|
+
compute: {
|
|
16505
|
+
module: e.createShaderModule({
|
|
16506
|
+
label: "oidn-color-scale",
|
|
16507
|
+
code: dm
|
|
16508
|
+
}),
|
|
16509
|
+
entryPoint: "main"
|
|
16510
|
+
}
|
|
16511
|
+
}), this._colorScaleUniform ||= e.createBuffer({
|
|
16512
|
+
label: "oidn-color-scale-uniform",
|
|
16513
|
+
size: 16,
|
|
16514
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
16515
|
+
}), this._colorScaleBindGroup ||= e.createBindGroup({
|
|
16516
|
+
label: "oidn-color-scale",
|
|
16517
|
+
layout: this._colorScalePipeline.getBindGroupLayout(0),
|
|
16518
|
+
entries: [{
|
|
16519
|
+
binding: 0,
|
|
16520
|
+
resource: { buffer: t }
|
|
16521
|
+
}, {
|
|
16522
|
+
binding: 1,
|
|
16523
|
+
resource: { buffer: this._colorScaleUniform }
|
|
16524
|
+
}]
|
|
16525
|
+
}), this._colorScalePipeline);
|
|
16526
|
+
}
|
|
16462
16527
|
_executeWithAbortGPU(e) {
|
|
16463
16528
|
return new Promise((t, n) => {
|
|
16464
16529
|
if (this.state.abortController?.signal.aborted) {
|
|
@@ -16496,7 +16561,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16496
16561
|
}
|
|
16497
16562
|
r.queue.submit([d.finish()]);
|
|
16498
16563
|
let f = u.mapAsync(GPUMapMode.READ).then(() => {
|
|
16499
|
-
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.
|
|
16564
|
+
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this._outputExposure(), c = this.getSaturation(), l = Zp.get(this.getToneMapping()) || Zp.get(He), d = this._cachedAlpha, f = this._cachedAlphaWidth;
|
|
16500
16565
|
for (let i = 0, a = e.length; i < a; i += 4) {
|
|
16501
16566
|
let a = e[i] * r, s = e[i + 1] * r, u = e[i + 2] * r;
|
|
16502
16567
|
if (c !== 1 && (lm[0] = a, lm[1] = s, lm[2] = u, rm(lm, c), a = lm[0], s = lm[1], u = lm[2]), l(a, s, u, 1, lm), t.data[i] = $p(lm[0]) * 255 + .5 | 0, t.data[i + 1] = $p(lm[1]) * 255 + .5 | 0, t.data[i + 2] = $p(lm[2]) * 255 + .5 | 0, d) {
|
|
@@ -16537,7 +16602,7 @@ var lm = new Float32Array(3), um = {
|
|
|
16537
16602
|
try {
|
|
16538
16603
|
let o = r.createCommandEncoder({ label: "oidn-readback" });
|
|
16539
16604
|
o.copyBufferToBuffer(e, 0, a, 0, i), r.queue.submit([o.finish()]), await a.mapAsync(GPUMapMode.READ);
|
|
16540
|
-
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.
|
|
16605
|
+
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this._outputExposure(), u = this.getSaturation(), d = Zp.get(this.getToneMapping()) || Zp.get(He), f = this._cachedAlpha;
|
|
16541
16606
|
for (let e = 0, t = s.length; e < t; e += 4) {
|
|
16542
16607
|
let t = s[e] * l, n = s[e + 1] * l, r = s[e + 2] * l;
|
|
16543
16608
|
u !== 1 && (lm[0] = t, lm[1] = n, lm[2] = r, rm(lm, u), t = lm[0], n = lm[1], r = lm[2]), d(t, n, r, 1, lm), c.data[e] = $p(lm[0]) * 255 + .5 | 0, c.data[e + 1] = $p(lm[1]) * 255 + .5 | 0, c.data[e + 2] = $p(lm[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
|
|
@@ -16561,13 +16626,13 @@ var lm = new Float32Array(3), um = {
|
|
|
16561
16626
|
this._pendingStagingBuffers.clear();
|
|
16562
16627
|
}
|
|
16563
16628
|
dispose() {
|
|
16564
|
-
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), cm(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), im.debug("disposed");
|
|
16629
|
+
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), cm(), this._destroyGPUInputBuffers(), this._colorScalePipeline = null, this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), im.debug("disposed");
|
|
16565
16630
|
}
|
|
16566
|
-
},
|
|
16567
|
-
function
|
|
16631
|
+
}, _m = "let e={ortRuntimeUrl:`https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/ort.webgpu.bundle.min.mjs`,ortWasmPaths:`https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/`,cacheNamespace:`rayzee`},t=null;async function n(){return t||(t=await import(e.ortRuntimeUrl),t.env.wasm.wasmPaths=e.ortWasmPaths,t.env.logLevel=`error`,t)}function r(){return`${e.cacheNamespace}:ai-upscaler-models`}const i=`models`;let a=null,o=null;function s(){return new Promise((e,t)=>{let n=indexedDB.open(r(),1);n.onupgradeneeded=()=>n.result.createObjectStore(i),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function c(e){try{let t=await s();return await new Promise((n,r)=>{let a=t.transaction(i,`readonly`).objectStore(i).get(e);a.onsuccess=()=>n(a.result||null),a.onerror=()=>r(a.error)})}catch{return null}}async function l(e,t){try{let n=await s();await new Promise((r,a)=>{let o=n.transaction(i,`readwrite`);o.objectStore(i).put(t,e),o.oncomplete=()=>r(),o.onerror=()=>a(o.error)})}catch{}}async function u(e){let t=await c(e);if(t)return console.log(`AI Upscaler Worker: model loaded from cache (${(t.byteLength/1024/1024).toFixed(1)}MB)`),t;let n=await fetch(e);if(!n.ok)throw Error(`Failed to fetch model: ${n.status}`);let r=await n.arrayBuffer();return l(e,r.slice(0)),r}async function d(e,t){if(a&&o===e){self.postMessage({type:`loaded`,backend:`webgpu`});return}a&&=(await a.release(),null);let[r,i]=await Promise.all([u(e),n()]);a=await i.InferenceSession.create(r,t),o=e;let s=512;try{let e=await navigator.gpu?.requestAdapter(),t=await e?.requestAdapterInfo?.()||e?.info,n=/apple|swiftshader|llvmpipe/i.test(t?.vendor||``)||/apple|swiftshader/i.test(t?.architecture||``),r=t?.device?.toLowerCase?.()?.includes(`integrated`)||/intel.*iris|intel.*uhd|intel.*hd|amd.*vega|radeon.*graphics/i.test(t?.description||``);s=n?128:r?256:512,console.log(`AI Upscaler Worker: GPU=\"${t?.description||t?.device||`unknown`}\", tileSize=${s}`)}catch{}let c=(r.byteLength/1024/1024).toFixed(1);console.log(`AI Upscaler Worker: model loaded (${c}MB), backend: webgpu`),self.postMessage({type:`loaded`,backend:`webgpu`,tileSize:s})}async function f(e,t,r,i){let o=await n(),s=a.inputNames[0],c=a.outputNames[0],l=new o.Tensor(`float32`,e,[1,3,r,t]),u=(await a.run({[s]:l}))[c].data;self.postMessage({type:`inferred`,outputData:u,id:i},[u.buffer])}self.onmessage=async t=>{let{type:n}=t.data;try{n===`load`?(t.data.ortRuntimeUrl&&(e.ortRuntimeUrl=t.data.ortRuntimeUrl),t.data.ortWasmPaths&&(e.ortWasmPaths=t.data.ortWasmPaths),t.data.cacheNamespace&&(e.cacheNamespace=t.data.cacheNamespace),await d(t.data.url,t.data.sessionOptions)):n===`infer`?await f(t.data.tileData,t.data.width,t.data.height,t.data.id):n===`dispose`&&a&&(await a.release(),a=null,o=null)}catch(e){self.postMessage({type:`error`,message:e.message,id:t.data?.id})}};", vm = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", _m], { type: "text/javascript;charset=utf-8" });
|
|
16632
|
+
function ym(e) {
|
|
16568
16633
|
let t;
|
|
16569
16634
|
try {
|
|
16570
|
-
if (t =
|
|
16635
|
+
if (t = vm && (self.URL || self.webkitURL).createObjectURL(vm), !t) throw "";
|
|
16571
16636
|
let n = new Worker(t, {
|
|
16572
16637
|
type: "module",
|
|
16573
16638
|
name: e?.name
|
|
@@ -16576,7 +16641,7 @@ function mm(e) {
|
|
|
16576
16641
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
16577
16642
|
}), n;
|
|
16578
16643
|
} catch {
|
|
16579
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
16644
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(_m), {
|
|
16580
16645
|
type: "module",
|
|
16581
16646
|
name: e?.name
|
|
16582
16647
|
});
|
|
@@ -16584,7 +16649,7 @@ function mm(e) {
|
|
|
16584
16649
|
}
|
|
16585
16650
|
//#endregion
|
|
16586
16651
|
//#region src/Passes/AIUpscaler.js
|
|
16587
|
-
var
|
|
16652
|
+
var bm = {
|
|
16588
16653
|
fast: {
|
|
16589
16654
|
2: "2x-spanx2-ch48.onnx",
|
|
16590
16655
|
4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
|
|
@@ -16598,17 +16663,17 @@ var hm = {
|
|
|
16598
16663
|
4: "4xNomos2_hq_mosr_fp32.onnx"
|
|
16599
16664
|
}
|
|
16600
16665
|
};
|
|
16601
|
-
function
|
|
16666
|
+
function xm() {
|
|
16602
16667
|
let { upscalerModelBaseUrl: e } = cl(), t = {};
|
|
16603
|
-
for (let n in
|
|
16668
|
+
for (let n in bm) {
|
|
16604
16669
|
t[n] = {};
|
|
16605
|
-
for (let r in
|
|
16670
|
+
for (let r in bm[n]) t[n][r] = e + bm[n][r];
|
|
16606
16671
|
}
|
|
16607
16672
|
return t;
|
|
16608
16673
|
}
|
|
16609
|
-
var
|
|
16674
|
+
var Sm = {
|
|
16610
16675
|
get QUALITY_PRESETS() {
|
|
16611
|
-
return
|
|
16676
|
+
return xm();
|
|
16612
16677
|
},
|
|
16613
16678
|
TILE_SIZE: 512,
|
|
16614
16679
|
TILE_OVERLAP: 16,
|
|
@@ -16619,17 +16684,17 @@ var _m = {
|
|
|
16619
16684
|
}],
|
|
16620
16685
|
graphOptimizationLevel: "all"
|
|
16621
16686
|
}
|
|
16622
|
-
},
|
|
16687
|
+
}, Cm = class extends lt {
|
|
16623
16688
|
constructor(e, t, n = {}) {
|
|
16624
16689
|
if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
|
|
16625
|
-
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 || (() => He), 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 ||
|
|
16690
|
+
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 || (() => He), 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 || Sm.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
|
|
16626
16691
|
isUpscaling: !1,
|
|
16627
16692
|
isLoading: !1,
|
|
16628
16693
|
abortController: null
|
|
16629
16694
|
}, 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;
|
|
16630
16695
|
}
|
|
16631
16696
|
async _ensureSession() {
|
|
16632
|
-
let e =
|
|
16697
|
+
let e = Sm.QUALITY_PRESETS[this.quality];
|
|
16633
16698
|
if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
|
|
16634
16699
|
let t = e[this.scaleFactor];
|
|
16635
16700
|
if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
|
|
@@ -16639,14 +16704,14 @@ var _m = {
|
|
|
16639
16704
|
message: `Loading ${this.scaleFactor}x upscale model...`
|
|
16640
16705
|
});
|
|
16641
16706
|
try {
|
|
16642
|
-
this._worker ||= new
|
|
16707
|
+
this._worker ||= new ym(), await new Promise((e, n) => {
|
|
16643
16708
|
let r = (t) => {
|
|
16644
16709
|
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)));
|
|
16645
16710
|
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } = cl();
|
|
16646
16711
|
this._worker.addEventListener("message", r), this._worker.postMessage({
|
|
16647
16712
|
type: "load",
|
|
16648
16713
|
url: t,
|
|
16649
|
-
sessionOptions:
|
|
16714
|
+
sessionOptions: Sm.SESSION_OPTIONS,
|
|
16650
16715
|
ortRuntimeUrl: i,
|
|
16651
16716
|
ortWasmPaths: a,
|
|
16652
16717
|
cacheNamespace: o
|
|
@@ -16717,7 +16782,7 @@ var _m = {
|
|
|
16717
16782
|
alpha: !0
|
|
16718
16783
|
});
|
|
16719
16784
|
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = Zp.get(this.getToneMapping()) || Zp.get(He), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
|
|
16720
|
-
let o =
|
|
16785
|
+
let o = Sm.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
|
|
16721
16786
|
for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
|
|
16722
16787
|
if (e.aborted) throw new DOMException("Aborted", "AbortError");
|
|
16723
16788
|
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);
|
|
@@ -16863,7 +16928,7 @@ var _m = {
|
|
|
16863
16928
|
this.hdr = !!e;
|
|
16864
16929
|
}
|
|
16865
16930
|
setQuality(e) {
|
|
16866
|
-
if (!
|
|
16931
|
+
if (!Sm.QUALITY_PRESETS[e]) {
|
|
16867
16932
|
console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
|
|
16868
16933
|
return;
|
|
16869
16934
|
}
|
|
@@ -16886,9 +16951,9 @@ var _m = {
|
|
|
16886
16951
|
async dispose() {
|
|
16887
16952
|
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");
|
|
16888
16953
|
}
|
|
16889
|
-
},
|
|
16954
|
+
}, wm = class extends lt {
|
|
16890
16955
|
constructor({ renderer: e, mainCanvas: t, scene: n, camera: r, stages: i, pipeline: a, getExposure: o, getSaturation: s, getTransparentBg: c }) {
|
|
16891
|
-
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;
|
|
16956
|
+
super(), this.renderer = e, this.mainCanvas = t, this.denoiserCanvas = this._createDenoiserCanvas(t), this.scene = n, this.camera = r, this.pipeline = a, this._stages = i, this._getExposure = o, this._getSaturation = s, this._getTransparentBg = c, this.denoiser = null, this.upscaler = null, this._onReset = null, this._onPostProcessRefresh = null, this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._pendingStartUpscaler = null, this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null;
|
|
16892
16957
|
}
|
|
16893
16958
|
_createDenoiserCanvas(e) {
|
|
16894
16959
|
let t = e.parentNode;
|
|
@@ -16907,7 +16972,7 @@ var _m = {
|
|
|
16907
16972
|
setupDenoiser() {
|
|
16908
16973
|
if (!this.denoiserCanvas) return;
|
|
16909
16974
|
let e = this._stages.pathTracer;
|
|
16910
|
-
this.denoiser = new
|
|
16975
|
+
this.denoiser = new gm(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
|
|
16911
16976
|
...Y,
|
|
16912
16977
|
backendParams: () => ({
|
|
16913
16978
|
device: this.renderer.backend.device,
|
|
@@ -16932,7 +16997,7 @@ var _m = {
|
|
|
16932
16997
|
setupUpscaler() {
|
|
16933
16998
|
if (!this.denoiserCanvas) return;
|
|
16934
16999
|
let e = this._stages.pathTracer;
|
|
16935
|
-
this.upscaler = new
|
|
17000
|
+
this.upscaler = new Cm(this.denoiserCanvas, this.renderer, {
|
|
16936
17001
|
scaleFactor: Y.upscalerScale || 2,
|
|
16937
17002
|
quality: Y.upscalerQuality || "fast",
|
|
16938
17003
|
getSourceCanvas: () => this.denoiser?.enabled ? null : this.renderer.domElement,
|
|
@@ -17013,6 +17078,9 @@ var _m = {
|
|
|
17013
17078
|
setResetCallback(e) {
|
|
17014
17079
|
this._onReset = e;
|
|
17015
17080
|
}
|
|
17081
|
+
setPostProcessRefreshCallback(e) {
|
|
17082
|
+
this._onPostProcessRefresh = e;
|
|
17083
|
+
}
|
|
17016
17084
|
setSettings(e) {
|
|
17017
17085
|
this._settings = e;
|
|
17018
17086
|
}
|
|
@@ -17032,10 +17100,10 @@ var _m = {
|
|
|
17032
17100
|
this._stages.autoExposure?.updateParameters(e);
|
|
17033
17101
|
}
|
|
17034
17102
|
setOIDNEnabled(e) {
|
|
17035
|
-
this.denoiser && (this.denoiser.enabled = e), this._syncGBufferStages();
|
|
17103
|
+
this.denoiser && (this.denoiser.enabled = e), this._syncGBufferStages(), this._onPostProcessRefresh?.();
|
|
17036
17104
|
}
|
|
17037
17105
|
setOIDNQuality(e) {
|
|
17038
|
-
this.denoiser?.updateQuality(e), this._stages.pathTracer?.setCleanAuxNormal?.(!!this.denoiser?.enabled && e !== "fast");
|
|
17106
|
+
this.denoiser?.updateQuality(e), this._stages.pathTracer?.setCleanAuxNormal?.(!!this.denoiser?.enabled && e !== "fast"), this._onPostProcessRefresh?.();
|
|
17039
17107
|
}
|
|
17040
17108
|
setTileHelperEnabled(e) {
|
|
17041
17109
|
this._setTileHelper(e);
|
|
@@ -17080,7 +17148,7 @@ var _m = {
|
|
|
17080
17148
|
let t = kr[e];
|
|
17081
17149
|
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));
|
|
17082
17150
|
}
|
|
17083
|
-
},
|
|
17151
|
+
}, Tm = class {
|
|
17084
17152
|
constructor() {
|
|
17085
17153
|
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;
|
|
17086
17154
|
}
|
|
@@ -17104,7 +17172,7 @@ var _m = {
|
|
|
17104
17172
|
dispose() {
|
|
17105
17173
|
this.visible = !1;
|
|
17106
17174
|
}
|
|
17107
|
-
},
|
|
17175
|
+
}, Em = class {
|
|
17108
17176
|
constructor(n, r) {
|
|
17109
17177
|
this.layer = "scene", this._enabled = !0, this._outlineNode = bn(n, r, {
|
|
17110
17178
|
selectedObjects: [],
|
|
@@ -17135,11 +17203,11 @@ var _m = {
|
|
|
17135
17203
|
this._enabled = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
|
|
17136
17204
|
}
|
|
17137
17205
|
};
|
|
17138
|
-
function
|
|
17206
|
+
function Dm(e = !1) {
|
|
17139
17207
|
let t = document.createElement("canvas");
|
|
17140
17208
|
return t.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;" + (e ? "display:none;" : ""), t;
|
|
17141
17209
|
}
|
|
17142
|
-
function
|
|
17210
|
+
function Om(e, t = Infinity) {
|
|
17143
17211
|
let n = e?.getBoundingClientRect();
|
|
17144
17212
|
if (!n || n.width === 0 || n.height === 0) return null;
|
|
17145
17213
|
let r = Math.min(window.devicePixelRatio || 1, 2), i = Math.round(n.width * r), a = Math.round(n.height * r), o = t / Math.max(i, a);
|
|
@@ -17150,9 +17218,9 @@ function Cm(e, t = Infinity) {
|
|
|
17150
17218
|
}
|
|
17151
17219
|
//#endregion
|
|
17152
17220
|
//#region src/managers/helpers/ViewOverlayRenderer.js
|
|
17153
|
-
var
|
|
17221
|
+
var km = 4096, Am = class {
|
|
17154
17222
|
constructor() {
|
|
17155
|
-
this.canvas =
|
|
17223
|
+
this.canvas = Dm(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
|
|
17156
17224
|
}
|
|
17157
17225
|
async init({ device: e, sizeSource: t }) {
|
|
17158
17226
|
this._sizeSource = t;
|
|
@@ -17169,7 +17237,7 @@ var wm = 4096, Tm = class {
|
|
|
17169
17237
|
}
|
|
17170
17238
|
syncSize() {
|
|
17171
17239
|
if (!this.renderer) return;
|
|
17172
|
-
let e =
|
|
17240
|
+
let e = Om(this._sizeSource, km);
|
|
17173
17241
|
!e || e.width === this.canvas.width && e.height === this.canvas.height || this.renderer.setSize(e.width, e.height, !1);
|
|
17174
17242
|
}
|
|
17175
17243
|
begin() {
|
|
@@ -17181,18 +17249,18 @@ var wm = 4096, Tm = class {
|
|
|
17181
17249
|
dispose() {
|
|
17182
17250
|
br(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
|
|
17183
17251
|
}
|
|
17184
|
-
},
|
|
17252
|
+
}, jm = ai("overlay"), Mm = (e, t) => e.visible && e.layer === t && e.render, Nm = class {
|
|
17185
17253
|
constructor(e) {
|
|
17186
|
-
this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas =
|
|
17254
|
+
this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = Dm(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
|
|
17187
17255
|
}
|
|
17188
17256
|
async initViewRenderer({ device: e, sizeSource: t }) {
|
|
17189
17257
|
if (!(!e || !t)) try {
|
|
17190
|
-
this._viewOverlay = await new
|
|
17258
|
+
this._viewOverlay = await new Am().init({
|
|
17191
17259
|
device: e,
|
|
17192
17260
|
sizeSource: t
|
|
17193
17261
|
});
|
|
17194
17262
|
} catch (e) {
|
|
17195
|
-
|
|
17263
|
+
jm.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
|
|
17196
17264
|
}
|
|
17197
17265
|
}
|
|
17198
17266
|
setHelperScene(e) {
|
|
@@ -17208,11 +17276,11 @@ var wm = 4096, Tm = class {
|
|
|
17208
17276
|
}
|
|
17209
17277
|
setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
|
|
17210
17278
|
this.setHelperScene(e);
|
|
17211
|
-
let s = new
|
|
17279
|
+
let s = new Tm();
|
|
17212
17280
|
this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener("resolution_changed", (e) => {
|
|
17213
17281
|
s.setRenderSize(e.width, e.height);
|
|
17214
17282
|
}), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
|
|
17215
|
-
let c = new
|
|
17283
|
+
let c = new Em(t, this.camera);
|
|
17216
17284
|
this.register("outline", c);
|
|
17217
17285
|
}
|
|
17218
17286
|
_wireDenoiserTileEvents(e, t) {
|
|
@@ -17224,7 +17292,7 @@ var wm = 4096, Tm = class {
|
|
|
17224
17292
|
}));
|
|
17225
17293
|
}
|
|
17226
17294
|
register(e, t) {
|
|
17227
|
-
this._helpers.has(e) && (
|
|
17295
|
+
this._helpers.has(e) && (jm.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
|
|
17228
17296
|
}
|
|
17229
17297
|
unregister(e) {
|
|
17230
17298
|
let t = this._helpers.get(e);
|
|
@@ -17262,16 +17330,16 @@ var wm = 4096, Tm = class {
|
|
|
17262
17330
|
}
|
|
17263
17331
|
_renderSceneLayer(e) {
|
|
17264
17332
|
this._helperScene?.render(e, this.camera);
|
|
17265
|
-
for (let t of this._helpers.values())
|
|
17333
|
+
for (let t of this._helpers.values()) Mm(t, "scene") && t.render(e, this.camera);
|
|
17266
17334
|
}
|
|
17267
17335
|
_hasVisibleSceneOverlay() {
|
|
17268
17336
|
if (this._helperScene?.isDrawing) return !0;
|
|
17269
|
-
for (let e of this._helpers.values()) if (
|
|
17337
|
+
for (let e of this._helpers.values()) if (Mm(e, "scene")) return !0;
|
|
17270
17338
|
return !1;
|
|
17271
17339
|
}
|
|
17272
17340
|
refreshHUD() {
|
|
17273
17341
|
let e = this._hudCanvas, t = this._hudCtx, n = !1;
|
|
17274
|
-
for (let e of this._helpers.values()) if (
|
|
17342
|
+
for (let e of this._helpers.values()) if (Mm(e, "hud")) {
|
|
17275
17343
|
n = !0;
|
|
17276
17344
|
break;
|
|
17277
17345
|
}
|
|
@@ -17280,10 +17348,10 @@ var wm = 4096, Tm = class {
|
|
|
17280
17348
|
return;
|
|
17281
17349
|
}
|
|
17282
17350
|
e.style.display !== "" && (e.style.display = "");
|
|
17283
|
-
let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ?
|
|
17351
|
+
let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? Om(e) : null;
|
|
17284
17352
|
if (a) {
|
|
17285
17353
|
(e.width !== a.width || e.height !== a.height) && (e.width = a.width, e.height = a.height), t.clearRect(0, 0, a.width, a.height), t.save(), t.scale(a.width / r, a.height / i);
|
|
17286
|
-
for (let e of this._helpers.values())
|
|
17354
|
+
for (let e of this._helpers.values()) Mm(e, "hud") && e.render(t, r, i);
|
|
17287
17355
|
t.restore(), e.style.display !== "" && (e.style.display = "");
|
|
17288
17356
|
}
|
|
17289
17357
|
}
|
|
@@ -17291,7 +17359,7 @@ var wm = 4096, Tm = class {
|
|
|
17291
17359
|
for (let e of this._helpers.values()) e.dispose?.();
|
|
17292
17360
|
this._helpers.clear(), this._viewOverlay?.dispose(), this._viewOverlay = null, this._hudCanvas.parentElement && this._hudCanvas.parentElement.removeChild(this._hudCanvas);
|
|
17293
17361
|
}
|
|
17294
|
-
},
|
|
17362
|
+
}, Pm = class extends lt {
|
|
17295
17363
|
constructor() {
|
|
17296
17364
|
super(), this.mixer = null, this.timer = new tn(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._tempVec = new sn(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this.wakeCallback = null;
|
|
17297
17365
|
}
|
|
@@ -17391,7 +17459,7 @@ var wm = 4096, Tm = class {
|
|
|
17391
17459
|
dispose() {
|
|
17392
17460
|
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;
|
|
17393
17461
|
}
|
|
17394
|
-
},
|
|
17462
|
+
}, Fm = new sn(0, 0, -1), Im = class {
|
|
17395
17463
|
constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
|
|
17396
17464
|
this._app = r, this._orbitControls = n, this._camera = e, this._controls = new xn(e, t), this._gizmoScene = new Jt(), 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 sn(), this._normalMatrix = new xt(), this._refitInFlight = !1, this._baselineComputed = !1, this._tempForward = new sn(), this._lightTargetDistance = null, this._lastLightPosition = null, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
|
|
17397
17465
|
}
|
|
@@ -17412,7 +17480,7 @@ var wm = 4096, Tm = class {
|
|
|
17412
17480
|
attach(e) {
|
|
17413
17481
|
if (this._attached !== e && (this._controls.attach(e), this._attached = e, this._lightTargetDistance = null, this._lastLightPosition = null, e.isLight && e.target)) {
|
|
17414
17482
|
let t = e.target.position.clone().sub(e.position), n = t.length();
|
|
17415
|
-
n > 1e-4 ? (e.quaternion.setFromUnitVectors(
|
|
17483
|
+
n > 1e-4 ? (e.quaternion.setFromUnitVectors(Fm, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1, this._lastLightPosition = e.position.clone();
|
|
17416
17484
|
}
|
|
17417
17485
|
}
|
|
17418
17486
|
detach() {
|
|
@@ -17524,7 +17592,7 @@ var wm = 4096, Tm = class {
|
|
|
17524
17592
|
dispose() {
|
|
17525
17593
|
this._controls.removeEventListener("dragging-changed", this._onDraggingChanged), this._controls.removeEventListener("objectChange", this._onObjectChange), this.detach(), this._gizmoScene.remove(this._controls.getHelper()), this._controls.dispose(), this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._baselineComputed = !1, this._tempForward = null, this._lightTargetDistance = null, this._lastLightPosition = null, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
|
|
17526
17594
|
}
|
|
17527
|
-
},
|
|
17595
|
+
}, Lm = class {
|
|
17528
17596
|
constructor(e) {
|
|
17529
17597
|
this.layer = "scene", this._transformManager = e, this._enabled = !0;
|
|
17530
17598
|
}
|
|
@@ -17543,15 +17611,15 @@ var wm = 4096, Tm = class {
|
|
|
17543
17611
|
dispose() {
|
|
17544
17612
|
this._enabled = !1;
|
|
17545
17613
|
}
|
|
17546
|
-
},
|
|
17614
|
+
}, Rm = /* @__PURE__ */ new WeakMap(), zm = ai("engine"), Bm = class extends lt {
|
|
17547
17615
|
constructor(e, t = {}) {
|
|
17548
17616
|
super();
|
|
17549
17617
|
try {
|
|
17550
|
-
|
|
17618
|
+
Rm.get(e)?.dispose();
|
|
17551
17619
|
} catch (e) {
|
|
17552
|
-
|
|
17620
|
+
zm.warn("prior canvas owner dispose failed", e);
|
|
17553
17621
|
}
|
|
17554
|
-
|
|
17622
|
+
Rm.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new Dp(Y), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = Y.maxTextureSize, this.pipeline = null, this._pendingReservedRenderSize = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Pm(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this._pathTracerEnabled = !0, this._rasterPrecompile = null, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Hf(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null;
|
|
17555
17623
|
}
|
|
17556
17624
|
_addTrackedListener(e, t, n) {
|
|
17557
17625
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -17564,12 +17632,12 @@ var wm = 4096, Tm = class {
|
|
|
17564
17632
|
for (let { target: e, type: t, handler: n } of this._trackedListeners) try {
|
|
17565
17633
|
e.removeEventListener(t, n);
|
|
17566
17634
|
} catch (e) {
|
|
17567
|
-
|
|
17635
|
+
zm.warn("failed to remove listener", t, e);
|
|
17568
17636
|
}
|
|
17569
17637
|
this._trackedListeners.length = 0;
|
|
17570
17638
|
}
|
|
17571
17639
|
async init() {
|
|
17572
|
-
return await this._initRenderer(), this._applyPendingReservedRenderSize(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), this.stages.pathTracer.setTriangleData(new Float32Array(32), 0), this.stages.pathTracer.setBVHData(new Float32Array(16)), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0,
|
|
17640
|
+
return await this._initRenderer(), this._applyPendingReservedRenderSize(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), this.stages.pathTracer.setTriangleData(new Float32Array(32), 0), this.stages.pathTracer.setBVHData(new Float32Array(16)), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, zm.debug("WebGPU path tracer app initialized"), this;
|
|
17573
17641
|
}
|
|
17574
17642
|
animate() {
|
|
17575
17643
|
if (!this._deviceLost) {
|
|
@@ -17579,7 +17647,7 @@ var wm = 4096, Tm = class {
|
|
|
17579
17647
|
}
|
|
17580
17648
|
if (this.cameraManager.controls && this.cameraManager.controls.update(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
|
|
17581
17649
|
let e = this.animationManager.update();
|
|
17582
|
-
e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) =>
|
|
17650
|
+
e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => zm.error("animation refit error:", e)).finally(() => {
|
|
17583
17651
|
this._animRefitInFlight = !1;
|
|
17584
17652
|
}));
|
|
17585
17653
|
}
|
|
@@ -17613,7 +17681,7 @@ var wm = 4096, Tm = class {
|
|
|
17613
17681
|
this.animationManagerId &&= (cancelAnimationFrame(this.animationManagerId), null);
|
|
17614
17682
|
}
|
|
17615
17683
|
_handleDeviceLost(e) {
|
|
17616
|
-
this._deviceLost || (this._deviceLost = !0,
|
|
17684
|
+
this._deviceLost || (this._deviceLost = !0, zm.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
|
|
17617
17685
|
type: ur.DEVICE_LOST,
|
|
17618
17686
|
reason: e?.reason,
|
|
17619
17687
|
message: e?.message
|
|
@@ -17629,15 +17697,7 @@ var wm = 4096, Tm = class {
|
|
|
17629
17697
|
this._paused = !1, this.animationManagerId || this.animate();
|
|
17630
17698
|
}
|
|
17631
17699
|
reset(e = !1) {
|
|
17632
|
-
|
|
17633
|
-
let e = this.denoisingManager._lastRenderWidth, t = this.denoisingManager._lastRenderHeight;
|
|
17634
|
-
this.dispatchEvent({
|
|
17635
|
-
type: "resolution_changed",
|
|
17636
|
-
width: e,
|
|
17637
|
-
height: t
|
|
17638
|
-
});
|
|
17639
|
-
}
|
|
17640
|
-
this.completion.reset(), this.wake(), this.dispatchEvent({ type: "RenderReset" }), this.dispatchEvent({ type: ur.RENDER_RESET });
|
|
17700
|
+
this.pipeline && (this.pipeline.reset(), e || this.pipeline.eventBus.emit("asvgf:reset")), this._abortPostProcess(), this.completion.reset(), this.wake(), this.dispatchEvent({ type: "RenderReset" }), this.dispatchEvent({ type: ur.RENDER_RESET });
|
|
17641
17701
|
}
|
|
17642
17702
|
dispose() {
|
|
17643
17703
|
if (!this._disposed) {
|
|
@@ -17651,7 +17711,7 @@ var wm = 4096, Tm = class {
|
|
|
17651
17711
|
let e = Ae().value, t = k().value;
|
|
17652
17712
|
e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
|
|
17653
17713
|
} catch (e) {
|
|
17654
|
-
|
|
17714
|
+
zm.warn("failed to clear TSL texture singleton listeners", e);
|
|
17655
17715
|
}
|
|
17656
17716
|
br(this.renderer), this.renderer = null, this.stages = {}, this.isInitialized = !1;
|
|
17657
17717
|
}
|
|
@@ -17875,7 +17935,7 @@ var wm = 4096, Tm = class {
|
|
|
17875
17935
|
if (!e) return;
|
|
17876
17936
|
this._pendingReservedRenderSize = null;
|
|
17877
17937
|
let t = this.setReservedRenderResolution(e.requestedPx, { allowLower: e.allowLower });
|
|
17878
|
-
t < e.requestedPx &&
|
|
17938
|
+
t < e.requestedPx && zm.warn(`reserved render size ${Q.n(e.requestedPx)}px was capped to ${Q.n(t)}px by this device's limits — renders above ${Q.n(t)}px will be declined.`), this.dispatchEvent({
|
|
17879
17939
|
type: "reserved_render_size_changed",
|
|
17880
17940
|
size: t
|
|
17881
17941
|
});
|
|
@@ -17884,7 +17944,7 @@ var wm = 4096, Tm = class {
|
|
|
17884
17944
|
return Dr;
|
|
17885
17945
|
}
|
|
17886
17946
|
_isRenderSizeSupported(e, t) {
|
|
17887
|
-
return e > Dr || t > Dr ? (
|
|
17947
|
+
return e > Dr || t > Dr ? (zm.warn(`render resolution ${e}×${t} exceeds the ${Dr}px reserve (compute storage textures are pre-allocated at ${Dr}px). Ignoring resize — raise the reserve with setReservedRenderResolution( ${Math.max(e, t)} ) first, or use a resolution ≤ ${Dr}.`), !1) : !0;
|
|
17888
17948
|
}
|
|
17889
17949
|
onResize() {
|
|
17890
17950
|
let e = this.canvas.clientWidth, t = this.canvas.clientHeight;
|
|
@@ -17934,6 +17994,19 @@ var wm = 4096, Tm = class {
|
|
|
17934
17994
|
refreshFrame() {
|
|
17935
17995
|
this._needsDisplayRefresh = !0, this.wake();
|
|
17936
17996
|
}
|
|
17997
|
+
_abortPostProcess() {
|
|
17998
|
+
if (this.denoisingManager?.abort(this.canvas), this.denoisingManager?.restoreBaseResolution()) {
|
|
17999
|
+
let e = this.denoisingManager._lastRenderWidth, t = this.denoisingManager._lastRenderHeight;
|
|
18000
|
+
this.dispatchEvent({
|
|
18001
|
+
type: "resolution_changed",
|
|
18002
|
+
width: e,
|
|
18003
|
+
height: t
|
|
18004
|
+
});
|
|
18005
|
+
}
|
|
18006
|
+
}
|
|
18007
|
+
requestPostProcessRefresh() {
|
|
18008
|
+
!this.stages.pathTracer?.isReady || this._deviceLost || (this._abortPostProcess(), this.completion.renderCompleteDispatched = !1, this.wake());
|
|
18009
|
+
}
|
|
17937
18010
|
setDeterministicMode(e = !0, { pinDispatch: t = !0 } = {}) {
|
|
17938
18011
|
let n = this.stages.pathTracer;
|
|
17939
18012
|
if (!n) return !1;
|
|
@@ -18055,7 +18128,7 @@ var wm = 4096, Tm = class {
|
|
|
18055
18128
|
this._pathTracerEnabled = e, e || this.precompileRaster();
|
|
18056
18129
|
}
|
|
18057
18130
|
precompileRaster() {
|
|
18058
|
-
return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) =>
|
|
18131
|
+
return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) => zm.warn("raster fallback precompile failed", e)), this._rasterPrecompile);
|
|
18059
18132
|
}
|
|
18060
18133
|
get isLoading() {
|
|
18061
18134
|
return this._loadingInProgress;
|
|
@@ -18162,7 +18235,7 @@ var wm = 4096, Tm = class {
|
|
|
18162
18235
|
let n = this.renderer.backend?.device;
|
|
18163
18236
|
n?.lost && (n.lost.then((e) => {
|
|
18164
18237
|
this._disposed || this._handleDeviceLost(e);
|
|
18165
|
-
}), n.onuncapturederror = (e) =>
|
|
18238
|
+
}), n.onuncapturederror = (e) => zm.error("WebGPU uncaptured error:", e.error)), r.setLTC(cn.init()), this.renderer.outputColorSpace = a, this.renderer.toneMapping = He, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
|
|
18166
18239
|
}
|
|
18167
18240
|
_initCameraManager() {
|
|
18168
18241
|
this.cameraManager = new Op(this.canvas);
|
|
@@ -18190,18 +18263,18 @@ var wm = 4096, Tm = class {
|
|
|
18190
18263
|
assetLoader: this.assetLoader,
|
|
18191
18264
|
pathTracer: null,
|
|
18192
18265
|
floorPlane: this.assetLoader.floorPlane
|
|
18193
|
-
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new kp(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new Ap(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Vp(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), await this._setupOverlayManager(), this.transformManager = new
|
|
18266
|
+
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new kp(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new Ap(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Vp(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), await this._setupOverlayManager(), this.transformManager = new Im({
|
|
18194
18267
|
camera: this.cameraManager.camera,
|
|
18195
18268
|
canvas: this.canvas,
|
|
18196
18269
|
orbitControls: this.cameraManager.controls,
|
|
18197
18270
|
app: this
|
|
18198
|
-
}), this.overlayManager.register("transform", new
|
|
18271
|
+
}), this.overlayManager.register("transform", new Lm(this.transformManager)), this.interactionManager.setDependencies({
|
|
18199
18272
|
overlayManager: this.overlayManager,
|
|
18200
18273
|
transformManager: this.transformManager,
|
|
18201
18274
|
appDispatch: (e) => this.dispatchEvent(e),
|
|
18202
18275
|
orbitControls: this.cameraManager.controls,
|
|
18203
18276
|
helperScene: this._sceneHelpers.scene
|
|
18204
|
-
}), this.denoisingManager.setOverlayManager(this.overlayManager), this.denoisingManager.setResetCallback(() => this.reset()), this.denoisingManager.setSettings(this.settings), this.environmentManager = this.stages.pathTracer.environment, this.environmentManager.callbacks.onAutoExposureReset = () => this.pipeline.eventBus.emit("autoexposure:resetHistory");
|
|
18277
|
+
}), this.denoisingManager.setOverlayManager(this.overlayManager), this.denoisingManager.setResetCallback(() => this.reset()), this.denoisingManager.setPostProcessRefreshCallback(() => this.requestPostProcessRefresh()), this.denoisingManager.setSettings(this.settings), this.environmentManager = this.stages.pathTracer.environment, this.environmentManager.callbacks.onAutoExposureReset = () => this.pipeline.eventBus.emit("autoexposure:resetHistory");
|
|
18205
18278
|
}
|
|
18206
18279
|
_wireEvents() {
|
|
18207
18280
|
this._addTrackedListener(this.cameraManager, "CameraSwitched", (e) => this.dispatchEvent(e)), this._addTrackedListener(this.cameraManager, ur.AUTO_FOCUS_UPDATED, (e) => this.dispatchEvent(e)), this._forwardEvents(this.denoisingManager, [
|
|
@@ -18273,7 +18346,7 @@ var wm = 4096, Tm = class {
|
|
|
18273
18346
|
});
|
|
18274
18347
|
}
|
|
18275
18348
|
_setupDenoisingManager() {
|
|
18276
|
-
this.denoisingManager = new
|
|
18349
|
+
this.denoisingManager = new wm({
|
|
18277
18350
|
renderer: this.renderer,
|
|
18278
18351
|
mainCanvas: this.canvas,
|
|
18279
18352
|
scene: this.scene,
|
|
@@ -18316,7 +18389,7 @@ var wm = 4096, Tm = class {
|
|
|
18316
18389
|
this.scene.updateMatrixWorld(), this.overlayManager?.render();
|
|
18317
18390
|
}
|
|
18318
18391
|
async _setupOverlayManager() {
|
|
18319
|
-
this.overlayManager = new
|
|
18392
|
+
this.overlayManager = new Nm(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
|
|
18320
18393
|
helperScene: this._sceneHelpers,
|
|
18321
18394
|
meshScene: this.meshScene,
|
|
18322
18395
|
pipeline: this.pipeline,
|
|
@@ -18347,7 +18420,7 @@ var wm = 4096, Tm = class {
|
|
|
18347
18420
|
_forwardEvents(e, t) {
|
|
18348
18421
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
18349
18422
|
}
|
|
18350
|
-
},
|
|
18423
|
+
}, Vm = class {
|
|
18351
18424
|
constructor(e) {
|
|
18352
18425
|
this._app = e, this._cancelled = !1, this._rendering = !1;
|
|
18353
18426
|
}
|
|
@@ -18445,4 +18518,4 @@ var wm = 4096, Tm = class {
|
|
|
18445
18518
|
}
|
|
18446
18519
|
};
|
|
18447
18520
|
//#endregion
|
|
18448
|
-
export { Pr as AF_DEFAULTS, kr as ASVGF_QUALITY_PRESETS, Nr as AUTO_FOCUS_MODES,
|
|
18521
|
+
export { Pr as AF_DEFAULTS, kr as ASVGF_QUALITY_PRESETS, Nr as AUTO_FOCUS_MODES, Pm as AnimationManager, Fr as BVH_LEAF_MARKERS, Mr as CAMERA_PRESETS, Ar as CAMERA_RANGES, Op as CameraManager, Br as DEFAULT_TEXTURE_MATRIX, wm as DenoisingManager, Y as ENGINE_DEFAULTS, ur as EngineEvents, Ap as GoboManager, Vp as IESManager, Hr as INTERACTIVE_RENDER_CONFIG, Uf as InteractionManager, Wr as LOG_LEVELS, kp as LightManager, ii as Logger, Er as MAX_RESERVABLE_RENDER_SIZE, Ur as MEMORY_CONSTANTS, Nm as OverlayManager, Vr as PRODUCTION_RENDER_CONFIG, Bm as PathTracerApp, kf as PipelineContext, Vf as RenderPipeline, Dp as RenderSettings, cr as RenderStage, jr as SKY_PRESETS, sr as StageExecutionMode, Ir as TEXTURE_CONSTANTS, X as TRIANGLE_DATA_LAYOUT, Im as TransformManager, uu as VRAMTracker, Vm as VideoRenderManager, cu as bufferBytes, If as clearBindingAuditFindings, sl as configureAssets, ai as createLogger, Q as fmt, cl as getAssetConfig, Ff as getBindingAuditFindings, Pf as setBindingAudit, lu as textureBytes };
|