rayzee 11.3.0 → 11.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 +33 -5
- package/dist/{ArchiveImporter-D735xX-4.js → ArchiveImporter-29Nl1567.js} +2 -2
- package/dist/{BidirectionalIntegrator-M89c0AlP.js → BidirectionalIntegrator-CJay8tXK.js} +2 -2
- package/dist/{NeuralRetouch-DiBH63kz.js → NeuralRetouch-KqGVPV7u.js} +4 -3
- package/dist/{NeuralSuperRes-CZNQP13W.js → NeuralSuperRes-BHxhYzlD.js} +11 -5
- package/dist/{PathTracer-BXCCVrPK.js → PathTracer-Cldt0mXi.js} +19 -12
- package/dist/{PhysicalSky-DqmaS0lb.js → PhysicalSky-CUWrTcmT.js} +1 -1
- package/dist/{RayzeeRenderer-DUSMFhmc.js → RayzeeRenderer-Dd-Dit0v.js} +313 -281
- package/dist/{ToneMapGPU-BOjpul7A.js → ToneMapGPU-sAs8wdgI.js} +44 -22
- package/dist/addons/archives.es.js +1 -1
- package/dist/addons/bidirectional.es.js +1 -1
- package/dist/addons/physical-sky.es.js +1 -1
- package/dist/rayzee-core.es.js +3 -3
- package/dist/rayzee.es.js +1428 -902
- package/dist/rayzee.umd.js +124 -113
- package/dist/{sceneCachePolicy-BAib5fCp.js → sceneCachePolicy--ta6moJu.js} +1 -1
- package/package.json +1 -1
- package/src/EngineDefaults.js +2 -2
- package/src/Passes/AIUpscaler.js +17 -12
- package/src/PathTracerApp.js +122 -16
- package/src/Pipeline/CompletionTracker.js +7 -3
- package/src/Processor/ToneMapCPU.js +16 -4
- package/src/Processor/ToneMapGPU.js +49 -14
- package/src/RayzeeRenderer.js +54 -7
- package/src/RenderSettings.js +4 -2
- package/src/Stages/AutoExposure.js +484 -494
- package/src/Stages/Compositor.js +27 -6
- package/src/Stages/LocalExposure.js +569 -0
- package/src/Stages/PathTracer.js +6 -4
- package/src/Stages/PathTracerStage.js +9 -7
- package/src/index.js +1 -0
- package/src/managers/DenoisingManager.js +93 -34
- package/src/managers/VideoRenderManager.js +30 -4
- package/src/neural/NeuralRetouch.js +1 -0
- package/src/neural/NeuralSuperRes.js +6 -1
package/dist/rayzee.es.js
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import { t as e } from "./BidirectionalIntegrator-
|
|
1
|
+
import { t as e } from "./BidirectionalIntegrator-CJay8tXK.js";
|
|
2
2
|
import { $t as t, Ft as n, Pt as r, Yt as i, en as a, jt as o, nn as s, rt as c, wt as l } from "./SolarLimb-bZE6y63S.js";
|
|
3
|
-
import { _ as u, a as d, c as f, d as p, f as m, g as h, h as g, i as _, l as v, m as y, n as b, o as x, p as S, r as ee, s as C, t as
|
|
4
|
-
import { $ as
|
|
3
|
+
import { _ as u, a as d, c as f, d as p, f as m, g as h, h as g, i as _, l as v, m as y, n as b, o as x, p as S, r as ee, s as C, t as w, u as T } from "./RayzeeRenderer-Dd-Dit0v.js";
|
|
4
|
+
import { $ as E, B as te, Et as D, H as ne, K as re, L as ie, N as ae, Ot as O, P as k, Q as oe, R as se, Tt as A, X as ce, Z as le, _t as ue, dt as de, et as fe, ft as pe, gt as me, ht as he, kt as ge, lt as _e, nt as ve, pt as ye, tt as be, ut as xe, wt as Se, z as Ce } from "./PathTracer-Cldt0mXi.js";
|
|
5
5
|
import { n as we, t as j } from "./EngineEvents-Ci8dVWCP.js";
|
|
6
|
-
import { D as Te, G as Ee, J as De, K as Oe, O as ke, W as Ae, Y as je, a as Me, c as Ne, et as Pe, i as Fe, m as Ie, ot as Le, p as Re, q as ze, r as Be, tt as Ve, x as He, y as Ue } from "./sceneCachePolicy
|
|
6
|
+
import { D as Te, G as Ee, J as De, K as Oe, O as ke, W as Ae, Y as je, a as Me, c as Ne, et as Pe, i as Fe, m as Ie, ot as Le, p as Re, q as ze, r as Be, tt as Ve, x as He, y as Ue } from "./sceneCachePolicy--ta6moJu.js";
|
|
7
7
|
import { i as We, n as Ge, r as Ke, t as qe } from "./Logger-dDDGj9Av.js";
|
|
8
8
|
import { f as Je, r as Ye } from "./BufferLayout-xPRH9jYD.js";
|
|
9
9
|
import { i as Xe, n as Ze, r as Qe, t as $e } from "./EngineIssues-CIZnXHsF.js";
|
|
10
10
|
import { i as et, r as tt } from "./shared-BGBcSxBQ.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { a as
|
|
15
|
-
import { a as
|
|
16
|
-
import { t as Et } from "./
|
|
17
|
-
import { t as Dt } from "./
|
|
18
|
-
import {
|
|
19
|
-
import { c as
|
|
20
|
-
import { n as
|
|
21
|
-
import {
|
|
22
|
-
import { i as
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
11
|
+
import { r as nt } from "./WorkingMatrix-C6y233hT.js";
|
|
12
|
+
import { i as rt, r as it, t as at } from "./ActiveColor-YvuQq44O.js";
|
|
13
|
+
import { n as ot, t as st } from "./AssetConfig-DSEntE65.js";
|
|
14
|
+
import { a as ct, d as lt, g as ut, i as dt, l as ft, o as pt, p as mt, r as ht, s as gt, t as _t, u as vt } from "./ViewTransforms-CYN7bq2w.js";
|
|
15
|
+
import { a as yt, i as bt, n as xt, r as St } from "./identity-C1cLD1C0.js";
|
|
16
|
+
import { a as Ct, n as wt, r as Tt, t as Et } from "./SceneMetadata-D2Sh-0e-.js";
|
|
17
|
+
import { t as Dt } from "./ToneMapGPU-sAs8wdgI.js";
|
|
18
|
+
import { t as Ot } from "./FileFormats-sPGJeCRc.js";
|
|
19
|
+
import { A as kt, C as At, D as jt, E as Mt, O as Nt, S as Pt, T as Ft, _ as It, a as Lt, b as Rt, c as zt, d as Bt, f as Vt, g as Ht, h as Ut, i as Wt, k as Gt, l as Kt, m as qt, n as Jt, o as Yt, p as Xt, r as Zt, s as Qt, t as $t, u as en, v as tn, w as nn, x as rn, y as an } from "./ColorManagement-oeEk7oSu.js";
|
|
20
|
+
import { c as on, l as sn, n as cn, o as ln, t as un } from "./openStorage-Fe9BoS1_.js";
|
|
21
|
+
import { n as dn, t as fn } from "./ZipReader-gDSWr0I5.js";
|
|
22
|
+
import { i as pn, n as mn, r as hn } from "./NeuralSuperRes-BHxhYzlD.js";
|
|
23
|
+
import { i as gn, n as _n, r as vn } from "./NeuralRetouch-KqGVPV7u.js";
|
|
24
|
+
import { ExternalTexture as yn, MeshBasicNodeMaterial as bn, QuadMesh as xn, ReadbackBuffer as Sn, RenderTarget as Cn, StorageTexture as wn, TextureNode as M, WebGPURenderer as Tn } from "three/webgpu";
|
|
25
|
+
import { Fn as En, If as N, Loop as Dn, Return as On, abs as kn, atan as An, atomicAdd as jn, atomicLoad as Mn, atomicStore as Nn, attributeArray as Pn, dot as Fn, exp as In, exp2 as Ln, float as P, floatBitsToUint as Rn, floor as zn, fract as Bn, int as F, ivec2 as I, localId as L, log2 as Vn, max as R, min as Hn, mix as z, normalize as Un, pow as Wn, round as Gn, saturate as B, select as V, smoothstep as Kn, sqrt as qn, storage as Jn, textureLoad as H, textureStore as U, toneMappingExposure as Yn, uint as W, uniform as G, uvec2 as Xn, uvec4 as Zn, vec2 as K, vec3 as q, vec4 as J, wgslFn as Qn, workgroupArray as $n, workgroupBarrier as er, workgroupId as Y } from "three/tsl";
|
|
26
|
+
import { ACESFilmicToneMapping as tr, AddEquation as nr, AnimationMixer as rr, Box2 as ir, Box3 as ar, ClampToEdgeWrapping as or, Color as sr, Controls as cr, CustomBlending as lr, DataArrayTexture as ur, DataTexture as dr, EventDispatcher as fr, FloatType as pr, HalfFloatType as mr, InterpolateSmooth as hr, LinearFilter as X, LoopOnce as gr, LoopRepeat as _r, MathUtils as vr, Matrix3 as yr, Matrix4 as br, Mesh as xr, MeshBasicMaterial as Sr, NearestFilter as Z, NoColorSpace as Cr, NumberKeyframeTrack as wr, OneFactor as Tr, OrthographicCamera as Er, PerspectiveCamera as Dr, PropertyBinding as Or, Quaternion as kr, RGBAFormat as Q, Raycaster as Ar, RedIntegerFormat as jr, SRGBColorSpace as Mr, Scene as Nr, SphereGeometry as Pr, Timer as Fr, UnsignedByteType as Ir, UnsignedIntType as Lr, Vector2 as Rr, Vector3 as $, Vector4 as zr, VectorKeyframeTrack as Br } from "three";
|
|
27
|
+
import { OrbitControls as Vr } from "three/addons/controls/OrbitControls.js";
|
|
28
|
+
import { outline as Hr } from "three/addons/tsl/display/OutlineNode.js";
|
|
29
|
+
import { TransformControls as Ur } from "three/addons/controls/TransformControls.js";
|
|
29
30
|
//#region src/Stages/DenoiserSettings.js
|
|
30
|
-
var
|
|
31
|
+
var Wr = 65504, Gr = 6e4, Kr = .01, qr = {
|
|
31
32
|
low: {
|
|
32
33
|
temporalAlpha: .1,
|
|
33
34
|
gradientStrength: .8,
|
|
@@ -67,7 +68,7 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
67
68
|
maxAccumFrames: 128,
|
|
68
69
|
varianceBoost: 1.5
|
|
69
70
|
}
|
|
70
|
-
},
|
|
71
|
+
}, Jr = 3, Yr = .1, Xr = {
|
|
71
72
|
maxAccumulatedFrameNum: 30,
|
|
72
73
|
maxFastAccumulatedFrameNum: 6,
|
|
73
74
|
maxStabilizedFrameNum: 63,
|
|
@@ -91,7 +92,7 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
91
92
|
convergenceP: .8,
|
|
92
93
|
lobeVolumePercent: .1,
|
|
93
94
|
handoverFrames: 0
|
|
94
|
-
},
|
|
95
|
+
}, Zr = [
|
|
95
96
|
"maxAccumulatedFrameNum",
|
|
96
97
|
"maxFastAccumulatedFrameNum",
|
|
97
98
|
"maxStabilizedFrameNum",
|
|
@@ -99,7 +100,7 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
99
100
|
"prepassBlurRadius",
|
|
100
101
|
"maxBlurRadius",
|
|
101
102
|
"enableAntiFirefly"
|
|
102
|
-
],
|
|
103
|
+
], Qr = {
|
|
103
104
|
low: {
|
|
104
105
|
maxAccumulatedFrameNum: 16,
|
|
105
106
|
maxFastAccumulatedFrameNum: 4,
|
|
@@ -117,7 +118,7 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
117
118
|
prepassBlurRadius: 40,
|
|
118
119
|
maxBlurRadius: 40
|
|
119
120
|
}
|
|
120
|
-
},
|
|
121
|
+
}, $r = qr.medium, ei = {
|
|
121
122
|
denoiserStrategy: "none",
|
|
122
123
|
filterStrength: 1,
|
|
123
124
|
edgeAtrousIterations: 5,
|
|
@@ -135,45 +136,45 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
135
136
|
upscalerHdr: !0,
|
|
136
137
|
enableASVGF: !1,
|
|
137
138
|
asvgfQualityPreset: "medium",
|
|
138
|
-
asvgfTemporalAlpha:
|
|
139
|
-
asvgfAtrousIterations:
|
|
140
|
-
asvgfPhiColor:
|
|
141
|
-
asvgfPhiNormal:
|
|
142
|
-
asvgfPhiDepth:
|
|
143
|
-
asvgfPhiLuminance:
|
|
144
|
-
asvgfVarianceBoost:
|
|
145
|
-
asvgfMaxAccumFrames:
|
|
146
|
-
asvgfGradientStrength:
|
|
147
|
-
asvgfGradientSigmaScale:
|
|
148
|
-
asvgfGradientNoiseFloor:
|
|
139
|
+
asvgfTemporalAlpha: $r.temporalAlpha,
|
|
140
|
+
asvgfAtrousIterations: $r.atrousIterations,
|
|
141
|
+
asvgfPhiColor: $r.phiColor,
|
|
142
|
+
asvgfPhiNormal: $r.phiNormal,
|
|
143
|
+
asvgfPhiDepth: $r.phiDepth,
|
|
144
|
+
asvgfPhiLuminance: $r.phiLuminance,
|
|
145
|
+
asvgfVarianceBoost: $r.varianceBoost,
|
|
146
|
+
asvgfMaxAccumFrames: $r.maxAccumFrames,
|
|
147
|
+
asvgfGradientStrength: $r.gradientStrength,
|
|
148
|
+
asvgfGradientSigmaScale: $r.gradientSigmaScale,
|
|
149
|
+
asvgfGradientNoiseFloor: $r.gradientNoiseFloor,
|
|
149
150
|
asvgfDebugMode: 0,
|
|
150
151
|
showAsvgfHeatmap: !1,
|
|
151
152
|
nrdQualityPreset: "medium",
|
|
152
153
|
nrdDebugMode: 0
|
|
153
|
-
},
|
|
154
|
+
}, ti = class extends O {
|
|
154
155
|
constructor(e, t = {}) {
|
|
155
156
|
super("NormalDepth", {
|
|
156
157
|
...t,
|
|
157
158
|
executionMode: ge.ALWAYS
|
|
158
|
-
}), this.renderer = e, this.pathTracer = t.pathTracer, this._dirty = !0, this.cameraWorldMatrix =
|
|
159
|
+
}), this.renderer = e, this.pathTracer = t.pathTracer, this._dirty = !0, this.cameraWorldMatrix = G(new br(), "mat4"), this.cameraProjectionMatrixInverse = G(new br(), "mat4"), this.cameraRay = oe(), this.resolutionWidth = G(t.width || 1), this.resolutionHeight = G(t.height || 1);
|
|
159
160
|
let n = t.width || 1, r = t.height || 1;
|
|
160
|
-
this._outputStorageTex = new
|
|
161
|
-
type:
|
|
161
|
+
this._outputStorageTex = new wn(A, A), this._outputStorageTex.type = mr, this._outputStorageTex.format = Q, this._outputStorageTex.minFilter = Z, this._outputStorageTex.magFilter = Z, this._shadingStorageTex = new wn(A, A), this._shadingStorageTex.type = mr, this._shadingStorageTex.format = Q, this._shadingStorageTex.minFilter = Z, this._shadingStorageTex.magFilter = Z, this._shadingRT = new Cn(n, r, {
|
|
162
|
+
type: mr,
|
|
162
163
|
format: Q,
|
|
163
164
|
minFilter: Z,
|
|
164
165
|
magFilter: Z,
|
|
165
166
|
depthBuffer: !1,
|
|
166
167
|
stencilBuffer: !1
|
|
167
|
-
}), this._leafStorageTex = null, this._leafRT = null, this._srcRegion = new
|
|
168
|
+
}), this._leafStorageTex = null, this._leafRT = null, this._srcRegion = new ir(new Rr(0, 0), new Rr(0, 0));
|
|
168
169
|
let i = {
|
|
169
|
-
type:
|
|
170
|
+
type: mr,
|
|
170
171
|
format: Q,
|
|
171
172
|
minFilter: Z,
|
|
172
173
|
magFilter: Z,
|
|
173
174
|
depthBuffer: !1,
|
|
174
175
|
stencilBuffer: !1
|
|
175
176
|
};
|
|
176
|
-
this._rtA = new
|
|
177
|
+
this._rtA = new Cn(n, r, i), this._rtB = new Cn(n, r, i), this._currentIdx = 0, this._hasHistory = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._triStorageNode = null, this._bvhStorageNode = null, this._matStorageNode = null, this._lastTriAttr = null, this._lastBvhAttr = null, this._lastMatAttr = null, this._computeNode = null, this._computeBuilt = !1, this._linearBuckets = null;
|
|
177
178
|
}
|
|
178
179
|
setupEventListeners() {
|
|
179
180
|
this.on("camera:moved", () => {
|
|
@@ -190,35 +191,35 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
190
191
|
let t = e.sceneStorageNodes?.();
|
|
191
192
|
t && (this._triStorageNode = t.triangles, this._bvhStorageNode = t.bvh);
|
|
192
193
|
}
|
|
193
|
-
return t && !this._matStorageNode && (this._matStorageNode =
|
|
194
|
+
return t && !this._matStorageNode && (this._matStorageNode = Jn(t, "vec4", t.count).toReadOnly()), this._linearBuckets && te(this._linearBuckets, e.materialData?.linearBuckets), this._lastTriAttr = e.triangleGeoAttr || this._lastTriAttr, this._lastBvhAttr = e.bvhStorageAttr || this._lastBvhAttr, this._lastMatAttr = t || this._lastMatAttr, !!(this._triStorageNode && this._bvhStorageNode && this._matStorageNode);
|
|
194
195
|
}
|
|
195
196
|
_buildCompute() {
|
|
196
197
|
let e = this._triStorageNode, n = this._bvhStorageNode, r = this._matStorageNode;
|
|
197
|
-
this._linearBuckets =
|
|
198
|
+
this._linearBuckets = ae(this.pathTracer?.materialData?.linearBuckets);
|
|
198
199
|
let o = {
|
|
199
|
-
srgbBuckets:
|
|
200
|
+
srgbBuckets: ae(null),
|
|
200
201
|
linearBuckets: this._linearBuckets,
|
|
201
202
|
shadowAlbedoMaps: null,
|
|
202
203
|
goboMaps: null,
|
|
203
204
|
iesProfiles: null,
|
|
204
205
|
alphaShadows: null
|
|
205
206
|
}, c = this.cameraWorldMatrix, u = this.cameraProjectionMatrixInverse, d = this.resolutionWidth, f = this.resolutionHeight, p = this._outputStorageTex, m = this._shadingStorageTex, h = this._leafStorageTex;
|
|
206
|
-
this._computeNode = he(
|
|
207
|
-
let u =
|
|
208
|
-
|
|
209
|
-
let _ = t(
|
|
210
|
-
|
|
211
|
-
let S = v.normal.toVar(), ee =
|
|
212
|
-
|
|
213
|
-
let t = a.wrap(l(v.materialIndex, r)).toVar(), i = s.wrap(
|
|
214
|
-
|
|
215
|
-
o.assign(
|
|
207
|
+
this._computeNode = he(En(([o, c]) => {
|
|
208
|
+
let u = F(Y.x).mul(8).add(F(L.x)), g = F(Y.y).mul(8).add(F(L.y));
|
|
209
|
+
N(u.lessThan(F(d)).and(g.lessThan(F(f))), () => {
|
|
210
|
+
let _ = t(ce(K(P(u).add(.5).div(d), P(g).add(.5).div(f)), o, c, this.cameraRay)), v = i.wrap(re(_, n, e)), y = v.normal.mul(.5).add(.5), b = Hn(v.dst, P(65504)), x = v.didHit.select(J(y, b), J(0, 0, 0, P(Wr)));
|
|
211
|
+
U(p, Xn(W(u), W(g)), x).toWriteOnly(), h && U(h, Xn(W(u), W(g)), Zn(W(v.instanceLeaf.add(1)), 0, 0, 0)).toWriteOnly();
|
|
212
|
+
let S = v.normal.toVar(), ee = P(1).toVar();
|
|
213
|
+
N(v.didHit, () => {
|
|
214
|
+
let t = a.wrap(l(v.materialIndex, r)).toVar(), i = s.wrap(k(v.uv, t)).toVar(), o = J(0).toVar();
|
|
215
|
+
N(t.normalMapIndex.greaterThanEqual(F(0)), () => {
|
|
216
|
+
o.assign(ne(e, v.triangleIndex, v.normal, t.normalTransform, n, v.instanceLeaf));
|
|
216
217
|
});
|
|
217
218
|
let c = Ce(v.normal, t, i, o).toVar();
|
|
218
|
-
S.assign(
|
|
219
|
+
S.assign(ie(c, t, i)), ee.assign(se(t, i).y.clamp(.05, 1));
|
|
219
220
|
});
|
|
220
221
|
let C = v.didHit.select(J(S.mul(.5).add(.5), ee), J(0, 0, 0, 1));
|
|
221
|
-
|
|
222
|
+
U(m, Xn(W(u), W(g)), C).toWriteOnly();
|
|
222
223
|
});
|
|
223
224
|
})(c, u), o).compute([
|
|
224
225
|
this._dispatchX,
|
|
@@ -264,15 +265,15 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
264
265
|
reallocateReservedStorage() {
|
|
265
266
|
this._computeNode?.dispose(), this._computeNode = null, this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose();
|
|
266
267
|
let e = () => {
|
|
267
|
-
let e = new
|
|
268
|
-
return e.type =
|
|
268
|
+
let e = new wn(A, A);
|
|
269
|
+
return e.type = mr, e.format = Q, e.minFilter = Z, e.magFilter = Z, e;
|
|
269
270
|
};
|
|
270
271
|
this._outputStorageTex = e(), this._shadingStorageTex = e(), this._leafStorageTex &&= (this._leafStorageTex.dispose(), this._makeLeafStorage()), this._computeBuilt = !1;
|
|
271
272
|
}
|
|
272
273
|
setInstanceLeafOutput(e) {
|
|
273
|
-
e = !!e, e !== !!this._leafStorageTex && (this._computeNode?.dispose(), this._computeNode = null, this._computeBuilt = !1, this._dirty = !0, e ? (this._leafStorageTex = this._makeLeafStorage(), this._leafRT = new
|
|
274
|
-
type:
|
|
275
|
-
format:
|
|
274
|
+
e = !!e, e !== !!this._leafStorageTex && (this._computeNode?.dispose(), this._computeNode = null, this._computeBuilt = !1, this._dirty = !0, e ? (this._leafStorageTex = this._makeLeafStorage(), this._leafRT = new Cn(this._rtA.width, this._rtA.height, {
|
|
275
|
+
type: Lr,
|
|
276
|
+
format: jr,
|
|
276
277
|
minFilter: Z,
|
|
277
278
|
magFilter: Z,
|
|
278
279
|
depthBuffer: !1,
|
|
@@ -283,40 +284,40 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
283
284
|
this._leafRT ? e.setTexture("pathtracer:instanceLeaf", this._leafRT.texture) : e.getTexture("pathtracer:instanceLeaf") && e.removeTexture("pathtracer:instanceLeaf");
|
|
284
285
|
}
|
|
285
286
|
_makeLeafStorage() {
|
|
286
|
-
let e = new
|
|
287
|
-
return e.type =
|
|
287
|
+
let e = new wn(A, A);
|
|
288
|
+
return e.type = Lr, e.format = jr, e.minFilter = Z, e.magFilter = Z, e;
|
|
288
289
|
}
|
|
289
290
|
dispose() {
|
|
290
291
|
this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose(), this._shadingRT?.dispose(), this._leafStorageTex?.dispose(), this._leafRT?.dispose(), this._rtA?.dispose(), this._rtB?.dispose();
|
|
291
292
|
}
|
|
292
|
-
},
|
|
293
|
+
}, ni = class extends O {
|
|
293
294
|
constructor(e, t, n = {}) {
|
|
294
295
|
super("MotionVector", {
|
|
295
296
|
...n,
|
|
296
297
|
executionMode: ge.ALWAYS
|
|
297
298
|
}), this.renderer = e, this.camera = t, this.pathTracer = n.pathTracer || null;
|
|
298
299
|
let r = n.width || 1, i = n.height || 1;
|
|
299
|
-
this.prevViewProjectionMatrix = new
|
|
300
|
+
this.prevViewProjectionMatrix = new br(), this.currentViewProjectionMatrix = new br(), this.matricesInitialized = !1, this.isFirstFrame = !0, this.frameCount = 0, this.cameraWorldMatrix = G(new br(), "mat4"), this.cameraProjectionMatrixInverse = G(new br(), "mat4"), this.cameraRay = oe(), this.prevVP = G(new br(), "mat4"), this.isFirstFrameU = G(1), this.deltaTime = G(1 / 60), this.velocityScale = G(1), this.resolutionWidth = G(r), this.resolutionHeight = G(i), this._normalDepthTexNode = new M(), this._screenSpaceStorageTex = new wn(A, A), this._screenSpaceStorageTex.type = mr, this._screenSpaceStorageTex.format = Q, this._screenSpaceStorageTex.minFilter = Z, this._screenSpaceStorageTex.magFilter = Z, this._worldSpaceStorageTex = new wn(A, A), this._worldSpaceStorageTex.type = mr, this._worldSpaceStorageTex.format = Q, this._worldSpaceStorageTex.minFilter = Z, this._worldSpaceStorageTex.magFilter = Z, this._srcRegion = new ir(new Rr(0, 0), new Rr(0, 0));
|
|
300
301
|
let a = {
|
|
301
|
-
type:
|
|
302
|
+
type: mr,
|
|
302
303
|
format: Q,
|
|
303
304
|
minFilter: Z,
|
|
304
305
|
magFilter: Z,
|
|
305
306
|
depthBuffer: !1,
|
|
306
307
|
stencilBuffer: !1
|
|
307
308
|
};
|
|
308
|
-
this.screenSpaceTarget = new
|
|
309
|
+
this.screenSpaceTarget = new Cn(r, i, a), this.worldSpaceTarget = new Cn(r, i, a), this._dispatchX = Math.ceil(r / 16), this._dispatchY = Math.ceil(i / 16), this._buildScreenSpaceCompute(), this._buildWorldSpaceCompute();
|
|
309
310
|
}
|
|
310
311
|
_buildScreenSpaceCompute() {
|
|
311
312
|
let e = this._normalDepthTexNode, t = this.cameraWorldMatrix, n = this.cameraProjectionMatrixInverse, r = this.prevVP, i = this.resolutionWidth, a = this.resolutionHeight, o = this._screenSpaceStorageTex;
|
|
312
|
-
this._screenSpaceComputeNode =
|
|
313
|
-
let s =
|
|
314
|
-
|
|
315
|
-
let l =
|
|
316
|
-
|
|
317
|
-
let e =
|
|
318
|
-
d.assign(c.select(J(s, l, 1), J(
|
|
319
|
-
}),
|
|
313
|
+
this._screenSpaceComputeNode = En(([t, n]) => {
|
|
314
|
+
let s = F(Y.x).mul(16).add(F(L.x)), c = F(Y.y).mul(16).add(F(L.y));
|
|
315
|
+
N(s.lessThan(F(i)).and(c.lessThan(F(a))), () => {
|
|
316
|
+
let l = H(e, I(s, c)).w, u = K(P(s).add(.5).div(i), P(c).add(.5).div(a)), d = J(0, 0, l, 1).toVar();
|
|
317
|
+
N(l.lessThan(P(6e4)), () => {
|
|
318
|
+
let e = le(u, l, t, n, this.cameraRay), i = r.mul(J(e, 1)), a = i.xy.div(i.w), o = K(a.x.mul(.5).add(.5), a.y.mul(-.5).add(.5)), s = u.sub(o), c = o.x.greaterThanEqual(0).and(o.x.lessThanEqual(1)).and(o.y.greaterThanEqual(0)).and(o.y.lessThanEqual(1));
|
|
319
|
+
d.assign(c.select(J(s, l, 1), J(P(1e3), P(1e3), l, 0)));
|
|
320
|
+
}), U(o, Xn(W(s), W(c)), d).toWriteOnly();
|
|
320
321
|
});
|
|
321
322
|
})(t, n).compute([
|
|
322
323
|
this._dispatchX,
|
|
@@ -330,14 +331,14 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
330
331
|
}
|
|
331
332
|
_buildWorldSpaceCompute() {
|
|
332
333
|
let e = this._normalDepthTexNode, t = this.cameraWorldMatrix, n = this.cameraProjectionMatrixInverse, r = this.prevVP, i = this.isFirstFrameU, a = this.deltaTime, o = this.velocityScale, s = this.resolutionWidth, c = this.resolutionHeight, l = this._worldSpaceStorageTex;
|
|
333
|
-
this._worldSpaceComputeNode =
|
|
334
|
-
let u =
|
|
335
|
-
|
|
336
|
-
let f =
|
|
337
|
-
|
|
338
|
-
let e =
|
|
334
|
+
this._worldSpaceComputeNode = En(([t, n]) => {
|
|
335
|
+
let u = F(Y.x).mul(16).add(F(L.x)), d = F(Y.y).mul(16).add(F(L.y));
|
|
336
|
+
N(u.lessThan(F(s)).and(d.lessThan(F(c))), () => {
|
|
337
|
+
let f = H(e, I(u, d)).w, p = J(0, 0, 0, 0).toVar();
|
|
338
|
+
N(i.lessThan(.5).and(f.lessThan(P(6e4))), () => {
|
|
339
|
+
let e = K(P(u).add(.5).div(s), P(d).add(.5).div(c)), i = le(e, f, t, n, this.cameraRay), l = r.mul(J(i, 1)), m = l.xy.div(l.w), h = K(m.x.mul(.5).add(.5), m.y.mul(-.5).add(.5)), g = h.x.greaterThanEqual(0).and(h.x.lessThanEqual(1)).and(h.y.greaterThanEqual(0)).and(h.y.lessThanEqual(1)), _ = e.sub(h), v = q(_.x.div(a).mul(o), _.y.div(a).mul(o), 0);
|
|
339
340
|
p.assign(g.select(J(v, 1), J(0, 0, 0, .5)));
|
|
340
|
-
}),
|
|
341
|
+
}), U(l, Xn(W(u), W(d)), p).toWriteOnly();
|
|
341
342
|
});
|
|
342
343
|
})(t, n).compute([
|
|
343
344
|
this._dispatchX,
|
|
@@ -401,83 +402,83 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
401
402
|
reallocateReservedStorage() {
|
|
402
403
|
this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose();
|
|
403
404
|
let e = () => {
|
|
404
|
-
let e = new
|
|
405
|
-
return e.type =
|
|
405
|
+
let e = new wn(A, A);
|
|
406
|
+
return e.type = mr, e.format = Q, e.minFilter = Z, e.magFilter = Z, e;
|
|
406
407
|
};
|
|
407
408
|
this._screenSpaceStorageTex = e(), this._worldSpaceStorageTex = e(), this._buildScreenSpaceCompute(), this._buildWorldSpaceCompute();
|
|
408
409
|
}
|
|
409
410
|
dispose() {
|
|
410
411
|
this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose(), this.screenSpaceTarget?.dispose(), this.worldSpaceTarget?.dispose(), this._normalDepthTexNode?.dispose();
|
|
411
412
|
}
|
|
412
|
-
},
|
|
413
|
+
}, ri = (e) => V(e.equal(e), e, P(0)).clamp(0, 1e7), ii = (e) => q(ri(e.x), ri(e.y), ri(e.z)), ai = class extends O {
|
|
413
414
|
constructor(e, t = {}) {
|
|
414
415
|
super("ASVGF", {
|
|
415
416
|
...t,
|
|
416
417
|
executionMode: ge.PER_CYCLE
|
|
417
|
-
}), this.renderer = e, this.temporalAlpha =
|
|
418
|
+
}), this.renderer = e, this.temporalAlpha = G(t.temporalAlpha ?? qr.medium.temporalAlpha), this.gradientStrength = G(t.gradientStrength ?? qr.medium.gradientStrength), this.gradientSigmaScale = G(t.gradientSigmaScale ?? qr.medium.gradientSigmaScale), this.gradientNoiseFloor = G(t.gradientNoiseFloor ?? qr.medium.gradientNoiseFloor), this.maxAccumFrames = G(t.maxAccumFrames ?? qr.medium.maxAccumFrames), this.resW = G(t.width || 1), this.resH = G(t.height || 1), this.temporalEnabledU = G(1), this.forceResetU = G(0), this._colorTexNode = new M(), this._albedoTexNode = new M(), this._motionTexNode = new M(), this._normalDepthTexNode = new M(), this._prevNormalDepthTexNode = new M(), this._readTemporalTexNode = new M(), this._gradientReadTexNode = new M();
|
|
418
419
|
let n = t.width || 1, r = t.height || 1;
|
|
419
|
-
this._temporalTexA = new
|
|
420
|
-
type:
|
|
420
|
+
this._temporalTexA = new wn(A, A), this._temporalTexA.type = pr, this._temporalTexA.format = Q, this._temporalTexA.minFilter = X, this._temporalTexA.magFilter = X, this._temporalTexB = new wn(A, A), this._temporalTexB.type = pr, this._temporalTexB.format = Q, this._temporalTexB.minFilter = X, this._temporalTexB.magFilter = X, this._outputModulatedTex = new wn(A, A), this._outputModulatedTex.type = pr, this._outputModulatedTex.format = Q, this._outputModulatedTex.minFilter = X, this._outputModulatedTex.magFilter = X, this._gradientStorageTex = new wn(A, A), this._gradientStorageTex.type = mr, this._gradientStorageTex.format = Q, this._gradientStorageTex.minFilter = X, this._gradientStorageTex.magFilter = X, this._srcRegion = new ir(new Rr(0, 0), new Rr(0, 0)), this._demodulatedRT = new Cn(n, r, {
|
|
421
|
+
type: pr,
|
|
421
422
|
format: Q,
|
|
422
423
|
minFilter: X,
|
|
423
424
|
magFilter: X,
|
|
424
425
|
depthBuffer: !1,
|
|
425
426
|
stencilBuffer: !1
|
|
426
|
-
}), this._outputRT = new
|
|
427
|
-
type:
|
|
427
|
+
}), this._outputRT = new Cn(n, r, {
|
|
428
|
+
type: pr,
|
|
428
429
|
format: Q,
|
|
429
430
|
minFilter: X,
|
|
430
431
|
magFilter: X,
|
|
431
432
|
depthBuffer: !1,
|
|
432
433
|
stencilBuffer: !1
|
|
433
|
-
}), this._gradientRT = new
|
|
434
|
-
type:
|
|
434
|
+
}), this._gradientRT = new Cn(n, r, {
|
|
435
|
+
type: mr,
|
|
435
436
|
format: Q,
|
|
436
437
|
minFilter: X,
|
|
437
438
|
magFilter: X,
|
|
438
439
|
depthBuffer: !1,
|
|
439
440
|
stencilBuffer: !1
|
|
440
|
-
}), this.currentMoments = 0, this._compiled = !1, this._needsWarmReset = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildGradientCompute(), this._buildTemporalCompute(), this.showHeatmap = !1, this.debugMode =
|
|
441
|
-
type:
|
|
441
|
+
}), this.currentMoments = 0, this._compiled = !1, this._needsWarmReset = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildGradientCompute(), this._buildTemporalCompute(), this.showHeatmap = !1, this.debugMode = G(0, "int"), this._heatmapStorageTex = new wn(A, A), this._heatmapStorageTex.type = pr, this._heatmapStorageTex.format = Q, this._heatmapStorageTex.minFilter = Z, this._heatmapStorageTex.magFilter = Z, this.heatmapTarget = new Cn(n, r, {
|
|
442
|
+
type: pr,
|
|
442
443
|
format: Q,
|
|
443
444
|
minFilter: Z,
|
|
444
445
|
magFilter: Z,
|
|
445
446
|
depthBuffer: !1,
|
|
446
447
|
stencilBuffer: !1
|
|
447
|
-
}), this._heatmapRawColorTexNode = new
|
|
448
|
+
}), this._heatmapRawColorTexNode = new M(), this._heatmapColorTexNode = new M(), this._heatmapTemporalTexNode = new M(), this._heatmapNDTexNode = new M(), this._heatmapMotionTexNode = new M(), this._heatmapGradientTexNode = new M(), this._buildHeatmapCompute();
|
|
448
449
|
}
|
|
449
450
|
_buildGradientCompute() {
|
|
450
|
-
let e = this._colorTexNode, t = this._albedoTexNode, n = this._motionTexNode, r = this._readTemporalTexNode, i = this.gradientNoiseFloor, a = this.gradientSigmaScale, s = this._gradientStorageTex, c = this.resW, l = this.resH, u =
|
|
451
|
-
this._gradientNode =
|
|
452
|
-
let f =
|
|
453
|
-
let a = i.mod(
|
|
451
|
+
let e = this._colorTexNode, t = this._albedoTexNode, n = this._motionTexNode, r = this._readTemporalTexNode, i = this.gradientNoiseFloor, a = this.gradientSigmaScale, s = this._gradientStorageTex, c = this.resW, l = this.resH, u = $n("float", 144), d = $n("float", 144);
|
|
452
|
+
this._gradientNode = En(() => {
|
|
453
|
+
let f = L.x, p = L.y, m = p.mul(8).add(f), h = F(Y.x).mul(8).sub(2).toVar(), g = F(Y.y).mul(8).sub(2).toVar(), _ = (i) => {
|
|
454
|
+
let a = i.mod(W(12)), s = i.div(W(12)), f = h.add(F(a)).clamp(F(0), F(c).sub(1)), p = g.add(F(s)).clamp(F(0), F(l).sub(1)), m = H(e, I(f, p)).xyz, _ = H(t, I(f, p)).xyz, v = o(ii(m.div(R(_, q(Kr))))).toVar();
|
|
454
455
|
u.element(i).assign(v);
|
|
455
|
-
let y =
|
|
456
|
-
d.element(i).assign(
|
|
456
|
+
let y = H(n, I(f, p)), b = P(f).sub(y.x.mul(c)), x = P(p).sub(y.y.mul(l)), S = F(b.add(.5)).clamp(F(0), F(c).sub(1)), ee = F(x.add(.5)).clamp(F(0), F(l).sub(1)), C = y.w.greaterThan(.5), w = H(r, I(S, ee)).xyz, T = C.select(o(w), v);
|
|
457
|
+
d.element(i).assign(T);
|
|
457
458
|
};
|
|
458
459
|
_(m);
|
|
459
|
-
let v = m.add(
|
|
460
|
-
|
|
460
|
+
let v = m.add(W(64));
|
|
461
|
+
N(v.lessThan(W(144)), () => {
|
|
461
462
|
_(v);
|
|
462
463
|
});
|
|
463
|
-
let y = m.add(
|
|
464
|
-
|
|
464
|
+
let y = m.add(W(128));
|
|
465
|
+
N(y.lessThan(W(144)), () => {
|
|
465
466
|
_(y);
|
|
466
|
-
}),
|
|
467
|
-
let b =
|
|
468
|
-
|
|
469
|
-
let e =
|
|
467
|
+
}), er();
|
|
468
|
+
let b = F(Y.x).mul(8).add(F(f)), x = F(Y.y).mul(8).add(F(p));
|
|
469
|
+
N(b.lessThan(F(c)).and(x.lessThan(F(l))), () => {
|
|
470
|
+
let e = P(0).toVar(), t = P(0).toVar();
|
|
470
471
|
for (let n = -2; n <= 2; n++) for (let r = -2; r <= 2; r++) {
|
|
471
|
-
let i = p.add(
|
|
472
|
+
let i = p.add(W(2 + n)).mul(W(12)).add(f.add(W(2 + r))), a = u.element(i);
|
|
472
473
|
e.addAssign(a), t.addAssign(a.mul(a));
|
|
473
474
|
}
|
|
474
|
-
let o = e.div(25), m =
|
|
475
|
+
let o = e.div(25), m = qn(R(t.div(25).sub(o.mul(o)), P(0))).mul(a).toVar(), h = P(0).toVar();
|
|
475
476
|
for (let e = -2; e <= 2; e++) for (let t = -2; t <= 2; t++) {
|
|
476
|
-
let n = p.add(
|
|
477
|
+
let n = p.add(W(2 + e)).mul(W(12)).add(f.add(W(2 + t))), r = u.element(n), a = d.element(n), o = R(R(kn(r.sub(a)).sub(m), P(0)).div(R(R(r, a), P(.001))).sub(i), P(0)).div(R(P(1).sub(i), P(1e-4)));
|
|
477
478
|
h.addAssign(o.mul(o));
|
|
478
479
|
}
|
|
479
|
-
let g = h.div(25).clamp(0, 1).toVar(), _ =
|
|
480
|
-
|
|
480
|
+
let g = h.div(25).clamp(0, 1).toVar(), _ = H(n, I(b, x)), v = F(P(b).sub(_.x.mul(c)).add(.5)).clamp(F(0), F(c).sub(1)), y = F(P(x).sub(_.y.mul(l)).add(.5)).clamp(F(0), F(l).sub(1)), S = _.w.greaterThan(.5).select(H(r, I(v, y)).w, P(0)).div(4).clamp(0, 1), ee = g.mul(S);
|
|
481
|
+
U(s, Xn(W(b), W(x)), J(ee, g, m, 1)).toWriteOnly();
|
|
481
482
|
});
|
|
482
483
|
})().compute([
|
|
483
484
|
this._dispatchX,
|
|
@@ -494,23 +495,23 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
494
495
|
}
|
|
495
496
|
_buildTemporalForDirection(e) {
|
|
496
497
|
let t = this._colorTexNode, n = this._albedoTexNode, r = this._motionTexNode, i = this._normalDepthTexNode, a = this._prevNormalDepthTexNode, o = this._readTemporalTexNode, s = this._gradientReadTexNode, c = this._outputModulatedTex, l = this.maxAccumFrames, u = this.temporalAlpha, d = this.gradientStrength, f = this.temporalEnabledU, p = this.forceResetU, m = this.resW, h = this.resH;
|
|
497
|
-
return
|
|
498
|
-
let g =
|
|
499
|
-
|
|
500
|
-
let v =
|
|
501
|
-
|
|
502
|
-
let e =
|
|
503
|
-
|
|
504
|
-
let e =
|
|
505
|
-
let o =
|
|
498
|
+
return En(() => {
|
|
499
|
+
let g = F(Y.x).mul(8).add(F(L.x)), _ = F(Y.y).mul(8).add(F(L.y));
|
|
500
|
+
N(g.lessThan(F(m)).and(_.lessThan(F(h))), () => {
|
|
501
|
+
let v = I(g, _), y = H(t, v), b = y.xyz, x = y.w, S = H(n, v).xyz, ee = R(S, q(Kr)), C = ii(b.div(ee)), w = J(C, 1).toVar(), T = J(b, x).toVar();
|
|
502
|
+
N(f.greaterThan(.5).and(p.lessThan(.5)), () => {
|
|
503
|
+
let e = H(r, v), t = e.w.greaterThan(.5), n = P(g).sub(e.x.mul(m)), c = P(_).sub(e.y.mul(h)), f = n.greaterThanEqual(0).and(n.lessThan(P(m))).and(c.greaterThanEqual(0)).and(c.lessThan(P(h)));
|
|
504
|
+
N(t.and(f), () => {
|
|
505
|
+
let e = H(i, v), t = e.xyz.mul(2).sub(1), r = e.w, f = F(n), p = F(c), g = f.add(F(1)), _ = p.add(F(1)), y = n.sub(P(f)), b = c.sub(P(p)), S = f.clamp(F(0), F(m).sub(1)), E = g.clamp(F(0), F(m).sub(1)), te = p.clamp(F(0), F(h).sub(1)), D = _.clamp(F(0), F(h).sub(1)), ne = P(1).sub(y).mul(P(1).sub(b)), re = y.mul(P(1).sub(b)), ie = P(1).sub(y).mul(b), ae = y.mul(b), O = (e, n, i) => {
|
|
506
|
+
let o = H(a, I(e, n)), s = o.xyz.mul(2).sub(1), c = o.w, l = Wn(Fn(t, s).clamp(0, 1), P(16)), u = In(kn(r.sub(c)).div(R(r, P(.001))).div(P(.05)).negate());
|
|
506
507
|
return i.mul(l).mul(u);
|
|
507
|
-
},
|
|
508
|
-
|
|
509
|
-
let e =
|
|
510
|
-
|
|
508
|
+
}, k = O(S, te, ne), oe = O(E, te, re), se = O(S, D, ie), A = O(E, D, ae), ce = k.add(oe).add(se).add(A);
|
|
509
|
+
N(ce.greaterThan(P(.01)), () => {
|
|
510
|
+
let e = H(o, I(S, te)), t = H(o, I(E, te)), n = H(o, I(S, D)), r = H(o, I(E, D)), i = P(1).div(ce), a = e.xyz.mul(k).add(t.xyz.mul(oe)).add(n.xyz.mul(se)).add(r.xyz.mul(A)).mul(i), c = e.w.mul(k).add(t.w.mul(oe)).add(n.w.mul(se)).add(r.w.mul(A)).mul(i), f = H(s, v).x.mul(d).clamp(0, 1), p = ii(z(a, C, z(R(P(1).div(c.add(1)), u), P(1), f))), m = Hn(c.add(1), l);
|
|
511
|
+
w.assign(J(p, m)), T.assign(J(p.mul(ee), x));
|
|
511
512
|
});
|
|
512
513
|
});
|
|
513
|
-
}),
|
|
514
|
+
}), U(e, Xn(W(g), W(_)), w).toWriteOnly(), U(c, Xn(W(g), W(_)), T).toWriteOnly();
|
|
514
515
|
});
|
|
515
516
|
})().compute([
|
|
516
517
|
this._dispatchX,
|
|
@@ -524,35 +525,35 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
524
525
|
}
|
|
525
526
|
_buildHeatmapCompute() {
|
|
526
527
|
let e = this._heatmapRawColorTexNode, t = this._heatmapColorTexNode, n = this._heatmapTemporalTexNode, r = this._heatmapNDTexNode, i = this._heatmapMotionTexNode, a = this._heatmapGradientTexNode, s = this._heatmapStorageTex, c = this.debugMode, l = this.resW, u = this.resH;
|
|
527
|
-
this._heatmapComputeNode =
|
|
528
|
-
let d =
|
|
529
|
-
|
|
530
|
-
let p =
|
|
531
|
-
|
|
532
|
-
let e =
|
|
528
|
+
this._heatmapComputeNode = En(() => {
|
|
529
|
+
let d = F(Y.x).mul(8).add(F(L.x)), f = F(Y.y).mul(8).add(F(L.y));
|
|
530
|
+
N(d.lessThan(F(l)).and(f.lessThan(F(u))), () => {
|
|
531
|
+
let p = I(d, f), m = J(0, 0, 0, 1).toVar();
|
|
532
|
+
N(c.equal(F(0)), () => {
|
|
533
|
+
let e = H(t, p).xyz;
|
|
533
534
|
m.assign(J(e, 1));
|
|
534
|
-
}).ElseIf(c.equal(
|
|
535
|
-
let t =
|
|
535
|
+
}).ElseIf(c.equal(F(1)), () => {
|
|
536
|
+
let t = P(0).toVar(), n = P(0).toVar();
|
|
536
537
|
for (let r = -1; r <= 1; r++) for (let i = -1; i <= 1; i++) {
|
|
537
|
-
let a =
|
|
538
|
+
let a = H(e, I(d.add(i).clamp(F(0), F(l).sub(1)), f.add(r).clamp(F(0), F(u).sub(1)))).xyz, s = o(a);
|
|
538
539
|
t.addAssign(s), n.addAssign(s.mul(s));
|
|
539
540
|
}
|
|
540
541
|
t.divAssign(9), n.divAssign(9);
|
|
541
|
-
let r =
|
|
542
|
+
let r = R(n.sub(t.mul(t)), P(0)).div(R(t.mul(t), P(1e-4))).mul(10).clamp(0, 1), i = r.sub(.5).mul(4).clamp(0, 1), a = r.mul(4).clamp(0, 1).sub(r.sub(.75).mul(4).clamp(0, 1)), s = P(1).sub(r.sub(.25).mul(4).clamp(0, 1));
|
|
542
543
|
m.assign(J(i, a, s, 1));
|
|
543
|
-
}).ElseIf(c.equal(
|
|
544
|
-
let e =
|
|
545
|
-
m.assign(J(
|
|
546
|
-
}).ElseIf(c.equal(
|
|
547
|
-
let e =
|
|
544
|
+
}).ElseIf(c.equal(F(2)), () => {
|
|
545
|
+
let e = H(n, p).w.div(32).clamp(0, 1);
|
|
546
|
+
m.assign(J(P(1).sub(e), e, P(.2), 1));
|
|
547
|
+
}).ElseIf(c.equal(F(3)), () => {
|
|
548
|
+
let e = H(i, p), t = kn(e.x).mul(100).clamp(0, 1), n = kn(e.y).mul(100).clamp(0, 1), r = t.add(n).clamp(0, 1);
|
|
548
549
|
m.assign(J(t, n, r.mul(.3), 1));
|
|
549
|
-
}).ElseIf(c.equal(
|
|
550
|
-
let e =
|
|
550
|
+
}).ElseIf(c.equal(F(4)), () => {
|
|
551
|
+
let e = H(r, p);
|
|
551
552
|
m.assign(J(e.xyz, 1));
|
|
552
553
|
}).Else(() => {
|
|
553
|
-
let e =
|
|
554
|
-
m.assign(J(e, e.mul(.5),
|
|
555
|
-
}),
|
|
554
|
+
let e = H(a, p).x.mul(5).clamp(0, 1);
|
|
555
|
+
m.assign(J(e, e.mul(.5), P(1).sub(e), 1));
|
|
556
|
+
}), U(s, Xn(W(d), W(f)), m).toWriteOnly();
|
|
556
557
|
});
|
|
557
558
|
})().compute([
|
|
558
559
|
this._dispatchX,
|
|
@@ -593,10 +594,10 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
593
594
|
reallocateReservedStorage() {
|
|
594
595
|
this._gradientNode?.dispose(), this._temporalNodeA?.dispose(), this._temporalNodeB?.dispose(), this._heatmapComputeNode?.dispose(), this._temporalTexA?.dispose(), this._temporalTexB?.dispose(), this._outputModulatedTex?.dispose(), this._gradientStorageTex?.dispose(), this._heatmapStorageTex?.dispose();
|
|
595
596
|
let e = (e, t) => {
|
|
596
|
-
let n = new
|
|
597
|
+
let n = new wn(A, A);
|
|
597
598
|
return n.type = e, n.format = Q, n.minFilter = t, n.magFilter = t, n;
|
|
598
599
|
};
|
|
599
|
-
this._temporalTexA = e(
|
|
600
|
+
this._temporalTexA = e(pr, X), this._temporalTexB = e(pr, X), this._outputModulatedTex = e(pr, X), this._gradientStorageTex = e(mr, X), this._heatmapStorageTex = e(pr, Z), this._buildGradientCompute(), this._buildTemporalCompute(), this._buildHeatmapCompute(), this._compiled = !1, this.currentMoments = 0, this._needsWarmReset = !0;
|
|
600
601
|
}
|
|
601
602
|
setSize(e, t) {
|
|
602
603
|
this._demodulatedRT.setSize(e, t), this._demodulatedRT.texture.needsUpdate = !0, this._outputRT.setSize(e, t), this._outputRT.texture.needsUpdate = !0, this._gradientRT.setSize(e, t), this._gradientRT.texture.needsUpdate = !0, this.heatmapTarget.setSize(e, t), this.heatmapTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / 8), this._dispatchY = Math.ceil(t / 8), this._gradientNode.dispatchSize = [
|
|
@@ -624,7 +625,7 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
624
625
|
dispose() {
|
|
625
626
|
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();
|
|
626
627
|
}
|
|
627
|
-
},
|
|
628
|
+
}, oi = 1e-6, si = 1.5 / 255, ci = .01, li = 3, ui = 2, di = 2, fi = 3, pi = 2, mi = 38, hi = .1, gi = 4, _i = Math.cos(89 * Math.PI / 180), vi = .5, yi = 16, bi = {
|
|
628
629
|
pre: {
|
|
629
630
|
radiusScale: 1,
|
|
630
631
|
fractionScale: 2
|
|
@@ -637,7 +638,7 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
637
638
|
radiusScale: 2,
|
|
638
639
|
fractionScale: .5
|
|
639
640
|
}
|
|
640
|
-
},
|
|
641
|
+
}, xi = .25 * Math.SQRT2, Si = [
|
|
641
642
|
[
|
|
642
643
|
-1,
|
|
643
644
|
0,
|
|
@@ -659,62 +660,62 @@ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
|
|
|
659
660
|
1
|
|
660
661
|
],
|
|
661
662
|
[
|
|
662
|
-
-
|
|
663
|
-
|
|
663
|
+
-xi,
|
|
664
|
+
xi,
|
|
664
665
|
.5
|
|
665
666
|
],
|
|
666
667
|
[
|
|
667
|
-
|
|
668
|
-
|
|
668
|
+
xi,
|
|
669
|
+
xi,
|
|
669
670
|
.5
|
|
670
671
|
],
|
|
671
672
|
[
|
|
672
|
-
|
|
673
|
-
-
|
|
673
|
+
xi,
|
|
674
|
+
-xi,
|
|
674
675
|
.5
|
|
675
676
|
],
|
|
676
677
|
[
|
|
677
|
-
-
|
|
678
|
-
-
|
|
678
|
+
-xi,
|
|
679
|
+
-xi,
|
|
679
680
|
.5
|
|
680
681
|
]
|
|
681
|
-
],
|
|
682
|
-
let r = e.mul(t).add(n).abs().mul(-
|
|
683
|
-
return
|
|
684
|
-
},
|
|
685
|
-
let i =
|
|
686
|
-
return
|
|
687
|
-
},
|
|
688
|
-
let n =
|
|
689
|
-
return
|
|
690
|
-
},
|
|
691
|
-
let r =
|
|
692
|
-
return
|
|
693
|
-
},
|
|
694
|
-
let n =
|
|
695
|
-
return
|
|
696
|
-
},
|
|
697
|
-
let i =
|
|
698
|
-
return
|
|
699
|
-
},
|
|
682
|
+
], Ci = (e, t, n) => Kn(0, 1, P(1).sub(e.mul(t).add(n).abs())), wi = (e, t, n) => {
|
|
683
|
+
let r = e.mul(t).add(n).abs().mul(-li);
|
|
684
|
+
return P(1).div(r.mul(r).sub(r).add(1));
|
|
685
|
+
}, Ti = (e) => z(P(1.570796), P(1.395402), B(e)).mul(qn(B(P(1).sub(e)))), Ei = (e, t) => P(1).sub(Ln(e.mul(e).mul(-200))).mul(Wn(B(e), t)), Di = (e, t) => B(e).mul(qn(t.div(P(1).sub(t).add(oi)))), Oi = (e, t, n, r) => {
|
|
686
|
+
let i = R(An(Di(n, r.mul(z(B(t), P(1), e)))), P(si));
|
|
687
|
+
return P(1).div(i);
|
|
688
|
+
}, ki = (e, t) => {
|
|
689
|
+
let n = P(1).div(z(P(ci), P(1), B(e.mul(t))));
|
|
690
|
+
return K(n, e.mul(n).negate());
|
|
691
|
+
}, Ai = (e, t, n) => {
|
|
692
|
+
let r = P(1).div(z(P(n), P(1), z(e.mul(e), e, B(t))));
|
|
693
|
+
return K(r, e.mul(r).negate());
|
|
694
|
+
}, ji = (e, t) => {
|
|
695
|
+
let n = P(1).div(t);
|
|
696
|
+
return K(n, e.mul(n).negate());
|
|
697
|
+
}, Mi = (e, t, n, r) => {
|
|
698
|
+
let i = P(1).div(e.mul(t));
|
|
699
|
+
return K(i, Fn(r, n).mul(i).negate());
|
|
700
|
+
}, Ni = (e) => K(1).sub(K(1).sub(Bn(e.mul(.5)).mul(2)).abs()).min(.99999), Pi = (e) => q(Fn(e, q(.25, .5, .25)), Fn(e, q(.5, 0, -.5)), Fn(e, q(-.25, .5, -.25))), Fi = (e) => {
|
|
700
701
|
let t = e.x.sub(e.z);
|
|
701
|
-
return
|
|
702
|
-
},
|
|
703
|
-
function
|
|
702
|
+
return R(q(t.add(e.y), e.x.add(e.z), t.sub(e.y)), q(0));
|
|
703
|
+
}, Ii = (e, t) => t.add(oi).div(e.add(oi)), Li = (e, t) => J(e.xyz.mul(Ii(e.x, t)), e.w), Ri = (e) => J(Pi(Fi(e.xyz)), B(e.w)), zi = (e, t) => qn(t.sub(e.mul(e)).abs()), Bi = (e, t) => K(e.x.mul(t.x).add(e.y.mul(t.y)), e.z.mul(t.x).add(e.w.mul(t.y))), Vi = (e, t) => V(e.equal(0), J(0), t);
|
|
704
|
+
function Hi(e) {
|
|
704
705
|
let t = Math.imul(e | 0, 2654435761) >>> 0;
|
|
705
706
|
return t ^= t >>> 15, t = Math.imul(t, 2246822507) >>> 0, t ^= t >>> 13, t = Math.imul(t, 3266489909) >>> 0, t ^= t >>> 16, t / 4294967296;
|
|
706
707
|
}
|
|
707
|
-
var
|
|
708
|
+
var Ui = class extends O {
|
|
708
709
|
constructor(e, t = {}) {
|
|
709
710
|
super("NRD", {
|
|
710
711
|
...t,
|
|
711
712
|
executionMode: ge.PER_CYCLE
|
|
712
713
|
}), this.renderer = e, this.pathTracer = t.pathTracer || null, this.settings = {
|
|
713
|
-
...
|
|
714
|
+
...Xr,
|
|
714
715
|
...t.settings || {}
|
|
715
|
-
}, this._releaseHitDistance = this.pathTracer?.requestOutput?.("hitDistance", { encode: (e, t) => e.div(
|
|
716
|
+
}, this._releaseHitDistance = this.pathTracer?.requestOutput?.("hitDistance", { encode: (e, t) => e.div(R(t.mul(.1).add(3), P(1e-4))).clamp(0, 1) }) ?? null;
|
|
716
717
|
let n = t.width || 1, r = t.height || 1;
|
|
717
|
-
this.resW =
|
|
718
|
+
this.resW = G(n), this.resH = G(r), this.minRectDimMulUnproject = G(1), this.inputFrames = G(0), this.resetU = G(0), this.debugMode = G(0, "int"), this.rotPre = G(new zr(1, 0, 0, 1), "vec4"), this.rotBlur = G(new zr(1, 0, 0, 1), "vec4"), this.rotPost = G(new zr(1, 0, 0, 1), "vec4"), this.camWorld = G(new br(), "mat4"), this.camProjInv = G(new br(), "mat4"), this.camView = G(new br(), "mat4"), this.prevCamView = G(new br(), "mat4"), this.camPos = G(new $(), "vec3"), this.prevCamPos = G(new $(), "vec3"), this.viewVector = G(new $(), "vec3"), this.prevViewVector = G(new $(), "vec3"), this.cameraRay = oe(), this.u = {};
|
|
718
719
|
for (let e of [
|
|
719
720
|
"maxAccum",
|
|
720
721
|
"maxFast",
|
|
@@ -734,25 +735,25 @@ var Ri = class extends E {
|
|
|
734
735
|
"disocclusionThreshold",
|
|
735
736
|
"lobeVolumePercent",
|
|
736
737
|
"handoverFrames"
|
|
737
|
-
]) this.u[e] =
|
|
738
|
-
this.u.antilag =
|
|
738
|
+
]) this.u[e] = G(0);
|
|
739
|
+
this.u.antilag = G(new Rr(), "vec2"), this.u.convergence = G(new $(), "vec3"), this._syncUniforms(), this._colorTexNode = new M(), this._albedoTexNode = new M(), this._ndTexNode = new M(), this._snTexNode = new M(), this._motionTexNode = new M(), this._placeholders = /* @__PURE__ */ new Map();
|
|
739
740
|
let i = () => {
|
|
740
|
-
let e = new
|
|
741
|
+
let e = new dr(new Float32Array(4), 1, 1, Q, pr);
|
|
741
742
|
e.needsUpdate = !0;
|
|
742
|
-
let t = new
|
|
743
|
+
let t = new M(e);
|
|
743
744
|
return this._placeholders.set(t, e), t;
|
|
744
745
|
};
|
|
745
|
-
this._nTmpA = i(), this._nTmpB = i(), this._nHist = i(), this._nFast = i(), this._nInternal = i(), this._nGeom = i(), this._nData = i(), this._nStabRead = i(), this._allocStorage(), this._srcRegion = new
|
|
746
|
-
type:
|
|
746
|
+
this._nTmpA = i(), this._nTmpB = i(), this._nHist = i(), this._nFast = i(), this._nInternal = i(), this._nGeom = i(), this._nData = i(), this._nStabRead = i(), this._allocStorage(), this._srcRegion = new ir(new Rr(0, 0), new Rr(0, 0)), this.outputTarget = new Cn(n, r, {
|
|
747
|
+
type: mr,
|
|
747
748
|
format: Q,
|
|
748
749
|
minFilter: X,
|
|
749
750
|
magFilter: X,
|
|
750
751
|
depthBuffer: !1,
|
|
751
752
|
stencilBuffer: !1
|
|
752
|
-
}), this._compiled = !1, this._needsReset = !0, this._stabPing = 0, this._camInitialized = !1, this._dispatchX = Math.ceil(n /
|
|
753
|
+
}), this._compiled = !1, this._needsReset = !0, this._stabPing = 0, this._camInitialized = !1, this._dispatchX = Math.ceil(n / yi), this._dispatchY = Math.ceil(r / yi), this._buildKernels();
|
|
753
754
|
}
|
|
754
755
|
_allocStorage() {
|
|
755
|
-
let e = () =>
|
|
756
|
+
let e = () => D(mr);
|
|
756
757
|
this._tmpA = e(), this._tmpB = e(), this._hist = e(), this._fastHist = e(), this._internal = e(), this._geomPrev = e(), this._stabA = e(), this._stabB = e(), this._dataT = e();
|
|
757
758
|
}
|
|
758
759
|
_disposeStorage() {
|
|
@@ -773,7 +774,7 @@ var Ri = class extends E {
|
|
|
773
774
|
}
|
|
774
775
|
updateParameters(e) {
|
|
775
776
|
if (e) {
|
|
776
|
-
for (let t of Object.keys(e)) t === "debugMode" ? this.debugMode.value = e.debugMode | 0 : t in
|
|
777
|
+
for (let t of Object.keys(e)) t === "debugMode" ? this.debugMode.value = e.debugMode | 0 : t in Xr && (this.settings[t] = e[t]);
|
|
777
778
|
this._syncUniforms();
|
|
778
779
|
}
|
|
779
780
|
}
|
|
@@ -784,32 +785,32 @@ var Ri = class extends E {
|
|
|
784
785
|
t.fastClampSigmaScale.value = 3 + (e.fastHistoryClampingSigmaScale - 3) * a, t.fireflyMinRelativeScale.value = e.fireflySuppressorMinRelativeScale, t.antiFirefly.value = +!!e.enableAntiFirefly, t.antilag.value.set(e.antilagLuminanceSigmaScale, e.antilagLuminanceSensitivity), t.disocclusionThreshold.value = e.disocclusionThreshold, t.convergence.value.set(e.convergenceS, e.convergenceB, e.convergenceP), t.lobeVolumePercent.value = e.lobeVolumePercent, t.handoverFrames.value = e.handoverFrames > 0 ? e.handoverFrames : 2 * n;
|
|
785
786
|
}
|
|
786
787
|
_worldPosAt(e, t, n, r) {
|
|
787
|
-
return
|
|
788
|
+
return le(e, t, n, r, this.cameraRay);
|
|
788
789
|
}
|
|
789
790
|
_viewVector(e, t, n) {
|
|
790
|
-
return
|
|
791
|
+
return V(E(this.cameraRay.cameraProjection), n, Un(t.sub(e)));
|
|
791
792
|
}
|
|
792
793
|
_frustumSize(e) {
|
|
793
|
-
return this.minRectDimMulUnproject.mul(
|
|
794
|
+
return this.minRectDimMulUnproject.mul(V(E(this.cameraRay.cameraProjection), P(1), e));
|
|
794
795
|
}
|
|
795
796
|
_pixelUv(e, t) {
|
|
796
|
-
return
|
|
797
|
+
return K(P(e).add(.5).div(this.resW), P(t).add(.5).div(this.resH));
|
|
797
798
|
}
|
|
798
799
|
_clampCoord(e, t) {
|
|
799
|
-
return
|
|
800
|
+
return I(e.clamp(F(0), F(this.resW).sub(1)), t.clamp(F(0), F(this.resH).sub(1)));
|
|
800
801
|
}
|
|
801
802
|
_uvToCoord(e) {
|
|
802
|
-
return this._clampCoord(
|
|
803
|
+
return this._clampCoord(F(e.x.mul(this.resW)), F(e.y.mul(this.resH)));
|
|
803
804
|
}
|
|
804
805
|
_advancedNonLinear(e) {
|
|
805
|
-
let t = this.u.convergence, n =
|
|
806
|
-
return
|
|
806
|
+
let t = this.u.convergence, n = B(e.div(P(1).add(this.u.maxAccum.mul(t.z)))), r = t.x.mul(z(t.y, P(1), n));
|
|
807
|
+
return P(1).div(P(1).add(r.mul(e)));
|
|
807
808
|
}
|
|
808
809
|
_handover(e) {
|
|
809
|
-
return
|
|
810
|
+
return B(e.div(R(this.u.handoverFrames, 1)));
|
|
810
811
|
}
|
|
811
812
|
_bilinear(e) {
|
|
812
|
-
let t = e.mul(
|
|
813
|
+
let t = e.mul(K(this.resW, this.resH)).sub(.5), n = zn(t), r = B(t.sub(n)), i = F(n.x), a = F(n.y), o = (e, t) => V(e.greaterThanEqual(F(0)).and(t.greaterThanEqual(F(0))).and(e.lessThan(F(this.resW))).and(t.lessThan(F(this.resH))), P(1), P(0));
|
|
813
814
|
return {
|
|
814
815
|
f: r,
|
|
815
816
|
taps: [
|
|
@@ -825,22 +826,22 @@ var Ri = class extends E {
|
|
|
825
826
|
o(i.add(1), a.add(1))
|
|
826
827
|
],
|
|
827
828
|
customWeights: (e) => [
|
|
828
|
-
e[0].mul(
|
|
829
|
-
e[1].mul(r.x).mul(
|
|
830
|
-
e[2].mul(
|
|
829
|
+
e[0].mul(P(1).sub(r.x)).mul(P(1).sub(r.y)),
|
|
830
|
+
e[1].mul(r.x).mul(P(1).sub(r.y)),
|
|
831
|
+
e[2].mul(P(1).sub(r.x)).mul(r.y),
|
|
831
832
|
e[3].mul(r.x).mul(r.y)
|
|
832
833
|
],
|
|
833
|
-
filter: (e) =>
|
|
834
|
+
filter: (e) => z(z(e[0], e[1], r.x), z(e[2], e[3], r.x), r.y)
|
|
834
835
|
};
|
|
835
836
|
}
|
|
836
837
|
_applyCustomWeights(e, t, n) {
|
|
837
838
|
let r = e[0].mul(t[0]).add(e[1].mul(t[1])).add(e[2].mul(t[2])).add(e[3].mul(t[3])), i = t[0].add(t[1]).add(t[2]).add(t[3]);
|
|
838
|
-
return
|
|
839
|
+
return V(i.lessThan(1e-4), n, r.div(R(i, 1e-4)));
|
|
839
840
|
}
|
|
840
841
|
_sampleHistory(e, t, n, r, i) {
|
|
841
842
|
let a = J(0).toVar();
|
|
842
|
-
return
|
|
843
|
-
let n =
|
|
843
|
+
return N(i, () => {
|
|
844
|
+
let n = B(t).mul(K(this.resW, this.resH)), r = zn(n.sub(.5)).add(.5), i = B(n.sub(r)), o = vi, s = i.mul(i.mul(i.mul(-o).add(2 * o)).sub(o)), c = i.mul(i.mul(i.mul(2 - o).sub(3 - o))).add(1), l = i.mul(i.mul(i.mul(-(2 - o)).add(3 - 2 * o)).add(o)), u = i.mul(i.mul(i.mul(o).sub(o))), d = [
|
|
844
845
|
s.x,
|
|
845
846
|
c.x,
|
|
846
847
|
l.x,
|
|
@@ -850,13 +851,13 @@ var Ri = class extends E {
|
|
|
850
851
|
c.y,
|
|
851
852
|
l.y,
|
|
852
853
|
u.y
|
|
853
|
-
], p =
|
|
854
|
+
], p = F(r.x).sub(1), m = F(r.y).sub(1), h = J(0).toVar(), g = P(0).toVar();
|
|
854
855
|
for (let t = 0; t < 4; t++) for (let n = 0; n < 4; n++) {
|
|
855
856
|
if ((n === 0 || n === 3) && (t === 0 || t === 3)) continue;
|
|
856
857
|
let r = d[n].mul(f[t]);
|
|
857
858
|
h.addAssign(e(this._clampCoord(p.add(n), m.add(t))).mul(r)), g.addAssign(r);
|
|
858
859
|
}
|
|
859
|
-
a.assign(
|
|
860
|
+
a.assign(V(g.lessThan(1e-4), J(0), h.div(R(g, 1e-4))));
|
|
860
861
|
}).Else(() => {
|
|
861
862
|
a.assign(this._applyCustomWeights(n.taps.map((t) => e(t)), r, J(0)));
|
|
862
863
|
}), a;
|
|
@@ -878,176 +879,176 @@ var Ri = class extends E {
|
|
|
878
879
|
this._dispatchY,
|
|
879
880
|
1
|
|
880
881
|
], [
|
|
881
|
-
|
|
882
|
-
|
|
882
|
+
yi,
|
|
883
|
+
yi,
|
|
883
884
|
1
|
|
884
885
|
]);
|
|
885
886
|
}
|
|
886
887
|
_buildSpatial(e) {
|
|
887
|
-
let t = e === "pre", { radiusScale: i, fractionScale: a } =
|
|
888
|
-
let t =
|
|
889
|
-
return J(
|
|
890
|
-
} : (e) =>
|
|
891
|
-
let s =
|
|
892
|
-
|
|
893
|
-
let l =
|
|
894
|
-
|
|
888
|
+
let t = e === "pre", { radiusScale: i, fractionScale: a } = bi[e], o = this.u, s = this._colorTexNode, l = this._albedoTexNode, u = this._ndTexNode, d = this._snTexNode, f = this._nData, p = e === "blur" ? this._nTmpA : this._nTmpB, m = e === "blur" ? this._tmpB : t ? this._tmpA : this._hist, h = this._geomPrev, g = t ? this.rotPre : e === "blur" ? this.rotBlur : this.rotPost, _ = t ? o.prepassBlurRadius : o.maxBlurRadius, v = this.camView, y = this.camPos, b = this.resW, x = this.resH, S = this.inputFrames, ee = t ? (e) => {
|
|
889
|
+
let t = H(s, e), i = H(l, e);
|
|
890
|
+
return J(Pi(n(t.xyz.div(R(i.xyz, q(Kr))))), r(i.w, c).min(1));
|
|
891
|
+
} : (e) => H(p, e), C = En(([n, r]) => {
|
|
892
|
+
let s = F(Y.x).mul(yi).add(F(L.x)), c = F(Y.y).mul(yi).add(F(L.y));
|
|
893
|
+
N(s.lessThan(F(b)).and(c.lessThan(F(x))), () => {
|
|
894
|
+
let l = I(s, c), p = Xn(W(s), W(c)), C = H(u, l).w.toVar(), w = C.greaterThanEqual(Gr), T = H(d, l).toVar(), E = Un(T.xyz.mul(2).sub(1)).toVar(), te = T.w.clamp(.05, 1).toVar(), D = P(Gr).toVar(), ne = ee(l).toVar();
|
|
895
|
+
N(w.not(), () => {
|
|
895
896
|
let e = this._pixelUv(s, c), p = this._worldPosAt(e, C, n, r).toVar();
|
|
896
|
-
|
|
897
|
-
let s =
|
|
898
|
-
t || (
|
|
899
|
-
let
|
|
897
|
+
D.assign(v.mul(J(p, 1)).z.abs()), N(_.greaterThan(0), () => {
|
|
898
|
+
let s = Fn(E, this._viewVector(p, y, this.viewVector)).abs().toVar(), c = this._frustumSize(D).toVar(), m = S.add(1), h = t ? R(S, P(10)) : H(f, l).y.add(S), C = (t ? P(1).div(h.add(1)) : this._advancedNonLinear(h)).toVar(), w = Ei(te, .5).toVar(), T = D.mul(Yr).add(3), re = ne.w.toVar(), ie = B(re.mul(T).div(c)), ae = P(1).sub(this._handover(m)), O = (t ? ie.div(m) : ie.mul(C)).mul(ae), k = o.minBlurRadius.mul(B(P(2).sub(h.div(R(o.maxAccum, 1))))), oe = R(B(qn(B(O)).mul(i)).mul(_).mul(w), k.mul(w)).toVar(), se = Mi(o.planeDistSensitivity, c, p, E).toVar(), A = Oi(C, o.lobeAngleFraction, te, o.lobeVolumePercent).div(a).toVar(), ce = ki(te, o.roughnessFraction.mul(a)).toVar(), le = ji(re, C).toVar(), ue = o.minHitDistanceWeight.mul(a).mul(w);
|
|
899
|
+
t || (ue = ue.mul(C)), ue = ue.toVar();
|
|
900
|
+
let de = K(1);
|
|
900
901
|
if (!t) {
|
|
901
|
-
let e = v.mul(J(
|
|
902
|
-
|
|
902
|
+
let e = v.mul(J(E, 0)).xy;
|
|
903
|
+
de = z(K(1).sub(e.abs()), K(1), s), de = de.div(R(de.x, de.y));
|
|
903
904
|
}
|
|
904
|
-
let fe =
|
|
905
|
-
for (let t = 0; t <
|
|
906
|
-
let i =
|
|
907
|
-
s.mulAssign(
|
|
908
|
-
let h =
|
|
909
|
-
s.mulAssign(
|
|
905
|
+
let fe = de.mul(K(P(1).div(b), P(1).div(x))).mul(oe).toVar(), pe = P(1).toVar();
|
|
906
|
+
for (let t = 0; t < Si.length; t++) {
|
|
907
|
+
let i = Si[t], a = e.add(Bi(g, K(i[0], i[1])).mul(fe)), o = Ni(a), s = V(o.x.notEqual(a.x).or(o.y.notEqual(a.y)), P(1), P(Math.exp(-.66 * i[2] * i[2]))).toVar(), c = this._uvToCoord(o), l = H(u, c).w, f = this._worldPosAt(o, l, n, r), p = H(d, c), m = Ti(Fn(E, Un(p.xyz.mul(2).sub(1))));
|
|
908
|
+
s.mulAssign(Ci(m, A, P(0))), s.mulAssign(Ci(p.w, ce.x, ce.y)), s.mulAssign(Ci(Fn(E, f), se.x, se.y)), s.assign(V(l.greaterThanEqual(Gr), P(0), s));
|
|
909
|
+
let h = Vi(s, ee(c));
|
|
910
|
+
s.mulAssign(ue.add(wi(h.w, le.x, le.y))), pe.addAssign(s), ne.addAssign(h.mul(s));
|
|
910
911
|
}
|
|
911
|
-
|
|
912
|
+
ne.divAssign(R(pe, 1e-6)), t || ne.assign(J(ne.xyz, re));
|
|
912
913
|
});
|
|
913
|
-
}),
|
|
914
|
+
}), U(m, p, ne).toWriteOnly(), e === "post" && U(h, p, J(E, D)).toWriteOnly();
|
|
914
915
|
});
|
|
915
916
|
});
|
|
916
917
|
return this._dispatchOf(C);
|
|
917
918
|
}
|
|
918
919
|
_buildTemporalAccumulation() {
|
|
919
|
-
let e = this.u, t = this._ndTexNode, n = this._snTexNode, r = this._motionTexNode, i = this._nTmpA, a = this._nHist, o = this._nFast, s = this._nInternal, c = this._nGeom, l = this._tmpB, u = this._dataT, d = this.camView, f = this.prevCamView, p = this.camPos, m = this.prevCamPos, h = this.resW, g = this.resH, _ = this.inputFrames, v = this.resetU, y =
|
|
920
|
-
let x =
|
|
921
|
-
|
|
922
|
-
let h =
|
|
923
|
-
|
|
924
|
-
|
|
920
|
+
let e = this.u, t = this._ndTexNode, n = this._snTexNode, r = this._motionTexNode, i = this._nTmpA, a = this._nHist, o = this._nFast, s = this._nInternal, c = this._nGeom, l = this._tmpB, u = this._dataT, d = this.camView, f = this.prevCamView, p = this.camPos, m = this.prevCamPos, h = this.resW, g = this.resH, _ = this.inputFrames, v = this.resetU, y = En(([y, b]) => {
|
|
921
|
+
let x = F(Y.x).mul(yi).add(F(L.x)), S = F(Y.y).mul(yi).add(F(L.y));
|
|
922
|
+
N(x.lessThan(F(h)).and(S.lessThan(F(g))), () => {
|
|
923
|
+
let h = I(x, S), g = Xn(W(x), W(S)), ee = H(t, h).w, C = H(i, h).toVar();
|
|
924
|
+
N(ee.greaterThanEqual(Gr), () => {
|
|
925
|
+
U(l, g, C).toWriteOnly(), U(u, g, J(0)).toWriteOnly(), On();
|
|
925
926
|
});
|
|
926
|
-
let
|
|
927
|
-
|
|
927
|
+
let w = e.maxAccum.mul(P(1).sub(v)).toVar(), T = e.maxFast.mul(P(1).sub(v)).toVar(), E = H(n, h), te = Un(E.xyz.mul(2).sub(1)).toVar(), D = E.w.clamp(.05, 1).toVar(), ne = this._pixelUv(x, S), re = this._worldPosAt(ne, ee, y, b).toVar(), ie = d.mul(J(re, 1)).z.abs().toVar(), ae = Fn(te, this._viewVector(re, p, this.viewVector)).abs().toVar(), O = this._frustumSize(ie).toVar(), k = q(0).toVar();
|
|
928
|
+
k.addAssign(te.mul(.25));
|
|
928
929
|
for (let e = -1; e <= 0; e++) for (let r = -1; r <= 0; r++) {
|
|
929
930
|
if (r === 0 && e === 0) continue;
|
|
930
|
-
let i = this._clampCoord(x.add(r), S.add(e)), a =
|
|
931
|
-
|
|
931
|
+
let i = this._clampCoord(x.add(r), S.add(e)), a = Un(H(n, i).xyz.mul(2).sub(1)), o = H(t, i).w.lessThan(Gr);
|
|
932
|
+
k.addAssign(V(o, a, te).mul(.25));
|
|
932
933
|
}
|
|
933
|
-
let
|
|
934
|
+
let oe = H(r, h), se = ne.sub(oe.xy).toVar(), A = f.mul(J(re, 1)).z.abs().toVar(), ce = this._bilinear(se), le = O.mul(B(e.disocclusionThreshold.div(R(ae, .05)))).sub(oi).toVar(), ue = P(1).sub(v), de = [], fe = [];
|
|
934
935
|
for (let e = 0; e < 4; e++) {
|
|
935
|
-
let t =
|
|
936
|
-
|
|
936
|
+
let t = H(c, ce.taps[e]), n = V(Fn(t.xyz, k).greaterThan(_i), P(1), P(0)), r = V(t.w.sub(A).abs().lessThanEqual(le), P(1), P(0)), i = V(t.w.lessThan(Gr), P(1), P(0));
|
|
937
|
+
de.push(n.mul(r).mul(i).mul(ce.inScreen[e]).mul(ue).toVar()), fe.push(H(s, ce.taps[e]).x);
|
|
937
938
|
}
|
|
938
|
-
let pe =
|
|
939
|
-
_e.assign(
|
|
940
|
-
let ve =
|
|
941
|
-
ge.assign(ge.mul(
|
|
942
|
-
let ye =
|
|
943
|
-
De.assign(De.div(De.add(1)).mul(
|
|
944
|
-
let Oe =
|
|
945
|
-
Te.assign(
|
|
946
|
-
let ke =
|
|
947
|
-
Te.assign(J(Te.xyz,
|
|
948
|
-
let Ae =
|
|
949
|
-
Me.assign(
|
|
939
|
+
let pe = ce.customWeights(de).map((e) => e.toVar()), me = de[0].add(de[1]).add(de[2]).add(de[3]).greaterThan(3.5).toVar(), he = de[0].add(de[1].mul(2)).add(de[2].mul(4)).add(de[3].mul(8)), ge = this._applyCustomWeights(fe, pe, P(0)).toVar(), _e = Fn(te, this._viewVector(re, m, this.prevViewVector)).abs().add(.001).div(ae.add(.001)).toVar();
|
|
940
|
+
_e.assign(z(P(.1), P(1), B(_e.mul(_e))));
|
|
941
|
+
let ve = qn(B(ce.filter(de))).mul(_e).toVar();
|
|
942
|
+
ge.assign(ge.mul(z(ve, P(1), P(1).div(ge.add(1))))), ge.assign(Hn(ge, w));
|
|
943
|
+
let ye = Ri(this._sampleHistory((e) => H(a, e), se, ce, pe, me)).toVar(), be = R(this._applyCustomWeights(ce.taps.map((e) => H(o, e).x), pe, P(0)), 0).toVar(), xe = _.add(1), Se = this._handover(xe).toVar(), Ce = ge.mul(P(1).sub(Se)), we = xe.div(xe.add(Ce)).toVar(), j = P(1).div(P(1).add(Ei(D, .25).mul(.5).mul(w))), Te = J(z(ye.xyz, C.xyz, we), z(ye.w, C.w, R(we, j))).toVar(), Ee = e.fireflyMinRelativeScale.add(P(mi).div(ge.add(1))).toVar(), De = ge.mul(e.maxBlurRadius).mul(hi).toVar();
|
|
944
|
+
De.assign(De.div(De.add(1)).mul(P(1).sub(Se)));
|
|
945
|
+
let Oe = z(Te.x, Hn(Te.x, ye.x.mul(Ee)), De);
|
|
946
|
+
Te.assign(Li(Te, Oe));
|
|
947
|
+
let ke = P(1.2).add(P(1).div(ge.add(1)));
|
|
948
|
+
Te.assign(J(Te.xyz, z(Te.w, Hn(Te.w, ye.w.mul(ke)), De))), U(l, g, Te).toWriteOnly();
|
|
949
|
+
let Ae = Hn(ge, T).mul(P(1).sub(Se)), je = xe.div(xe.add(Ae)), Me = z(be, C.x, je).toVar(), Ne = Hn(Me, ye.x.mul(Ee).mul(gi));
|
|
950
|
+
Me.assign(z(Me, Ne, De)), U(u, g, J(Me, ge, he, V(me, P(1), P(0)))).toWriteOnly();
|
|
950
951
|
});
|
|
951
952
|
});
|
|
952
953
|
return this._dispatchOf(y);
|
|
953
954
|
}
|
|
954
955
|
_buildHistoryFix() {
|
|
955
|
-
let e = this.u, t = this._ndTexNode, n = this._snTexNode, r = this._nTmpB, i = this._nData, a = this._tmpA, o = this._fastHist, s = this.camView, c = this.resW, l = this.resH, u = this.inputFrames, d =
|
|
956
|
-
let p =
|
|
957
|
-
|
|
958
|
-
let h =
|
|
959
|
-
|
|
960
|
-
let e =
|
|
961
|
-
|
|
956
|
+
let e = this.u, t = this._ndTexNode, n = this._snTexNode, r = this._nTmpB, i = this._nData, a = this._tmpA, o = this._fastHist, s = this.camView, c = this.resW, l = this.resH, u = this.inputFrames, d = En(([d, f]) => {
|
|
957
|
+
let p = F(Y.x).mul(yi).add(F(L.x)), m = F(Y.y).mul(yi).add(F(L.y));
|
|
958
|
+
N(p.lessThan(F(c)).and(m.lessThan(F(l))), () => {
|
|
959
|
+
let h = I(p, m), g = Xn(W(p), W(m)), _ = H(t, h).w;
|
|
960
|
+
N(_.greaterThanEqual(Gr), () => {
|
|
961
|
+
let e = H(r, h);
|
|
962
|
+
U(a, g, e).toWriteOnly(), U(o, g, J(e.x, 0, 0, 0)).toWriteOnly(), On();
|
|
962
963
|
});
|
|
963
|
-
let v =
|
|
964
|
-
|
|
965
|
-
let a =
|
|
966
|
-
|
|
967
|
-
for (let e = -
|
|
968
|
-
if (m === 0 && e === 0 || Math.abs(m) + Math.abs(e) ===
|
|
969
|
-
let h =
|
|
970
|
-
b.mulAssign(
|
|
971
|
-
let x =
|
|
972
|
-
b.mulAssign(
|
|
964
|
+
let v = H(i, h).toVar(), y = v.y.toVar(), b = y.add(u), x = this._handover(u.add(1)).toVar(), S = H(n, h), ee = Un(S.xyz.mul(2).sub(1)).toVar(), C = S.w.clamp(.05, 1).toVar(), w = this._pixelUv(p, m), T = this._worldPosAt(w, _, d, f).toVar(), E = s.mul(J(T, 1)).z.abs(), te = this._frustumSize(E).toVar(), D = H(r, h).toVar(), ne = P(1).div(b.add(1)).toVar(), re = E.mul(Yr).add(3), ie = B(D.w.mul(re).div(te)), ae = D.w.toVar(), O = Gn(V(b.lessThan(e.historyFixFrameNum), P(1), P(0)).mul(.5).mul(2 / ui).mul(e.historyFixStride).mul(z(P(.25).add(qn(ie).mul(.75)), P(1), ne))).toVar();
|
|
965
|
+
N(O.notEqual(0), () => {
|
|
966
|
+
let a = Oi(ne, e.lobeAngleFraction, C, e.lobeVolumePercent).toVar(), o = Mi(e.planeDistSensitivity, te, T, ee).toVar(), s = ji(ae, ne).toVar(), u = Ai(C.mul(C), qn(e.roughnessFraction), ci).toVar(), p = P(1).add(y).toVar();
|
|
967
|
+
D.mulAssign(p);
|
|
968
|
+
for (let e = -ui; e <= ui; e++) for (let m = -ui; m <= ui; m++) {
|
|
969
|
+
if (m === 0 && e === 0 || Math.abs(m) + Math.abs(e) === ui * 2) continue;
|
|
970
|
+
let h = Ni(w.add(K(m, e).mul(O).mul(K(P(1).div(c), P(1).div(l))))), g = this._uvToCoord(h), _ = H(t, g).w, v = this._worldPosAt(h, _, d, f), y = H(n, g), b = wi(Ti(Fn(Un(y.xyz.mul(2).sub(1)), ee)), a, P(0)).toVar();
|
|
971
|
+
b.mulAssign(wi(y.w.mul(y.w), u.x, u.y)), b.mulAssign(P(1).add(H(i, g).y)), b.mulAssign(Ci(Fn(ee, v), o.x, o.y)), b.assign(V(_.greaterThanEqual(Gr), P(0), b));
|
|
972
|
+
let x = Vi(b, H(r, g));
|
|
973
|
+
b.mulAssign(wi(x.w, s.x, s.y)), p.addAssign(b), D.addAssign(x.mul(b));
|
|
973
974
|
}
|
|
974
|
-
|
|
975
|
+
D.divAssign(R(p, 1e-6));
|
|
975
976
|
});
|
|
976
|
-
let
|
|
977
|
-
|
|
978
|
-
let
|
|
979
|
-
let a = this._clampCoord(p.add(e), m.add(n)), o =
|
|
980
|
-
Math.abs(e) <=
|
|
977
|
+
let k = D.x.toVar(), oe = B(y.div(R(e.historyFixFrameNum, oi))), se = z(k, v.x, oe).toVar();
|
|
978
|
+
U(o, g, J(se, 0, 0, 0)).toWriteOnly();
|
|
979
|
+
let A = se.toVar(), ce = se.mul(se).toVar(), le = P(0).toVar(), ue = P(0).toVar(), de = (e, n, r) => {
|
|
980
|
+
let a = this._clampCoord(p.add(e), m.add(n)), o = H(t, a).w, s = V(o.greaterThanEqual(Gr), se, H(i, a).x);
|
|
981
|
+
Math.abs(e) <= di && Math.abs(n) <= di && (A.addAssign(s), ce.addAssign(s.mul(s))), r && (le.addAssign(s), ue.addAssign(s.mul(s)));
|
|
981
982
|
}, fe = e.antiFirefly.greaterThan(.5);
|
|
982
|
-
for (let e = -
|
|
983
|
-
|
|
984
|
-
for (let e = -
|
|
985
|
-
}),
|
|
986
|
-
let e = 1 / ((
|
|
987
|
-
|
|
983
|
+
for (let e = -di; e <= di; e++) for (let t = -di; t <= di; t++) t === 0 && e === 0 || de(t, e, Math.abs(t) > 1 || Math.abs(e) > 1);
|
|
984
|
+
N(fe, () => {
|
|
985
|
+
for (let e = -fi; e <= fi; e++) for (let t = -fi; t <= fi; t++) Math.abs(t) <= di && Math.abs(e) <= di || de(t, e, !0);
|
|
986
|
+
}), N(fe, () => {
|
|
987
|
+
let e = 1 / ((fi * 2 + 1) ** 2 - 9), t = le.mul(e), n = zi(t, ue.mul(e)).mul(pi);
|
|
988
|
+
k.assign(z(k.clamp(t.sub(n), t.add(n)), k, x));
|
|
988
989
|
});
|
|
989
990
|
{
|
|
990
|
-
let t = 1 / (
|
|
991
|
-
|
|
991
|
+
let t = 1 / (di * 2 + 1) ** 2, n = A.mul(t), r = zi(n, ce.mul(t)).mul(e.fastClampSigmaScale), i = k.clamp(n.sub(r), n.add(r)), a = V(e.maxFast.lessThan(e.maxAccum), P(1), P(0)), o = z(P(1).div(P(1).add(a.mul(y).mul(2))), P(1), x);
|
|
992
|
+
k.assign(z(i, k, o));
|
|
992
993
|
}
|
|
993
|
-
|
|
994
|
+
U(a, g, Li(D, k)).toWriteOnly();
|
|
994
995
|
});
|
|
995
996
|
});
|
|
996
997
|
return this._dispatchOf(d);
|
|
997
998
|
}
|
|
998
999
|
_buildTemporalStabilization(e) {
|
|
999
1000
|
let t = this.u, n = this._colorTexNode, r = this._albedoTexNode, i = this._ndTexNode, a = this._snTexNode, o = this._motionTexNode, s = this._nHist, c = this._nData, l = this._nStabRead, u = this._internal, d = this._tmpA, f = this.resW, p = this.resH, m = this.inputFrames, h = this.resetU, g = this.debugMode;
|
|
1000
|
-
return
|
|
1001
|
-
let _ =
|
|
1002
|
-
|
|
1003
|
-
let f =
|
|
1004
|
-
|
|
1005
|
-
|
|
1001
|
+
return En(() => {
|
|
1002
|
+
let _ = F(Y.x).mul(yi).add(F(L.x)), v = F(Y.y).mul(yi).add(F(L.y));
|
|
1003
|
+
N(_.lessThan(F(f)).and(v.lessThan(F(p))), () => {
|
|
1004
|
+
let f = I(_, v), p = Xn(W(_), W(v)), y = H(i, f).w, b = H(n, f).toVar();
|
|
1005
|
+
N(y.greaterThanEqual(Gr), () => {
|
|
1006
|
+
U(d, p, b).toWriteOnly(), U(e, p, J(H(s, f).x, 0, 0, 0)).toWriteOnly(), U(u, p, J(0, 1, 0, 0)).toWriteOnly(), On();
|
|
1006
1007
|
});
|
|
1007
|
-
let x =
|
|
1008
|
+
let x = H(a, f).w.clamp(.05, 1), S = this._pixelUv(_, v), ee = H(o, f), C = S.sub(ee.xy).toVar(), w = H(c, f).toVar(), T = w.y.toVar(), E = W(w.z.add(.5)).toVar(), te = w.w.greaterThan(.5), D = this._bilinear(C), ne = [
|
|
1008
1009
|
1,
|
|
1009
1010
|
2,
|
|
1010
1011
|
4,
|
|
1011
1012
|
8
|
|
1012
|
-
].map((e) =>
|
|
1013
|
+
].map((e) => V(E.bitAnd(W(e)).notEqual(W(0)), P(1), P(0))), re = D.customWeights(ne).map((e) => e.toVar()), ie = qn(B(D.filter(ne))).toVar(), ae = H(s, f).toVar(), O = ae.x.toVar(), k = O.toVar(), oe = O.mul(O).toVar();
|
|
1013
1014
|
for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
|
|
1014
1015
|
if (t === 0 && e === 0) continue;
|
|
1015
|
-
let n = this._clampCoord(_.add(t), v.add(e)), r =
|
|
1016
|
-
|
|
1016
|
+
let n = this._clampCoord(_.add(t), v.add(e)), r = H(i, n).w, a = V(r.greaterThanEqual(Gr), O, H(s, n).x);
|
|
1017
|
+
k.addAssign(a), oe.addAssign(a.mul(a));
|
|
1017
1018
|
}
|
|
1018
|
-
|
|
1019
|
-
let
|
|
1020
|
-
|
|
1021
|
-
|
|
1019
|
+
k.divAssign(9), oe.divAssign(9);
|
|
1020
|
+
let se = zi(k, oe).toVar();
|
|
1021
|
+
N(T.lessThan(t.historyFixFrameNum), () => {
|
|
1022
|
+
O.assign(Hn(O, k.mul(P(1.2).add(P(1).div(T.add(1))))));
|
|
1022
1023
|
});
|
|
1023
|
-
let
|
|
1024
|
-
|
|
1025
|
-
let me = m.add(1), he = this._handover(me), ge =
|
|
1026
|
-
|
|
1027
|
-
let be = t.maxAccum.mul(
|
|
1028
|
-
|
|
1029
|
-
let xe =
|
|
1030
|
-
|
|
1031
|
-
let e =
|
|
1032
|
-
Se.assign(J(
|
|
1033
|
-
}).ElseIf(g.equal(
|
|
1034
|
-
Se.assign(J(q(
|
|
1035
|
-
}).ElseIf(g.equal(
|
|
1024
|
+
let A = R(this._sampleHistory((e) => H(l, e), C, D, re, te).x, 0).toVar(), ce = se.mul(t.antilag.x), le = t.antilag.y.mul(4), ue = A.clamp(k.sub(ce), k.add(ce)), de = A.sub(ue).abs().div(R(A, ue).add(oi)), fe = P(1).div(P(1).add(de.mul(T.mul(ie)).div(le))).toVar(), pe = Hn(T, t.historyFixFrameNum);
|
|
1025
|
+
T.assign(z(pe, T, fe));
|
|
1026
|
+
let me = m.add(1), he = this._handover(me), ge = ie.mul(P(1).sub(this._advancedNonLinear(T.mul(P(1).sub(he)).div(me)))).mul(fe).toVar(), _e = P(1).add(ge.mul(6)), ve = t.stabilizationStrength.mul(P(1).sub(h)), ye = z(O, A.clamp(k.sub(se.mul(_e)), k.add(se.mul(_e))), Hn(ge, ve)).toVar();
|
|
1027
|
+
ae.assign(Li(ae, ye)), U(e, p, J(ye, 0, 0, 0)).toWriteOnly();
|
|
1028
|
+
let be = t.maxAccum.mul(P(1).sub(h));
|
|
1029
|
+
U(u, p, J(Hn(T.add(1), be), x, 0, 0)).toWriteOnly();
|
|
1030
|
+
let xe = H(r, f), Se = J(Fi(ae.xyz).mul(R(xe.xyz, q(Kr))), b.w).toVar();
|
|
1031
|
+
N(g.equal(F(1)), () => {
|
|
1032
|
+
let e = B(T.div(R(t.maxAccum, 1)));
|
|
1033
|
+
Se.assign(J(P(1).sub(e), e, .2, 1));
|
|
1034
|
+
}).ElseIf(g.equal(F(2)), () => {
|
|
1035
|
+
Se.assign(J(q(ae.w), 1));
|
|
1036
|
+
}).ElseIf(g.equal(F(3)), () => {
|
|
1036
1037
|
Se.assign(J(q(x), 1));
|
|
1037
|
-
}).ElseIf(g.equal(
|
|
1038
|
-
let e =
|
|
1038
|
+
}).ElseIf(g.equal(F(4)), () => {
|
|
1039
|
+
let e = w.x.div(w.x.add(1));
|
|
1039
1040
|
Se.assign(J(q(e), 1));
|
|
1040
|
-
}).ElseIf(g.equal(
|
|
1041
|
-
Se.assign(J(q(
|
|
1042
|
-
}),
|
|
1041
|
+
}).ElseIf(g.equal(F(5)), () => {
|
|
1042
|
+
Se.assign(J(q(w.z.div(15)), 1));
|
|
1043
|
+
}), U(d, p, Se).toWriteOnly();
|
|
1043
1044
|
});
|
|
1044
1045
|
})().compute([
|
|
1045
1046
|
this._dispatchX,
|
|
1046
1047
|
this._dispatchY,
|
|
1047
1048
|
1
|
|
1048
1049
|
], [
|
|
1049
|
-
|
|
1050
|
-
|
|
1050
|
+
yi,
|
|
1051
|
+
yi,
|
|
1051
1052
|
1
|
|
1052
1053
|
]);
|
|
1053
1054
|
}
|
|
@@ -1067,7 +1068,7 @@ var Ri = class extends E {
|
|
|
1067
1068
|
}
|
|
1068
1069
|
_updateRotators(e) {
|
|
1069
1070
|
let t = (t, n) => {
|
|
1070
|
-
let r =
|
|
1071
|
+
let r = Hi(e * 3 + n) * Math.PI * 2;
|
|
1071
1072
|
t.value.set(Math.cos(r), Math.sin(r), -Math.sin(r), Math.cos(r));
|
|
1072
1073
|
};
|
|
1073
1074
|
t(this.rotPre, 0), t(this.rotBlur, 1), t(this.rotPost, 2);
|
|
@@ -1094,7 +1095,7 @@ var Ri = class extends E {
|
|
|
1094
1095
|
this._nTmpA.value = this._tmpA, this._nTmpB.value = this._tmpB, this._nHist.value = this._hist, this._nFast.value = this._fastHist, this._nInternal.value = this._internal, this._nGeom.value = this._geomPrev, this._nData.value = this._dataT, this._nStabRead.value = this._stabPing === 0 ? this._stabB : this._stabA, this.renderer.compute(this._kPre), this.renderer.compute(this._kTa), this.renderer.compute(this._kHf), this.renderer.compute(this._kBlur), this.renderer.compute(this._kPost), this.renderer.compute(this._stabPing === 0 ? this._kTsA : this._kTsB), this._srcRegion.max.set(this.outputTarget.width, this.outputTarget.height), this.renderer.copyTextureToTexture(this._tmpA, this.outputTarget.texture, this._srcRegion), e.setTexture("nrd:output", this.outputTarget.texture), this._stabPing = 1 - this._stabPing, this._needsReset = !1, this._needsReset = !1;
|
|
1095
1096
|
}
|
|
1096
1097
|
setSize(e, t) {
|
|
1097
|
-
this.outputTarget.setSize(e, t), this.outputTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e /
|
|
1098
|
+
this.outputTarget.setSize(e, t), this.outputTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / yi), this._dispatchY = Math.ceil(t / yi);
|
|
1098
1099
|
let n = [
|
|
1099
1100
|
this._dispatchX,
|
|
1100
1101
|
this._dispatchY,
|
|
@@ -1123,15 +1124,15 @@ var Ri = class extends E {
|
|
|
1123
1124
|
for (let [e, t] of this._placeholders) e.dispose(), t.dispose();
|
|
1124
1125
|
this._placeholders.clear();
|
|
1125
1126
|
}
|
|
1126
|
-
},
|
|
1127
|
+
}, Wi = (e) => V(e.equal(e), e, P(0)).clamp(0, 1e7), Gi = /* @__PURE__ */ Qn("\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"), Ki = class extends O {
|
|
1127
1128
|
constructor(e, t = {}) {
|
|
1128
1129
|
super("VarianceEstimation", {
|
|
1129
1130
|
...t,
|
|
1130
1131
|
executionMode: ge.ALWAYS
|
|
1131
|
-
}), this.renderer = e, this.inputTextureName = t.inputTextureName || "pathtracer:color", this.varianceBoost =
|
|
1132
|
+
}), this.renderer = e, this.inputTextureName = t.inputTextureName || "pathtracer:color", this.varianceBoost = G(t.varianceBoost ?? 1), this.temporalAlpha = G(t.temporalAlpha ?? .1), this.resW = G(t.width || 1), this.resH = G(t.height || 1), this._colorTexNode = new M();
|
|
1132
1133
|
let n = t.width || 1, r = t.height || 1;
|
|
1133
|
-
this._storageTexA = new
|
|
1134
|
-
type:
|
|
1134
|
+
this._storageTexA = new wn(A, A), this._storageTexA.type = pr, this._storageTexA.format = Q, this._storageTexA.minFilter = X, this._storageTexA.magFilter = X, this._storageTexB = new wn(A, A), this._storageTexB.type = pr, this._storageTexB.format = Q, this._storageTexB.minFilter = X, this._storageTexB.magFilter = X, this._srcRegion = new ir(new Rr(0, 0), new Rr(0, 0)), this._outputTarget = new Cn(n, r, {
|
|
1135
|
+
type: pr,
|
|
1135
1136
|
format: Q,
|
|
1136
1137
|
minFilter: X,
|
|
1137
1138
|
magFilter: X,
|
|
@@ -1143,26 +1144,26 @@ var Ri = class extends E {
|
|
|
1143
1144
|
this.on("pathtracer:viewpointChanged", () => this.reset());
|
|
1144
1145
|
}
|
|
1145
1146
|
_buildCompute() {
|
|
1146
|
-
this._readTexNodeA = new
|
|
1147
|
+
this._readTexNodeA = new M(), this._readTexNodeB = new M(), this._computeNodeA = this._buildComputeForDirection(this._storageTexA, this._readTexNodeB), this._computeNodeB = this._buildComputeForDirection(this._storageTexB, this._readTexNodeA);
|
|
1147
1148
|
}
|
|
1148
1149
|
_buildComputeForDirection(e, t) {
|
|
1149
|
-
let n = this._colorTexNode, r = this.temporalAlpha, i = this.varianceBoost, a = this.resW, s = this.resH, c =
|
|
1150
|
-
return
|
|
1151
|
-
let l =
|
|
1152
|
-
c.element(d).assign(
|
|
1153
|
-
let e = d.add(
|
|
1154
|
-
c.element(e).assign(
|
|
1155
|
-
}),
|
|
1156
|
-
let _ =
|
|
1157
|
-
|
|
1158
|
-
let n =
|
|
1150
|
+
let n = this._colorTexNode, r = this.temporalAlpha, i = this.varianceBoost, a = this.resW, s = this.resH, c = $n("float", 100);
|
|
1151
|
+
return En(() => {
|
|
1152
|
+
let l = L.x, u = L.y, d = u.mul(8).add(l), f = F(Y.x).mul(8).sub(1), p = F(Y.y).mul(8).sub(1), m = d.mod(10), h = d.div(10), g = H(n, I(f.add(F(m)).clamp(F(0), F(a).sub(1)), p.add(F(h)).clamp(F(0), F(s).sub(1)))).xyz;
|
|
1153
|
+
c.element(d).assign(Wi(o(g))), N(d.lessThan(W(36)), () => {
|
|
1154
|
+
let e = d.add(W(64)), t = e.mod(10), r = e.div(10), i = H(n, I(f.add(F(t)).clamp(F(0), F(a).sub(1)), p.add(F(r)).clamp(F(0), F(s).sub(1)))).xyz;
|
|
1155
|
+
c.element(e).assign(Wi(o(i)));
|
|
1156
|
+
}), er();
|
|
1157
|
+
let _ = F(Y.x).mul(8).add(F(l)), v = F(Y.y).mul(8).add(F(u));
|
|
1158
|
+
N(_.lessThan(F(a)).and(v.lessThan(F(s))), () => {
|
|
1159
|
+
let n = P(0).toVar(), a = P(0).toVar();
|
|
1159
1160
|
for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
|
|
1160
1161
|
let r = c.element(u.add(1 + e).mul(10).add(l.add(1 + t)));
|
|
1161
1162
|
n.addAssign(r), a.addAssign(r.mul(r));
|
|
1162
1163
|
}
|
|
1163
1164
|
n.divAssign(9), a.divAssign(9);
|
|
1164
|
-
let o =
|
|
1165
|
-
|
|
1165
|
+
let o = R(a.sub(n.mul(n)), P(0)), s = c.element(u.add(1).mul(10).add(l.add(1))), d = H(t, I(_, v));
|
|
1166
|
+
U(e, Xn(W(_), W(v)), Gi(s, d.x, d.y, r, o, i)).toWriteOnly();
|
|
1166
1167
|
});
|
|
1167
1168
|
})().compute([
|
|
1168
1169
|
this._dispatchX,
|
|
@@ -1208,23 +1209,23 @@ var Ri = class extends E {
|
|
|
1208
1209
|
reallocateReservedStorage() {
|
|
1209
1210
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose();
|
|
1210
1211
|
let e = () => {
|
|
1211
|
-
let e = new
|
|
1212
|
-
return e.type =
|
|
1212
|
+
let e = new wn(A, A);
|
|
1213
|
+
return e.type = pr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
|
|
1213
1214
|
};
|
|
1214
1215
|
this._storageTexA = e(), this._storageTexB = e(), this._buildCompute(), this._compiled = !1;
|
|
1215
1216
|
}
|
|
1216
1217
|
dispose() {
|
|
1217
1218
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._colorTexNode?.dispose(), this._readTexNodeA?.dispose(), this._readTexNodeB?.dispose();
|
|
1218
1219
|
}
|
|
1219
|
-
},
|
|
1220
|
+
}, qi = /* @__PURE__ */ Qn("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n sigmaL: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) / sigmaL );\n // clamp dot to [0,1]: miss-ray normals decode to (-1,-1,-1) with\n // dot=3 → pow saturates to +inf → inf*0 = NaN. See project_tsl_pitfalls.\n // max(phiNorm, 1e-6): pow(0.0, 0.0) is undefined in WGSL and returned NaN on ~12%\n // of pixels when phiNormal was set to 0.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), max( phiNorm, 1e-6 ) );\n let depW = exp( -abs( centerDepth - sDepth ) / max( centerDepth * phiDep, 0.001 ) );\n let maxDiff = max( max( abs( centerColor.x - sColor.x ),\n abs( centerColor.y - sColor.y ) ),\n abs( centerColor.z - sColor.z ) );\n let avgLum = max( ( centerLum + sLum ) * 0.5, 0.0001 );\n let colW = exp( -( maxDiff / avgLum ) / max( phiCol, 0.0001 ) );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), Ji = class extends O {
|
|
1220
1221
|
constructor(e, t = {}) {
|
|
1221
1222
|
super("BilateralFiltering", {
|
|
1222
1223
|
...t,
|
|
1223
1224
|
executionMode: ge.ALWAYS
|
|
1224
|
-
}), this.renderer = e, this.inputTextureName = t.inputTextureName || "asvgf:demodulated", this.normalDepthTextureName = t.normalDepthTextureName || "pathtracer:normalDepth", this.shadingNormalTextureName = t.shadingNormalTextureName || "pathtracer:shadingNormal", this.albedoTextureName = t.albedoTextureName || "pathtracer:albedo", this.varianceTextureName = t.varianceTextureName || "variance:output", this.iterations = t.iterations ?? 4, this.phiColor =
|
|
1225
|
+
}), this.renderer = e, this.inputTextureName = t.inputTextureName || "asvgf:demodulated", this.normalDepthTextureName = t.normalDepthTextureName || "pathtracer:normalDepth", this.shadingNormalTextureName = t.shadingNormalTextureName || "pathtracer:shadingNormal", this.albedoTextureName = t.albedoTextureName || "pathtracer:albedo", this.varianceTextureName = t.varianceTextureName || "variance:output", this.iterations = t.iterations ?? 4, this.phiColor = G(t.phiColor ?? .5), this.phiNormal = G(t.phiNormal ?? 128), this.phiDepth = G(t.phiDepth ?? .05), this.phiLuminance = G(t.phiLuminance ?? 4), this.spatialVarianceWeight = G(t.spatialVarianceWeight ?? 1), this.stepSizeU = G(1, "int"), this.isLastIterationU = G(0, "int"), this.isFirstIterationU = G(1, "int"), this.resW = G(t.width || 1), this.resH = G(t.height || 1), this._readTexNode = new M(), this._normalDepthTexNode = new M(), this._shadingNormalTexNode = new M(), this._albedoTexNode = new M(), this._varianceTexNode = new M(), this._srcAlphaTexNode = new M();
|
|
1225
1226
|
let n = t.width || 1, r = t.height || 1;
|
|
1226
|
-
this._storageTexA = new
|
|
1227
|
-
type:
|
|
1227
|
+
this._storageTexA = new wn(A, A), this._storageTexA.type = mr, this._storageTexA.format = Q, this._storageTexA.minFilter = X, this._storageTexA.magFilter = X, this._storageTexB = new wn(A, A), this._storageTexB.type = mr, this._storageTexB.format = Q, this._storageTexB.minFilter = X, this._storageTexB.magFilter = X, this._srcRegion = new ir(new Rr(0, 0), new Rr(0, 0)), this._outputTarget = new Cn(n, r, {
|
|
1228
|
+
type: mr,
|
|
1228
1229
|
format: Q,
|
|
1229
1230
|
minFilter: X,
|
|
1230
1231
|
magFilter: X,
|
|
@@ -1263,19 +1264,19 @@ var Ri = class extends E {
|
|
|
1263
1264
|
4 / 256,
|
|
1264
1265
|
1 / 256
|
|
1265
1266
|
];
|
|
1266
|
-
return
|
|
1267
|
-
let y =
|
|
1268
|
-
|
|
1269
|
-
let x =
|
|
1270
|
-
let t =
|
|
1271
|
-
return
|
|
1272
|
-
},
|
|
1267
|
+
return En(() => {
|
|
1268
|
+
let y = F(Y.x).mul(8).add(F(L.x)), b = F(Y.y).mul(8).add(F(L.y));
|
|
1269
|
+
N(y.lessThan(F(g)).and(b.lessThan(F(_))), () => {
|
|
1270
|
+
let x = I(y, b), S = H(t, x), ee = S.xyz, C = H(n, x), w = H(r, x).xyz.mul(2).sub(1), T = C.w, E = o(ee), te = R(H(i, x).xyz, q(Kr)), D = R(o(te), P(Kr)).toVar(), ne = h.equal(F(1)), re = (e) => {
|
|
1271
|
+
let t = H(a, e);
|
|
1272
|
+
return z(t.z, R(t.z, t.w), f);
|
|
1273
|
+
}, ie = ne.select(re(x), S.w.mul(S.w)).toVar(), ae = d.mul(qn(R(ie, P(0)))).div(D).add(P(1e-4)), O = q(0).toVar(), k = P(0).toVar(), oe = P(0).toVar();
|
|
1273
1274
|
for (let e = 0; e < 5; e++) for (let i = 0; i < 5; i++) {
|
|
1274
|
-
let a = i - 2, s = e - 2, d = v[e * 5 + i], f = y.add(p.mul(a)).clamp(
|
|
1275
|
-
|
|
1275
|
+
let a = i - 2, s = e - 2, d = v[e * 5 + i], f = y.add(p.mul(a)).clamp(F(0), F(g).sub(1)), m = b.add(p.mul(s)).clamp(F(0), F(_).sub(1)), h = H(t, I(f, m)), x = h.xyz, S = H(n, I(f, m)), C = H(r, I(f, m)).xyz.mul(2).sub(1), te = S.w, D = qi(E, o(x), w, C, T, te, ee, x, P(d), ae, l, u, c), ie = ne.select(re(I(f, m)), h.w.mul(h.w));
|
|
1276
|
+
O.addAssign(x.mul(D)), k.addAssign(D), oe.addAssign(D.mul(D).mul(R(ie, P(0))));
|
|
1276
1277
|
}
|
|
1277
|
-
let
|
|
1278
|
-
|
|
1278
|
+
let se = O.div(R(k, P(1e-4))), A = oe.div(R(k.mul(k), P(1e-8))), ce = m.equal(F(1)), le = ce.select(se.mul(te), se), ue = ce.select(H(s, x).w, qn(R(A, P(0))));
|
|
1279
|
+
U(e, Xn(W(y), W(b)), J(le, ue)).toWriteOnly();
|
|
1279
1280
|
});
|
|
1280
1281
|
})().compute([
|
|
1281
1282
|
this._dispatchX,
|
|
@@ -1322,15 +1323,15 @@ var Ri = class extends E {
|
|
|
1322
1323
|
reallocateReservedStorage() {
|
|
1323
1324
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose();
|
|
1324
1325
|
let e = () => {
|
|
1325
|
-
let e = new
|
|
1326
|
-
return e.type =
|
|
1326
|
+
let e = new wn(A, A);
|
|
1327
|
+
return e.type = mr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
|
|
1327
1328
|
};
|
|
1328
1329
|
this._storageTexA = e(), this._storageTexB = e(), this._buildCompute(), this._compiled = !1;
|
|
1329
1330
|
}
|
|
1330
1331
|
dispose() {
|
|
1331
1332
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._readTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._shadingNormalTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varianceTexNode?.dispose(), this._srcAlphaTexNode?.dispose();
|
|
1332
1333
|
}
|
|
1333
|
-
},
|
|
1334
|
+
}, Yi = 6e4, Xi = (e) => V(e.equal(e), e, P(0)).clamp(0, 1e7), Zi = (e) => q(Xi(e.x), Xi(e.y), Xi(e.z)), Qi = 4, $i = [
|
|
1334
1335
|
1 / 256,
|
|
1335
1336
|
4 / 256,
|
|
1336
1337
|
6 / 256,
|
|
@@ -1356,15 +1357,15 @@ var Ri = class extends E {
|
|
|
1356
1357
|
6 / 256,
|
|
1357
1358
|
4 / 256,
|
|
1358
1359
|
1 / 256
|
|
1359
|
-
],
|
|
1360
|
+
], ea = class extends O {
|
|
1360
1361
|
constructor(e, t = {}) {
|
|
1361
1362
|
super("EdgeAwareFiltering", {
|
|
1362
1363
|
...t,
|
|
1363
1364
|
executionMode: ge.PER_CYCLE
|
|
1364
|
-
}), this.renderer = e, this.filterStrength =
|
|
1365
|
+
}), this.renderer = e, this.filterStrength = G(t.filterStrength ?? 1), this.phiLuminance = G(t.phiLuminance ?? 1), this.phiNormal = G(t.phiNormal ?? 64), this.phiDepth = G(t.phiDepth ?? .1), this.iterations = t.atrousIterations ?? t.edgeAtrousIterations ?? 5, this.stepSizeU = G(1, "int"), this.isLastIterationU = G(0, "int"), this.isFirstIterationU = G(1, "int"), this.varianceHistoryU = G(0, "int"), this.resW = G(t.width || 1), this.resH = G(t.height || 1), this._colorTexNode = new M(), this._ndTexNode = new M(), this._snTexNode = new M(), this._albedoTexNode = new M(), this._varTexNode = new M(), this._readTexNode = new M();
|
|
1365
1366
|
let n = t.width || 1, r = t.height || 1;
|
|
1366
|
-
this._demodTex = this._makeStorageTex(), this._storageTexA = this._makeStorageTex(), this._storageTexB = this._makeStorageTex(), this._srcRegion = new
|
|
1367
|
-
type:
|
|
1367
|
+
this._demodTex = this._makeStorageTex(), this._storageTexA = this._makeStorageTex(), this._storageTexB = this._makeStorageTex(), this._srcRegion = new ir(new Rr(0, 0), new Rr(0, 0)), this.outputTarget = new Cn(n, r, {
|
|
1368
|
+
type: pr,
|
|
1368
1369
|
format: Q,
|
|
1369
1370
|
minFilter: X,
|
|
1370
1371
|
magFilter: X,
|
|
@@ -1373,19 +1374,19 @@ var Ri = class extends E {
|
|
|
1373
1374
|
}), this._compiled = !1, this._dispatchX = Math.ceil(n / 16), this._dispatchY = Math.ceil(r / 16), this._buildCompute();
|
|
1374
1375
|
}
|
|
1375
1376
|
_makeStorageTex() {
|
|
1376
|
-
let e = new
|
|
1377
|
-
return e.type =
|
|
1377
|
+
let e = new wn(A, A);
|
|
1378
|
+
return e.type = pr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
|
|
1378
1379
|
}
|
|
1379
1380
|
_buildCompute() {
|
|
1380
1381
|
this._computeDemod = this._buildDemod(), this._computeAtrousA = this._buildAtrous(this._storageTexA), this._computeAtrousB = this._buildAtrous(this._storageTexB);
|
|
1381
1382
|
}
|
|
1382
1383
|
_buildDemod() {
|
|
1383
1384
|
let e = this._colorTexNode, t = this._ndTexNode, n = this._albedoTexNode, r = this._demodTex, i = this.resW, a = this.resH;
|
|
1384
|
-
return
|
|
1385
|
-
let o =
|
|
1386
|
-
|
|
1387
|
-
let i =
|
|
1388
|
-
|
|
1385
|
+
return En(() => {
|
|
1386
|
+
let o = F(Y.x).mul(16).add(F(L.x)), s = F(Y.y).mul(16).add(F(L.y));
|
|
1387
|
+
N(o.lessThan(F(i)).and(s.lessThan(F(a))), () => {
|
|
1388
|
+
let i = I(o, s), a = H(e, i).xyz, c = H(t, i).w.lessThan(P(Yi)), l = H(n, i).xyz, u = V(c, R(l, q(Kr)), q(1)), d = Zi(a.div(u));
|
|
1389
|
+
U(r, Xn(W(o), W(s)), J(d, 1)).toWriteOnly();
|
|
1389
1390
|
});
|
|
1390
1391
|
})().compute([
|
|
1391
1392
|
this._dispatchX,
|
|
@@ -1399,19 +1400,19 @@ var Ri = class extends E {
|
|
|
1399
1400
|
}
|
|
1400
1401
|
_buildAtrous(e) {
|
|
1401
1402
|
let t = this._readTexNode, n = this._colorTexNode, r = this._ndTexNode, i = this._snTexNode, a = this._albedoTexNode, s = this._varTexNode, c = this.filterStrength, l = this.phiLuminance, u = this.phiNormal, d = this.phiDepth, f = this.stepSizeU, p = this.isLastIterationU, m = this.isFirstIterationU, h = this.varianceHistoryU, g = this.resW, _ = this.resH;
|
|
1402
|
-
return
|
|
1403
|
-
let v =
|
|
1404
|
-
|
|
1405
|
-
let b =
|
|
1406
|
-
let t =
|
|
1407
|
-
return
|
|
1408
|
-
},
|
|
1403
|
+
return En(() => {
|
|
1404
|
+
let v = F(Y.x).mul(16).add(F(L.x)), y = F(Y.y).mul(16).add(F(L.y));
|
|
1405
|
+
N(v.lessThan(F(g)).and(y.lessThan(F(_))), () => {
|
|
1406
|
+
let b = I(v, y), x = H(t, b), S = x.xyz, ee = o(S), C = H(r, b).w, w = H(i, b).xyz.mul(2).sub(1), T = C.lessThan(P(Yi)), E = V(T, P(1), P(0)), te = H(a, b).xyz, D = V(T, R(te, q(Kr)), q(1)), ne = R(o(D), P(Kr)), re = m.equal(F(1)), ie = h.lessThan(F(Qi)), ae = (e) => {
|
|
1407
|
+
let t = H(s, e);
|
|
1408
|
+
return V(ie, R(t.z, t.w), t.z);
|
|
1409
|
+
}, O = re.select(ae(b), x.w.mul(x.w)).toVar(), k = l.mul(qn(R(O, P(0)))).div(ne).add(P(1e-4)), oe = q(0).toVar(), se = P(0).toVar(), A = P(0).toVar();
|
|
1409
1410
|
for (let e = 0; e < 5; e++) for (let n = 0; n < 5; n++) {
|
|
1410
|
-
let a = n - 2, s = e - 2, c =
|
|
1411
|
-
|
|
1411
|
+
let a = n - 2, s = e - 2, c = $i[e * 5 + n], l = I(v.add(f.mul(a)).clamp(F(0), F(g).sub(1)), y.add(f.mul(s)).clamp(F(0), F(_).sub(1))), p = H(t, l), m = p.xyz, h = o(m), b = H(r, l).w, x = H(i, l).xyz.mul(2).sub(1), S = V(b.lessThan(P(Yi)), P(1), P(0)), T = ee.sub(h).abs().div(k).negate().exp(), te = Wn(Fn(w, x).clamp(0, 1), u), D = C.sub(b).abs().div(R(C.mul(d), P(.001))).negate().exp(), ne = E.mul(S), ie = E.oneMinus().mul(S.oneMinus()), O = ne.add(ie), ce = z(P(1), te.mul(D), ne), le = P(c).mul(T).mul(ce).mul(O), ue = re.select(ae(l), p.w.mul(p.w));
|
|
1412
|
+
oe.addAssign(m.mul(le)), se.addAssign(le), A.addAssign(le.mul(le).mul(R(ue, P(0))));
|
|
1412
1413
|
}
|
|
1413
|
-
let
|
|
1414
|
-
|
|
1414
|
+
let ce = oe.div(R(se, P(1e-4))), le = A.div(R(se.mul(se), P(1e-8))), ue = p.equal(F(1)), de = H(n, b).xyz, fe = z(de, ce.mul(D), c), pe = ue.select(fe, ce), me = ue.select(H(n, b).w, qn(R(le, P(0))));
|
|
1415
|
+
U(e, Xn(W(v), W(y)), J(pe, me)).toWriteOnly();
|
|
1415
1416
|
});
|
|
1416
1417
|
})().compute([
|
|
1417
1418
|
this._dispatchX,
|
|
@@ -1469,175 +1470,614 @@ var Ri = class extends E {
|
|
|
1469
1470
|
dispose() {
|
|
1470
1471
|
this._computeDemod?.dispose(), this._computeAtrousA?.dispose(), this._computeAtrousB?.dispose(), this._demodTex?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this.outputTarget?.dispose(), this._colorTexNode?.dispose(), this._ndTexNode?.dispose(), this._snTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varTexNode?.dispose(), this._readTexNode?.dispose();
|
|
1471
1472
|
}
|
|
1472
|
-
},
|
|
1473
|
+
}, ta = {
|
|
1473
1474
|
autoExposure: !1,
|
|
1475
|
+
autoExposureMetering: "center",
|
|
1476
|
+
autoExposureStrength: .3,
|
|
1474
1477
|
autoExposureKeyValue: .18,
|
|
1475
|
-
autoExposureMinExposure:
|
|
1476
|
-
autoExposureMaxExposure:
|
|
1478
|
+
autoExposureMinExposure: 2 ** -8,
|
|
1479
|
+
autoExposureMaxExposure: 2 ** 8,
|
|
1477
1480
|
autoExposureAdaptSpeedBright: 3,
|
|
1478
|
-
autoExposureAdaptSpeedDark:
|
|
1479
|
-
},
|
|
1481
|
+
autoExposureAdaptSpeedDark: 1
|
|
1482
|
+
}, na = [
|
|
1483
|
+
"average",
|
|
1484
|
+
"center",
|
|
1485
|
+
"spot"
|
|
1486
|
+
], ra = 64, ia = 8, aa = 8, oa = 256, sa = -16, ca = (12 - sa) / oa, la = 2 ** -24, ua = 65536, da = 256, fa = 128, pa = 1.5, ma = .01, ha = .06, ga = .25, _a = 4, va = .3, ya = 1.5, ba = 3, xa = [
|
|
1487
|
+
.2126,
|
|
1488
|
+
.7152,
|
|
1489
|
+
.0722
|
|
1490
|
+
];
|
|
1491
|
+
function Sa(e, t, n, r, i) {
|
|
1492
|
+
let a = t - e;
|
|
1493
|
+
if (a === 0 || !(n > 0)) return e;
|
|
1494
|
+
let o = Math.max(a < 0 ? r : i, .001);
|
|
1495
|
+
if (n === Infinity) return t;
|
|
1496
|
+
let s = Math.min(o * n, Math.abs(a) * (1 - Math.exp(-o * n / pa)));
|
|
1497
|
+
return e + Math.sign(a) * s;
|
|
1498
|
+
}
|
|
1499
|
+
function Ca(e, t, n) {
|
|
1500
|
+
let r = Math.abs(e);
|
|
1501
|
+
return e * (r <= ya ? n : r >= ba ? 1 : n + (1 - n) * (r - ya) / (ba - ya)) + n * (t - e);
|
|
1502
|
+
}
|
|
1503
|
+
function wa(e, t) {
|
|
1504
|
+
if (!e) return t.fromArray(xa);
|
|
1505
|
+
let n = new yr().set(...e).invert().elements;
|
|
1506
|
+
return t.set(xa[0] * n[0] + xa[1] * n[1] + xa[2] * n[2], xa[0] * n[3] + xa[1] * n[4] + xa[2] * n[5], xa[0] * n[6] + xa[1] * n[7] + xa[2] * n[8]);
|
|
1507
|
+
}
|
|
1508
|
+
var Ta = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, Ea = class extends O {
|
|
1480
1509
|
constructor(e, t = {}) {
|
|
1481
1510
|
super("AutoExposure", {
|
|
1482
1511
|
...t,
|
|
1483
1512
|
executionMode: ge.ALWAYS
|
|
1484
|
-
}), this.renderer = e, this.
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1513
|
+
}), this.renderer = e, this.metering = t.metering ?? ta.autoExposureMetering, this.meteringPoint = new Rr(.5, .5), this.keyValue = t.keyValue ?? ta.autoExposureKeyValue, this.minExposure = t.minExposure ?? ta.autoExposureMinExposure, this.maxExposure = t.maxExposure ?? ta.autoExposureMaxExposure, this.adaptSpeedBright = t.adaptSpeedBright ?? ta.autoExposureAdaptSpeedBright, this.adaptSpeedDark = t.adaptSpeedDark ?? ta.autoExposureAdaptSpeedDark, this.centerWeight = t.centerWeight ?? 8, this.strength = t.strength ?? ta.autoExposureStrength, this.instant = !1, this.holdSamples = 0, this.onChange = null, this._lowU = G(t.lowPercentile ?? .1), this._highU = G(t.highPercentile ?? .9), this._falloffU = G(new Rr()), this._pointU = G(new Rr(.5, .5)), this._lumWeightsU = G(new $().fromArray(xa)), this._widthU = G(1, "int"), this._heightU = G(1, "int"), this._strideU = G(1, "int"), this._gridXU = G(ra, "int"), this._gridYU = G(ra, "int"), this._inputNode = new M(), this._workingMatrix = void 0, this._histogram = Pn(oa, "uint").toAtomic(), this._result = Pn(1, "vec4"), this._readback = new Sn(16), this._readback.name = "AutoExposure", this._kernels = [this._buildTileKernel(), this._buildResolveKernel()], this._compensation = 1, this._exposureEV = 0, this._targetEV = null, this._viewEV = null, this._roomEV = null, this._clock = 0, this._movingUntil = -1, this._viewMoves = 0, this._landed = null, this._meteredLog2 = null, this._snap = !0, this._lastUpdate = null, this._accumulating = !1, this._emittedEV = null, this._pending = null, this._generation = 0, this._restarts = 0, this._meteredAt = {
|
|
1514
|
+
restarts: -1,
|
|
1515
|
+
samples: -1
|
|
1516
|
+
}, this._stale = !1, this._disposed = !1;
|
|
1517
|
+
}
|
|
1518
|
+
_buildTileKernel() {
|
|
1519
|
+
let e = this._inputNode, t = this._histogram, n = this._widthU, r = this._heightU, i = this._strideU, a = this._gridXU, o = this._gridYU, s = this._lumWeightsU, c = this._falloffU, l = this._pointU;
|
|
1520
|
+
return En(() => {
|
|
1521
|
+
let u = L.y.mul(W(aa)).add(L.x), d = F(Y.x), f = F(Y.y), p = d.mul(n).div(a).toVar(), m = d.add(F(1)).mul(n).div(a).toVar(), h = f.mul(r).div(o).toVar(), g = f.add(F(1)).mul(r).div(o).toVar(), _ = i.mul(F(aa)), v = P(0).toVar(), y = P(0).toVar();
|
|
1522
|
+
Dn({
|
|
1523
|
+
start: h.add(F(L.y)),
|
|
1524
|
+
end: g,
|
|
1525
|
+
type: "int",
|
|
1526
|
+
condition: "<",
|
|
1527
|
+
update: _,
|
|
1528
|
+
name: "py"
|
|
1529
|
+
}, ({ py: t }) => {
|
|
1530
|
+
Dn({
|
|
1531
|
+
start: p.add(F(L.x)),
|
|
1532
|
+
end: m,
|
|
1533
|
+
type: "int",
|
|
1534
|
+
condition: "<",
|
|
1535
|
+
update: _,
|
|
1536
|
+
name: "px"
|
|
1537
|
+
}, ({ px: n }) => {
|
|
1538
|
+
let r = H(e, I(n, t)), i = Fn(r.xyz, s).toVar(), a = Rn(i).bitAnd(W(2139095040)).notEqual(W(2139095040)), o = r.w.clamp(0, 1);
|
|
1539
|
+
v.addAssign(V(a, i.clamp(0, 1e6), P(0)).mul(o)), y.addAssign(o);
|
|
1508
1540
|
});
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1541
|
+
});
|
|
1542
|
+
let b = $n("float", aa * aa), x = $n("float", aa * aa);
|
|
1543
|
+
b.element(u).assign(v), x.element(u).assign(y), er();
|
|
1544
|
+
for (let e = aa * aa >> 1; e > 0; e >>= 1) N(u.lessThan(W(e)), () => {
|
|
1545
|
+
b.element(u).addAssign(b.element(u.add(W(e)))), x.element(u).addAssign(x.element(u.add(W(e))));
|
|
1546
|
+
}), er();
|
|
1547
|
+
N(u.equal(W(0)), () => {
|
|
1548
|
+
let e = b.element(W(0)).toVar(), i = x.element(W(0)).toVar(), a = (e) => e.div(_).mul(F(aa)).add(Hn(e.mod(_), F(aa))), o = P(a(m.sub(p)).mul(a(g.sub(h))));
|
|
1549
|
+
N(i.greaterThan(0).and(e.greaterThan(i.mul(la))), () => {
|
|
1550
|
+
let a = W(Vn(e.div(i)).sub(sa).div(ca).floor().clamp(0, oa - 1)), s = K(P(p.add(m)).div(P(n)), P(h.add(g)).div(P(r))).mul(.5).sub(l), u = W(In(Fn(s.mul(s), c).negate()).mul(i.div(R(o, 1))).mul(ua).add(.5));
|
|
1551
|
+
N(u.greaterThan(W(0)), () => {
|
|
1552
|
+
jn(t.element(a), u);
|
|
1553
|
+
});
|
|
1554
|
+
});
|
|
1555
|
+
});
|
|
1511
1556
|
})().compute([
|
|
1512
|
-
|
|
1513
|
-
|
|
1557
|
+
ra,
|
|
1558
|
+
ra,
|
|
1514
1559
|
1
|
|
1515
1560
|
], [
|
|
1516
|
-
|
|
1517
|
-
|
|
1561
|
+
aa,
|
|
1562
|
+
aa,
|
|
1518
1563
|
1
|
|
1519
1564
|
]);
|
|
1520
1565
|
}
|
|
1521
|
-
|
|
1522
|
-
let e = this.
|
|
1523
|
-
|
|
1524
|
-
let
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1566
|
+
_buildResolveKernel() {
|
|
1567
|
+
let e = this._histogram, t = this._result, n = this._lowU, r = this._highU;
|
|
1568
|
+
return En(() => {
|
|
1569
|
+
let i = L.x, a = P(Mn(e.element(i))).toVar();
|
|
1570
|
+
Nn(e.element(i), W(0));
|
|
1571
|
+
let o = $n("float", oa), s = $n("float", oa);
|
|
1572
|
+
o.element(i).assign(a), er();
|
|
1573
|
+
for (let e = 1; e < oa; e <<= 1) {
|
|
1574
|
+
let t = o.element(i).toVar();
|
|
1575
|
+
N(i.greaterThanEqual(W(e)), () => {
|
|
1576
|
+
t.addAssign(o.element(i.sub(W(e))));
|
|
1577
|
+
}), er(), o.element(i).assign(t), er();
|
|
1532
1578
|
}
|
|
1579
|
+
let c = o.element(W(oa - 1)).toVar(), l = o.element(i).toVar();
|
|
1580
|
+
er();
|
|
1581
|
+
let u = R(Hn(l, c.mul(r)).sub(R(l.sub(a), c.mul(n))), 0);
|
|
1582
|
+
o.element(i).assign(u), s.element(i).assign(u.mul(P(i).add(.5).mul(ca).add(sa))), er();
|
|
1583
|
+
for (let e = oa >> 1; e > 0; e >>= 1) N(i.lessThan(W(e)), () => {
|
|
1584
|
+
o.element(i).addAssign(o.element(i.add(W(e)))), s.element(i).addAssign(s.element(i.add(W(e))));
|
|
1585
|
+
}), er();
|
|
1586
|
+
N(i.equal(W(0)), () => {
|
|
1587
|
+
let e = o.element(W(0));
|
|
1588
|
+
t.element(W(0)).assign(J(s.element(W(0)).div(R(e, 1e-6)), c.div(ua), e.div(ua), 1));
|
|
1589
|
+
});
|
|
1533
1590
|
})().compute([
|
|
1534
1591
|
1,
|
|
1535
1592
|
1,
|
|
1536
1593
|
1
|
|
1537
1594
|
], [
|
|
1538
|
-
|
|
1595
|
+
oa,
|
|
1539
1596
|
1,
|
|
1540
1597
|
1
|
|
1541
1598
|
]);
|
|
1542
1599
|
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1600
|
+
setupEventListeners() {
|
|
1601
|
+
this.on("pipeline:reset", () => this._restarts++), this.on("pipeline:lightingChanged", () => this.resetHistory());
|
|
1602
|
+
}
|
|
1603
|
+
render(e) {
|
|
1604
|
+
if (!this.enabled) return;
|
|
1605
|
+
let t = e.getState("pathtracer:samples") ?? 0;
|
|
1606
|
+
if (this._accumulating = t >= 2, !this._pending) {
|
|
1607
|
+
let n = this._meteredAt, r = this._stale || this._targetEV === null || n.restarts !== this._restarts || t - n.samples >= Ta(t), i = t < this.holdSamples && this._targetEV !== null && !this._stale;
|
|
1608
|
+
r && !i && this._meter(e, t);
|
|
1609
|
+
}
|
|
1610
|
+
e.setState("autoexposure:value", this.renderer.toneMappingExposure), e.setState("autoexposure:avgLuminance", this.luminance);
|
|
1611
|
+
}
|
|
1612
|
+
async meter(e = this.context) {
|
|
1613
|
+
for (; this._pending;) await this._pending;
|
|
1614
|
+
let t = this._meter(e, e?.getState("pathtracer:samples") ?? 0);
|
|
1615
|
+
return t ? await t : null;
|
|
1616
|
+
}
|
|
1617
|
+
_meter(e, t) {
|
|
1618
|
+
let n = e?.getTexture("pathtracer:color"), r = n?.image?.width | 0, i = n?.image?.height | 0;
|
|
1619
|
+
if (!n || r < 1 || i < 1 || this._disposed) return null;
|
|
1620
|
+
this._meteredAt.restarts = this._restarts, this._meteredAt.samples = t, this._stale = !1;
|
|
1621
|
+
let a = nt();
|
|
1622
|
+
a !== this._workingMatrix && (this._workingMatrix = a, wa(a, this._lumWeightsU.value));
|
|
1623
|
+
let o = Math.min(ra, Math.max(1, Math.floor(r / ia))), s = Math.min(ra, Math.max(1, Math.floor(i / ia))), c = r / o * (i / s);
|
|
1624
|
+
this._gridXU.value = o, this._gridYU.value = s, this._kernels[0].dispatchSize = [
|
|
1625
|
+
o,
|
|
1626
|
+
s,
|
|
1627
|
+
1
|
|
1628
|
+
], this._strideU.value = Math.max(1, Math.round(Math.sqrt(c / da))), this._widthU.value = r, this._heightU.value = i, this._updateMeteringPattern(r / i), this._inputNode.value = n, this.renderer.compute(this._kernels);
|
|
1629
|
+
let l = this._generation, u = {
|
|
1630
|
+
restarts: this._restarts,
|
|
1631
|
+
moves: this._viewMoves
|
|
1632
|
+
}, d = this.renderer.getArrayBufferAsync(this._result.value, this._readback).then((e) => {
|
|
1633
|
+
let t = e?.buffer ? new Float32Array(e.buffer.slice(0, 16)) : null;
|
|
1634
|
+
return this._readback.release(), t && l === this._generation && !this._disposed ? this._applyMetering(t, u) : null;
|
|
1635
|
+
}, () => (!this._disposed && this._readback._mapped && this._readback.release(), null)).finally(() => {
|
|
1636
|
+
this._pending === d && (this._pending = null);
|
|
1637
|
+
});
|
|
1638
|
+
return this._pending = d, d;
|
|
1639
|
+
}
|
|
1640
|
+
_updateMeteringPattern(e) {
|
|
1641
|
+
let t = this._falloffU.value, n = this._pointU.value;
|
|
1642
|
+
if (this.metering === "average") t.set(0, 0);
|
|
1643
|
+
else if (this.metering === "spot") {
|
|
1644
|
+
t.set(fa * e * e, fa), n.copy(this.meteringPoint);
|
|
1645
|
+
return;
|
|
1646
|
+
} else t.set(this.centerWeight, this.centerWeight);
|
|
1647
|
+
n.set(.5, .5);
|
|
1648
|
+
}
|
|
1649
|
+
_applyMetering(e, t = this._landed) {
|
|
1650
|
+
let [n, r, i] = e;
|
|
1651
|
+
if (!this.enabled || !(r > 0 && i > 0) || !Number.isFinite(n)) return null;
|
|
1652
|
+
let a = this._viewEV;
|
|
1653
|
+
this._meteredLog2 = n, this._viewEV = Math.log2(this.keyValue) - n, this._roomEV === null ? this._roomEV = this._viewEV : t?.moves === this._landed?.moves ? this._roomEV += this._viewEV - a : this._movingUntil = this._clock + va, this._landed = t;
|
|
1654
|
+
let o = this._aim(), s = this._targetEV === null || Math.abs(o - this._targetEV) > ma;
|
|
1655
|
+
return this._targetEV = o, (s || this.settling) && this.onChange?.(), n;
|
|
1656
|
+
}
|
|
1657
|
+
update(e = performance.now()) {
|
|
1658
|
+
let t = this._lastUpdate === null ? 0 : Math.min((e - this._lastUpdate) / 1e3, ga), n = this.advance(t, this._accumulating);
|
|
1659
|
+
return this._lastUpdate = this.settling || this._clock <= this._movingUntil ? e : null, n;
|
|
1660
|
+
}
|
|
1661
|
+
advance(e, t = !1) {
|
|
1662
|
+
if (!this.enabled || this._targetEV === null) return !1;
|
|
1663
|
+
e > 0 && e !== Infinity && (this._clock += e, this._clock <= this._movingUntil && (this._roomEV += (this._viewEV - this._roomEV) * (1 - Math.exp(-Math.min(e, ga) / _a)), this._targetEV = this._aim()));
|
|
1664
|
+
let n = this._exposureEV;
|
|
1665
|
+
return this._snap || this.instant ? (this._exposureEV = this._targetEV, this._snap = !1) : (this._exposureEV = t ? n + (this._targetEV - n) * (1 - Math.exp(-e / ha)) : Sa(n, this._targetEV, e, this.adaptSpeedBright, this.adaptSpeedDark), Math.abs(this._targetEV - this._exposureEV) <= ma && (this._exposureEV = this._targetEV)), this._exposureEV === n ? !1 : (this._apply(), !0);
|
|
1666
|
+
}
|
|
1667
|
+
_inRange(e) {
|
|
1668
|
+
return Math.min(Math.max(e, Math.log2(this.minExposure)), Math.log2(this.maxExposure));
|
|
1669
|
+
}
|
|
1670
|
+
_aim() {
|
|
1671
|
+
return this._inRange(Ca(this._roomEV, this._viewEV, this.strength));
|
|
1672
|
+
}
|
|
1673
|
+
noteViewChanged() {
|
|
1674
|
+
this._viewMoves++;
|
|
1675
|
+
}
|
|
1676
|
+
get settling() {
|
|
1677
|
+
return this.enabled && this._targetEV !== null && (this._snap || Math.abs(this._targetEV - this._exposureEV) > 0);
|
|
1678
|
+
}
|
|
1679
|
+
get wantsMetering() {
|
|
1680
|
+
return this.enabled && !this._pending && (this._stale || this._targetEV === null);
|
|
1681
|
+
}
|
|
1682
|
+
_apply() {
|
|
1683
|
+
this.renderer.toneMappingExposure = this.enabled ? 2 ** this._exposureEV * this._compensation : this._compensation, !(!this.enabled || this._emittedEV !== null && Math.abs(this._exposureEV - this._emittedEV) < .005) && (this._emittedEV = this._exposureEV, this.emit("autoexposure:updated", {
|
|
1684
|
+
exposure: this.renderer.toneMappingExposure,
|
|
1685
|
+
autoExposure: this.getExposure(),
|
|
1686
|
+
targetExposure: this._targetEV === null ? null : 2 ** this._targetEV,
|
|
1687
|
+
luminance: this.luminance
|
|
1688
|
+
}));
|
|
1689
|
+
}
|
|
1690
|
+
setEnabled(e, t = this._compensation) {
|
|
1691
|
+
if (this._compensation = t, e === this.enabled) {
|
|
1692
|
+
this._apply();
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
this.enabled = e, this._emittedEV = null, e && (this.resetHistory(), this._exposureEV = 0), this._apply(), this.onChange?.();
|
|
1696
|
+
}
|
|
1697
|
+
setCompensation(e) {
|
|
1698
|
+
this._compensation = e, this._apply();
|
|
1699
|
+
}
|
|
1700
|
+
resetHistory() {
|
|
1701
|
+
this._generation++, this._targetEV = null, this._viewEV = null, this._roomEV = null, this._landed = null, this._meteredLog2 = null, this._snap = !0;
|
|
1702
|
+
}
|
|
1703
|
+
getExposure() {
|
|
1704
|
+
return 2 ** this._exposureEV;
|
|
1705
|
+
}
|
|
1706
|
+
get luminance() {
|
|
1707
|
+
return this._meteredLog2 === null ? null : 2 ** this._meteredLog2;
|
|
1708
|
+
}
|
|
1709
|
+
getLuminance() {
|
|
1710
|
+
return this.luminance;
|
|
1711
|
+
}
|
|
1712
|
+
updateParameters(e) {
|
|
1713
|
+
let t = e.metering;
|
|
1714
|
+
t !== void 0 && na.includes(t) && (this.metering = t), e.meteringPoint && this.meteringPoint.set(e.meteringPoint.x, e.meteringPoint.y);
|
|
1715
|
+
for (let t of [
|
|
1716
|
+
"keyValue",
|
|
1717
|
+
"minExposure",
|
|
1718
|
+
"maxExposure",
|
|
1719
|
+
"adaptSpeedBright",
|
|
1720
|
+
"adaptSpeedDark",
|
|
1721
|
+
"centerWeight",
|
|
1722
|
+
"strength"
|
|
1723
|
+
]) e[t] !== void 0 && (this[t] = e[t]);
|
|
1724
|
+
e.lowPercentile !== void 0 && (this._lowU.value = e.lowPercentile), e.highPercentile !== void 0 && (this._highU.value = e.highPercentile), this._stale = !0, this._meteredLog2 !== null && this._applyMetering([
|
|
1725
|
+
this._meteredLog2,
|
|
1726
|
+
1,
|
|
1727
|
+
1
|
|
1728
|
+
]), this.onChange?.();
|
|
1729
|
+
}
|
|
1730
|
+
reset() {}
|
|
1731
|
+
setSize() {}
|
|
1732
|
+
dispose() {
|
|
1733
|
+
this._disposed = !0, this.onChange = null;
|
|
1734
|
+
for (let e of this._kernels) e.dispose();
|
|
1735
|
+
this._readback.dispose(), this._inputNode.dispose();
|
|
1736
|
+
}
|
|
1737
|
+
}, Da = {
|
|
1738
|
+
localExposure: !1,
|
|
1739
|
+
localExposureHighlightContrast: .6,
|
|
1740
|
+
localExposureShadowContrast: 1,
|
|
1741
|
+
localExposureDetailStrength: 1
|
|
1742
|
+
}, Oa = 128, ka = (Oa / 2) ** 2, Aa = 32, ja = -16, Ma = 16, Na = -40, Pa = 40, Fa = 256, Ia = 32, La = .6, Ra = 50, za = Math.log2(.18), Ba = 2 ** -24, Va = Math.ceil(Se / Oa), Ha = Math.ceil(Se / Ia), Ua = [
|
|
1743
|
+
.2126,
|
|
1744
|
+
.7152,
|
|
1745
|
+
.0722
|
|
1746
|
+
], Wa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, Ga = (e, t, n) => Math.min(Math.max(e, t), n);
|
|
1747
|
+
function Ka(e, t, n, r, i, a, o) {
|
|
1748
|
+
let s = Math.min(Math.log2(Math.max(a, Ba)), Pa), c = e[6], l = e[7], u = Ga(r * e[2] - .5, 0, c - 1), d = Ga(i * e[3] - .5, 0, l - 1), f = Math.floor(u), p = Math.floor(d), m = Math.min(f + 1, c - 1), h = Math.min(p + 1, l - 1), g = u - f, _ = d - p, v = (e) => n[e * c + f] + (n[e * c + m] - n[e * c + f]) * g, y = v(p) + (v(h) - v(p)) * _, b = e[4], x = e[5], S = Ga(r * e[0] - .5, 0, b - 1), ee = Ga(i * e[1] - .5, 0, x - 1), C = Ga((s + e[8] - ja) / (Ma - ja), 0, 1) * (Aa - 1), w = Math.floor(S), T = Math.floor(ee), E = Math.floor(C), te = S - w, D = ee - T, ne = C - E, re = 0, ie = 0;
|
|
1749
|
+
for (let e = 0; e < 8; e++) {
|
|
1750
|
+
let n = e & 1, r = e >> 1 & 1, i = e >> 2, a = (n ? te : 1 - te) * (r ? D : 1 - D) * (i ? ne : 1 - ne), o = ((Math.min(T + r, x - 1) * b + Math.min(w + n, b - 1)) * Aa + Math.min(E + i, Aa - 1)) * 2;
|
|
1751
|
+
re += t[o] * a, ie += t[o + 1] * a;
|
|
1752
|
+
}
|
|
1753
|
+
let ae = ie * ka < .001 ? y : re / ie, O = ae + (y - ae) * e[12] + o, k = s + o, oe = O > e[13] ? e[9] : e[10];
|
|
1754
|
+
return 2 ** (e[13] + (O - e[13]) * oe + (k - O) * e[11] - k);
|
|
1755
|
+
}
|
|
1756
|
+
var qa = `
|
|
1757
|
+
@group(1) @binding(0) var<storage, read> leGrid: array<vec2<f32>>;
|
|
1758
|
+
@group(1) @binding(1) var<storage, read> leBlur: array<f32>;
|
|
1759
|
+
@group(1) @binding(2) var<uniform> le: array<vec4<f32>, 4>;
|
|
1760
|
+
|
|
1761
|
+
fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
|
|
1762
|
+
let logL = min( log2( max( dot( linear, vec3<f32>( ${Ua.join(", ")} ) ), ${Ba} ) ), ${Pa}.0 );
|
|
1763
|
+
let logExposure = log2( exposure );
|
|
1764
|
+
|
|
1765
|
+
let bs = vec2<i32>( le[ 1 ].zw );
|
|
1766
|
+
let bp = clamp( uv * le[ 0 ].zw - 0.5, vec2<f32>( 0.0 ), vec2<f32>( bs - 1 ) );
|
|
1767
|
+
let b0 = vec2<i32>( floor( bp ) );
|
|
1768
|
+
let b1 = min( b0 + 1, bs - 1 );
|
|
1769
|
+
let bf = bp - floor( bp );
|
|
1770
|
+
let top = mix( leBlur[ b0.y * bs.x + b0.x ], leBlur[ b0.y * bs.x + b1.x ], bf.x );
|
|
1771
|
+
let bottom = mix( leBlur[ b1.y * bs.x + b0.x ], leBlur[ b1.y * bs.x + b1.x ], bf.x );
|
|
1772
|
+
let blurred = mix( top, bottom, bf.y );
|
|
1773
|
+
|
|
1774
|
+
let cs = vec2<i32>( le[ 1 ].xy );
|
|
1775
|
+
let gp = clamp( uv * le[ 0 ].xy - 0.5, vec2<f32>( 0.0 ), vec2<f32>( cs - 1 ) );
|
|
1776
|
+
let gz = clamp( ( logL + le[ 2 ].x - (${ja}.0) ) / ${Ma - ja}.0, 0.0, 1.0 ) * ${Aa - 1}.0;
|
|
1777
|
+
let g0 = vec3<i32>( vec2<i32>( floor( gp ) ), i32( floor( gz ) ) );
|
|
1778
|
+
let gf = vec3<f32>( gp - floor( gp ), gz - floor( gz ) );
|
|
1779
|
+
var acc = vec2<f32>( 0.0 );
|
|
1780
|
+
for ( var k = 0; k < 8; k++ ) {
|
|
1781
|
+
let d = vec3<i32>( k & 1, ( k >> 1u ) & 1, k >> 2u );
|
|
1782
|
+
let wv = select( 1.0 - gf, gf, d == vec3<i32>( 1 ) );
|
|
1783
|
+
let c = min( g0 + d, vec3<i32>( cs - 1, ${Aa - 1} ) );
|
|
1784
|
+
acc += leGrid[ ( c.y * cs.x + c.x ) * ${Aa} + c.z ] * ( wv.x * wv.y * wv.z );
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
let bilateral = select( acc.x / acc.y, blurred, acc.y * ${ka}.0 < 1e-3 );
|
|
1788
|
+
let base = mix( bilateral, blurred, le[ 3 ].x ) + logExposure;
|
|
1789
|
+
let y = logL + logExposure;
|
|
1790
|
+
let contrast = select( le[ 2 ].z, le[ 2 ].y, base > le[ 3 ].y );
|
|
1791
|
+
return exp2( le[ 3 ].y + ( base - le[ 3 ].y ) * contrast + ( y - base ) * le[ 2 ].w - y );
|
|
1792
|
+
}
|
|
1793
|
+
`, Ja = class extends O {
|
|
1794
|
+
constructor(e, t = {}) {
|
|
1795
|
+
super("LocalExposure", {
|
|
1796
|
+
...t,
|
|
1797
|
+
executionMode: ge.ALWAYS
|
|
1798
|
+
}), this.renderer = e, this.highlightContrast = t.highlightContrast ?? Da.localExposureHighlightContrast, this.shadowContrast = t.shadowContrast ?? Da.localExposureShadowContrast, this.detailStrength = t.detailStrength ?? Da.localExposureDetailStrength, this.onChange = null, this._grid = Pn(Va * Va * Aa, "vec2"), this._blur = Pn(Ha * Ha, "float"), this._blurTmp = Pn(Ha * Ha, "float"), this._inputNode = new M(), this._widthU = G(1, "int"), this._heightU = G(1, "int"), this._cellsXU = G(1, "int"), this._blurWU = G(1, "int"), this._blurHU = G(1, "int"), this._radiusU = G(1), this._logExposureU = G(0), this._p = [
|
|
1799
|
+
new zr(),
|
|
1800
|
+
new zr(),
|
|
1801
|
+
new zr(),
|
|
1802
|
+
new zr()
|
|
1803
|
+
].map((e) => G(e)), this._params = new Float32Array(16), this._kernels = [
|
|
1804
|
+
this._buildGridKernel(),
|
|
1805
|
+
this._buildBlurSourceKernel(),
|
|
1806
|
+
this._buildBlurKernel(this._blur, this._blurTmp, !0),
|
|
1807
|
+
this._buildBlurKernel(this._blurTmp, this._blur, !1)
|
|
1808
|
+
], this._built = !1, this._restarts = 0, this._builtAt = {
|
|
1809
|
+
restarts: -1,
|
|
1810
|
+
samples: -1
|
|
1811
|
+
}, this._stale = !1, this._paramsBuffer = null, this._disposed = !1;
|
|
1812
|
+
}
|
|
1813
|
+
_buildGridKernel() {
|
|
1814
|
+
let e = this._inputNode, t = this._grid, n = this._widthU, r = this._heightU, i = this._cellsXU, a = this._logExposureU, o = J(...Ua, 0).xyz;
|
|
1815
|
+
return En(() => {
|
|
1816
|
+
let s = L.y.mul(W(16)).add(L.x), c = $n("uint", Aa).toAtomic(), l = $n("uint", Aa).toAtomic();
|
|
1817
|
+
N(s.lessThan(W(Aa)), () => {
|
|
1818
|
+
Nn(c.element(s), W(0)), Nn(l.element(s), W(0));
|
|
1819
|
+
}), er();
|
|
1820
|
+
let u = F(Y.x).mul(F(Oa)).add(F(L.x).mul(F(8))), d = F(Y.y).mul(F(Oa)).add(F(L.y).mul(F(8)));
|
|
1821
|
+
Dn({
|
|
1822
|
+
start: F(0),
|
|
1823
|
+
end: F(8),
|
|
1824
|
+
type: "int",
|
|
1825
|
+
condition: "<",
|
|
1826
|
+
update: 2,
|
|
1827
|
+
name: "ty"
|
|
1828
|
+
}, ({ ty: t }) => {
|
|
1829
|
+
Dn({
|
|
1830
|
+
start: F(0),
|
|
1831
|
+
end: F(8),
|
|
1832
|
+
type: "int",
|
|
1833
|
+
condition: "<",
|
|
1834
|
+
update: 2,
|
|
1835
|
+
name: "tx"
|
|
1836
|
+
}, ({ tx: i }) => {
|
|
1837
|
+
let s = u.add(i), f = d.add(t);
|
|
1838
|
+
N(s.lessThan(n).and(f.lessThan(r)), () => {
|
|
1839
|
+
let t = Hn(s.add(F(1)), n.sub(F(1))), i = Hn(f.add(F(1)), r.sub(F(1))), u = Fn(H(e, I(s, f)).xyz, o).add(Fn(H(e, I(t, f)).xyz, o)).add(Fn(H(e, I(s, i)).xyz, o)).add(Fn(H(e, I(t, i)).xyz, o)).mul(.25).toVar();
|
|
1840
|
+
N(Rn(u).bitAnd(W(2139095040)).notEqual(W(2139095040)), () => {
|
|
1841
|
+
let e = Vn(R(u, Ba)).clamp(Na, Pa).toVar(), t = e.add(a).sub(ja).div(Ma - ja).clamp(0, 1).mul(Aa - 1).toVar(), n = W(zn(t)).min(W(Aa - 1)), r = n.add(W(1)).min(W(Aa - 1)), i = t.sub(zn(t)), o = P(1).sub(i), s = e.sub(Na).mul(Fa);
|
|
1842
|
+
jn(c.element(n), W(s.mul(o).add(.5))), jn(l.element(n), W(o.mul(Fa).add(.5))), jn(c.element(r), W(s.mul(i).add(.5))), jn(l.element(r), W(i.mul(Fa).add(.5)));
|
|
1843
|
+
});
|
|
1844
|
+
});
|
|
1845
|
+
});
|
|
1846
|
+
}), er(), N(s.lessThan(W(Aa)), () => {
|
|
1847
|
+
let e = P(Mn(l.element(s))).div(Fa), n = P(Mn(c.element(s))).div(Fa).add(e.mul(Na)), r = W(Y.y).mul(W(i)).add(W(Y.x));
|
|
1848
|
+
t.element(r.mul(W(Aa)).add(s)).assign(K(n, e).div(ka));
|
|
1549
1849
|
});
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1850
|
+
})().compute([
|
|
1851
|
+
1,
|
|
1852
|
+
1,
|
|
1853
|
+
1
|
|
1854
|
+
], [
|
|
1855
|
+
16,
|
|
1856
|
+
16,
|
|
1857
|
+
1
|
|
1858
|
+
]);
|
|
1859
|
+
}
|
|
1860
|
+
_buildBlurSourceKernel() {
|
|
1861
|
+
let e = this._inputNode, t = this._blur, n = this._widthU, r = this._heightU, i = this._blurWU, a = J(...Ua, 0).xyz;
|
|
1862
|
+
return En(() => {
|
|
1863
|
+
let o = L.y.mul(W(8)).add(L.x), s = F(Y.x).mul(F(Ia)), c = F(Y.y).mul(F(Ia)), l = P(0).toVar(), u = P(0).toVar();
|
|
1864
|
+
Dn({
|
|
1865
|
+
start: F(L.y),
|
|
1866
|
+
end: F(Ia),
|
|
1867
|
+
type: "int",
|
|
1868
|
+
condition: "<",
|
|
1869
|
+
update: 8,
|
|
1870
|
+
name: "by"
|
|
1871
|
+
}, ({ by: t }) => {
|
|
1872
|
+
Dn({
|
|
1873
|
+
start: F(L.x),
|
|
1874
|
+
end: F(Ia),
|
|
1875
|
+
type: "int",
|
|
1876
|
+
condition: "<",
|
|
1877
|
+
update: 8,
|
|
1878
|
+
name: "bx"
|
|
1879
|
+
}, ({ bx: i }) => {
|
|
1880
|
+
let o = s.add(i), d = c.add(t);
|
|
1881
|
+
N(o.lessThan(n).and(d.lessThan(r)), () => {
|
|
1882
|
+
let t = Fn(H(e, I(o, d)).xyz, a).toVar(), n = Rn(t).bitAnd(W(2139095040)).notEqual(W(2139095040));
|
|
1883
|
+
l.addAssign(V(n, t.max(0), P(0))), u.addAssign(V(n, P(1), P(0)));
|
|
1884
|
+
});
|
|
1556
1885
|
});
|
|
1557
1886
|
});
|
|
1558
|
-
let d =
|
|
1559
|
-
|
|
1560
|
-
|
|
1887
|
+
let d = $n("float", 64), f = $n("float", 64);
|
|
1888
|
+
d.element(o).assign(l), f.element(o).assign(u), er();
|
|
1889
|
+
for (let e = 32; e > 0; e >>= 1) N(o.lessThan(W(e)), () => {
|
|
1890
|
+
d.element(o).addAssign(d.element(o.add(W(e)))), f.element(o).addAssign(f.element(o.add(W(e))));
|
|
1891
|
+
}), er();
|
|
1892
|
+
N(o.equal(W(0)), () => {
|
|
1893
|
+
let e = d.element(W(0)).div(R(f.element(W(0)), 1));
|
|
1894
|
+
t.element(W(F(Y.y).mul(i).add(F(Y.x)))).assign(Vn(R(e, Ba)).clamp(Na, Pa));
|
|
1895
|
+
});
|
|
1896
|
+
})().compute([
|
|
1561
1897
|
1,
|
|
1562
1898
|
1,
|
|
1563
1899
|
1
|
|
1900
|
+
], [
|
|
1901
|
+
8,
|
|
1902
|
+
8,
|
|
1903
|
+
1
|
|
1564
1904
|
]);
|
|
1565
1905
|
}
|
|
1566
|
-
|
|
1567
|
-
let
|
|
1568
|
-
|
|
1569
|
-
let
|
|
1570
|
-
|
|
1571
|
-
|
|
1906
|
+
_buildBlurKernel(e, t, n) {
|
|
1907
|
+
let r = this._blurWU, i = this._blurHU, a = this._radiusU;
|
|
1908
|
+
return En(() => {
|
|
1909
|
+
let o = F(Y.x).mul(F(8)).add(F(L.x)), s = F(Y.y).mul(F(8)).add(F(L.y));
|
|
1910
|
+
N(o.lessThan(r).and(s.lessThan(i)), () => {
|
|
1911
|
+
let c = n ? r : i, l = n ? o : s, u = F(a.ceil()), d = P(0).toVar(), f = P(0).toVar();
|
|
1912
|
+
Dn({
|
|
1913
|
+
start: u.negate(),
|
|
1914
|
+
end: u.add(F(1)),
|
|
1915
|
+
type: "int",
|
|
1916
|
+
condition: "<",
|
|
1917
|
+
name: "o"
|
|
1918
|
+
}, ({ o: t }) => {
|
|
1919
|
+
let i = P(t).div(a), u = In(i.mul(i).mul(-16.7)), p = c.mul(F(2)), m = l.add(t).mod(p).add(p).mod(p).toVar();
|
|
1920
|
+
N(m.greaterThanEqual(c), () => {
|
|
1921
|
+
m.assign(p.sub(m).sub(F(1)));
|
|
1922
|
+
});
|
|
1923
|
+
let h = n ? s.mul(r).add(m) : m.mul(r).add(o);
|
|
1924
|
+
d.addAssign(e.element(W(h)).mul(u)), f.addAssign(u);
|
|
1925
|
+
}), t.element(W(s.mul(r).add(o))).assign(d.div(f));
|
|
1926
|
+
});
|
|
1927
|
+
})().compute([
|
|
1572
1928
|
1,
|
|
1573
1929
|
1,
|
|
1574
1930
|
1
|
|
1931
|
+
], [
|
|
1932
|
+
8,
|
|
1933
|
+
8,
|
|
1934
|
+
1
|
|
1575
1935
|
]);
|
|
1576
1936
|
}
|
|
1577
1937
|
setupEventListeners() {
|
|
1578
|
-
this.on("pipeline:reset", () => this.
|
|
1938
|
+
this.on("pipeline:reset", () => this._restarts++);
|
|
1579
1939
|
}
|
|
1580
1940
|
render(e) {
|
|
1581
1941
|
if (!this.enabled) return;
|
|
1582
|
-
let t = e.
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
getLuminance() {
|
|
1623
|
-
return this.currentLuminance;
|
|
1942
|
+
let t = e.getState("pathtracer:samples") ?? 0, n = this._builtAt;
|
|
1943
|
+
(this._stale || !this._built || n.restarts !== this._restarts || t - n.samples >= Wa(t)) && this.build(e);
|
|
1944
|
+
}
|
|
1945
|
+
build(e = this.context) {
|
|
1946
|
+
let t = e?.getTexture("pathtracer:color"), n = t?.image?.width | 0, r = t?.image?.height | 0;
|
|
1947
|
+
if (!t || n < 1 || r < 1 || this._disposed) return !1;
|
|
1948
|
+
this._builtAt.restarts = this._restarts, this._builtAt.samples = e.getState("pathtracer:samples") ?? 0, this._stale = !1;
|
|
1949
|
+
let i = Math.min(Va, Math.ceil(n / Oa)), a = Math.min(Va, Math.ceil(r / Oa)), o = Math.min(Ha, Math.ceil(n / Ia)), s = Math.min(Ha, Math.ceil(r / Ia)), c = Math.log2(Math.max(this.renderer.toneMappingExposure, 1e-6));
|
|
1950
|
+
return this._inputNode.value = t, this._widthU.value = n, this._heightU.value = r, this._cellsXU.value = i, this._blurWU.value = o, this._blurHU.value = s, this._radiusU.value = Math.max(1, Ra / 100 * o), this._logExposureU.value = c, this._kernels[0].dispatchSize = [
|
|
1951
|
+
i,
|
|
1952
|
+
a,
|
|
1953
|
+
1
|
|
1954
|
+
], this._kernels[1].dispatchSize = [
|
|
1955
|
+
o,
|
|
1956
|
+
s,
|
|
1957
|
+
1
|
|
1958
|
+
], this._kernels[2].dispatchSize = this._kernels[3].dispatchSize = [
|
|
1959
|
+
Math.ceil(o / 8),
|
|
1960
|
+
Math.ceil(s / 8),
|
|
1961
|
+
1
|
|
1962
|
+
], this.renderer.compute(this._kernels), this._params.set([
|
|
1963
|
+
n / Oa,
|
|
1964
|
+
r / Oa,
|
|
1965
|
+
n / Ia,
|
|
1966
|
+
r / Ia,
|
|
1967
|
+
i,
|
|
1968
|
+
a,
|
|
1969
|
+
o,
|
|
1970
|
+
s,
|
|
1971
|
+
c
|
|
1972
|
+
], 0), this._built = !0, this._writeParams(), !0;
|
|
1973
|
+
}
|
|
1974
|
+
_writeParams() {
|
|
1975
|
+
let e = this._params;
|
|
1976
|
+
e[9] = this.highlightContrast, e[10] = this.shadowContrast, e[11] = this.detailStrength, e[12] = La, e[13] = za;
|
|
1977
|
+
for (let t = 0; t < 4; t++) this._p[t].value.fromArray(e, t * 4);
|
|
1978
|
+
this.onChange?.();
|
|
1979
|
+
}
|
|
1980
|
+
get wantsBuild() {
|
|
1981
|
+
return this.enabled && (this._stale || !this._built);
|
|
1624
1982
|
}
|
|
1625
1983
|
updateParameters(e) {
|
|
1626
|
-
|
|
1984
|
+
for (let t of [
|
|
1985
|
+
"highlightContrast",
|
|
1986
|
+
"shadowContrast",
|
|
1987
|
+
"detailStrength"
|
|
1988
|
+
]) e[t] !== void 0 && (this[t] = e[t]);
|
|
1989
|
+
this._writeParams();
|
|
1990
|
+
}
|
|
1991
|
+
setEnabled(e) {
|
|
1992
|
+
this.enabled !== e && (this.enabled = e, this._stale = !0, this.onChange?.());
|
|
1993
|
+
}
|
|
1994
|
+
gainNode(e, t) {
|
|
1995
|
+
let n = Jn(this._grid.value, "vec2", Va * Va * Aa).toReadOnly(), r = Jn(this._blur.value, "float", Ha * Ha).toReadOnly(), [i, a, o, s] = this._p;
|
|
1996
|
+
return En(([e, t]) => {
|
|
1997
|
+
let c = Vn(R(Fn(e, J(...Ua, 0).xyz), Ba)).min(Pa).toVar(), l = Vn(Yn).toVar(), u = I(a.zw), d = t.mul(i.zw).sub(.5).clamp(K(0), K(u.sub(F(1)))).toVar(), f = I(zn(d)).toVar(), p = f.add(F(1)).min(u.sub(F(1))).toVar(), m = d.sub(zn(d)).toVar(), h = (e, t) => r.element(W(t.mul(u.x).add(e))), g = z(z(h(f.x, f.y), h(p.x, f.y), m.x), z(h(f.x, p.y), h(p.x, p.y), m.x), m.y).toVar(), _ = I(a.xy), v = t.mul(i.xy).sub(.5).clamp(K(0), K(_.sub(F(1)))).toVar(), y = c.add(o.x).sub(ja).div(Ma - ja).clamp(0, 1).mul(Aa - 1).toVar(), b = F(zn(v.x)), x = F(zn(v.y)), S = F(zn(y)), ee = v.x.sub(zn(v.x)), C = v.y.sub(zn(v.y)), w = y.sub(zn(y)), T = K(0).toVar();
|
|
1998
|
+
for (let e = 0; e < 8; e++) {
|
|
1999
|
+
let t = e & 1, r = e >> 1 & 1, i = e >> 2, a = (t ? ee : ee.oneMinus()).mul(r ? C : C.oneMinus()).mul(i ? w : w.oneMinus()), o = b.add(F(t)).min(_.x.sub(F(1))), s = x.add(F(r)).min(_.y.sub(F(1))), c = S.add(F(i)).min(F(Aa - 1));
|
|
2000
|
+
T.addAssign(n.element(W(s.mul(_.x).add(o).mul(F(Aa)).add(c))).mul(a));
|
|
2001
|
+
}
|
|
2002
|
+
let E = z(V(T.y.mul(ka).lessThan(.001), g, T.x.div(T.y)), g, s.x).add(l).toVar(), te = c.add(l), D = V(E.greaterThan(s.y), o.y, o.z);
|
|
2003
|
+
return Ln(s.y.add(E.sub(s.y).mul(D)).add(te.sub(E).mul(o.w)).sub(te));
|
|
2004
|
+
})(e, t);
|
|
2005
|
+
}
|
|
2006
|
+
toneGain() {
|
|
2007
|
+
if (!this.enabled || !this._built) return null;
|
|
2008
|
+
let e = this.renderer.backend, t = e.get(this._grid.value)?.buffer, n = e.get(this._blur.value)?.buffer;
|
|
2009
|
+
if (!t || !n) return null;
|
|
2010
|
+
this._paramsBuffer ??= e.device.createBuffer({
|
|
2011
|
+
label: "local-exposure-params",
|
|
2012
|
+
size: 64,
|
|
2013
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
2014
|
+
}), e.device.queue.writeBuffer(this._paramsBuffer, 0, this._params);
|
|
2015
|
+
let r = this._params.slice(), i = () => Promise.all([this.renderer.getArrayBufferAsync(this._grid.value), this.renderer.getArrayBufferAsync(this._blur.value)]);
|
|
2016
|
+
return {
|
|
2017
|
+
key: "local-exposure",
|
|
2018
|
+
wgsl: qa,
|
|
2019
|
+
device: e.device,
|
|
2020
|
+
entries: [
|
|
2021
|
+
{
|
|
2022
|
+
binding: 0,
|
|
2023
|
+
resource: { buffer: t }
|
|
2024
|
+
},
|
|
2025
|
+
{
|
|
2026
|
+
binding: 1,
|
|
2027
|
+
resource: { buffer: n }
|
|
2028
|
+
},
|
|
2029
|
+
{
|
|
2030
|
+
binding: 2,
|
|
2031
|
+
resource: { buffer: this._paramsBuffer }
|
|
2032
|
+
}
|
|
2033
|
+
],
|
|
2034
|
+
cpu: async () => {
|
|
2035
|
+
let [e, t] = await i(), n = new Float32Array(e), a = new Float32Array(t);
|
|
2036
|
+
return (e, t, i, o) => Ka(r, n, a, e, t, i, o);
|
|
2037
|
+
},
|
|
2038
|
+
copyTo: async (e) => {
|
|
2039
|
+
let [t, n] = await i(), a = [
|
|
2040
|
+
[t, GPUBufferUsage.STORAGE],
|
|
2041
|
+
[n, GPUBufferUsage.STORAGE],
|
|
2042
|
+
[r, GPUBufferUsage.UNIFORM]
|
|
2043
|
+
].map(([t, n]) => {
|
|
2044
|
+
let r = e.createBuffer({
|
|
2045
|
+
label: "local-exposure-copy",
|
|
2046
|
+
size: t.byteLength,
|
|
2047
|
+
usage: n | GPUBufferUsage.COPY_DST
|
|
2048
|
+
});
|
|
2049
|
+
return e.queue.writeBuffer(r, 0, t), r;
|
|
2050
|
+
});
|
|
2051
|
+
return {
|
|
2052
|
+
key: "local-exposure",
|
|
2053
|
+
wgsl: qa,
|
|
2054
|
+
device: e,
|
|
2055
|
+
entries: a.map((e, t) => ({
|
|
2056
|
+
binding: t,
|
|
2057
|
+
resource: { buffer: e }
|
|
2058
|
+
})),
|
|
2059
|
+
destroy: () => a.forEach((e) => e.destroy())
|
|
2060
|
+
};
|
|
2061
|
+
}
|
|
2062
|
+
};
|
|
1627
2063
|
}
|
|
2064
|
+
reset() {}
|
|
2065
|
+
setSize() {}
|
|
1628
2066
|
dispose() {
|
|
1629
|
-
this.
|
|
2067
|
+
this._disposed = !0, this.onChange = null;
|
|
2068
|
+
for (let e of this._kernels) e.dispose();
|
|
2069
|
+
this._inputNode.dispose(), this._paramsBuffer?.destroy(), this._paramsBuffer = null;
|
|
1630
2070
|
}
|
|
1631
|
-
},
|
|
1632
|
-
function
|
|
1633
|
-
return
|
|
2071
|
+
}, Ya = new $(), Xa = new $();
|
|
2072
|
+
function Za(e, t) {
|
|
2073
|
+
return Xa.subVectors(e, t.position).dot(t.getWorldDirection(Ya));
|
|
1634
2074
|
}
|
|
1635
|
-
function
|
|
1636
|
-
return n ? e.distance :
|
|
2075
|
+
function Qa(e, t, n = !1) {
|
|
2076
|
+
return n ? e.distance : Za(e.point, t);
|
|
1637
2077
|
}
|
|
1638
|
-
var
|
|
2078
|
+
var $a = class extends fr {
|
|
1639
2079
|
constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a, isGeometryOnDisk: o = null }) {
|
|
1640
|
-
super(), this.scene = e, this.isGeometryOnDisk = o, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new
|
|
2080
|
+
super(), this.scene = e, this.isGeometryOnDisk = o, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new Ar(), this.focusMode = !1, this.focusPointIndicator = null, this.afPointPlacementMode = !1, this.handleAFPointClick = this.handleAFPointClick.bind(this), this.selectedObject = null, this.selectMode = !1, this.clickTimeout = null, this.mouseDownPosition = null, this.dragThreshold = 5, this.handleFocusClick = this.handleFocusClick.bind(this), this.handleSelectClick = this.handleSelectClick.bind(this), this.handleSelectDoubleClick = this.handleSelectDoubleClick.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), this.handleMouseUp = this.handleMouseUp.bind(this), this.handleContextMenu = this.handleContextMenu.bind(this), this.handleContextPointerDown = this.handleContextPointerDown.bind(this), this.handleContextPointerUp = this.handleContextPointerUp.bind(this), this.contextPointerDownPosition = null, this.canvas.addEventListener("pointerdown", this.handleContextPointerDown), this.canvas.addEventListener("pointerup", this.handleContextPointerUp), this.canvas.addEventListener("contextmenu", this.handleContextMenu), this._overlayManager = null, this._transformManager = null, this._appDispatch = null, this._orbitControls = null, this._helperScene = null;
|
|
1641
2081
|
}
|
|
1642
2082
|
setDependencies({ overlayManager: e, transformManager: t, appDispatch: n, orbitControls: r, helperScene: i }) {
|
|
1643
2083
|
this._overlayManager = e || null, this._transformManager = t || null, this._appDispatch = n || null, this._orbitControls = r || null, this._helperScene = i || null;
|
|
@@ -1669,7 +2109,7 @@ var ca = class extends cr {
|
|
|
1669
2109
|
this.raycaster.setFromCamera(t, this.camera);
|
|
1670
2110
|
let n = this._intersectScene();
|
|
1671
2111
|
if (n.length > 0) {
|
|
1672
|
-
let e = n[0], t = this.pathTracer?.cameraProjection?.value === Ae.equirectangular, r =
|
|
2112
|
+
let e = n[0], t = this.pathTracer?.cameraProjection?.value === Ae.equirectangular, r = Qa(e, this.camera, t);
|
|
1673
2113
|
this.showFocusPoint(e.point), this.toggleFocusMode(), this.dispatchEvent({
|
|
1674
2114
|
type: "focusChanged",
|
|
1675
2115
|
distance: r / this.assetLoader.getSceneScale(),
|
|
@@ -1678,7 +2118,7 @@ var ca = class extends cr {
|
|
|
1678
2118
|
}
|
|
1679
2119
|
}
|
|
1680
2120
|
showFocusPoint(e) {
|
|
1681
|
-
this.focusPointIndicator && this.scene.remove(this.focusPointIndicator), this.focusPointIndicator = new
|
|
2121
|
+
this.focusPointIndicator && this.scene.remove(this.focusPointIndicator), this.focusPointIndicator = new xr(new Pr(this.assetLoader.getSceneScale() * .02, 16, 16), new Sr({
|
|
1682
2122
|
color: 65280,
|
|
1683
2123
|
transparent: !0,
|
|
1684
2124
|
opacity: .8,
|
|
@@ -1880,7 +2320,7 @@ var ca = class extends cr {
|
|
|
1880
2320
|
dispose() {
|
|
1881
2321
|
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;
|
|
1882
2322
|
}
|
|
1883
|
-
},
|
|
2323
|
+
}, eo = 8, to = 4, no = .25, ro = vr.degToRad(89), io = .25, ao = {
|
|
1884
2324
|
KeyD: [
|
|
1885
2325
|
1,
|
|
1886
2326
|
0,
|
|
@@ -1931,15 +2371,15 @@ var ca = class extends cr {
|
|
|
1931
2371
|
0,
|
|
1932
2372
|
-1
|
|
1933
2373
|
]
|
|
1934
|
-
},
|
|
2374
|
+
}, oo = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=textbox], [role=combobox], [role=listbox], [role=menu], [role=menuitem]", so = (e) => e.shiftKey ? to : e.altKey ? no : 1, co = { type: "change" }, lo = { type: "start" }, uo = new $(), fo = new $(), po = new $(), mo = new $(), ho = new kr(), go = class extends cr {
|
|
1935
2375
|
constructor(e, t, n) {
|
|
1936
|
-
super(e, t), this.orbit = n, this.enabled = !1, this.speed = 1 /
|
|
2376
|
+
super(e, t), this.orbit = n, this.enabled = !1, this.speed = 1 / eo, this._held = /* @__PURE__ */ new Set(), this._factor = 1, this._lastTime = 0, this._drag = null, this._onKeyDown = this._onKeyDown.bind(this), this._onKeyUp = this._onKeyUp.bind(this), this.release = this.release.bind(this), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), t && this.connect(t);
|
|
1937
2377
|
}
|
|
1938
2378
|
get active() {
|
|
1939
2379
|
return this.enabled && this.orbit.enabled;
|
|
1940
2380
|
}
|
|
1941
2381
|
fitSpeed(e) {
|
|
1942
|
-
this.speed = (e > 0 ? e : 1) /
|
|
2382
|
+
this.speed = (e > 0 ? e : 1) / eo;
|
|
1943
2383
|
}
|
|
1944
2384
|
connect(e) {
|
|
1945
2385
|
super.connect(e);
|
|
@@ -1959,34 +2399,34 @@ var ca = class extends cr {
|
|
|
1959
2399
|
if (!this._held.size || !this.active) return !1;
|
|
1960
2400
|
let t = 0, n = 0, r = 0;
|
|
1961
2401
|
for (let e of this._held) {
|
|
1962
|
-
let [i, a, o] =
|
|
2402
|
+
let [i, a, o] = ao[e];
|
|
1963
2403
|
t += i, n += a, r += o;
|
|
1964
2404
|
}
|
|
1965
2405
|
if (!t && !n && !r) return !1;
|
|
1966
2406
|
let i = this.object;
|
|
1967
|
-
return
|
|
2407
|
+
return fo.set(1, 0, 0).applyQuaternion(i.quaternion), uo.crossVectors(i.up, fo).normalize(), fo.crossVectors(uo, i.up), po.set(0, 0, 0).addScaledVector(fo, t).addScaledVector(uo, n).addScaledVector(i.up, r).normalize().multiplyScalar(this.speed * this._factor * e), i.position.add(po), this.orbit.target.add(po), i.updateMatrixWorld(), this.dispatchEvent(co), !0;
|
|
1968
2408
|
}
|
|
1969
2409
|
_elapsed() {
|
|
1970
|
-
let e = performance.now(), t = Math.min((e - this._lastTime) / 1e3,
|
|
2410
|
+
let e = performance.now(), t = Math.min((e - this._lastTime) / 1e3, io);
|
|
1971
2411
|
return this._lastTime = e, t;
|
|
1972
2412
|
}
|
|
1973
2413
|
_look(e, t) {
|
|
1974
|
-
let n = this.object, r = this.orbit.target, i = n.position.distanceTo(r) || 1, a =
|
|
1975
|
-
n.quaternion.premultiply(
|
|
1976
|
-
let o = Math.asin(
|
|
1977
|
-
n.quaternion.multiply(
|
|
2414
|
+
let n = this.object, r = this.orbit.target, i = n.position.distanceTo(r) || 1, a = vr.degToRad(n.fov) / (this.domElement.clientHeight || 1);
|
|
2415
|
+
n.quaternion.premultiply(ho.setFromAxisAngle(n.up, e * a)), n.getWorldDirection(uo);
|
|
2416
|
+
let o = Math.asin(vr.clamp(uo.dot(n.up), -1, 1)), s = vr.clamp(o + t * a, -ro, ro);
|
|
2417
|
+
n.quaternion.multiply(ho.setFromAxisAngle(mo.set(1, 0, 0), s - o)), n.updateMatrixWorld(), r.copy(n.position).addScaledVector(n.getWorldDirection(uo), i), this.dispatchEvent(co);
|
|
1978
2418
|
}
|
|
1979
2419
|
_onKeyDown(e) {
|
|
1980
|
-
if (!(!this.active || e.defaultPrevented || e.target?.closest?.(
|
|
2420
|
+
if (!(!this.active || e.defaultPrevented || e.target?.closest?.(oo))) {
|
|
1981
2421
|
if (e.metaKey || e.ctrlKey) {
|
|
1982
2422
|
this.release();
|
|
1983
2423
|
return;
|
|
1984
2424
|
}
|
|
1985
|
-
this._factor =
|
|
2425
|
+
this._factor = so(e), ao[e.code] && (e.preventDefault(), !this._held.has(e.code) && (this._held.add(e.code), this._held.size === 1 && (this._lastTime = performance.now(), this.dispatchEvent(lo))));
|
|
1986
2426
|
}
|
|
1987
2427
|
}
|
|
1988
2428
|
_onKeyUp(e) {
|
|
1989
|
-
this._factor =
|
|
2429
|
+
this._factor = so(e), this._held.delete(e.code);
|
|
1990
2430
|
}
|
|
1991
2431
|
release() {
|
|
1992
2432
|
this._held.clear(), this._factor = 1;
|
|
@@ -2007,24 +2447,24 @@ var ca = class extends cr {
|
|
|
2007
2447
|
_onPointerUp(e) {
|
|
2008
2448
|
this._drag?.id === e.pointerId && (this._drag = null, this.domElement.releasePointerCapture?.(e.pointerId));
|
|
2009
2449
|
}
|
|
2010
|
-
},
|
|
2450
|
+
}, _o = {
|
|
2011
2451
|
autoFocusMode: "auto",
|
|
2012
2452
|
afScreenPoint: {
|
|
2013
2453
|
x: .5,
|
|
2014
2454
|
y: .5
|
|
2015
2455
|
},
|
|
2016
2456
|
afSmoothingFactor: .15
|
|
2017
|
-
},
|
|
2457
|
+
}, vo = .05, yo = 10, bo = .5, xo = Object.freeze(new $(1, 1, 1)), So = (e) => e?.isOrthographicCamera ? (e.top - e.bottom) / e.zoom : null, Co = class extends fr {
|
|
2018
2458
|
constructor(e) {
|
|
2019
2459
|
super();
|
|
2020
2460
|
let t = e.clientWidth, n = e.clientHeight;
|
|
2021
|
-
this.camera = new _(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new
|
|
2461
|
+
this.camera = new _(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new Vr(this.camera, e), this.controls.screenSpacePanning = !0, this.controls.zoomToCursor = !0, this.controls.saveState(), this._reportedOrthoHeight = null, this._reportOrthoHeight = this._reportOrthoHeight.bind(this), this.controls.addEventListener("change", this._reportOrthoHeight), this.walkControls = new go(this.camera, e, this.controls), this.interactionManager = null, this.cameras = [this.camera], this.currentCameraIndex = 0, this._userCameraCounter = 0, this.autoFocusMode = _o.autoFocusMode, this.afScreenPoint = { ..._o.afScreenPoint }, this.afSmoothingFactor = _o.afSmoothingFactor, this._lastValidFocusDistance = null, this._smoothedFocusDistance = null, this._afPointDirty = !1, this._afSuspended = !1, this._afPick = null, this._defaultCameraState = null, this._onResize = null, this._onReset = null, this._getSettings = null, this._applySettings = null;
|
|
2022
2462
|
}
|
|
2023
2463
|
setCameras(e) {
|
|
2024
2464
|
this.cameras = e, this._userCameraCounter = 0, this.resetAutoFocus();
|
|
2025
2465
|
}
|
|
2026
2466
|
addCameraFromView(e) {
|
|
2027
|
-
let t = this.camera, n = t.orthographic ? new
|
|
2467
|
+
let t = this.camera, n = t.orthographic ? new Er(t.left, t.right, t.top, t.bottom, t.near, t.far) : new Dr(t.fov, t.aspect, t.near, t.far);
|
|
2028
2468
|
return n.zoom = t.zoom, n.position.copy(t.position), n.quaternion.copy(t.quaternion), n.scale.copy(t.scale), n.updateMatrixWorld(!0), n.userData.__rayzeeUserCamera = !0, n.userData.__rayzeeEffects = this._captureEffects(), this.controls && (n.userData.__rayzeeOrbitTarget = this.controls.target.clone()), this._userCameraCounter += 1, n.name = e || `View Camera ${this._userCameraCounter}`, this.cameras.push(n), this.cameras.length - 1;
|
|
2029
2469
|
}
|
|
2030
2470
|
removeCamera(e) {
|
|
@@ -2078,11 +2518,11 @@ var ca = class extends cr {
|
|
|
2078
2518
|
target: this.controls ? this.controls.target.clone() : null
|
|
2079
2519
|
}), this.currentCameraIndex = e, e === 0 && this._defaultCameraState) {
|
|
2080
2520
|
let e = this._defaultCameraState;
|
|
2081
|
-
this.camera.position.copy(e.position), this.camera.quaternion.copy(e.quaternion), this.camera.scale.copy(e.scale ??
|
|
2521
|
+
this.camera.position.copy(e.position), this.camera.quaternion.copy(e.quaternion), this.camera.scale.copy(e.scale ?? xo), this.camera.fov = e.fov, this.camera.near = e.near, this.camera.far = e.far, this.camera.updateProjectionMatrix(), this.camera.updateMatrixWorld(!0), this.controls && e.target && (this.controls.target.copy(e.target), this.controls.update());
|
|
2082
2522
|
} else this._placeAt(this.cameras[e], t);
|
|
2083
2523
|
this.resetAutoFocus();
|
|
2084
2524
|
let a = this.cameras[e], o = a?.userData?.__rayzeeEffects;
|
|
2085
|
-
this._showOrthographic(o ? o.orthoHeight :
|
|
2525
|
+
this._showOrthographic(o ? o.orthoHeight : So(a)), this._applyEffects(o), n?.(), r?.(), this.dispatchEvent({
|
|
2086
2526
|
type: j.CAMERA_SWITCHED,
|
|
2087
2527
|
cameraIndex: e,
|
|
2088
2528
|
effects: this._captureEffects(),
|
|
@@ -2097,7 +2537,7 @@ var ca = class extends cr {
|
|
|
2097
2537
|
return;
|
|
2098
2538
|
}
|
|
2099
2539
|
this._placeAt(e, this._getSettings?.("focusDistance"));
|
|
2100
|
-
let t =
|
|
2540
|
+
let t = So(e);
|
|
2101
2541
|
this.camera.orthographic && this._setView(!0, t ? t / 2 : this.camera.orthoHalfHeight), this._onReset?.();
|
|
2102
2542
|
}
|
|
2103
2543
|
_placeAt(e, t) {
|
|
@@ -2120,14 +2560,14 @@ var ca = class extends cr {
|
|
|
2120
2560
|
if (t.orthographic !== n) {
|
|
2121
2561
|
if (n) this._setView(!0, this._fittedHalfHeight());
|
|
2122
2562
|
else {
|
|
2123
|
-
let e = this.controls.target, n = this.orthoHeight / 2 / Math.tan(
|
|
2563
|
+
let e = this.controls.target, n = this.orthoHeight / 2 / Math.tan(vr.degToRad(t.fov) / 2);
|
|
2124
2564
|
t.position.sub(e).setLength(n).add(e), this._setView(!1);
|
|
2125
2565
|
}
|
|
2126
2566
|
this.controls.update();
|
|
2127
2567
|
}
|
|
2128
2568
|
}
|
|
2129
2569
|
get orthoHeight() {
|
|
2130
|
-
return
|
|
2570
|
+
return So(this.camera);
|
|
2131
2571
|
}
|
|
2132
2572
|
setOrthoHeight(e) {
|
|
2133
2573
|
e > 0 && (this._setView(this.camera.orthographic, e / 2), this._onReset?.());
|
|
@@ -2140,7 +2580,7 @@ var ca = class extends cr {
|
|
|
2140
2580
|
n.orthographic = e, n.orthoHalfHeight = t, n.zoom = 1, n.updateProjectionMatrix(), this._reportOrthoHeight();
|
|
2141
2581
|
}
|
|
2142
2582
|
_fittedHalfHeight() {
|
|
2143
|
-
return this.camera.position.distanceTo(this.controls.target) * Math.tan(
|
|
2583
|
+
return this.camera.position.distanceTo(this.controls.target) * Math.tan(vr.degToRad(this.camera.fov) / 2);
|
|
2144
2584
|
}
|
|
2145
2585
|
_reportOrthoHeight() {
|
|
2146
2586
|
if (!this.camera.orthographic) return;
|
|
@@ -2161,7 +2601,7 @@ var ca = class extends cr {
|
|
|
2161
2601
|
this.walkControls.release();
|
|
2162
2602
|
let r = this.interactionManager?.pickSurface(0, 0);
|
|
2163
2603
|
if (!r) return;
|
|
2164
|
-
let i =
|
|
2604
|
+
let i = vr.clamp(r.distance, n.minDistance, n.maxDistance);
|
|
2165
2605
|
n.target.copy(this.camera.position).addScaledVector(this.camera.getWorldDirection(new $()), i), n.update();
|
|
2166
2606
|
}
|
|
2167
2607
|
get navigationMode() {
|
|
@@ -2217,7 +2657,7 @@ var ca = class extends cr {
|
|
|
2217
2657
|
let n = {
|
|
2218
2658
|
index: t,
|
|
2219
2659
|
name: e.name ?? "",
|
|
2220
|
-
effects:
|
|
2660
|
+
effects: ue(e.userData?.__rayzeeEffects) ?? null
|
|
2221
2661
|
};
|
|
2222
2662
|
return t === 0 || !e.userData?.__rayzeeUserCamera ? n : {
|
|
2223
2663
|
...n,
|
|
@@ -2249,7 +2689,7 @@ var ca = class extends cr {
|
|
|
2249
2689
|
let n = /* @__PURE__ */ new Map();
|
|
2250
2690
|
for (let r of e.cameras ?? []) {
|
|
2251
2691
|
if (r.user) {
|
|
2252
|
-
let e = r.orthographic ? new
|
|
2692
|
+
let e = r.orthographic ? new Er(...r.frustum, r.near, r.far) : new Dr(r.fov, r.aspect, r.near, r.far);
|
|
2253
2693
|
e.name = r.name, e.zoom = r.zoom ?? 1, e.position.fromArray(r.position), e.quaternion.fromArray(r.quaternion), e.scale.fromArray(r.scale), e.updateProjectionMatrix(), e.updateMatrixWorld(!0), e.userData.__rayzeeUserCamera = !0, e.userData.__rayzeeEffects = me(r.effects), r.orbitTarget && (e.userData.__rayzeeOrbitTarget = new $().fromArray(r.orbitTarget)), n.set(r.index, this.cameras.length), this.cameras.push(e);
|
|
2254
2694
|
continue;
|
|
2255
2695
|
}
|
|
@@ -2264,7 +2704,7 @@ var ca = class extends cr {
|
|
|
2264
2704
|
let r = e.defaultView;
|
|
2265
2705
|
this._defaultCameraState = r ? {
|
|
2266
2706
|
position: new $().fromArray(r.position),
|
|
2267
|
-
quaternion: new
|
|
2707
|
+
quaternion: new kr().fromArray(r.quaternion),
|
|
2268
2708
|
scale: new $().fromArray(r.scale),
|
|
2269
2709
|
fov: r.fov,
|
|
2270
2710
|
near: r.near,
|
|
@@ -2321,14 +2761,14 @@ var ca = class extends cr {
|
|
|
2321
2761
|
let c = i;
|
|
2322
2762
|
if (c?.isReady && c.renderMode?.value === 1 && c.frameCount > 0 && !c.isComplete) return;
|
|
2323
2763
|
let l = this._pickFocusPoint(c.resetCount), u;
|
|
2324
|
-
if (l) u =
|
|
2764
|
+
if (l) u = Za(l, this.camera), this._lastValidFocusDistance = u;
|
|
2325
2765
|
else if (this._lastValidFocusDistance !== null) u = this._lastValidFocusDistance;
|
|
2326
2766
|
else {
|
|
2327
|
-
let e = this.controls ?
|
|
2328
|
-
u = e > 0 ? e :
|
|
2767
|
+
let e = this.controls ? Za(this.controls.target, this.camera) : 0;
|
|
2768
|
+
u = e > 0 ? e : yo * (n?.getSceneScale() || 1), this._lastValidFocusDistance = u;
|
|
2329
2769
|
}
|
|
2330
2770
|
let d = this._afPointDirty;
|
|
2331
|
-
this._afPointDirty = !1, d || this._smoothedFocusDistance === null || this._smoothedFocusDistance === 0 || Math.abs(u - this._smoothedFocusDistance) / this._smoothedFocusDistance >
|
|
2771
|
+
this._afPointDirty = !1, d || this._smoothedFocusDistance === null || this._smoothedFocusDistance === 0 || Math.abs(u - this._smoothedFocusDistance) / this._smoothedFocusDistance > bo ? this._smoothedFocusDistance = u : this._smoothedFocusDistance += this.afSmoothingFactor * (u - this._smoothedFocusDistance);
|
|
2332
2772
|
let f = r, p = this._smoothedFocusDistance;
|
|
2333
2773
|
if (d || f === 0 || Math.abs(p - f) / Math.max(f, .001) > .001) {
|
|
2334
2774
|
a(p);
|
|
@@ -2339,7 +2779,7 @@ var ca = class extends cr {
|
|
|
2339
2779
|
worldDistance: p
|
|
2340
2780
|
});
|
|
2341
2781
|
let t = Math.abs(p - f) / Math.max(f, .001);
|
|
2342
|
-
d ? s?.() : t >
|
|
2782
|
+
d ? s?.() : t > vo && o?.();
|
|
2343
2783
|
}
|
|
2344
2784
|
}
|
|
2345
2785
|
_pickFocusPoint(e) {
|
|
@@ -2349,8 +2789,8 @@ var ca = class extends cr {
|
|
|
2349
2789
|
resetCount: NaN,
|
|
2350
2790
|
x: NaN,
|
|
2351
2791
|
y: NaN,
|
|
2352
|
-
view: new
|
|
2353
|
-
projection: new
|
|
2792
|
+
view: new br(),
|
|
2793
|
+
projection: new br()
|
|
2354
2794
|
};
|
|
2355
2795
|
if (this._afPointDirty || e !== i.resetCount || n !== i.x || r !== i.y || !i.view.equals(t.matrixWorld) || !i.projection.equals(t.projectionMatrix)) {
|
|
2356
2796
|
let a = this.interactionManager.pickSurface(n * 2 - 1, 1 - r * 2);
|
|
@@ -2373,7 +2813,7 @@ var ca = class extends cr {
|
|
|
2373
2813
|
dispose() {
|
|
2374
2814
|
this.walkControls?.dispose(), this.controls?.removeEventListener("change", this._reportOrthoHeight), this.controls?.dispose();
|
|
2375
2815
|
}
|
|
2376
|
-
},
|
|
2816
|
+
}, wo = .001, To = 2, Eo = (e, t, n, r) => new e(t, n, r, hr).createInterpolant(), Do = class {
|
|
2377
2817
|
constructor(e, t) {
|
|
2378
2818
|
this._cameraManager = e, this._onChange = t, this.keys = [], this._nextId = 1, this._interpolants = null;
|
|
2379
2819
|
}
|
|
@@ -2383,7 +2823,7 @@ var ca = class extends cr {
|
|
|
2383
2823
|
get duration() {
|
|
2384
2824
|
return this.keys.length ? this.keys[this.keys.length - 1].time : 0;
|
|
2385
2825
|
}
|
|
2386
|
-
addKey(e = this.keys.length ? this.duration +
|
|
2826
|
+
addKey(e = this.keys.length ? this.duration + To : 0) {
|
|
2387
2827
|
return this.add(this._cameraManager.captureView(), e);
|
|
2388
2828
|
}
|
|
2389
2829
|
updateKey(e) {
|
|
@@ -2397,13 +2837,13 @@ var ca = class extends cr {
|
|
|
2397
2837
|
let n = {
|
|
2398
2838
|
id: this._nextId++,
|
|
2399
2839
|
time: t,
|
|
2400
|
-
...
|
|
2840
|
+
...Oo(e)
|
|
2401
2841
|
};
|
|
2402
2842
|
return this.keys.push(n), this._changed(), n;
|
|
2403
2843
|
}
|
|
2404
2844
|
update(e, t) {
|
|
2405
2845
|
let n = this.get(e);
|
|
2406
|
-
n && (Object.assign(n,
|
|
2846
|
+
n && (Object.assign(n, Oo(t)), this._changed());
|
|
2407
2847
|
}
|
|
2408
2848
|
setTime(e, t) {
|
|
2409
2849
|
let n = this.get(e);
|
|
@@ -2448,12 +2888,12 @@ var ca = class extends cr {
|
|
|
2448
2888
|
orthoHeight: 0
|
|
2449
2889
|
}) {
|
|
2450
2890
|
if (!this.keys.length) return null;
|
|
2451
|
-
let { position: n, target: r, fov: i, logHeight: a, start: o, end: s } = this._interpolants ??= this._build(), c =
|
|
2891
|
+
let { position: n, target: r, fov: i, logHeight: a, start: o, end: s } = this._interpolants ??= this._build(), c = vr.clamp(e, o, s);
|
|
2452
2892
|
return t.position.fromArray(n.evaluate(c)), t.target.fromArray(r.evaluate(c)), t.fov = i.evaluate(c)[0], t.orthoHeight = Math.exp(a.evaluate(c)[0]), t;
|
|
2453
2893
|
}
|
|
2454
2894
|
_build() {
|
|
2455
2895
|
let e = [];
|
|
2456
|
-
for (let t of this.keys) e.push(e.length ? Math.max(t.time, e[e.length - 1] +
|
|
2896
|
+
for (let t of this.keys) e.push(e.length ? Math.max(t.time, e[e.length - 1] + wo) : t.time);
|
|
2457
2897
|
let t = e[0], n = e[e.length - 1], r = this.keys;
|
|
2458
2898
|
if (r.length > 1) {
|
|
2459
2899
|
let i = r.length;
|
|
@@ -2467,17 +2907,17 @@ var ca = class extends cr {
|
|
|
2467
2907
|
return {
|
|
2468
2908
|
start: t,
|
|
2469
2909
|
end: n,
|
|
2470
|
-
position:
|
|
2471
|
-
target:
|
|
2472
|
-
fov:
|
|
2473
|
-
logHeight:
|
|
2910
|
+
position: Eo(Br, ".position", e, i((e) => e.position)),
|
|
2911
|
+
target: Eo(Br, ".target", e, i((e) => e.target)),
|
|
2912
|
+
fov: Eo(wr, ".fov", e, r.map((e) => e.fov)),
|
|
2913
|
+
logHeight: Eo(wr, ".orthoHeight", e, r.map((e) => Math.log(e.orthoHeight)))
|
|
2474
2914
|
};
|
|
2475
2915
|
}
|
|
2476
2916
|
_changed() {
|
|
2477
2917
|
this.keys.sort((e, t) => e.time - t.time), this._interpolants = null, this._onChange?.();
|
|
2478
2918
|
}
|
|
2479
2919
|
};
|
|
2480
|
-
function
|
|
2920
|
+
function Oo({ position: e, target: t, fov: n, orthoHeight: r }) {
|
|
2481
2921
|
return {
|
|
2482
2922
|
position: e.clone(),
|
|
2483
2923
|
target: t.clone(),
|
|
@@ -2487,9 +2927,9 @@ function Ia({ position: e, target: t, fov: n, orthoHeight: r }) {
|
|
|
2487
2927
|
}
|
|
2488
2928
|
//#endregion
|
|
2489
2929
|
//#region src/managers/timeline/TimelineManager.js
|
|
2490
|
-
var
|
|
2930
|
+
var ko = class extends fr {
|
|
2491
2931
|
constructor({ cameraManager: e, onReset: t }) {
|
|
2492
|
-
super(), this._cameraManager = e, this._onReset = t, this.camera = new
|
|
2932
|
+
super(), this._cameraManager = e, this._onReset = t, this.camera = new Do(e, () => this._changed("camera")), this._playback = null, this._timer = new Fr(), typeof document < "u" && this._timer.connect(document);
|
|
2493
2933
|
}
|
|
2494
2934
|
get duration() {
|
|
2495
2935
|
return this.camera.duration;
|
|
@@ -2521,7 +2961,7 @@ var La = class extends cr {
|
|
|
2521
2961
|
let e = this._playback;
|
|
2522
2962
|
if (!e) return;
|
|
2523
2963
|
this._timer.update(), e.elapsed += this._timer.getDelta();
|
|
2524
|
-
let t =
|
|
2964
|
+
let t = vr.clamp(e.elapsed, 0, this.duration);
|
|
2525
2965
|
this.seek(t), t >= this.duration && this.stop();
|
|
2526
2966
|
}
|
|
2527
2967
|
serialize() {
|
|
@@ -2542,14 +2982,14 @@ var La = class extends cr {
|
|
|
2542
2982
|
track: e
|
|
2543
2983
|
});
|
|
2544
2984
|
}
|
|
2545
|
-
},
|
|
2985
|
+
}, Ao = class {
|
|
2546
2986
|
constructor(e, t = {}) {
|
|
2547
2987
|
this.pathTracer = e, this._onReset = t.onReset || null, this._issues = t.issues ?? null, this.texture = null, this.entries = [], this._size = 256;
|
|
2548
2988
|
}
|
|
2549
2989
|
async loadLibrary(e, { size: t = 256 } = {}) {
|
|
2550
2990
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
2551
2991
|
this._size = t;
|
|
2552
|
-
let n = await Promise.all(e.map((e) =>
|
|
2992
|
+
let n = await Promise.all(e.map((e) => jo(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
|
|
2553
2993
|
s.width = r, s.height = i;
|
|
2554
2994
|
let c = s.getContext("2d", { willReadFrequently: !0 }), l = performance.now();
|
|
2555
2995
|
for (let e = 0; e < a; e++) {
|
|
@@ -2557,8 +2997,8 @@ var La = class extends cr {
|
|
|
2557
2997
|
let t = c.getImageData(0, 0, r, i);
|
|
2558
2998
|
o.set(t.data, e * r * i * 4), performance.now() - l > 16 && (await new Promise((e) => setTimeout(e, 0)), l = performance.now());
|
|
2559
2999
|
}
|
|
2560
|
-
let u = new
|
|
2561
|
-
u.minFilter = X, u.magFilter = X, u.format = Q, u.type =
|
|
3000
|
+
let u = new ur(o, r, i, a);
|
|
3001
|
+
u.minFilter = X, u.magFilter = X, u.format = Q, u.type = Ir, u.generateMipmaps = !1, u.needsUpdate = !0;
|
|
2562
3002
|
let d = this.texture;
|
|
2563
3003
|
return this.texture = u, this.entries = e.map((e, t) => ({
|
|
2564
3004
|
name: e.name,
|
|
@@ -2581,7 +3021,7 @@ var La = class extends cr {
|
|
|
2581
3021
|
o.userData.gobo = {
|
|
2582
3022
|
name: e.name,
|
|
2583
3023
|
index: e.index,
|
|
2584
|
-
intensity:
|
|
3024
|
+
intensity: Mo(r),
|
|
2585
3025
|
inverted: !!i,
|
|
2586
3026
|
scale: Math.max(1e-4, a)
|
|
2587
3027
|
};
|
|
@@ -2623,7 +3063,7 @@ var La = class extends cr {
|
|
|
2623
3063
|
return t && t.isSpotLight ? t : null;
|
|
2624
3064
|
}
|
|
2625
3065
|
};
|
|
2626
|
-
async function
|
|
3066
|
+
async function jo(e) {
|
|
2627
3067
|
let t = await v(e);
|
|
2628
3068
|
try {
|
|
2629
3069
|
return await new Promise((n, r) => {
|
|
@@ -2634,22 +3074,22 @@ async function za(e) {
|
|
|
2634
3074
|
t.release();
|
|
2635
3075
|
}
|
|
2636
3076
|
}
|
|
2637
|
-
function
|
|
3077
|
+
function Mo(e) {
|
|
2638
3078
|
return Math.max(0, Math.min(1, e));
|
|
2639
3079
|
}
|
|
2640
3080
|
//#endregion
|
|
2641
3081
|
//#region src/Processor/IESParser.js
|
|
2642
|
-
function
|
|
3082
|
+
function No(e, t = "ies") {
|
|
2643
3083
|
let n = e.search(/TILT\s*=/i);
|
|
2644
3084
|
if (n < 0) throw Error(`IES (${t}): missing TILT line`);
|
|
2645
3085
|
let r = e.indexOf("\n", n);
|
|
2646
3086
|
if (r < 0) throw Error(`IES (${t}): truncated TILT line`);
|
|
2647
3087
|
let i = e.slice(n, r).match(/TILT\s*=\s*(\w+)/i), a = i ? i[1].toUpperCase() : "NONE", o = e.slice(r);
|
|
2648
3088
|
if (a === "INCLUDE") {
|
|
2649
|
-
let e =
|
|
2650
|
-
o =
|
|
3089
|
+
let e = Ro(o), t = 2 + 2 * Number(e[1]);
|
|
3090
|
+
o = zo(o, t);
|
|
2651
3091
|
}
|
|
2652
|
-
let s =
|
|
3092
|
+
let s = Ro(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
|
|
2653
3093
|
l(), l(), l(), l();
|
|
2654
3094
|
let g = l();
|
|
2655
3095
|
if (l(), l(), !Number.isFinite(p) || p <= 0) throw Error(`IES (${t}): invalid vertical angle count ${p}`);
|
|
@@ -2675,34 +3115,34 @@ function Va(e, t = "ies") {
|
|
|
2675
3115
|
name: t
|
|
2676
3116
|
};
|
|
2677
3117
|
}
|
|
2678
|
-
function
|
|
3118
|
+
function Po(e, t, n) {
|
|
2679
3119
|
if (t === 0 && n === 90) {
|
|
2680
3120
|
let t = e % 180;
|
|
2681
3121
|
return t > 90 ? 180 - t : t;
|
|
2682
3122
|
}
|
|
2683
3123
|
return t === 0 && n === 180 ? e > 180 ? 360 - e : e : t === 90 && n === 270 ? e >= 90 && e <= 270 ? e : (540 - e) % 360 : e;
|
|
2684
3124
|
}
|
|
2685
|
-
function
|
|
3125
|
+
function Fo(e, t, n) {
|
|
2686
3126
|
let r = new Uint8Array(t * n), { verticalAngles: i, horizontalAngles: a, candela: o, maxCandela: s, photometricType: c } = e;
|
|
2687
3127
|
if (s <= 0) return r;
|
|
2688
3128
|
let l = c === void 0 || c === 1, u = i[0], d = i[i.length - 1], f = a[0], p = a[a.length - 1], m = a.length === 1 || p === f, h = (e, t, n, r) => {
|
|
2689
|
-
if (m) return
|
|
3129
|
+
if (m) return Vo(o[e][0], o[t][0], n);
|
|
2690
3130
|
if (r < f || r > p) return 0;
|
|
2691
|
-
let i =
|
|
2692
|
-
return
|
|
3131
|
+
let i = Bo(a, r), s = Math.min(i + 1, a.length - 1), c = a[s] - a[i], l = c > 0 ? (r - a[i]) / c : 0;
|
|
3132
|
+
return Vo(Vo(o[e][i], o[e][s], l), Vo(o[t][i], o[t][s], l), n);
|
|
2693
3133
|
};
|
|
2694
3134
|
for (let e = 0; e < n; e++) {
|
|
2695
3135
|
let a = (e + .5) / n, o = l ? a * 180 : u + a * (d - u);
|
|
2696
3136
|
if (o < u || o > d) continue;
|
|
2697
|
-
let c =
|
|
3137
|
+
let c = Bo(i, o), m = Math.min(c + 1, i.length - 1), g = i[m] - i[c], _ = g > 0 ? (o - i[c]) / g : 0;
|
|
2698
3138
|
for (let n = 0; n < t; n++) {
|
|
2699
|
-
let i = (n + .5) / t, a = l ?
|
|
3139
|
+
let i = (n + .5) / t, a = l ? Po(i * 360, f, p) : f + i * (p - f), o = Math.min(1, Math.max(0, h(c, m, _, a) / s));
|
|
2700
3140
|
r[e * t + n] = Math.round(o * 255);
|
|
2701
3141
|
}
|
|
2702
3142
|
}
|
|
2703
3143
|
return r;
|
|
2704
3144
|
}
|
|
2705
|
-
function
|
|
3145
|
+
function Io(e, t = .1) {
|
|
2706
3146
|
let { verticalAngles: n, horizontalAngles: r, candela: i, maxCandela: a } = e, o = Math.PI / 4;
|
|
2707
3147
|
if (a <= 0 || !n?.length) return o;
|
|
2708
3148
|
let s = a * t, c = r.length, l = n[n.length - 1], u = !1;
|
|
@@ -2717,7 +3157,7 @@ function Wa(e, t = .1) {
|
|
|
2717
3157
|
let d = l * Math.PI / 180;
|
|
2718
3158
|
return Math.min(Math.max(d, 5 * Math.PI / 180), 89 * Math.PI / 180);
|
|
2719
3159
|
}
|
|
2720
|
-
function
|
|
3160
|
+
function Lo(e, t, n = .7) {
|
|
2721
3161
|
let { verticalAngles: r, horizontalAngles: i, candela: a, maxCandela: o } = e;
|
|
2722
3162
|
if (o <= 0 || !r?.length || t <= 0) return 0;
|
|
2723
3163
|
let s = o * n, c = i.length, l = 0;
|
|
@@ -2730,15 +3170,15 @@ function Ga(e, t, n = .7) {
|
|
|
2730
3170
|
let u = t * 180 / Math.PI, d = u > 0 ? 1 - l / u : 0;
|
|
2731
3171
|
return Math.min(Math.max(d, 0), 1);
|
|
2732
3172
|
}
|
|
2733
|
-
function
|
|
3173
|
+
function Ro(e) {
|
|
2734
3174
|
return e.split(/\s+/).filter((e) => e.length > 0);
|
|
2735
3175
|
}
|
|
2736
|
-
function
|
|
3176
|
+
function zo(e, t) {
|
|
2737
3177
|
let n = /\S+/g, r = 0;
|
|
2738
3178
|
for (; n.exec(e) !== null;) if (r++, r === t) return e.slice(n.lastIndex);
|
|
2739
3179
|
return "";
|
|
2740
3180
|
}
|
|
2741
|
-
function
|
|
3181
|
+
function Bo(e, t) {
|
|
2742
3182
|
if (t <= e[0]) return 0;
|
|
2743
3183
|
if (t >= e[e.length - 1]) return e.length - 1;
|
|
2744
3184
|
let n = 0, r = e.length - 1;
|
|
@@ -2748,12 +3188,12 @@ function Ja(e, t) {
|
|
|
2748
3188
|
}
|
|
2749
3189
|
return n;
|
|
2750
3190
|
}
|
|
2751
|
-
function
|
|
3191
|
+
function Vo(e, t, n) {
|
|
2752
3192
|
return e + (t - e) * n;
|
|
2753
3193
|
}
|
|
2754
3194
|
//#endregion
|
|
2755
3195
|
//#region src/managers/IESManager.js
|
|
2756
|
-
var
|
|
3196
|
+
var Ho = class {
|
|
2757
3197
|
constructor(e, t = {}) {
|
|
2758
3198
|
this.pathTracer = e, this._onReset = t.onReset || null, this._issues = t.issues ?? null, this.texture = null, this.entries = [], this._gridWidth = 128, this._gridHeight = 128;
|
|
2759
3199
|
}
|
|
@@ -2762,11 +3202,11 @@ var Xa = class {
|
|
|
2762
3202
|
this._gridWidth = t, this._gridHeight = n;
|
|
2763
3203
|
let r = (await Promise.all(e.map(async (e) => {
|
|
2764
3204
|
try {
|
|
2765
|
-
let { file: r, release: i } = await m().fetch(e.url), a =
|
|
3205
|
+
let { file: r, release: i } = await m().fetch(e.url), a = No(await r.text().finally(i), e.name);
|
|
2766
3206
|
return {
|
|
2767
3207
|
it: e,
|
|
2768
3208
|
profile: a,
|
|
2769
|
-
grid:
|
|
3209
|
+
grid: Fo(a, t, n)
|
|
2770
3210
|
};
|
|
2771
3211
|
} catch (t) {
|
|
2772
3212
|
return this._issues?.warn(Ze.ASSET_UNREACHABLE, `IES profile "${e.name}" could not be loaded: ${t.message}`, {
|
|
@@ -2784,19 +3224,19 @@ var Xa = class {
|
|
|
2784
3224
|
let r = t[e];
|
|
2785
3225
|
o[n + e * 4 + 0] = r, o[n + e * 4 + 1] = r, o[n + e * 4 + 2] = r, o[n + e * 4 + 3] = 255;
|
|
2786
3226
|
}
|
|
2787
|
-
let i = r[e].profile, c =
|
|
3227
|
+
let i = r[e].profile, c = Io(i);
|
|
2788
3228
|
s.push({
|
|
2789
3229
|
name: r[e].it.name,
|
|
2790
3230
|
index: e,
|
|
2791
3231
|
maxCandela: i.maxCandela,
|
|
2792
3232
|
photometricType: i.photometricType,
|
|
2793
3233
|
suggestedAngle: c,
|
|
2794
|
-
suggestedPenumbra:
|
|
3234
|
+
suggestedPenumbra: Lo(i, c),
|
|
2795
3235
|
lumens: i.lumens
|
|
2796
3236
|
});
|
|
2797
3237
|
}
|
|
2798
|
-
let c = new
|
|
2799
|
-
c.format = Q, c.type =
|
|
3238
|
+
let c = new ur(o, t, n, i);
|
|
3239
|
+
c.format = Q, c.type = Ir, c.minFilter = X, c.magFilter = X, c.generateMipmaps = !1, c.needsUpdate = !0;
|
|
2800
3240
|
let l = this.texture;
|
|
2801
3241
|
return this.texture = c, this.entries = s, this.pathTracer.iesProfiles = c, this.pathTracer.shaderBuilder?.updateIESProfiles?.(c), l?.dispose?.(), this.entries.map(({ name: e, index: t }) => ({
|
|
2802
3242
|
name: e,
|
|
@@ -2827,7 +3267,7 @@ var Xa = class {
|
|
|
2827
3267
|
l = Number.isFinite(e.lumens) ? e.lumens : null, i.userData.ies = {
|
|
2828
3268
|
name: e.name,
|
|
2829
3269
|
index: e.index,
|
|
2830
|
-
intensity:
|
|
3270
|
+
intensity: Uo(n),
|
|
2831
3271
|
fixtureLumens: l
|
|
2832
3272
|
}, 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);
|
|
2833
3273
|
}
|
|
@@ -2850,16 +3290,16 @@ var Xa = class {
|
|
|
2850
3290
|
return t && t.isSpotLight ? t : null;
|
|
2851
3291
|
}
|
|
2852
3292
|
};
|
|
2853
|
-
function
|
|
3293
|
+
function Uo(e) {
|
|
2854
3294
|
return Math.max(0, Math.min(1, e));
|
|
2855
3295
|
}
|
|
2856
3296
|
//#endregion
|
|
2857
3297
|
//#region src/Passes/OIDNDenoiser.js
|
|
2858
|
-
var
|
|
2859
|
-
async function
|
|
2860
|
-
return
|
|
3298
|
+
var Wo = Ke("oidn"), Go = 16, Ko = null;
|
|
3299
|
+
async function qo() {
|
|
3300
|
+
return Ko ||= (await import("oidn-web/dist/oidn.js")).initUNetFromBuffer, Ko;
|
|
2861
3301
|
}
|
|
2862
|
-
var
|
|
3302
|
+
var Jo = {
|
|
2863
3303
|
QUALITY_MODELS: {
|
|
2864
3304
|
fast: {
|
|
2865
3305
|
model: "rt_hdr_alb_nrm_small",
|
|
@@ -2883,9 +3323,9 @@ var no = {
|
|
|
2883
3323
|
oidnQuality: "fast",
|
|
2884
3324
|
tileSize: 1024
|
|
2885
3325
|
}
|
|
2886
|
-
},
|
|
2887
|
-
const WG: u32 = ${
|
|
2888
|
-
const GROUPS: u32 = ${
|
|
3326
|
+
}, Yo = .18, Xo = 256, Zo = 256, Qo = `
|
|
3327
|
+
const WG: u32 = ${Xo}u;
|
|
3328
|
+
const GROUPS: u32 = ${Zo}u;
|
|
2889
3329
|
|
|
2890
3330
|
@group(0) @binding(0) var<storage, read> col: array<vec4<f32>>;
|
|
2891
3331
|
@group(0) @binding(1) var<storage, read_write> partials: array<f32>;
|
|
@@ -2904,7 +3344,7 @@ fn treeSum( lid: u32 ) {
|
|
|
2904
3344
|
}
|
|
2905
3345
|
}
|
|
2906
3346
|
|
|
2907
|
-
@compute @workgroup_size(${
|
|
3347
|
+
@compute @workgroup_size(${Xo})
|
|
2908
3348
|
fn reduce( @builtin(global_invocation_id) gid: vec3<u32>,
|
|
2909
3349
|
@builtin(local_invocation_id) lid: vec3<u32>,
|
|
2910
3350
|
@builtin(workgroup_id) wid: vec3<u32> ) {
|
|
@@ -2927,7 +3367,7 @@ fn reduce( @builtin(global_invocation_id) gid: vec3<u32>,
|
|
|
2927
3367
|
if ( lid.x == 0u ) { partials[ wid.x ] = sdata[ 0 ]; }
|
|
2928
3368
|
}
|
|
2929
3369
|
|
|
2930
|
-
@compute @workgroup_size(${
|
|
3370
|
+
@compute @workgroup_size(${Xo})
|
|
2931
3371
|
fn finalize( @builtin(local_invocation_id) lid: vec3<u32> ) {
|
|
2932
3372
|
|
|
2933
3373
|
var v = 0.0;
|
|
@@ -2937,12 +3377,12 @@ fn finalize( @builtin(local_invocation_id) lid: vec3<u32> ) {
|
|
|
2937
3377
|
treeSum( lid.x );
|
|
2938
3378
|
|
|
2939
3379
|
if ( lid.x == 0u ) {
|
|
2940
|
-
let scale = ${
|
|
3380
|
+
let scale = ${Yo} / exp2( sdata[ 0 ] / f32( params.x ) );
|
|
2941
3381
|
// Mirrors the CPU guard: a non-finite or non-positive scale means no scaling at all.
|
|
2942
3382
|
scaleOut[ 0 ] = select( 1.0, scale, scale > 0.0 && scale < 3.4e38 );
|
|
2943
3383
|
}
|
|
2944
3384
|
}
|
|
2945
|
-
`,
|
|
3385
|
+
`, $o = "\n@group(0) @binding(0) var<storage, read_write> col: array<vec4<f32>>;\n@group(0) @binding(1) var<storage, read> scaleBuf: array<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 * scaleBuf[ 0 ], c.w );\n}\n", es = 64, ts = 32768, ns = 16, rs = 32, is = `
|
|
2946
3386
|
struct UnpackParams {
|
|
2947
3387
|
srcWidth: u32,
|
|
2948
3388
|
tileX: u32,
|
|
@@ -2960,7 +3400,7 @@ struct UnpackParams {
|
|
|
2960
3400
|
@group(0) @binding(3) var<storage, read> inColor: array<vec4<f32>>;
|
|
2961
3401
|
@group(0) @binding(4) var dst: texture_storage_2d<rgba16float, write>;
|
|
2962
3402
|
|
|
2963
|
-
@compute @workgroup_size(${
|
|
3403
|
+
@compute @workgroup_size(${ns}, ${ns})
|
|
2964
3404
|
fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
2965
3405
|
|
|
2966
3406
|
if ( gid.x >= P.tileW || gid.y >= P.tileH ) { return; }
|
|
@@ -2974,18 +3414,18 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
2974
3414
|
// survives the denoise.
|
|
2975
3415
|
textureStore( dst, vec2<u32>( px, py ), vec4<f32>( src[ si ].xyz / scaleBuf[ 0 ], inColor[ si ].w ) );
|
|
2976
3416
|
}
|
|
2977
|
-
`,
|
|
3417
|
+
`, as = 8, os = `
|
|
2978
3418
|
@group(0) @binding(0) var src: texture_2d<f32>;
|
|
2979
3419
|
@group(0) @binding(1) var<storage, read_write> dst: array<vec4<f32>>;
|
|
2980
3420
|
@group(0) @binding(2) var<uniform> size: vec2<u32>;
|
|
2981
3421
|
|
|
2982
|
-
@compute @workgroup_size(${
|
|
3422
|
+
@compute @workgroup_size(${as}, ${as})
|
|
2983
3423
|
fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
2984
3424
|
|
|
2985
3425
|
if ( gid.x >= size.x || gid.y >= size.y ) { return; }
|
|
2986
3426
|
dst[ gid.y * size.x + gid.x ] = textureLoad( src, gid.xy, 0 );
|
|
2987
3427
|
}
|
|
2988
|
-
`,
|
|
3428
|
+
`, ss = class extends fr {
|
|
2989
3429
|
constructor(e, t = {}) {
|
|
2990
3430
|
if (super(), !e) throw Error("OIDNDenoiser requires a renderer");
|
|
2991
3431
|
this.renderer = e, this._renderWidth = e.domElement.width, this._renderHeight = e.domElement.height, this.backendParamsGetter = t.backendParams || null, this.getGPUTextures = t.getGPUTextures || null, this.gpuDevice = null, this._gpuInputBuffers = {
|
|
@@ -2999,14 +3439,14 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
2999
3439
|
width: 0,
|
|
3000
3440
|
height: 0
|
|
3001
3441
|
}, this.config = {
|
|
3002
|
-
...
|
|
3442
|
+
...Jo.DEFAULT_OPTIONS,
|
|
3003
3443
|
...t
|
|
3004
3444
|
}, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.maxTileSize = this.config.tileSize, this._activeTileSize = 0, this.state = {
|
|
3005
3445
|
isDenoising: !1,
|
|
3006
3446
|
isLoading: !1,
|
|
3007
3447
|
abortController: null
|
|
3008
3448
|
}, this._tilesWritten = 0, this._runId = 0, this._hasOutput = !1, this.lastDenoiseMs = 0, this.currentTZAUrl = null, this.unet = null, this._weights = /* @__PURE__ */ new Map(), this._pendingStart = !1, this._pendingStartContinuous = !1, this._reloadPending = !1, this._initialize().catch((e) => {
|
|
3009
|
-
|
|
3449
|
+
Wo.error("init failed:", e), this.dispatchEvent({
|
|
3010
3450
|
type: "error",
|
|
3011
3451
|
error: e
|
|
3012
3452
|
});
|
|
@@ -3020,7 +3460,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3020
3460
|
}
|
|
3021
3461
|
}
|
|
3022
3462
|
expectsCleanAux(e = this.quality) {
|
|
3023
|
-
let { QUALITY_MODELS: t } =
|
|
3463
|
+
let { QUALITY_MODELS: t } = Jo;
|
|
3024
3464
|
return (t[e] || t.balance).cleanAux;
|
|
3025
3465
|
}
|
|
3026
3466
|
getRuntimeInfo() {
|
|
@@ -3035,8 +3475,8 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3035
3475
|
_resolveTileSize() {
|
|
3036
3476
|
let e = Math.max(this._renderWidth, this._renderHeight);
|
|
3037
3477
|
if (!e) return this.maxTileSize;
|
|
3038
|
-
let t = Math.ceil(e /
|
|
3039
|
-
return t <= this.maxTileSize ? t : Math.max(
|
|
3478
|
+
let t = Math.ceil(e / Go) * Go;
|
|
3479
|
+
return t <= this.maxTileSize ? t : Math.max(Go, Math.floor(this.maxTileSize / Go) * Go);
|
|
3040
3480
|
}
|
|
3041
3481
|
_setupUNetDenoiser() {
|
|
3042
3482
|
return this.state.isLoading ? (this._reloadPending = !0, Promise.resolve()) : (this._loading = this._loadUNet(), this._loading);
|
|
@@ -3050,7 +3490,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3050
3490
|
try {
|
|
3051
3491
|
await this._loadUNetWeights();
|
|
3052
3492
|
} catch (e) {
|
|
3053
|
-
|
|
3493
|
+
Wo.error("UNet weights failed to load:", e), this.dispatchEvent({
|
|
3054
3494
|
type: "error",
|
|
3055
3495
|
error: /* @__PURE__ */ Error(`Denoiser loading failed: ${e.message}`),
|
|
3056
3496
|
url: this._generateTzaUrl()
|
|
@@ -3076,26 +3516,26 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3076
3516
|
let e = this.backendParamsGetter();
|
|
3077
3517
|
this.gpuDevice = e?.device ?? null, n = e?.device ? e : void 0;
|
|
3078
3518
|
}
|
|
3079
|
-
this.unet = await (await
|
|
3519
|
+
this.unet = await (await qo())(await this._fetchWeights(e), n, {
|
|
3080
3520
|
aux: !0,
|
|
3081
3521
|
hdr: !0,
|
|
3082
3522
|
maxTileSize: t,
|
|
3083
3523
|
dynamicTile: !1
|
|
3084
|
-
}), this.currentTZAUrl = e, this._activeTileSize = t, this.dispatchEvent({ type: "loaded" }),
|
|
3524
|
+
}), this.currentTZAUrl = e, this._activeTileSize = t, this.dispatchEvent({ type: "loaded" }), Wo.debug("UNet weights loaded:", e);
|
|
3085
3525
|
}
|
|
3086
3526
|
_fetchWeights(e) {
|
|
3087
3527
|
let t = this._weights.get(e);
|
|
3088
3528
|
return t || (t = m().fetch(e, { policy: C.IMMUTABLE }).then(({ file: e, release: t }) => e.arrayBuffer().finally(t)), t.catch(() => this._weights.delete(e)), this._weights.set(e, t)), t;
|
|
3089
3529
|
}
|
|
3090
3530
|
_generateTzaUrl() {
|
|
3091
|
-
let { oidnWeightsBaseUrl: e } =
|
|
3531
|
+
let { oidnWeightsBaseUrl: e } = ot(), { QUALITY_MODELS: t } = Jo;
|
|
3092
3532
|
return `${e}${(t[this.quality] || t.balance).model}.tza`;
|
|
3093
3533
|
}
|
|
3094
3534
|
async updateConfiguration(e) {
|
|
3095
3535
|
Object.keys(e).some((t) => this.config[t] !== e[t]) && (Object.assign(this.config, e), this.quality = this.config.oidnQuality, this.maxTileSize = this.config.tileSize, await this._setupUNetDenoiser());
|
|
3096
3536
|
}
|
|
3097
3537
|
async updateQuality(e) {
|
|
3098
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
3538
|
+
if (!Object.prototype.hasOwnProperty.call(Jo.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(Jo.QUALITY_MODELS).join(", ")}`);
|
|
3099
3539
|
await this.updateConfiguration({ oidnQuality: e });
|
|
3100
3540
|
}
|
|
3101
3541
|
async start({ continuous: e = !1 } = {}) {
|
|
@@ -3106,7 +3546,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3106
3546
|
continuous: e
|
|
3107
3547
|
});
|
|
3108
3548
|
let t = performance.now(), n = await this.execute(e);
|
|
3109
|
-
return n && (this.renderer?.resetState?.(), this.lastDenoiseMs = performance.now() - t,
|
|
3549
|
+
return n && (this.renderer?.resetState?.(), this.lastDenoiseMs = performance.now() - t, Wo.debug(`denoise complete in ${We.ms(this.lastDenoiseMs)} · quality ${this.quality}`)), n;
|
|
3110
3550
|
}
|
|
3111
3551
|
async execute(e = !1) {
|
|
3112
3552
|
if (!this.enabled || !this.unet) return !1;
|
|
@@ -3115,7 +3555,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3115
3555
|
try {
|
|
3116
3556
|
return await this._executeUNetGPU(e) !== !1;
|
|
3117
3557
|
} catch (e) {
|
|
3118
|
-
return e.name === "AbortError" ?
|
|
3558
|
+
return e.name === "AbortError" ? Wo.debug("denoise aborted") : Wo.error("denoise error:", e), !1;
|
|
3119
3559
|
} finally {
|
|
3120
3560
|
this._runId === t && (this.state.isDenoising = !1, this.state.abortController = null), this.dispatchEvent({
|
|
3121
3561
|
type: "end",
|
|
@@ -3125,11 +3565,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3125
3565
|
}
|
|
3126
3566
|
async _executeUNetGPU(e = !1) {
|
|
3127
3567
|
let t = this._renderWidth, n = this._renderHeight;
|
|
3128
|
-
if (!this.getGPUTextures) return
|
|
3568
|
+
if (!this.getGPUTextures) return Wo.warn("GPU mode enabled but getGPUTextures not provided"), !1;
|
|
3129
3569
|
let r = this.getGPUTextures({ continuous: e });
|
|
3130
|
-
if (!r?.color) return
|
|
3570
|
+
if (!r?.color) return Wo.warn("GPU textures not ready yet"), !1;
|
|
3131
3571
|
let i = this.gpuDevice;
|
|
3132
|
-
if (!i) return
|
|
3572
|
+
if (!i) return Wo.warn("gpuDevice not available"), !1;
|
|
3133
3573
|
this._ensureGPUInputBuffers(t, n), this._copyInputs(i, r, t, n), this._computeInputScale(i, t * n), this._applyColorScale(i, t * n), !e && !this._hasOutput && this._unpackToTexture(this._gpuInputBuffers.color, t, {
|
|
3134
3574
|
x: 0,
|
|
3135
3575
|
y: 0,
|
|
@@ -3173,7 +3613,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3173
3613
|
resource: { buffer: this._packParams }
|
|
3174
3614
|
}
|
|
3175
3615
|
]
|
|
3176
|
-
})), o.dispatchWorkgroups(Math.ceil(n /
|
|
3616
|
+
})), o.dispatchWorkgroups(Math.ceil(n / as), Math.ceil(r / as))) : i.copyTextureToBuffer({
|
|
3177
3617
|
texture: t,
|
|
3178
3618
|
mipLevel: 0
|
|
3179
3619
|
}, {
|
|
@@ -3237,7 +3677,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3237
3677
|
compute: {
|
|
3238
3678
|
module: e.createShaderModule({
|
|
3239
3679
|
label: "oidn-pack",
|
|
3240
|
-
code:
|
|
3680
|
+
code: os
|
|
3241
3681
|
}),
|
|
3242
3682
|
entryPoint: "main"
|
|
3243
3683
|
}
|
|
@@ -3290,7 +3730,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3290
3730
|
});
|
|
3291
3731
|
let t = e.createShaderModule({
|
|
3292
3732
|
label: "oidn-autoexposure",
|
|
3293
|
-
code:
|
|
3733
|
+
code: Qo
|
|
3294
3734
|
}), n = e.createPipelineLayout({ bindGroupLayouts: [this._lumLayout] });
|
|
3295
3735
|
this._lumReducePipeline = e.createComputePipeline({
|
|
3296
3736
|
label: "oidn-autoexposure-reduce",
|
|
@@ -3314,7 +3754,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3314
3754
|
compute: {
|
|
3315
3755
|
module: e.createShaderModule({
|
|
3316
3756
|
label: "oidn-color-scale",
|
|
3317
|
-
code:
|
|
3757
|
+
code: $o
|
|
3318
3758
|
}),
|
|
3319
3759
|
entryPoint: "main"
|
|
3320
3760
|
}
|
|
@@ -3324,7 +3764,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3324
3764
|
compute: {
|
|
3325
3765
|
module: e.createShaderModule({
|
|
3326
3766
|
label: "oidn-output-unpack",
|
|
3327
|
-
code:
|
|
3767
|
+
code: is
|
|
3328
3768
|
}),
|
|
3329
3769
|
entryPoint: "main"
|
|
3330
3770
|
}
|
|
@@ -3334,7 +3774,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3334
3774
|
size: 4
|
|
3335
3775
|
}), this._lumPartials = e.createBuffer({
|
|
3336
3776
|
label: "oidn-autoexposure-partials",
|
|
3337
|
-
size:
|
|
3777
|
+
size: Zo * 4,
|
|
3338
3778
|
usage: GPUBufferUsage.STORAGE
|
|
3339
3779
|
}), this._lumParams = e.createBuffer({
|
|
3340
3780
|
label: "oidn-autoexposure-params",
|
|
@@ -3386,13 +3826,13 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3386
3826
|
0
|
|
3387
3827
|
]));
|
|
3388
3828
|
let n = e.createCommandEncoder({ label: "oidn-autoexposure" }), r = n.beginComputePass({ label: "oidn-autoexposure-reduce" });
|
|
3389
|
-
r.setPipeline(this._lumReducePipeline), r.setBindGroup(0, this._lumBindGroup), r.dispatchWorkgroups(
|
|
3829
|
+
r.setPipeline(this._lumReducePipeline), r.setBindGroup(0, this._lumBindGroup), r.dispatchWorkgroups(Zo, 1, 1), r.end();
|
|
3390
3830
|
let i = n.beginComputePass({ label: "oidn-autoexposure-finalize" });
|
|
3391
3831
|
i.setPipeline(this._lumFinalizePipeline), i.setBindGroup(0, this._lumBindGroup), i.dispatchWorkgroups(1, 1, 1), i.end(), e.queue.submit([n.finish()]);
|
|
3392
3832
|
}
|
|
3393
3833
|
_applyColorScale(e, t) {
|
|
3394
3834
|
if (!this._ensureScalePipelines(e)) return;
|
|
3395
|
-
let n = Math.ceil(t /
|
|
3835
|
+
let n = Math.ceil(t / es), r = Math.min(n, ts), i = Math.ceil(n / r), a = e.createCommandEncoder({ label: "oidn-color-scale" }), o = a.beginComputePass({ label: "oidn-color-scale" });
|
|
3396
3836
|
o.setPipeline(this._colorScalePipeline), o.setBindGroup(0, this._colorScaleBindGroup), o.dispatchWorkgroups(r, i, 1), o.end(), e.queue.submit([a.finish()]);
|
|
3397
3837
|
}
|
|
3398
3838
|
get outputTexture() {
|
|
@@ -3414,12 +3854,12 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3414
3854
|
format: "rgba16float",
|
|
3415
3855
|
usage: GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC
|
|
3416
3856
|
});
|
|
3417
|
-
let r = new
|
|
3857
|
+
let r = new yn(this._outGPUTexture);
|
|
3418
3858
|
r.name = "oidn:output", r.image = {
|
|
3419
3859
|
width: t,
|
|
3420
3860
|
height: n,
|
|
3421
3861
|
depth: 1
|
|
3422
|
-
}, r.type =
|
|
3862
|
+
}, r.type = mr, r.format = Q, r.colorSpace = Cr, r.minFilter = Z, r.magFilter = Z, r.wrapS = or, r.wrapT = or, r.generateMipmaps = !1, r.flipY = !1, this._outTexture = r, this._outTexSize = {
|
|
3423
3863
|
width: t,
|
|
3424
3864
|
height: n
|
|
3425
3865
|
};
|
|
@@ -3437,7 +3877,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3437
3877
|
if (this._ensureOutputTexture(i, this._renderWidth, this._renderHeight), !this._outGPUTexture) return;
|
|
3438
3878
|
let l = i.createBuffer({
|
|
3439
3879
|
label: "oidn-unpack-params",
|
|
3440
|
-
size:
|
|
3880
|
+
size: rs,
|
|
3441
3881
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
3442
3882
|
});
|
|
3443
3883
|
try {
|
|
@@ -3477,7 +3917,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3477
3917
|
}
|
|
3478
3918
|
]
|
|
3479
3919
|
}), u = i.createCommandEncoder({ label: "oidn-output-unpack" }), d = u.beginComputePass({ label: "oidn-output-unpack" });
|
|
3480
|
-
d.setPipeline(this._unpackPipeline), d.setBindGroup(0, n), d.dispatchWorkgroups(Math.ceil(s /
|
|
3920
|
+
d.setPipeline(this._unpackPipeline), d.setBindGroup(0, n), d.dispatchWorkgroups(Math.ceil(s / ns), Math.ceil(c / ns), 1), d.end(), i.queue.submit([u.finish()]), r && (this._hasOutput = !0);
|
|
3481
3921
|
} finally {
|
|
3482
3922
|
l.destroy();
|
|
3483
3923
|
}
|
|
@@ -3526,7 +3966,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3526
3966
|
}
|
|
3527
3967
|
_displayGPUOutput({ data: e, width: t, height: n }) {
|
|
3528
3968
|
if (!this.gpuDevice) {
|
|
3529
|
-
|
|
3969
|
+
Wo.error("gpuDevice not available for the output picture");
|
|
3530
3970
|
return;
|
|
3531
3971
|
}
|
|
3532
3972
|
this._unpackToTexture(e, t, {
|
|
@@ -3537,7 +3977,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3537
3977
|
});
|
|
3538
3978
|
}
|
|
3539
3979
|
abort() {
|
|
3540
|
-
this._pendingStart = !1, this._pendingStartContinuous = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this.state.isDenoising = !1,
|
|
3980
|
+
this._pendingStart = !1, this._pendingStartContinuous = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this.state.isDenoising = !1, Wo.debug("denoise aborted"));
|
|
3541
3981
|
}
|
|
3542
3982
|
get hasOutput() {
|
|
3543
3983
|
return this._hasOutput;
|
|
@@ -3548,13 +3988,13 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3548
3988
|
setSize(e, t) {
|
|
3549
3989
|
if (e <= 0 || t <= 0) throw Error(`Invalid dimensions: ${e}x${t}`);
|
|
3550
3990
|
this._renderWidth = e, this._renderHeight = t, this._hasOutput = !1, this.lastDenoiseMs = 0, this._setupUNetDenoiser().catch((e) => {
|
|
3551
|
-
|
|
3991
|
+
Wo.error("reinitialize after size change failed:", e);
|
|
3552
3992
|
});
|
|
3553
3993
|
}
|
|
3554
3994
|
dispose() {
|
|
3555
|
-
this.abort(), this.unet?.dispose(), this._destroyGPUInputBuffers(), this._releaseOutputTexture(), this._colorScalePipeline = null, this._lumReducePipeline = null, this._lumFinalizePipeline = null, this._lumLayout = null, this._unpackPipeline = null, this.unet = null, this._weights.clear(), this.state.abortController = null, this.removeAllListeners?.(),
|
|
3995
|
+
this.abort(), this.unet?.dispose(), this._destroyGPUInputBuffers(), this._releaseOutputTexture(), this._colorScalePipeline = null, this._lumReducePipeline = null, this._lumFinalizePipeline = null, this._lumLayout = null, this._unpackPipeline = null, this.unet = null, this._weights.clear(), this.state.abortController = null, this.removeAllListeners?.(), Wo.debug("disposed");
|
|
3556
3996
|
}
|
|
3557
|
-
},
|
|
3997
|
+
}, cs = Object.freeze({
|
|
3558
3998
|
maxLength: 8,
|
|
3559
3999
|
smoothLength: 2,
|
|
3560
4000
|
roughStart: .45,
|
|
@@ -3562,7 +4002,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3562
4002
|
depthTolerance: .05,
|
|
3563
4003
|
normalTolerance: .8,
|
|
3564
4004
|
movedLength: 2
|
|
3565
|
-
}),
|
|
4005
|
+
}), ls = 8, us = 304, ds = 16, fs = 1, ps = 2, ms = 4, hs = 1073741824, gs = "\nstruct Params {\n size: vec2<u32>,\n reset: u32,\n flags: u32,\n maxLength: f32,\n smoothLength: f32,\n depthTolerance: f32,\n normalTolerance: f32,\n roughStart: f32,\n roughEnd: f32,\n samples: f32,\n historyScale: f32,\n camWorld: mat4x4<f32>,\n projInv: mat4x4<f32>,\n prevViewProj: mat4x4<f32>,\n prevCamPos: vec4<f32>,\n moved: vec4<u32>,\n movedLength: f32,\n prevCamDir: vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> P: Params;\n\nfn finite3( v: vec3<f32> ) -> bool {\n let e = bitcast<vec3<u32>>( v ) & vec3<u32>( 0x7f800000u );\n return all( e != vec3<u32>( 0x7f800000u ) );\n}\n\n// [0,1]-encoded in and out, renormalised like FinalWrite's clean aux.\nfn mixNormal( h: vec3<f32>, c: vec3<f32>, t: f32 ) -> vec3<f32> {\n let m = mix( h * 2.0 - 1.0, c * 2.0 - 1.0, t );\n let l = length( m );\n return select( c, m / l * 0.5 + 0.5, l > 1e-4 );\n}\n", _s = gs + `
|
|
3566
4006
|
@group(0) @binding(1) var geoCur: texture_2d<f32>;
|
|
3567
4007
|
@group(0) @binding(2) var geoPrev: texture_2d<f32>;
|
|
3568
4008
|
@group(0) @binding(3) var<storage, read_write> picked: array<i32>;
|
|
@@ -3588,7 +4028,7 @@ fn movedIndex( leaf: u32 ) -> i32 {
|
|
|
3588
4028
|
|
|
3589
4029
|
}
|
|
3590
4030
|
|
|
3591
|
-
@compute @workgroup_size(${
|
|
4031
|
+
@compute @workgroup_size(${ls}, ${ls})
|
|
3592
4032
|
fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
3593
4033
|
|
|
3594
4034
|
if ( gid.x >= P.size.x || gid.y >= P.size.y ) { return; }
|
|
@@ -3598,12 +4038,12 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3598
4038
|
var pick = -1;
|
|
3599
4039
|
var movedFlag = 0;
|
|
3600
4040
|
|
|
3601
|
-
if ( P.reset == 0u && g.w < ${
|
|
4041
|
+
if ( P.reset == 0u && g.w < ${Gr.toFixed(1)} ) {
|
|
3602
4042
|
|
|
3603
4043
|
let size = vec2<f32>( P.size );
|
|
3604
4044
|
let uv = ( vec2<f32>( gid.xy ) + 0.5 ) / size;
|
|
3605
4045
|
// Depth is along the ray: from the camera, or from its image plane when orthographic.
|
|
3606
|
-
let ortho = ( P.flags & ${
|
|
4046
|
+
let ortho = ( P.flags & ${ms}u ) != 0u;
|
|
3607
4047
|
let ndc = vec2<f32>( uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0 );
|
|
3608
4048
|
var origin = P.camWorld[ 3 ].xyz;
|
|
3609
4049
|
var dir: vec3<f32>;
|
|
@@ -3627,7 +4067,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3627
4067
|
let toPrev = movedToPrev[ u32( m ) ];
|
|
3628
4068
|
wp = ( toPrev * vec4<f32>( wp, 1.0 ) ).xyz;
|
|
3629
4069
|
n = normalize( ( toPrev * vec4<f32>( n, 0.0 ) ).xyz );
|
|
3630
|
-
movedFlag = ${
|
|
4070
|
+
movedFlag = ${hs};
|
|
3631
4071
|
|
|
3632
4072
|
}
|
|
3633
4073
|
|
|
@@ -3664,7 +4104,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3664
4104
|
if ( pick >= 0 ) { atomicAdd( &copies[ u32( pick ) ], 1u ); }
|
|
3665
4105
|
|
|
3666
4106
|
}
|
|
3667
|
-
`,
|
|
4107
|
+
`, vs = gs + `
|
|
3668
4108
|
@group(0) @binding(1) var curColor: texture_2d<f32>;
|
|
3669
4109
|
@group(0) @binding(2) var curAlbedo: texture_2d<f32>;
|
|
3670
4110
|
@group(0) @binding(3) var curNormal: texture_2d<f32>;
|
|
@@ -3678,7 +4118,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3678
4118
|
@group(0) @binding(11) var outAlbedo: texture_storage_2d<rgba32float, write>;
|
|
3679
4119
|
@group(0) @binding(12) var outNormal: texture_storage_2d<rgba32float, write>;
|
|
3680
4120
|
|
|
3681
|
-
@compute @workgroup_size(${
|
|
4121
|
+
@compute @workgroup_size(${ls}, ${ls})
|
|
3682
4122
|
fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
3683
4123
|
|
|
3684
4124
|
if ( gid.x >= P.size.x || gid.y >= P.size.y ) { return; }
|
|
@@ -3694,8 +4134,8 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3694
4134
|
var ha = ca.xyz;
|
|
3695
4135
|
var hn = cn.xyz;
|
|
3696
4136
|
let raw = picked[ gid.y * P.size.x + gid.x ];
|
|
3697
|
-
let movedPx = raw >= 0 && ( raw & ${
|
|
3698
|
-
let pick = select( raw, raw & ~${
|
|
4137
|
+
let movedPx = raw >= 0 && ( raw & ${hs} ) != 0;
|
|
4138
|
+
let pick = select( raw, raw & ~${hs}, raw >= 0 );
|
|
3699
4139
|
|
|
3700
4140
|
if ( pick >= 0 ) {
|
|
3701
4141
|
|
|
@@ -3709,7 +4149,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3709
4149
|
ha = a.xyz;
|
|
3710
4150
|
hn = textureLoad( histNormal, q, 0 ).xyz;
|
|
3711
4151
|
len = a.w;
|
|
3712
|
-
if ( ( P.flags & ${
|
|
4152
|
+
if ( ( P.flags & ${ps}u ) != 0u ) { len = len / f32( max( copies[ u32( pick ) ], 1u ) ); }
|
|
3713
4153
|
|
|
3714
4154
|
}
|
|
3715
4155
|
|
|
@@ -3723,11 +4163,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3723
4163
|
|
|
3724
4164
|
textureStore( outColor, p, vec4<f32>( mix( hc, cur.xyz, t ), cur.w ) );
|
|
3725
4165
|
textureStore( outAlbedo, p, vec4<f32>( mix( ha, ca.xyz, t ), newLen ) );
|
|
3726
|
-
let n = select( cn.xyz, mixNormal( hn, cn.xyz, t ), ( P.flags & ${
|
|
4166
|
+
let n = select( cn.xyz, mixNormal( hn, cn.xyz, t ), ( P.flags & ${fs}u ) != 0u );
|
|
3727
4167
|
textureStore( outNormal, p, vec4<f32>( n, cn.w ) );
|
|
3728
4168
|
|
|
3729
4169
|
}
|
|
3730
|
-
`,
|
|
4170
|
+
`, ys = gs + `
|
|
3731
4171
|
@group(0) @binding(1) var accColor: texture_2d<f32>;
|
|
3732
4172
|
@group(0) @binding(2) var accAlbedo: texture_2d<f32>;
|
|
3733
4173
|
@group(0) @binding(3) var accNormal: texture_2d<f32>;
|
|
@@ -3738,7 +4178,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3738
4178
|
@group(0) @binding(8) var outAlbedo: texture_storage_2d<rgba32float, write>;
|
|
3739
4179
|
@group(0) @binding(9) var outNormal: texture_storage_2d<rgba32float, write>;
|
|
3740
4180
|
|
|
3741
|
-
@compute @workgroup_size(${
|
|
4181
|
+
@compute @workgroup_size(${ls}, ${ls})
|
|
3742
4182
|
fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
3743
4183
|
|
|
3744
4184
|
if ( gid.x >= P.size.x || gid.y >= P.size.y ) { return; }
|
|
@@ -3772,32 +4212,32 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3772
4212
|
let t = P.samples / max( k + P.samples, 1e-6 );
|
|
3773
4213
|
textureStore( outColor, p, vec4<f32>( mix( hc, ac.xyz, t ), ac.w ) );
|
|
3774
4214
|
textureStore( outAlbedo, p, vec4<f32>( mix( ha, aa.xyz, t ), min( k + P.samples, P.maxLength ) ) );
|
|
3775
|
-
let n = select( an.xyz, mixNormal( hn, an.xyz, t ), ( P.flags & ${
|
|
4215
|
+
let n = select( an.xyz, mixNormal( hn, an.xyz, t ), ( P.flags & ${fs}u ) != 0u );
|
|
3776
4216
|
textureStore( outNormal, p, vec4<f32>( n, an.w ) );
|
|
3777
4217
|
|
|
3778
4218
|
}
|
|
3779
|
-
`,
|
|
4219
|
+
`, bs = (e) => ({
|
|
3780
4220
|
binding: e,
|
|
3781
4221
|
visibility: GPUShaderStage.COMPUTE,
|
|
3782
4222
|
texture: { sampleType: "unfilterable-float" }
|
|
3783
|
-
}),
|
|
4223
|
+
}), xs = (e) => ({
|
|
3784
4224
|
binding: e,
|
|
3785
4225
|
visibility: GPUShaderStage.COMPUTE,
|
|
3786
4226
|
storageTexture: {
|
|
3787
4227
|
access: "write-only",
|
|
3788
4228
|
format: "rgba32float"
|
|
3789
4229
|
}
|
|
3790
|
-
}),
|
|
4230
|
+
}), Ss = (e, t) => ({
|
|
3791
4231
|
binding: e,
|
|
3792
4232
|
visibility: GPUShaderStage.COMPUTE,
|
|
3793
4233
|
buffer: { type: t }
|
|
3794
|
-
}),
|
|
4234
|
+
}), Cs = class {
|
|
3795
4235
|
constructor(e) {
|
|
3796
4236
|
this.device = e, this.settings = {
|
|
3797
|
-
...
|
|
4237
|
+
...cs,
|
|
3798
4238
|
cleanAux: !1,
|
|
3799
4239
|
splitCopies: !0
|
|
3800
|
-
}, this.valid = !1, this.width = 0, this.height = 0, this._sets = null, this._current = 0, this._picked = null, this._copies = null, this._paramsBuffer = null, this._pipelines = null, this._movedLeaves = null, this._movedToPrev = null, this._movedCapacity = 0, this._movedCount = 0, this._paramData = new ArrayBuffer(
|
|
4240
|
+
}, this.valid = !1, this.width = 0, this.height = 0, this._sets = null, this._current = 0, this._picked = null, this._copies = null, this._paramsBuffer = null, this._pipelines = null, this._movedLeaves = null, this._movedToPrev = null, this._movedCapacity = 0, this._movedCount = 0, this._paramData = new ArrayBuffer(us), this._paramU32 = new Uint32Array(this._paramData), this._paramF32 = new Float32Array(this._paramData), this._prevViewProj = new Float32Array(16), this._prevCamPos = new Float32Array(4), this._prevCamDir = new Float32Array(4);
|
|
3801
4241
|
}
|
|
3802
4242
|
get textures() {
|
|
3803
4243
|
return this.valid ? this._sets[this._current] : null;
|
|
@@ -3905,23 +4345,23 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3905
4345
|
}),
|
|
3906
4346
|
layout: i
|
|
3907
4347
|
};
|
|
3908
|
-
}, n =
|
|
4348
|
+
}, n = Ss(0, "uniform");
|
|
3909
4349
|
this._pipelines = {
|
|
3910
|
-
select: t("oidn-history-select",
|
|
4350
|
+
select: t("oidn-history-select", _s, [
|
|
3911
4351
|
n,
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
4352
|
+
bs(1),
|
|
4353
|
+
bs(2),
|
|
4354
|
+
Ss(3, "storage"),
|
|
4355
|
+
Ss(4, "storage"),
|
|
3916
4356
|
{
|
|
3917
4357
|
binding: 5,
|
|
3918
4358
|
visibility: GPUShaderStage.COMPUTE,
|
|
3919
4359
|
texture: { sampleType: "uint" }
|
|
3920
4360
|
},
|
|
3921
|
-
|
|
3922
|
-
|
|
4361
|
+
Ss(6, "read-only-storage"),
|
|
4362
|
+
Ss(7, "read-only-storage")
|
|
3923
4363
|
]),
|
|
3924
|
-
blend: t("oidn-history-blend",
|
|
4364
|
+
blend: t("oidn-history-blend", vs, [
|
|
3925
4365
|
n,
|
|
3926
4366
|
...[
|
|
3927
4367
|
1,
|
|
@@ -3931,14 +4371,14 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3931
4371
|
5,
|
|
3932
4372
|
6,
|
|
3933
4373
|
7
|
|
3934
|
-
].map(
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
4374
|
+
].map(bs),
|
|
4375
|
+
Ss(8, "read-only-storage"),
|
|
4376
|
+
Ss(9, "read-only-storage"),
|
|
4377
|
+
xs(10),
|
|
4378
|
+
xs(11),
|
|
4379
|
+
xs(12)
|
|
3940
4380
|
]),
|
|
3941
|
-
merge: t("oidn-history-merge",
|
|
4381
|
+
merge: t("oidn-history-merge", ys, [
|
|
3942
4382
|
n,
|
|
3943
4383
|
...[
|
|
3944
4384
|
1,
|
|
@@ -3947,16 +4387,16 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3947
4387
|
4,
|
|
3948
4388
|
5,
|
|
3949
4389
|
6
|
|
3950
|
-
].map(
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
4390
|
+
].map(bs),
|
|
4391
|
+
xs(7),
|
|
4392
|
+
xs(8),
|
|
4393
|
+
xs(9)
|
|
3954
4394
|
])
|
|
3955
4395
|
}, this._paramsBuffer = e.createBuffer({
|
|
3956
4396
|
label: "oidn-history-params",
|
|
3957
|
-
size:
|
|
4397
|
+
size: us,
|
|
3958
4398
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
3959
|
-
}), this._growMoved(
|
|
4399
|
+
}), this._growMoved(ds);
|
|
3960
4400
|
}
|
|
3961
4401
|
_growMoved(e) {
|
|
3962
4402
|
this._movedLeaves?.destroy(), this._movedToPrev?.destroy();
|
|
@@ -3982,11 +4422,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3982
4422
|
a.setPipeline(t), a.setBindGroup(0, this.device.createBindGroup({
|
|
3983
4423
|
layout: n,
|
|
3984
4424
|
entries: i
|
|
3985
|
-
})), a.dispatchWorkgroups(Math.ceil(this.width /
|
|
4425
|
+
})), a.dispatchWorkgroups(Math.ceil(this.width / ls), Math.ceil(this.height / ls)), a.end();
|
|
3986
4426
|
}
|
|
3987
4427
|
_writeParams(e, t, n, r) {
|
|
3988
4428
|
let i = this.settings, a = this._paramU32, o = this._paramF32;
|
|
3989
|
-
a[0] = this.width, a[1] = this.height, a[2] = +!!t, a[3] = (i.cleanAux ?
|
|
4429
|
+
a[0] = this.width, a[1] = this.height, a[2] = +!!t, a[3] = (i.cleanAux ? fs : 0) | (i.splitCopies ? ps : 0) | (e.orthographic ? ms : 0), o[4] = i.maxLength, o[5] = i.smoothLength, o[6] = i.depthTolerance, o[7] = i.normalTolerance, o[8] = i.roughStart, o[9] = i.roughEnd, o[10] = n, o[11] = r, o.set(e.world, 12), o.set(e.projInv, 28), o.set(this._prevViewProj, 44), o.set(this._prevCamPos, 60), a[64] = this._movedCount, o[68] = i.movedLength, o.set(this._prevCamDir, 72), this.device.queue.writeBuffer(this._paramsBuffer, 0, this._paramData);
|
|
3990
4430
|
}
|
|
3991
4431
|
_rememberCamera(e) {
|
|
3992
4432
|
this._prevViewProj.set(e.viewProj), this._prevCamPos[0] = e.world[12], this._prevCamPos[1] = e.world[13], this._prevCamPos[2] = e.world[14];
|
|
@@ -3996,11 +4436,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
3996
4436
|
_releaseTextures() {
|
|
3997
4437
|
this._sets?.forEach((e) => Object.values(e).forEach((e) => e.destroy())), this._picked?.destroy(), this._copies?.destroy(), this._sets = null, this._picked = null, this._copies = null, this.width = 0, this.height = 0, this.valid = !1;
|
|
3998
4438
|
}
|
|
3999
|
-
}, No = "const e=Object.freeze({ADAPTER_SOFTWARE:`adapter.software`,ASSET_UNREACHABLE:`asset.unreachable`,ASSET_AMBIGUOUS_ENTRY:`asset.ambiguous_entry`,ASSET_ARCHIVE_TOO_LARGE:`asset.archive_too_large`,ASSET_ENTRY_TOO_LARGE:`asset.entry_too_large`,TEXTURE_BUILD_FAILED:`texture.build_failed`,TEXTURE_PROCESSING_FALLBACK:`texture.processing_fallback`,TEXTURE_LIMIT_EXCEEDED:`texture.limit_exceeded`,ENVIRONMENT_LOAD_FAILED:`environment.load_failed`,SETTING_UNKNOWN_KEY:`setting.unknown_key`,RENDER_SIZE_DECLINED:`render.size_declined`,STAGE_RENDER_FAILED:`stage.render_failed`,RENDER_RESERVE_CAPPED:`render.reserve_capped`,SCENE_MEMORY_BUDGET:`scene.memory_budget`,EMISSIVE_INSTANCES_COLLAPSED:`emissive.instances_collapsed`,REFIT_SHARED_GEOMETRY:`refit.shared_geometry`,VIEW_TRANSFORM_DISPLAY_MISMATCH:`viewTransform.display_mismatch`,VIEW_TRANSFORM_BAKE_FAILED:`viewTransform.bake_failed`,COLOR_CONFIG_LOAD_FAILED:`color.config_load_failed`,STORAGE_UNAVAILABLE:`storage.unavailable`,STORAGE_QUOTA_EXCEEDED:`storage.quota_exceeded`,STORAGE_WRITE_FAILED:`storage.write_failed`,STORAGE_READ_FAILED:`storage.read_failed`,STORAGE_ENTRY_CORRUPT:`storage.entry_corrupt`,STORAGE_CACHE_MISMATCH:`storage.cache_mismatch`,DENOISER_UNAVAILABLE:`denoiser.unavailable`,OUTPUT_SOURCE_FALLBACK:`output.source_fallback`,OUTPUT_TONEMAP_FALLBACK:`output.tonemap_fallback`,LIGHT_PLACEHOLDER_SKIPPED:`light.placeholder_skipped`,CAPABILITY_MISSING:`capability.missing`});Object.freeze({ERROR:`error`,WARNING:`warning`});const t=new Map;function n(e,t){return e.exclusive||t===`exclusive`&&e.shared>0?!1:(t===`exclusive`?e.exclusive=!0:e.shared++,!0)}function r(e,r,a){let o=t.get(e);o||(o={shared:0,exclusive:!1,queue:[]},t.set(e,o));let s=i(()=>{for(r===`exclusive`?o.exclusive=!1:o.shared--;o.queue.length&&n(o,o.queue[0].mode);)o.queue.shift().grant();!o.exclusive&&o.shared===0&&o.queue.length===0&&t.delete(e)});return o.queue.length===0&&n(o,r)?Promise.resolve(s):a?(!o.exclusive&&o.shared===0&&o.queue.length===0&&t.delete(e),Promise.resolve(null)):new Promise(e=>o.queue.push({mode:r,grant:()=>e(s)}))}function i(e){let t=!1;return()=>{t||(t=!0,e())}}const a=()=>typeof navigator<`u`&&navigator.locks?.request?navigator.locks:null;function o(e,{mode:t=`exclusive`,ifAvailable:n=!1}={}){let o=a();return o?new Promise((r,a)=>{o.request(e,{mode:t,ifAvailable:n},e=>{if(!e){r(null);return}return new Promise(e=>r(i(e)))}).catch(a)}):r(e,t,n)}async function s(){let e=a();if(!e)return new Set(t.keys());let{held:n=[]}=await e.query();return new Set(n.map(e=>e.name))}const c=new TextEncoder;function l(e){let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return t}async function u(e){let t=typeof e==`string`?c.encode(e):e;return l(new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))}async function d(e){return(await u(e)).slice(0,32)}var f=class{constructor(){this._handlers=new Map}addEventListener(e,t){this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t)}removeEventListener(e,t){this._handlers.get(e)?.delete(t)}dispatchEvent(e){for(let t of[...this._handlers.get(e.type)??[]])t.call(this,e)}},p=class{constructor(e){this._root=e,this._writers=new Map,this._nextId=1}async _dir(e,t){let n=await this._root;for(let r of e)n=await n.getDirectoryHandle(r,{create:t});return n}async openWriter({path:e,name:t,truncate:n=!0,length:r}){let i=await(await(await this._dir(e,!0)).getFileHandle(t,{create:!0})).createSyncAccessHandle();n?i.truncate(0):r!==void 0&&i.getSize()>r&&i.truncate(r);let a=this._nextId++;return this._writers.set(a,{handle:i,end:i.getSize()}),{id:a}}write({id:e,buffer:t,byteOffset:n=0,byteLength:r,at:i}){let a=this._writers.get(e);if(!a)throw Error(`storage: writer ${e} is not open`);let o=new Uint8Array(t,n,r??t.byteLength-n),s=i??a.end,c=0;for(;c<o.length;){let e=a.handle.write(o.subarray(c),{at:s+c});if(e<=0)throw Error(`storage: write made no progress`);c+=e}return a.end=Math.max(a.end,s+o.length),{bytes:o.length}}closeWriter({id:e,abort:t=!1}){let n=this._writers.get(e);if(!n)return{size:0};this._writers.delete(e);try{return t||n.handle.flush(),{size:n.handle.getSize()}}finally{n.handle.close()}}async writeFile({path:e,name:t,buffer:n,byteOffset:r=0,byteLength:i}){let{id:a}=await this.openWriter({path:e,name:t});try{return this.write({id:a,buffer:n,byteOffset:r,byteLength:i}),this.closeWriter({id:a})}catch(e){throw this.closeWriter({id:a,abort:!0}),e}}async readRange({path:e,name:t,offset:n=0,length:r}){let i=await(await this._dir(e,!1)).getFileHandle(t),a=null;try{a=await i.createSyncAccessHandle()}catch(e){if(e.name!==`NoModificationAllowedError`)throw e}if(!a){let e=await i.getFile(),t=r===void 0?e.size:n+r;return{buffer:await e.slice(n,t).arrayBuffer()}}try{let e=a.getSize(),t=Math.max(0,Math.min(r??e-n,e-n)),i=new ArrayBuffer(t);return a.read(i,{at:n}),{buffer:i}}finally{a.close()}}dispose(){for(let e of[...this._writers.keys()])this.closeWriter({id:e,abort:!0})}},m=class{constructor(e){this._ops=new p(e)}async call(e,t){return this._ops[e](t)}dispose(){this._ops.dispose()}};const h=Object.freeze({CACHE:`cache`,USER:`user`,SCRATCH:`scratch`}),g=Object.freeze({DOWNLOADS:`downloads`,ARCHIVES:`archives`,SCENES:`scenes`,CDF:`cdf`,SPILL:`spill`}),_=`meta.json`,v=100*1024**3,y=64*1024**2,b=8*1024**2,x=new TextEncoder;function S(e,{copy:t,transfer:n}){if(typeof e==`string`&&(e=x.encode(e)),e instanceof ArrayBuffer){if(!t||n)return{args:{buffer:e},list:[e]};let r=e.slice(0);return{args:{buffer:r},list:[r]}}if(!ArrayBuffer.isView(e))throw TypeError(`storage: write expects an ArrayBuffer, a typed array, a Blob or a string`);let{buffer:r,byteOffset:i,byteLength:a}=e,o=typeof SharedArrayBuffer<`u`&&r instanceof SharedArrayBuffer;if(!t)return{args:{buffer:r,byteOffset:i,byteLength:a},list:[]};if(o){let e=new Uint8Array(a);return e.set(new Uint8Array(r,i,a)),{args:{buffer:e.buffer},list:[e.buffer]}}if(n&&i===0&&a===r.byteLength)return{args:{buffer:r},list:[r]};let s=r.slice(i,i+a);return{args:{buffer:s},list:[s]}}async function C(e,t){try{let n=await(await e.getFileHandle(t)).getFile();return JSON.parse(await n.text())}catch{return null}}async function*w(e){for await(let[t,n]of e.entries())n.kind===`directory`&&(yield[t,n])}var T=class{constructor(e,t,n,r,i){this.area=e,this.id=t,this.key=n.key,this.meta=n,this._dir=r,this._release=i}get bytes(){return this.meta.bytes}get extra(){return this.meta.extra??{}}async file(t){try{return await(await this._dir.getFileHandle(t)).getFile()}catch(n){return this.area.manager._issue(e.STORAGE_READ_FAILED,`could not read ${this.area.name}/${this.id}/${t}`,{error:n.message}),null}}async json(e){let t=await this.file(e);return t?JSON.parse(await t.text()):null}release(){this._release?.(),this._release=null}},E=class{constructor(e,t,n,r,i,{sizes:a={},append:o=!1}={}){this.area=e,this.id=t,this.key=n,this._info=r,this._release=i,this._writers=new Map,this._sizes={...a},this._append=o,this._done=!1,this._committedBytes=o?Object.values(a).reduce((e,t)=>e+t,0):0}get _transport(){return this.area.manager._transport}get _path(){return[this.area.name,this.id]}async _writer(e){let t=this._writers.get(e);if(!t){let n=this._append&&e in this._sizes,r=n&&(this._info.growable??[]).includes(e)?this._sizes[e]:void 0;t=this._transport.call(`openWriter`,{path:this._path,name:e,truncate:!n,length:r}),this._writers.set(e,t)}return(await t).id}async write(e,t,{at:n,transfer:r=!1}={}){this._assertOpen();let{args:i,list:a}=(typeof Blob<`u`&&t instanceof Blob?null:S(t,{copy:!0,transfer:r}))??S(await t.arrayBuffer(),{copy:!0,transfer:!0}),o=await this._writer(e);return this._transport.call(`write`,{id:o,at:n,...i},a)}async writeFile(e,t){this._assertOpen(),typeof Blob<`u`&&t instanceof Blob&&(t=await t.arrayBuffer());let{args:n,list:r}=S(t,{copy:!0,transfer:!0}),{size:i}=await this._transport.call(`writeFile`,{path:this._path,name:e,...n},r);return this._sizes[e]=i,i}writeJSON(e,t){return this.writeFile(e,JSON.stringify(t))}async writeStream(e,t,{onProgress:n=null,signal:r=null,batchBytes:i=b}={}){let a=t.getReader(),o=[],s=new Uint8Array(i),c=0,l=0,u=async()=>{if(c===0)return;let t=c===i?s:s.slice(0,c);s=new Uint8Array(i),c=0,o.push(this.write(e,t,{transfer:!0})),o.length>=4&&await o.shift()};try{for(;;){if(r?.aborted)throw r.reason??new DOMException(`aborted`,`AbortError`);let{done:e,value:t}=await a.read();if(e)break;let o=0;for(;o<t.length;){let e=Math.min(t.length-o,i-c);s.set(t.subarray(o,o+e),c),c+=e,o+=e,l+=e,c===i&&await u()}n?.(l)}return await u(),await Promise.all(o),l}catch(e){throw a.cancel().catch(()=>{}),await Promise.allSettled(o),e}}async commit(e={}){this._assertOpen(),this._done=!0;try{for(let[e,t]of this._writers){let{size:n}=await this._transport.call(`closeWriter`,{id:(await t).id});this._sizes[e]=n}this._writers.clear();let t=Date.now(),n={v:1,key:this.key,label:this._info.label??``,kind:this.area.kind,files:{...this._sizes},bytes:Object.values(this._sizes).reduce((e,t)=>e+t,0),createdAt:this._info.createdAt??t,lastUsed:t,pinned:this._info.pinned===!0,extra:{...this._info.extra,...e}},r=this._info.growable??[];r.length&&(n.growable=r);let{args:i,list:a}=S(JSON.stringify(n),{copy:!1});return await this._transport.call(`writeFile`,{path:this._path,name:_,...i},a),this.area.kind===h.CACHE&&this.area.manager._countCacheBytes(n.bytes-this._committedBytes),this.area.manager._changed(this.area.name),n}catch(e){throw await this._discard(),this.area.manager._writeFailed(this.area.name,e),e}finally{this._release?.(),this._release=null}}async abort(){if(!this._done){this._done=!0;try{this._append?await this._closeAll(!0):await this._discard()}finally{this._release?.(),this._release=null}}}async _closeAll(e){for(let t of this._writers.values())try{await this._transport.call(`closeWriter`,{id:(await t).id,abort:e})}catch{}this._writers.clear()}async _discard(){await this._closeAll(!0),await this.area._removeDir(this.id)}_assertOpen(){if(this._done)throw Error(`storage: entry ${this.area.name}/${this.id} is already committed or aborted`)}},D=class{constructor(e,t,n){this.manager=e,this.name=t,this.kind=n}_lockName(e){return`${this.manager.namespace}:store:${this.name}:${e}`}async _dir(e=!1){try{return await this.manager._root.getDirectoryHandle(this.name,{create:e})}catch(e){if(e.name===`NotFoundError`)return null;throw e}}async _entryDir(e,t=!1){let n=await this._dir(t);if(!n)return null;try{return await n.getDirectoryHandle(e,{create:t})}catch(e){if(e.name===`NotFoundError`)return null;throw e}}async _removeDir(e){let t=await this._dir(!1);if(t)try{await t.removeEntry(e,{recursive:!0})}catch(e){if(e.name!==`NotFoundError`)throw e}}async _validMeta(e,t=null){let n=await C(e,_);if(!n||n.v!==1||typeof n.key!=`string`||t!==null&&n.key!==t)return null;let r=n.growable??[];for(let[t,i]of Object.entries(n.files??{}))try{let n=await(await e.getFileHandle(t)).getFile();if(n.size!==i&&!(r.includes(t)&&n.size>i))return null}catch{return null}return n}async open(t,{wait:n=!1}={}){let r=await d(t),i=await o(this._lockName(r),{mode:`shared`,ifAvailable:!n});if(!i)return null;try{let e=await this._entryDir(r),n=e?await this._validMeta(e,t):null;return n?(Date.now()-n.lastUsed>36e5&&this._touch(r,n),new T(this,r,n,e,i)):(i(),null)}catch(t){return i(),this.manager._issue(e.STORAGE_READ_FAILED,`could not open ${this.name} entry`,{error:t.message}),null}}async has(e){let t=await this.open(e);return t?.release(),!!t}_touch(e,t){let n={...t,lastUsed:Date.now()},{args:r,list:i}=S(JSON.stringify(n),{copy:!1});this.manager._transport.call(`writeFile`,{path:[this.name,e],name:_,...r},i).catch(()=>{}),t.lastUsed=n.lastUsed}async create(t,{label:n=``,pinned:r=!1,expectedBytes:i=0,extra:a={},growable:s=[]}={}){let c=await d(t),l=await o(this._lockName(c),{mode:`exclusive`});try{return i>0&&!await this.manager.ensureSpace(i,this.kind)?(l(),this.manager._issue(e.STORAGE_QUOTA_EXCEEDED,`no room for ${(i/1048576).toFixed(0)} MB in ${this.name}`,{area:this.name,expectedBytes:i}),null):(await this._removeDir(c),await this._entryDir(c,!0),new E(this,c,t,{label:n,pinned:r,extra:a,growable:s},l))}catch(e){return l(),this.manager._writeFailed(this.name,e),null}}async patchMeta(e,t){let n=await d(e),r=await o(this._lockName(n),{mode:`shared`,ifAvailable:!0});if(!r)return!1;try{let r=await this._entryDir(n),i=r?await this._validMeta(r,e):null;if(!i)return!1;let{args:a,list:o}=S(JSON.stringify({...i,...t,v:1,key:e}),{copy:!1});return await this.manager._transport.call(`writeFile`,{path:[this.name,n],name:_,...a},o),!0}finally{r()}}async edit(e){let t=await d(e),n=await o(this._lockName(t),{mode:`exclusive`});try{let r=await this._entryDir(t),i=r?await this._validMeta(r,e):null;if(!i)return n(),null;let a={label:i.label,pinned:i.pinned,extra:i.extra,createdAt:i.createdAt,growable:i.growable};return new E(this,t,e,a,n,{sizes:i.files,append:!0})}catch(e){return n(),this.manager._writeFailed(this.name,e),null}}async remove(e){return this.removeById(await d(e))}async removeById(e){let t=await o(this._lockName(e),{mode:`exclusive`,ifAvailable:!0});if(!t)return!1;try{return await this._removeDir(e),this.manager._changed(this.name),!0}finally{t()}}async list(){let e=await this._dir(!1);if(!e)return[];let t=[];for await(let[n,r]of w(e)){let e=await C(r,_);e?.v===1&&t.push({...e,id:n})}return t}async clear(){let e=0;for(let{id:t}of await this.list())await this.removeById(t)&&e++;return e}async sweep(){let e=await this._dir(!1);if(!e)return 0;let t=await s(),n=0;for await(let[r,i]of w(e))t.has(this._lockName(r))||await this._validMeta(i)||await this.removeById(r)&&n++;return n}},O=class extends f{constructor({root:e,transport:t,namespace:n}){super(),this.namespace=n,this._root=e,this._transport=t,this._areas=new Map,this._budget=null,this._cacheTotal=null;for(let e of Object.values(g))this.defineArea(e,{kind:e===g.SPILL?h.SCRATCH:h.CACHE})}defineArea(e,{kind:t=h.CACHE}={}){let n=this._areas.get(e);if(n){if(n.kind!==t)throw Error(`storage: area \"${e}\" is already defined as ${n.kind}`);return n}let r=new D(this,e,t);return this._areas.set(e,r),r}area(e){let t=this._areas.get(e);if(!t)throw Error(`storage: unknown area \"${e}\"`);return t}get areaNames(){return[...this._areas.keys()]}async estimate(){let e=typeof navigator<`u`?navigator.storage:null;if(!e?.estimate)return{quota:1/0,usage:0};let{quota:t=1/0,usage:n=0}=await e.estimate();return{quota:t,usage:n}}async persisted(){return await globalThis.navigator?.storage?.persisted?.()===!0}async persist(){let e=await globalThis.navigator?.storage?.persist?.()===!0;return this._changed(null),e}async budget(){if(this._budget!==null)return this._budget;let{quota:e}=await this.estimate();return Math.min(e*.3,v)}setBudget(e){this._budget=e===null?null:Math.max(0,e),this._changed(null)}async _cacheBytes(){let e=this._cacheTotal;return(!e||Date.now()-e.at>3e4)&&(e=this._cacheTotal={at:Date.now(),bytes:0,ready:null},e.ready=this._cacheEntries().then(t=>{e.bytes+=t.reduce((e,t)=>e+(t.meta.bytes??0),0)}),e.ready.catch(()=>{this._cacheTotal===e&&(this._cacheTotal=null)})),await e.ready,e.bytes}_countCacheBytes(e){this._cacheTotal&&(this._cacheTotal.bytes+=e)}async _cacheEntries(){let e=[];for(let t of this._areas.values())if(t.kind===h.CACHE)for(let n of await t.list())e.push({area:t,meta:n});return e}async usage(){let{quota:e,usage:t}=await this.estimate(),n={},r=0;for(let e of this._areas.values()){let t=await e.list(),i=t.reduce((e,t)=>e+(t.bytes??0),0);n[e.name]={kind:e.kind,bytes:i,entries:t.length},e.kind===h.CACHE&&(r+=i)}return{quota:e,usage:t,persisted:await this.persisted(),budget:await this.budget(),cacheBytes:r,areas:n}}async collect({freeBytes:e=null}={}){let t=await this._cacheEntries(),n=await this.budget(),r=this._cacheTotal={at:Date.now(),bytes:t.reduce((e,t)=>e+(t.meta.bytes??0),0),ready:null},i=e??Math.max(0,r.bytes-n);if(i<=0)return 0;let a=await s(),o=t.filter(({area:e,meta:t})=>!t.pinned&&!a.has(e._lockName(t.id))).sort((e,t)=>e.meta.lastUsed-t.meta.lastUsed),c=0;for(let{area:e,meta:t}of o){if(c>=i)break;await e.removeById(t.id)&&(c+=t.bytes??0,r.bytes-=t.bytes??0)}return c}async ensureSpace(e,t=h.CACHE){let n=async()=>{let{quota:n,usage:r}=await this.estimate(),i=e+y-(n-r);return t===h.CACHE?{free:i,budget:await this._cacheBytes()+e-await this.budget()}:{free:i,budget:0}},r=await n();return r.free<=0&&r.budget<=0?!0:(await this.collect({freeBytes:Math.max(r.free,r.budget)}),(await n()).free<=0)}async sweep(){let e=0;for(let t of this._areas.values())e+=await t.sweep(),t.kind===h.SCRATCH&&(e+=await t.clear());return e}_changed(e){this.dispatchEvent({type:`change`,area:e})}_issue(e,t,n={}){this.dispatchEvent({type:`issue`,code:e,message:t,detail:n})}_writeFailed(t,n){let r=n?.name===`QuotaExceededError`;this._issue(r?e.STORAGE_QUOTA_EXCEEDED:e.STORAGE_WRITE_FAILED,`${t}: ${n?.message??n}`,{area:t,error:n?.name})}dispose(){this._transport?.dispose(),this._transport=null,this._areas.clear()}};function k({namespace:e,root:t}){let n=new m(t);n.inline=!0;let r=new O({root:t,transport:n,namespace:e});return r.sweep().catch(()=>{}),r}const A=Object.freeze({IMMUTABLE:`immutable`,REVALIDATE:`revalidate`,NETWORK:`network`}),j=(e,t)=>({loaded:e,total:t,lengthComputable:t>0&&e<=t}),M=(e,t)=>e.headers?.get?.(t)??null,N=e=>e.reason??new DOMException(`aborted`,`AbortError`);function P(e){try{let t=new URL(e,globalThis.location?.href??`http://localhost/`).pathname;return decodeURIComponent(t.split(`/`).pop())||`download`}catch{return`download`}}async function F(e,{onProgress:t,signal:n}){let r=Number(M(e,`content-length`))||0,i=M(e,`content-type`)??``;if(!e.body)return new Blob([await e.arrayBuffer()],{type:i});let a=e.body.getReader(),o=[],s=0;for(;;){if(n?.aborted)throw a.cancel().catch(()=>{}),N(n);let{done:e,value:i}=await a.read();if(e)break;o.push(i),s+=i.length,t?.(j(s,r))}return new Blob(o,{type:i})}const I=(e,t,n)=>new File([e],t,{type:n||e.type,lastModified:e.lastModified??Date.now()}),L=()=>{};var R=class{constructor(e){this._storage=e,this._revalidating=new Set}get _area(){return this._storage?.area(g.DOWNLOADS)??null}async fetch(e,{key:t=e,name:n=P(e),policy:r=A.REVALIDATE,maxAgeMs:i=864e5,onProgress:a=null,signal:o=null,fetchOptions:s={}}={}){let c=this._area;if(c&&r!==A.NETWORK){let o=await c.open(t);if(o){let c=await o.file(`data`);if(c)return r===A.REVALIDATE&&Date.now()-(o.extra.checkedAt??0)>=i&&this._revalidate(e,t,n,o.extra,s),a?.(j(c.size,c.size)),{file:I(c,n,o.extra.contentType),release:()=>o.release(),fromCache:!0};o.release()}}return this._download(e,t,n,{onProgress:a,signal:o,fetchOptions:s,cache:!!c})}async has(e){return await this._area?.has(e)===!0}async _download(e,t,n,{onProgress:r,signal:i,fetchOptions:a,cache:o}){if(i?.aborted)throw N(i);let s=await fetch(e,{...a,signal:i});if(!s.ok)throw Error(`HTTP ${s.status} fetching ${e}`);let c=Number(M(s,`content-length`))||0,l={url:e,contentType:M(s,`content-type`)??``,lastModified:M(s,`last-modified`),contentLength:c||null,checkedAt:Date.now()},u=o&&s.body?await this._area.create(t,{label:n,expectedBytes:c}):null;if(!u)return{file:I(await F(s,{onProgress:r,signal:i}),n,l.contentType),release:L,fromCache:!1};try{await u.writeStream(`data`,s.body,{signal:i,onProgress:e=>r?.(j(e,c))}),await u.commit(l)}catch(o){if(await u.abort(),o?.name!==`QuotaExceededError`)throw o;return this._download(e,t,n,{onProgress:r,signal:i,fetchOptions:a,cache:!1})}let d=await this._area.open(t,{wait:!0}),f=d&&await d.file(`data`);if(!f)throw d?.release(),Error(`storage: ${n} vanished right after it was saved`);return{file:I(f,n,l.contentType),release:()=>d.release(),fromCache:!1}}async _revalidate(e,t,n,r,i){if(this._revalidating.has(t))return;this._revalidating.add(t);let a=!1;try{let t=new Headers(i?.headers);t.set(`Range`,`bytes=0-0`);let n=await fetch(e,{...i,headers:t});if(n.body?.cancel().catch(()=>{}),n.ok){let e=M(n,`last-modified`),t=n.status===206?Number(M(n,`content-range`)?.match(/\\/(\\d+)$/)?.[1])||null:Number(M(n,`content-length`))||null;a=!!(e&&r.lastModified&&e!==r.lastModified||t&&r.contentLength&&t!==r.contentLength)}}catch{}try{if(a){let{release:r}=await this._download(e,t,n,{fetchOptions:i,cache:!0});r()}else await this._area.patchMeta(t,{extra:{...r,checkedAt:Date.now()}})}catch{}finally{this._revalidating.delete(t)}}};let z={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`,storage:`auto`},B=null;async function V(){return B||(B=await import(z.ortRuntimeUrl),B.env.wasm.wasmPaths=z.ortWasmPaths,B.env.logLevel=`error`,B)}let H=null,U=null,W=null;function G(){return W??=(async()=>{if(z.storage===!1||!navigator.storage?.getDirectory)return new R(null);try{let e=await(await navigator.storage.getDirectory()).getDirectoryHandle(z.cacheNamespace,{create:!0}),t=k({namespace:z.cacheNamespace,root:e});return await K(t).catch(()=>{}),new R(t)}catch{return new R(null)}})(),W}async function K(e){let t=`${z.cacheNamespace}:ai-upscaler-models`;if(typeof indexedDB>`u`||!indexedDB.databases||!(await indexedDB.databases()).some(e=>e.name===t))return;let n=await new Promise((e,n)=>{let r=indexedDB.open(t);r.onerror=()=>n(r.error),r.onsuccess=()=>{let t=r.result;if(!t.objectStoreNames.contains(`models`)){t.close(),e([]);return}let i=[],a=t.transaction(`models`,`readonly`).objectStore(`models`).openCursor();a.onerror=()=>n(a.error),a.onsuccess=()=>{let n=a.result;if(!n){t.close(),e(i);return}i.push([n.key,n.value]),n.continue()}}}),r=e.area(`downloads`);for(let[e,t]of n){if(typeof e!=`string`||!(t instanceof ArrayBuffer)||await r.has(e))continue;let n=await r.create(e,{label:e.split(`/`).pop(),expectedBytes:t.byteLength});n&&(await n.write(`data`,t,{transfer:!0}),await n.commit({url:e,contentType:`application/octet-stream`,checkedAt:Date.now()}))}await new Promise(e=>{let n=indexedDB.deleteDatabase(t);n.onsuccess=n.onerror=n.onblocked=()=>e()})}async function q(e){let{file:t,release:n,fromCache:r}=await(await G()).fetch(e);try{let e=await t.arrayBuffer();return r&&console.log(`AI Upscaler Worker: model loaded from cache (${(e.byteLength/1024/1024).toFixed(1)}MB)`),e}finally{n()}}async function J(e,t){if(H&&U===e){self.postMessage({type:`loaded`,backend:`webgpu`});return}H&&=(await H.release(),null);let[n,r]=await Promise.all([q(e),V()]);H=await r.InferenceSession.create(n,t),U=e;let i=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||``);i=n?128:r?256:512,console.log(`AI Upscaler Worker: GPU=\"${t?.description||t?.device||`unknown`}\", tileSize=${i}`)}catch{}let a=(n.byteLength/1024/1024).toFixed(1);console.log(`AI Upscaler Worker: model loaded (${a}MB), backend: webgpu`),self.postMessage({type:`loaded`,backend:`webgpu`,tileSize:i})}async function Y(e,t,n,r){let i=await V(),a=H.inputNames[0],o=H.outputNames[0],s=new i.Tensor(`float32`,e,[1,3,n,t]),c=(await H.run({[a]:s}))[o].data;self.postMessage({type:`inferred`,outputData:c,id:r},[c.buffer])}self.onmessage=async e=>{let{type:t}=e.data;try{t===`load`?(e.data.ortRuntimeUrl&&(z.ortRuntimeUrl=e.data.ortRuntimeUrl),e.data.ortWasmPaths&&(z.ortWasmPaths=e.data.ortWasmPaths),e.data.cacheNamespace&&(z.cacheNamespace=e.data.cacheNamespace),e.data.storage!==void 0&&(z.storage=e.data.storage),await J(e.data.url,e.data.sessionOptions)):t===`infer`?await Y(e.data.tileData,e.data.width,e.data.height,e.data.id):t===`dispose`&&H&&(await H.release(),H=null,U=null)}catch(t){self.postMessage({type:`error`,message:t.message,id:e.data?.id})}};", Po = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", No], { type: "text/javascript;charset=utf-8" });
|
|
4000
|
-
function
|
|
4439
|
+
}, ws = "const e=Object.freeze({ADAPTER_SOFTWARE:`adapter.software`,ASSET_UNREACHABLE:`asset.unreachable`,ASSET_AMBIGUOUS_ENTRY:`asset.ambiguous_entry`,ASSET_ARCHIVE_TOO_LARGE:`asset.archive_too_large`,ASSET_ENTRY_TOO_LARGE:`asset.entry_too_large`,TEXTURE_BUILD_FAILED:`texture.build_failed`,TEXTURE_PROCESSING_FALLBACK:`texture.processing_fallback`,TEXTURE_LIMIT_EXCEEDED:`texture.limit_exceeded`,ENVIRONMENT_LOAD_FAILED:`environment.load_failed`,SETTING_UNKNOWN_KEY:`setting.unknown_key`,RENDER_SIZE_DECLINED:`render.size_declined`,STAGE_RENDER_FAILED:`stage.render_failed`,RENDER_RESERVE_CAPPED:`render.reserve_capped`,SCENE_MEMORY_BUDGET:`scene.memory_budget`,EMISSIVE_INSTANCES_COLLAPSED:`emissive.instances_collapsed`,REFIT_SHARED_GEOMETRY:`refit.shared_geometry`,VIEW_TRANSFORM_DISPLAY_MISMATCH:`viewTransform.display_mismatch`,VIEW_TRANSFORM_BAKE_FAILED:`viewTransform.bake_failed`,COLOR_CONFIG_LOAD_FAILED:`color.config_load_failed`,STORAGE_UNAVAILABLE:`storage.unavailable`,STORAGE_QUOTA_EXCEEDED:`storage.quota_exceeded`,STORAGE_WRITE_FAILED:`storage.write_failed`,STORAGE_READ_FAILED:`storage.read_failed`,STORAGE_ENTRY_CORRUPT:`storage.entry_corrupt`,STORAGE_CACHE_MISMATCH:`storage.cache_mismatch`,DENOISER_UNAVAILABLE:`denoiser.unavailable`,OUTPUT_SOURCE_FALLBACK:`output.source_fallback`,OUTPUT_TONEMAP_FALLBACK:`output.tonemap_fallback`,LIGHT_PLACEHOLDER_SKIPPED:`light.placeholder_skipped`,CAPABILITY_MISSING:`capability.missing`});Object.freeze({ERROR:`error`,WARNING:`warning`});const t=new Map;function n(e,t){return e.exclusive||t===`exclusive`&&e.shared>0?!1:(t===`exclusive`?e.exclusive=!0:e.shared++,!0)}function r(e,r,a){let o=t.get(e);o||(o={shared:0,exclusive:!1,queue:[]},t.set(e,o));let s=i(()=>{for(r===`exclusive`?o.exclusive=!1:o.shared--;o.queue.length&&n(o,o.queue[0].mode);)o.queue.shift().grant();!o.exclusive&&o.shared===0&&o.queue.length===0&&t.delete(e)});return o.queue.length===0&&n(o,r)?Promise.resolve(s):a?(!o.exclusive&&o.shared===0&&o.queue.length===0&&t.delete(e),Promise.resolve(null)):new Promise(e=>o.queue.push({mode:r,grant:()=>e(s)}))}function i(e){let t=!1;return()=>{t||(t=!0,e())}}const a=()=>typeof navigator<`u`&&navigator.locks?.request?navigator.locks:null;function o(e,{mode:t=`exclusive`,ifAvailable:n=!1}={}){let o=a();return o?new Promise((r,a)=>{o.request(e,{mode:t,ifAvailable:n},e=>{if(!e){r(null);return}return new Promise(e=>r(i(e)))}).catch(a)}):r(e,t,n)}async function s(){let e=a();if(!e)return new Set(t.keys());let{held:n=[]}=await e.query();return new Set(n.map(e=>e.name))}const c=new TextEncoder;function l(e){let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return t}async function u(e){let t=typeof e==`string`?c.encode(e):e;return l(new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))}async function d(e){return(await u(e)).slice(0,32)}var f=class{constructor(){this._handlers=new Map}addEventListener(e,t){this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t)}removeEventListener(e,t){this._handlers.get(e)?.delete(t)}dispatchEvent(e){for(let t of[...this._handlers.get(e.type)??[]])t.call(this,e)}},p=class{constructor(e){this._root=e,this._writers=new Map,this._nextId=1}async _dir(e,t){let n=await this._root;for(let r of e)n=await n.getDirectoryHandle(r,{create:t});return n}async openWriter({path:e,name:t,truncate:n=!0,length:r}){let i=await(await(await this._dir(e,!0)).getFileHandle(t,{create:!0})).createSyncAccessHandle();n?i.truncate(0):r!==void 0&&i.getSize()>r&&i.truncate(r);let a=this._nextId++;return this._writers.set(a,{handle:i,end:i.getSize()}),{id:a}}write({id:e,buffer:t,byteOffset:n=0,byteLength:r,at:i}){let a=this._writers.get(e);if(!a)throw Error(`storage: writer ${e} is not open`);let o=new Uint8Array(t,n,r??t.byteLength-n),s=i??a.end,c=0;for(;c<o.length;){let e=a.handle.write(o.subarray(c),{at:s+c});if(e<=0)throw Error(`storage: write made no progress`);c+=e}return a.end=Math.max(a.end,s+o.length),{bytes:o.length}}closeWriter({id:e,abort:t=!1}){let n=this._writers.get(e);if(!n)return{size:0};this._writers.delete(e);try{return t||n.handle.flush(),{size:n.handle.getSize()}}finally{n.handle.close()}}async writeFile({path:e,name:t,buffer:n,byteOffset:r=0,byteLength:i}){let{id:a}=await this.openWriter({path:e,name:t});try{return this.write({id:a,buffer:n,byteOffset:r,byteLength:i}),this.closeWriter({id:a})}catch(e){throw this.closeWriter({id:a,abort:!0}),e}}async readRange({path:e,name:t,offset:n=0,length:r}){let i=await(await this._dir(e,!1)).getFileHandle(t),a=null;try{a=await i.createSyncAccessHandle()}catch(e){if(e.name!==`NoModificationAllowedError`)throw e}if(!a){let e=await i.getFile(),t=r===void 0?e.size:n+r;return{buffer:await e.slice(n,t).arrayBuffer()}}try{let e=a.getSize(),t=Math.max(0,Math.min(r??e-n,e-n)),i=new ArrayBuffer(t);return a.read(i,{at:n}),{buffer:i}}finally{a.close()}}dispose(){for(let e of[...this._writers.keys()])this.closeWriter({id:e,abort:!0})}},m=class{constructor(e){this._ops=new p(e)}async call(e,t){return this._ops[e](t)}dispose(){this._ops.dispose()}};const h=Object.freeze({CACHE:`cache`,USER:`user`,SCRATCH:`scratch`}),g=Object.freeze({DOWNLOADS:`downloads`,ARCHIVES:`archives`,SCENES:`scenes`,CDF:`cdf`,SPILL:`spill`}),_=`meta.json`,v=100*1024**3,y=64*1024**2,b=8*1024**2,x=new TextEncoder;function S(e,{copy:t,transfer:n}){if(typeof e==`string`&&(e=x.encode(e)),e instanceof ArrayBuffer){if(!t||n)return{args:{buffer:e},list:[e]};let r=e.slice(0);return{args:{buffer:r},list:[r]}}if(!ArrayBuffer.isView(e))throw TypeError(`storage: write expects an ArrayBuffer, a typed array, a Blob or a string`);let{buffer:r,byteOffset:i,byteLength:a}=e,o=typeof SharedArrayBuffer<`u`&&r instanceof SharedArrayBuffer;if(!t)return{args:{buffer:r,byteOffset:i,byteLength:a},list:[]};if(o){let e=new Uint8Array(a);return e.set(new Uint8Array(r,i,a)),{args:{buffer:e.buffer},list:[e.buffer]}}if(n&&i===0&&a===r.byteLength)return{args:{buffer:r},list:[r]};let s=r.slice(i,i+a);return{args:{buffer:s},list:[s]}}async function C(e,t){try{let n=await(await e.getFileHandle(t)).getFile();return JSON.parse(await n.text())}catch{return null}}async function*w(e){for await(let[t,n]of e.entries())n.kind===`directory`&&(yield[t,n])}var T=class{constructor(e,t,n,r,i){this.area=e,this.id=t,this.key=n.key,this.meta=n,this._dir=r,this._release=i}get bytes(){return this.meta.bytes}get extra(){return this.meta.extra??{}}async file(t){try{return await(await this._dir.getFileHandle(t)).getFile()}catch(n){return this.area.manager._issue(e.STORAGE_READ_FAILED,`could not read ${this.area.name}/${this.id}/${t}`,{error:n.message}),null}}async json(e){let t=await this.file(e);return t?JSON.parse(await t.text()):null}release(){this._release?.(),this._release=null}},E=class{constructor(e,t,n,r,i,{sizes:a={},append:o=!1}={}){this.area=e,this.id=t,this.key=n,this._info=r,this._release=i,this._writers=new Map,this._sizes={...a},this._append=o,this._done=!1,this._committedBytes=o?Object.values(a).reduce((e,t)=>e+t,0):0}get _transport(){return this.area.manager._transport}get _path(){return[this.area.name,this.id]}async _writer(e){let t=this._writers.get(e);if(!t){let n=this._append&&e in this._sizes,r=n&&(this._info.growable??[]).includes(e)?this._sizes[e]:void 0;t=this._transport.call(`openWriter`,{path:this._path,name:e,truncate:!n,length:r}),this._writers.set(e,t)}return(await t).id}async write(e,t,{at:n,transfer:r=!1}={}){this._assertOpen();let{args:i,list:a}=(typeof Blob<`u`&&t instanceof Blob?null:S(t,{copy:!0,transfer:r}))??S(await t.arrayBuffer(),{copy:!0,transfer:!0}),o=await this._writer(e);return this._transport.call(`write`,{id:o,at:n,...i},a)}async writeFile(e,t){this._assertOpen(),typeof Blob<`u`&&t instanceof Blob&&(t=await t.arrayBuffer());let{args:n,list:r}=S(t,{copy:!0,transfer:!0}),{size:i}=await this._transport.call(`writeFile`,{path:this._path,name:e,...n},r);return this._sizes[e]=i,i}writeJSON(e,t){return this.writeFile(e,JSON.stringify(t))}async writeStream(e,t,{onProgress:n=null,signal:r=null,batchBytes:i=b}={}){let a=t.getReader(),o=[],s=new Uint8Array(i),c=0,l=0,u=async()=>{if(c===0)return;let t=c===i?s:s.slice(0,c);s=new Uint8Array(i),c=0,o.push(this.write(e,t,{transfer:!0})),o.length>=4&&await o.shift()};try{for(;;){if(r?.aborted)throw r.reason??new DOMException(`aborted`,`AbortError`);let{done:e,value:t}=await a.read();if(e)break;let o=0;for(;o<t.length;){let e=Math.min(t.length-o,i-c);s.set(t.subarray(o,o+e),c),c+=e,o+=e,l+=e,c===i&&await u()}n?.(l)}return await u(),await Promise.all(o),l}catch(e){throw a.cancel().catch(()=>{}),await Promise.allSettled(o),e}}async commit(e={}){this._assertOpen(),this._done=!0;try{for(let[e,t]of this._writers){let{size:n}=await this._transport.call(`closeWriter`,{id:(await t).id});this._sizes[e]=n}this._writers.clear();let t=Date.now(),n={v:1,key:this.key,label:this._info.label??``,kind:this.area.kind,files:{...this._sizes},bytes:Object.values(this._sizes).reduce((e,t)=>e+t,0),createdAt:this._info.createdAt??t,lastUsed:t,pinned:this._info.pinned===!0,extra:{...this._info.extra,...e}},r=this._info.growable??[];r.length&&(n.growable=r);let{args:i,list:a}=S(JSON.stringify(n),{copy:!1});return await this._transport.call(`writeFile`,{path:this._path,name:_,...i},a),this.area.kind===h.CACHE&&this.area.manager._countCacheBytes(n.bytes-this._committedBytes),this.area.manager._changed(this.area.name),n}catch(e){throw await this._discard(),this.area.manager._writeFailed(this.area.name,e),e}finally{this._release?.(),this._release=null}}async abort(){if(!this._done){this._done=!0;try{this._append?await this._closeAll(!0):await this._discard()}finally{this._release?.(),this._release=null}}}async _closeAll(e){for(let t of this._writers.values())try{await this._transport.call(`closeWriter`,{id:(await t).id,abort:e})}catch{}this._writers.clear()}async _discard(){await this._closeAll(!0),await this.area._removeDir(this.id)}_assertOpen(){if(this._done)throw Error(`storage: entry ${this.area.name}/${this.id} is already committed or aborted`)}},D=class{constructor(e,t,n){this.manager=e,this.name=t,this.kind=n}_lockName(e){return`${this.manager.namespace}:store:${this.name}:${e}`}async _dir(e=!1){try{return await this.manager._root.getDirectoryHandle(this.name,{create:e})}catch(e){if(e.name===`NotFoundError`)return null;throw e}}async _entryDir(e,t=!1){let n=await this._dir(t);if(!n)return null;try{return await n.getDirectoryHandle(e,{create:t})}catch(e){if(e.name===`NotFoundError`)return null;throw e}}async _removeDir(e){let t=await this._dir(!1);if(t)try{await t.removeEntry(e,{recursive:!0})}catch(e){if(e.name!==`NotFoundError`)throw e}}async _validMeta(e,t=null){let n=await C(e,_);if(!n||n.v!==1||typeof n.key!=`string`||t!==null&&n.key!==t)return null;let r=n.growable??[];for(let[t,i]of Object.entries(n.files??{}))try{let n=await(await e.getFileHandle(t)).getFile();if(n.size!==i&&!(r.includes(t)&&n.size>i))return null}catch{return null}return n}async open(t,{wait:n=!1}={}){let r=await d(t),i=await o(this._lockName(r),{mode:`shared`,ifAvailable:!n});if(!i)return null;try{let e=await this._entryDir(r),n=e?await this._validMeta(e,t):null;return n?(Date.now()-n.lastUsed>36e5&&this._touch(r,n),new T(this,r,n,e,i)):(i(),null)}catch(t){return i(),this.manager._issue(e.STORAGE_READ_FAILED,`could not open ${this.name} entry`,{error:t.message}),null}}async has(e){let t=await this.open(e);return t?.release(),!!t}_touch(e,t){let n={...t,lastUsed:Date.now()},{args:r,list:i}=S(JSON.stringify(n),{copy:!1});this.manager._transport.call(`writeFile`,{path:[this.name,e],name:_,...r},i).catch(()=>{}),t.lastUsed=n.lastUsed}async create(t,{label:n=``,pinned:r=!1,expectedBytes:i=0,extra:a={},growable:s=[]}={}){let c=await d(t),l=await o(this._lockName(c),{mode:`exclusive`});try{return i>0&&!await this.manager.ensureSpace(i,this.kind)?(l(),this.manager._issue(e.STORAGE_QUOTA_EXCEEDED,`no room for ${(i/1048576).toFixed(0)} MB in ${this.name}`,{area:this.name,expectedBytes:i}),null):(await this._removeDir(c),await this._entryDir(c,!0),new E(this,c,t,{label:n,pinned:r,extra:a,growable:s},l))}catch(e){return l(),this.manager._writeFailed(this.name,e),null}}async patchMeta(e,t){let n=await d(e),r=await o(this._lockName(n),{mode:`shared`,ifAvailable:!0});if(!r)return!1;try{let r=await this._entryDir(n),i=r?await this._validMeta(r,e):null;if(!i)return!1;let{args:a,list:o}=S(JSON.stringify({...i,...t,v:1,key:e}),{copy:!1});return await this.manager._transport.call(`writeFile`,{path:[this.name,n],name:_,...a},o),!0}finally{r()}}async edit(e){let t=await d(e),n=await o(this._lockName(t),{mode:`exclusive`});try{let r=await this._entryDir(t),i=r?await this._validMeta(r,e):null;if(!i)return n(),null;let a={label:i.label,pinned:i.pinned,extra:i.extra,createdAt:i.createdAt,growable:i.growable};return new E(this,t,e,a,n,{sizes:i.files,append:!0})}catch(e){return n(),this.manager._writeFailed(this.name,e),null}}async remove(e){return this.removeById(await d(e))}async removeById(e){let t=await o(this._lockName(e),{mode:`exclusive`,ifAvailable:!0});if(!t)return!1;try{return await this._removeDir(e),this.manager._changed(this.name),!0}finally{t()}}async list(){let e=await this._dir(!1);if(!e)return[];let t=[];for await(let[n,r]of w(e)){let e=await C(r,_);e?.v===1&&t.push({...e,id:n})}return t}async clear(){let e=0;for(let{id:t}of await this.list())await this.removeById(t)&&e++;return e}async sweep(){let e=await this._dir(!1);if(!e)return 0;let t=await s(),n=0;for await(let[r,i]of w(e))t.has(this._lockName(r))||await this._validMeta(i)||await this.removeById(r)&&n++;return n}},O=class extends f{constructor({root:e,transport:t,namespace:n}){super(),this.namespace=n,this._root=e,this._transport=t,this._areas=new Map,this._budget=null,this._cacheTotal=null;for(let e of Object.values(g))this.defineArea(e,{kind:e===g.SPILL?h.SCRATCH:h.CACHE})}defineArea(e,{kind:t=h.CACHE}={}){let n=this._areas.get(e);if(n){if(n.kind!==t)throw Error(`storage: area \"${e}\" is already defined as ${n.kind}`);return n}let r=new D(this,e,t);return this._areas.set(e,r),r}area(e){let t=this._areas.get(e);if(!t)throw Error(`storage: unknown area \"${e}\"`);return t}get areaNames(){return[...this._areas.keys()]}async estimate(){let e=typeof navigator<`u`?navigator.storage:null;if(!e?.estimate)return{quota:1/0,usage:0};let{quota:t=1/0,usage:n=0}=await e.estimate();return{quota:t,usage:n}}async persisted(){return await globalThis.navigator?.storage?.persisted?.()===!0}async persist(){let e=await globalThis.navigator?.storage?.persist?.()===!0;return this._changed(null),e}async budget(){if(this._budget!==null)return this._budget;let{quota:e}=await this.estimate();return Math.min(e*.3,v)}setBudget(e){this._budget=e===null?null:Math.max(0,e),this._changed(null)}async _cacheBytes(){let e=this._cacheTotal;return(!e||Date.now()-e.at>3e4)&&(e=this._cacheTotal={at:Date.now(),bytes:0,ready:null},e.ready=this._cacheEntries().then(t=>{e.bytes+=t.reduce((e,t)=>e+(t.meta.bytes??0),0)}),e.ready.catch(()=>{this._cacheTotal===e&&(this._cacheTotal=null)})),await e.ready,e.bytes}_countCacheBytes(e){this._cacheTotal&&(this._cacheTotal.bytes+=e)}async _cacheEntries(){let e=[];for(let t of this._areas.values())if(t.kind===h.CACHE)for(let n of await t.list())e.push({area:t,meta:n});return e}async usage(){let{quota:e,usage:t}=await this.estimate(),n={},r=0;for(let e of this._areas.values()){let t=await e.list(),i=t.reduce((e,t)=>e+(t.bytes??0),0);n[e.name]={kind:e.kind,bytes:i,entries:t.length},e.kind===h.CACHE&&(r+=i)}return{quota:e,usage:t,persisted:await this.persisted(),budget:await this.budget(),cacheBytes:r,areas:n}}async collect({freeBytes:e=null}={}){let t=await this._cacheEntries(),n=await this.budget(),r=this._cacheTotal={at:Date.now(),bytes:t.reduce((e,t)=>e+(t.meta.bytes??0),0),ready:null},i=e??Math.max(0,r.bytes-n);if(i<=0)return 0;let a=await s(),o=t.filter(({area:e,meta:t})=>!t.pinned&&!a.has(e._lockName(t.id))).sort((e,t)=>e.meta.lastUsed-t.meta.lastUsed),c=0;for(let{area:e,meta:t}of o){if(c>=i)break;await e.removeById(t.id)&&(c+=t.bytes??0,r.bytes-=t.bytes??0)}return c}async ensureSpace(e,t=h.CACHE){let n=async()=>{let{quota:n,usage:r}=await this.estimate(),i=e+y-(n-r);return t===h.CACHE?{free:i,budget:await this._cacheBytes()+e-await this.budget()}:{free:i,budget:0}},r=await n();return r.free<=0&&r.budget<=0?!0:(await this.collect({freeBytes:Math.max(r.free,r.budget)}),(await n()).free<=0)}async sweep(){let e=0;for(let t of this._areas.values())e+=await t.sweep(),t.kind===h.SCRATCH&&(e+=await t.clear());return e}_changed(e){this.dispatchEvent({type:`change`,area:e})}_issue(e,t,n={}){this.dispatchEvent({type:`issue`,code:e,message:t,detail:n})}_writeFailed(t,n){let r=n?.name===`QuotaExceededError`;this._issue(r?e.STORAGE_QUOTA_EXCEEDED:e.STORAGE_WRITE_FAILED,`${t}: ${n?.message??n}`,{area:t,error:n?.name})}dispose(){this._transport?.dispose(),this._transport=null,this._areas.clear()}};function k({namespace:e,root:t}){let n=new m(t);n.inline=!0;let r=new O({root:t,transport:n,namespace:e});return r.sweep().catch(()=>{}),r}const A=Object.freeze({IMMUTABLE:`immutable`,REVALIDATE:`revalidate`,NETWORK:`network`}),j=(e,t)=>({loaded:e,total:t,lengthComputable:t>0&&e<=t}),M=(e,t)=>e.headers?.get?.(t)??null,N=e=>e.reason??new DOMException(`aborted`,`AbortError`);function P(e){try{let t=new URL(e,globalThis.location?.href??`http://localhost/`).pathname;return decodeURIComponent(t.split(`/`).pop())||`download`}catch{return`download`}}async function F(e,{onProgress:t,signal:n}){let r=Number(M(e,`content-length`))||0,i=M(e,`content-type`)??``;if(!e.body)return new Blob([await e.arrayBuffer()],{type:i});let a=e.body.getReader(),o=[],s=0;for(;;){if(n?.aborted)throw a.cancel().catch(()=>{}),N(n);let{done:e,value:i}=await a.read();if(e)break;o.push(i),s+=i.length,t?.(j(s,r))}return new Blob(o,{type:i})}const I=(e,t,n)=>new File([e],t,{type:n||e.type,lastModified:e.lastModified??Date.now()}),L=()=>{};var R=class{constructor(e){this._storage=e,this._revalidating=new Set}get _area(){return this._storage?.area(g.DOWNLOADS)??null}async fetch(e,{key:t=e,name:n=P(e),policy:r=A.REVALIDATE,maxAgeMs:i=864e5,onProgress:a=null,signal:o=null,fetchOptions:s={}}={}){let c=this._area;if(c&&r!==A.NETWORK){let o=await c.open(t);if(o){let c=await o.file(`data`);if(c)return r===A.REVALIDATE&&Date.now()-(o.extra.checkedAt??0)>=i&&this._revalidate(e,t,n,o.extra,s),a?.(j(c.size,c.size)),{file:I(c,n,o.extra.contentType),release:()=>o.release(),fromCache:!0};o.release()}}return this._download(e,t,n,{onProgress:a,signal:o,fetchOptions:s,cache:!!c})}async has(e){return await this._area?.has(e)===!0}async _download(e,t,n,{onProgress:r,signal:i,fetchOptions:a,cache:o}){if(i?.aborted)throw N(i);let s=await fetch(e,{...a,signal:i});if(!s.ok)throw Error(`HTTP ${s.status} fetching ${e}`);let c=Number(M(s,`content-length`))||0,l={url:e,contentType:M(s,`content-type`)??``,lastModified:M(s,`last-modified`),contentLength:c||null,checkedAt:Date.now()},u=o&&s.body?await this._area.create(t,{label:n,expectedBytes:c}):null;if(!u)return{file:I(await F(s,{onProgress:r,signal:i}),n,l.contentType),release:L,fromCache:!1};try{await u.writeStream(`data`,s.body,{signal:i,onProgress:e=>r?.(j(e,c))}),await u.commit(l)}catch(o){if(await u.abort(),o?.name!==`QuotaExceededError`)throw o;return this._download(e,t,n,{onProgress:r,signal:i,fetchOptions:a,cache:!1})}let d=await this._area.open(t,{wait:!0}),f=d&&await d.file(`data`);if(!f)throw d?.release(),Error(`storage: ${n} vanished right after it was saved`);return{file:I(f,n,l.contentType),release:()=>d.release(),fromCache:!1}}async _revalidate(e,t,n,r,i){if(this._revalidating.has(t))return;this._revalidating.add(t);let a=!1;try{let t=new Headers(i?.headers);t.set(`Range`,`bytes=0-0`);let n=await fetch(e,{...i,headers:t});if(n.body?.cancel().catch(()=>{}),n.ok){let e=M(n,`last-modified`),t=n.status===206?Number(M(n,`content-range`)?.match(/\\/(\\d+)$/)?.[1])||null:Number(M(n,`content-length`))||null;a=!!(e&&r.lastModified&&e!==r.lastModified||t&&r.contentLength&&t!==r.contentLength)}}catch{}try{if(a){let{release:r}=await this._download(e,t,n,{fetchOptions:i,cache:!0});r()}else await this._area.patchMeta(t,{extra:{...r,checkedAt:Date.now()}})}catch{}finally{this._revalidating.delete(t)}}};let z={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`,storage:`auto`},B=null;async function V(){return B||(B=await import(z.ortRuntimeUrl),B.env.wasm.wasmPaths=z.ortWasmPaths,B.env.logLevel=`error`,B)}let H=null,U=null,W=null;function G(){return W??=(async()=>{if(z.storage===!1||!navigator.storage?.getDirectory)return new R(null);try{let e=await(await navigator.storage.getDirectory()).getDirectoryHandle(z.cacheNamespace,{create:!0}),t=k({namespace:z.cacheNamespace,root:e});return await K(t).catch(()=>{}),new R(t)}catch{return new R(null)}})(),W}async function K(e){let t=`${z.cacheNamespace}:ai-upscaler-models`;if(typeof indexedDB>`u`||!indexedDB.databases||!(await indexedDB.databases()).some(e=>e.name===t))return;let n=await new Promise((e,n)=>{let r=indexedDB.open(t);r.onerror=()=>n(r.error),r.onsuccess=()=>{let t=r.result;if(!t.objectStoreNames.contains(`models`)){t.close(),e([]);return}let i=[],a=t.transaction(`models`,`readonly`).objectStore(`models`).openCursor();a.onerror=()=>n(a.error),a.onsuccess=()=>{let n=a.result;if(!n){t.close(),e(i);return}i.push([n.key,n.value]),n.continue()}}}),r=e.area(`downloads`);for(let[e,t]of n){if(typeof e!=`string`||!(t instanceof ArrayBuffer)||await r.has(e))continue;let n=await r.create(e,{label:e.split(`/`).pop(),expectedBytes:t.byteLength});n&&(await n.write(`data`,t,{transfer:!0}),await n.commit({url:e,contentType:`application/octet-stream`,checkedAt:Date.now()}))}await new Promise(e=>{let n=indexedDB.deleteDatabase(t);n.onsuccess=n.onerror=n.onblocked=()=>e()})}async function q(e){let{file:t,release:n,fromCache:r}=await(await G()).fetch(e);try{let e=await t.arrayBuffer();return r&&console.log(`AI Upscaler Worker: model loaded from cache (${(e.byteLength/1024/1024).toFixed(1)}MB)`),e}finally{n()}}async function J(e,t){if(H&&U===e){self.postMessage({type:`loaded`,backend:`webgpu`});return}H&&=(await H.release(),null);let[n,r]=await Promise.all([q(e),V()]);H=await r.InferenceSession.create(n,t),U=e;let i=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||``);i=n?128:r?256:512,console.log(`AI Upscaler Worker: GPU=\"${t?.description||t?.device||`unknown`}\", tileSize=${i}`)}catch{}let a=(n.byteLength/1024/1024).toFixed(1);console.log(`AI Upscaler Worker: model loaded (${a}MB), backend: webgpu`),self.postMessage({type:`loaded`,backend:`webgpu`,tileSize:i})}async function Y(e,t,n,r){let i=await V(),a=H.inputNames[0],o=H.outputNames[0],s=new i.Tensor(`float32`,e,[1,3,n,t]),c=(await H.run({[a]:s}))[o].data;self.postMessage({type:`inferred`,outputData:c,id:r},[c.buffer])}self.onmessage=async e=>{let{type:t}=e.data;try{t===`load`?(e.data.ortRuntimeUrl&&(z.ortRuntimeUrl=e.data.ortRuntimeUrl),e.data.ortWasmPaths&&(z.ortWasmPaths=e.data.ortWasmPaths),e.data.cacheNamespace&&(z.cacheNamespace=e.data.cacheNamespace),e.data.storage!==void 0&&(z.storage=e.data.storage),await J(e.data.url,e.data.sessionOptions)):t===`infer`?await Y(e.data.tileData,e.data.width,e.data.height,e.data.id):t===`dispose`&&H&&(await H.release(),H=null,U=null)}catch(t){self.postMessage({type:`error`,message:t.message,id:e.data?.id})}};", Ts = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", ws], { type: "text/javascript;charset=utf-8" });
|
|
4440
|
+
function Es(e) {
|
|
4001
4441
|
let t;
|
|
4002
4442
|
try {
|
|
4003
|
-
if (t =
|
|
4443
|
+
if (t = Ts && (self.URL || self.webkitURL).createObjectURL(Ts), !t) throw "";
|
|
4004
4444
|
let n = new Worker(t, {
|
|
4005
4445
|
type: "module",
|
|
4006
4446
|
name: e?.name
|
|
@@ -4009,7 +4449,7 @@ function Fo(e) {
|
|
|
4009
4449
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
4010
4450
|
}), n;
|
|
4011
4451
|
} catch {
|
|
4012
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
4452
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(ws), {
|
|
4013
4453
|
type: "module",
|
|
4014
4454
|
name: e?.name
|
|
4015
4455
|
});
|
|
@@ -4017,7 +4457,7 @@ function Fo(e) {
|
|
|
4017
4457
|
}
|
|
4018
4458
|
//#endregion
|
|
4019
4459
|
//#region src/Passes/AIUpscaler.js
|
|
4020
|
-
var
|
|
4460
|
+
var Ds = {
|
|
4021
4461
|
fast: {
|
|
4022
4462
|
2: "2x-spanx2-ch48.onnx",
|
|
4023
4463
|
4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
|
|
@@ -4031,17 +4471,17 @@ var Io = {
|
|
|
4031
4471
|
4: "4xNomos2_hq_mosr_fp32.onnx"
|
|
4032
4472
|
}
|
|
4033
4473
|
};
|
|
4034
|
-
function
|
|
4035
|
-
let { upscalerModelBaseUrl: e } =
|
|
4036
|
-
for (let n in
|
|
4474
|
+
function Os() {
|
|
4475
|
+
let { upscalerModelBaseUrl: e } = ot(), t = {};
|
|
4476
|
+
for (let n in Ds) {
|
|
4037
4477
|
t[n] = {};
|
|
4038
|
-
for (let r in
|
|
4478
|
+
for (let r in Ds[n]) t[n][r] = e + Ds[n][r];
|
|
4039
4479
|
}
|
|
4040
4480
|
return t;
|
|
4041
4481
|
}
|
|
4042
|
-
var
|
|
4482
|
+
var ks = {
|
|
4043
4483
|
get QUALITY_PRESETS() {
|
|
4044
|
-
return
|
|
4484
|
+
return Os();
|
|
4045
4485
|
},
|
|
4046
4486
|
TILE_SIZE: 512,
|
|
4047
4487
|
TILE_OVERLAP: 16,
|
|
@@ -4052,17 +4492,17 @@ var Ro = {
|
|
|
4052
4492
|
}],
|
|
4053
4493
|
graphOptimizationLevel: "all"
|
|
4054
4494
|
}
|
|
4055
|
-
},
|
|
4495
|
+
}, As = class extends fr {
|
|
4056
4496
|
constructor(e, t, n = {}) {
|
|
4057
4497
|
if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
|
|
4058
|
-
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 || (() =>
|
|
4498
|
+
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 || (() => tr), this.getSaturation = n.getSaturation || (() => 1), this.getDisplayGain = n.getDisplayGain || (() => null), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.refreshInput = n.refreshInput || null, this.tileSize = n.tileSize || ks.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
|
|
4059
4499
|
isUpscaling: !1,
|
|
4060
4500
|
isLoading: !1,
|
|
4061
4501
|
abortController: null
|
|
4062
|
-
}, this._worker = null, this._currentModelUrl = null, this._tileId = 0, this._pendingWorkerHandlers = /* @__PURE__ */ new
|
|
4502
|
+
}, this._worker = null, this._currentModelUrl = null, this._tileId = 0, this._pendingWorkerHandlers = /* @__PURE__ */ new Map(), this._upscaledAlpha = null, this._upscaledAlphaWidth = 0, this._backupCanvas = null, this._baseWidth = e.width, this._baseHeight = e.height, this._toneMapper = null;
|
|
4063
4503
|
}
|
|
4064
4504
|
async _ensureSession() {
|
|
4065
|
-
let e =
|
|
4505
|
+
let e = ks.QUALITY_PRESETS[this.quality];
|
|
4066
4506
|
if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
|
|
4067
4507
|
let t = e[this.scaleFactor];
|
|
4068
4508
|
if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
|
|
@@ -4072,14 +4512,14 @@ var Ro = {
|
|
|
4072
4512
|
message: `Loading ${this.scaleFactor}x upscale model...`
|
|
4073
4513
|
});
|
|
4074
4514
|
try {
|
|
4075
|
-
this._worker ||= new
|
|
4515
|
+
this._worker ||= new Es(), await new Promise((e, n) => {
|
|
4076
4516
|
let r = (t) => {
|
|
4077
4517
|
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)));
|
|
4078
|
-
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o, storage: s } =
|
|
4518
|
+
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o, storage: s } = ot();
|
|
4079
4519
|
this._worker.addEventListener("message", r), this._worker.postMessage({
|
|
4080
4520
|
type: "load",
|
|
4081
4521
|
url: t,
|
|
4082
|
-
sessionOptions:
|
|
4522
|
+
sessionOptions: ks.SESSION_OPTIONS,
|
|
4083
4523
|
ortRuntimeUrl: i,
|
|
4084
4524
|
ortWasmPaths: a,
|
|
4085
4525
|
cacheNamespace: o,
|
|
@@ -4096,30 +4536,30 @@ var Ro = {
|
|
|
4096
4536
|
}
|
|
4097
4537
|
}
|
|
4098
4538
|
}
|
|
4099
|
-
async start() {
|
|
4539
|
+
async start(e = null) {
|
|
4100
4540
|
if (!this.enabled || this.state.isUpscaling || this.state.isLoading) return !1;
|
|
4101
4541
|
this.dispatchEvent({ type: "start" });
|
|
4102
|
-
let
|
|
4103
|
-
if (
|
|
4542
|
+
let t = performance.now(), n = await this.execute(e);
|
|
4543
|
+
if (n) {
|
|
4104
4544
|
this.renderer?.resetState?.();
|
|
4105
|
-
let
|
|
4106
|
-
console.log(`AI Upscaler: ${this.scaleFactor}x upscale completed in ${
|
|
4545
|
+
let e = performance.now() - t;
|
|
4546
|
+
console.log(`AI Upscaler: ${this.scaleFactor}x upscale completed in ${e.toFixed(1)}ms`);
|
|
4107
4547
|
}
|
|
4108
|
-
return
|
|
4548
|
+
return n;
|
|
4109
4549
|
}
|
|
4110
4550
|
_revealOutput() {
|
|
4111
4551
|
this.output.style.display = "block", this.input.style.opacity = "0";
|
|
4112
4552
|
}
|
|
4113
|
-
async execute() {
|
|
4553
|
+
async execute(e = null) {
|
|
4114
4554
|
if (!this.enabled) return !1;
|
|
4115
|
-
this.state.abortController = new AbortController(), this.state.isUpscaling = !0, this.hdr && this.getGPUTextures ? this._capturedSource = await this._captureSourceHDR() : this._capturedSource = this._captureSource(), this._createBackup(this._capturedSource);
|
|
4116
|
-
let
|
|
4117
|
-
this.output.width =
|
|
4118
|
-
let
|
|
4555
|
+
this.state.abortController = new AbortController(), this.state.isUpscaling = !0, e ? this._capturedSource = e : this.hdr && this.getGPUTextures ? this._capturedSource = await this._captureSourceHDR() : this._capturedSource = this._captureSource(), this._createBackup(this._capturedSource);
|
|
4556
|
+
let t = this._capturedSource.width * this.scaleFactor, n = this._capturedSource.height * this.scaleFactor;
|
|
4557
|
+
this.output.width = t, this.output.height = n;
|
|
4558
|
+
let r = this.output.getContext("2d", {
|
|
4119
4559
|
willReadFrequently: !0,
|
|
4120
4560
|
alpha: !0
|
|
4121
4561
|
});
|
|
4122
|
-
|
|
4562
|
+
r.imageSmoothingEnabled = !0, r.imageSmoothingQuality = "high", r.drawImage(this._backupCanvas, 0, 0, t, n), this._revealOutput();
|
|
4123
4563
|
try {
|
|
4124
4564
|
return await this._ensureSession(), await this._runUpscale(), this.dispatchEvent({
|
|
4125
4565
|
type: "resolution_changed",
|
|
@@ -4154,7 +4594,7 @@ var Ro = {
|
|
|
4154
4594
|
alpha: !0
|
|
4155
4595
|
});
|
|
4156
4596
|
this._cacheUpscaledAlpha(t, n * i, r * i);
|
|
4157
|
-
let o =
|
|
4597
|
+
let o = ks.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
|
|
4158
4598
|
for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
|
|
4159
4599
|
if (e.aborted) throw new DOMException("Aborted", "AbortError");
|
|
4160
4600
|
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);
|
|
@@ -4195,14 +4635,15 @@ var Ro = {
|
|
|
4195
4635
|
let e = this.getGPUTextures();
|
|
4196
4636
|
if (!e?.color) throw Error("No GPU color texture available for HDR capture");
|
|
4197
4637
|
let t = e.color, { width: n, height: r } = t;
|
|
4198
|
-
this._toneMapper ??= new
|
|
4638
|
+
this._toneMapper ??= new Dt(this.renderer.backend.device, "aiupscaler-tonemap", {
|
|
4199
4639
|
input: "texture",
|
|
4200
4640
|
output: "planar"
|
|
4201
4641
|
}), this._toneMapper.ensureSize(n, r);
|
|
4202
4642
|
let i = await this._toneMapper.toPlanar(t, {
|
|
4203
4643
|
exposure: this.getExposure(),
|
|
4204
|
-
toneMapping: this.getToneMapping() ??
|
|
4205
|
-
saturation: this.getSaturation()
|
|
4644
|
+
toneMapping: this.getToneMapping() ?? tr,
|
|
4645
|
+
saturation: this.getSaturation(),
|
|
4646
|
+
gain: this.getDisplayGain()
|
|
4206
4647
|
});
|
|
4207
4648
|
return this._toneMapper.release(), {
|
|
4208
4649
|
planes: i,
|
|
@@ -4234,7 +4675,7 @@ var Ro = {
|
|
|
4234
4675
|
let o = (e) => {
|
|
4235
4676
|
e.data.id === r && (this._worker.removeEventListener("message", o), this._pendingWorkerHandlers.delete(o), e.data.type === "inferred" ? i(e.data.outputData) : e.data.type === "error" && a(Error(e.data.message)));
|
|
4236
4677
|
};
|
|
4237
|
-
this._pendingWorkerHandlers.
|
|
4678
|
+
this._pendingWorkerHandlers.set(o, a), this._worker.addEventListener("message", o), this._worker.postMessage({
|
|
4238
4679
|
type: "infer",
|
|
4239
4680
|
tileData: e,
|
|
4240
4681
|
width: t,
|
|
@@ -4296,7 +4737,7 @@ var Ro = {
|
|
|
4296
4737
|
this.hdr = !!e;
|
|
4297
4738
|
}
|
|
4298
4739
|
setQuality(e) {
|
|
4299
|
-
if (!
|
|
4740
|
+
if (!ks.QUALITY_PRESETS[e]) {
|
|
4300
4741
|
console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
|
|
4301
4742
|
return;
|
|
4302
4743
|
}
|
|
@@ -4313,15 +4754,15 @@ var Ro = {
|
|
|
4313
4754
|
this._baseWidth = e, this._baseHeight = t;
|
|
4314
4755
|
}
|
|
4315
4756
|
_cleanupPendingWorkerHandlers() {
|
|
4316
|
-
|
|
4757
|
+
for (let [e, t] of this._pendingWorkerHandlers) this._worker?.removeEventListener("message", e), t(new DOMException("Aborted", "AbortError"));
|
|
4317
4758
|
this._pendingWorkerHandlers.clear();
|
|
4318
4759
|
}
|
|
4319
4760
|
async dispose() {
|
|
4320
4761
|
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._toneMapper?.dispose(), this._toneMapper = null, console.log("AIUpscaler disposed");
|
|
4321
4762
|
}
|
|
4322
|
-
},
|
|
4323
|
-
constructor({ renderer: e, mainCanvas: t, stages: n, pipeline: r, getExposure: i, getSaturation: a,
|
|
4324
|
-
super(), this.renderer = e, this._issues =
|
|
4763
|
+
}, js = Ke("neural"), Ms = 120, Ns = 2, Ps = 1, Fs = 0, Is = 300, Ls = 5, Rs = 3, zs = 3, Bs = 16, Vs = (e) => Math.max(0, 1 - e / Bs), Hs = class extends fr {
|
|
4764
|
+
constructor({ renderer: e, mainCanvas: t, stages: n, pipeline: r, getExposure: i, getSaturation: a, getDisplayGain: o = null, issues: s = null }) {
|
|
4765
|
+
super(), this.renderer = e, this._issues = s, this.mainCanvas = t, this.upscalerCanvas = this._createUpscalerCanvas(t), this.pipeline = r, this._stages = n, this._getExposure = i, this._getSaturation = a, this._getDisplayGain = o, this.denoiser = null, this.upscaler = null, this.upscalerBackend = "esrgan", this._neuralUpscaler = null, this.neuralRendering = !1, this.neuralRenderingSettings = {}, this._retouch = null, this._superResModule = null, this._neuralPostBusy = !1, this._postIsStillComplete = null, this._postRun = null, this._postRedo = null, this._postCancelled = !1, this._finalQuality = ei.oidnQuality, this.finalDenoise = ei.enableOIDN, this.continuousDenoise = ei.continuousDenoise, this.continuousDenoiseInterval = ei.continuousDenoiseInterval, this._lastCadenceAt = -Infinity, this._lastCadenceSamples = 0, this._failedRefreshes = 0, this._cadenceSuspended = !1, this._movingDenoiseMs = [], this._movingHopeless = !1, this._holdWhileMoving = null, this._onReset = null, this._onPostProcessRefresh = null, this._onDisplayRefresh = null, this.temporalHistory = ei.oidnTemporalHistory, this._history = null, this._historyDirty = !0, this._knownResetCount = 0, this._seenTracedFrames = 0, this._viewProj = new br(), this._historyCamera = {
|
|
4325
4766
|
world: null,
|
|
4326
4767
|
projInv: null,
|
|
4327
4768
|
viewProj: null,
|
|
@@ -4330,7 +4771,7 @@ var Ro = {
|
|
|
4330
4771
|
count: 0,
|
|
4331
4772
|
leaves: new Uint32Array(),
|
|
4332
4773
|
toPrev: new Float32Array()
|
|
4333
|
-
}, this._matA = new
|
|
4774
|
+
}, this._matA = new br(), this._matB = new br(), this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._pendingStartUpscaler = null, this._pendingCloseDenoise = null, this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._denoiserTileHandler = null, this._denoiserErrorHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null;
|
|
4334
4775
|
}
|
|
4335
4776
|
_createUpscalerCanvas(e) {
|
|
4336
4777
|
let t = e.parentNode;
|
|
@@ -4352,9 +4793,9 @@ var Ro = {
|
|
|
4352
4793
|
}
|
|
4353
4794
|
setupDenoiser() {
|
|
4354
4795
|
let e = this._stages.pathTracer;
|
|
4355
|
-
this.denoiser = new
|
|
4356
|
-
enableOIDN:
|
|
4357
|
-
oidnQuality:
|
|
4796
|
+
this.denoiser = new ss(this.renderer, {
|
|
4797
|
+
enableOIDN: ei.enableOIDN,
|
|
4798
|
+
oidnQuality: ei.oidnQuality,
|
|
4358
4799
|
backendParams: () => ({
|
|
4359
4800
|
device: this.renderer.backend.device,
|
|
4360
4801
|
adapterInfo: null
|
|
@@ -4392,9 +4833,9 @@ var Ro = {
|
|
|
4392
4833
|
setupUpscaler() {
|
|
4393
4834
|
if (!this.upscalerCanvas) return;
|
|
4394
4835
|
let e = this._stages.pathTracer;
|
|
4395
|
-
this.upscaler = new
|
|
4396
|
-
scaleFactor:
|
|
4397
|
-
quality:
|
|
4836
|
+
this.upscaler = new As(this.upscalerCanvas, this.renderer, {
|
|
4837
|
+
scaleFactor: ei.upscalerScale || 2,
|
|
4838
|
+
quality: ei.upscalerQuality || "fast",
|
|
4398
4839
|
getSourceCanvas: () => this.renderer.domElement,
|
|
4399
4840
|
refreshInput: () => {
|
|
4400
4841
|
let e = this.pipeline?.context;
|
|
@@ -4407,8 +4848,9 @@ var Ro = {
|
|
|
4407
4848
|
},
|
|
4408
4849
|
getExposure: () => this._getEffectiveExposure(),
|
|
4409
4850
|
getToneMapping: () => this._getToneMapping(),
|
|
4410
|
-
getSaturation: () => this._getSaturation()
|
|
4411
|
-
|
|
4851
|
+
getSaturation: () => this._getSaturation(),
|
|
4852
|
+
getDisplayGain: () => this._getDisplayGain?.() ?? null
|
|
4853
|
+
}), this.upscaler.enabled = ei.enableUpscaler || !1, this._upscalerResChangedHandler = (e) => this.dispatchEvent({
|
|
4412
4854
|
type: j.RESOLUTION_CHANGED,
|
|
4413
4855
|
width: e.width,
|
|
4414
4856
|
height: e.height
|
|
@@ -4443,8 +4885,7 @@ var Ro = {
|
|
|
4443
4885
|
this._applyASVGFPreset(e);
|
|
4444
4886
|
}
|
|
4445
4887
|
setAutoExposureEnabled(e, t) {
|
|
4446
|
-
|
|
4447
|
-
n.autoExposure && (n.autoExposure.enabled = e, !e && this.renderer && (this.renderer.toneMappingExposure = t));
|
|
4888
|
+
this._stages.autoExposure?.setEnabled(e, t);
|
|
4448
4889
|
}
|
|
4449
4890
|
get requiresMotionVectors() {
|
|
4450
4891
|
return !!(this._stages.asvgf?.enabled || this._stages.nrd?.enabled);
|
|
@@ -4468,8 +4909,8 @@ var Ro = {
|
|
|
4468
4909
|
get holdsWhileMoving() {
|
|
4469
4910
|
if (!this._stages.pathTracer?.viewIsChanging || !this.continuousDenoise || this._cadenceSuspended || !this.denoiser?.enabled || this._movingHopeless) return !1;
|
|
4470
4911
|
let e = this.movingCostMs, t = this._movingDenoiseMs.length;
|
|
4471
|
-
e >
|
|
4472
|
-
let n = !this._movingHopeless && (t < 2 || e <=
|
|
4912
|
+
e > Is * Rs && (this._movingHopeless = !0, this._syncGBufferStages());
|
|
4913
|
+
let n = !this._movingHopeless && (t < 2 || e <= Is);
|
|
4473
4914
|
return this._holdWhileMoving = (this._holdWhileMoving === null || this._holdWhileMoving) && n, this._holdWhileMoving;
|
|
4474
4915
|
}
|
|
4475
4916
|
skipsTrace() {
|
|
@@ -4486,7 +4927,7 @@ var Ro = {
|
|
|
4486
4927
|
this.pipeline?.context?.removeTexture("oidn:output"), this.denoiser?.invalidateOutput();
|
|
4487
4928
|
}
|
|
4488
4929
|
_checkHeldFrameHealthy() {
|
|
4489
|
-
!this.denoiser?.hasOutput || this._failedRefreshes <
|
|
4930
|
+
!this.denoiser?.hasOutput || this._failedRefreshes < zs || this._unpublishOutput();
|
|
4490
4931
|
}
|
|
4491
4932
|
tickContinuousDenoise(e) {
|
|
4492
4933
|
let t = this.denoiser;
|
|
@@ -4496,12 +4937,12 @@ var Ro = {
|
|
|
4496
4937
|
if (!n) this._holdWhileMoving = null, this._movingDenoiseMs.length = 0;
|
|
4497
4938
|
else if (!this.holdsWhileMoving) return !1;
|
|
4498
4939
|
if (t.state.isDenoising || t.state.isLoading || !n && e <= this._lastCadenceSamples) return !1;
|
|
4499
|
-
let r = performance.now(), i = n ?
|
|
4940
|
+
let r = performance.now(), i = n ? Fs : this._lastCadenceSamples === 0 ? Ps : Ns, a = Math.max(this.continuousDenoiseInterval, t.lastDenoiseMs * i);
|
|
4500
4941
|
if (r - this._lastCadenceAt < a) return !1;
|
|
4501
|
-
this._lastCadenceAt = r, this._lastCadenceSamples = e, t.lastDenoiseMs >
|
|
4942
|
+
this._lastCadenceAt = r, this._lastCadenceSamples = e, t.lastDenoiseMs > Ms && (this._cadenceDowngraded = !0);
|
|
4502
4943
|
let o = this._cadenceDowngraded ? this.previewQuality() : this._finalQuality;
|
|
4503
4944
|
return t.quality !== o && t.updateQuality(o), t.start({ continuous: !0 }).then((e) => {
|
|
4504
|
-
this._failedRefreshes = e ? 0 : this._failedRefreshes + 1, !(!e || !n) && (this._movingDenoiseMs.push(t.lastDenoiseMs), this._movingDenoiseMs.length >
|
|
4945
|
+
this._failedRefreshes = e ? 0 : this._failedRefreshes + 1, !(!e || !n) && (this._movingDenoiseMs.push(t.lastDenoiseMs), this._movingDenoiseMs.length > Ls && this._movingDenoiseMs.shift());
|
|
4505
4946
|
}), !0;
|
|
4506
4947
|
}
|
|
4507
4948
|
previewQuality() {
|
|
@@ -4543,7 +4984,7 @@ var Ro = {
|
|
|
4543
4984
|
r && (this._ensureHistory().merge(r, t.frameCount, this._historyCameraNow(), {
|
|
4544
4985
|
commit: !0,
|
|
4545
4986
|
keepHistory: !this._historyDirty && !n,
|
|
4546
|
-
historyScale:
|
|
4987
|
+
historyScale: Vs(t.frameCount)
|
|
4547
4988
|
}), this._historyDirty = !1);
|
|
4548
4989
|
}
|
|
4549
4990
|
afterReset() {
|
|
@@ -4585,9 +5026,9 @@ var Ro = {
|
|
|
4585
5026
|
let e = this._stages.pathTracer, t = this._history;
|
|
4586
5027
|
if (!t?.valid || this._historyDirty || !this.historyActive || e.isComplete || e.resetCount !== this._knownResetCount || t.width !== this._lastRenderWidth || t.height !== this._lastRenderHeight) return null;
|
|
4587
5028
|
if (e.frameCount <= 1) return t.textures;
|
|
4588
|
-
if (e.frameCount >=
|
|
5029
|
+
if (e.frameCount >= Bs) return null;
|
|
4589
5030
|
let n = this._historyInputs();
|
|
4590
|
-
return n ? t.merge(n, e.frameCount, this._historyCameraNow(), { historyScale:
|
|
5031
|
+
return n ? t.merge(n, e.frameCount, this._historyCameraNow(), { historyScale: Vs(e.frameCount) }) : null;
|
|
4591
5032
|
}
|
|
4592
5033
|
_historyInputs() {
|
|
4593
5034
|
let e = this._stages.pathTracer, t = this.pipeline?.context, n = this.renderer?.backend;
|
|
@@ -4612,7 +5053,7 @@ var Ro = {
|
|
|
4612
5053
|
return t.world = e.cameraWorldMatrix.value.elements, t.projInv = e.cameraProjectionMatrixInverse.value.elements, t.viewProj = this._viewProj.elements, t.orthographic = e.uniforms?.get("cameraProjection")?.value === Ae.orthographic, t;
|
|
4613
5054
|
}
|
|
4614
5055
|
_ensureHistory() {
|
|
4615
|
-
return this._history ??= new
|
|
5056
|
+
return this._history ??= new Cs(this.renderer.backend.device), this._history.settings.cleanAux = !!this.denoiser?.expectsCleanAux(this._finalQuality), this._history;
|
|
4616
5057
|
}
|
|
4617
5058
|
_releaseHistory() {
|
|
4618
5059
|
this._history?.dispose(), this._history = null, this._historyDirty = !0, this._movedPlacements.clear();
|
|
@@ -4633,66 +5074,76 @@ var Ro = {
|
|
|
4633
5074
|
this._neuralUpscaler?.dispose(), this._neuralUpscaler = null, this._superResModule?.releaseDenoisedReader();
|
|
4634
5075
|
}
|
|
4635
5076
|
setNeuralRendering(e, t = null) {
|
|
5077
|
+
let n = this.neuralRendering !== !!e;
|
|
4636
5078
|
this.neuralRendering = !!e, t && (this.neuralRenderingSettings = {
|
|
4637
5079
|
...this.neuralRenderingSettings,
|
|
4638
5080
|
...t
|
|
4639
|
-
}), this.neuralRendering || (this._releaseNeuralRetouch(), this._restoreRenderDisplay());
|
|
5081
|
+
}), this.neuralRendering || (this._releaseNeuralRetouch(), this._restoreRenderDisplay()), n && this._redoPostPasses();
|
|
4640
5082
|
}
|
|
4641
5083
|
_releaseNeuralRetouch() {
|
|
4642
5084
|
this._retouch?.dispose(), this._retouch = null;
|
|
4643
5085
|
}
|
|
4644
5086
|
async _runNeuralPost(e) {
|
|
4645
|
-
let t = this.upscaler?.enabled && this.upscalerBackend === "neural", n = this.neuralRendering;
|
|
5087
|
+
let t = this.upscaler?.enabled && this.upscalerBackend === "neural", n = this.neuralRendering, r = this.upscaler?.enabled && !t;
|
|
4646
5088
|
if (!(!t && !n) && !this._neuralPostBusy) {
|
|
4647
5089
|
if (!this.upscalerCanvas) {
|
|
4648
5090
|
this._recordNoOverlayCanvas("neural");
|
|
4649
5091
|
return;
|
|
4650
5092
|
}
|
|
4651
5093
|
if (!this.pipeline?.context?.getTexture("oidn:output")) {
|
|
4652
|
-
|
|
5094
|
+
js.warn("neural pass skipped: no denoised picture — it needs OIDN");
|
|
4653
5095
|
return;
|
|
4654
5096
|
}
|
|
4655
5097
|
this._neuralPostBusy = !0, this.dispatchEvent({ type: j.UPSCALING_START });
|
|
4656
5098
|
try {
|
|
4657
|
-
let
|
|
4658
|
-
this._superResModule =
|
|
4659
|
-
let
|
|
4660
|
-
if (n && !
|
|
4661
|
-
|
|
5099
|
+
let i = await import("./NeuralSuperRes-BHxhYzlD.js").then((e) => e.t);
|
|
5100
|
+
this._superResModule = i;
|
|
5101
|
+
let a = n ? await import("./NeuralRetouch-KqGVPV7u.js").then((e) => e.t) : null, o = this.denoiser?._outTexSize, s = (o?.width ?? 0) * (o?.height ?? 0), c = n && s <= a.RETOUCH_MAX_PIXELS;
|
|
5102
|
+
if (n && !c && (js.warn(`Neural rendering skipped: the render is ${(s / 1e6).toFixed(1)} MP, above the ${(a.RETOUCH_MAX_PIXELS / 1e6).toFixed(1)} MP the pass survives.` + (t ? " The upscale still ran." : "")), this._releaseNeuralRetouch()), !t && !c) {
|
|
5103
|
+
r && !this._postCancelled && await this.upscaler.start();
|
|
5104
|
+
return;
|
|
5105
|
+
}
|
|
5106
|
+
let l = {
|
|
4662
5107
|
exposure: this._getEffectiveExposure(),
|
|
4663
5108
|
toneMapping: this._getToneMapping(),
|
|
4664
|
-
saturation: this._getSaturation?.() ?? 1
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
5109
|
+
saturation: this._getSaturation?.() ?? 1,
|
|
5110
|
+
gain: this._getDisplayGain?.() ?? null
|
|
5111
|
+
}, u = await i.readDenoisedHalf(this.denoiser);
|
|
5112
|
+
t && (this._neuralUpscaler && (this._neuralUpscaler.inputWidth !== u.width || this._neuralUpscaler.inputHeight !== u.height) && this._releaseNeuralUpscaler(), this._neuralUpscaler ||= await i.NeuralSuperRes.create({
|
|
5113
|
+
width: u.width,
|
|
5114
|
+
height: u.height
|
|
4669
5115
|
}));
|
|
4670
|
-
let
|
|
4671
|
-
if (
|
|
4672
|
-
let e = await
|
|
4673
|
-
source:
|
|
5116
|
+
let d = u;
|
|
5117
|
+
if (c) {
|
|
5118
|
+
let e = await a.enhanceFrame({
|
|
5119
|
+
source: d,
|
|
4674
5120
|
settings: this.neuralRenderingSettings,
|
|
4675
5121
|
instance: this._retouch,
|
|
4676
|
-
exposure:
|
|
4677
|
-
tone: t ? null :
|
|
5122
|
+
exposure: l.exposure,
|
|
5123
|
+
tone: t ? null : l
|
|
4678
5124
|
});
|
|
4679
|
-
this._retouch = e.instance,
|
|
5125
|
+
this._retouch = e.instance, d = e;
|
|
4680
5126
|
}
|
|
4681
|
-
if (t && (
|
|
5127
|
+
if (t && (d = await this._neuralUpscaler.upscaleToRGBA8(d, l)), !e()) {
|
|
4682
5128
|
this.dropDisplay();
|
|
4683
5129
|
return;
|
|
4684
5130
|
}
|
|
4685
|
-
if (
|
|
5131
|
+
if (this._postRedo || this._postCancelled) return;
|
|
5132
|
+
if (r) {
|
|
5133
|
+
await this.upscaler.start(new ImageData(d.rgba8, d.width, d.height));
|
|
5134
|
+
return;
|
|
5135
|
+
}
|
|
5136
|
+
if (i.presentRGBA8(this.upscalerCanvas, d.rgba8, d.width, d.height), !e()) {
|
|
4686
5137
|
this.dropDisplay();
|
|
4687
5138
|
return;
|
|
4688
5139
|
}
|
|
4689
5140
|
this.mainCanvas && (this.mainCanvas.style.opacity = "0"), this.dispatchEvent({
|
|
4690
5141
|
type: j.RESOLUTION_CHANGED,
|
|
4691
|
-
width:
|
|
4692
|
-
height:
|
|
5142
|
+
width: d.width,
|
|
5143
|
+
height: d.height
|
|
4693
5144
|
});
|
|
4694
5145
|
} catch (e) {
|
|
4695
|
-
|
|
5146
|
+
js.warn("neural pass failed", e);
|
|
4696
5147
|
} finally {
|
|
4697
5148
|
this._neuralPostBusy = !1, this.dispatchEvent({ type: j.UPSCALING_END });
|
|
4698
5149
|
}
|
|
@@ -4710,16 +5161,22 @@ var Ro = {
|
|
|
4710
5161
|
let t = await e.start();
|
|
4711
5162
|
return t && this._onDisplayRefresh?.(), t && e.hasOutput;
|
|
4712
5163
|
}
|
|
5164
|
+
_runPostPasses(e) {
|
|
5165
|
+
this._postIsStillComplete = e, this._postCancelled = !1, this.neuralRendering || this.upscaler?.enabled && this.upscalerBackend === "neural" ? this._postRun = this._runNeuralPost(e) : this._postRun = this.upscaler?.enabled ? this.upscaler.start() : null;
|
|
5166
|
+
}
|
|
5167
|
+
_redoPostPasses() {
|
|
5168
|
+
let e = this._postIsStillComplete;
|
|
5169
|
+
!e?.() || this._postRedo || (this.upscaler?.abort(), this._postCancelled = !1, this._postRedo = Promise.resolve(this._postRun).catch(() => {}).then(() => {
|
|
5170
|
+
this._postRedo = null, !(this._postCancelled || this._postIsStillComplete !== e || !e()) && (this._restoreRenderDisplay(), this._runPostPasses(e));
|
|
5171
|
+
}));
|
|
5172
|
+
}
|
|
5173
|
+
cancelPostPasses() {
|
|
5174
|
+
this._postCancelled = !0, this.upscaler?.abort(), this._restoreRenderDisplay(), this.dispatchEvent({ type: j.UPSCALING_END });
|
|
5175
|
+
}
|
|
4713
5176
|
onRenderComplete({ isStillComplete: e }) {
|
|
4714
|
-
this._cleanupCompletionListener();
|
|
5177
|
+
this._cleanupCompletionListener(), this._postIsStillComplete = null;
|
|
4715
5178
|
let t = this.finalDenoise ? "final" : this.continuousDenoise ? "refresh" : null, n = () => {
|
|
4716
|
-
|
|
4717
|
-
if (t && this._onDisplayRefresh?.(), this.neuralRendering || this.upscaler?.enabled && this.upscalerBackend === "neural") {
|
|
4718
|
-
this._runNeuralPost(e);
|
|
4719
|
-
return;
|
|
4720
|
-
}
|
|
4721
|
-
this.upscaler?.enabled && this.upscaler.start();
|
|
4722
|
-
}
|
|
5179
|
+
this.denoiser?.removeEventListener("end", n), this._pendingStartUpscaler = null, e() && (t && this._onDisplayRefresh?.(), this._runPostPasses(e));
|
|
4723
5180
|
};
|
|
4724
5181
|
if (!t) {
|
|
4725
5182
|
n();
|
|
@@ -4736,7 +5193,7 @@ var Ro = {
|
|
|
4736
5193
|
} else r();
|
|
4737
5194
|
}
|
|
4738
5195
|
abort(e, { keepDisplay: t = !1 } = {}) {
|
|
4739
|
-
this._cleanupCompletionListener(), this._restoreRenderDisplay(), e && e !== this.mainCanvas && (e.style.opacity = "1"), this.upscaler && this.upscaler.abort();
|
|
5196
|
+
this._cleanupCompletionListener(), this._postIsStillComplete = null, this._restoreRenderDisplay(), e && e !== this.mainCanvas && (e.style.opacity = "1"), this.upscaler && this.upscaler.abort();
|
|
4740
5197
|
let n = !!this._stages.pathTracer?.viewIsChanging, r = t && this.continuousDenoise && !this._cadenceSuspended && !!this.denoiser?.hasOutput && (!n || this.holdsWhileMoving);
|
|
4741
5198
|
this.denoiser && !r && (this.denoiser.enabled && this.denoiser.abort(), this._unpublishOutput()), this._resetCadence();
|
|
4742
5199
|
}
|
|
@@ -4744,7 +5201,7 @@ var Ro = {
|
|
|
4744
5201
|
this._unpublishOutput(), this._restoreRenderDisplay(), this._historyDirty = !0;
|
|
4745
5202
|
}
|
|
4746
5203
|
dispose() {
|
|
4747
|
-
this._cleanupCompletionListener(), this._releaseNeuralUpscaler(), this._releaseNeuralRetouch(), this._unpublishOutput(), this._releaseHistory(), this.denoiser &&= (this._denoiserStartHandler && this.denoiser.removeEventListener("start", this._denoiserStartHandler), this._denoiserEndHandler && this.denoiser.removeEventListener("end", this._denoiserEndHandler), this._denoiserTileHandler && this.denoiser.removeEventListener("tileProgress", this._denoiserTileHandler), this._denoiserErrorHandler && this.denoiser.removeEventListener("error", this._denoiserErrorHandler), this.denoiser.dispose(), null), this.upscaler && (this._upscalerResChangedHandler && this.upscaler.removeEventListener("resolution_changed", this._upscalerResChangedHandler), this._upscalerStartHandler && this.upscaler.removeEventListener("start", this._upscalerStartHandler), this._upscalerProgressHandler && this.upscaler.removeEventListener("progress", this._upscalerProgressHandler), this._upscalerEndHandler && this.upscaler.removeEventListener("end", this._upscalerEndHandler), this.upscaler.dispose(), this.upscaler = null, this.upscalerBackend = "esrgan", this._neuralUpscaler = null), this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._denoiserTileHandler = null, this._denoiserErrorHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null, this._onReset = null, this._onPostProcessRefresh = null, this._onDisplayRefresh = null, this._issues = null, this.upscalerCanvas?.parentNode && (this.upscalerCanvas.parentNode.removeChild(this.upscalerCanvas), this.upscalerCanvas = null);
|
|
5204
|
+
this._cleanupCompletionListener(), this._postIsStillComplete = null, this._releaseNeuralUpscaler(), this._releaseNeuralRetouch(), this._unpublishOutput(), this._releaseHistory(), this.denoiser &&= (this._denoiserStartHandler && this.denoiser.removeEventListener("start", this._denoiserStartHandler), this._denoiserEndHandler && this.denoiser.removeEventListener("end", this._denoiserEndHandler), this._denoiserTileHandler && this.denoiser.removeEventListener("tileProgress", this._denoiserTileHandler), this._denoiserErrorHandler && this.denoiser.removeEventListener("error", this._denoiserErrorHandler), this.denoiser.dispose(), null), this.upscaler && (this._upscalerResChangedHandler && this.upscaler.removeEventListener("resolution_changed", this._upscalerResChangedHandler), this._upscalerStartHandler && this.upscaler.removeEventListener("start", this._upscalerStartHandler), this._upscalerProgressHandler && this.upscaler.removeEventListener("progress", this._upscalerProgressHandler), this._upscalerEndHandler && this.upscaler.removeEventListener("end", this._upscalerEndHandler), this.upscaler.dispose(), this.upscaler = null, this.upscalerBackend = "esrgan", this._neuralUpscaler = null), this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._denoiserTileHandler = null, this._denoiserErrorHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null, this._onReset = null, this._onPostProcessRefresh = null, this._onDisplayRefresh = null, this._getExposure = null, this._getSaturation = null, this._getDisplayGain = null, this._issues = null, this.upscalerCanvas?.parentNode && (this.upscalerCanvas.parentNode.removeChild(this.upscalerCanvas), this.upscalerCanvas = null);
|
|
4748
5205
|
}
|
|
4749
5206
|
setOverlayManager(e) {
|
|
4750
5207
|
this._overlayManager = e;
|
|
@@ -4798,7 +5255,8 @@ var Ro = {
|
|
|
4798
5255
|
this._setTileHelper(e);
|
|
4799
5256
|
}
|
|
4800
5257
|
setUpscalerEnabled(e) {
|
|
4801
|
-
this.upscaler
|
|
5258
|
+
let t = !!this.upscaler && this.upscaler.enabled !== !!e;
|
|
5259
|
+
this.upscaler ? this.upscaler.enabled = e : e && this._recordNoOverlayCanvas("upscaler"), e || this._restoreRenderDisplay(), t && this._redoPostPasses();
|
|
4802
5260
|
}
|
|
4803
5261
|
setUpscalerScaleFactor(e) {
|
|
4804
5262
|
this.upscaler?.setScaleFactor(e);
|
|
@@ -4807,7 +5265,7 @@ var Ro = {
|
|
|
4807
5265
|
this.upscaler?.setQuality(e);
|
|
4808
5266
|
}
|
|
4809
5267
|
setAutoExposure(e) {
|
|
4810
|
-
this.setAutoExposureEnabled(e, this._getExposure())
|
|
5268
|
+
this.setAutoExposureEnabled(e, this._getExposure());
|
|
4811
5269
|
}
|
|
4812
5270
|
setStrategy(e, t) {
|
|
4813
5271
|
this.setDenoiserStrategy(e, t), this._onReset?.();
|
|
@@ -4845,20 +5303,20 @@ var Ro = {
|
|
|
4845
5303
|
].forEach((t) => e.removeTexture(t));
|
|
4846
5304
|
}
|
|
4847
5305
|
_applyNRDPreset(e) {
|
|
4848
|
-
let t =
|
|
5306
|
+
let t = Qr[e];
|
|
4849
5307
|
if (!t) return;
|
|
4850
5308
|
let n = {};
|
|
4851
|
-
for (let e of
|
|
5309
|
+
for (let e of Zr) n[e] = Xr[e];
|
|
4852
5310
|
this._stages.nrd?.updateParameters({
|
|
4853
5311
|
...n,
|
|
4854
5312
|
...t
|
|
4855
5313
|
});
|
|
4856
5314
|
}
|
|
4857
5315
|
_applyASVGFPreset(e) {
|
|
4858
|
-
let t =
|
|
5316
|
+
let t = qr[e];
|
|
4859
5317
|
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));
|
|
4860
5318
|
}
|
|
4861
|
-
},
|
|
5319
|
+
}, Us = class {
|
|
4862
5320
|
constructor() {
|
|
4863
5321
|
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;
|
|
4864
5322
|
}
|
|
@@ -4882,18 +5340,18 @@ var Ro = {
|
|
|
4882
5340
|
dispose() {
|
|
4883
5341
|
this.visible = !1;
|
|
4884
5342
|
}
|
|
4885
|
-
},
|
|
5343
|
+
}, Ws = class {
|
|
4886
5344
|
constructor(e, t) {
|
|
4887
5345
|
this.layer = "scene", this._enabled = !0, this._scene = e, this._camera = t, this._build([]);
|
|
4888
5346
|
}
|
|
4889
5347
|
_build(e) {
|
|
4890
|
-
this._orthographic = this._camera.isOrthographicCamera === !0, this._outlineNode =
|
|
5348
|
+
this._orthographic = this._camera.isOrthographicCamera === !0, this._outlineNode = Hr(this._scene, this._camera, {
|
|
4891
5349
|
selectedObjects: e,
|
|
4892
|
-
edgeThickness:
|
|
4893
|
-
edgeGlow:
|
|
5350
|
+
edgeThickness: G(1),
|
|
5351
|
+
edgeGlow: G(0)
|
|
4894
5352
|
});
|
|
4895
|
-
let t =
|
|
4896
|
-
this._material = new
|
|
5353
|
+
let t = G(3), n = G(new sr(16777215)), r = G(new sr(1640965)), { visibleEdge: i, hiddenEdge: a } = this._outlineNode, o = i.mul(n).add(a.mul(r)).mul(t), s = o.r.max(o.g).max(o.b).clamp(0, 1);
|
|
5354
|
+
this._material = new bn(), this._material.colorNode = J(o, s), this._material.transparent = !0, this._material.blending = lr, this._material.blendEquation = nr, this._material.blendSrc = Tr, this._material.blendDst = Tr, this._material.blendEquationAlpha = nr, this._material.blendSrcAlpha = Tr, this._material.blendDstAlpha = Tr, this._material.toneMapped = !1, this._material.depthTest = !1, this._material.depthWrite = !1, this._quad = new xn(this._material);
|
|
4897
5355
|
}
|
|
4898
5356
|
setSelectedObjects(e) {
|
|
4899
5357
|
this._outlineNode.selectedObjects = e;
|
|
@@ -4920,11 +5378,11 @@ var Ro = {
|
|
|
4920
5378
|
this._enabled = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
|
|
4921
5379
|
}
|
|
4922
5380
|
};
|
|
4923
|
-
function
|
|
5381
|
+
function Gs(e = !1) {
|
|
4924
5382
|
let t = document.createElement("canvas");
|
|
4925
5383
|
return t.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;" + (e ? "display:none;" : ""), t;
|
|
4926
5384
|
}
|
|
4927
|
-
function
|
|
5385
|
+
function Ks(e, t = Infinity) {
|
|
4928
5386
|
let n = e?.getBoundingClientRect();
|
|
4929
5387
|
if (!n || n.width === 0 || n.height === 0) return null;
|
|
4930
5388
|
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);
|
|
@@ -4935,26 +5393,26 @@ function ts(e, t = Infinity) {
|
|
|
4935
5393
|
}
|
|
4936
5394
|
//#endregion
|
|
4937
5395
|
//#region src/managers/helpers/ViewOverlayRenderer.js
|
|
4938
|
-
var
|
|
5396
|
+
var qs = 4096, Js = class {
|
|
4939
5397
|
constructor() {
|
|
4940
|
-
this.canvas =
|
|
5398
|
+
this.canvas = Gs(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
|
|
4941
5399
|
}
|
|
4942
5400
|
async init({ device: e, sizeSource: t }) {
|
|
4943
5401
|
this._sizeSource = t;
|
|
4944
|
-
let n = e.onuncapturederror, r = new
|
|
5402
|
+
let n = e.onuncapturederror, r = new Tn({
|
|
4945
5403
|
canvas: this.canvas,
|
|
4946
5404
|
device: e,
|
|
4947
5405
|
alpha: !0,
|
|
4948
5406
|
antialias: (window.devicePixelRatio || 1) < 2
|
|
4949
5407
|
});
|
|
4950
|
-
return await r.init(), e.onuncapturederror = n, r.outputColorSpace =
|
|
5408
|
+
return await r.init(), e.onuncapturederror = n, r.outputColorSpace = Mr, r.setPixelRatio(1), r.setClearColor(0, 0), r.autoClear = !1, this.renderer = r, this.syncSize(), this;
|
|
4951
5409
|
}
|
|
4952
5410
|
get isVisible() {
|
|
4953
5411
|
return this._visible;
|
|
4954
5412
|
}
|
|
4955
5413
|
syncSize() {
|
|
4956
5414
|
if (!this.renderer) return;
|
|
4957
|
-
let e =
|
|
5415
|
+
let e = Ks(this._sizeSource, qs);
|
|
4958
5416
|
!e || e.width === this.canvas.width && e.height === this.canvas.height || this.renderer.setSize(e.width, e.height, !1);
|
|
4959
5417
|
}
|
|
4960
5418
|
begin() {
|
|
@@ -4966,18 +5424,18 @@ var ns = 4096, rs = class {
|
|
|
4966
5424
|
dispose() {
|
|
4967
5425
|
Pe(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
|
|
4968
5426
|
}
|
|
4969
|
-
},
|
|
5427
|
+
}, Ys = Ke("overlay"), Xs = (e, t) => e.visible && e.layer === t && e.render, Zs = class {
|
|
4970
5428
|
constructor(e) {
|
|
4971
|
-
this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas =
|
|
5429
|
+
this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = Gs(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
|
|
4972
5430
|
}
|
|
4973
5431
|
async initViewRenderer({ device: e, sizeSource: t }) {
|
|
4974
5432
|
if (!(!e || !t)) try {
|
|
4975
|
-
this._viewOverlay = await new
|
|
5433
|
+
this._viewOverlay = await new Js().init({
|
|
4976
5434
|
device: e,
|
|
4977
5435
|
sizeSource: t
|
|
4978
5436
|
});
|
|
4979
5437
|
} catch (e) {
|
|
4980
|
-
|
|
5438
|
+
Ys.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
|
|
4981
5439
|
}
|
|
4982
5440
|
}
|
|
4983
5441
|
gpuResources() {
|
|
@@ -4997,11 +5455,11 @@ var ns = 4096, rs = class {
|
|
|
4997
5455
|
}
|
|
4998
5456
|
setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
|
|
4999
5457
|
this.setHelperScene(e);
|
|
5000
|
-
let s = new
|
|
5458
|
+
let s = new Us();
|
|
5001
5459
|
this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener(j.RESOLUTION_CHANGED, (e) => {
|
|
5002
5460
|
s.setRenderSize(e.width, e.height);
|
|
5003
5461
|
}), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
|
|
5004
|
-
let c = new
|
|
5462
|
+
let c = new Ws(t, this.camera);
|
|
5005
5463
|
this.register("outline", c);
|
|
5006
5464
|
}
|
|
5007
5465
|
_wireDenoiserTileEvents(e, t) {
|
|
@@ -5013,7 +5471,7 @@ var ns = 4096, rs = class {
|
|
|
5013
5471
|
}));
|
|
5014
5472
|
}
|
|
5015
5473
|
register(e, t) {
|
|
5016
|
-
this._helpers.has(e) && (
|
|
5474
|
+
this._helpers.has(e) && (Ys.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
|
|
5017
5475
|
}
|
|
5018
5476
|
unregister(e) {
|
|
5019
5477
|
let t = this._helpers.get(e);
|
|
@@ -5051,16 +5509,16 @@ var ns = 4096, rs = class {
|
|
|
5051
5509
|
}
|
|
5052
5510
|
_renderSceneLayer(e) {
|
|
5053
5511
|
this._helperScene?.render(e, this.camera);
|
|
5054
|
-
for (let t of this._helpers.values())
|
|
5512
|
+
for (let t of this._helpers.values()) Xs(t, "scene") && t.render(e, this.camera);
|
|
5055
5513
|
}
|
|
5056
5514
|
_hasVisibleSceneOverlay() {
|
|
5057
5515
|
if (this._helperScene?.isDrawing) return !0;
|
|
5058
|
-
for (let e of this._helpers.values()) if (
|
|
5516
|
+
for (let e of this._helpers.values()) if (Xs(e, "scene")) return !0;
|
|
5059
5517
|
return !1;
|
|
5060
5518
|
}
|
|
5061
5519
|
refreshHUD() {
|
|
5062
5520
|
let e = this._hudCanvas, t = this._hudCtx, n = !1;
|
|
5063
|
-
for (let e of this._helpers.values()) if (
|
|
5521
|
+
for (let e of this._helpers.values()) if (Xs(e, "hud")) {
|
|
5064
5522
|
n = !0;
|
|
5065
5523
|
break;
|
|
5066
5524
|
}
|
|
@@ -5069,10 +5527,10 @@ var ns = 4096, rs = class {
|
|
|
5069
5527
|
return;
|
|
5070
5528
|
}
|
|
5071
5529
|
e.style.display !== "" && (e.style.display = "");
|
|
5072
|
-
let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ?
|
|
5530
|
+
let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? Ks(e) : null;
|
|
5073
5531
|
if (a) {
|
|
5074
5532
|
(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);
|
|
5075
|
-
for (let e of this._helpers.values())
|
|
5533
|
+
for (let e of this._helpers.values()) Xs(e, "hud") && e.render(t, r, i);
|
|
5076
5534
|
t.restore(), e.style.display !== "" && (e.style.display = "");
|
|
5077
5535
|
}
|
|
5078
5536
|
}
|
|
@@ -5083,7 +5541,7 @@ var ns = 4096, rs = class {
|
|
|
5083
5541
|
};
|
|
5084
5542
|
//#endregion
|
|
5085
5543
|
//#region src/managers/AnimationManager.js
|
|
5086
|
-
function
|
|
5544
|
+
function Qs(e, t) {
|
|
5087
5545
|
let n = [...e].filter((t) => {
|
|
5088
5546
|
for (let n = t.parent; n; n = n.parent) if (e.has(n)) return !1;
|
|
5089
5547
|
return !0;
|
|
@@ -5092,18 +5550,18 @@ function ss(e, t) {
|
|
|
5092
5550
|
for (let e of n) e.traverse?.(() => i++);
|
|
5093
5551
|
return i + n.length / 2 < r ? n : null;
|
|
5094
5552
|
}
|
|
5095
|
-
var
|
|
5553
|
+
var $s = class extends fr {
|
|
5096
5554
|
constructor() {
|
|
5097
|
-
super(), this.mixer = null, this.timer = new
|
|
5555
|
+
super(), this.mixer = null, this.timer = new Fr(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._meshPositions = null, this._tempVec = new $(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this._rigid = !1, this._plans = null, this._allPlan = null, this._activeClip = 0, this._slotOf = null, this._lastWorld = null, this._lastVisible = null, this._lastMeshWorld = null, this._lastMorphWeights = null, this.wakeCallback = null, this.applyPoseCallback = null;
|
|
5098
5556
|
}
|
|
5099
5557
|
init(e, t, n, r) {
|
|
5100
5558
|
if (this.dispose(), !r || r.length === 0) return;
|
|
5101
|
-
this._scene = e, this._mixerRoot = t, this._meshes = n, this.mixer = new
|
|
5559
|
+
this._scene = e, this._mixerRoot = t, this._meshes = n, this.mixer = new rr(t);
|
|
5102
5560
|
let i = r.map((e) => this.mixer.clipAction(e)), a = (e, t) => e.name === t || e.getObjectByName(t) !== void 0;
|
|
5103
5561
|
!i.some((e) => e.getClip().tracks.some((e) => {
|
|
5104
5562
|
let n = e.name.split(".")[0];
|
|
5105
5563
|
return a(t, n);
|
|
5106
|
-
})) && t !== e && (console.log("[AnimationManager] Tracks did not resolve from model root, retrying with scene root"), this.mixer = new
|
|
5564
|
+
})) && t !== e && (console.log("[AnimationManager] Tracks did not resolve from model root, retrying with scene root"), this.mixer = new rr(e), this._mixerRoot = e, i = r.map((e) => this.mixer.clipAction(e))), this.actions = i, this._rigid = !n.some((e) => e?.isSkinnedMesh) && !r.some((e) => e.tracks.some((e) => e.name.includes("morphTargetInfluences"))), this._planClips(r), this.mixer.addEventListener("finished", () => {
|
|
5107
5565
|
this.isPlaying = !1, this.timer.reset(), this.onFinished && this.onFinished();
|
|
5108
5566
|
}), this._meshTriRanges = [], this._skinnedCache = [];
|
|
5109
5567
|
let o = 0;
|
|
@@ -5127,7 +5585,7 @@ var cs = class extends cr {
|
|
|
5127
5585
|
}), this._plans = e.map((e) => {
|
|
5128
5586
|
let r = /* @__PURE__ */ new Set(), i = !1, a = !1;
|
|
5129
5587
|
for (let o of e.tracks) {
|
|
5130
|
-
let { nodeName: e, propertyName: s } =
|
|
5588
|
+
let { nodeName: e, propertyName: s } = Or.parseTrackName(o.name), c = e === "" || e === "." ? t : n.get(e);
|
|
5131
5589
|
if (!c) {
|
|
5132
5590
|
a = !0;
|
|
5133
5591
|
continue;
|
|
@@ -5146,7 +5604,7 @@ var cs = class extends cr {
|
|
|
5146
5604
|
visibility: i,
|
|
5147
5605
|
cameras: [...s],
|
|
5148
5606
|
nodes: a ? null : r,
|
|
5149
|
-
roots: a ? null :
|
|
5607
|
+
roots: a ? null : Qs(r, t)
|
|
5150
5608
|
};
|
|
5151
5609
|
}), this._allPlan = null, !this._rigid) return;
|
|
5152
5610
|
this._slotOf = new Int32Array(this._meshes.length).fill(-1);
|
|
@@ -5165,7 +5623,7 @@ var cs = class extends cr {
|
|
|
5165
5623
|
visibility: n,
|
|
5166
5624
|
cameras: [...t],
|
|
5167
5625
|
nodes: r,
|
|
5168
|
-
roots: r ?
|
|
5626
|
+
roots: r ? Qs(r, this._mixerRoot) : null
|
|
5169
5627
|
};
|
|
5170
5628
|
}
|
|
5171
5629
|
return this._allPlan;
|
|
@@ -5216,7 +5674,7 @@ var cs = class extends cr {
|
|
|
5216
5674
|
this._savedTimeScale = e, this.mixer && this.isPlaying && (this.mixer.timeScale = e);
|
|
5217
5675
|
}
|
|
5218
5676
|
setLoop(e) {
|
|
5219
|
-
let t = e ?
|
|
5677
|
+
let t = e ? _r : gr;
|
|
5220
5678
|
for (let n of this.actions) n.setLoop(t), n.clampWhenFinished = !e;
|
|
5221
5679
|
}
|
|
5222
5680
|
seekTo(e, t = 0) {
|
|
@@ -5297,19 +5755,19 @@ var cs = class extends cr {
|
|
|
5297
5755
|
dispose() {
|
|
5298
5756
|
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._meshPositions = null, this._skinnedCache = null, this._clipsCache = null, this._rigid = !1, this._plans = null, this._allPlan = null, this._activeClip = 0, this._slotOf = null, this._lastWorld = null, this._lastVisible = null, this._lastMeshWorld = null, this._lastMorphWeights = null;
|
|
5299
5757
|
}
|
|
5300
|
-
},
|
|
5758
|
+
}, ec = new $(0, 0, -1), tc = (e) => {
|
|
5301
5759
|
for (; e.parent;) e = e.parent;
|
|
5302
5760
|
return e.isScene ? e : null;
|
|
5303
|
-
},
|
|
5761
|
+
}, nc = class {
|
|
5304
5762
|
constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
|
|
5305
|
-
this._app = r, this._orbitControls = n, this._camera = e, this._controls = new
|
|
5763
|
+
this._app = r, this._orbitControls = n, this._camera = e, this._controls = new Ur(e, t), this._gizmoScene = new Nr(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._refitInFlight = !1, this._baselineComputed = !1, this._moved = /* @__PURE__ */ new Set(), this._tempForward = new $(), 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);
|
|
5306
5764
|
}
|
|
5307
5765
|
setMeshData(e) {
|
|
5308
5766
|
this._meshes = e;
|
|
5309
|
-
for (let e of this._moved)
|
|
5767
|
+
for (let e of this._moved) tc(e) || this._moved.delete(e);
|
|
5310
5768
|
}
|
|
5311
5769
|
get movedObjects() {
|
|
5312
|
-
return [...this._moved].filter((e) =>
|
|
5770
|
+
return [...this._moved].filter((e) => tc(e));
|
|
5313
5771
|
}
|
|
5314
5772
|
noteMoved(e) {
|
|
5315
5773
|
e && !e.isLight && this._moved.add(e);
|
|
@@ -5370,7 +5828,7 @@ var cs = class extends cr {
|
|
|
5370
5828
|
}
|
|
5371
5829
|
_syncLightAim(e) {
|
|
5372
5830
|
let t = this._tempForward.copy(e.target.position).sub(e.position), n = t.length();
|
|
5373
|
-
n > 1e-4 ? (e.quaternion.setFromUnitVectors(
|
|
5831
|
+
n > 1e-4 ? (e.quaternion.setFromUnitVectors(ec, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1;
|
|
5374
5832
|
}
|
|
5375
5833
|
_recomputeAndRefit() {
|
|
5376
5834
|
if (!this._meshes || this._refitInFlight || !this._attached) return;
|
|
@@ -5406,7 +5864,7 @@ var cs = class extends cr {
|
|
|
5406
5864
|
dispose() {
|
|
5407
5865
|
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._moved.clear(), 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;
|
|
5408
5866
|
}
|
|
5409
|
-
},
|
|
5867
|
+
}, rc = class {
|
|
5410
5868
|
constructor(e) {
|
|
5411
5869
|
this.layer = "scene", this._transformManager = e, this._enabled = !0;
|
|
5412
5870
|
}
|
|
@@ -5425,8 +5883,8 @@ var cs = class extends cr {
|
|
|
5425
5883
|
dispose() {
|
|
5426
5884
|
this._enabled = !1;
|
|
5427
5885
|
}
|
|
5428
|
-
},
|
|
5429
|
-
function
|
|
5886
|
+
}, ic = 1, ac = (e) => typeof e == "string" && /^https?:\/\//.test(e);
|
|
5887
|
+
function oc(e, t) {
|
|
5430
5888
|
let n = [];
|
|
5431
5889
|
for (; e && e !== t;) {
|
|
5432
5890
|
let t = e.parent;
|
|
@@ -5435,12 +5893,12 @@ function hs(e, t) {
|
|
|
5435
5893
|
}
|
|
5436
5894
|
return e === t ? n : null;
|
|
5437
5895
|
}
|
|
5438
|
-
function
|
|
5896
|
+
function sc(e, t) {
|
|
5439
5897
|
let n = e;
|
|
5440
5898
|
for (let e of t) if (n = n?.children[e], !n) return null;
|
|
5441
5899
|
return n;
|
|
5442
5900
|
}
|
|
5443
|
-
function
|
|
5901
|
+
function cc(e) {
|
|
5444
5902
|
return {
|
|
5445
5903
|
key: e.assetLoader?.sceneSourceKey ?? null,
|
|
5446
5904
|
name: e.sceneModel?.name ?? null,
|
|
@@ -5448,7 +5906,7 @@ function _s(e) {
|
|
|
5448
5906
|
materials: e.stages.pathTracer?.materialData.materialCount ?? 0
|
|
5449
5907
|
};
|
|
5450
5908
|
}
|
|
5451
|
-
function
|
|
5909
|
+
function lc(e) {
|
|
5452
5910
|
let t = /* @__PURE__ */ new Map();
|
|
5453
5911
|
for (let n of e.sceneMeshes) {
|
|
5454
5912
|
let e = n.userData?.materialIndex;
|
|
@@ -5456,7 +5914,7 @@ function vs(e) {
|
|
|
5456
5914
|
}
|
|
5457
5915
|
return t;
|
|
5458
5916
|
}
|
|
5459
|
-
function
|
|
5917
|
+
function uc(e) {
|
|
5460
5918
|
if (!e) return null;
|
|
5461
5919
|
let t = e.status(), n = t.activeView, r = t.config?.id ?? n?.configId ?? null;
|
|
5462
5920
|
return {
|
|
@@ -5471,15 +5929,15 @@ function ys(e) {
|
|
|
5471
5929
|
context: t.context ?? null
|
|
5472
5930
|
};
|
|
5473
5931
|
}
|
|
5474
|
-
function
|
|
5475
|
-
let t = e.meshScene, n =
|
|
5932
|
+
function dc(e) {
|
|
5933
|
+
let t = e.meshScene, n = lc(e), r = [];
|
|
5476
5934
|
return t.traverse((e) => {
|
|
5477
|
-
e !== t && e.visible === !1 && r.push(
|
|
5935
|
+
e !== t && e.visible === !1 && r.push(oc(e, t));
|
|
5478
5936
|
}), {
|
|
5479
5937
|
v: 1,
|
|
5480
5938
|
engine: Be,
|
|
5481
5939
|
savedAt: Date.now(),
|
|
5482
|
-
scene:
|
|
5940
|
+
scene: cc(e),
|
|
5483
5941
|
appended: t.children.filter((t) => t !== e.sceneModel && t.userData?.__rayzeeSceneObject).map((e) => ({
|
|
5484
5942
|
name: e.userData.__rayzeeName ?? e.name,
|
|
5485
5943
|
url: e.userData.__rayzeeSourceUrl ?? null,
|
|
@@ -5487,7 +5945,7 @@ function bs(e) {
|
|
|
5487
5945
|
})),
|
|
5488
5946
|
settings: e.settings.serialize(),
|
|
5489
5947
|
environment: e.environmentManager?.serialize() ?? null,
|
|
5490
|
-
color:
|
|
5948
|
+
color: uc(e.color),
|
|
5491
5949
|
lights: e.lightManager.serialize(),
|
|
5492
5950
|
cameras: e.cameraManager.serialize(),
|
|
5493
5951
|
timeline: e.timeline?.serialize() ?? null,
|
|
@@ -5497,7 +5955,7 @@ function bs(e) {
|
|
|
5497
5955
|
})),
|
|
5498
5956
|
hidden: r,
|
|
5499
5957
|
moved: (e.transformManager?.movedObjects ?? []).map((e) => ({
|
|
5500
|
-
path:
|
|
5958
|
+
path: oc(e, t),
|
|
5501
5959
|
name: e.name,
|
|
5502
5960
|
position: e.position.toArray(),
|
|
5503
5961
|
quaternion: e.quaternion.toArray(),
|
|
@@ -5505,15 +5963,15 @@ function bs(e) {
|
|
|
5505
5963
|
})).filter((e) => e.path)
|
|
5506
5964
|
};
|
|
5507
5965
|
}
|
|
5508
|
-
function
|
|
5966
|
+
function fc(e, t, n) {
|
|
5509
5967
|
let r = e[t];
|
|
5510
5968
|
r?.copy && (n?.isColor || n?.isVector2 || n?.isVector3) ? r.copy(n) : e[t] = n, e.needsUpdate = !0;
|
|
5511
5969
|
}
|
|
5512
|
-
async function
|
|
5970
|
+
async function pc(e, t, n, r) {
|
|
5513
5971
|
if (!t) return;
|
|
5514
5972
|
let i = e.environmentManager;
|
|
5515
5973
|
if (t.hdri && t.hdri !== i.hdriSource) {
|
|
5516
|
-
let i =
|
|
5974
|
+
let i = ac(t.hdri) ? t.hdri : await n({
|
|
5517
5975
|
kind: "environment",
|
|
5518
5976
|
source: t.hdri
|
|
5519
5977
|
});
|
|
@@ -5525,7 +5983,7 @@ async function Ss(e, t, n, r) {
|
|
|
5525
5983
|
}
|
|
5526
5984
|
await i.restore(t);
|
|
5527
5985
|
}
|
|
5528
|
-
async function
|
|
5986
|
+
async function mc(e, t, n, r) {
|
|
5529
5987
|
let i = e.color;
|
|
5530
5988
|
if (!t || !i) return;
|
|
5531
5989
|
let a = i.status(), o = a.activeView, s = !!t.view && !!o && o.display === t.view.display && o.view === t.view.view && (o.look ?? null) === t.view.look, c = a.config?.id ?? null, l = c ?? o?.configId ?? null;
|
|
@@ -5550,7 +6008,7 @@ async function Cs(e, t, n, r) {
|
|
|
5550
6008
|
r("color", e.message, { config: t.config?.id ?? null });
|
|
5551
6009
|
}
|
|
5552
6010
|
}
|
|
5553
|
-
async function
|
|
6011
|
+
async function hc(e, t, { resolve: n = async () => null } = {}) {
|
|
5554
6012
|
if (t?.v !== 1) throw Error(`scene state version ${t?.v} is not 1`);
|
|
5555
6013
|
let r = [], i = (e, t, n = {}) => r.push({
|
|
5556
6014
|
section: e,
|
|
@@ -5571,11 +6029,11 @@ async function ws(e, t, { resolve: n = async () => null } = {}) {
|
|
|
5571
6029
|
i("appended", e.message, { name: n.name });
|
|
5572
6030
|
}
|
|
5573
6031
|
}
|
|
5574
|
-
let a =
|
|
6032
|
+
let a = cc(e), o = t.scene ?? {}, s = o.meshes === a.meshes && o.materials === a.materials;
|
|
5575
6033
|
s || i("scene", "the loaded scene is not the one saved: objects and materials left as loaded", {
|
|
5576
6034
|
saved: o,
|
|
5577
6035
|
now: a
|
|
5578
|
-
}), await
|
|
6036
|
+
}), await pc(e, t.environment, n, i), await mc(e, t.color, n, i);
|
|
5579
6037
|
let c = e.settings.restore(t.settings);
|
|
5580
6038
|
c.length && i("settings", "not settings in this engine", { keys: c });
|
|
5581
6039
|
let l = e.lightManager.restore(t.lights);
|
|
@@ -5584,7 +6042,7 @@ async function ws(e, t, { resolve: n = async () => null } = {}) {
|
|
|
5584
6042
|
n && e.goboManager?.entries?.length && e.goboManager.setLightGobo(t.uuid, n.name, n), r && e.iesManager?.entries?.length && e.iesManager.setSpotLightProfile(t.uuid, r.name, r.intensity, { applyAutoCone: !1 });
|
|
5585
6043
|
}
|
|
5586
6044
|
if (s) {
|
|
5587
|
-
let n =
|
|
6045
|
+
let n = lc(e);
|
|
5588
6046
|
for (let r of t.materials ?? []) {
|
|
5589
6047
|
let t = n.get(r.index);
|
|
5590
6048
|
if (!t || (t.name ?? "") !== r.name) {
|
|
@@ -5596,16 +6054,16 @@ async function ws(e, t, { resolve: n = async () => null } = {}) {
|
|
|
5596
6054
|
}
|
|
5597
6055
|
for (let [n, i] of Object.entries(r.props)) {
|
|
5598
6056
|
let a = me(i);
|
|
5599
|
-
|
|
6057
|
+
fc(t, n, a), e.setMaterialProperty(r.index, n, a);
|
|
5600
6058
|
}
|
|
5601
6059
|
}
|
|
5602
|
-
let r = e.meshScene, a = new Set((t.hidden ?? []).map((e) =>
|
|
6060
|
+
let r = e.meshScene, a = new Set((t.hidden ?? []).map((e) => sc(r, e)).filter(Boolean));
|
|
5603
6061
|
r.traverse((e) => {
|
|
5604
6062
|
e !== r && !e.isLight && (e.visible = !a.has(e));
|
|
5605
6063
|
}), e.updateAllMeshVisibility();
|
|
5606
6064
|
let o = [];
|
|
5607
6065
|
for (let n of t.moved ?? []) {
|
|
5608
|
-
let t =
|
|
6066
|
+
let t = sc(r, n.path);
|
|
5609
6067
|
if (!t || t.name !== n.name) {
|
|
5610
6068
|
i("moved", "no such object", { name: n.name });
|
|
5611
6069
|
continue;
|
|
@@ -5627,24 +6085,24 @@ async function ws(e, t, { resolve: n = async () => null } = {}) {
|
|
|
5627
6085
|
}
|
|
5628
6086
|
//#endregion
|
|
5629
6087
|
//#region src/PathTracerApp.js
|
|
5630
|
-
var
|
|
6088
|
+
var gc = Ke("engine"), _c = class extends w {
|
|
5631
6089
|
constructor(e, t = {}) {
|
|
5632
|
-
super(e, t), this.setColorManagement(
|
|
6090
|
+
super(e, t), this.setColorManagement($t), this.setStorageOpener(un), this.settings.define("interactionRenderScale", {
|
|
5633
6091
|
default: .5,
|
|
5634
6092
|
apply: () => {
|
|
5635
6093
|
this.stages?.pathTracer?.interactionMode && this._requestRenderScale(this._interactionRenderScale());
|
|
5636
6094
|
},
|
|
5637
6095
|
reset: !1
|
|
5638
|
-
}), this._container = t.container || null, this._animRefitInFlight = !1, this._emittersMoved = !1, this._pendingRenderScale = null, this.cameraManager = null, this.timeline = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new
|
|
6096
|
+
}), this._container = t.container || null, this._animRefitInFlight = !1, this._emittersMoved = !1, this._pendingRenderScale = null, this.cameraManager = null, this.timeline = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new $s();
|
|
5639
6097
|
}
|
|
5640
6098
|
_createCamera() {
|
|
5641
|
-
return this.cameraManager = new
|
|
6099
|
+
return this.cameraManager = new Co(this.canvas), this.timeline = new ko({
|
|
5642
6100
|
cameraManager: this.cameraManager,
|
|
5643
6101
|
onReset: () => this.reset()
|
|
5644
6102
|
}), this.cameraManager.camera;
|
|
5645
6103
|
}
|
|
5646
6104
|
_initAssetPipeline() {
|
|
5647
|
-
super._initAssetPipeline(), this.assetLoader.controls = this.cameraManager.controls, this.assetLoader.registerFormat(...
|
|
6105
|
+
super._initAssetPipeline(), this.assetLoader.controls = this.cameraManager.controls, this.assetLoader.registerFormat(...Ot), this.assetLoader.setArchiveImporterLoader(() => import("./ArchiveImporter-29Nl1567.js").then((e) => e.r).then((e) => new e.ArchiveImporter(this.assetLoader)), Tt);
|
|
5648
6106
|
let e = () => {
|
|
5649
6107
|
this.needsReset = !0, this.stages.pathTracer?.enterInteractionMode(), this.wake();
|
|
5650
6108
|
};
|
|
@@ -5652,10 +6110,10 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5652
6110
|
}
|
|
5653
6111
|
_createExtraStages() {
|
|
5654
6112
|
let { renderer: e, stages: t } = this;
|
|
5655
|
-
return t.normalDepth = new
|
|
6113
|
+
return t.normalDepth = new ti(e, { pathTracer: t.pathTracer }), t.motionVector = new ni(e, this.camera, { pathTracer: t.pathTracer }), t.asvgf = new ai(e, { enabled: !1 }), t.nrd = new Ui(e, {
|
|
5656
6114
|
enabled: !1,
|
|
5657
6115
|
pathTracer: t.pathTracer
|
|
5658
|
-
}), t.variance = new
|
|
6116
|
+
}), t.variance = new Ki(e, { enabled: !1 }), t.bilateralFilter = new Ji(e, { enabled: !1 }), t.edgeFilter = new ea(e, { enabled: !1 }), t.autoExposure = new Ea(e, { enabled: ta.autoExposure }), t.localExposure = new Ja(e, { enabled: Da.localExposure }), [
|
|
5659
6117
|
t.normalDepth,
|
|
5660
6118
|
t.motionVector,
|
|
5661
6119
|
t.nrd,
|
|
@@ -5663,14 +6121,15 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5663
6121
|
t.variance,
|
|
5664
6122
|
t.bilateralFilter,
|
|
5665
6123
|
t.edgeFilter,
|
|
5666
|
-
t.autoExposure
|
|
6124
|
+
t.autoExposure,
|
|
6125
|
+
t.localExposure
|
|
5667
6126
|
];
|
|
5668
6127
|
}
|
|
5669
6128
|
_initPipeline() {
|
|
5670
6129
|
super._initPipeline(), this.pipeline.eventBus.on("pathtracer:interactionStart", () => this._requestRenderScale(this._interactionRenderScale())), this.pipeline.eventBus.on("pathtracer:interactionEnd", () => this._applyRenderScale(1));
|
|
5671
6130
|
}
|
|
5672
6131
|
async _initManagers() {
|
|
5673
|
-
await super._initManagers(), this.environmentManager.setProceduralSkyLoader(() => import("./PhysicalSky-
|
|
6132
|
+
await super._initManagers(), this.environmentManager.setProceduralSkyLoader(() => import("./PhysicalSky-CUWrTcmT.js").then((e) => e.n).then((e) => e.PhysicalSky)), this.stages.pathTracer.registerIntegrator(["bidirectional", "vcm"], (t) => new e(t)), this.stages.pathTracer.requestOutput("gBuffer"), this.interactionManager = new $a({
|
|
5674
6133
|
scene: this.meshScene,
|
|
5675
6134
|
camera: this.camera,
|
|
5676
6135
|
canvas: this.canvas,
|
|
@@ -5678,18 +6137,18 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5678
6137
|
pathTracer: null,
|
|
5679
6138
|
floorPlane: this.assetLoader.floorPlane,
|
|
5680
6139
|
isGeometryOnDisk: () => this.geometryOnDisk
|
|
5681
|
-
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.goboManager = new
|
|
6140
|
+
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.goboManager = new Ao(this.stages.pathTracer, {
|
|
5682
6141
|
onReset: () => this.reset(),
|
|
5683
6142
|
issues: this._issues
|
|
5684
|
-
}), this.iesManager = new
|
|
6143
|
+
}), this.iesManager = new Ho(this.stages.pathTracer, {
|
|
5685
6144
|
onReset: () => this.reset(),
|
|
5686
6145
|
issues: this._issues
|
|
5687
|
-
}), this._setupDenoisingManager(), this._headless || (await this._setupOverlayManager(), this.transformManager = new
|
|
6146
|
+
}), this._setupDenoisingManager(), this._headless || (await this._setupOverlayManager(), this.transformManager = new nc({
|
|
5688
6147
|
camera: this.camera,
|
|
5689
6148
|
canvas: this.canvas,
|
|
5690
6149
|
orbitControls: this.cameraManager.controls,
|
|
5691
6150
|
app: this
|
|
5692
|
-
}), this.overlayManager.register("transform", new
|
|
6151
|
+
}), this.overlayManager.register("transform", new rc(this.transformManager))), this.interactionManager.setDependencies({
|
|
5693
6152
|
overlayManager: this.overlayManager,
|
|
5694
6153
|
transformManager: this.transformManager,
|
|
5695
6154
|
appDispatch: (e) => this.dispatchEvent(e),
|
|
@@ -5746,7 +6205,7 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5746
6205
|
return {
|
|
5747
6206
|
...e,
|
|
5748
6207
|
applyExposure: (t) => {
|
|
5749
|
-
this.stages.autoExposure
|
|
6208
|
+
this.stages.autoExposure ? this.stages.autoExposure.setCompensation(t) : e.applyExposure(t);
|
|
5750
6209
|
},
|
|
5751
6210
|
onCameraProjection: (e) => {
|
|
5752
6211
|
this.cameraManager.applyProjection(e), e === "equirectangular" && this.denoisingManager?.requiresMotionVectors && this.denoisingManager.setDenoiserStrategy("edgeaware");
|
|
@@ -5754,9 +6213,9 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5754
6213
|
};
|
|
5755
6214
|
}
|
|
5756
6215
|
_beginFrame() {
|
|
5757
|
-
if (this.timeline.update(), this.cameraManager.updateControls(), this._applyPendingRenderScale(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
|
|
6216
|
+
if (this.timeline.update(), this.cameraManager.updateControls(), this._updateExposure(), this._applyPendingRenderScale(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
|
|
5758
6217
|
let e = this.animationManager.update();
|
|
5759
|
-
e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) =>
|
|
6218
|
+
e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => gc.error("animation refit error:", e)).finally(() => {
|
|
5760
6219
|
this._animRefitInFlight = !1;
|
|
5761
6220
|
}));
|
|
5762
6221
|
}
|
|
@@ -5771,11 +6230,45 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5771
6230
|
this.denoisingManager?.afterTrace(), t && !e.isComplete && this.denoisingManager?.tickContinuousDenoise(e.frameCount);
|
|
5772
6231
|
}
|
|
5773
6232
|
_renderCompleted() {
|
|
5774
|
-
this.denoisingManager.onRenderComplete({
|
|
6233
|
+
this.stages.autoExposure?.enabled && this._refreshFinished(), this.denoisingManager.onRenderComplete({
|
|
5775
6234
|
isStillComplete: () => this.completion.renderCompleteDispatched,
|
|
5776
6235
|
context: this.pipeline?.context
|
|
5777
6236
|
});
|
|
5778
6237
|
}
|
|
6238
|
+
_settling() {
|
|
6239
|
+
return !!this.stages.autoExposure?.settling;
|
|
6240
|
+
}
|
|
6241
|
+
_displayGain() {
|
|
6242
|
+
let e = this.stages.localExposure;
|
|
6243
|
+
return e?.wantsBuild && e.build(this.pipeline.context), e?.toneGain() ?? null;
|
|
6244
|
+
}
|
|
6245
|
+
setLocalExposure(e) {
|
|
6246
|
+
let t = this.stages.localExposure;
|
|
6247
|
+
t && (t.setEnabled(e), this.stages.compositor.setDisplayGain(e ? (e, n) => t.gainNode(e, n) : null), this.refreshFrame());
|
|
6248
|
+
}
|
|
6249
|
+
setLocalExposureParams(e) {
|
|
6250
|
+
this.stages.localExposure?.updateParameters(e);
|
|
6251
|
+
}
|
|
6252
|
+
_finishImage() {
|
|
6253
|
+
let e = this.stages.autoExposure;
|
|
6254
|
+
return e?.enabled ? e.meter(this.pipeline.context).then(() => e.advance(Infinity)) : null;
|
|
6255
|
+
}
|
|
6256
|
+
getProvenance() {
|
|
6257
|
+
let e = super.getProvenance(), t = this.stages.autoExposure, n = this.stages.localExposure;
|
|
6258
|
+
return e.exposure = {
|
|
6259
|
+
auto: t?.enabled ? {
|
|
6260
|
+
exposure: t.getExposure(),
|
|
6261
|
+
strength: t.strength,
|
|
6262
|
+
metering: t.metering,
|
|
6263
|
+
keyValue: t.keyValue
|
|
6264
|
+
} : null,
|
|
6265
|
+
local: n?.enabled ? {
|
|
6266
|
+
highlightContrast: n.highlightContrast,
|
|
6267
|
+
shadowContrast: n.shadowContrast,
|
|
6268
|
+
detailStrength: n.detailStrength
|
|
6269
|
+
} : null
|
|
6270
|
+
}, e;
|
|
6271
|
+
}
|
|
5779
6272
|
_renderHelperOverlay() {
|
|
5780
6273
|
super._renderHelperOverlay(), this.overlayManager?.render();
|
|
5781
6274
|
}
|
|
@@ -5834,10 +6327,10 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5834
6327
|
}
|
|
5835
6328
|
_setDeterministicExtras(e, t) {
|
|
5836
6329
|
if (e) {
|
|
5837
|
-
this.cameraManager?.setAutoFocusMode("manual"), this.stages.autoExposure
|
|
6330
|
+
this.cameraManager?.setAutoFocusMode("manual"), this.stages.autoExposure?.setEnabled(!1), this.denoisingManager?.setContinuousDenoise(!1);
|
|
5838
6331
|
return;
|
|
5839
6332
|
}
|
|
5840
|
-
t.autoFocusMode !== void 0 && this.cameraManager?.setAutoFocusMode(t.autoFocusMode),
|
|
6333
|
+
t.autoFocusMode !== void 0 && this.cameraManager?.setAutoFocusMode(t.autoFocusMode), t.autoExposure !== void 0 && this.stages.autoExposure?.setEnabled(t.autoExposure), t.continuousDenoise !== void 0 && this.denoisingManager?.setContinuousDenoise(t.continuousDenoise);
|
|
5841
6334
|
}
|
|
5842
6335
|
_disposeExtensions() {
|
|
5843
6336
|
this.interactionManager?.deselect?.(), this.transformManager?.detach?.(), this.animationManager?.dispose(), this.transformManager?.dispose(), this.overlayManager?.dispose(), this.goboManager?.dispose(), this.iesManager?.dispose(), this.denoisingManager?.dispose(), this.interactionManager?.dispose(), this.timeline?.dispose(), this.cameraManager?.dispose();
|
|
@@ -5854,10 +6347,10 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5854
6347
|
return t && this._dispatchCamerasUpdated(), t;
|
|
5855
6348
|
}
|
|
5856
6349
|
exportSceneState() {
|
|
5857
|
-
return
|
|
6350
|
+
return dc(this);
|
|
5858
6351
|
}
|
|
5859
6352
|
async importSceneState(e, t) {
|
|
5860
|
-
return await
|
|
6353
|
+
return await hc(this, e, t);
|
|
5861
6354
|
}
|
|
5862
6355
|
_dispatchCamerasUpdated() {
|
|
5863
6356
|
this.dispatchEvent({
|
|
@@ -5916,7 +6409,7 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5916
6409
|
}
|
|
5917
6410
|
configureForMode(e, t = {}) {
|
|
5918
6411
|
let n = e === "production", r = n ? De : Oe;
|
|
5919
|
-
this.denoisingManager?.setCadenceSuspended(n), this.timeline.stop(), this.cameraManager.controls.enabled = !n, this.settings.setMany(je(r), {
|
|
6412
|
+
this.denoisingManager?.setCadenceSuspended(n), this.timeline.stop(), this.cameraManager.controls.enabled = !n, this.stages.autoExposure && (this.stages.autoExposure.holdSamples = n ? 8 : 0), this.settings.setMany(je(r), {
|
|
5920
6413
|
silent: !0,
|
|
5921
6414
|
source: x.MODE_PRESET
|
|
5922
6415
|
}), this.stages.pathTracer?.setUniform("renderMode", parseInt(r.renderMode)), n && this._applyRenderScale(1), this.stages.pathTracer?.updateCompletionThreshold?.();
|
|
@@ -5979,7 +6472,7 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5979
6472
|
this.transformManager?.setMeshData(this._sdf.meshes);
|
|
5980
6473
|
}
|
|
5981
6474
|
_setupDenoisingManager() {
|
|
5982
|
-
this.denoisingManager = new
|
|
6475
|
+
this.denoisingManager = new Hs({
|
|
5983
6476
|
renderer: this.renderer,
|
|
5984
6477
|
mainCanvas: this.canvas,
|
|
5985
6478
|
stages: {
|
|
@@ -5997,22 +6490,45 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
5997
6490
|
pipeline: this.pipeline,
|
|
5998
6491
|
getExposure: () => this.settings.get("exposure") ?? 1,
|
|
5999
6492
|
getSaturation: () => this.settings.get("saturation") ?? 1,
|
|
6493
|
+
getDisplayGain: () => this._displayGain(),
|
|
6000
6494
|
issues: this._issues
|
|
6001
6495
|
}), this.denoisingManager.setupDenoiser(), this.denoisingManager.setupUpscaler(), this.denoisingManager._syncGBufferStages();
|
|
6002
6496
|
let e = this.canvas.clientWidth || 1, t = this.canvas.clientHeight || 1;
|
|
6003
6497
|
this.denoisingManager.setRenderSize(e, t);
|
|
6004
6498
|
}
|
|
6005
6499
|
_setupAutoExposureListener() {
|
|
6006
|
-
|
|
6500
|
+
let e = this.stages.autoExposure;
|
|
6501
|
+
e && (e.setCompensation(this.settings.get("exposure") ?? 1), this.stages.localExposure && (this.stages.localExposure.onChange = () => this._refreshFinished()), e.onChange = () => this._refreshFinished(), this._addTrackedListener(this.cameraManager, j.CAMERA_SWITCHED, () => e.resetHistory()), e.on("autoexposure:updated", ({ exposure: e, autoExposure: t, targetExposure: n, luminance: r }) => {
|
|
6007
6502
|
this.dispatchEvent({
|
|
6008
6503
|
type: j.AUTO_EXPOSURE_UPDATED,
|
|
6009
|
-
exposure: e
|
|
6010
|
-
|
|
6504
|
+
exposure: e,
|
|
6505
|
+
autoExposure: t,
|
|
6506
|
+
targetExposure: n,
|
|
6507
|
+
luminance: r
|
|
6011
6508
|
});
|
|
6012
|
-
});
|
|
6509
|
+
}));
|
|
6510
|
+
}
|
|
6511
|
+
_refreshFinished() {
|
|
6512
|
+
this.completion.renderCompleteDispatched && (this._needsDisplayRefresh = !0, this.wake());
|
|
6513
|
+
}
|
|
6514
|
+
_updateExposure() {
|
|
6515
|
+
let e = this.stages.localExposure;
|
|
6516
|
+
e?.wantsBuild && this.completion.renderCompleteDispatched && e.build(this.pipeline.context);
|
|
6517
|
+
let t = this.stages.autoExposure;
|
|
6518
|
+
if (!t?.enabled) return;
|
|
6519
|
+
this._noteExposureView();
|
|
6520
|
+
let n = this.cameraManager.afScreenPoint;
|
|
6521
|
+
t.metering === "spot" && (t.meteringPoint.x !== n.x || t.meteringPoint.y !== n.y) && t.updateParameters({ meteringPoint: n }), t.wantsMetering && this.completion.renderCompleteDispatched && t.meter(this.pipeline.context), t.update() && (this._needsDisplayRefresh = !0);
|
|
6522
|
+
}
|
|
6523
|
+
_noteExposureView() {
|
|
6524
|
+
let { matrixWorld: e, projectionMatrix: t } = this.camera, n = this._exposureView;
|
|
6525
|
+
n?.view.equals(e) && n.projection.equals(t) || (this._exposureView = {
|
|
6526
|
+
view: e.clone(),
|
|
6527
|
+
projection: t.clone()
|
|
6528
|
+
}, n && this.stages.autoExposure?.noteViewChanged());
|
|
6013
6529
|
}
|
|
6014
6530
|
async _setupOverlayManager() {
|
|
6015
|
-
this.overlayManager = new
|
|
6531
|
+
this.overlayManager = new Zs(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
|
|
6016
6532
|
helperScene: this._sceneHelpers,
|
|
6017
6533
|
meshScene: this.meshScene,
|
|
6018
6534
|
pipeline: this.pipeline,
|
|
@@ -6030,7 +6546,7 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
6030
6546
|
}
|
|
6031
6547
|
_recalibrateControlLimits() {
|
|
6032
6548
|
if (!this.meshScene || !this.cameraManager) return;
|
|
6033
|
-
let e = new
|
|
6549
|
+
let e = new ar(), t = new ar();
|
|
6034
6550
|
for (let n of this.meshScene.children) n.userData?.__rayzeeSceneObject && (t.setFromObject(n), t.isEmpty() || e.union(t));
|
|
6035
6551
|
if (e.isEmpty()) return;
|
|
6036
6552
|
let n = Math.max(e.max.x - e.min.x, e.max.y - e.min.y, e.max.z - e.min.z);
|
|
@@ -6043,15 +6559,15 @@ var Ts = Ke("engine"), Es = class extends te {
|
|
|
6043
6559
|
};
|
|
6044
6560
|
//#endregion
|
|
6045
6561
|
//#region src/Headless.js
|
|
6046
|
-
async function
|
|
6047
|
-
let t = await
|
|
6562
|
+
async function vc(e) {
|
|
6563
|
+
let t = await bc(e);
|
|
6048
6564
|
try {
|
|
6049
|
-
return await
|
|
6565
|
+
return await yc(t, e);
|
|
6050
6566
|
} finally {
|
|
6051
6567
|
t.dispose();
|
|
6052
6568
|
}
|
|
6053
6569
|
}
|
|
6054
|
-
async function
|
|
6570
|
+
async function yc(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire: r = !1, denoise: i = !1, onProgress: a = void 0 } = {}) {
|
|
6055
6571
|
let o = e.denoisingManager;
|
|
6056
6572
|
i && o && !o.finalDenoise && (o.applyOIDNEnabled(!0), o._syncGBufferStages());
|
|
6057
6573
|
let s = await e.renderFrames(t, {
|
|
@@ -6070,8 +6586,8 @@ async function Os(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire
|
|
|
6070
6586
|
provenance: e.getProvenance()
|
|
6071
6587
|
};
|
|
6072
6588
|
}
|
|
6073
|
-
async function
|
|
6074
|
-
let l = new
|
|
6589
|
+
async function bc({ canvas: e, model: t = null, width: n = 1920, height: r = 1080, strict: i = !0, deterministic: a = !0, settings: o = null, storage: s = !1, hostMemoryGB: c = void 0 } = {}) {
|
|
6590
|
+
let l = new _c(e ?? null, {
|
|
6075
6591
|
autoResize: !1,
|
|
6076
6592
|
strict: i,
|
|
6077
6593
|
storage: s,
|
|
@@ -6085,7 +6601,7 @@ async function ks({ canvas: e, model: t = null, width: n = 1920, height: r = 108
|
|
|
6085
6601
|
}
|
|
6086
6602
|
//#endregion
|
|
6087
6603
|
//#region src/managers/VideoRenderManager.js
|
|
6088
|
-
var
|
|
6604
|
+
var xc = class {
|
|
6089
6605
|
constructor(e) {
|
|
6090
6606
|
this._app = e, this._cancelled = !1, this._rendering = !1;
|
|
6091
6607
|
}
|
|
@@ -6102,24 +6618,32 @@ var As = class {
|
|
|
6102
6618
|
}
|
|
6103
6619
|
this._cancelled = !1, this._rendering = !0;
|
|
6104
6620
|
let g = this._saveState({ view: !!o });
|
|
6105
|
-
d.stopAnimation(), d.configureForMode("production")
|
|
6621
|
+
d.stopAnimation(), d.configureForMode("production");
|
|
6622
|
+
let _ = d.stages.autoExposure?.enabled ? d.stages.autoExposure : null;
|
|
6623
|
+
_ && (_.instant = !1), d.settings.setMany({
|
|
6624
|
+
maxSamples: i,
|
|
6625
|
+
renderLimitMode: "frames"
|
|
6626
|
+
}, {
|
|
6627
|
+
silent: !0,
|
|
6628
|
+
reset: !1
|
|
6629
|
+
}), d.stages.pathTracer?.updateCompletionThreshold?.(), d.cameraManager.controls && (d.cameraManager.controls.enabled = !1);
|
|
6106
6630
|
try {
|
|
6107
6631
|
for (let e = Math.max(0, s); e < m && !this._cancelled; e++) {
|
|
6108
6632
|
let n = e * h * r, i = f ? d.animationManager.seekTo(n, t) : null;
|
|
6109
|
-
if (o?.seek(e * h) && (d.cameraManager.resetAutoFocus(), d.cameraManager.updateAutoFocus()), i ? await d.refitBVH(i) : d.reset(), d.stopAnimation(), await this._accumulateFrame(d), this._cancelled || (a && d.denoisingManager?.finalDenoise && await this._waitForDenoise(d), this._cancelled)) break;
|
|
6110
|
-
let
|
|
6111
|
-
if (
|
|
6112
|
-
let t = await createImageBitmap(
|
|
6633
|
+
if (o?.seek(e * h) && (d.cameraManager.resetAutoFocus(), d.cameraManager.updateAutoFocus()), i ? await d.refitBVH(i) : d.reset(), d.stopAnimation(), _ && d._noteExposureView(), await this._accumulateFrame(d), this._cancelled || (_ && (await _.meter(d.pipeline.context), _.advance(e === Math.max(0, s) ? Infinity : h), d._presentDisplay()), a && d.denoisingManager?.finalDenoise && await this._waitForDenoise(d), this._cancelled)) break;
|
|
6634
|
+
let u = d.getCanvas();
|
|
6635
|
+
if (u && c) {
|
|
6636
|
+
let t = await createImageBitmap(u);
|
|
6113
6637
|
await c(t, e, m), t.close();
|
|
6114
6638
|
}
|
|
6115
|
-
let
|
|
6639
|
+
let p = {
|
|
6116
6640
|
frame: e + 1,
|
|
6117
6641
|
totalFrames: m,
|
|
6118
6642
|
percent: (e + 1) / m * 100
|
|
6119
6643
|
};
|
|
6120
|
-
l?.(
|
|
6644
|
+
l?.(p), d.dispatchEvent({
|
|
6121
6645
|
type: j.VIDEO_RENDER_PROGRESS,
|
|
6122
|
-
...
|
|
6646
|
+
...p
|
|
6123
6647
|
});
|
|
6124
6648
|
}
|
|
6125
6649
|
} catch (e) {
|
|
@@ -6166,7 +6690,7 @@ var As = class {
|
|
|
6166
6690
|
});
|
|
6167
6691
|
}
|
|
6168
6692
|
_saveState({ view: e }) {
|
|
6169
|
-
let t = this._app, n = t.settings.getEffective(), r = Object.keys(je(De));
|
|
6693
|
+
let t = this._app, n = t.settings.getEffective(), r = [...Object.keys(je(De)), "renderLimitMode"];
|
|
6170
6694
|
return e && r.push("focusDistance"), {
|
|
6171
6695
|
view: e ? t.cameraManager.captureView() : null,
|
|
6172
6696
|
settings: r.map((e) => [e, n[e]]),
|
|
@@ -6174,6 +6698,8 @@ var As = class {
|
|
|
6174
6698
|
controlsEnabled: t.cameraManager.controls?.enabled,
|
|
6175
6699
|
oidnEnabled: t.denoisingManager?.finalDenoise,
|
|
6176
6700
|
oidnQuality: t.denoisingManager?.oidnQuality,
|
|
6701
|
+
instantExposure: t.stages.autoExposure?.instant,
|
|
6702
|
+
holdExposureSamples: t.stages.autoExposure?.holdSamples,
|
|
6177
6703
|
wasPlaying: t.animationManager?.isPlaying,
|
|
6178
6704
|
pauseRendering: t.pauseRendering
|
|
6179
6705
|
};
|
|
@@ -6185,8 +6711,8 @@ var As = class {
|
|
|
6185
6711
|
reset: !1,
|
|
6186
6712
|
source: r.source
|
|
6187
6713
|
});
|
|
6188
|
-
t.stages.pathTracer && e.renderMode !== void 0 && t.stages.pathTracer?.setUniform("renderMode", parseInt(e.renderMode)), t.stages.pathTracer?.updateCompletionThreshold?.(), t.cameraManager.controls && (t.cameraManager.controls.enabled = e.controlsEnabled ?? !0), t.denoisingManager?.denoiser && (t.denoisingManager.applyOIDNEnabled(e.oidnEnabled ?? !1), e.oidnQuality && t.denoisingManager.applyOIDNQuality(e.oidnQuality)), t.pauseRendering = e.pauseRendering ?? !1, e.view && t.cameraManager.applyPose(e.view), t.denoisingManager?.setCadenceSuspended(!1), t.animationManager?.stop(), t.reset(), t.wake();
|
|
6714
|
+
t.stages.pathTracer && e.renderMode !== void 0 && t.stages.pathTracer?.setUniform("renderMode", parseInt(e.renderMode)), t.stages.pathTracer?.updateCompletionThreshold?.(), t.cameraManager.controls && (t.cameraManager.controls.enabled = e.controlsEnabled ?? !0), t.denoisingManager?.denoiser && (t.denoisingManager.applyOIDNEnabled(e.oidnEnabled ?? !1), e.oidnQuality && t.denoisingManager.applyOIDNQuality(e.oidnQuality)), t.pauseRendering = e.pauseRendering ?? !1, t.stages.autoExposure && (t.stages.autoExposure.instant = e.instantExposure ?? !1, t.stages.autoExposure.holdSamples = e.holdExposureSamples ?? 0), e.view && t.cameraManager.applyPose(e.view), t.denoisingManager?.setCadenceSuspended(!1), t.animationManager?.stop(), t.reset(), t.wake();
|
|
6189
6715
|
}
|
|
6190
6716
|
};
|
|
6191
6717
|
//#endregion
|
|
6192
|
-
export {
|
|
6718
|
+
export { Tt as ARCHIVE_FORMATS, qr as ASVGF_QUALITY_PRESETS, ta as AUTO_EXPOSURE_DEFAULTS, _o as AUTO_FOCUS_DEFAULTS, $s as AnimationManager, Ye as BVH_LEAF_MARKERS, Co as CameraManager, Do as CameraTrack, $t as ColorManagement, Vt as DEFAULT_LUT_SIZE, Xt as DEFAULT_MAX_EV, qt as DEFAULT_MIN_EV, _e as DEFAULT_SUN_PATH, _t as DEFAULT_VIEW, at as DEFAULT_WORKING_SPACE, ei as DENOISER_DEFAULTS, C as DOWNLOAD_POLICY, Hs as DenoisingManager, f as DownloadCache, tt as ENGINE_AREAS, Ee as ENGINE_DEFAULTS, j as EngineEvents, $e as EngineIssueError, Ao as GoboManager, Ho as IESManager, Oe as INTERACTIVE_RENDER_CONFIG, Ze as ISSUE_CODES, Qe as ISSUE_SEVERITY, $a as InteractionManager, Xe as IssueLog, we as LEGACY_EVENT_NAMES, Da as LOCAL_EXPOSURE_DEFAULTS, qe as LOG_LEVELS, ee as LightManager, Ge as Logger, ze as MATERIAL_DEFAULTS, Te as MATERIAL_VALUE_SOURCE, Se as MAX_RESERVABLE_RENDER_SIZE, Fe as MAX_SCENE_BYTES, ht as MAX_TABLE_TRANSFORMS, Me as MemoryLedger, Xr as NRD_DEFAULTS, Jr as NRD_HIT_DIST_A, Yr as NRD_HIT_DIST_B, Zr as NRD_PRESET_KEYS, Qr as NRD_QUALITY_PRESETS, dt as OCIO_VIEW_BASE, Zs as OverlayManager, De as PRODUCTION_RENDER_CONFIG, _c as PathTracerApp, u as PipelineContext, _n as RETOUCH_DEFAULTS, vn as RETOUCH_MAX_PIXELS, gn as RETOUCH_RANGES, w as RayzeeRenderer, S as RenderPipeline, d as RenderSettings, O as RenderStage, Ne as SAFE_SCENE_BYTES, ic as SCENE_STATE_VERSION, x as SETTING_SOURCE, xe as SKY_DEFAULTS, mn as SR_MAX_INPUT, hn as SR_SCALE, et as STORAGE_KIND, ge as StageExecutionMode, ln as StorageManager, Je as TRIANGLE_DATA_LAYOUT, ko as TimelineManager, nc as TransformManager, Be as VERSION, ct as VIEW_TRANSFORMS, fe as VRAMTracker, xc as VideoRenderManager, on as acquireLock, Ut as addAllOcioViews, Ht as addOcioView, pt as addViewTransform, rn as applyMatrixRGBA8, tn as bakeLut, be as bufferBytes, It as buildOcioView, gt as buildToneMapWGSL, v as cachedObjectURL, Jt as canvasColorSpaceFor, yc as captureHeadless, y as clearBindingAuditFindings, Lt as clearInputOverrides, st as configureAssets, Ue as configurePlatform, Pt as convertColor, At as convertEncodedRGBA8, nn as convertPixelsF32, Ke as createLogger, de as dayOfYearForMonth, ke as deriveAlphaMode, b as describeAdapter, kt as displayCanvasFit, Re as estimateSceneBytes, Ft as extractMatrix, Et as extractSceneMetadata, T as fetchFile, xt as fileIdentity, Zt as findNativeLinearSpace, We as fmt, St as folderIdentity, me as fromPortable, it as getActiveColorManagement, ot as getAssetConfig, g as getBindingAuditFindings, He as getPlatform, ft as getRegistryVersion, vt as getViewTransform, Mt as hasColorSpace, sn as heldLockNames, bt as identityKey, Wt as isColorManaged, jt as isDataSpace, Yt as isDataTexture, Nt as linearToSrgb, Qt as listFileRules, zt as listInputOverrides, lt as listViewTransforms, Ct as localFolder, an as makeCpuSampler, Rt as measureBakeError, p as nameFromUrl, mt as onRegistryChange, bc as openHeadless, cn as openStorage, fn as openZip, wt as parseSceneMetadata, Ie as probeAddressSpace, dn as readZipDirectory, ut as removeViewTransform, vc as renderHeadless, pn as renderUpscaled, Kt as resolveInputSpace, yt as sameIdentity, rt as setActiveColorManagement, h as setBindingAudit, en as setInputOverride, Gt as srgbToLinear, pe as sunPosition, ve as textureBytes, Bt as textureInputSpace, ye as timeForSunElevation, ue as toPortable };
|