rayzee 9.5.0 → 11.0.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.
Files changed (78) hide show
  1. package/README.md +22 -20
  2. package/dist/{ArchiveImporter-xuUJiklP.js → ArchiveImporter-BRQvLggb.js} +12 -13
  3. package/dist/{BidirectionalIntegrator-C5PKjJoT.js → BidirectionalIntegrator-9lZQxFVH.js} +87 -87
  4. package/dist/BufferLayout-D_IBo2ci.js +150 -0
  5. package/dist/{ColorManagement-CheBCPaW.js → ColorManagement-oeEk7oSu.js} +171 -171
  6. package/dist/{NeuralRetouch-CW11yLZ_.js → NeuralRetouch-BCXylThH.js} +3 -3
  7. package/dist/{NeuralSuperRes-BekaecYg.js → NeuralSuperRes-sZAeS142.js} +3 -3
  8. package/dist/{PathTracer-Ccl9KOuF.js → PathTracer-CQPW06Mm.js} +2911 -2669
  9. package/dist/{PhysicalSky-Dv2PMFGW.js → PhysicalSky-BvqCw_dy.js} +2 -2
  10. package/dist/{RayzeeRenderer-BQxnzCTD.js → RayzeeRenderer-COpwotpU.js} +338 -329
  11. package/dist/{SolarLimb-ken-JbDK.js → SolarLimb-CPaeZVwz.js} +10 -10
  12. package/dist/{ToneMapGPU-BHi5JzIq.js → ToneMapGPU-CjU3osDd.js} +1 -1
  13. package/dist/{ViewTransforms-D0rTLBsX.js → ViewTransforms-CYN7bq2w.js} +2 -2
  14. package/dist/addons/archives.es.js +1 -1
  15. package/dist/addons/bidirectional.es.js +1 -1
  16. package/dist/addons/color.es.js +1 -1
  17. package/dist/addons/physical-sky.es.js +1 -1
  18. package/dist/rayzee-core.es.js +11 -11
  19. package/dist/rayzee.es.js +734 -599
  20. package/dist/rayzee.umd.js +102 -102
  21. package/dist/sceneCachePolicy-BSSsKY98.js +443 -0
  22. package/package.json +1 -1
  23. package/src/Color/ViewTransforms.js +5 -1
  24. package/src/EngineDefaults.js +59 -1032
  25. package/src/Headless.js +6 -5
  26. package/src/Passes/OIDNTemporalHistory.js +1 -1
  27. package/src/PathTracerApp.js +5 -3
  28. package/src/Processor/AssetLoader.js +6 -5
  29. package/src/Processor/BVHBuilder.js +10 -31
  30. package/src/Processor/BVHLeafFold.js +4 -6
  31. package/src/Processor/BVHRefitter.js +3 -46
  32. package/src/Processor/BufferLayout.js +291 -0
  33. package/src/Processor/EmissiveTriangleBuilder.js +1 -1
  34. package/src/Processor/GeometryExtractor.js +3 -3
  35. package/src/Processor/HostMemory.js +7 -1
  36. package/src/Processor/InstanceTable.js +1 -1
  37. package/src/Processor/MaterialPacking.js +2 -1
  38. package/src/Processor/PBRT/PBRTSceneBuilder.js +1 -1
  39. package/src/Processor/QueueManager.js +28 -3
  40. package/src/Processor/SceneProcessor.js +4 -2
  41. package/src/Processor/SplitBLAS.js +1 -1
  42. package/src/Processor/StorageTexturePool.js +22 -1
  43. package/src/Processor/TLASBuilder.js +1 -3
  44. package/src/Processor/TextureBuckets.js +237 -0
  45. package/src/Processor/TextureCreator.js +10 -1
  46. package/src/Processor/Workers/TexturesWorker.js +5 -6
  47. package/src/RayzeeRenderer.js +29 -32
  48. package/src/RenderSettings.js +26 -28
  49. package/src/Stages/ASVGF.js +8 -7
  50. package/src/Stages/AutoExposure.js +14 -5
  51. package/src/Stages/BilateralFilter.js +2 -1
  52. package/src/Stages/DenoiserSettings.js +182 -0
  53. package/src/Stages/EdgeFilter.js +2 -1
  54. package/src/Stages/MotionVector.js +1 -1
  55. package/src/Stages/NRD.js +2 -3
  56. package/src/Stages/NormalDepth.js +3 -2
  57. package/src/Stages/PathTracer.js +72 -4
  58. package/src/Stages/PathTracerStage.js +2 -1
  59. package/src/Stages/Variance.js +1 -1
  60. package/src/TSL/BVHTraversal.js +4 -1
  61. package/src/TSL/Common.js +1 -1
  62. package/src/TSL/EmissiveSampling.js +1 -1
  63. package/src/TSL/LightVisibility.js +111 -0
  64. package/src/TSL/LightsSampling.js +151 -15
  65. package/src/TSL/Random.js +1 -1
  66. package/src/TSL/ShadeKernel.js +88 -3
  67. package/src/TSL/TextureSampling.js +1 -1
  68. package/src/core.js +5 -9
  69. package/src/index.js +10 -21
  70. package/src/integrators/BidirectionalIntegrator.js +2 -1
  71. package/src/managers/CameraManager.js +17 -7
  72. package/src/managers/DenoisingManager.js +14 -10
  73. package/src/managers/EnvironmentManager.js +32 -13
  74. package/src/managers/MaterialDataManager.js +3 -3
  75. package/src/managers/UniformManager.js +2 -2
  76. package/dist/EngineDefaults-DH3bI5t-.js +0 -844
  77. package/dist/sceneCachePolicy-BmwYOYDu.js +0 -183
  78. /package/dist/{Logger-BnHghprG.js → Logger-dDDGj9Av.js} +0 -0
package/dist/rayzee.es.js CHANGED
@@ -1,56 +1,179 @@
1
- import { t as e } from "./BidirectionalIntegrator-C5PKjJoT.js";
2
- import { $t as t, Ft as n, Jt as r, Pt as i, Qt as a, jt as o, rt as s, tn as c, wt as l } from "./SolarLimb-ken-JbDK.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 te, u as w } from "./RayzeeRenderer-BQxnzCTD.js";
4
- import { $ as ne, B as re, Ct as T, H as ie, K as ae, L as oe, Mt as E, N as se, Nt as D, P as ce, Q as O, R as le, St as ue, X as de, Z as fe, bt as pe, dt as me, et as he, gt as ge, ht as _e, jt as ve, lt as ye, mt as be, nt as xe, pt as Se, tt as Ce, ut as we, wt as Te, xt as Ee, z as De } from "./PathTracer-Ccl9KOuF.js";
5
- import { n as Oe, t as k } from "./EngineEvents-Ci8dVWCP.js";
6
- import { _ as ke, d as Ae, f as je, r as Me } from "./sceneCachePolicy-BmwYOYDu.js";
7
- import { C as Ne, D as Pe, E as Fe, O as Ie, P as Le, S as Re, T as ze, V as Be, X as Ve, Y as He, Z as Ue, _ as We, b as Ge, c as Ke, d as qe, f as Je, h as Ye, i as Xe, j as Ze, l as Qe, m as $e, n as et, o as tt, p as nt, r as rt, t as it, u as at, v as ot, w as st, x as ct, y as A, z as lt } from "./EngineDefaults-DH3bI5t-.js";
8
- import { i as ut, n as dt, r as ft, t as pt } from "./Logger-BnHghprG.js";
9
- import { i as mt, n as ht, r as gt, t as _t } from "./EngineIssues-CIZnXHsF.js";
10
- import { i as vt, r as yt } from "./shared-BGBcSxBQ.js";
11
- import { i as bt, r as xt, t as St } from "./ActiveColor-YvuQq44O.js";
12
- import { n as Ct, t as wt } from "./AssetConfig-DSEntE65.js";
13
- import { a as Tt, c as Et, f as Dt, h as Ot, i as kt, l as At, n as jt, o as Mt, r as Nt, u as Pt } from "./ViewTransforms-D0rTLBsX.js";
14
- import { i as Ft, n as It, r as Lt } from "./identity-DrQsGT2o.js";
15
- import { t as Rt } from "./ToneMapGPU-BHi5JzIq.js";
16
- import { n as zt, r as Bt, t as Vt } from "./archiveFormats-BZw7TiDp.js";
17
- import { t as Ht } from "./FileFormats-sPGJeCRc.js";
18
- import { A as Ut, C as Wt, D as Gt, E as Kt, O as qt, S as Jt, T as Yt, _ as Xt, a as Zt, b as Qt, c as $t, d as en, f as tn, g as nn, h as rn, i as an, k as on, l as sn, m as cn, n as ln, o as un, p as dn, r as fn, s as pn, t as mn, u as hn, v as gn, w as _n, x as vn, y as yn } from "./ColorManagement-CheBCPaW.js";
19
- import { c as bn, l as xn, n as Sn, o as Cn, t as wn } from "./openStorage-DwcBRUj7.js";
20
- import { n as Tn, t as En } from "./ZipReader-gDSWr0I5.js";
21
- import { i as Dn, n as On, r as kn } from "./NeuralSuperRes-BekaecYg.js";
22
- import { i as An, n as jn, r as Mn } from "./NeuralRetouch-CW11yLZ_.js";
23
- import { ExternalTexture as Nn, MeshBasicNodeMaterial as Pn, QuadMesh as Fn, ReadbackBuffer as In, RenderTarget as Ln, StorageTexture as j, TextureNode as M, WebGPURenderer as Rn } from "three/webgpu";
24
- import { Fn as zn, If as N, Loop as Bn, Return as Vn, abs as Hn, atan as Un, atomicAdd as Wn, atomicLoad as Gn, atomicStore as Kn, attributeArray as qn, dot as Jn, exp as Yn, exp2 as Xn, float as P, floor as Zn, fract as Qn, int as F, ivec2 as I, localId as L, max as R, min as $n, mix as z, normalize as er, pow as tr, round as nr, saturate as B, select as V, smoothstep as rr, sqrt as ir, storage as ar, textureLoad as H, textureStore as U, uint as W, uniform as G, uvec2 as or, uvec4 as sr, vec2 as K, vec3 as q, vec4 as J, wgslFn as cr, workgroupArray as lr, workgroupBarrier as ur, workgroupId as Y } from "three/tsl";
25
- import { ACESFilmicToneMapping as dr, AddEquation as fr, AnimationMixer as pr, Box2 as mr, Box3 as hr, ClampToEdgeWrapping as gr, Color as _r, Controls as vr, CustomBlending as yr, DataArrayTexture as br, DataTexture as xr, EventDispatcher as Sr, FloatType as Cr, HalfFloatType as wr, InterpolateSmooth as Tr, LinearFilter as X, LoopOnce as Er, LoopRepeat as Dr, MathUtils as Or, Matrix4 as kr, Mesh as Ar, MeshBasicMaterial as jr, NearestFilter as Z, NoColorSpace as Mr, NumberKeyframeTrack as Nr, OneFactor as Pr, OrthographicCamera as Fr, PerspectiveCamera as Ir, PropertyBinding as Lr, Quaternion as Rr, RGBAFormat as Q, Raycaster as zr, RedIntegerFormat as Br, SRGBColorSpace as Vr, Scene as Hr, SphereGeometry as Ur, Timer as Wr, UnsignedByteType as Gr, UnsignedIntType as Kr, Vector2 as qr, Vector3 as $, Vector4 as Jr, VectorKeyframeTrack as Yr } from "three";
26
- import { OrbitControls as Xr } from "three/addons/controls/OrbitControls.js";
27
- import { outline as Zr } from "three/addons/tsl/display/OutlineNode.js";
28
- import { TransformControls as Qr } from "three/addons/controls/TransformControls.js";
29
- //#region src/Stages/NormalDepth.js
30
- var $r = class extends E {
1
+ import { t as e } from "./BidirectionalIntegrator-9lZQxFVH.js";
2
+ import { $t as t, Ft as n, Jt as r, Pt as i, Qt as a, jt as o, rt as s, tn as c, wt as l } from "./SolarLimb-CPaeZVwz.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 te, u as w } from "./RayzeeRenderer-COpwotpU.js";
4
+ import { $ as ne, At as re, B as T, Bt as E, Ct as ie, Dt as ae, Et as oe, H as se, It as D, K as ce, L as O, Lt as k, N as le, Ot as ue, P as de, Q as A, R as fe, Rt as pe, St as me, Tt as he, Vt as ge, X as _e, Z as ve, bt as ye, dt as be, et as xe, ft as Se, ht as Ce, kt as we, lt as Te, mt as Ee, nt as De, pt as Oe, tt as ke, ut as Ae, xt as je, yt as Me, z as Ne } from "./PathTracer-CQPW06Mm.js";
5
+ import { n as Pe, t as j } from "./EngineEvents-Ci8dVWCP.js";
6
+ import { E as Fe, T as Ie, a as Le, c as Re, f as ze, i as Be, j as Ve, p as He, r as Ue } from "./sceneCachePolicy-BSSsKY98.js";
7
+ import { i as We, n as Ge, r as Ke, t as qe } from "./Logger-dDDGj9Av.js";
8
+ import { n as Je, s as Ye } from "./BufferLayout-D_IBo2ci.js";
9
+ import { i as Xe, n as Ze, r as Qe, t as $e } from "./EngineIssues-CIZnXHsF.js";
10
+ import { i as et, r as tt } from "./shared-BGBcSxBQ.js";
11
+ import { i as nt, r as rt, t as it } from "./ActiveColor-YvuQq44O.js";
12
+ import { n as at, t as ot } from "./AssetConfig-DSEntE65.js";
13
+ import { a as st, d as ct, g as lt, i as ut, l as dt, o as ft, p as pt, r as mt, s as ht, t as gt, u as _t } from "./ViewTransforms-CYN7bq2w.js";
14
+ import { i as vt, n as yt, r as bt } from "./identity-DrQsGT2o.js";
15
+ import { t as xt } from "./ToneMapGPU-CjU3osDd.js";
16
+ import { n as St, r as Ct, t as wt } from "./archiveFormats-BZw7TiDp.js";
17
+ import { t as Tt } from "./FileFormats-sPGJeCRc.js";
18
+ import { A as Et, C as Dt, D as Ot, E as kt, O as At, S as jt, T as Mt, _ as Nt, a as Pt, b as Ft, c as It, d as Lt, f as Rt, g as zt, h as Bt, i as Vt, k as Ht, l as Ut, m as Wt, n as Gt, o as Kt, p as qt, r as Jt, s as Yt, t as Xt, u as Zt, v as Qt, w as $t, x as en, y as tn } from "./ColorManagement-oeEk7oSu.js";
19
+ import { c as nn, l as rn, n as an, o as on, t as sn } from "./openStorage-DwcBRUj7.js";
20
+ import { n as cn, t as ln } from "./ZipReader-gDSWr0I5.js";
21
+ import { i as un, n as dn, r as fn } from "./NeuralSuperRes-sZAeS142.js";
22
+ import { i as pn, n as mn, r as hn } from "./NeuralRetouch-BCXylThH.js";
23
+ import { ExternalTexture as gn, MeshBasicNodeMaterial as _n, QuadMesh as vn, ReadbackBuffer as yn, RenderTarget as bn, StorageTexture as M, TextureNode as N, WebGPURenderer as xn } from "three/webgpu";
24
+ import { Fn as Sn, If as P, Loop as Cn, Return as wn, abs as Tn, atan as En, atomicAdd as Dn, atomicLoad as On, atomicStore as kn, attributeArray as An, dot as jn, exp as Mn, exp2 as Nn, float as F, floor as Pn, fract as Fn, int as I, ivec2 as L, localId as R, max as z, min as In, mix as B, normalize as Ln, pow as Rn, round as zn, saturate as V, select as H, smoothstep as Bn, sqrt as Vn, storage as Hn, textureLoad as U, textureStore as W, uint as G, uniform as K, uvec2 as Un, uvec4 as Wn, vec2 as Gn, vec3 as q, vec4 as J, wgslFn as Kn, workgroupArray as qn, workgroupBarrier as Jn, workgroupId as Y } from "three/tsl";
25
+ import { ACESFilmicToneMapping as Yn, AddEquation as Xn, AnimationMixer as Zn, Box2 as Qn, Box3 as $n, ClampToEdgeWrapping as er, Color as tr, Controls as nr, CustomBlending as rr, DataArrayTexture as ir, DataTexture as ar, EventDispatcher as or, FloatType as sr, HalfFloatType as cr, InterpolateSmooth as lr, LinearFilter as X, LoopOnce as ur, LoopRepeat as dr, MathUtils as fr, Matrix4 as pr, Mesh as mr, MeshBasicMaterial as hr, NearestFilter as Z, NoColorSpace as gr, NumberKeyframeTrack as _r, OneFactor as vr, OrthographicCamera as yr, PerspectiveCamera as br, PropertyBinding as xr, Quaternion as Sr, RGBAFormat as Q, Raycaster as Cr, RedIntegerFormat as wr, SRGBColorSpace as Tr, Scene as Er, SphereGeometry as Dr, Timer as Or, UnsignedByteType as kr, UnsignedIntType as Ar, Vector2 as jr, Vector3 as $, Vector4 as Mr, VectorKeyframeTrack as Nr } from "three";
26
+ import { OrbitControls as Pr } from "three/addons/controls/OrbitControls.js";
27
+ import { outline as Fr } from "three/addons/tsl/display/OutlineNode.js";
28
+ import { TransformControls as Ir } from "three/addons/controls/TransformControls.js";
29
+ //#region src/Stages/DenoiserSettings.js
30
+ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
31
+ low: {
32
+ temporalAlpha: .1,
33
+ gradientStrength: .8,
34
+ gradientSigmaScale: 2.5,
35
+ gradientNoiseFloor: .05,
36
+ atrousIterations: 3,
37
+ phiColor: 1,
38
+ phiNormal: 64,
39
+ phiDepth: .1,
40
+ phiLuminance: 6,
41
+ maxAccumFrames: 16,
42
+ varianceBoost: .5
43
+ },
44
+ medium: {
45
+ temporalAlpha: .03,
46
+ gradientStrength: 1,
47
+ gradientSigmaScale: 2.5,
48
+ gradientNoiseFloor: .05,
49
+ atrousIterations: 4,
50
+ phiColor: .5,
51
+ phiNormal: 128,
52
+ phiDepth: .05,
53
+ phiLuminance: 4,
54
+ maxAccumFrames: 64,
55
+ varianceBoost: 1
56
+ },
57
+ high: {
58
+ temporalAlpha: 0,
59
+ gradientStrength: 1,
60
+ gradientSigmaScale: 2.5,
61
+ gradientNoiseFloor: .05,
62
+ atrousIterations: 6,
63
+ phiColor: .3,
64
+ phiNormal: 256,
65
+ phiDepth: .02,
66
+ phiLuminance: 2,
67
+ maxAccumFrames: 128,
68
+ varianceBoost: 1.5
69
+ }
70
+ }, Vr = 3, Hr = .1, Ur = {
71
+ maxAccumulatedFrameNum: 30,
72
+ maxFastAccumulatedFrameNum: 6,
73
+ maxStabilizedFrameNum: 63,
74
+ historyFixFrameNum: 3,
75
+ historyFixBasePixelStride: 14,
76
+ prepassBlurRadius: 30,
77
+ minBlurRadius: 1,
78
+ maxBlurRadius: 30,
79
+ lobeAngleFraction: .15,
80
+ roughnessFraction: .15,
81
+ planeDistanceSensitivity: .02,
82
+ minHitDistanceWeight: .1,
83
+ fastHistoryClampingSigmaScale: 2,
84
+ fireflySuppressorMinRelativeScale: 2,
85
+ enableAntiFirefly: !0,
86
+ antilagLuminanceSigmaScale: 2,
87
+ antilagLuminanceSensitivity: 3,
88
+ disocclusionThreshold: .01,
89
+ convergenceS: 1,
90
+ convergenceB: .2,
91
+ convergenceP: .8,
92
+ lobeVolumePercent: .1,
93
+ handoverFrames: 0
94
+ }, Wr = [
95
+ "maxAccumulatedFrameNum",
96
+ "maxFastAccumulatedFrameNum",
97
+ "maxStabilizedFrameNum",
98
+ "historyFixFrameNum",
99
+ "prepassBlurRadius",
100
+ "maxBlurRadius",
101
+ "enableAntiFirefly"
102
+ ], Gr = {
103
+ low: {
104
+ maxAccumulatedFrameNum: 16,
105
+ maxFastAccumulatedFrameNum: 4,
106
+ maxStabilizedFrameNum: 16,
107
+ historyFixFrameNum: 2,
108
+ prepassBlurRadius: 0,
109
+ maxBlurRadius: 20,
110
+ enableAntiFirefly: !1
111
+ },
112
+ medium: {},
113
+ high: {
114
+ maxAccumulatedFrameNum: 45,
115
+ maxFastAccumulatedFrameNum: 8,
116
+ historyFixFrameNum: 4,
117
+ prepassBlurRadius: 40,
118
+ maxBlurRadius: 40
119
+ }
120
+ }, Kr = Br.medium, qr = {
121
+ denoiserStrategy: "none",
122
+ filterStrength: 1,
123
+ edgeAtrousIterations: 5,
124
+ edgePhiLuminance: 4,
125
+ edgePhiNormal: 64,
126
+ edgePhiDepth: .1,
127
+ enableOIDN: !1,
128
+ oidnQuality: "fast",
129
+ continuousDenoise: !1,
130
+ continuousDenoiseInterval: 8,
131
+ oidnTemporalHistory: !0,
132
+ enableUpscaler: !1,
133
+ upscalerScale: 2,
134
+ upscalerQuality: "fast",
135
+ upscalerHdr: !0,
136
+ enableASVGF: !1,
137
+ asvgfQualityPreset: "medium",
138
+ asvgfTemporalAlpha: Kr.temporalAlpha,
139
+ asvgfAtrousIterations: Kr.atrousIterations,
140
+ asvgfPhiColor: Kr.phiColor,
141
+ asvgfPhiNormal: Kr.phiNormal,
142
+ asvgfPhiDepth: Kr.phiDepth,
143
+ asvgfPhiLuminance: Kr.phiLuminance,
144
+ asvgfVarianceBoost: Kr.varianceBoost,
145
+ asvgfMaxAccumFrames: Kr.maxAccumFrames,
146
+ asvgfGradientStrength: Kr.gradientStrength,
147
+ asvgfGradientSigmaScale: Kr.gradientSigmaScale,
148
+ asvgfGradientNoiseFloor: Kr.gradientNoiseFloor,
149
+ asvgfDebugMode: 0,
150
+ showAsvgfHeatmap: !1,
151
+ nrdQualityPreset: "medium",
152
+ nrdDebugMode: 0
153
+ }, Jr = class extends E {
31
154
  constructor(e, t = {}) {
32
155
  super("NormalDepth", {
33
156
  ...t,
34
- executionMode: D.ALWAYS
35
- }), this.renderer = e, this.pathTracer = t.pathTracer, this._dirty = !0, this.cameraWorldMatrix = G(new kr(), "mat4"), this.cameraProjectionMatrixInverse = G(new kr(), "mat4"), this.cameraRay = O(), this.resolutionWidth = G(t.width || 1), this.resolutionHeight = G(t.height || 1);
157
+ executionMode: ge.ALWAYS
158
+ }), this.renderer = e, this.pathTracer = t.pathTracer, this._dirty = !0, this.cameraWorldMatrix = K(new pr(), "mat4"), this.cameraProjectionMatrixInverse = K(new pr(), "mat4"), this.cameraRay = A(), this.resolutionWidth = K(t.width || 1), this.resolutionHeight = K(t.height || 1);
36
159
  let n = t.width || 1, r = t.height || 1;
37
- this._outputStorageTex = new j(A, A), this._outputStorageTex.type = wr, this._outputStorageTex.format = Q, this._outputStorageTex.minFilter = Z, this._outputStorageTex.magFilter = Z, this._shadingStorageTex = new j(A, A), this._shadingStorageTex.type = wr, this._shadingStorageTex.format = Q, this._shadingStorageTex.minFilter = Z, this._shadingStorageTex.magFilter = Z, this._shadingRT = new Ln(n, r, {
38
- type: wr,
160
+ this._outputStorageTex = new M(k, k), this._outputStorageTex.type = cr, this._outputStorageTex.format = Q, this._outputStorageTex.minFilter = Z, this._outputStorageTex.magFilter = Z, this._shadingStorageTex = new M(k, k), this._shadingStorageTex.type = cr, this._shadingStorageTex.format = Q, this._shadingStorageTex.minFilter = Z, this._shadingStorageTex.magFilter = Z, this._shadingRT = new bn(n, r, {
161
+ type: cr,
39
162
  format: Q,
40
163
  minFilter: Z,
41
164
  magFilter: Z,
42
165
  depthBuffer: !1,
43
166
  stencilBuffer: !1
44
- }), this._leafStorageTex = null, this._leafRT = null, this._srcRegion = new mr(new qr(0, 0), new qr(0, 0));
167
+ }), this._leafStorageTex = null, this._leafRT = null, this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0));
45
168
  let i = {
46
- type: wr,
169
+ type: cr,
47
170
  format: Q,
48
171
  minFilter: Z,
49
172
  magFilter: Z,
50
173
  depthBuffer: !1,
51
174
  stencilBuffer: !1
52
175
  };
53
- this._rtA = new Ln(n, r, i), this._rtB = new Ln(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;
176
+ this._rtA = new bn(n, r, i), this._rtB = new bn(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;
54
177
  }
55
178
  setupEventListeners() {
56
179
  this.on("camera:moved", () => {
@@ -64,37 +187,37 @@ var $r = class extends E {
64
187
  if (!e) return !1;
65
188
  let t = e.materialData?.materialStorageAttr, n = e.triangleGeoAttr && e.triangleGeoAttr !== this._lastTriAttr, r = e.bvhStorageAttr && e.bvhStorageAttr !== this._lastBvhAttr, i = t && t !== this._lastMatAttr;
66
189
  return (n || r || i) && (this._computeNode?.dispose?.(), this._computeNode = null, this._computeBuilt = !1, this._triStorageNode = null, this._bvhStorageNode = null, this._matStorageNode = null, this._dirty = !0, this._hasHistory = !1), e.triangleGeoAttr && !this._triStorageNode && (this._triStorageNode = {
67
- geo: ar(e.triangleGeoAttr, "uvec4", e.triangleGeoAttr.count).toReadOnly(),
68
- shade: ar(e.triangleShadeAttr, "uvec4", e.triangleShadeAttr.count).toReadOnly()
69
- }), e.bvhStorageAttr && !this._bvhStorageNode && (this._bvhStorageNode = ar(e.bvhStorageAttr, "vec4", e.bvhStorageAttr.count).toReadOnly()), t && !this._matStorageNode && (this._matStorageNode = ar(t, "vec4", t.count).toReadOnly()), this._linearBuckets && re(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);
190
+ geo: Hn(e.triangleGeoAttr, "uvec4", e.triangleGeoAttr.count).toReadOnly(),
191
+ shade: Hn(e.triangleShadeAttr, "uvec4", e.triangleShadeAttr.count).toReadOnly()
192
+ }), e.bvhStorageAttr && !this._bvhStorageNode && (this._bvhStorageNode = Hn(e.bvhStorageAttr, "vec4", e.bvhStorageAttr.count).toReadOnly()), t && !this._matStorageNode && (this._matStorageNode = Hn(t, "vec4", t.count).toReadOnly()), this._linearBuckets && T(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);
70
193
  }
71
194
  _buildCompute() {
72
195
  let e = this._triStorageNode, n = this._bvhStorageNode, i = this._matStorageNode;
73
- this._linearBuckets = se(this.pathTracer?.materialData?.linearBuckets);
196
+ this._linearBuckets = le(this.pathTracer?.materialData?.linearBuckets);
74
197
  let o = {
75
- srgbBuckets: se(null),
198
+ srgbBuckets: le(null),
76
199
  linearBuckets: this._linearBuckets,
77
200
  shadowAlbedoMaps: null,
78
201
  goboMaps: null,
79
202
  iesProfiles: null,
80
203
  alphaShadows: null
81
204
  }, s = this.cameraWorldMatrix, u = this.cameraProjectionMatrixInverse, d = this.resolutionWidth, f = this.resolutionHeight, p = this._outputStorageTex, m = this._shadingStorageTex, h = this._leafStorageTex;
82
- this._computeNode = pe(zn(([o, s]) => {
83
- let u = F(Y.x).mul(8).add(F(L.x)), g = F(Y.y).mul(8).add(F(L.y));
84
- N(u.lessThan(F(d)).and(g.lessThan(F(f))), () => {
85
- let _ = a(de(K(P(u).add(.5).div(d), P(g).add(.5).div(f)), o, s, this.cameraRay)), v = r.wrap(ae(_, n, e)), y = v.normal.mul(.5).add(.5), b = $n(v.dst, P(65504)), x = v.didHit.select(J(y, b), J(0, 0, 0, P(65504)));
86
- U(p, or(W(u), W(g)), x).toWriteOnly(), h && U(h, or(W(u), W(g)), sr(W(v.instanceLeaf.add(1)), 0, 0, 0)).toWriteOnly();
87
- let S = v.normal.toVar(), ee = P(1).toVar();
88
- N(v.didHit, () => {
89
- let r = t.wrap(l(v.materialIndex, i)).toVar(), a = c.wrap(ce(v.uv, r)).toVar(), o = J(0).toVar();
90
- N(r.normalMapIndex.greaterThanEqual(F(0)), () => {
91
- o.assign(ie(e, v.triangleIndex, v.normal, r.normalTransform, n, v.instanceLeaf));
205
+ this._computeNode = Me(Sn(([o, s]) => {
206
+ let u = I(Y.x).mul(8).add(I(R.x)), g = I(Y.y).mul(8).add(I(R.y));
207
+ P(u.lessThan(I(d)).and(g.lessThan(I(f))), () => {
208
+ let _ = a(_e(Gn(F(u).add(.5).div(d), F(g).add(.5).div(f)), o, s, this.cameraRay)), v = r.wrap(ce(_, n, e)), y = v.normal.mul(.5).add(.5), b = In(v.dst, F(65504)), x = v.didHit.select(J(y, b), J(0, 0, 0, F(Lr)));
209
+ W(p, Un(G(u), G(g)), x).toWriteOnly(), h && W(h, Un(G(u), G(g)), Wn(G(v.instanceLeaf.add(1)), 0, 0, 0)).toWriteOnly();
210
+ let S = v.normal.toVar(), ee = F(1).toVar();
211
+ P(v.didHit, () => {
212
+ let r = t.wrap(l(v.materialIndex, i)).toVar(), a = c.wrap(de(v.uv, r)).toVar(), o = J(0).toVar();
213
+ P(r.normalMapIndex.greaterThanEqual(I(0)), () => {
214
+ o.assign(se(e, v.triangleIndex, v.normal, r.normalTransform, n, v.instanceLeaf));
92
215
  });
93
- let s = De(v.normal, r, a, o).toVar();
94
- S.assign(oe(s, r, a)), ee.assign(le(r, a).y.clamp(.05, 1));
216
+ let s = Ne(v.normal, r, a, o).toVar();
217
+ S.assign(O(s, r, a)), ee.assign(fe(r, a).y.clamp(.05, 1));
95
218
  });
96
219
  let C = v.didHit.select(J(S.mul(.5).add(.5), ee), J(0, 0, 0, 1));
97
- U(m, or(W(u), W(g)), C).toWriteOnly();
220
+ W(m, Un(G(u), G(g)), C).toWriteOnly();
98
221
  });
99
222
  })(s, u), o).compute([
100
223
  this._dispatchX,
@@ -140,15 +263,15 @@ var $r = class extends E {
140
263
  reallocateReservedStorage() {
141
264
  this._computeNode?.dispose(), this._computeNode = null, this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose();
142
265
  let e = () => {
143
- let e = new j(A, A);
144
- return e.type = wr, e.format = Q, e.minFilter = Z, e.magFilter = Z, e;
266
+ let e = new M(k, k);
267
+ return e.type = cr, e.format = Q, e.minFilter = Z, e.magFilter = Z, e;
145
268
  };
146
269
  this._outputStorageTex = e(), this._shadingStorageTex = e(), this._leafStorageTex &&= (this._leafStorageTex.dispose(), this._makeLeafStorage()), this._computeBuilt = !1;
147
270
  }
148
271
  setInstanceLeafOutput(e) {
149
- 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 Ln(this._rtA.width, this._rtA.height, {
150
- type: Kr,
151
- format: Br,
272
+ 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 bn(this._rtA.width, this._rtA.height, {
273
+ type: Ar,
274
+ format: wr,
152
275
  minFilter: Z,
153
276
  magFilter: Z,
154
277
  depthBuffer: !1,
@@ -159,40 +282,40 @@ var $r = class extends E {
159
282
  this._leafRT ? e.setTexture("pathtracer:instanceLeaf", this._leafRT.texture) : e.getTexture("pathtracer:instanceLeaf") && e.removeTexture("pathtracer:instanceLeaf");
160
283
  }
161
284
  _makeLeafStorage() {
162
- let e = new j(A, A);
163
- return e.type = Kr, e.format = Br, e.minFilter = Z, e.magFilter = Z, e;
285
+ let e = new M(k, k);
286
+ return e.type = Ar, e.format = wr, e.minFilter = Z, e.magFilter = Z, e;
164
287
  }
165
288
  dispose() {
166
289
  this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose(), this._shadingRT?.dispose(), this._leafStorageTex?.dispose(), this._leafRT?.dispose(), this._rtA?.dispose(), this._rtB?.dispose();
167
290
  }
168
- }, ei = class extends E {
291
+ }, Yr = class extends E {
169
292
  constructor(e, t, n = {}) {
170
293
  super("MotionVector", {
171
294
  ...n,
172
- executionMode: D.ALWAYS
295
+ executionMode: ge.ALWAYS
173
296
  }), this.renderer = e, this.camera = t, this.pathTracer = n.pathTracer || null;
174
297
  let r = n.width || 1, i = n.height || 1;
175
- this.prevViewProjectionMatrix = new kr(), this.currentViewProjectionMatrix = new kr(), this.matricesInitialized = !1, this.isFirstFrame = !0, this.frameCount = 0, this.cameraWorldMatrix = G(new kr(), "mat4"), this.cameraProjectionMatrixInverse = G(new kr(), "mat4"), this.cameraRay = O(), this.prevVP = G(new kr(), "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 j(A, A), this._screenSpaceStorageTex.type = wr, this._screenSpaceStorageTex.format = Q, this._screenSpaceStorageTex.minFilter = Z, this._screenSpaceStorageTex.magFilter = Z, this._worldSpaceStorageTex = new j(A, A), this._worldSpaceStorageTex.type = wr, this._worldSpaceStorageTex.format = Q, this._worldSpaceStorageTex.minFilter = Z, this._worldSpaceStorageTex.magFilter = Z, this._srcRegion = new mr(new qr(0, 0), new qr(0, 0));
298
+ this.prevViewProjectionMatrix = new pr(), this.currentViewProjectionMatrix = new pr(), this.matricesInitialized = !1, this.isFirstFrame = !0, this.frameCount = 0, this.cameraWorldMatrix = K(new pr(), "mat4"), this.cameraProjectionMatrixInverse = K(new pr(), "mat4"), this.cameraRay = A(), this.prevVP = K(new pr(), "mat4"), this.isFirstFrameU = K(1), this.deltaTime = K(1 / 60), this.velocityScale = K(1), this.resolutionWidth = K(r), this.resolutionHeight = K(i), this._normalDepthTexNode = new N(), this._screenSpaceStorageTex = new M(k, k), this._screenSpaceStorageTex.type = cr, this._screenSpaceStorageTex.format = Q, this._screenSpaceStorageTex.minFilter = Z, this._screenSpaceStorageTex.magFilter = Z, this._worldSpaceStorageTex = new M(k, k), this._worldSpaceStorageTex.type = cr, this._worldSpaceStorageTex.format = Q, this._worldSpaceStorageTex.minFilter = Z, this._worldSpaceStorageTex.magFilter = Z, this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0));
176
299
  let a = {
177
- type: wr,
300
+ type: cr,
178
301
  format: Q,
179
302
  minFilter: Z,
180
303
  magFilter: Z,
181
304
  depthBuffer: !1,
182
305
  stencilBuffer: !1
183
306
  };
184
- this.screenSpaceTarget = new Ln(r, i, a), this.worldSpaceTarget = new Ln(r, i, a), this._dispatchX = Math.ceil(r / 16), this._dispatchY = Math.ceil(i / 16), this._buildScreenSpaceCompute(), this._buildWorldSpaceCompute();
307
+ this.screenSpaceTarget = new bn(r, i, a), this.worldSpaceTarget = new bn(r, i, a), this._dispatchX = Math.ceil(r / 16), this._dispatchY = Math.ceil(i / 16), this._buildScreenSpaceCompute(), this._buildWorldSpaceCompute();
185
308
  }
186
309
  _buildScreenSpaceCompute() {
187
310
  let e = this._normalDepthTexNode, t = this.cameraWorldMatrix, n = this.cameraProjectionMatrixInverse, r = this.prevVP, i = this.resolutionWidth, a = this.resolutionHeight, o = this._screenSpaceStorageTex;
188
- this._screenSpaceComputeNode = zn(([t, n]) => {
189
- let s = F(Y.x).mul(16).add(F(L.x)), c = F(Y.y).mul(16).add(F(L.y));
190
- N(s.lessThan(F(i)).and(c.lessThan(F(a))), () => {
191
- 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();
192
- N(l.lessThan(P(6e4)), () => {
193
- let e = fe(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));
194
- d.assign(c.select(J(s, l, 1), J(P(1e3), P(1e3), l, 0)));
195
- }), U(o, or(W(s), W(c)), d).toWriteOnly();
311
+ this._screenSpaceComputeNode = Sn(([t, n]) => {
312
+ let s = I(Y.x).mul(16).add(I(R.x)), c = I(Y.y).mul(16).add(I(R.y));
313
+ P(s.lessThan(I(i)).and(c.lessThan(I(a))), () => {
314
+ let l = U(e, L(s, c)).w, u = Gn(F(s).add(.5).div(i), F(c).add(.5).div(a)), d = J(0, 0, l, 1).toVar();
315
+ P(l.lessThan(F(6e4)), () => {
316
+ let e = ve(u, l, t, n, this.cameraRay), i = r.mul(J(e, 1)), a = i.xy.div(i.w), o = Gn(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));
317
+ d.assign(c.select(J(s, l, 1), J(F(1e3), F(1e3), l, 0)));
318
+ }), W(o, Un(G(s), G(c)), d).toWriteOnly();
196
319
  });
197
320
  })(t, n).compute([
198
321
  this._dispatchX,
@@ -206,14 +329,14 @@ var $r = class extends E {
206
329
  }
207
330
  _buildWorldSpaceCompute() {
208
331
  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;
209
- this._worldSpaceComputeNode = zn(([t, n]) => {
210
- let u = F(Y.x).mul(16).add(F(L.x)), d = F(Y.y).mul(16).add(F(L.y));
211
- N(u.lessThan(F(s)).and(d.lessThan(F(c))), () => {
212
- let f = H(e, I(u, d)).w, p = J(0, 0, 0, 0).toVar();
213
- N(i.lessThan(.5).and(f.lessThan(P(6e4))), () => {
214
- let e = K(P(u).add(.5).div(s), P(d).add(.5).div(c)), i = fe(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);
332
+ this._worldSpaceComputeNode = Sn(([t, n]) => {
333
+ let u = I(Y.x).mul(16).add(I(R.x)), d = I(Y.y).mul(16).add(I(R.y));
334
+ P(u.lessThan(I(s)).and(d.lessThan(I(c))), () => {
335
+ let f = U(e, L(u, d)).w, p = J(0, 0, 0, 0).toVar();
336
+ P(i.lessThan(.5).and(f.lessThan(F(6e4))), () => {
337
+ let e = Gn(F(u).add(.5).div(s), F(d).add(.5).div(c)), i = ve(e, f, t, n, this.cameraRay), l = r.mul(J(i, 1)), m = l.xy.div(l.w), h = Gn(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);
215
338
  p.assign(g.select(J(v, 1), J(0, 0, 0, .5)));
216
- }), U(l, or(W(u), W(d)), p).toWriteOnly();
339
+ }), W(l, Un(G(u), G(d)), p).toWriteOnly();
217
340
  });
218
341
  })(t, n).compute([
219
342
  this._dispatchX,
@@ -277,83 +400,83 @@ var $r = class extends E {
277
400
  reallocateReservedStorage() {
278
401
  this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose();
279
402
  let e = () => {
280
- let e = new j(A, A);
281
- return e.type = wr, e.format = Q, e.minFilter = Z, e.magFilter = Z, e;
403
+ let e = new M(k, k);
404
+ return e.type = cr, e.format = Q, e.minFilter = Z, e.magFilter = Z, e;
282
405
  };
283
406
  this._screenSpaceStorageTex = e(), this._worldSpaceStorageTex = e(), this._buildScreenSpaceCompute(), this._buildWorldSpaceCompute();
284
407
  }
285
408
  dispose() {
286
409
  this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose(), this.screenSpaceTarget?.dispose(), this.worldSpaceTarget?.dispose(), this._normalDepthTexNode?.dispose();
287
410
  }
288
- }, ti = (e) => V(e.equal(e), e, P(0)).clamp(0, 1e7), ni = (e) => q(ti(e.x), ti(e.y), ti(e.z)), ri = class extends E {
411
+ }, Xr = (e) => H(e.equal(e), e, F(0)).clamp(0, 1e7), Zr = (e) => q(Xr(e.x), Xr(e.y), Xr(e.z)), Qr = class extends E {
289
412
  constructor(e, t = {}) {
290
413
  super("ASVGF", {
291
414
  ...t,
292
- executionMode: D.PER_CYCLE
293
- }), this.renderer = e, this.temporalAlpha = G(t.temporalAlpha ?? 0), this.gradientStrength = G(t.gradientStrength ?? 1), this.gradientSigmaScale = G(t.gradientSigmaScale ?? 2), this.gradientNoiseFloor = G(t.gradientNoiseFloor ?? 0), this.maxAccumFrames = G(t.maxAccumFrames ?? 32), 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();
415
+ executionMode: ge.PER_CYCLE
416
+ }), this.renderer = e, this.temporalAlpha = K(t.temporalAlpha ?? Br.medium.temporalAlpha), this.gradientStrength = K(t.gradientStrength ?? Br.medium.gradientStrength), this.gradientSigmaScale = K(t.gradientSigmaScale ?? Br.medium.gradientSigmaScale), this.gradientNoiseFloor = K(t.gradientNoiseFloor ?? Br.medium.gradientNoiseFloor), this.maxAccumFrames = K(t.maxAccumFrames ?? Br.medium.maxAccumFrames), this.resW = K(t.width || 1), this.resH = K(t.height || 1), this.temporalEnabledU = K(1), this.forceResetU = K(0), this._colorTexNode = new N(), this._albedoTexNode = new N(), this._motionTexNode = new N(), this._normalDepthTexNode = new N(), this._prevNormalDepthTexNode = new N(), this._readTemporalTexNode = new N(), this._gradientReadTexNode = new N();
294
417
  let n = t.width || 1, r = t.height || 1;
295
- this._temporalTexA = new j(A, A), this._temporalTexA.type = Cr, this._temporalTexA.format = Q, this._temporalTexA.minFilter = X, this._temporalTexA.magFilter = X, this._temporalTexB = new j(A, A), this._temporalTexB.type = Cr, this._temporalTexB.format = Q, this._temporalTexB.minFilter = X, this._temporalTexB.magFilter = X, this._outputModulatedTex = new j(A, A), this._outputModulatedTex.type = Cr, this._outputModulatedTex.format = Q, this._outputModulatedTex.minFilter = X, this._outputModulatedTex.magFilter = X, this._gradientStorageTex = new j(A, A), this._gradientStorageTex.type = wr, this._gradientStorageTex.format = Q, this._gradientStorageTex.minFilter = X, this._gradientStorageTex.magFilter = X, this._srcRegion = new mr(new qr(0, 0), new qr(0, 0)), this._demodulatedRT = new Ln(n, r, {
296
- type: Cr,
418
+ this._temporalTexA = new M(k, k), this._temporalTexA.type = sr, this._temporalTexA.format = Q, this._temporalTexA.minFilter = X, this._temporalTexA.magFilter = X, this._temporalTexB = new M(k, k), this._temporalTexB.type = sr, this._temporalTexB.format = Q, this._temporalTexB.minFilter = X, this._temporalTexB.magFilter = X, this._outputModulatedTex = new M(k, k), this._outputModulatedTex.type = sr, this._outputModulatedTex.format = Q, this._outputModulatedTex.minFilter = X, this._outputModulatedTex.magFilter = X, this._gradientStorageTex = new M(k, k), this._gradientStorageTex.type = cr, this._gradientStorageTex.format = Q, this._gradientStorageTex.minFilter = X, this._gradientStorageTex.magFilter = X, this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0)), this._demodulatedRT = new bn(n, r, {
419
+ type: sr,
297
420
  format: Q,
298
421
  minFilter: X,
299
422
  magFilter: X,
300
423
  depthBuffer: !1,
301
424
  stencilBuffer: !1
302
- }), this._outputRT = new Ln(n, r, {
303
- type: Cr,
425
+ }), this._outputRT = new bn(n, r, {
426
+ type: sr,
304
427
  format: Q,
305
428
  minFilter: X,
306
429
  magFilter: X,
307
430
  depthBuffer: !1,
308
431
  stencilBuffer: !1
309
- }), this._gradientRT = new Ln(n, r, {
310
- type: wr,
432
+ }), this._gradientRT = new bn(n, r, {
433
+ type: cr,
311
434
  format: Q,
312
435
  minFilter: X,
313
436
  magFilter: X,
314
437
  depthBuffer: !1,
315
438
  stencilBuffer: !1
316
- }), 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 j(A, A), this._heatmapStorageTex.type = Cr, this._heatmapStorageTex.format = Q, this._heatmapStorageTex.minFilter = Z, this._heatmapStorageTex.magFilter = Z, this.heatmapTarget = new Ln(n, r, {
317
- type: Cr,
439
+ }), 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 = K(0, "int"), this._heatmapStorageTex = new M(k, k), this._heatmapStorageTex.type = sr, this._heatmapStorageTex.format = Q, this._heatmapStorageTex.minFilter = Z, this._heatmapStorageTex.magFilter = Z, this.heatmapTarget = new bn(n, r, {
440
+ type: sr,
318
441
  format: Q,
319
442
  minFilter: Z,
320
443
  magFilter: Z,
321
444
  depthBuffer: !1,
322
445
  stencilBuffer: !1
323
- }), 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();
446
+ }), this._heatmapRawColorTexNode = new N(), this._heatmapColorTexNode = new N(), this._heatmapTemporalTexNode = new N(), this._heatmapNDTexNode = new N(), this._heatmapMotionTexNode = new N(), this._heatmapGradientTexNode = new N(), this._buildHeatmapCompute();
324
447
  }
325
448
  _buildGradientCompute() {
326
- 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 = lr("float", 144), d = lr("float", 144);
327
- this._gradientNode = zn(() => {
328
- 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) => {
329
- 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(ni(m.div(R(_, q(et))))).toVar();
449
+ 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 = qn("float", 144), d = qn("float", 144);
450
+ this._gradientNode = Sn(() => {
451
+ let f = R.x, p = R.y, m = p.mul(8).add(f), h = I(Y.x).mul(8).sub(2).toVar(), g = I(Y.y).mul(8).sub(2).toVar(), _ = (i) => {
452
+ let a = i.mod(G(12)), s = i.div(G(12)), f = h.add(I(a)).clamp(I(0), I(c).sub(1)), p = g.add(I(s)).clamp(I(0), I(l).sub(1)), m = U(e, L(f, p)).xyz, _ = U(t, L(f, p)).xyz, v = o(Zr(m.div(z(_, q(zr))))).toVar();
330
453
  u.element(i).assign(v);
331
- 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), te = H(r, I(S, ee)).xyz, w = C.select(o(te), v);
454
+ let y = U(n, L(f, p)), b = F(f).sub(y.x.mul(c)), x = F(p).sub(y.y.mul(l)), S = I(b.add(.5)).clamp(I(0), I(c).sub(1)), ee = I(x.add(.5)).clamp(I(0), I(l).sub(1)), C = y.w.greaterThan(.5), te = U(r, L(S, ee)).xyz, w = C.select(o(te), v);
332
455
  d.element(i).assign(w);
333
456
  };
334
457
  _(m);
335
- let v = m.add(W(64));
336
- N(v.lessThan(W(144)), () => {
458
+ let v = m.add(G(64));
459
+ P(v.lessThan(G(144)), () => {
337
460
  _(v);
338
461
  });
339
- let y = m.add(W(128));
340
- N(y.lessThan(W(144)), () => {
462
+ let y = m.add(G(128));
463
+ P(y.lessThan(G(144)), () => {
341
464
  _(y);
342
- }), ur();
343
- let b = F(Y.x).mul(8).add(F(f)), x = F(Y.y).mul(8).add(F(p));
344
- N(b.lessThan(F(c)).and(x.lessThan(F(l))), () => {
345
- let e = P(0).toVar(), t = P(0).toVar();
465
+ }), Jn();
466
+ let b = I(Y.x).mul(8).add(I(f)), x = I(Y.y).mul(8).add(I(p));
467
+ P(b.lessThan(I(c)).and(x.lessThan(I(l))), () => {
468
+ let e = F(0).toVar(), t = F(0).toVar();
346
469
  for (let n = -2; n <= 2; n++) for (let r = -2; r <= 2; r++) {
347
- let i = p.add(W(2 + n)).mul(W(12)).add(f.add(W(2 + r))), a = u.element(i);
470
+ let i = p.add(G(2 + n)).mul(G(12)).add(f.add(G(2 + r))), a = u.element(i);
348
471
  e.addAssign(a), t.addAssign(a.mul(a));
349
472
  }
350
- let o = e.div(25), m = ir(R(t.div(25).sub(o.mul(o)), P(0))).mul(a).toVar(), h = P(0).toVar();
473
+ let o = e.div(25), m = Vn(z(t.div(25).sub(o.mul(o)), F(0))).mul(a).toVar(), h = F(0).toVar();
351
474
  for (let e = -2; e <= 2; e++) for (let t = -2; t <= 2; t++) {
352
- 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(Hn(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)));
475
+ let n = p.add(G(2 + e)).mul(G(12)).add(f.add(G(2 + t))), r = u.element(n), a = d.element(n), o = z(z(Tn(r.sub(a)).sub(m), F(0)).div(z(z(r, a), F(.001))).sub(i), F(0)).div(z(F(1).sub(i), F(1e-4)));
353
476
  h.addAssign(o.mul(o));
354
477
  }
355
- 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);
356
- U(s, or(W(b), W(x)), J(ee, g, m, 1)).toWriteOnly();
478
+ let g = h.div(25).clamp(0, 1).toVar(), _ = U(n, L(b, x)), v = I(F(b).sub(_.x.mul(c)).add(.5)).clamp(I(0), I(c).sub(1)), y = I(F(x).sub(_.y.mul(l)).add(.5)).clamp(I(0), I(l).sub(1)), S = _.w.greaterThan(.5).select(U(r, L(v, y)).w, F(0)).div(4).clamp(0, 1), ee = g.mul(S);
479
+ W(s, Un(G(b), G(x)), J(ee, g, m, 1)).toWriteOnly();
357
480
  });
358
481
  })().compute([
359
482
  this._dispatchX,
@@ -370,23 +493,23 @@ var $r = class extends E {
370
493
  }
371
494
  _buildTemporalForDirection(e) {
372
495
  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;
373
- return zn(() => {
374
- let g = F(Y.x).mul(8).add(F(L.x)), _ = F(Y.y).mul(8).add(F(L.y));
375
- N(g.lessThan(F(m)).and(_.lessThan(F(h))), () => {
376
- let v = I(g, _), y = H(t, v), b = y.xyz, x = y.w, S = H(n, v).xyz, ee = R(S, q(et)), C = ni(b.div(ee)), te = J(C, 1).toVar(), w = J(b, x).toVar();
377
- N(f.greaterThan(.5).and(p.lessThan(.5)), () => {
378
- 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)));
379
- N(t.and(f), () => {
380
- 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)), ne = g.clamp(F(0), F(m).sub(1)), re = p.clamp(F(0), F(h).sub(1)), T = _.clamp(F(0), F(h).sub(1)), ie = P(1).sub(y).mul(P(1).sub(b)), ae = y.mul(P(1).sub(b)), oe = P(1).sub(y).mul(b), E = y.mul(b), se = (e, n, i) => {
381
- let o = H(a, I(e, n)), s = o.xyz.mul(2).sub(1), c = o.w, l = tr(Jn(t, s).clamp(0, 1), P(16)), u = Yn(Hn(r.sub(c)).div(R(r, P(.001))).div(P(.05)).negate());
496
+ return Sn(() => {
497
+ let g = I(Y.x).mul(8).add(I(R.x)), _ = I(Y.y).mul(8).add(I(R.y));
498
+ P(g.lessThan(I(m)).and(_.lessThan(I(h))), () => {
499
+ let v = L(g, _), y = U(t, v), b = y.xyz, x = y.w, S = U(n, v).xyz, ee = z(S, q(zr)), C = Zr(b.div(ee)), te = J(C, 1).toVar(), w = J(b, x).toVar();
500
+ P(f.greaterThan(.5).and(p.lessThan(.5)), () => {
501
+ let e = U(r, v), t = e.w.greaterThan(.5), n = F(g).sub(e.x.mul(m)), c = F(_).sub(e.y.mul(h)), f = n.greaterThanEqual(0).and(n.lessThan(F(m))).and(c.greaterThanEqual(0)).and(c.lessThan(F(h)));
502
+ P(t.and(f), () => {
503
+ let e = U(i, v), t = e.xyz.mul(2).sub(1), r = e.w, f = I(n), p = I(c), g = f.add(I(1)), _ = p.add(I(1)), y = n.sub(F(f)), b = c.sub(F(p)), S = f.clamp(I(0), I(m).sub(1)), ne = g.clamp(I(0), I(m).sub(1)), re = p.clamp(I(0), I(h).sub(1)), T = _.clamp(I(0), I(h).sub(1)), E = F(1).sub(y).mul(F(1).sub(b)), ie = y.mul(F(1).sub(b)), ae = F(1).sub(y).mul(b), oe = y.mul(b), se = (e, n, i) => {
504
+ let o = U(a, L(e, n)), s = o.xyz.mul(2).sub(1), c = o.w, l = Rn(jn(t, s).clamp(0, 1), F(16)), u = Mn(Tn(r.sub(c)).div(z(r, F(.001))).div(F(.05)).negate());
382
505
  return i.mul(l).mul(u);
383
- }, D = se(S, re, ie), ce = se(ne, re, ae), O = se(S, T, oe), le = se(ne, T, E), ue = D.add(ce).add(O).add(le);
384
- N(ue.greaterThan(P(.01)), () => {
385
- let e = H(o, I(S, re)), t = H(o, I(ne, re)), n = H(o, I(S, T)), r = H(o, I(ne, T)), i = P(1).div(ue), a = e.xyz.mul(D).add(t.xyz.mul(ce)).add(n.xyz.mul(O)).add(r.xyz.mul(le)).mul(i), c = e.w.mul(D).add(t.w.mul(ce)).add(n.w.mul(O)).add(r.w.mul(le)).mul(i), f = H(s, v).x.mul(d).clamp(0, 1), p = ni(z(a, C, z(R(P(1).div(c.add(1)), u), P(1), f))), m = $n(c.add(1), l);
506
+ }, D = se(S, re, E), ce = se(ne, re, ie), O = se(S, T, ae), k = se(ne, T, oe), le = D.add(ce).add(O).add(k);
507
+ P(le.greaterThan(F(.01)), () => {
508
+ let e = U(o, L(S, re)), t = U(o, L(ne, re)), n = U(o, L(S, T)), r = U(o, L(ne, T)), i = F(1).div(le), a = e.xyz.mul(D).add(t.xyz.mul(ce)).add(n.xyz.mul(O)).add(r.xyz.mul(k)).mul(i), c = e.w.mul(D).add(t.w.mul(ce)).add(n.w.mul(O)).add(r.w.mul(k)).mul(i), f = U(s, v).x.mul(d).clamp(0, 1), p = Zr(B(a, C, B(z(F(1).div(c.add(1)), u), F(1), f))), m = In(c.add(1), l);
386
509
  te.assign(J(p, m)), w.assign(J(p.mul(ee), x));
387
510
  });
388
511
  });
389
- }), U(e, or(W(g), W(_)), te).toWriteOnly(), U(c, or(W(g), W(_)), w).toWriteOnly();
512
+ }), W(e, Un(G(g), G(_)), te).toWriteOnly(), W(c, Un(G(g), G(_)), w).toWriteOnly();
390
513
  });
391
514
  })().compute([
392
515
  this._dispatchX,
@@ -400,35 +523,35 @@ var $r = class extends E {
400
523
  }
401
524
  _buildHeatmapCompute() {
402
525
  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;
403
- this._heatmapComputeNode = zn(() => {
404
- let d = F(Y.x).mul(8).add(F(L.x)), f = F(Y.y).mul(8).add(F(L.y));
405
- N(d.lessThan(F(l)).and(f.lessThan(F(u))), () => {
406
- let p = I(d, f), m = J(0, 0, 0, 1).toVar();
407
- N(c.equal(F(0)), () => {
408
- let e = H(t, p).xyz;
526
+ this._heatmapComputeNode = Sn(() => {
527
+ let d = I(Y.x).mul(8).add(I(R.x)), f = I(Y.y).mul(8).add(I(R.y));
528
+ P(d.lessThan(I(l)).and(f.lessThan(I(u))), () => {
529
+ let p = L(d, f), m = J(0, 0, 0, 1).toVar();
530
+ P(c.equal(I(0)), () => {
531
+ let e = U(t, p).xyz;
409
532
  m.assign(J(e, 1));
410
- }).ElseIf(c.equal(F(1)), () => {
411
- let t = P(0).toVar(), n = P(0).toVar();
533
+ }).ElseIf(c.equal(I(1)), () => {
534
+ let t = F(0).toVar(), n = F(0).toVar();
412
535
  for (let r = -1; r <= 1; r++) for (let i = -1; i <= 1; i++) {
413
- 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);
536
+ let a = U(e, L(d.add(i).clamp(I(0), I(l).sub(1)), f.add(r).clamp(I(0), I(u).sub(1)))).xyz, s = o(a);
414
537
  t.addAssign(s), n.addAssign(s.mul(s));
415
538
  }
416
539
  t.divAssign(9), n.divAssign(9);
417
- 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));
540
+ let r = z(n.sub(t.mul(t)), F(0)).div(z(t.mul(t), F(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 = F(1).sub(r.sub(.25).mul(4).clamp(0, 1));
418
541
  m.assign(J(i, a, s, 1));
419
- }).ElseIf(c.equal(F(2)), () => {
420
- let e = H(n, p).w.div(32).clamp(0, 1);
421
- m.assign(J(P(1).sub(e), e, P(.2), 1));
422
- }).ElseIf(c.equal(F(3)), () => {
423
- let e = H(i, p), t = Hn(e.x).mul(100).clamp(0, 1), n = Hn(e.y).mul(100).clamp(0, 1), r = t.add(n).clamp(0, 1);
542
+ }).ElseIf(c.equal(I(2)), () => {
543
+ let e = U(n, p).w.div(32).clamp(0, 1);
544
+ m.assign(J(F(1).sub(e), e, F(.2), 1));
545
+ }).ElseIf(c.equal(I(3)), () => {
546
+ let e = U(i, p), t = Tn(e.x).mul(100).clamp(0, 1), n = Tn(e.y).mul(100).clamp(0, 1), r = t.add(n).clamp(0, 1);
424
547
  m.assign(J(t, n, r.mul(.3), 1));
425
- }).ElseIf(c.equal(F(4)), () => {
426
- let e = H(r, p);
548
+ }).ElseIf(c.equal(I(4)), () => {
549
+ let e = U(r, p);
427
550
  m.assign(J(e.xyz, 1));
428
551
  }).Else(() => {
429
- let e = H(a, p).x.mul(5).clamp(0, 1);
430
- m.assign(J(e, e.mul(.5), P(1).sub(e), 1));
431
- }), U(s, or(W(d), W(f)), m).toWriteOnly();
552
+ let e = U(a, p).x.mul(5).clamp(0, 1);
553
+ m.assign(J(e, e.mul(.5), F(1).sub(e), 1));
554
+ }), W(s, Un(G(d), G(f)), m).toWriteOnly();
432
555
  });
433
556
  })().compute([
434
557
  this._dispatchX,
@@ -469,10 +592,10 @@ var $r = class extends E {
469
592
  reallocateReservedStorage() {
470
593
  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();
471
594
  let e = (e, t) => {
472
- let n = new j(A, A);
595
+ let n = new M(k, k);
473
596
  return n.type = e, n.format = Q, n.minFilter = t, n.magFilter = t, n;
474
597
  };
475
- this._temporalTexA = e(Cr, X), this._temporalTexB = e(Cr, X), this._outputModulatedTex = e(Cr, X), this._gradientStorageTex = e(wr, X), this._heatmapStorageTex = e(Cr, Z), this._buildGradientCompute(), this._buildTemporalCompute(), this._buildHeatmapCompute(), this._compiled = !1, this.currentMoments = 0, this._needsWarmReset = !0;
598
+ this._temporalTexA = e(sr, X), this._temporalTexB = e(sr, X), this._outputModulatedTex = e(sr, X), this._gradientStorageTex = e(cr, X), this._heatmapStorageTex = e(sr, Z), this._buildGradientCompute(), this._buildTemporalCompute(), this._buildHeatmapCompute(), this._compiled = !1, this.currentMoments = 0, this._needsWarmReset = !0;
476
599
  }
477
600
  setSize(e, t) {
478
601
  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 = [
@@ -500,7 +623,7 @@ var $r = class extends E {
500
623
  dispose() {
501
624
  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();
502
625
  }
503
- }, ii = 1e-6, ai = 1.5 / 255, oi = .01, si = 3, ci = 2, li = 2, ui = 3, di = 2, fi = 38, pi = .1, mi = 4, hi = Math.cos(89 * Math.PI / 180), gi = .5, _i = 16, vi = {
626
+ }, $r = 1e-6, ei = 1.5 / 255, ti = .01, ni = 3, ri = 2, ii = 2, ai = 3, oi = 2, si = 38, ci = .1, li = 4, ui = Math.cos(89 * Math.PI / 180), di = .5, fi = 16, pi = {
504
627
  pre: {
505
628
  radiusScale: 1,
506
629
  fractionScale: 2
@@ -513,7 +636,7 @@ var $r = class extends E {
513
636
  radiusScale: 2,
514
637
  fractionScale: .5
515
638
  }
516
- }, yi = .25 * Math.SQRT2, bi = [
639
+ }, mi = .25 * Math.SQRT2, hi = [
517
640
  [
518
641
  -1,
519
642
  0,
@@ -535,62 +658,62 @@ var $r = class extends E {
535
658
  1
536
659
  ],
537
660
  [
538
- -yi,
539
- yi,
661
+ -mi,
662
+ mi,
540
663
  .5
541
664
  ],
542
665
  [
543
- yi,
544
- yi,
666
+ mi,
667
+ mi,
545
668
  .5
546
669
  ],
547
670
  [
548
- yi,
549
- -yi,
671
+ mi,
672
+ -mi,
550
673
  .5
551
674
  ],
552
675
  [
553
- -yi,
554
- -yi,
676
+ -mi,
677
+ -mi,
555
678
  .5
556
679
  ]
557
- ], xi = (e, t, n) => rr(0, 1, P(1).sub(e.mul(t).add(n).abs())), Si = (e, t, n) => {
558
- let r = e.mul(t).add(n).abs().mul(-si);
559
- return P(1).div(r.mul(r).sub(r).add(1));
560
- }, Ci = (e) => z(P(1.570796), P(1.395402), B(e)).mul(ir(B(P(1).sub(e)))), wi = (e, t) => P(1).sub(Xn(e.mul(e).mul(-200))).mul(tr(B(e), t)), Ti = (e, t) => B(e).mul(ir(t.div(P(1).sub(t).add(ii)))), Ei = (e, t, n, r) => {
561
- let i = R(Un(Ti(n, r.mul(z(B(t), P(1), e)))), P(ai));
562
- return P(1).div(i);
563
- }, Di = (e, t) => {
564
- let n = P(1).div(z(P(oi), P(1), B(e.mul(t))));
565
- return K(n, e.mul(n).negate());
566
- }, Oi = (e, t, n) => {
567
- let r = P(1).div(z(P(n), P(1), z(e.mul(e), e, B(t))));
568
- return K(r, e.mul(r).negate());
569
- }, ki = (e, t) => {
570
- let n = P(1).div(t);
571
- return K(n, e.mul(n).negate());
572
- }, Ai = (e, t, n, r) => {
573
- let i = P(1).div(e.mul(t));
574
- return K(i, Jn(r, n).mul(i).negate());
575
- }, ji = (e) => K(1).sub(K(1).sub(Qn(e.mul(.5)).mul(2)).abs()).min(.99999), Mi = (e) => q(Jn(e, q(.25, .5, .25)), Jn(e, q(.5, 0, -.5)), Jn(e, q(-.25, .5, -.25))), Ni = (e) => {
680
+ ], gi = (e, t, n) => Bn(0, 1, F(1).sub(e.mul(t).add(n).abs())), _i = (e, t, n) => {
681
+ let r = e.mul(t).add(n).abs().mul(-ni);
682
+ return F(1).div(r.mul(r).sub(r).add(1));
683
+ }, vi = (e) => B(F(1.570796), F(1.395402), V(e)).mul(Vn(V(F(1).sub(e)))), yi = (e, t) => F(1).sub(Nn(e.mul(e).mul(-200))).mul(Rn(V(e), t)), bi = (e, t) => V(e).mul(Vn(t.div(F(1).sub(t).add($r)))), xi = (e, t, n, r) => {
684
+ let i = z(En(bi(n, r.mul(B(V(t), F(1), e)))), F(ei));
685
+ return F(1).div(i);
686
+ }, Si = (e, t) => {
687
+ let n = F(1).div(B(F(ti), F(1), V(e.mul(t))));
688
+ return Gn(n, e.mul(n).negate());
689
+ }, Ci = (e, t, n) => {
690
+ let r = F(1).div(B(F(n), F(1), B(e.mul(e), e, V(t))));
691
+ return Gn(r, e.mul(r).negate());
692
+ }, wi = (e, t) => {
693
+ let n = F(1).div(t);
694
+ return Gn(n, e.mul(n).negate());
695
+ }, Ti = (e, t, n, r) => {
696
+ let i = F(1).div(e.mul(t));
697
+ return Gn(i, jn(r, n).mul(i).negate());
698
+ }, Ei = (e) => Gn(1).sub(Gn(1).sub(Fn(e.mul(.5)).mul(2)).abs()).min(.99999), Di = (e) => q(jn(e, q(.25, .5, .25)), jn(e, q(.5, 0, -.5)), jn(e, q(-.25, .5, -.25))), Oi = (e) => {
576
699
  let t = e.x.sub(e.z);
577
- return R(q(t.add(e.y), e.x.add(e.z), t.sub(e.y)), q(0));
578
- }, Pi = (e, t) => t.add(ii).div(e.add(ii)), Fi = (e, t) => J(e.xyz.mul(Pi(e.x, t)), e.w), Ii = (e) => J(Mi(Ni(e.xyz)), B(e.w)), Li = (e, t) => ir(t.sub(e.mul(e)).abs()), Ri = (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))), zi = (e, t) => V(e.equal(0), J(0), t);
579
- function Bi(e) {
700
+ return z(q(t.add(e.y), e.x.add(e.z), t.sub(e.y)), q(0));
701
+ }, ki = (e, t) => t.add($r).div(e.add($r)), Ai = (e, t) => J(e.xyz.mul(ki(e.x, t)), e.w), ji = (e) => J(Di(Oi(e.xyz)), V(e.w)), Mi = (e, t) => Vn(t.sub(e.mul(e)).abs()), Ni = (e, t) => Gn(e.x.mul(t.x).add(e.y.mul(t.y)), e.z.mul(t.x).add(e.w.mul(t.y))), Pi = (e, t) => H(e.equal(0), J(0), t);
702
+ function Fi(e) {
580
703
  let t = Math.imul(e | 0, 2654435761) >>> 0;
581
704
  return t ^= t >>> 15, t = Math.imul(t, 2246822507) >>> 0, t ^= t >>> 13, t = Math.imul(t, 3266489909) >>> 0, t ^= t >>> 16, t / 4294967296;
582
705
  }
583
- var Vi = class extends E {
706
+ var Ii = class extends E {
584
707
  constructor(e, t = {}) {
585
708
  super("NRD", {
586
709
  ...t,
587
- executionMode: D.PER_CYCLE
710
+ executionMode: ge.PER_CYCLE
588
711
  }), this.renderer = e, this.pathTracer = t.pathTracer || null, this.settings = {
589
- ...ct,
712
+ ...Ur,
590
713
  ...t.settings || {}
591
- }, this._releaseHitDistance = this.pathTracer?.requestOutput?.("hitDistance", { encode: (e, t) => e.div(R(t.mul(.1).add(3), P(1e-4))).clamp(0, 1) }) ?? null;
714
+ }, this._releaseHitDistance = this.pathTracer?.requestOutput?.("hitDistance", { encode: (e, t) => e.div(z(t.mul(.1).add(3), F(1e-4))).clamp(0, 1) }) ?? null;
592
715
  let n = t.width || 1, r = t.height || 1;
593
- 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 Jr(1, 0, 0, 1), "vec4"), this.rotBlur = G(new Jr(1, 0, 0, 1), "vec4"), this.rotPost = G(new Jr(1, 0, 0, 1), "vec4"), this.camWorld = G(new kr(), "mat4"), this.camProjInv = G(new kr(), "mat4"), this.camView = G(new kr(), "mat4"), this.prevCamView = G(new kr(), "mat4"), this.camPos = G(new $(), "vec3"), this.prevCamPos = G(new $(), "vec3"), this.viewVector = G(new $(), "vec3"), this.prevViewVector = G(new $(), "vec3"), this.cameraRay = O(), this.u = {};
716
+ this.resW = K(n), this.resH = K(r), this.minRectDimMulUnproject = K(1), this.inputFrames = K(0), this.resetU = K(0), this.debugMode = K(0, "int"), this.rotPre = K(new Mr(1, 0, 0, 1), "vec4"), this.rotBlur = K(new Mr(1, 0, 0, 1), "vec4"), this.rotPost = K(new Mr(1, 0, 0, 1), "vec4"), this.camWorld = K(new pr(), "mat4"), this.camProjInv = K(new pr(), "mat4"), this.camView = K(new pr(), "mat4"), this.prevCamView = K(new pr(), "mat4"), this.camPos = K(new $(), "vec3"), this.prevCamPos = K(new $(), "vec3"), this.viewVector = K(new $(), "vec3"), this.prevViewVector = K(new $(), "vec3"), this.cameraRay = A(), this.u = {};
594
717
  for (let e of [
595
718
  "maxAccum",
596
719
  "maxFast",
@@ -610,25 +733,25 @@ var Vi = class extends E {
610
733
  "disocclusionThreshold",
611
734
  "lobeVolumePercent",
612
735
  "handoverFrames"
613
- ]) this.u[e] = G(0);
614
- this.u.antilag = G(new qr(), "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();
736
+ ]) this.u[e] = K(0);
737
+ this.u.antilag = K(new jr(), "vec2"), this.u.convergence = K(new $(), "vec3"), this._syncUniforms(), this._colorTexNode = new N(), this._albedoTexNode = new N(), this._ndTexNode = new N(), this._snTexNode = new N(), this._motionTexNode = new N(), this._placeholders = /* @__PURE__ */ new Map();
615
738
  let i = () => {
616
- let e = new xr(new Float32Array(4), 1, 1, Q, Cr);
739
+ let e = new ar(new Float32Array(4), 1, 1, Q, sr);
617
740
  e.needsUpdate = !0;
618
- let t = new M(e);
741
+ let t = new N(e);
619
742
  return this._placeholders.set(t, e), t;
620
743
  };
621
- 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 mr(new qr(0, 0), new qr(0, 0)), this.outputTarget = new Ln(n, r, {
622
- type: wr,
744
+ 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 Qn(new jr(0, 0), new jr(0, 0)), this.outputTarget = new bn(n, r, {
745
+ type: cr,
623
746
  format: Q,
624
747
  minFilter: X,
625
748
  magFilter: X,
626
749
  depthBuffer: !1,
627
750
  stencilBuffer: !1
628
- }), this._compiled = !1, this._needsReset = !0, this._stabPing = 0, this._camInitialized = !1, this._dispatchX = Math.ceil(n / _i), this._dispatchY = Math.ceil(r / _i), this._buildKernels();
751
+ }), this._compiled = !1, this._needsReset = !0, this._stabPing = 0, this._camInitialized = !1, this._dispatchX = Math.ceil(n / fi), this._dispatchY = Math.ceil(r / fi), this._buildKernels();
629
752
  }
630
753
  _allocStorage() {
631
- let e = () => ve(wr);
754
+ let e = () => pe(cr);
632
755
  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();
633
756
  }
634
757
  _disposeStorage() {
@@ -649,7 +772,7 @@ var Vi = class extends E {
649
772
  }
650
773
  updateParameters(e) {
651
774
  if (e) {
652
- for (let t of Object.keys(e)) t === "debugMode" ? this.debugMode.value = e.debugMode | 0 : t in ct && (this.settings[t] = e[t]);
775
+ for (let t of Object.keys(e)) t === "debugMode" ? this.debugMode.value = e.debugMode | 0 : t in Ur && (this.settings[t] = e[t]);
653
776
  this._syncUniforms();
654
777
  }
655
778
  }
@@ -660,32 +783,32 @@ var Vi = class extends E {
660
783
  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;
661
784
  }
662
785
  _worldPosAt(e, t, n, r) {
663
- return fe(e, t, n, r, this.cameraRay);
786
+ return ve(e, t, n, r, this.cameraRay);
664
787
  }
665
788
  _viewVector(e, t, n) {
666
- return V(ne(this.cameraRay.cameraProjection), n, er(t.sub(e)));
789
+ return H(ne(this.cameraRay.cameraProjection), n, Ln(t.sub(e)));
667
790
  }
668
791
  _frustumSize(e) {
669
- return this.minRectDimMulUnproject.mul(V(ne(this.cameraRay.cameraProjection), P(1), e));
792
+ return this.minRectDimMulUnproject.mul(H(ne(this.cameraRay.cameraProjection), F(1), e));
670
793
  }
671
794
  _pixelUv(e, t) {
672
- return K(P(e).add(.5).div(this.resW), P(t).add(.5).div(this.resH));
795
+ return Gn(F(e).add(.5).div(this.resW), F(t).add(.5).div(this.resH));
673
796
  }
674
797
  _clampCoord(e, t) {
675
- return I(e.clamp(F(0), F(this.resW).sub(1)), t.clamp(F(0), F(this.resH).sub(1)));
798
+ return L(e.clamp(I(0), I(this.resW).sub(1)), t.clamp(I(0), I(this.resH).sub(1)));
676
799
  }
677
800
  _uvToCoord(e) {
678
- return this._clampCoord(F(e.x.mul(this.resW)), F(e.y.mul(this.resH)));
801
+ return this._clampCoord(I(e.x.mul(this.resW)), I(e.y.mul(this.resH)));
679
802
  }
680
803
  _advancedNonLinear(e) {
681
- 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));
682
- return P(1).div(P(1).add(r.mul(e)));
804
+ let t = this.u.convergence, n = V(e.div(F(1).add(this.u.maxAccum.mul(t.z)))), r = t.x.mul(B(t.y, F(1), n));
805
+ return F(1).div(F(1).add(r.mul(e)));
683
806
  }
684
807
  _handover(e) {
685
- return B(e.div(R(this.u.handoverFrames, 1)));
808
+ return V(e.div(z(this.u.handoverFrames, 1)));
686
809
  }
687
810
  _bilinear(e) {
688
- 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));
811
+ let t = e.mul(Gn(this.resW, this.resH)).sub(.5), n = Pn(t), r = V(t.sub(n)), i = I(n.x), a = I(n.y), o = (e, t) => H(e.greaterThanEqual(I(0)).and(t.greaterThanEqual(I(0))).and(e.lessThan(I(this.resW))).and(t.lessThan(I(this.resH))), F(1), F(0));
689
812
  return {
690
813
  f: r,
691
814
  taps: [
@@ -701,22 +824,22 @@ var Vi = class extends E {
701
824
  o(i.add(1), a.add(1))
702
825
  ],
703
826
  customWeights: (e) => [
704
- e[0].mul(P(1).sub(r.x)).mul(P(1).sub(r.y)),
705
- e[1].mul(r.x).mul(P(1).sub(r.y)),
706
- e[2].mul(P(1).sub(r.x)).mul(r.y),
827
+ e[0].mul(F(1).sub(r.x)).mul(F(1).sub(r.y)),
828
+ e[1].mul(r.x).mul(F(1).sub(r.y)),
829
+ e[2].mul(F(1).sub(r.x)).mul(r.y),
707
830
  e[3].mul(r.x).mul(r.y)
708
831
  ],
709
- filter: (e) => z(z(e[0], e[1], r.x), z(e[2], e[3], r.x), r.y)
832
+ filter: (e) => B(B(e[0], e[1], r.x), B(e[2], e[3], r.x), r.y)
710
833
  };
711
834
  }
712
835
  _applyCustomWeights(e, t, n) {
713
836
  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]);
714
- return V(i.lessThan(1e-4), n, r.div(R(i, 1e-4)));
837
+ return H(i.lessThan(1e-4), n, r.div(z(i, 1e-4)));
715
838
  }
716
839
  _sampleHistory(e, t, n, r, i) {
717
840
  let a = J(0).toVar();
718
- return N(i, () => {
719
- let n = B(t).mul(K(this.resW, this.resH)), r = Zn(n.sub(.5)).add(.5), i = B(n.sub(r)), o = gi, 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 = [
841
+ return P(i, () => {
842
+ let n = V(t).mul(Gn(this.resW, this.resH)), r = Pn(n.sub(.5)).add(.5), i = V(n.sub(r)), o = di, 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 = [
720
843
  s.x,
721
844
  c.x,
722
845
  l.x,
@@ -726,13 +849,13 @@ var Vi = class extends E {
726
849
  c.y,
727
850
  l.y,
728
851
  u.y
729
- ], p = F(r.x).sub(1), m = F(r.y).sub(1), h = J(0).toVar(), g = P(0).toVar();
852
+ ], p = I(r.x).sub(1), m = I(r.y).sub(1), h = J(0).toVar(), g = F(0).toVar();
730
853
  for (let t = 0; t < 4; t++) for (let n = 0; n < 4; n++) {
731
854
  if ((n === 0 || n === 3) && (t === 0 || t === 3)) continue;
732
855
  let r = d[n].mul(f[t]);
733
856
  h.addAssign(e(this._clampCoord(p.add(n), m.add(t))).mul(r)), g.addAssign(r);
734
857
  }
735
- a.assign(V(g.lessThan(1e-4), J(0), h.div(R(g, 1e-4))));
858
+ a.assign(H(g.lessThan(1e-4), J(0), h.div(z(g, 1e-4))));
736
859
  }).Else(() => {
737
860
  a.assign(this._applyCustomWeights(n.taps.map((t) => e(t)), r, J(0)));
738
861
  }), a;
@@ -754,176 +877,176 @@ var Vi = class extends E {
754
877
  this._dispatchY,
755
878
  1
756
879
  ], [
757
- _i,
758
- _i,
880
+ fi,
881
+ fi,
759
882
  1
760
883
  ]);
761
884
  }
762
885
  _buildSpatial(e) {
763
- let t = e === "pre", { radiusScale: r, fractionScale: a } = vi[e], o = this.u, c = 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) => {
764
- let t = H(c, e), r = H(l, e);
765
- return J(Mi(n(t.xyz.div(R(r.xyz, q(et))))), i(r.w, s).min(1));
766
- } : (e) => H(p, e), C = zn(([n, i]) => {
767
- let s = F(Y.x).mul(_i).add(F(L.x)), c = F(Y.y).mul(_i).add(F(L.y));
768
- N(s.lessThan(F(b)).and(c.lessThan(F(x))), () => {
769
- let l = I(s, c), p = or(W(s), W(c)), C = H(u, l).w.toVar(), te = C.greaterThanEqual($e), w = H(d, l).toVar(), ne = er(w.xyz.mul(2).sub(1)).toVar(), re = w.w.clamp(.05, 1).toVar(), T = P($e).toVar(), ie = ee(l).toVar();
770
- N(te.not(), () => {
886
+ let t = e === "pre", { radiusScale: r, fractionScale: a } = pi[e], o = this.u, c = 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) => {
887
+ let t = U(c, e), r = U(l, e);
888
+ return J(Di(n(t.xyz.div(z(r.xyz, q(zr))))), i(r.w, s).min(1));
889
+ } : (e) => U(p, e), C = Sn(([n, i]) => {
890
+ let s = I(Y.x).mul(fi).add(I(R.x)), c = I(Y.y).mul(fi).add(I(R.y));
891
+ P(s.lessThan(I(b)).and(c.lessThan(I(x))), () => {
892
+ let l = L(s, c), p = Un(G(s), G(c)), C = U(u, l).w.toVar(), te = C.greaterThanEqual(Rr), w = U(d, l).toVar(), ne = Ln(w.xyz.mul(2).sub(1)).toVar(), re = w.w.clamp(.05, 1).toVar(), T = F(Rr).toVar(), E = ee(l).toVar();
893
+ P(te.not(), () => {
771
894
  let e = this._pixelUv(s, c), p = this._worldPosAt(e, C, n, i).toVar();
772
- T.assign(v.mul(J(p, 1)).z.abs()), N(_.greaterThan(0), () => {
773
- let s = Jn(ne, this._viewVector(p, y, this.viewVector)).abs().toVar(), c = this._frustumSize(T).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(), te = wi(re, .5).toVar(), w = T.mul(Ne).add(3), ae = ie.w.toVar(), oe = B(ae.mul(w).div(c)), E = P(1).sub(this._handover(m)), se = (t ? oe.div(m) : oe.mul(C)).mul(E), D = o.minBlurRadius.mul(B(P(2).sub(h.div(R(o.maxAccum, 1))))), ce = R(B(ir(B(se)).mul(r)).mul(_).mul(te), D.mul(te)).toVar(), O = Ai(o.planeDistSensitivity, c, p, ne).toVar(), le = Ei(C, o.lobeAngleFraction, re, o.lobeVolumePercent).div(a).toVar(), ue = Di(re, o.roughnessFraction.mul(a)).toVar(), de = ki(ae, C).toVar(), fe = o.minHitDistanceWeight.mul(a).mul(te);
774
- t || (fe = fe.mul(C)), fe = fe.toVar();
775
- let pe = K(1);
895
+ T.assign(v.mul(J(p, 1)).z.abs()), P(_.greaterThan(0), () => {
896
+ let s = jn(ne, this._viewVector(p, y, this.viewVector)).abs().toVar(), c = this._frustumSize(T).toVar(), m = S.add(1), h = t ? z(S, F(10)) : U(f, l).y.add(S), C = (t ? F(1).div(h.add(1)) : this._advancedNonLinear(h)).toVar(), te = yi(re, .5).toVar(), w = T.mul(Hr).add(3), ie = E.w.toVar(), ae = V(ie.mul(w).div(c)), oe = F(1).sub(this._handover(m)), se = (t ? ae.div(m) : ae.mul(C)).mul(oe), D = o.minBlurRadius.mul(V(F(2).sub(h.div(z(o.maxAccum, 1))))), ce = z(V(Vn(V(se)).mul(r)).mul(_).mul(te), D.mul(te)).toVar(), O = Ti(o.planeDistSensitivity, c, p, ne).toVar(), k = xi(C, o.lobeAngleFraction, re, o.lobeVolumePercent).div(a).toVar(), le = Si(re, o.roughnessFraction.mul(a)).toVar(), ue = wi(ie, C).toVar(), de = o.minHitDistanceWeight.mul(a).mul(te);
897
+ t || (de = de.mul(C)), de = de.toVar();
898
+ let A = Gn(1);
776
899
  if (!t) {
777
900
  let e = v.mul(J(ne, 0)).xy;
778
- pe = z(K(1).sub(e.abs()), K(1), s), pe = pe.div(R(pe.x, pe.y));
901
+ A = B(Gn(1).sub(e.abs()), Gn(1), s), A = A.div(z(A.x, A.y));
779
902
  }
780
- let me = pe.mul(K(P(1).div(b), P(1).div(x))).mul(ce).toVar(), he = P(1).toVar();
781
- for (let t = 0; t < bi.length; t++) {
782
- let r = bi[t], a = e.add(Ri(g, K(r[0], r[1])).mul(me)), o = ji(a), s = V(o.x.notEqual(a.x).or(o.y.notEqual(a.y)), P(1), P(Math.exp(-.66 * r[2] * r[2]))).toVar(), c = this._uvToCoord(o), l = H(u, c).w, f = this._worldPosAt(o, l, n, i), p = H(d, c), m = Ci(Jn(ne, er(p.xyz.mul(2).sub(1))));
783
- s.mulAssign(xi(m, le, P(0))), s.mulAssign(xi(p.w, ue.x, ue.y)), s.mulAssign(xi(Jn(ne, f), O.x, O.y)), s.assign(V(l.greaterThanEqual($e), P(0), s));
784
- let h = zi(s, ee(c));
785
- s.mulAssign(fe.add(Si(h.w, de.x, de.y))), he.addAssign(s), ie.addAssign(h.mul(s));
903
+ let fe = A.mul(Gn(F(1).div(b), F(1).div(x))).mul(ce).toVar(), pe = F(1).toVar();
904
+ for (let t = 0; t < hi.length; t++) {
905
+ let r = hi[t], a = e.add(Ni(g, Gn(r[0], r[1])).mul(fe)), o = Ei(a), s = H(o.x.notEqual(a.x).or(o.y.notEqual(a.y)), F(1), F(Math.exp(-.66 * r[2] * r[2]))).toVar(), c = this._uvToCoord(o), l = U(u, c).w, f = this._worldPosAt(o, l, n, i), p = U(d, c), m = vi(jn(ne, Ln(p.xyz.mul(2).sub(1))));
906
+ s.mulAssign(gi(m, k, F(0))), s.mulAssign(gi(p.w, le.x, le.y)), s.mulAssign(gi(jn(ne, f), O.x, O.y)), s.assign(H(l.greaterThanEqual(Rr), F(0), s));
907
+ let h = Pi(s, ee(c));
908
+ s.mulAssign(de.add(_i(h.w, ue.x, ue.y))), pe.addAssign(s), E.addAssign(h.mul(s));
786
909
  }
787
- ie.divAssign(R(he, 1e-6)), t || ie.assign(J(ie.xyz, ae));
910
+ E.divAssign(z(pe, 1e-6)), t || E.assign(J(E.xyz, ie));
788
911
  });
789
- }), U(m, p, ie).toWriteOnly(), e === "post" && U(h, p, J(ne, T)).toWriteOnly();
912
+ }), W(m, p, E).toWriteOnly(), e === "post" && W(h, p, J(ne, T)).toWriteOnly();
790
913
  });
791
914
  });
792
915
  return this._dispatchOf(C);
793
916
  }
794
917
  _buildTemporalAccumulation() {
795
- 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 = zn(([y, b]) => {
796
- let x = F(Y.x).mul(_i).add(F(L.x)), S = F(Y.y).mul(_i).add(F(L.y));
797
- N(x.lessThan(F(h)).and(S.lessThan(F(g))), () => {
798
- let h = I(x, S), g = or(W(x), W(S)), ee = H(t, h).w, C = H(i, h).toVar();
799
- N(ee.greaterThanEqual($e), () => {
800
- U(l, g, C).toWriteOnly(), U(u, g, J(0)).toWriteOnly(), Vn();
918
+ 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 = Sn(([y, b]) => {
919
+ let x = I(Y.x).mul(fi).add(I(R.x)), S = I(Y.y).mul(fi).add(I(R.y));
920
+ P(x.lessThan(I(h)).and(S.lessThan(I(g))), () => {
921
+ let h = L(x, S), g = Un(G(x), G(S)), ee = U(t, h).w, C = U(i, h).toVar();
922
+ P(ee.greaterThanEqual(Rr), () => {
923
+ W(l, g, C).toWriteOnly(), W(u, g, J(0)).toWriteOnly(), wn();
801
924
  });
802
- let te = e.maxAccum.mul(P(1).sub(v)).toVar(), w = e.maxFast.mul(P(1).sub(v)).toVar(), ne = H(n, h), re = er(ne.xyz.mul(2).sub(1)).toVar(), T = ne.w.clamp(.05, 1).toVar(), ie = this._pixelUv(x, S), ae = this._worldPosAt(ie, ee, y, b).toVar(), oe = d.mul(J(ae, 1)).z.abs().toVar(), E = Jn(re, this._viewVector(ae, p, this.viewVector)).abs().toVar(), se = this._frustumSize(oe).toVar(), D = q(0).toVar();
925
+ let te = e.maxAccum.mul(F(1).sub(v)).toVar(), w = e.maxFast.mul(F(1).sub(v)).toVar(), ne = U(n, h), re = Ln(ne.xyz.mul(2).sub(1)).toVar(), T = ne.w.clamp(.05, 1).toVar(), E = this._pixelUv(x, S), ie = this._worldPosAt(E, ee, y, b).toVar(), ae = d.mul(J(ie, 1)).z.abs().toVar(), oe = jn(re, this._viewVector(ie, p, this.viewVector)).abs().toVar(), se = this._frustumSize(ae).toVar(), D = q(0).toVar();
803
926
  D.addAssign(re.mul(.25));
804
927
  for (let e = -1; e <= 0; e++) for (let r = -1; r <= 0; r++) {
805
928
  if (r === 0 && e === 0) continue;
806
- let i = this._clampCoord(x.add(r), S.add(e)), a = er(H(n, i).xyz.mul(2).sub(1)), o = H(t, i).w.lessThan($e);
807
- D.addAssign(V(o, a, re).mul(.25));
929
+ let i = this._clampCoord(x.add(r), S.add(e)), a = Ln(U(n, i).xyz.mul(2).sub(1)), o = U(t, i).w.lessThan(Rr);
930
+ D.addAssign(H(o, a, re).mul(.25));
808
931
  }
809
- let ce = H(r, h), O = ie.sub(ce.xy).toVar(), le = f.mul(J(ae, 1)).z.abs().toVar(), ue = this._bilinear(O), de = se.mul(B(e.disocclusionThreshold.div(R(E, .05)))).sub(ii).toVar(), fe = P(1).sub(v), pe = [], me = [];
932
+ let ce = U(r, h), O = E.sub(ce.xy).toVar(), k = f.mul(J(ie, 1)).z.abs().toVar(), le = this._bilinear(O), ue = se.mul(V(e.disocclusionThreshold.div(z(oe, .05)))).sub($r).toVar(), de = F(1).sub(v), A = [], fe = [];
810
933
  for (let e = 0; e < 4; e++) {
811
- let t = H(c, ue.taps[e]), n = V(Jn(t.xyz, D).greaterThan(hi), P(1), P(0)), r = V(t.w.sub(le).abs().lessThanEqual(de), P(1), P(0)), i = V(t.w.lessThan($e), P(1), P(0));
812
- pe.push(n.mul(r).mul(i).mul(ue.inScreen[e]).mul(fe).toVar()), me.push(H(s, ue.taps[e]).x);
934
+ let t = U(c, le.taps[e]), n = H(jn(t.xyz, D).greaterThan(ui), F(1), F(0)), r = H(t.w.sub(k).abs().lessThanEqual(ue), F(1), F(0)), i = H(t.w.lessThan(Rr), F(1), F(0));
935
+ A.push(n.mul(r).mul(i).mul(le.inScreen[e]).mul(de).toVar()), fe.push(U(s, le.taps[e]).x);
813
936
  }
814
- let he = ue.customWeights(pe).map((e) => e.toVar()), ge = pe[0].add(pe[1]).add(pe[2]).add(pe[3]).greaterThan(3.5).toVar(), _e = pe[0].add(pe[1].mul(2)).add(pe[2].mul(4)).add(pe[3].mul(8)), ve = this._applyCustomWeights(me, he, P(0)).toVar(), ye = Jn(re, this._viewVector(ae, m, this.prevViewVector)).abs().add(.001).div(E.add(.001)).toVar();
815
- ye.assign(z(P(.1), P(1), B(ye.mul(ye))));
816
- let be = ir(B(ue.filter(pe))).mul(ye).toVar();
817
- ve.assign(ve.mul(z(be, P(1), P(1).div(ve.add(1))))), ve.assign($n(ve, te));
818
- let xe = Ii(this._sampleHistory((e) => H(a, e), O, ue, he, ge)).toVar(), Se = R(this._applyCustomWeights(ue.taps.map((e) => H(o, e).x), he, P(0)), 0).toVar(), Ce = _.add(1), we = this._handover(Ce).toVar(), Te = ve.mul(P(1).sub(we)), Ee = Ce.div(Ce.add(Te)).toVar(), De = P(1).div(P(1).add(wi(T, .25).mul(.5).mul(te))), Oe = J(z(xe.xyz, C.xyz, Ee), z(xe.w, C.w, R(Ee, De))).toVar(), k = e.fireflyMinRelativeScale.add(P(fi).div(ve.add(1))).toVar(), ke = ve.mul(e.maxBlurRadius).mul(pi).toVar();
819
- ke.assign(ke.div(ke.add(1)).mul(P(1).sub(we)));
820
- let Ae = z(Oe.x, $n(Oe.x, xe.x.mul(k)), ke);
821
- Oe.assign(Fi(Oe, Ae));
822
- let je = P(1.2).add(P(1).div(ve.add(1)));
823
- Oe.assign(J(Oe.xyz, z(Oe.w, $n(Oe.w, xe.w.mul(je)), ke))), U(l, g, Oe).toWriteOnly();
824
- let Me = $n(ve, w).mul(P(1).sub(we)), Ne = Ce.div(Ce.add(Me)), Pe = z(Se, C.x, Ne).toVar(), Fe = $n(Pe, xe.x.mul(k).mul(mi));
825
- Pe.assign(z(Pe, Fe, ke)), U(u, g, J(Pe, ve, _e, V(ge, P(1), P(0)))).toWriteOnly();
937
+ let pe = le.customWeights(A).map((e) => e.toVar()), me = A[0].add(A[1]).add(A[2]).add(A[3]).greaterThan(3.5).toVar(), he = A[0].add(A[1].mul(2)).add(A[2].mul(4)).add(A[3].mul(8)), ge = this._applyCustomWeights(fe, pe, F(0)).toVar(), _e = jn(re, this._viewVector(ie, m, this.prevViewVector)).abs().add(.001).div(oe.add(.001)).toVar();
938
+ _e.assign(B(F(.1), F(1), V(_e.mul(_e))));
939
+ let ve = Vn(V(le.filter(A))).mul(_e).toVar();
940
+ ge.assign(ge.mul(B(ve, F(1), F(1).div(ge.add(1))))), ge.assign(In(ge, te));
941
+ let ye = ji(this._sampleHistory((e) => U(a, e), O, le, pe, me)).toVar(), be = z(this._applyCustomWeights(le.taps.map((e) => U(o, e).x), pe, F(0)), 0).toVar(), xe = _.add(1), Se = this._handover(xe).toVar(), Ce = ge.mul(F(1).sub(Se)), we = xe.div(xe.add(Ce)).toVar(), Te = F(1).div(F(1).add(yi(T, .25).mul(.5).mul(te))), Ee = J(B(ye.xyz, C.xyz, we), B(ye.w, C.w, z(we, Te))).toVar(), De = e.fireflyMinRelativeScale.add(F(si).div(ge.add(1))).toVar(), Oe = ge.mul(e.maxBlurRadius).mul(ci).toVar();
942
+ Oe.assign(Oe.div(Oe.add(1)).mul(F(1).sub(Se)));
943
+ let ke = B(Ee.x, In(Ee.x, ye.x.mul(De)), Oe);
944
+ Ee.assign(Ai(Ee, ke));
945
+ let Ae = F(1.2).add(F(1).div(ge.add(1)));
946
+ Ee.assign(J(Ee.xyz, B(Ee.w, In(Ee.w, ye.w.mul(Ae)), Oe))), W(l, g, Ee).toWriteOnly();
947
+ let je = In(ge, w).mul(F(1).sub(Se)), Me = xe.div(xe.add(je)), Ne = B(be, C.x, Me).toVar(), Pe = In(Ne, ye.x.mul(De).mul(li));
948
+ Ne.assign(B(Ne, Pe, Oe)), W(u, g, J(Ne, ge, he, H(me, F(1), F(0)))).toWriteOnly();
826
949
  });
827
950
  });
828
951
  return this._dispatchOf(y);
829
952
  }
830
953
  _buildHistoryFix() {
831
- 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 = zn(([d, f]) => {
832
- let p = F(Y.x).mul(_i).add(F(L.x)), m = F(Y.y).mul(_i).add(F(L.y));
833
- N(p.lessThan(F(c)).and(m.lessThan(F(l))), () => {
834
- let h = I(p, m), g = or(W(p), W(m)), _ = H(t, h).w;
835
- N(_.greaterThanEqual($e), () => {
836
- let e = H(r, h);
837
- U(a, g, e).toWriteOnly(), U(o, g, J(e.x, 0, 0, 0)).toWriteOnly(), Vn();
954
+ 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 = Sn(([d, f]) => {
955
+ let p = I(Y.x).mul(fi).add(I(R.x)), m = I(Y.y).mul(fi).add(I(R.y));
956
+ P(p.lessThan(I(c)).and(m.lessThan(I(l))), () => {
957
+ let h = L(p, m), g = Un(G(p), G(m)), _ = U(t, h).w;
958
+ P(_.greaterThanEqual(Rr), () => {
959
+ let e = U(r, h);
960
+ W(a, g, e).toWriteOnly(), W(o, g, J(e.x, 0, 0, 0)).toWriteOnly(), wn();
838
961
  });
839
- 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 = er(S.xyz.mul(2).sub(1)).toVar(), C = S.w.clamp(.05, 1).toVar(), te = this._pixelUv(p, m), w = this._worldPosAt(te, _, d, f).toVar(), ne = s.mul(J(w, 1)).z.abs(), re = this._frustumSize(ne).toVar(), T = H(r, h).toVar(), ie = P(1).div(b.add(1)).toVar(), ae = ne.mul(Ne).add(3), oe = B(T.w.mul(ae).div(re)), E = T.w.toVar(), se = nr(V(b.lessThan(e.historyFixFrameNum), P(1), P(0)).mul(.5).mul(2 / ci).mul(e.historyFixStride).mul(z(P(.25).add(ir(oe).mul(.75)), P(1), ie))).toVar();
840
- N(se.notEqual(0), () => {
841
- let a = Ei(ie, e.lobeAngleFraction, C, e.lobeVolumePercent).toVar(), o = Ai(e.planeDistSensitivity, re, w, ee).toVar(), s = ki(E, ie).toVar(), u = Oi(C.mul(C), ir(e.roughnessFraction), oi).toVar(), p = P(1).add(y).toVar();
962
+ let v = U(i, h).toVar(), y = v.y.toVar(), b = y.add(u), x = this._handover(u.add(1)).toVar(), S = U(n, h), ee = Ln(S.xyz.mul(2).sub(1)).toVar(), C = S.w.clamp(.05, 1).toVar(), te = this._pixelUv(p, m), w = this._worldPosAt(te, _, d, f).toVar(), ne = s.mul(J(w, 1)).z.abs(), re = this._frustumSize(ne).toVar(), T = U(r, h).toVar(), E = F(1).div(b.add(1)).toVar(), ie = ne.mul(Hr).add(3), ae = V(T.w.mul(ie).div(re)), oe = T.w.toVar(), se = zn(H(b.lessThan(e.historyFixFrameNum), F(1), F(0)).mul(.5).mul(2 / ri).mul(e.historyFixStride).mul(B(F(.25).add(Vn(ae).mul(.75)), F(1), E))).toVar();
963
+ P(se.notEqual(0), () => {
964
+ let a = xi(E, e.lobeAngleFraction, C, e.lobeVolumePercent).toVar(), o = Ti(e.planeDistSensitivity, re, w, ee).toVar(), s = wi(oe, E).toVar(), u = Ci(C.mul(C), Vn(e.roughnessFraction), ti).toVar(), p = F(1).add(y).toVar();
842
965
  T.mulAssign(p);
843
- for (let e = -ci; e <= ci; e++) for (let m = -ci; m <= ci; m++) {
844
- if (m === 0 && e === 0 || Math.abs(m) + Math.abs(e) === ci * 2) continue;
845
- let h = ji(te.add(K(m, e).mul(se).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 = Si(Ci(Jn(er(y.xyz.mul(2).sub(1)), ee)), a, P(0)).toVar();
846
- b.mulAssign(Si(y.w.mul(y.w), u.x, u.y)), b.mulAssign(P(1).add(H(i, g).y)), b.mulAssign(xi(Jn(ee, v), o.x, o.y)), b.assign(V(_.greaterThanEqual($e), P(0), b));
847
- let x = zi(b, H(r, g));
848
- b.mulAssign(Si(x.w, s.x, s.y)), p.addAssign(b), T.addAssign(x.mul(b));
966
+ for (let e = -ri; e <= ri; e++) for (let m = -ri; m <= ri; m++) {
967
+ if (m === 0 && e === 0 || Math.abs(m) + Math.abs(e) === ri * 2) continue;
968
+ let h = Ei(te.add(Gn(m, e).mul(se).mul(Gn(F(1).div(c), F(1).div(l))))), g = this._uvToCoord(h), _ = U(t, g).w, v = this._worldPosAt(h, _, d, f), y = U(n, g), b = _i(vi(jn(Ln(y.xyz.mul(2).sub(1)), ee)), a, F(0)).toVar();
969
+ b.mulAssign(_i(y.w.mul(y.w), u.x, u.y)), b.mulAssign(F(1).add(U(i, g).y)), b.mulAssign(gi(jn(ee, v), o.x, o.y)), b.assign(H(_.greaterThanEqual(Rr), F(0), b));
970
+ let x = Pi(b, U(r, g));
971
+ b.mulAssign(_i(x.w, s.x, s.y)), p.addAssign(b), T.addAssign(x.mul(b));
849
972
  }
850
- T.divAssign(R(p, 1e-6));
973
+ T.divAssign(z(p, 1e-6));
851
974
  });
852
- let D = T.x.toVar(), ce = B(y.div(R(e.historyFixFrameNum, ii))), O = z(D, v.x, ce).toVar();
853
- U(o, g, J(O, 0, 0, 0)).toWriteOnly();
854
- let le = O.toVar(), ue = O.mul(O).toVar(), de = P(0).toVar(), fe = P(0).toVar(), pe = (e, n, r) => {
855
- let a = this._clampCoord(p.add(e), m.add(n)), o = H(t, a).w, s = V(o.greaterThanEqual($e), O, H(i, a).x);
856
- Math.abs(e) <= li && Math.abs(n) <= li && (le.addAssign(s), ue.addAssign(s.mul(s))), r && (de.addAssign(s), fe.addAssign(s.mul(s)));
857
- }, me = e.antiFirefly.greaterThan(.5);
858
- for (let e = -li; e <= li; e++) for (let t = -li; t <= li; t++) t === 0 && e === 0 || pe(t, e, Math.abs(t) > 1 || Math.abs(e) > 1);
859
- N(me, () => {
860
- for (let e = -ui; e <= ui; e++) for (let t = -ui; t <= ui; t++) Math.abs(t) <= li && Math.abs(e) <= li || pe(t, e, !0);
861
- }), N(me, () => {
862
- let e = 1 / ((ui * 2 + 1) ** 2 - 9), t = de.mul(e), n = Li(t, fe.mul(e)).mul(di);
863
- D.assign(z(D.clamp(t.sub(n), t.add(n)), D, x));
975
+ let D = T.x.toVar(), ce = V(y.div(z(e.historyFixFrameNum, $r))), O = B(D, v.x, ce).toVar();
976
+ W(o, g, J(O, 0, 0, 0)).toWriteOnly();
977
+ let k = O.toVar(), le = O.mul(O).toVar(), ue = F(0).toVar(), de = F(0).toVar(), A = (e, n, r) => {
978
+ let a = this._clampCoord(p.add(e), m.add(n)), o = U(t, a).w, s = H(o.greaterThanEqual(Rr), O, U(i, a).x);
979
+ Math.abs(e) <= ii && Math.abs(n) <= ii && (k.addAssign(s), le.addAssign(s.mul(s))), r && (ue.addAssign(s), de.addAssign(s.mul(s)));
980
+ }, fe = e.antiFirefly.greaterThan(.5);
981
+ for (let e = -ii; e <= ii; e++) for (let t = -ii; t <= ii; t++) t === 0 && e === 0 || A(t, e, Math.abs(t) > 1 || Math.abs(e) > 1);
982
+ P(fe, () => {
983
+ for (let e = -ai; e <= ai; e++) for (let t = -ai; t <= ai; t++) Math.abs(t) <= ii && Math.abs(e) <= ii || A(t, e, !0);
984
+ }), P(fe, () => {
985
+ let e = 1 / ((ai * 2 + 1) ** 2 - 9), t = ue.mul(e), n = Mi(t, de.mul(e)).mul(oi);
986
+ D.assign(B(D.clamp(t.sub(n), t.add(n)), D, x));
864
987
  });
865
988
  {
866
- let t = 1 / (li * 2 + 1) ** 2, n = le.mul(t), r = Li(n, ue.mul(t)).mul(e.fastClampSigmaScale), i = D.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);
867
- D.assign(z(i, D, o));
989
+ let t = 1 / (ii * 2 + 1) ** 2, n = k.mul(t), r = Mi(n, le.mul(t)).mul(e.fastClampSigmaScale), i = D.clamp(n.sub(r), n.add(r)), a = H(e.maxFast.lessThan(e.maxAccum), F(1), F(0)), o = B(F(1).div(F(1).add(a.mul(y).mul(2))), F(1), x);
990
+ D.assign(B(i, D, o));
868
991
  }
869
- U(a, g, Fi(T, D)).toWriteOnly();
992
+ W(a, g, Ai(T, D)).toWriteOnly();
870
993
  });
871
994
  });
872
995
  return this._dispatchOf(d);
873
996
  }
874
997
  _buildTemporalStabilization(e) {
875
998
  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;
876
- return zn(() => {
877
- let _ = F(Y.x).mul(_i).add(F(L.x)), v = F(Y.y).mul(_i).add(F(L.y));
878
- N(_.lessThan(F(f)).and(v.lessThan(F(p))), () => {
879
- let f = I(_, v), p = or(W(_), W(v)), y = H(i, f).w, b = H(n, f).toVar();
880
- N(y.greaterThanEqual($e), () => {
881
- 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(), Vn();
999
+ return Sn(() => {
1000
+ let _ = I(Y.x).mul(fi).add(I(R.x)), v = I(Y.y).mul(fi).add(I(R.y));
1001
+ P(_.lessThan(I(f)).and(v.lessThan(I(p))), () => {
1002
+ let f = L(_, v), p = Un(G(_), G(v)), y = U(i, f).w, b = U(n, f).toVar();
1003
+ P(y.greaterThanEqual(Rr), () => {
1004
+ W(d, p, b).toWriteOnly(), W(e, p, J(U(s, f).x, 0, 0, 0)).toWriteOnly(), W(u, p, J(0, 1, 0, 0)).toWriteOnly(), wn();
882
1005
  });
883
- let x = H(a, f).w.clamp(.05, 1), S = this._pixelUv(_, v), ee = H(o, f), C = S.sub(ee.xy).toVar(), te = H(c, f).toVar(), w = te.y.toVar(), ne = W(te.z.add(.5)).toVar(), re = te.w.greaterThan(.5), T = this._bilinear(C), ie = [
1006
+ let x = U(a, f).w.clamp(.05, 1), S = this._pixelUv(_, v), ee = U(o, f), C = S.sub(ee.xy).toVar(), te = U(c, f).toVar(), w = te.y.toVar(), ne = G(te.z.add(.5)).toVar(), re = te.w.greaterThan(.5), T = this._bilinear(C), E = [
884
1007
  1,
885
1008
  2,
886
1009
  4,
887
1010
  8
888
- ].map((e) => V(ne.bitAnd(W(e)).notEqual(W(0)), P(1), P(0))), ae = T.customWeights(ie).map((e) => e.toVar()), oe = ir(B(T.filter(ie))).toVar(), E = H(s, f).toVar(), se = E.x.toVar(), D = se.toVar(), ce = se.mul(se).toVar();
1011
+ ].map((e) => H(ne.bitAnd(G(e)).notEqual(G(0)), F(1), F(0))), ie = T.customWeights(E).map((e) => e.toVar()), ae = Vn(V(T.filter(E))).toVar(), oe = U(s, f).toVar(), se = oe.x.toVar(), D = se.toVar(), ce = se.mul(se).toVar();
889
1012
  for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
890
1013
  if (t === 0 && e === 0) continue;
891
- let n = this._clampCoord(_.add(t), v.add(e)), r = H(i, n).w, a = V(r.greaterThanEqual($e), se, H(s, n).x);
1014
+ let n = this._clampCoord(_.add(t), v.add(e)), r = U(i, n).w, a = H(r.greaterThanEqual(Rr), se, U(s, n).x);
892
1015
  D.addAssign(a), ce.addAssign(a.mul(a));
893
1016
  }
894
1017
  D.divAssign(9), ce.divAssign(9);
895
- let O = Li(D, ce).toVar();
896
- N(w.lessThan(t.historyFixFrameNum), () => {
897
- se.assign($n(se, D.mul(P(1.2).add(P(1).div(w.add(1))))));
1018
+ let O = Mi(D, ce).toVar();
1019
+ P(w.lessThan(t.historyFixFrameNum), () => {
1020
+ se.assign(In(se, D.mul(F(1.2).add(F(1).div(w.add(1))))));
898
1021
  });
899
- let le = R(this._sampleHistory((e) => H(l, e), C, T, ae, re).x, 0).toVar(), ue = O.mul(t.antilag.x), de = t.antilag.y.mul(4), fe = le.clamp(D.sub(ue), D.add(ue)), pe = le.sub(fe).abs().div(R(le, fe).add(ii)), me = P(1).div(P(1).add(pe.mul(w.mul(oe)).div(de))).toVar(), he = $n(w, t.historyFixFrameNum);
900
- w.assign(z(he, w, me));
901
- let ge = m.add(1), _e = this._handover(ge), ve = oe.mul(P(1).sub(this._advancedNonLinear(w.mul(P(1).sub(_e)).div(ge)))).mul(me).toVar(), ye = P(1).add(ve.mul(6)), be = t.stabilizationStrength.mul(P(1).sub(h)), xe = z(se, le.clamp(D.sub(O.mul(ye)), D.add(O.mul(ye))), $n(ve, be)).toVar();
902
- E.assign(Fi(E, xe)), U(e, p, J(xe, 0, 0, 0)).toWriteOnly();
903
- let Se = t.maxAccum.mul(P(1).sub(h));
904
- U(u, p, J($n(w.add(1), Se), x, 0, 0)).toWriteOnly();
905
- let Ce = H(r, f), we = J(Ni(E.xyz).mul(R(Ce.xyz, q(et))), b.w).toVar();
906
- N(g.equal(F(1)), () => {
907
- let e = B(w.div(R(t.maxAccum, 1)));
908
- we.assign(J(P(1).sub(e), e, .2, 1));
909
- }).ElseIf(g.equal(F(2)), () => {
910
- we.assign(J(q(E.w), 1));
911
- }).ElseIf(g.equal(F(3)), () => {
912
- we.assign(J(q(x), 1));
913
- }).ElseIf(g.equal(F(4)), () => {
1022
+ let k = z(this._sampleHistory((e) => U(l, e), C, T, ie, re).x, 0).toVar(), le = O.mul(t.antilag.x), ue = t.antilag.y.mul(4), de = k.clamp(D.sub(le), D.add(le)), A = k.sub(de).abs().div(z(k, de).add($r)), fe = F(1).div(F(1).add(A.mul(w.mul(ae)).div(ue))).toVar(), pe = In(w, t.historyFixFrameNum);
1023
+ w.assign(B(pe, w, fe));
1024
+ let me = m.add(1), he = this._handover(me), ge = ae.mul(F(1).sub(this._advancedNonLinear(w.mul(F(1).sub(he)).div(me)))).mul(fe).toVar(), _e = F(1).add(ge.mul(6)), ve = t.stabilizationStrength.mul(F(1).sub(h)), ye = B(se, k.clamp(D.sub(O.mul(_e)), D.add(O.mul(_e))), In(ge, ve)).toVar();
1025
+ oe.assign(Ai(oe, ye)), W(e, p, J(ye, 0, 0, 0)).toWriteOnly();
1026
+ let be = t.maxAccum.mul(F(1).sub(h));
1027
+ W(u, p, J(In(w.add(1), be), x, 0, 0)).toWriteOnly();
1028
+ let xe = U(r, f), Se = J(Oi(oe.xyz).mul(z(xe.xyz, q(zr))), b.w).toVar();
1029
+ P(g.equal(I(1)), () => {
1030
+ let e = V(w.div(z(t.maxAccum, 1)));
1031
+ Se.assign(J(F(1).sub(e), e, .2, 1));
1032
+ }).ElseIf(g.equal(I(2)), () => {
1033
+ Se.assign(J(q(oe.w), 1));
1034
+ }).ElseIf(g.equal(I(3)), () => {
1035
+ Se.assign(J(q(x), 1));
1036
+ }).ElseIf(g.equal(I(4)), () => {
914
1037
  let e = te.x.div(te.x.add(1));
915
- we.assign(J(q(e), 1));
916
- }).ElseIf(g.equal(F(5)), () => {
917
- we.assign(J(q(te.z.div(15)), 1));
918
- }), U(d, p, we).toWriteOnly();
1038
+ Se.assign(J(q(e), 1));
1039
+ }).ElseIf(g.equal(I(5)), () => {
1040
+ Se.assign(J(q(te.z.div(15)), 1));
1041
+ }), W(d, p, Se).toWriteOnly();
919
1042
  });
920
1043
  })().compute([
921
1044
  this._dispatchX,
922
1045
  this._dispatchY,
923
1046
  1
924
1047
  ], [
925
- _i,
926
- _i,
1048
+ fi,
1049
+ fi,
927
1050
  1
928
1051
  ]);
929
1052
  }
@@ -943,7 +1066,7 @@ var Vi = class extends E {
943
1066
  }
944
1067
  _updateRotators(e) {
945
1068
  let t = (t, n) => {
946
- let r = Bi(e * 3 + n) * Math.PI * 2;
1069
+ let r = Fi(e * 3 + n) * Math.PI * 2;
947
1070
  t.value.set(Math.cos(r), Math.sin(r), -Math.sin(r), Math.cos(r));
948
1071
  };
949
1072
  t(this.rotPre, 0), t(this.rotBlur, 1), t(this.rotPost, 2);
@@ -970,7 +1093,7 @@ var Vi = class extends E {
970
1093
  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;
971
1094
  }
972
1095
  setSize(e, t) {
973
- this.outputTarget.setSize(e, t), this.outputTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / _i), this._dispatchY = Math.ceil(t / _i);
1096
+ this.outputTarget.setSize(e, t), this.outputTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / fi), this._dispatchY = Math.ceil(t / fi);
974
1097
  let n = [
975
1098
  this._dispatchX,
976
1099
  this._dispatchY,
@@ -999,15 +1122,15 @@ var Vi = class extends E {
999
1122
  for (let [e, t] of this._placeholders) e.dispose(), t.dispose();
1000
1123
  this._placeholders.clear();
1001
1124
  }
1002
- }, Hi = (e) => V(e.equal(e), e, P(0)).clamp(0, 1e7), Ui = /* @__PURE__ */ cr("\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"), Wi = class extends E {
1125
+ }, Li = (e) => H(e.equal(e), e, F(0)).clamp(0, 1e7), Ri = /* @__PURE__ */ Kn("\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"), zi = class extends E {
1003
1126
  constructor(e, t = {}) {
1004
1127
  super("VarianceEstimation", {
1005
1128
  ...t,
1006
- executionMode: D.ALWAYS
1007
- }), 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();
1129
+ executionMode: ge.ALWAYS
1130
+ }), this.renderer = e, this.inputTextureName = t.inputTextureName || "pathtracer:color", this.varianceBoost = K(t.varianceBoost ?? 1), this.temporalAlpha = K(t.temporalAlpha ?? .1), this.resW = K(t.width || 1), this.resH = K(t.height || 1), this._colorTexNode = new N();
1008
1131
  let n = t.width || 1, r = t.height || 1;
1009
- this._storageTexA = new j(A, A), this._storageTexA.type = Cr, this._storageTexA.format = Q, this._storageTexA.minFilter = X, this._storageTexA.magFilter = X, this._storageTexB = new j(A, A), this._storageTexB.type = Cr, this._storageTexB.format = Q, this._storageTexB.minFilter = X, this._storageTexB.magFilter = X, this._srcRegion = new mr(new qr(0, 0), new qr(0, 0)), this._outputTarget = new Ln(n, r, {
1010
- type: Cr,
1132
+ this._storageTexA = new M(k, k), this._storageTexA.type = sr, this._storageTexA.format = Q, this._storageTexA.minFilter = X, this._storageTexA.magFilter = X, this._storageTexB = new M(k, k), this._storageTexB.type = sr, this._storageTexB.format = Q, this._storageTexB.minFilter = X, this._storageTexB.magFilter = X, this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0)), this._outputTarget = new bn(n, r, {
1133
+ type: sr,
1011
1134
  format: Q,
1012
1135
  minFilter: X,
1013
1136
  magFilter: X,
@@ -1019,26 +1142,26 @@ var Vi = class extends E {
1019
1142
  this.on("pathtracer:viewpointChanged", () => this.reset());
1020
1143
  }
1021
1144
  _buildCompute() {
1022
- this._readTexNodeA = new M(), this._readTexNodeB = new M(), this._computeNodeA = this._buildComputeForDirection(this._storageTexA, this._readTexNodeB), this._computeNodeB = this._buildComputeForDirection(this._storageTexB, this._readTexNodeA);
1145
+ this._readTexNodeA = new N(), this._readTexNodeB = new N(), this._computeNodeA = this._buildComputeForDirection(this._storageTexA, this._readTexNodeB), this._computeNodeB = this._buildComputeForDirection(this._storageTexB, this._readTexNodeA);
1023
1146
  }
1024
1147
  _buildComputeForDirection(e, t) {
1025
- let n = this._colorTexNode, r = this.temporalAlpha, i = this.varianceBoost, a = this.resW, s = this.resH, c = lr("float", 100);
1026
- return zn(() => {
1027
- 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;
1028
- c.element(d).assign(Hi(o(g))), N(d.lessThan(W(36)), () => {
1029
- 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;
1030
- c.element(e).assign(Hi(o(i)));
1031
- }), ur();
1032
- let _ = F(Y.x).mul(8).add(F(l)), v = F(Y.y).mul(8).add(F(u));
1033
- N(_.lessThan(F(a)).and(v.lessThan(F(s))), () => {
1034
- let n = P(0).toVar(), a = P(0).toVar();
1148
+ let n = this._colorTexNode, r = this.temporalAlpha, i = this.varianceBoost, a = this.resW, s = this.resH, c = qn("float", 100);
1149
+ return Sn(() => {
1150
+ let l = R.x, u = R.y, d = u.mul(8).add(l), f = I(Y.x).mul(8).sub(1), p = I(Y.y).mul(8).sub(1), m = d.mod(10), h = d.div(10), g = U(n, L(f.add(I(m)).clamp(I(0), I(a).sub(1)), p.add(I(h)).clamp(I(0), I(s).sub(1)))).xyz;
1151
+ c.element(d).assign(Li(o(g))), P(d.lessThan(G(36)), () => {
1152
+ let e = d.add(G(64)), t = e.mod(10), r = e.div(10), i = U(n, L(f.add(I(t)).clamp(I(0), I(a).sub(1)), p.add(I(r)).clamp(I(0), I(s).sub(1)))).xyz;
1153
+ c.element(e).assign(Li(o(i)));
1154
+ }), Jn();
1155
+ let _ = I(Y.x).mul(8).add(I(l)), v = I(Y.y).mul(8).add(I(u));
1156
+ P(_.lessThan(I(a)).and(v.lessThan(I(s))), () => {
1157
+ let n = F(0).toVar(), a = F(0).toVar();
1035
1158
  for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
1036
1159
  let r = c.element(u.add(1 + e).mul(10).add(l.add(1 + t)));
1037
1160
  n.addAssign(r), a.addAssign(r.mul(r));
1038
1161
  }
1039
1162
  n.divAssign(9), a.divAssign(9);
1040
- 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));
1041
- U(e, or(W(_), W(v)), Ui(s, d.x, d.y, r, o, i)).toWriteOnly();
1163
+ let o = z(a.sub(n.mul(n)), F(0)), s = c.element(u.add(1).mul(10).add(l.add(1))), d = U(t, L(_, v));
1164
+ W(e, Un(G(_), G(v)), Ri(s, d.x, d.y, r, o, i)).toWriteOnly();
1042
1165
  });
1043
1166
  })().compute([
1044
1167
  this._dispatchX,
@@ -1084,23 +1207,23 @@ var Vi = class extends E {
1084
1207
  reallocateReservedStorage() {
1085
1208
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose();
1086
1209
  let e = () => {
1087
- let e = new j(A, A);
1088
- return e.type = Cr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1210
+ let e = new M(k, k);
1211
+ return e.type = sr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1089
1212
  };
1090
1213
  this._storageTexA = e(), this._storageTexB = e(), this._buildCompute(), this._compiled = !1;
1091
1214
  }
1092
1215
  dispose() {
1093
1216
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._colorTexNode?.dispose(), this._readTexNodeA?.dispose(), this._readTexNodeB?.dispose();
1094
1217
  }
1095
- }, Gi = /* @__PURE__ */ cr("\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"), Ki = class extends E {
1218
+ }, Bi = /* @__PURE__ */ Kn("\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"), Vi = class extends E {
1096
1219
  constructor(e, t = {}) {
1097
1220
  super("BilateralFiltering", {
1098
1221
  ...t,
1099
- executionMode: D.ALWAYS
1100
- }), 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();
1222
+ executionMode: ge.ALWAYS
1223
+ }), 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 = K(t.phiColor ?? .5), this.phiNormal = K(t.phiNormal ?? 128), this.phiDepth = K(t.phiDepth ?? .05), this.phiLuminance = K(t.phiLuminance ?? 4), this.spatialVarianceWeight = K(t.spatialVarianceWeight ?? 1), this.stepSizeU = K(1, "int"), this.isLastIterationU = K(0, "int"), this.isFirstIterationU = K(1, "int"), this.resW = K(t.width || 1), this.resH = K(t.height || 1), this._readTexNode = new N(), this._normalDepthTexNode = new N(), this._shadingNormalTexNode = new N(), this._albedoTexNode = new N(), this._varianceTexNode = new N(), this._srcAlphaTexNode = new N();
1101
1224
  let n = t.width || 1, r = t.height || 1;
1102
- this._storageTexA = new j(A, A), this._storageTexA.type = wr, this._storageTexA.format = Q, this._storageTexA.minFilter = X, this._storageTexA.magFilter = X, this._storageTexB = new j(A, A), this._storageTexB.type = wr, this._storageTexB.format = Q, this._storageTexB.minFilter = X, this._storageTexB.magFilter = X, this._srcRegion = new mr(new qr(0, 0), new qr(0, 0)), this._outputTarget = new Ln(n, r, {
1103
- type: wr,
1225
+ this._storageTexA = new M(k, k), this._storageTexA.type = cr, this._storageTexA.format = Q, this._storageTexA.minFilter = X, this._storageTexA.magFilter = X, this._storageTexB = new M(k, k), this._storageTexB.type = cr, this._storageTexB.format = Q, this._storageTexB.minFilter = X, this._storageTexB.magFilter = X, this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0)), this._outputTarget = new bn(n, r, {
1226
+ type: cr,
1104
1227
  format: Q,
1105
1228
  minFilter: X,
1106
1229
  magFilter: X,
@@ -1139,19 +1262,19 @@ var Vi = class extends E {
1139
1262
  4 / 256,
1140
1263
  1 / 256
1141
1264
  ];
1142
- return zn(() => {
1143
- let y = F(Y.x).mul(8).add(F(L.x)), b = F(Y.y).mul(8).add(F(L.y));
1144
- N(y.lessThan(F(g)).and(b.lessThan(F(_))), () => {
1145
- let x = I(y, b), S = H(t, x), ee = S.xyz, C = H(n, x), te = H(r, x).xyz.mul(2).sub(1), w = C.w, ne = o(ee), re = R(H(i, x).xyz, q(et)), T = R(o(re), P(et)).toVar(), ie = h.equal(F(1)), ae = (e) => {
1146
- let t = H(a, e);
1147
- return z(t.z, R(t.z, t.w), f);
1148
- }, oe = ie.select(ae(x), S.w.mul(S.w)).toVar(), E = d.mul(ir(R(oe, P(0)))).div(T).add(P(1e-4)), se = q(0).toVar(), D = P(0).toVar(), ce = P(0).toVar();
1265
+ return Sn(() => {
1266
+ let y = I(Y.x).mul(8).add(I(R.x)), b = I(Y.y).mul(8).add(I(R.y));
1267
+ P(y.lessThan(I(g)).and(b.lessThan(I(_))), () => {
1268
+ let x = L(y, b), S = U(t, x), ee = S.xyz, C = U(n, x), te = U(r, x).xyz.mul(2).sub(1), w = C.w, ne = o(ee), re = z(U(i, x).xyz, q(zr)), T = z(o(re), F(zr)).toVar(), E = h.equal(I(1)), ie = (e) => {
1269
+ let t = U(a, e);
1270
+ return B(t.z, z(t.z, t.w), f);
1271
+ }, ae = E.select(ie(x), S.w.mul(S.w)).toVar(), oe = d.mul(Vn(z(ae, F(0)))).div(T).add(F(1e-4)), se = q(0).toVar(), D = F(0).toVar(), ce = F(0).toVar();
1149
1272
  for (let e = 0; e < 5; e++) for (let i = 0; i < 5; i++) {
1150
- 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), re = S.w, T = Gi(ne, o(x), te, C, w, re, ee, x, P(d), E, l, u, c), oe = ie.select(ae(I(f, m)), h.w.mul(h.w));
1151
- se.addAssign(x.mul(T)), D.addAssign(T), ce.addAssign(T.mul(T).mul(R(oe, P(0))));
1273
+ let a = i - 2, s = e - 2, d = v[e * 5 + i], f = y.add(p.mul(a)).clamp(I(0), I(g).sub(1)), m = b.add(p.mul(s)).clamp(I(0), I(_).sub(1)), h = U(t, L(f, m)), x = h.xyz, S = U(n, L(f, m)), C = U(r, L(f, m)).xyz.mul(2).sub(1), re = S.w, T = Bi(ne, o(x), te, C, w, re, ee, x, F(d), oe, l, u, c), ae = E.select(ie(L(f, m)), h.w.mul(h.w));
1274
+ se.addAssign(x.mul(T)), D.addAssign(T), ce.addAssign(T.mul(T).mul(z(ae, F(0))));
1152
1275
  }
1153
- let O = se.div(R(D, P(1e-4))), le = ce.div(R(D.mul(D), P(1e-8))), ue = m.equal(F(1)), de = ue.select(O.mul(re), O), fe = ue.select(H(s, x).w, ir(R(le, P(0))));
1154
- U(e, or(W(y), W(b)), J(de, fe)).toWriteOnly();
1276
+ let O = se.div(z(D, F(1e-4))), k = ce.div(z(D.mul(D), F(1e-8))), le = m.equal(I(1)), ue = le.select(O.mul(re), O), de = le.select(U(s, x).w, Vn(z(k, F(0))));
1277
+ W(e, Un(G(y), G(b)), J(ue, de)).toWriteOnly();
1155
1278
  });
1156
1279
  })().compute([
1157
1280
  this._dispatchX,
@@ -1198,15 +1321,15 @@ var Vi = class extends E {
1198
1321
  reallocateReservedStorage() {
1199
1322
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose();
1200
1323
  let e = () => {
1201
- let e = new j(A, A);
1202
- return e.type = wr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1324
+ let e = new M(k, k);
1325
+ return e.type = cr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1203
1326
  };
1204
1327
  this._storageTexA = e(), this._storageTexB = e(), this._buildCompute(), this._compiled = !1;
1205
1328
  }
1206
1329
  dispose() {
1207
1330
  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();
1208
1331
  }
1209
- }, qi = 6e4, Ji = (e) => V(e.equal(e), e, P(0)).clamp(0, 1e7), Yi = (e) => q(Ji(e.x), Ji(e.y), Ji(e.z)), Xi = 4, Zi = [
1332
+ }, Hi = 6e4, Ui = (e) => H(e.equal(e), e, F(0)).clamp(0, 1e7), Wi = (e) => q(Ui(e.x), Ui(e.y), Ui(e.z)), Gi = 4, Ki = [
1210
1333
  1 / 256,
1211
1334
  4 / 256,
1212
1335
  6 / 256,
@@ -1232,15 +1355,15 @@ var Vi = class extends E {
1232
1355
  6 / 256,
1233
1356
  4 / 256,
1234
1357
  1 / 256
1235
- ], Qi = class extends E {
1358
+ ], qi = class extends E {
1236
1359
  constructor(e, t = {}) {
1237
1360
  super("EdgeAwareFiltering", {
1238
1361
  ...t,
1239
- executionMode: D.PER_CYCLE
1240
- }), 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();
1362
+ executionMode: ge.PER_CYCLE
1363
+ }), this.renderer = e, this.filterStrength = K(t.filterStrength ?? 1), this.phiLuminance = K(t.phiLuminance ?? 1), this.phiNormal = K(t.phiNormal ?? 64), this.phiDepth = K(t.phiDepth ?? .1), this.iterations = t.atrousIterations ?? t.edgeAtrousIterations ?? 5, this.stepSizeU = K(1, "int"), this.isLastIterationU = K(0, "int"), this.isFirstIterationU = K(1, "int"), this.varianceHistoryU = K(0, "int"), this.resW = K(t.width || 1), this.resH = K(t.height || 1), this._colorTexNode = new N(), this._ndTexNode = new N(), this._snTexNode = new N(), this._albedoTexNode = new N(), this._varTexNode = new N(), this._readTexNode = new N();
1241
1364
  let n = t.width || 1, r = t.height || 1;
1242
- this._demodTex = this._makeStorageTex(), this._storageTexA = this._makeStorageTex(), this._storageTexB = this._makeStorageTex(), this._srcRegion = new mr(new qr(0, 0), new qr(0, 0)), this.outputTarget = new Ln(n, r, {
1243
- type: Cr,
1365
+ this._demodTex = this._makeStorageTex(), this._storageTexA = this._makeStorageTex(), this._storageTexB = this._makeStorageTex(), this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0)), this.outputTarget = new bn(n, r, {
1366
+ type: sr,
1244
1367
  format: Q,
1245
1368
  minFilter: X,
1246
1369
  magFilter: X,
@@ -1249,19 +1372,19 @@ var Vi = class extends E {
1249
1372
  }), this._compiled = !1, this._dispatchX = Math.ceil(n / 16), this._dispatchY = Math.ceil(r / 16), this._buildCompute();
1250
1373
  }
1251
1374
  _makeStorageTex() {
1252
- let e = new j(A, A);
1253
- return e.type = Cr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1375
+ let e = new M(k, k);
1376
+ return e.type = sr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1254
1377
  }
1255
1378
  _buildCompute() {
1256
1379
  this._computeDemod = this._buildDemod(), this._computeAtrousA = this._buildAtrous(this._storageTexA), this._computeAtrousB = this._buildAtrous(this._storageTexB);
1257
1380
  }
1258
1381
  _buildDemod() {
1259
1382
  let e = this._colorTexNode, t = this._ndTexNode, n = this._albedoTexNode, r = this._demodTex, i = this.resW, a = this.resH;
1260
- return zn(() => {
1261
- let o = F(Y.x).mul(16).add(F(L.x)), s = F(Y.y).mul(16).add(F(L.y));
1262
- N(o.lessThan(F(i)).and(s.lessThan(F(a))), () => {
1263
- let i = I(o, s), a = H(e, i).xyz, c = H(t, i).w.lessThan(P(qi)), l = H(n, i).xyz, u = V(c, R(l, q(et)), q(1)), d = Yi(a.div(u));
1264
- U(r, or(W(o), W(s)), J(d, 1)).toWriteOnly();
1383
+ return Sn(() => {
1384
+ let o = I(Y.x).mul(16).add(I(R.x)), s = I(Y.y).mul(16).add(I(R.y));
1385
+ P(o.lessThan(I(i)).and(s.lessThan(I(a))), () => {
1386
+ let i = L(o, s), a = U(e, i).xyz, c = U(t, i).w.lessThan(F(Hi)), l = U(n, i).xyz, u = H(c, z(l, q(zr)), q(1)), d = Wi(a.div(u));
1387
+ W(r, Un(G(o), G(s)), J(d, 1)).toWriteOnly();
1265
1388
  });
1266
1389
  })().compute([
1267
1390
  this._dispatchX,
@@ -1275,19 +1398,19 @@ var Vi = class extends E {
1275
1398
  }
1276
1399
  _buildAtrous(e) {
1277
1400
  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;
1278
- return zn(() => {
1279
- let v = F(Y.x).mul(16).add(F(L.x)), y = F(Y.y).mul(16).add(F(L.y));
1280
- N(v.lessThan(F(g)).and(y.lessThan(F(_))), () => {
1281
- let b = I(v, y), x = H(t, b), S = x.xyz, ee = o(S), C = H(r, b).w, te = H(i, b).xyz.mul(2).sub(1), w = C.lessThan(P(qi)), ne = V(w, P(1), P(0)), re = H(a, b).xyz, T = V(w, R(re, q(et)), q(1)), ie = R(o(T), P(et)), ae = m.equal(F(1)), oe = h.lessThan(F(Xi)), E = (e) => {
1282
- let t = H(s, e);
1283
- return V(oe, R(t.z, t.w), t.z);
1284
- }, se = ae.select(E(b), x.w.mul(x.w)).toVar(), D = l.mul(ir(R(se, P(0)))).div(ie).add(P(1e-4)), ce = q(0).toVar(), O = P(0).toVar(), le = P(0).toVar();
1401
+ return Sn(() => {
1402
+ let v = I(Y.x).mul(16).add(I(R.x)), y = I(Y.y).mul(16).add(I(R.y));
1403
+ P(v.lessThan(I(g)).and(y.lessThan(I(_))), () => {
1404
+ let b = L(v, y), x = U(t, b), S = x.xyz, ee = o(S), C = U(r, b).w, te = U(i, b).xyz.mul(2).sub(1), w = C.lessThan(F(Hi)), ne = H(w, F(1), F(0)), re = U(a, b).xyz, T = H(w, z(re, q(zr)), q(1)), E = z(o(T), F(zr)), ie = m.equal(I(1)), ae = h.lessThan(I(Gi)), oe = (e) => {
1405
+ let t = U(s, e);
1406
+ return H(ae, z(t.z, t.w), t.z);
1407
+ }, se = ie.select(oe(b), x.w.mul(x.w)).toVar(), D = l.mul(Vn(z(se, F(0)))).div(E).add(F(1e-4)), ce = q(0).toVar(), O = F(0).toVar(), k = F(0).toVar();
1285
1408
  for (let e = 0; e < 5; e++) for (let n = 0; n < 5; n++) {
1286
- let a = n - 2, s = e - 2, c = Zi[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(qi)), P(1), P(0)), w = ee.sub(h).abs().div(D).negate().exp(), re = tr(Jn(te, x).clamp(0, 1), u), T = C.sub(b).abs().div(R(C.mul(d), P(.001))).negate().exp(), ie = ne.mul(S), oe = ne.oneMinus().mul(S.oneMinus()), se = ie.add(oe), ue = z(P(1), re.mul(T), ie), de = P(c).mul(w).mul(ue).mul(se), fe = ae.select(E(l), p.w.mul(p.w));
1287
- ce.addAssign(m.mul(de)), O.addAssign(de), le.addAssign(de.mul(de).mul(R(fe, P(0))));
1409
+ let a = n - 2, s = e - 2, c = Ki[e * 5 + n], l = L(v.add(f.mul(a)).clamp(I(0), I(g).sub(1)), y.add(f.mul(s)).clamp(I(0), I(_).sub(1))), p = U(t, l), m = p.xyz, h = o(m), b = U(r, l).w, x = U(i, l).xyz.mul(2).sub(1), S = H(b.lessThan(F(Hi)), F(1), F(0)), w = ee.sub(h).abs().div(D).negate().exp(), re = Rn(jn(te, x).clamp(0, 1), u), T = C.sub(b).abs().div(z(C.mul(d), F(.001))).negate().exp(), E = ne.mul(S), ae = ne.oneMinus().mul(S.oneMinus()), se = E.add(ae), le = B(F(1), re.mul(T), E), ue = F(c).mul(w).mul(le).mul(se), de = ie.select(oe(l), p.w.mul(p.w));
1410
+ ce.addAssign(m.mul(ue)), O.addAssign(ue), k.addAssign(ue.mul(ue).mul(z(de, F(0))));
1288
1411
  }
1289
- let ue = ce.div(R(O, P(1e-4))), de = le.div(R(O.mul(O), P(1e-8))), fe = p.equal(F(1)), pe = H(n, b).xyz, me = z(pe, ue.mul(T), c), he = fe.select(me, ue), ge = fe.select(H(n, b).w, ir(R(de, P(0))));
1290
- U(e, or(W(v), W(y)), J(he, ge)).toWriteOnly();
1412
+ let le = ce.div(z(O, F(1e-4))), ue = k.div(z(O.mul(O), F(1e-8))), de = p.equal(I(1)), A = U(n, b).xyz, fe = B(A, le.mul(T), c), pe = de.select(fe, le), me = de.select(U(n, b).w, Vn(z(ue, F(0))));
1413
+ W(e, Un(G(v), G(y)), J(pe, me)).toWriteOnly();
1291
1414
  });
1292
1415
  })().compute([
1293
1416
  this._dispatchX,
@@ -1345,38 +1468,45 @@ var Vi = class extends E {
1345
1468
  dispose() {
1346
1469
  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();
1347
1470
  }
1348
- }, $i = 256, ea = -8, ta = 6 - ea, na = ta / $i, ra = 1e4, ia = /* @__PURE__ */ cr("\n fn adaptExposure(\n geoMean: f32,\n prevExposure: f32,\n keyValue: f32,\n minExp: f32,\n maxExp: f32,\n speedBright: f32,\n speedDark: f32,\n dt: f32,\n isFirstFrame: f32\n ) -> vec4f {\n\n let targetExp = clamp( keyValue / max( geoMean, 0.001 ), minExp, maxExp );\n var newExposure = targetExp;\n\n // Temporal smoothing (skip on first frame)\n if ( isFirstFrame < 0.5 ) {\n\n // Asymmetric speed: brighter scenes adapt faster\n let speed = select( speedDark, speedBright, targetExp < prevExposure );\n let alpha = 1.0 - exp( -dt * speed );\n newExposure = mix( prevExposure, targetExp, alpha );\n\n }\n\n return vec4f( newExposure, geoMean, targetExp, 1.0 );\n\n }\n"), aa = class extends E {
1471
+ }, Ji = {
1472
+ autoExposure: !1,
1473
+ autoExposureKeyValue: .18,
1474
+ autoExposureMinExposure: .1,
1475
+ autoExposureMaxExposure: 20,
1476
+ autoExposureAdaptSpeedBright: 3,
1477
+ autoExposureAdaptSpeedDark: .5
1478
+ }, Yi = 256, Xi = -8, Zi = 6 - Xi, Qi = Zi / Yi, $i = 1e4, ea = /* @__PURE__ */ Kn("\n fn adaptExposure(\n geoMean: f32,\n prevExposure: f32,\n keyValue: f32,\n minExp: f32,\n maxExp: f32,\n speedBright: f32,\n speedDark: f32,\n dt: f32,\n isFirstFrame: f32\n ) -> vec4f {\n\n let targetExp = clamp( keyValue / max( geoMean, 0.001 ), minExp, maxExp );\n var newExposure = targetExp;\n\n // Temporal smoothing (skip on first frame)\n if ( isFirstFrame < 0.5 ) {\n\n // Asymmetric speed: brighter scenes adapt faster\n let speed = select( speedDark, speedBright, targetExp < prevExposure );\n let alpha = 1.0 - exp( -dt * speed );\n newExposure = mix( prevExposure, targetExp, alpha );\n\n }\n\n return vec4f( newExposure, geoMean, targetExp, 1.0 );\n\n }\n"), ta = class extends E {
1349
1479
  constructor(e, t = {}) {
1350
1480
  super("AutoExposure", {
1351
1481
  ...t,
1352
- executionMode: D.ALWAYS
1353
- }), this.renderer = e, this.REDUCTION_SIZE = 64, this.keyValueU = G(t.keyValue ?? .18), this.minExposureU = G(t.minExposure ?? .1), this.maxExposureU = G(t.maxExposure ?? 20), this.adaptSpeedBrightU = G(t.adaptSpeedBright ?? 3), this.adaptSpeedDarkU = G(t.adaptSpeedDark ?? .5), this.epsilonU = G(t.epsilon ?? 1e-4), this.deltaTimeU = G(1 / 60), this.isFirstFrameU = G(1), this.previousExposureU = G(t.initialExposure ?? 1), this.lowPercentileU = G(t.lowPercentile ?? .1), this.highPercentileU = G(t.highPercentile ?? .9), this.centerWeightU = G(t.centerWeight ?? 8), this.inputResW = G(1), this.inputResH = G(1), this._inputTexNode = new M(), this._reductionReadTexNode = new M(), this.currentExposure = t.initialExposure ?? 1, this.currentLuminance = .18, this.targetExposure = 1, this.lastTime = performance.now(), this.isFirstFrame = !0, this._pendingReadback = !1, this._readbackGeneration = 0, this._initRenderTargets(), this._buildCompute();
1482
+ executionMode: ge.ALWAYS
1483
+ }), this.renderer = e, this.REDUCTION_SIZE = 64, this.keyValueU = K(t.keyValue ?? Ji.autoExposureKeyValue), this.minExposureU = K(t.minExposure ?? Ji.autoExposureMinExposure), this.maxExposureU = K(t.maxExposure ?? Ji.autoExposureMaxExposure), this.adaptSpeedBrightU = K(t.adaptSpeedBright ?? Ji.autoExposureAdaptSpeedBright), this.adaptSpeedDarkU = K(t.adaptSpeedDark ?? Ji.autoExposureAdaptSpeedDark), this.epsilonU = K(t.epsilon ?? 1e-4), this.deltaTimeU = K(1 / 60), this.isFirstFrameU = K(1), this.previousExposureU = K(t.initialExposure ?? 1), this.lowPercentileU = K(t.lowPercentile ?? .1), this.highPercentileU = K(t.highPercentile ?? .9), this.centerWeightU = K(t.centerWeight ?? 8), this.inputResW = K(1), this.inputResH = K(1), this._inputTexNode = new N(), this._reductionReadTexNode = new N(), this.currentExposure = t.initialExposure ?? 1, this.currentLuminance = .18, this.targetExposure = 1, this.lastTime = performance.now(), this.isFirstFrame = !0, this._pendingReadback = !1, this._readbackGeneration = 0, this._initRenderTargets(), this._buildCompute();
1354
1484
  }
1355
1485
  _initRenderTargets() {
1356
1486
  let e = {
1357
- type: Cr,
1487
+ type: sr,
1358
1488
  format: Q,
1359
1489
  minFilter: Z,
1360
1490
  magFilter: Z,
1361
1491
  depthBuffer: !1,
1362
1492
  stencilBuffer: !1
1363
1493
  };
1364
- this._downsampleTarget = new Ln(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new j(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = Cr, this._downsampleStorageTex.format = Q, this._downsampleStorageTex.minFilter = Z, this._downsampleStorageTex.magFilter = Z, this._reductionStorageTex = new j(1, 1), this._reductionStorageTex.type = Cr, this._reductionStorageTex.format = Q, this._reductionStorageTex.minFilter = Z, this._reductionStorageTex.magFilter = Z, this._reductionReadTarget = new Ln(1, 1, e), this._adaptationResult = qn(1, "vec4"), this._readbackBuffer = new In(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = qn($i, "uint").toAtomic();
1494
+ this._downsampleTarget = new bn(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new M(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = sr, this._downsampleStorageTex.format = Q, this._downsampleStorageTex.minFilter = Z, this._downsampleStorageTex.magFilter = Z, this._reductionStorageTex = new M(1, 1), this._reductionStorageTex.type = sr, this._reductionStorageTex.format = Q, this._reductionStorageTex.minFilter = Z, this._reductionStorageTex.magFilter = Z, this._reductionReadTarget = new bn(1, 1, e), this._adaptationResult = An(1, "vec4"), this._readbackBuffer = new yn(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = An(Yi, "uint").toAtomic();
1365
1495
  }
1366
1496
  _buildCompute() {
1367
1497
  this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
1368
1498
  }
1369
1499
  _buildDownsampleCompute() {
1370
1500
  let e = this._inputTexNode, t = this._downsampleStorageTex, n = this.epsilonU, r = this.inputResW, i = this.inputResH;
1371
- this._downsampleComputeNode = zn(() => {
1372
- let a = F(Y.x).mul(8).add(F(L.x)), s = F(Y.y).mul(8).add(F(L.y)), c = r.div(P(64)), l = i.div(P(64)), u = P(a).mul(c), d = P(s).mul(l), f = P(0).toVar(), p = P(0).toVar();
1501
+ this._downsampleComputeNode = Sn(() => {
1502
+ let a = I(Y.x).mul(8).add(I(R.x)), s = I(Y.y).mul(8).add(I(R.y)), c = r.div(F(64)), l = i.div(F(64)), u = F(a).mul(c), d = F(s).mul(l), f = F(0).toVar(), p = F(0).toVar();
1373
1503
  for (let t = 0; t < 4; t++) for (let r = 0; r < 4; r++) {
1374
- let i = o(H(e, I(F(u.add(P((r + .5) / 4).mul(c))), F(d.add(P((t + .5) / 4).mul(l))))).xyz);
1375
- N(i.greaterThan(n), () => {
1504
+ let i = o(U(e, L(I(u.add(F((r + .5) / 4).mul(c))), I(d.add(F((t + .5) / 4).mul(l))))).xyz);
1505
+ P(i.greaterThan(n), () => {
1376
1506
  f.addAssign(i.add(n).log()), p.addAssign(1);
1377
1507
  });
1378
1508
  }
1379
- U(t, or(W(a), W(s)), J(f, p, 0, 1)).toWriteOnly();
1509
+ W(t, Un(G(a), G(s)), J(f, p, 0, 1)).toWriteOnly();
1380
1510
  })().compute([
1381
1511
  64 / 8,
1382
1512
  64 / 8,
@@ -1389,14 +1519,14 @@ var Vi = class extends E {
1389
1519
  }
1390
1520
  _buildHistogramCompute() {
1391
1521
  let e = this._downsampleTarget.texture, t = this._histogramBuffer, n = this.centerWeightU;
1392
- this._histogramComputeNode = zn(() => {
1393
- let r = L.x;
1394
- Kn(t.element(r), W(0)), ur();
1522
+ this._histogramComputeNode = Sn(() => {
1523
+ let r = R.x;
1524
+ kn(t.element(r), G(0)), Jn();
1395
1525
  for (let i = 0; i < 16; i++) {
1396
- let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = H(e, I(F(o), F(s))), l = c.x, u = c.y;
1397
- N(u.greaterThan(0), () => {
1398
- let e = W(l.div(u).sub(P(ea)).div(P(ta)).mul(P($i)).floor().clamp(0, P($i - 1))), r = P(o).add(.5).div(P(64)), i = P(s).add(.5).div(P(64)), a = r.sub(.5), c = i.sub(.5), d = W(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(P(ra)));
1399
- Wn(t.element(e), d);
1526
+ let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = U(e, L(I(o), I(s))), l = c.x, u = c.y;
1527
+ P(u.greaterThan(0), () => {
1528
+ let e = G(l.div(u).sub(F(Xi)).div(F(Zi)).mul(F(Yi)).floor().clamp(0, F(Yi - 1))), r = F(o).add(.5).div(F(64)), i = F(s).add(.5).div(F(64)), a = r.sub(.5), c = i.sub(.5), d = G(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(F($i)));
1529
+ Dn(t.element(e), d);
1400
1530
  });
1401
1531
  }
1402
1532
  })().compute([
@@ -1411,21 +1541,21 @@ var Vi = class extends E {
1411
1541
  }
1412
1542
  _buildHistogramAnalyzeCompute() {
1413
1543
  let e = this._histogramBuffer, t = this._reductionStorageTex, n = this.lowPercentileU, r = this.highPercentileU;
1414
- this._histogramAnalyzeNode = zn(() => {
1415
- let i = P(0).toVar();
1416
- Bn($i, ({ i: t }) => {
1417
- i.addAssign(P(Gn(e.element(t))));
1544
+ this._histogramAnalyzeNode = Sn(() => {
1545
+ let i = F(0).toVar();
1546
+ Cn(Yi, ({ i: t }) => {
1547
+ i.addAssign(F(On(e.element(t))));
1418
1548
  });
1419
- let a = i.mul(n), o = i.mul(r), s = P(0).toVar(), c = P(0).toVar(), l = P(0).toVar(), u = P(0).toVar();
1420
- Bn($i, ({ i: t }) => {
1421
- let n = P(Gn(e.element(t)));
1422
- u.assign(s), s.addAssign(n), N(u.lessThan(o).and(s.greaterThan(a)), () => {
1423
- let e = P(ea).add(P(t).add(.5).mul(P(na)));
1549
+ let a = i.mul(n), o = i.mul(r), s = F(0).toVar(), c = F(0).toVar(), l = F(0).toVar(), u = F(0).toVar();
1550
+ Cn(Yi, ({ i: t }) => {
1551
+ let n = F(On(e.element(t)));
1552
+ u.assign(s), s.addAssign(n), P(u.lessThan(o).and(s.greaterThan(a)), () => {
1553
+ let e = F(Xi).add(F(t).add(.5).mul(F(Qi)));
1424
1554
  c.addAssign(e.mul(n)), l.addAssign(n);
1425
1555
  });
1426
1556
  });
1427
- let d = R(l, P(1)), f = c.div(d), p = f.exp();
1428
- U(t, or(W(0), W(0)), J(p, i, f, 1)).toWriteOnly();
1557
+ let d = z(l, F(1)), f = c.div(d), p = f.exp();
1558
+ W(t, Un(G(0), G(0)), J(p, i, f, 1)).toWriteOnly();
1429
1559
  })().compute(1, [
1430
1560
  1,
1431
1561
  1,
@@ -1434,9 +1564,9 @@ var Vi = class extends E {
1434
1564
  }
1435
1565
  _buildAdaptationCompute() {
1436
1566
  let e = this._reductionReadTexNode, t = this._adaptationResult, n = this.keyValueU, r = this.minExposureU, i = this.maxExposureU, a = this.adaptSpeedBrightU, o = this.adaptSpeedDarkU, s = this.deltaTimeU, c = this.isFirstFrameU, l = this.previousExposureU;
1437
- this._adaptationComputeNode = zn(() => {
1438
- let u = H(e, I(F(0), F(0))).x, d = ia(u, l, n, r, i, a, o, s, c);
1439
- t.element(W(0)).assign(d);
1567
+ this._adaptationComputeNode = Sn(() => {
1568
+ let u = U(e, L(I(0), I(0))).x, d = ea(u, l, n, r, i, a, o, s, c);
1569
+ t.element(G(0)).assign(d);
1440
1570
  })().compute(1, [
1441
1571
  1,
1442
1572
  1,
@@ -1497,16 +1627,16 @@ var Vi = class extends E {
1497
1627
  dispose() {
1498
1628
  this._downsampleComputeNode?.dispose(), this._histogramComputeNode?.dispose(), this._histogramAnalyzeNode?.dispose(), this._adaptationComputeNode?.dispose(), this._downsampleTarget?.dispose(), this._downsampleStorageTex?.dispose(), this._reductionStorageTex?.dispose(), this._reductionReadTarget?.dispose(), this._readbackBuffer?.dispose(), this._inputTexNode?.dispose(), this._reductionReadTexNode?.dispose();
1499
1629
  }
1500
- }, oa = new $(), sa = new $();
1501
- function ca(e, t) {
1502
- return sa.subVectors(e, t.position).dot(t.getWorldDirection(oa));
1630
+ }, na = new $(), ra = new $();
1631
+ function ia(e, t) {
1632
+ return ra.subVectors(e, t.position).dot(t.getWorldDirection(na));
1503
1633
  }
1504
- function la(e, t, n = !1) {
1505
- return n ? e.distance : ca(e.point, t);
1634
+ function aa(e, t, n = !1) {
1635
+ return n ? e.distance : ia(e.point, t);
1506
1636
  }
1507
- var ua = class extends Sr {
1637
+ var oa = class extends or {
1508
1638
  constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
1509
- super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new zr(), 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;
1639
+ super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new Cr(), 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;
1510
1640
  }
1511
1641
  setDependencies({ overlayManager: e, transformManager: t, appDispatch: n, orbitControls: r, helperScene: i }) {
1512
1642
  this._overlayManager = e || null, this._transformManager = t || null, this._appDispatch = n || null, this._orbitControls = r || null, this._helperScene = i || null;
@@ -1514,7 +1644,7 @@ var ua = class extends Sr {
1514
1644
  select(e) {
1515
1645
  let t = this._overlayManager?.getHelper("outline");
1516
1646
  t && t.setSelectedObjects(e ? [e] : []), this.selectedObject = e || null, e ? this._transformManager?.attach(e) : this._transformManager?.detach(), this._appDispatch?.({
1517
- type: k.OBJECT_SELECTED,
1647
+ type: j.OBJECT_SELECTED,
1518
1648
  object: e || null
1519
1649
  });
1520
1650
  }
@@ -1538,7 +1668,7 @@ var ua = class extends Sr {
1538
1668
  this.raycaster.setFromCamera(t, this.camera);
1539
1669
  let n = this.raycaster.intersectObjects(this.scene.children, !0);
1540
1670
  if (n.length > 0) {
1541
- let e = n[0], t = this.pathTracer?.cameraProjection?.value === Qe.equirectangular, r = la(e, this.camera, t);
1671
+ let e = n[0], t = this.pathTracer?.cameraProjection?.value === he.equirectangular, r = aa(e, this.camera, t);
1542
1672
  this.showFocusPoint(e.point), this.toggleFocusMode(), this.dispatchEvent({
1543
1673
  type: "focusChanged",
1544
1674
  distance: r / this.assetLoader.getSceneScale(),
@@ -1547,7 +1677,7 @@ var ua = class extends Sr {
1547
1677
  }
1548
1678
  }
1549
1679
  showFocusPoint(e) {
1550
- this.focusPointIndicator && this.scene.remove(this.focusPointIndicator), this.focusPointIndicator = new Ar(new Ur(this.assetLoader.getSceneScale() * .02, 16, 16), new jr({
1680
+ this.focusPointIndicator && this.scene.remove(this.focusPointIndicator), this.focusPointIndicator = new mr(new Dr(this.assetLoader.getSceneScale() * .02, 16, 16), new hr({
1551
1681
  color: 65280,
1552
1682
  transparent: !0,
1553
1683
  opacity: .8,
@@ -1710,35 +1840,35 @@ var ua = class extends Sr {
1710
1840
  wireAppEvents(e) {
1711
1841
  this.addEventListener("objectSelected", (t) => {
1712
1842
  this.select(t.object), e.refreshFrame(), e.dispatchEvent({
1713
- type: k.OBJECT_SELECTED,
1843
+ type: j.OBJECT_SELECTED,
1714
1844
  object: t.object,
1715
1845
  uuid: t.uuid
1716
1846
  });
1717
1847
  }), this.addEventListener("objectDeselected", (t) => {
1718
1848
  this.select(null), e.refreshFrame(), e.dispatchEvent({
1719
- type: k.OBJECT_DESELECTED,
1849
+ type: j.OBJECT_DESELECTED,
1720
1850
  object: t.object,
1721
1851
  uuid: t.uuid
1722
1852
  });
1723
1853
  }), this.addEventListener("selectModeChanged", (t) => {
1724
1854
  e.dispatchEvent({
1725
- type: k.SELECT_MODE_CHANGED,
1855
+ type: j.SELECT_MODE_CHANGED,
1726
1856
  enabled: t.enabled
1727
1857
  });
1728
1858
  }), this.addEventListener("objectDoubleClicked", (t) => {
1729
1859
  this.select(t.object), e.refreshFrame(), e.dispatchEvent({
1730
- type: k.OBJECT_DOUBLE_CLICKED,
1860
+ type: j.OBJECT_DOUBLE_CLICKED,
1731
1861
  object: t.object,
1732
1862
  uuid: t.uuid
1733
1863
  });
1734
1864
  }), this.addEventListener("focusChanged", (t) => {
1735
1865
  e.settings.set("focusDistance", t.worldDistance), e.dispatchEvent({
1736
- type: k.FOCUS_CHANGED,
1866
+ type: j.FOCUS_CHANGED,
1737
1867
  distance: t.distance
1738
1868
  });
1739
1869
  }), this.addEventListener("afPointPlaced", (t) => {
1740
1870
  e.dispatchEvent({
1741
- type: k.AF_POINT_PLACED,
1871
+ type: j.AF_POINT_PLACED,
1742
1872
  point: t.point
1743
1873
  });
1744
1874
  });
@@ -1746,7 +1876,7 @@ var ua = class extends Sr {
1746
1876
  dispose() {
1747
1877
  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;
1748
1878
  }
1749
- }, da = 8, fa = 4, pa = .25, ma = Or.degToRad(89), ha = .25, ga = {
1879
+ }, sa = 8, ca = 4, la = .25, ua = fr.degToRad(89), da = .25, fa = {
1750
1880
  KeyD: [
1751
1881
  1,
1752
1882
  0,
@@ -1797,15 +1927,15 @@ var ua = class extends Sr {
1797
1927
  0,
1798
1928
  -1
1799
1929
  ]
1800
- }, _a = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=textbox], [role=combobox], [role=listbox], [role=menu], [role=menuitem]", va = (e) => e.shiftKey ? fa : e.altKey ? pa : 1, ya = { type: "change" }, ba = { type: "start" }, xa = new $(), Sa = new $(), Ca = new $(), wa = new $(), Ta = new Rr(), Ea = class extends vr {
1930
+ }, pa = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=textbox], [role=combobox], [role=listbox], [role=menu], [role=menuitem]", ma = (e) => e.shiftKey ? ca : e.altKey ? la : 1, ha = { type: "change" }, ga = { type: "start" }, _a = new $(), va = new $(), ya = new $(), ba = new $(), xa = new Sr(), Sa = class extends nr {
1801
1931
  constructor(e, t, n) {
1802
- super(e, t), this.orbit = n, this.enabled = !1, this.speed = 1 / da, 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);
1932
+ super(e, t), this.orbit = n, this.enabled = !1, this.speed = 1 / sa, 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);
1803
1933
  }
1804
1934
  get active() {
1805
1935
  return this.enabled && this.orbit.enabled;
1806
1936
  }
1807
1937
  fitSpeed(e) {
1808
- this.speed = (e > 0 ? e : 1) / da;
1938
+ this.speed = (e > 0 ? e : 1) / sa;
1809
1939
  }
1810
1940
  connect(e) {
1811
1941
  super.connect(e);
@@ -1825,34 +1955,34 @@ var ua = class extends Sr {
1825
1955
  if (!this._held.size || !this.active) return !1;
1826
1956
  let t = 0, n = 0, r = 0;
1827
1957
  for (let e of this._held) {
1828
- let [i, a, o] = ga[e];
1958
+ let [i, a, o] = fa[e];
1829
1959
  t += i, n += a, r += o;
1830
1960
  }
1831
1961
  if (!t && !n && !r) return !1;
1832
1962
  let i = this.object;
1833
- return Sa.set(1, 0, 0).applyQuaternion(i.quaternion), xa.crossVectors(i.up, Sa).normalize(), Sa.crossVectors(xa, i.up), Ca.set(0, 0, 0).addScaledVector(Sa, t).addScaledVector(xa, n).addScaledVector(i.up, r).normalize().multiplyScalar(this.speed * this._factor * e), i.position.add(Ca), this.orbit.target.add(Ca), i.updateMatrixWorld(), this.dispatchEvent(ya), !0;
1963
+ return va.set(1, 0, 0).applyQuaternion(i.quaternion), _a.crossVectors(i.up, va).normalize(), va.crossVectors(_a, i.up), ya.set(0, 0, 0).addScaledVector(va, t).addScaledVector(_a, n).addScaledVector(i.up, r).normalize().multiplyScalar(this.speed * this._factor * e), i.position.add(ya), this.orbit.target.add(ya), i.updateMatrixWorld(), this.dispatchEvent(ha), !0;
1834
1964
  }
1835
1965
  _elapsed() {
1836
- let e = performance.now(), t = Math.min((e - this._lastTime) / 1e3, ha);
1966
+ let e = performance.now(), t = Math.min((e - this._lastTime) / 1e3, da);
1837
1967
  return this._lastTime = e, t;
1838
1968
  }
1839
1969
  _look(e, t) {
1840
- let n = this.object, r = this.orbit.target, i = n.position.distanceTo(r) || 1, a = Or.degToRad(n.fov) / (this.domElement.clientHeight || 1);
1841
- n.quaternion.premultiply(Ta.setFromAxisAngle(n.up, e * a)), n.getWorldDirection(xa);
1842
- let o = Math.asin(Or.clamp(xa.dot(n.up), -1, 1)), s = Or.clamp(o + t * a, -ma, ma);
1843
- n.quaternion.multiply(Ta.setFromAxisAngle(wa.set(1, 0, 0), s - o)), n.updateMatrixWorld(), r.copy(n.position).addScaledVector(n.getWorldDirection(xa), i), this.dispatchEvent(ya);
1970
+ let n = this.object, r = this.orbit.target, i = n.position.distanceTo(r) || 1, a = fr.degToRad(n.fov) / (this.domElement.clientHeight || 1);
1971
+ n.quaternion.premultiply(xa.setFromAxisAngle(n.up, e * a)), n.getWorldDirection(_a);
1972
+ let o = Math.asin(fr.clamp(_a.dot(n.up), -1, 1)), s = fr.clamp(o + t * a, -ua, ua);
1973
+ n.quaternion.multiply(xa.setFromAxisAngle(ba.set(1, 0, 0), s - o)), n.updateMatrixWorld(), r.copy(n.position).addScaledVector(n.getWorldDirection(_a), i), this.dispatchEvent(ha);
1844
1974
  }
1845
1975
  _onKeyDown(e) {
1846
- if (!(!this.active || e.defaultPrevented || e.target?.closest?.(_a))) {
1976
+ if (!(!this.active || e.defaultPrevented || e.target?.closest?.(pa))) {
1847
1977
  if (e.metaKey || e.ctrlKey) {
1848
1978
  this.release();
1849
1979
  return;
1850
1980
  }
1851
- this._factor = va(e), ga[e.code] && (e.preventDefault(), !this._held.has(e.code) && (this._held.add(e.code), this._held.size === 1 && (this._lastTime = performance.now(), this.dispatchEvent(ba))));
1981
+ this._factor = ma(e), fa[e.code] && (e.preventDefault(), !this._held.has(e.code) && (this._held.add(e.code), this._held.size === 1 && (this._lastTime = performance.now(), this.dispatchEvent(ga))));
1852
1982
  }
1853
1983
  }
1854
1984
  _onKeyUp(e) {
1855
- this._factor = va(e), this._held.delete(e.code);
1985
+ this._factor = ma(e), this._held.delete(e.code);
1856
1986
  }
1857
1987
  release() {
1858
1988
  this._held.clear(), this._factor = 1;
@@ -1873,20 +2003,24 @@ var ua = class extends Sr {
1873
2003
  _onPointerUp(e) {
1874
2004
  this._drag?.id === e.pointerId && (this._drag = null, this.domElement.releasePointerCapture?.(e.pointerId));
1875
2005
  }
1876
- }, Da = Object.freeze(new $(1, 1, 1)), Oa = (e) => e?.isOrthographicCamera ? (e.top - e.bottom) / e.zoom : null, ka = class extends Sr {
2006
+ }, Ca = {
2007
+ autoFocusMode: "auto",
2008
+ afScreenPoint: {
2009
+ x: .5,
2010
+ y: .5
2011
+ },
2012
+ afSmoothingFactor: .15
2013
+ }, wa = .05, Ta = 10, Ea = .5, Da = Object.freeze(new $(1, 1, 1)), Oa = (e) => e?.isOrthographicCamera ? (e.top - e.bottom) / e.zoom : null, ka = class extends or {
1877
2014
  constructor(e) {
1878
2015
  super();
1879
2016
  let t = e.clientWidth, n = e.clientHeight;
1880
- this.camera = new _(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new Xr(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 Ea(this.camera, e, this.controls), this.interactionManager = null, this.cameras = [this.camera], this.currentCameraIndex = 0, this._userCameraCounter = 0, this.autoFocusMode = it.SMOOTHING_FACTOR ? "auto" : "manual", this.afScreenPoint = {
1881
- x: .5,
1882
- y: .5
1883
- }, this.afSmoothingFactor = it.SMOOTHING_FACTOR, 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;
2017
+ this.camera = new _(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new Pr(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 Sa(this.camera, e, this.controls), this.interactionManager = null, this.cameras = [this.camera], this.currentCameraIndex = 0, this._userCameraCounter = 0, this.autoFocusMode = Ca.autoFocusMode, this.afScreenPoint = { ...Ca.afScreenPoint }, this.afSmoothingFactor = Ca.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;
1884
2018
  }
1885
2019
  setCameras(e) {
1886
2020
  this.cameras = e, this._userCameraCounter = 0, this.resetAutoFocus();
1887
2021
  }
1888
2022
  addCameraFromView(e) {
1889
- let t = this.camera, n = t.orthographic ? new Fr(t.left, t.right, t.top, t.bottom, t.near, t.far) : new Ir(t.fov, t.aspect, t.near, t.far);
2023
+ let t = this.camera, n = t.orthographic ? new yr(t.left, t.right, t.top, t.bottom, t.near, t.far) : new br(t.fov, t.aspect, t.near, t.far);
1890
2024
  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;
1891
2025
  }
1892
2026
  removeCamera(e) {
@@ -1945,7 +2079,7 @@ var ua = class extends Sr {
1945
2079
  this.resetAutoFocus();
1946
2080
  let a = this.cameras[e], o = a?.userData?.__rayzeeEffects;
1947
2081
  this._showOrthographic(o ? o.orthoHeight : Oa(a)), this._applyEffects(o), n?.(), r?.(), this.dispatchEvent({
1948
- type: k.CAMERA_SWITCHED,
2082
+ type: j.CAMERA_SWITCHED,
1949
2083
  cameraIndex: e,
1950
2084
  effects: this._captureEffects(),
1951
2085
  fov: this.camera.fov,
@@ -1982,7 +2116,7 @@ var ua = class extends Sr {
1982
2116
  if (t.orthographic !== n) {
1983
2117
  if (n) this._setView(!0, this._fittedHalfHeight());
1984
2118
  else {
1985
- let e = this.controls.target, n = this.orthoHeight / 2 / Math.tan(Or.degToRad(t.fov) / 2);
2119
+ let e = this.controls.target, n = this.orthoHeight / 2 / Math.tan(fr.degToRad(t.fov) / 2);
1986
2120
  t.position.sub(e).setLength(n).add(e), this._setView(!1);
1987
2121
  }
1988
2122
  this.controls.update();
@@ -2002,13 +2136,13 @@ var ua = class extends Sr {
2002
2136
  n.orthographic = e, n.orthoHalfHeight = t, n.zoom = 1, n.updateProjectionMatrix(), this._reportOrthoHeight();
2003
2137
  }
2004
2138
  _fittedHalfHeight() {
2005
- return this.camera.position.distanceTo(this.controls.target) * Math.tan(Or.degToRad(this.camera.fov) / 2);
2139
+ return this.camera.position.distanceTo(this.controls.target) * Math.tan(fr.degToRad(this.camera.fov) / 2);
2006
2140
  }
2007
2141
  _reportOrthoHeight() {
2008
2142
  if (!this.camera.orthographic) return;
2009
2143
  let e = this.orthoHeight;
2010
2144
  e !== this._reportedOrthoHeight && (this._reportedOrthoHeight = e, this.dispatchEvent({
2011
- type: k.ORTHO_HEIGHT_UPDATED,
2145
+ type: j.ORTHO_HEIGHT_UPDATED,
2012
2146
  height: e
2013
2147
  }));
2014
2148
  }
@@ -2023,7 +2157,7 @@ var ua = class extends Sr {
2023
2157
  this.walkControls.release();
2024
2158
  let r = this.interactionManager?.pickSurface(0, 0);
2025
2159
  if (!r) return;
2026
- let i = Or.clamp(r.distance, n.minDistance, n.maxDistance);
2160
+ let i = fr.clamp(r.distance, n.minDistance, n.maxDistance);
2027
2161
  n.target.copy(this.camera.position).addScaledVector(this.camera.getWorldDirection(new $()), i), n.update();
2028
2162
  }
2029
2163
  get navigationMode() {
@@ -2079,7 +2213,7 @@ var ua = class extends Sr {
2079
2213
  let n = {
2080
2214
  index: t,
2081
2215
  name: e.name ?? "",
2082
- effects: ue(e.userData?.__rayzeeEffects) ?? null
2216
+ effects: je(e.userData?.__rayzeeEffects) ?? null
2083
2217
  };
2084
2218
  return t === 0 || !e.userData?.__rayzeeUserCamera ? n : {
2085
2219
  ...n,
@@ -2111,8 +2245,8 @@ var ua = class extends Sr {
2111
2245
  let n = /* @__PURE__ */ new Map();
2112
2246
  for (let r of e.cameras ?? []) {
2113
2247
  if (r.user) {
2114
- let e = r.orthographic ? new Fr(...r.frustum, r.near, r.far) : new Ir(r.fov, r.aspect, r.near, r.far);
2115
- 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 = Ee(r.effects), r.orbitTarget && (e.userData.__rayzeeOrbitTarget = new $().fromArray(r.orbitTarget)), n.set(r.index, this.cameras.length), this.cameras.push(e);
2248
+ let e = r.orthographic ? new yr(...r.frustum, r.near, r.far) : new br(r.fov, r.aspect, r.near, r.far);
2249
+ 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 = ye(r.effects), r.orbitTarget && (e.userData.__rayzeeOrbitTarget = new $().fromArray(r.orbitTarget)), n.set(r.index, this.cameras.length), this.cameras.push(e);
2116
2250
  continue;
2117
2251
  }
2118
2252
  let e = this.cameras[r.index];
@@ -2120,13 +2254,13 @@ var ua = class extends Sr {
2120
2254
  t.push(r.name);
2121
2255
  continue;
2122
2256
  }
2123
- n.set(r.index, r.index), r.effects && (e.userData.__rayzeeEffects = Ee(r.effects));
2257
+ n.set(r.index, r.index), r.effects && (e.userData.__rayzeeEffects = ye(r.effects));
2124
2258
  }
2125
2259
  this._userCameraCounter = this.cameras.filter((e) => e.userData?.__rayzeeUserCamera).length, this.currentCameraIndex = n.get(e.current) ?? 0;
2126
2260
  let r = e.defaultView;
2127
2261
  this._defaultCameraState = r ? {
2128
2262
  position: new $().fromArray(r.position),
2129
- quaternion: new Rr().fromArray(r.quaternion),
2263
+ quaternion: new Sr().fromArray(r.quaternion),
2130
2264
  scale: new $().fromArray(r.scale),
2131
2265
  fov: r.fov,
2132
2266
  near: r.near,
@@ -2139,7 +2273,7 @@ var ua = class extends Sr {
2139
2273
  e.position.fromArray(i.position), e.quaternion.fromArray(i.quaternion), e.scale.fromArray(i.scale), e.fov = i.fov, e.near = i.near, e.far = i.far, this._setView(i.orthographic, i.orthoHalfHeight), e.zoom = i.zoom ?? 1, e.updateProjectionMatrix(), e.updateMatrixWorld(!0), this.controls.target.fromArray(i.target), this.controls.update();
2140
2274
  }
2141
2275
  return e.autoFocus && (this.setAutoFocusMode(e.autoFocus.mode), this.setAFScreenPoint(e.autoFocus.point.x, e.autoFocus.point.y)), this.resetAutoFocus(), this._reportOrthoHeight(), this.dispatchEvent({
2142
- type: k.CAMERA_SWITCHED,
2276
+ type: j.CAMERA_SWITCHED,
2143
2277
  cameraIndex: this.currentCameraIndex,
2144
2278
  effects: this._captureEffects(),
2145
2279
  fov: this.camera.fov,
@@ -2175,7 +2309,7 @@ var ua = class extends Sr {
2175
2309
  if (!t || !this.interactionManager) return;
2176
2310
  let { assetLoader: n, currentFocusDistance: r, pathTracer: i, setFocusDistance: a, softReset: o, hardReset: s } = t;
2177
2311
  if (this.autoFocusMode === "manual") return;
2178
- if (!i?.enableDOF?.value || i.cameraProjection?.value === Qe.equirectangular) {
2312
+ if (!i?.enableDOF?.value || i.cameraProjection?.value === he.equirectangular) {
2179
2313
  this._afSuspended = !0;
2180
2314
  return;
2181
2315
  }
@@ -2183,25 +2317,25 @@ var ua = class extends Sr {
2183
2317
  let c = i;
2184
2318
  if (c?.isReady && c.renderMode?.value === 1 && c.frameCount > 0 && !c.isComplete) return;
2185
2319
  let l = this._pickFocusPoint(c.resetCount), u;
2186
- if (l) u = ca(l, this.camera), this._lastValidFocusDistance = u;
2320
+ if (l) u = ia(l, this.camera), this._lastValidFocusDistance = u;
2187
2321
  else if (this._lastValidFocusDistance !== null) u = this._lastValidFocusDistance;
2188
2322
  else {
2189
- let e = this.controls ? ca(this.controls.target, this.camera) : 0;
2190
- u = e > 0 ? e : it.FALLBACK_DISTANCE * (n?.getSceneScale() || 1), this._lastValidFocusDistance = u;
2323
+ let e = this.controls ? ia(this.controls.target, this.camera) : 0;
2324
+ u = e > 0 ? e : Ta * (n?.getSceneScale() || 1), this._lastValidFocusDistance = u;
2191
2325
  }
2192
2326
  let d = this._afPointDirty;
2193
- this._afPointDirty = !1, d || this._smoothedFocusDistance === null || this._smoothedFocusDistance === 0 || Math.abs(u - this._smoothedFocusDistance) / this._smoothedFocusDistance > it.SNAP_THRESHOLD ? this._smoothedFocusDistance = u : this._smoothedFocusDistance += this.afSmoothingFactor * (u - this._smoothedFocusDistance);
2327
+ this._afPointDirty = !1, d || this._smoothedFocusDistance === null || this._smoothedFocusDistance === 0 || Math.abs(u - this._smoothedFocusDistance) / this._smoothedFocusDistance > Ea ? this._smoothedFocusDistance = u : this._smoothedFocusDistance += this.afSmoothingFactor * (u - this._smoothedFocusDistance);
2194
2328
  let f = r, p = this._smoothedFocusDistance;
2195
2329
  if (d || f === 0 || Math.abs(p - f) / Math.max(f, .001) > .001) {
2196
2330
  a(p);
2197
2331
  let e = n?.getSceneScale() || 1;
2198
2332
  this.dispatchEvent({
2199
- type: k.AUTO_FOCUS_UPDATED,
2333
+ type: j.AUTO_FOCUS_UPDATED,
2200
2334
  distance: p / e,
2201
2335
  worldDistance: p
2202
2336
  });
2203
2337
  let t = Math.abs(p - f) / Math.max(f, .001);
2204
- d ? s?.() : t > it.RESET_THRESHOLD && o?.();
2338
+ d ? s?.() : t > wa && o?.();
2205
2339
  }
2206
2340
  }
2207
2341
  _pickFocusPoint(e) {
@@ -2211,8 +2345,8 @@ var ua = class extends Sr {
2211
2345
  resetCount: NaN,
2212
2346
  x: NaN,
2213
2347
  y: NaN,
2214
- view: new kr(),
2215
- projection: new kr()
2348
+ view: new pr(),
2349
+ projection: new pr()
2216
2350
  };
2217
2351
  if (this._afPointDirty || e !== i.resetCount || n !== i.x || r !== i.y || !i.view.equals(t.matrixWorld) || !i.projection.equals(t.projectionMatrix)) {
2218
2352
  let a = this.interactionManager.pickSurface(n * 2 - 1, 1 - r * 2);
@@ -2235,7 +2369,7 @@ var ua = class extends Sr {
2235
2369
  dispose() {
2236
2370
  this.walkControls?.dispose(), this.controls?.removeEventListener("change", this._reportOrthoHeight), this.controls?.dispose();
2237
2371
  }
2238
- }, Aa = .001, ja = 2, Ma = (e, t, n, r) => new e(t, n, r, Tr).createInterpolant(), Na = class {
2372
+ }, Aa = .001, ja = 2, Ma = (e, t, n, r) => new e(t, n, r, lr).createInterpolant(), Na = class {
2239
2373
  constructor(e, t) {
2240
2374
  this._cameraManager = e, this._onChange = t, this.keys = [], this._nextId = 1, this._interpolants = null;
2241
2375
  }
@@ -2310,7 +2444,7 @@ var ua = class extends Sr {
2310
2444
  orthoHeight: 0
2311
2445
  }) {
2312
2446
  if (!this.keys.length) return null;
2313
- let { position: n, target: r, fov: i, logHeight: a, start: o, end: s } = this._interpolants ??= this._build(), c = Or.clamp(e, o, s);
2447
+ let { position: n, target: r, fov: i, logHeight: a, start: o, end: s } = this._interpolants ??= this._build(), c = fr.clamp(e, o, s);
2314
2448
  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;
2315
2449
  }
2316
2450
  _build() {
@@ -2329,10 +2463,10 @@ var ua = class extends Sr {
2329
2463
  return {
2330
2464
  start: t,
2331
2465
  end: n,
2332
- position: Ma(Yr, ".position", e, i((e) => e.position)),
2333
- target: Ma(Yr, ".target", e, i((e) => e.target)),
2334
- fov: Ma(Nr, ".fov", e, r.map((e) => e.fov)),
2335
- logHeight: Ma(Nr, ".orthoHeight", e, r.map((e) => Math.log(e.orthoHeight)))
2466
+ position: Ma(Nr, ".position", e, i((e) => e.position)),
2467
+ target: Ma(Nr, ".target", e, i((e) => e.target)),
2468
+ fov: Ma(_r, ".fov", e, r.map((e) => e.fov)),
2469
+ logHeight: Ma(_r, ".orthoHeight", e, r.map((e) => Math.log(e.orthoHeight)))
2336
2470
  };
2337
2471
  }
2338
2472
  _changed() {
@@ -2349,9 +2483,9 @@ function Pa({ position: e, target: t, fov: n, orthoHeight: r }) {
2349
2483
  }
2350
2484
  //#endregion
2351
2485
  //#region src/managers/timeline/TimelineManager.js
2352
- var Fa = class extends Sr {
2486
+ var Fa = class extends or {
2353
2487
  constructor({ cameraManager: e, onReset: t }) {
2354
- super(), this._cameraManager = e, this._onReset = t, this.camera = new Na(e, () => this._changed("camera")), this._playback = null, this._timer = new Wr(), typeof document < "u" && this._timer.connect(document);
2488
+ super(), this._cameraManager = e, this._onReset = t, this.camera = new Na(e, () => this._changed("camera")), this._playback = null, this._timer = new Or(), typeof document < "u" && this._timer.connect(document);
2355
2489
  }
2356
2490
  get duration() {
2357
2491
  return this.camera.duration;
@@ -2383,7 +2517,7 @@ var Fa = class extends Sr {
2383
2517
  let e = this._playback;
2384
2518
  if (!e) return;
2385
2519
  this._timer.update(), e.elapsed += this._timer.getDelta();
2386
- let t = Or.clamp(e.elapsed, 0, this.duration);
2520
+ let t = fr.clamp(e.elapsed, 0, this.duration);
2387
2521
  this.seek(t), t >= this.duration && this.stop();
2388
2522
  }
2389
2523
  serialize() {
@@ -2400,7 +2534,7 @@ var Fa = class extends Sr {
2400
2534
  }
2401
2535
  _changed(e) {
2402
2536
  this.dispatchEvent({
2403
- type: k.TIMELINE_CHANGED,
2537
+ type: j.TIMELINE_CHANGED,
2404
2538
  track: e
2405
2539
  });
2406
2540
  }
@@ -2419,8 +2553,8 @@ var Fa = class extends Sr {
2419
2553
  let t = c.getImageData(0, 0, r, i);
2420
2554
  o.set(t.data, e * r * i * 4), performance.now() - l > 16 && (await new Promise((e) => setTimeout(e, 0)), l = performance.now());
2421
2555
  }
2422
- let u = new br(o, r, i, a);
2423
- u.minFilter = X, u.magFilter = X, u.format = Q, u.type = Gr, u.generateMipmaps = !1, u.needsUpdate = !0;
2556
+ let u = new ir(o, r, i, a);
2557
+ u.minFilter = X, u.magFilter = X, u.format = Q, u.type = kr, u.generateMipmaps = !1, u.needsUpdate = !0;
2424
2558
  let d = this.texture;
2425
2559
  return this.texture = u, this.entries = e.map((e, t) => ({
2426
2560
  name: e.name,
@@ -2436,7 +2570,7 @@ var Fa = class extends Sr {
2436
2570
  if (o.userData = o.userData || {}, t == null) delete o.userData.gobo;
2437
2571
  else {
2438
2572
  let e = this.entries.find((e) => e.name === t);
2439
- if (!e) return this._issues?.record(ht.ASSET_UNREACHABLE, `no gobo named "${t}" is loaded — the light projects without one`, {
2573
+ if (!e) return this._issues?.record(Ze.ASSET_UNREACHABLE, `no gobo named "${t}" is loaded — the light projects without one`, {
2440
2574
  name: t,
2441
2575
  asset: "gobo"
2442
2576
  }), !1;
@@ -2631,7 +2765,7 @@ var Ja = class {
2631
2765
  grid: Va(a, t, n)
2632
2766
  };
2633
2767
  } catch (t) {
2634
- return this._issues?.warn(ht.ASSET_UNREACHABLE, `IES profile "${e.name}" could not be loaded: ${t.message}`, {
2768
+ return this._issues?.warn(Ze.ASSET_UNREACHABLE, `IES profile "${e.name}" could not be loaded: ${t.message}`, {
2635
2769
  url: e.url,
2636
2770
  asset: "ies",
2637
2771
  cause: t.message
@@ -2657,8 +2791,8 @@ var Ja = class {
2657
2791
  lumens: i.lumens
2658
2792
  });
2659
2793
  }
2660
- let c = new br(o, t, n, i);
2661
- c.format = Q, c.type = Gr, c.minFilter = X, c.magFilter = X, c.generateMipmaps = !1, c.needsUpdate = !0;
2794
+ let c = new ir(o, t, n, i);
2795
+ c.format = Q, c.type = kr, c.minFilter = X, c.magFilter = X, c.generateMipmaps = !1, c.needsUpdate = !0;
2662
2796
  let l = this.texture;
2663
2797
  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 }) => ({
2664
2798
  name: e,
@@ -2682,7 +2816,7 @@ var Ja = class {
2682
2816
  if (t == null) delete i.userData.ies;
2683
2817
  else {
2684
2818
  let e = this.entries.find((e) => e.name === t);
2685
- if (!e) return this._issues?.record(ht.ASSET_UNREACHABLE, `no IES profile named "${t}" is loaded — the light keeps its plain distribution`, {
2819
+ if (!e) return this._issues?.record(Ze.ASSET_UNREACHABLE, `no IES profile named "${t}" is loaded — the light keeps its plain distribution`, {
2686
2820
  name: t,
2687
2821
  asset: "ies"
2688
2822
  }), a;
@@ -2717,7 +2851,7 @@ function Ya(e) {
2717
2851
  }
2718
2852
  //#endregion
2719
2853
  //#region src/Passes/OIDNDenoiser.js
2720
- var Xa = ft("oidn"), Za = 16, Qa = null;
2854
+ var Xa = Ke("oidn"), Za = 16, Qa = null;
2721
2855
  async function $a() {
2722
2856
  return Qa ||= (await import("oidn-web/dist/oidn.js")).initUNetFromBuffer, Qa;
2723
2857
  }
@@ -2847,7 +2981,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2847
2981
  if ( gid.x >= size.x || gid.y >= size.y ) { return; }
2848
2982
  dst[ gid.y * size.x + gid.x ] = textureLoad( src, gid.xy, 0 );
2849
2983
  }
2850
- `, mo = class extends Sr {
2984
+ `, mo = class extends or {
2851
2985
  constructor(e, t = {}) {
2852
2986
  if (super(), !e) throw Error("OIDNDenoiser requires a renderer");
2853
2987
  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 = {
@@ -2950,7 +3084,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2950
3084
  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;
2951
3085
  }
2952
3086
  _generateTzaUrl() {
2953
- let { oidnWeightsBaseUrl: e } = Ct(), { QUALITY_MODELS: t } = eo;
3087
+ let { oidnWeightsBaseUrl: e } = at(), { QUALITY_MODELS: t } = eo;
2954
3088
  return `${e}${(t[this.quality] || t.balance).model}.tza`;
2955
3089
  }
2956
3090
  async updateConfiguration(e) {
@@ -2968,7 +3102,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2968
3102
  continuous: e
2969
3103
  });
2970
3104
  let t = performance.now(), n = await this.execute(e);
2971
- return n && (this.renderer?.resetState?.(), this.lastDenoiseMs = performance.now() - t, Xa.debug(`denoise complete in ${ut.ms(this.lastDenoiseMs)} · quality ${this.quality}`)), n;
3105
+ return n && (this.renderer?.resetState?.(), this.lastDenoiseMs = performance.now() - t, Xa.debug(`denoise complete in ${We.ms(this.lastDenoiseMs)} · quality ${this.quality}`)), n;
2972
3106
  }
2973
3107
  async execute(e = !1) {
2974
3108
  if (!this.enabled || !this.unet) return !1;
@@ -3276,12 +3410,12 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3276
3410
  format: "rgba16float",
3277
3411
  usage: GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC
3278
3412
  });
3279
- let r = new Nn(this._outGPUTexture);
3413
+ let r = new gn(this._outGPUTexture);
3280
3414
  r.name = "oidn:output", r.image = {
3281
3415
  width: t,
3282
3416
  height: n,
3283
3417
  depth: 1
3284
- }, r.type = wr, r.format = Q, r.colorSpace = Mr, r.minFilter = Z, r.magFilter = Z, r.wrapS = gr, r.wrapT = gr, r.generateMipmaps = !1, r.flipY = !1, this._outTexture = r, this._outTexSize = {
3418
+ }, r.type = cr, r.format = Q, r.colorSpace = gr, r.minFilter = Z, r.magFilter = Z, r.wrapS = er, r.wrapT = er, r.generateMipmaps = !1, r.flipY = !1, this._outTexture = r, this._outTexSize = {
3285
3419
  width: t,
3286
3420
  height: n
3287
3421
  };
@@ -3460,7 +3594,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3460
3594
  var pick = -1;
3461
3595
  var movedFlag = 0;
3462
3596
 
3463
- if ( P.reset == 0u && g.w < ${$e.toFixed(1)} ) {
3597
+ if ( P.reset == 0u && g.w < ${Rr.toFixed(1)} ) {
3464
3598
 
3465
3599
  let size = vec2<f32>( P.size );
3466
3600
  let uv = ( vec2<f32>( gid.xy ) + 0.5 ) / size;
@@ -3894,7 +4028,7 @@ var Po = {
3894
4028
  }
3895
4029
  };
3896
4030
  function Fo() {
3897
- let { upscalerModelBaseUrl: e } = Ct(), t = {};
4031
+ let { upscalerModelBaseUrl: e } = at(), t = {};
3898
4032
  for (let n in Po) {
3899
4033
  t[n] = {};
3900
4034
  for (let r in Po[n]) t[n][r] = e + Po[n][r];
@@ -3914,10 +4048,10 @@ var Io = {
3914
4048
  }],
3915
4049
  graphOptimizationLevel: "all"
3916
4050
  }
3917
- }, Lo = class extends Sr {
4051
+ }, Lo = class extends or {
3918
4052
  constructor(e, t, n = {}) {
3919
4053
  if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
3920
- 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 || (() => dr), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.refreshInput = n.refreshInput || null, this.tileSize = n.tileSize || Io.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
4054
+ 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 || (() => Yn), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.refreshInput = n.refreshInput || null, this.tileSize = n.tileSize || Io.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
3921
4055
  isUpscaling: !1,
3922
4056
  isLoading: !1,
3923
4057
  abortController: null
@@ -3937,7 +4071,7 @@ var Io = {
3937
4071
  this._worker ||= new No(), await new Promise((e, n) => {
3938
4072
  let r = (t) => {
3939
4073
  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)));
3940
- }, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o, storage: s } = Ct();
4074
+ }, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o, storage: s } = at();
3941
4075
  this._worker.addEventListener("message", r), this._worker.postMessage({
3942
4076
  type: "load",
3943
4077
  url: t,
@@ -4057,13 +4191,13 @@ var Io = {
4057
4191
  let e = this.getGPUTextures();
4058
4192
  if (!e?.color) throw Error("No GPU color texture available for HDR capture");
4059
4193
  let t = e.color, { width: n, height: r } = t;
4060
- this._toneMapper ??= new Rt(this.renderer.backend.device, "aiupscaler-tonemap", {
4194
+ this._toneMapper ??= new xt(this.renderer.backend.device, "aiupscaler-tonemap", {
4061
4195
  input: "texture",
4062
4196
  output: "planar"
4063
4197
  }), this._toneMapper.ensureSize(n, r);
4064
4198
  let i = await this._toneMapper.toPlanar(t, {
4065
4199
  exposure: this.getExposure(),
4066
- toneMapping: this.getToneMapping() ?? dr,
4200
+ toneMapping: this.getToneMapping() ?? Yn,
4067
4201
  saturation: this.getSaturation()
4068
4202
  });
4069
4203
  return this._toneMapper.release(), {
@@ -4181,9 +4315,9 @@ var Io = {
4181
4315
  async dispose() {
4182
4316
  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");
4183
4317
  }
4184
- }, Ro = ft("neural"), zo = 120, Bo = 2, Vo = 1, Ho = 0, Uo = 300, Wo = 5, Go = 3, Ko = 3, qo = 16, Jo = (e) => Math.max(0, 1 - e / qo), Yo = class extends Sr {
4318
+ }, Ro = Ke("neural"), zo = 120, Bo = 2, Vo = 1, Ho = 0, Uo = 300, Wo = 5, Go = 3, Ko = 3, qo = 16, Jo = (e) => Math.max(0, 1 - e / qo), Yo = class extends or {
4185
4319
  constructor({ renderer: e, mainCanvas: t, stages: n, pipeline: r, getExposure: i, getSaturation: a, issues: o = null }) {
4186
- super(), this.renderer = e, this._issues = o, this.mainCanvas = t, this.upscalerCanvas = this._createUpscalerCanvas(t), this.pipeline = r, this._stages = n, this._getExposure = i, this._getSaturation = a, 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._finalQuality = nt.oidnQuality, this.finalDenoise = nt.enableOIDN, this.continuousDenoise = nt.continuousDenoise, this.continuousDenoiseInterval = nt.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 = nt.oidnTemporalHistory, this._history = null, this._historyDirty = !0, this._knownResetCount = 0, this._seenTracedFrames = 0, this._viewProj = new kr(), this._historyCamera = {
4320
+ super(), this.renderer = e, this._issues = o, this.mainCanvas = t, this.upscalerCanvas = this._createUpscalerCanvas(t), this.pipeline = r, this._stages = n, this._getExposure = i, this._getSaturation = a, 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._finalQuality = qr.oidnQuality, this.finalDenoise = qr.enableOIDN, this.continuousDenoise = qr.continuousDenoise, this.continuousDenoiseInterval = qr.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 = qr.oidnTemporalHistory, this._history = null, this._historyDirty = !0, this._knownResetCount = 0, this._seenTracedFrames = 0, this._viewProj = new pr(), this._historyCamera = {
4187
4321
  world: null,
4188
4322
  projInv: null,
4189
4323
  viewProj: null,
@@ -4192,7 +4326,7 @@ var Io = {
4192
4326
  count: 0,
4193
4327
  leaves: new Uint32Array(),
4194
4328
  toPrev: new Float32Array()
4195
- }, this._matA = new kr(), this._matB = new kr(), 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;
4329
+ }, this._matA = new pr(), this._matB = new pr(), 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;
4196
4330
  }
4197
4331
  _createUpscalerCanvas(e) {
4198
4332
  let t = e.parentNode;
@@ -4204,7 +4338,7 @@ var Io = {
4204
4338
  return (this.denoiser?.gpuBytes?.() ?? 0) + (this._history?.gpuBytes?.() ?? 0);
4205
4339
  }
4206
4340
  _recordNoOverlayCanvas(e) {
4207
- this._issues?.record(ht.DENOISER_UNAVAILABLE, `the ${e} pass needs the render canvas to be in a document, and it is not — skipped`, { pass: e });
4341
+ this._issues?.record(Ze.DENOISER_UNAVAILABLE, `the ${e} pass needs the render canvas to be in a document, and it is not — skipped`, { pass: e });
4208
4342
  }
4209
4343
  setRenderSize(e, t) {
4210
4344
  this._lastRenderWidth = e, this._lastRenderHeight = t, this._cadenceDowngraded = !1, this._holdWhileMoving = null, this._movingDenoiseMs.length = 0, this._movingHopeless = !1, this._historyDirty = !0, this.denoiser?.abort(), this._unpublishOutput(), this.denoiser?.setSize(e, t), this.upscalerCanvas && (this.upscalerCanvas.width !== e || this.upscalerCanvas.height !== t) && (this.upscalerCanvas.width = e, this.upscalerCanvas.height = t), this.upscaler?.setBaseSize(e, t), this._syncGBufferStages();
@@ -4215,7 +4349,8 @@ var Io = {
4215
4349
  setupDenoiser() {
4216
4350
  let e = this._stages.pathTracer;
4217
4351
  this.denoiser = new mo(this.renderer, {
4218
- ...nt,
4352
+ enableOIDN: qr.enableOIDN,
4353
+ oidnQuality: qr.oidnQuality,
4219
4354
  backendParams: () => ({
4220
4355
  device: this.renderer.backend.device,
4221
4356
  adapterInfo: null
@@ -4232,11 +4367,11 @@ var Io = {
4232
4367
  };
4233
4368
  }
4234
4369
  }), this._syncOIDNInUse(), this._denoiserStartHandler = (e) => this.dispatchEvent({
4235
- type: k.DENOISING_START,
4370
+ type: j.DENOISING_START,
4236
4371
  continuous: !!e.continuous
4237
4372
  }), this._denoiserEndHandler = (e) => {
4238
4373
  this.denoiser?.hasOutput && this._publishOutput(), this.dispatchEvent({
4239
- type: k.DENOISING_END,
4374
+ type: j.DENOISING_END,
4240
4375
  continuous: !!e.continuous
4241
4376
  });
4242
4377
  }, this._denoiserTileHandler = (e) => {
@@ -4244,7 +4379,7 @@ var Io = {
4244
4379
  this._publishOutput();
4245
4380
  let t = this.pipeline?.context;
4246
4381
  this._stages.compositor && t && this._stages.compositor.render(t);
4247
- }, this._denoiserErrorHandler = (e) => e.url && this._issues?.record(ht.ASSET_UNREACHABLE, `denoiser weights "${e.url}" could not be loaded — the render is not denoised`, {
4382
+ }, this._denoiserErrorHandler = (e) => e.url && this._issues?.record(Ze.ASSET_UNREACHABLE, `denoiser weights "${e.url}" could not be loaded — the render is not denoised`, {
4248
4383
  url: e.url,
4249
4384
  asset: "oidn-weights",
4250
4385
  cause: String(e.error?.message ?? e.error)
@@ -4254,8 +4389,8 @@ var Io = {
4254
4389
  if (!this.upscalerCanvas) return;
4255
4390
  let e = this._stages.pathTracer;
4256
4391
  this.upscaler = new Lo(this.upscalerCanvas, this.renderer, {
4257
- scaleFactor: nt.upscalerScale || 2,
4258
- quality: nt.upscalerQuality || "fast",
4392
+ scaleFactor: qr.upscalerScale || 2,
4393
+ quality: qr.upscalerQuality || "fast",
4259
4394
  getSourceCanvas: () => this.renderer.domElement,
4260
4395
  refreshInput: () => {
4261
4396
  let e = this.pipeline?.context;
@@ -4269,14 +4404,14 @@ var Io = {
4269
4404
  getExposure: () => this._getEffectiveExposure(),
4270
4405
  getToneMapping: () => this._getToneMapping(),
4271
4406
  getSaturation: () => this._getSaturation()
4272
- }), this.upscaler.enabled = nt.enableUpscaler || !1, this._upscalerResChangedHandler = (e) => this.dispatchEvent({
4273
- type: k.RESOLUTION_CHANGED,
4407
+ }), this.upscaler.enabled = qr.enableUpscaler || !1, this._upscalerResChangedHandler = (e) => this.dispatchEvent({
4408
+ type: j.RESOLUTION_CHANGED,
4274
4409
  width: e.width,
4275
4410
  height: e.height
4276
- }), this._upscalerStartHandler = () => this.dispatchEvent({ type: k.UPSCALING_START }), this._upscalerProgressHandler = (e) => this.dispatchEvent({
4277
- type: k.UPSCALING_PROGRESS,
4411
+ }), this._upscalerStartHandler = () => this.dispatchEvent({ type: j.UPSCALING_START }), this._upscalerProgressHandler = (e) => this.dispatchEvent({
4412
+ type: j.UPSCALING_PROGRESS,
4278
4413
  progress: e.progress
4279
- }), this._upscalerEndHandler = () => this.dispatchEvent({ type: k.UPSCALING_END }), this.upscaler.addEventListener("resolution_changed", this._upscalerResChangedHandler), this.upscaler.addEventListener("start", this._upscalerStartHandler), this.upscaler.addEventListener("progress", this._upscalerProgressHandler), this.upscaler.addEventListener("end", this._upscalerEndHandler);
4414
+ }), this._upscalerEndHandler = () => this.dispatchEvent({ type: j.UPSCALING_END }), this.upscaler.addEventListener("resolution_changed", this._upscalerResChangedHandler), this.upscaler.addEventListener("start", this._upscalerStartHandler), this.upscaler.addEventListener("progress", this._upscalerProgressHandler), this.upscaler.addEventListener("end", this._upscalerEndHandler);
4280
4415
  }
4281
4416
  get denoiserStrategy() {
4282
4417
  return this.continuousDenoise ? "oidn" : this._stages.asvgf?.enabled ? "asvgf" : this._stages.nrd?.enabled ? "nrd" : this._stages.edgeFilter?.enabled ? "edgeaware" : "none";
@@ -4389,7 +4524,7 @@ var Io = {
4389
4524
  }
4390
4525
  get historyActive() {
4391
4526
  let e = this._stages.pathTracer;
4392
- return this.historyWanted && !this._cadenceSuspended && !!this._stages.normalDepth?.enabled && e?.uniforms?.get("cameraProjection")?.value !== Qe.equirectangular && !(e?.visMode?.value > 0);
4527
+ return this.historyWanted && !this._cadenceSuspended && !!this._stages.normalDepth?.enabled && e?.uniforms?.get("cameraProjection")?.value !== he.equirectangular && !(e?.visMode?.value > 0);
4393
4528
  }
4394
4529
  beforeReset({ keepHistory: e = !1 } = {}) {
4395
4530
  let t = this._stages.pathTracer;
@@ -4471,7 +4606,7 @@ var Io = {
4471
4606
  let e = this._stages.pathTracer;
4472
4607
  this._viewProj.multiplyMatrices(e.cameraProjectionMatrix.value, e.cameraViewMatrix.value);
4473
4608
  let t = this._historyCamera;
4474
- 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 === Qe.orthographic, t;
4609
+ 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 === he.orthographic, t;
4475
4610
  }
4476
4611
  _ensureHistory() {
4477
4612
  return this._history ??= new Ao(this.renderer.backend.device), this._history.settings.cleanAux = !!this.denoiser?.expectsCleanAux(this._finalQuality), this._history;
@@ -4486,7 +4621,7 @@ var Io = {
4486
4621
  _restoreRenderDisplay() {
4487
4622
  let e = this.upscalerCanvas && this.upscalerCanvas.style.display !== "none";
4488
4623
  return this.upscalerCanvas && (this.upscalerCanvas.style.display = "none"), this.mainCanvas && (this.mainCanvas.style.opacity = "1"), e && this._lastRenderWidth && this._lastRenderHeight && this.dispatchEvent({
4489
- type: k.RESOLUTION_CHANGED,
4624
+ type: j.RESOLUTION_CHANGED,
4490
4625
  width: this._lastRenderWidth,
4491
4626
  height: this._lastRenderHeight
4492
4627
  }), !!e;
@@ -4514,11 +4649,11 @@ var Io = {
4514
4649
  Ro.warn("neural pass skipped: no denoised picture — it needs OIDN");
4515
4650
  return;
4516
4651
  }
4517
- this._neuralPostBusy = !0, this.dispatchEvent({ type: k.UPSCALING_START });
4652
+ this._neuralPostBusy = !0, this.dispatchEvent({ type: j.UPSCALING_START });
4518
4653
  try {
4519
- let r = await import("./NeuralSuperRes-BekaecYg.js").then((e) => e.t);
4654
+ let r = await import("./NeuralSuperRes-sZAeS142.js").then((e) => e.t);
4520
4655
  this._superResModule = r;
4521
- let i = n ? await import("./NeuralRetouch-CW11yLZ_.js").then((e) => e.t) : null, a = this.denoiser?._outTexSize, o = (a?.width ?? 0) * (a?.height ?? 0), s = n && o <= i.RETOUCH_MAX_PIXELS;
4656
+ let i = n ? await import("./NeuralRetouch-BCXylThH.js").then((e) => e.t) : null, a = this.denoiser?._outTexSize, o = (a?.width ?? 0) * (a?.height ?? 0), s = n && o <= i.RETOUCH_MAX_PIXELS;
4522
4657
  if (n && !s && (Ro.warn(`Neural rendering skipped: the render is ${(o / 1e6).toFixed(1)} MP, above the ${(i.RETOUCH_MAX_PIXELS / 1e6).toFixed(1)} MP the pass survives.` + (t ? " The upscale still ran." : "")), this._releaseNeuralRetouch()), !t && !s) return;
4523
4658
  let c = {
4524
4659
  exposure: this._getEffectiveExposure(),
@@ -4549,14 +4684,14 @@ var Io = {
4549
4684
  return;
4550
4685
  }
4551
4686
  this.mainCanvas && (this.mainCanvas.style.opacity = "0"), this.dispatchEvent({
4552
- type: k.RESOLUTION_CHANGED,
4687
+ type: j.RESOLUTION_CHANGED,
4553
4688
  width: u.width,
4554
4689
  height: u.height
4555
4690
  });
4556
4691
  } catch (e) {
4557
4692
  Ro.warn("neural pass failed", e);
4558
4693
  } finally {
4559
- this._neuralPostBusy = !1, this.dispatchEvent({ type: k.UPSCALING_END });
4694
+ this._neuralPostBusy = !1, this.dispatchEvent({ type: j.UPSCALING_END });
4560
4695
  }
4561
4696
  }
4562
4697
  }
@@ -4707,17 +4842,17 @@ var Io = {
4707
4842
  ].forEach((t) => e.removeTexture(t));
4708
4843
  }
4709
4844
  _applyNRDPreset(e) {
4710
- let t = ze[e];
4845
+ let t = Gr[e];
4711
4846
  if (!t) return;
4712
4847
  let n = {};
4713
- for (let e of st) n[e] = ct[e];
4848
+ for (let e of Wr) n[e] = Ur[e];
4714
4849
  this._stages.nrd?.updateParameters({
4715
4850
  ...n,
4716
4851
  ...t
4717
4852
  });
4718
4853
  }
4719
4854
  _applyASVGFPreset(e) {
4720
- let t = rt[e];
4855
+ let t = Br[e];
4721
4856
  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));
4722
4857
  }
4723
4858
  }, Xo = class {
@@ -4749,13 +4884,13 @@ var Io = {
4749
4884
  this.layer = "scene", this._enabled = !0, this._scene = e, this._camera = t, this._build([]);
4750
4885
  }
4751
4886
  _build(e) {
4752
- this._orthographic = this._camera.isOrthographicCamera === !0, this._outlineNode = Zr(this._scene, this._camera, {
4887
+ this._orthographic = this._camera.isOrthographicCamera === !0, this._outlineNode = Fr(this._scene, this._camera, {
4753
4888
  selectedObjects: e,
4754
- edgeThickness: G(1),
4755
- edgeGlow: G(0)
4889
+ edgeThickness: K(1),
4890
+ edgeGlow: K(0)
4756
4891
  });
4757
- let t = G(3), n = G(new _r(16777215)), r = G(new _r(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);
4758
- this._material = new Pn(), this._material.colorNode = J(o, s), this._material.transparent = !0, this._material.blending = yr, this._material.blendEquation = fr, this._material.blendSrc = Pr, this._material.blendDst = Pr, this._material.blendEquationAlpha = fr, this._material.blendSrcAlpha = Pr, this._material.blendDstAlpha = Pr, this._material.toneMapped = !1, this._material.depthTest = !1, this._material.depthWrite = !1, this._quad = new Fn(this._material);
4892
+ let t = K(3), n = K(new tr(16777215)), r = K(new tr(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);
4893
+ this._material = new _n(), this._material.colorNode = J(o, s), this._material.transparent = !0, this._material.blending = rr, this._material.blendEquation = Xn, this._material.blendSrc = vr, this._material.blendDst = vr, this._material.blendEquationAlpha = Xn, this._material.blendSrcAlpha = vr, this._material.blendDstAlpha = vr, this._material.toneMapped = !1, this._material.depthTest = !1, this._material.depthWrite = !1, this._quad = new vn(this._material);
4759
4894
  }
4760
4895
  setSelectedObjects(e) {
4761
4896
  this._outlineNode.selectedObjects = e;
@@ -4803,13 +4938,13 @@ var es = 4096, ts = class {
4803
4938
  }
4804
4939
  async init({ device: e, sizeSource: t }) {
4805
4940
  this._sizeSource = t;
4806
- let n = e.onuncapturederror, r = new Rn({
4941
+ let n = e.onuncapturederror, r = new xn({
4807
4942
  canvas: this.canvas,
4808
4943
  device: e,
4809
4944
  alpha: !0,
4810
4945
  antialias: (window.devicePixelRatio || 1) < 2
4811
4946
  });
4812
- return await r.init(), e.onuncapturederror = n, r.outputColorSpace = Vr, r.setPixelRatio(1), r.setClearColor(0, 0), r.autoClear = !1, this.renderer = r, this.syncSize(), this;
4947
+ return await r.init(), e.onuncapturederror = n, r.outputColorSpace = Tr, r.setPixelRatio(1), r.setClearColor(0, 0), r.autoClear = !1, this.renderer = r, this.syncSize(), this;
4813
4948
  }
4814
4949
  get isVisible() {
4815
4950
  return this._visible;
@@ -4826,9 +4961,9 @@ var es = 4096, ts = class {
4826
4961
  this._visible !== e && (this._visible = e, this.canvas.style.display = e ? "" : "none");
4827
4962
  }
4828
4963
  dispose() {
4829
- Ae(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
4964
+ Ie(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
4830
4965
  }
4831
- }, ns = ft("overlay"), rs = (e, t) => e.visible && e.layer === t && e.render, is = class {
4966
+ }, ns = Ke("overlay"), rs = (e, t) => e.visible && e.layer === t && e.render, is = class {
4832
4967
  constructor(e) {
4833
4968
  this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = Qo(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
4834
4969
  }
@@ -4860,7 +4995,7 @@ var es = 4096, ts = class {
4860
4995
  setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
4861
4996
  this.setHelperScene(e);
4862
4997
  let s = new Xo();
4863
- this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener(k.RESOLUTION_CHANGED, (e) => {
4998
+ this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener(j.RESOLUTION_CHANGED, (e) => {
4864
4999
  s.setRenderSize(e.width, e.height);
4865
5000
  }), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
4866
5001
  let c = new Zo(t, this.camera);
@@ -4954,18 +5089,18 @@ function as(e, t) {
4954
5089
  for (let e of n) e.traverse?.(() => i++);
4955
5090
  return i + n.length / 2 < r ? n : null;
4956
5091
  }
4957
- var os = class extends Sr {
5092
+ var os = class extends or {
4958
5093
  constructor() {
4959
- super(), this.mixer = null, this.timer = new Wr(), 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;
5094
+ super(), this.mixer = null, this.timer = new Or(), 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;
4960
5095
  }
4961
5096
  init(e, t, n, r) {
4962
5097
  if (this.dispose(), !r || r.length === 0) return;
4963
- this._scene = e, this._mixerRoot = t, this._meshes = n, this.mixer = new pr(t);
5098
+ this._scene = e, this._mixerRoot = t, this._meshes = n, this.mixer = new Zn(t);
4964
5099
  let i = r.map((e) => this.mixer.clipAction(e)), a = (e, t) => e.name === t || e.getObjectByName(t) !== void 0;
4965
5100
  !i.some((e) => e.getClip().tracks.some((e) => {
4966
5101
  let n = e.name.split(".")[0];
4967
5102
  return a(t, n);
4968
- })) && t !== e && (console.log("[AnimationManager] Tracks did not resolve from model root, retrying with scene root"), this.mixer = new pr(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", () => {
5103
+ })) && t !== e && (console.log("[AnimationManager] Tracks did not resolve from model root, retrying with scene root"), this.mixer = new Zn(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", () => {
4969
5104
  this.isPlaying = !1, this.timer.reset(), this.onFinished && this.onFinished();
4970
5105
  }), this._meshTriRanges = [], this._skinnedCache = [];
4971
5106
  let o = 0;
@@ -4989,7 +5124,7 @@ var os = class extends Sr {
4989
5124
  }), this._plans = e.map((e) => {
4990
5125
  let r = /* @__PURE__ */ new Set(), i = !1, a = !1;
4991
5126
  for (let o of e.tracks) {
4992
- let { nodeName: e, propertyName: s } = Lr.parseTrackName(o.name), c = e === "" || e === "." ? t : n.get(e);
5127
+ let { nodeName: e, propertyName: s } = xr.parseTrackName(o.name), c = e === "" || e === "." ? t : n.get(e);
4993
5128
  if (!c) {
4994
5129
  a = !0;
4995
5130
  continue;
@@ -5062,23 +5197,23 @@ var os = class extends Sr {
5062
5197
  if (!(!this.mixer || this.actions.length === 0)) {
5063
5198
  if (this.mixer.stopAllAction(), e === -1) for (let e of this.actions) e.play();
5064
5199
  else e >= 0 && e < this.actions.length && this.actions[e].play();
5065
- this._activeClip = e, this.timer.reset(), this.isPlaying = !0, this.wakeCallback?.(), this.dispatchEvent({ type: k.ANIMATION_STARTED });
5200
+ this._activeClip = e, this.timer.reset(), this.isPlaying = !0, this.wakeCallback?.(), this.dispatchEvent({ type: j.ANIMATION_STARTED });
5066
5201
  }
5067
5202
  }
5068
5203
  pause() {
5069
- this.mixer && (this.mixer.timeScale = 0, this.timer.reset(), this.isPlaying = !1, this.dispatchEvent({ type: k.ANIMATION_PAUSED }));
5204
+ this.mixer && (this.mixer.timeScale = 0, this.timer.reset(), this.isPlaying = !1, this.dispatchEvent({ type: j.ANIMATION_PAUSED }));
5070
5205
  }
5071
5206
  resume() {
5072
- this.mixer && (this.mixer.timeScale = this._savedTimeScale || 1, this.timer.reset(), this.isPlaying = !0, this.wakeCallback?.(), this.dispatchEvent({ type: k.ANIMATION_STARTED }));
5207
+ this.mixer && (this.mixer.timeScale = this._savedTimeScale || 1, this.timer.reset(), this.isPlaying = !0, this.wakeCallback?.(), this.dispatchEvent({ type: j.ANIMATION_STARTED }));
5073
5208
  }
5074
5209
  stop() {
5075
- this.mixer && (this.mixer.stopAllAction(), this.mixer.timeScale = this._savedTimeScale || 1, this.timer.reset(), this.isPlaying = !1, this._rigid && (this._mixerRoot.updateMatrixWorld(!0), this._applyRigidPose(-1)), this.dispatchEvent({ type: k.ANIMATION_STOPPED }));
5210
+ this.mixer && (this.mixer.stopAllAction(), this.mixer.timeScale = this._savedTimeScale || 1, this.timer.reset(), this.isPlaying = !1, this._rigid && (this._mixerRoot.updateMatrixWorld(!0), this._applyRigidPose(-1)), this.dispatchEvent({ type: j.ANIMATION_STOPPED }));
5076
5211
  }
5077
5212
  setSpeed(e) {
5078
5213
  this._savedTimeScale = e, this.mixer && this.isPlaying && (this.mixer.timeScale = e);
5079
5214
  }
5080
5215
  setLoop(e) {
5081
- let t = e ? Dr : Er;
5216
+ let t = e ? dr : ur;
5082
5217
  for (let n of this.actions) n.setLoop(t), n.clampWhenFinished = !e;
5083
5218
  }
5084
5219
  seekTo(e, t = 0) {
@@ -5164,7 +5299,7 @@ var os = class extends Sr {
5164
5299
  return e.isScene ? e : null;
5165
5300
  }, ls = class {
5166
5301
  constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
5167
- this._app = r, this._orbitControls = n, this._camera = e, this._controls = new Qr(e, t), this._gizmoScene = new Hr(), 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);
5302
+ this._app = r, this._orbitControls = n, this._camera = e, this._controls = new Ir(e, t), this._gizmoScene = new Er(), 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);
5168
5303
  }
5169
5304
  setMeshData(e) {
5170
5305
  this._meshes = e;
@@ -5184,7 +5319,7 @@ var os = class extends Sr {
5184
5319
  }
5185
5320
  setMode(e) {
5186
5321
  this._controls.setMode(e), this._app?.dispatchEvent({
5187
- type: k.TRANSFORM_MODE_CHANGED,
5322
+ type: j.TRANSFORM_MODE_CHANGED,
5188
5323
  mode: e
5189
5324
  }), this._app?.refreshFrame();
5190
5325
  }
@@ -5206,7 +5341,7 @@ var os = class extends Sr {
5206
5341
  e.autoClear = !1, e.clearDepth(), e.setRenderTarget(null), e.render(this._gizmoScene, this._camera), e.autoClear = t;
5207
5342
  }
5208
5343
  _onDraggingChanged(e) {
5209
- this._isDragging = e.value, this._orbitControls && (this._orbitControls.enabled = !e.value), e.value ? this._app.dispatchEvent({ type: k.OBJECT_TRANSFORM_START }) : (this._attached?.isLight ? this._finalizeLightTransform() : this._recomputeAndRefit(), this._app.dispatchEvent({ type: k.OBJECT_TRANSFORM_END }));
5344
+ this._isDragging = e.value, this._orbitControls && (this._orbitControls.enabled = !e.value), e.value ? this._app.dispatchEvent({ type: j.OBJECT_TRANSFORM_START }) : (this._attached?.isLight ? this._finalizeLightTransform() : this._recomputeAndRefit(), this._app.dispatchEvent({ type: j.OBJECT_TRANSFORM_END }));
5210
5345
  }
5211
5346
  _onObjectChange() {
5212
5347
  this._app.needsReset = !0, this._app.wake(), this._attached?.isLight && this._syncLightDuringDrag();
@@ -5339,7 +5474,7 @@ function vs(e) {
5339
5474
  e !== t && e.visible === !1 && r.push(ps(e, t));
5340
5475
  }), {
5341
5476
  v: 1,
5342
- engine: Me,
5477
+ engine: Ue,
5343
5478
  savedAt: Date.now(),
5344
5479
  scene: hs(e),
5345
5480
  appended: t.children.filter((t) => t !== e.sceneModel && t.userData?.__rayzeeSceneObject).map((e) => ({
@@ -5457,7 +5592,7 @@ async function Ss(e, t, { resolve: n = async () => null } = {}) {
5457
5592
  continue;
5458
5593
  }
5459
5594
  for (let [n, i] of Object.entries(r.props)) {
5460
- let a = Ee(i);
5595
+ let a = ye(i);
5461
5596
  ys(t, n, a), e.setMaterialProperty(r.index, n, a);
5462
5597
  }
5463
5598
  }
@@ -5489,9 +5624,10 @@ async function Ss(e, t, { resolve: n = async () => null } = {}) {
5489
5624
  }
5490
5625
  //#endregion
5491
5626
  //#region src/PathTracerApp.js
5492
- var Cs = ft("engine"), ws = class extends te {
5627
+ var Cs = Ke("engine"), ws = class extends te {
5493
5628
  constructor(e, t = {}) {
5494
- super(e, t), this.setColorManagement(mn), this.setStorageOpener(wn), this.settings.define("interactionRenderScale", {
5629
+ super(e, t), this.setColorManagement(Xt), this.setStorageOpener(sn), this.settings.define("interactionRenderScale", {
5630
+ default: .5,
5495
5631
  apply: () => {
5496
5632
  this.stages?.pathTracer?.interactionMode && this._requestRenderScale(this._interactionRenderScale());
5497
5633
  },
@@ -5505,7 +5641,7 @@ var Cs = ft("engine"), ws = class extends te {
5505
5641
  }), this.cameraManager.camera;
5506
5642
  }
5507
5643
  _initAssetPipeline() {
5508
- super._initAssetPipeline(), this.assetLoader.controls = this.cameraManager.controls, this.assetLoader.registerFormat(...Ht), this.assetLoader.setArchiveImporterLoader(() => import("./ArchiveImporter-xuUJiklP.js").then((e) => e.r).then((e) => new e.ArchiveImporter(this.assetLoader)), Vt);
5644
+ super._initAssetPipeline(), this.assetLoader.controls = this.cameraManager.controls, this.assetLoader.registerFormat(...Tt), this.assetLoader.setArchiveImporterLoader(() => import("./ArchiveImporter-BRQvLggb.js").then((e) => e.r).then((e) => new e.ArchiveImporter(this.assetLoader)), wt);
5509
5645
  let e = () => {
5510
5646
  this.needsReset = !0, this.stages.pathTracer?.enterInteractionMode(), this.wake();
5511
5647
  };
@@ -5513,10 +5649,10 @@ var Cs = ft("engine"), ws = class extends te {
5513
5649
  }
5514
5650
  _createExtraStages() {
5515
5651
  let { renderer: e, stages: t } = this;
5516
- return t.normalDepth = new $r(e, { pathTracer: t.pathTracer }), t.motionVector = new ei(e, this.camera, { pathTracer: t.pathTracer }), t.asvgf = new ri(e, { enabled: !1 }), t.nrd = new Vi(e, {
5652
+ return t.normalDepth = new Jr(e, { pathTracer: t.pathTracer }), t.motionVector = new Yr(e, this.camera, { pathTracer: t.pathTracer }), t.asvgf = new Qr(e, { enabled: !1 }), t.nrd = new Ii(e, {
5517
5653
  enabled: !1,
5518
5654
  pathTracer: t.pathTracer
5519
- }), t.variance = new Wi(e, { enabled: !1 }), t.bilateralFilter = new Ki(e, { enabled: !1 }), t.edgeFilter = new Qi(e, { enabled: !1 }), t.autoExposure = new aa(e, { enabled: nt.autoExposure ?? !1 }), [
5655
+ }), t.variance = new zi(e, { enabled: !1 }), t.bilateralFilter = new Vi(e, { enabled: !1 }), t.edgeFilter = new qi(e, { enabled: !1 }), t.autoExposure = new ta(e, { enabled: Ji.autoExposure }), [
5520
5656
  t.normalDepth,
5521
5657
  t.motionVector,
5522
5658
  t.nrd,
@@ -5531,7 +5667,7 @@ var Cs = ft("engine"), ws = class extends te {
5531
5667
  super._initPipeline(), this.pipeline.eventBus.on("pathtracer:interactionStart", () => this._requestRenderScale(this._interactionRenderScale())), this.pipeline.eventBus.on("pathtracer:interactionEnd", () => this._applyRenderScale(1));
5532
5668
  }
5533
5669
  async _initManagers() {
5534
- await super._initManagers(), this.environmentManager.setProceduralSkyLoader(() => import("./PhysicalSky-Dv2PMFGW.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 ua({
5670
+ await super._initManagers(), this.environmentManager.setProceduralSkyLoader(() => import("./PhysicalSky-BvqCw_dy.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 oa({
5535
5671
  scene: this.meshScene,
5536
5672
  camera: this.camera,
5537
5673
  canvas: this.canvas,
@@ -5558,20 +5694,20 @@ var Cs = ft("engine"), ws = class extends te {
5558
5694
  }), this.denoisingManager.setOverlayManager(this.overlayManager), this.denoisingManager.setResetCallback(() => this.reset()), this.denoisingManager.setPostProcessRefreshCallback(() => this.requestPostProcessRefresh()), this.denoisingManager.setDisplayRefreshCallback(() => this._presentDisplay()), this.denoisingManager.setSettings(this.settings);
5559
5695
  }
5560
5696
  _wireEvents() {
5561
- this._addTrackedListener(this.cameraManager, k.CAMERA_SWITCHED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.cameraManager, k.AUTO_FOCUS_UPDATED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.cameraManager, k.ORTHO_HEIGHT_UPDATED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.timeline, k.TIMELINE_CHANGED, (e) => this.dispatchEvent(e)), this._forwardEvents(this.denoisingManager, [
5562
- k.DENOISING_START,
5563
- k.DENOISING_END,
5564
- k.UPSCALING_START,
5565
- k.UPSCALING_PROGRESS,
5566
- k.UPSCALING_END,
5567
- k.RESOLUTION_CHANGED
5697
+ this._addTrackedListener(this.cameraManager, j.CAMERA_SWITCHED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.cameraManager, j.AUTO_FOCUS_UPDATED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.cameraManager, j.ORTHO_HEIGHT_UPDATED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.timeline, j.TIMELINE_CHANGED, (e) => this.dispatchEvent(e)), this._forwardEvents(this.denoisingManager, [
5698
+ j.DENOISING_START,
5699
+ j.DENOISING_END,
5700
+ j.UPSCALING_START,
5701
+ j.UPSCALING_PROGRESS,
5702
+ j.UPSCALING_END,
5703
+ j.RESOLUTION_CHANGED
5568
5704
  ]), this._setupAutoExposureListener(), this.animationManager.wakeCallback = () => this.wake(), this.animationManager.applyPoseCallback = (e) => this._applyAnimationPose(e), this._forwardEvents(this.animationManager, [
5569
- k.ANIMATION_STARTED,
5570
- k.ANIMATION_PAUSED,
5571
- k.ANIMATION_STOPPED
5572
- ]), this._addTrackedListener(this.animationManager, k.ANIMATION_PAUSED, () => {
5705
+ j.ANIMATION_STARTED,
5706
+ j.ANIMATION_PAUSED,
5707
+ j.ANIMATION_STOPPED
5708
+ ]), this._addTrackedListener(this.animationManager, j.ANIMATION_PAUSED, () => {
5573
5709
  this._animRefitInFlight = !1, this._refreshMovedEmitters();
5574
- }), this._addTrackedListener(this.animationManager, k.ANIMATION_STOPPED, () => {
5710
+ }), this._addTrackedListener(this.animationManager, j.ANIMATION_STOPPED, () => {
5575
5711
  this._animRefitInFlight = !1;
5576
5712
  }), this.cameraManager.initCallbacks({
5577
5713
  onResize: () => this.onResize(),
@@ -5721,7 +5857,7 @@ var Cs = ft("engine"), ws = class extends te {
5721
5857
  }
5722
5858
  _dispatchCamerasUpdated() {
5723
5859
  this.dispatchEvent({
5724
- type: k.CAMERAS_UPDATED,
5860
+ type: j.CAMERAS_UPDATED,
5725
5861
  cameras: this.cameraManager.cameras,
5726
5862
  cameraNames: this.cameraManager.getCameraNames()
5727
5863
  });
@@ -5775,8 +5911,8 @@ var Cs = ft("engine"), ws = class extends te {
5775
5911
  this._pendingRenderScale = null, !(this._disposed || e === this._renderScale) && (this._renderScale = e, !(!this._displayWidth || !this._displayHeight) && (this._setDisplaySize(this._displayWidth, this._displayHeight), this.pipeline?.setSize(this._scaled(this._displayWidth), this._scaled(this._displayHeight)), this.pipeline?.eventBus.emit("pipeline:historyReset"), this.needsReset = !0));
5776
5912
  }
5777
5913
  configureForMode(e, t = {}) {
5778
- let n = e === "production", r = n ? Fe : Ye;
5779
- this.denoisingManager?.setCadenceSuspended(n), this.timeline.stop(), this.cameraManager.controls.enabled = !n, this.settings.setMany(Be(r), {
5914
+ let n = e === "production", r = n ? we : ae;
5915
+ this.denoisingManager?.setCadenceSuspended(n), this.timeline.stop(), this.cameraManager.controls.enabled = !n, this.settings.setMany(re(r), {
5780
5916
  silent: !0,
5781
5917
  source: x.MODE_PRESET
5782
5918
  }), this.stages.pathTracer?.setUniform("renderMode", parseInt(r.renderMode)), n && this._applyRenderScale(1), this.stages.pathTracer?.updateCompletionThreshold?.();
@@ -5799,13 +5935,13 @@ var Cs = ft("engine"), ws = class extends te {
5799
5935
  let e = this.denoisingManager;
5800
5936
  if (await e?.denoiseOnce()) return !0;
5801
5937
  let t = e?.denoiser ? e.denoiser.enabled ? "the denoise did not complete" : "OIDN was off while accumulating — call denoisingManager.setOIDNEnabled( true ) first" : "the denoiser was not built";
5802
- return this._issues.record(ht.DENOISER_UNAVAILABLE, `final denoise produced no picture: ${t}`, { reason: t }), !1;
5938
+ return this._issues.record(Ze.DENOISER_UNAVAILABLE, `final denoise produced no picture: ${t}`, { reason: t }), !1;
5803
5939
  }
5804
5940
  _abortPostProcess({ keepDisplay: e = !1 } = {}) {
5805
5941
  if (this.denoisingManager?.abort(this.canvas, { keepDisplay: e }), this.denoisingManager?.restoreBaseResolution()) {
5806
5942
  let e = this.denoisingManager._lastRenderWidth, t = this.denoisingManager._lastRenderHeight;
5807
5943
  this.dispatchEvent({
5808
- type: k.RESOLUTION_CHANGED,
5944
+ type: j.RESOLUTION_CHANGED,
5809
5945
  width: e,
5810
5946
  height: t
5811
5947
  });
@@ -5833,7 +5969,7 @@ var Cs = ft("engine"), ws = class extends te {
5833
5969
  if (e.length > 0) {
5834
5970
  let t = this.sceneModel || this.meshScene;
5835
5971
  this.animationManager.init(this.meshScene, t, this._sdf.meshes, e), this.animationManager.onFinished = () => {
5836
- this._animRefitInFlight = !1, this._refreshMovedEmitters(), this.dispatchEvent({ type: k.ANIMATION_FINISHED });
5972
+ this._animRefitInFlight = !1, this._refreshMovedEmitters(), this.dispatchEvent({ type: j.ANIMATION_FINISHED });
5837
5973
  };
5838
5974
  }
5839
5975
  this.transformManager?.setMeshData(this._sdf.meshes);
@@ -5865,7 +6001,7 @@ var Cs = ft("engine"), ws = class extends te {
5865
6001
  _setupAutoExposureListener() {
5866
6002
  this.stages.autoExposure && this.stages.autoExposure.on("autoexposure:updated", (e) => {
5867
6003
  this.dispatchEvent({
5868
- type: k.AUTO_EXPOSURE_UPDATED,
6004
+ type: j.AUTO_EXPOSURE_UPDATED,
5869
6005
  exposure: e.exposure,
5870
6006
  luminance: e.luminance
5871
6007
  });
@@ -5890,7 +6026,7 @@ var Cs = ft("engine"), ws = class extends te {
5890
6026
  }
5891
6027
  _recalibrateControlLimits() {
5892
6028
  if (!this.meshScene || !this.cameraManager) return;
5893
- let e = new hr(), t = new hr();
6029
+ let e = new $n(), t = new $n();
5894
6030
  for (let n of this.meshScene.children) n.userData?.__rayzeeSceneObject && (t.setFromObject(n), t.isEmpty() || e.union(t));
5895
6031
  if (e.isEmpty()) return;
5896
6032
  let n = Math.max(e.max.x - e.min.x, e.max.y - e.min.y, e.max.z - e.min.z);
@@ -5930,18 +6066,17 @@ async function Es(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire
5930
6066
  provenance: e.getProvenance()
5931
6067
  };
5932
6068
  }
5933
- async function Ds({ canvas: e, model: t = null, width: n = 1920, height: r = 1080, strict: i = !0, profile: a = "physical", deterministic: o = !0, settings: s = null, storage: c = !1, hostMemoryGB: l = void 0 } = {}) {
5934
- let u = new ws(e ?? null, {
6069
+ async function Ds({ 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 } = {}) {
6070
+ let l = new ws(e ?? null, {
5935
6071
  autoResize: !1,
5936
6072
  strict: i,
5937
- profile: a,
5938
- storage: c,
5939
- hostMemoryGB: l
6073
+ storage: s,
6074
+ hostMemoryGB: c
5940
6075
  });
5941
6076
  try {
5942
- return u.setReservedRenderResolution(Math.max(n, r)), await u.init(), u.setCanvasSize(n, r), t && await u.loadModel(t), s && u.settings.setMany(s, { silent: !0 }), o && u.setDeterministicMode(!0), u;
6077
+ return l.setReservedRenderResolution(Math.max(n, r)), await l.init(), l.setCanvasSize(n, r), o && l.settings.setMany(o, { silent: !0 }), t && await l.loadModel(t), o && l.settings.setMany(o, { silent: !0 }), a && l.setDeterministicMode(!0), l;
5943
6078
  } catch (e) {
5944
- throw u.dispose(), e;
6079
+ throw l.dispose(), e;
5945
6080
  }
5946
6081
  }
5947
6082
  //#endregion
@@ -5951,7 +6086,7 @@ var Os = class {
5951
6086
  this._app = e, this._cancelled = !1, this._rendering = !1;
5952
6087
  }
5953
6088
  async renderAnimation(e = {}) {
5954
- let { clipIndex: t = 0, fps: n = 30, speed: r = 1, samplesPerFrame: i = Fe.maxSamples, enableOIDN: a = !0, timeline: o = null, startFrame: s = 0, onFrame: c, onProgress: l, onComplete: u } = e, d = this._app, f = d.animationManager?.hasAnimations ? d.animationManager.clips[t] : null;
6089
+ let { clipIndex: t = 0, fps: n = 30, speed: r = 1, samplesPerFrame: i = we.maxSamples, enableOIDN: a = !0, timeline: o = null, startFrame: s = 0, onFrame: c, onProgress: l, onComplete: u } = e, d = this._app, f = d.animationManager?.hasAnimations ? d.animationManager.clips[t] : null;
5955
6090
  if (!f && !o?.animates) {
5956
6091
  console.warn(d.animationManager?.hasAnimations ? `VideoRenderManager: Invalid clip index ${t}` : "VideoRenderManager: No animation clips or keyframes"), u?.(!1);
5957
6092
  return;
@@ -5979,7 +6114,7 @@ var Os = class {
5979
6114
  percent: (e + 1) / m * 100
5980
6115
  };
5981
6116
  l?.(u), d.dispatchEvent({
5982
- type: k.VIDEO_RENDER_PROGRESS,
6117
+ type: j.VIDEO_RENDER_PROGRESS,
5983
6118
  ...u
5984
6119
  });
5985
6120
  }
@@ -5989,7 +6124,7 @@ var Os = class {
5989
6124
  this._restoreState(g), this._rendering = !1;
5990
6125
  let e = !this._cancelled;
5991
6126
  u?.(e), d.dispatchEvent({
5992
- type: k.VIDEO_RENDER_COMPLETE,
6127
+ type: j.VIDEO_RENDER_COMPLETE,
5993
6128
  success: e
5994
6129
  });
5995
6130
  }
@@ -6008,26 +6143,26 @@ var Os = class {
6008
6143
  await n;
6009
6144
  continue;
6010
6145
  }
6011
- e.cameraManager.camera.updateMatrixWorld(), e.pipeline.render(), t.frameCount % 4 == 0 && (ke({ samples: je(t) }), await new Promise((e) => setTimeout(e, 0)));
6146
+ e.cameraManager.camera.updateMatrixWorld(), e.pipeline.render(), t.frameCount % 4 == 0 && (Ve({ samples: Fe(t) }), await new Promise((e) => setTimeout(e, 0)));
6012
6147
  }
6013
6148
  }
6014
6149
  _waitForDenoise(e) {
6015
6150
  return new Promise((t) => {
6016
6151
  let n, r = () => {
6017
- e.removeEventListener(k.DENOISING_END, i), clearTimeout(n);
6152
+ e.removeEventListener(j.DENOISING_END, i), clearTimeout(n);
6018
6153
  }, i = () => {
6019
6154
  r(), t();
6020
6155
  };
6021
6156
  n = setTimeout(() => {
6022
6157
  console.warn("VideoRenderManager: Denoise timed out, skipping"), r(), t();
6023
- }, 3e4), e.addEventListener(k.DENOISING_END, i), e.denoisingManager.onRenderComplete({
6158
+ }, 3e4), e.addEventListener(j.DENOISING_END, i), e.denoisingManager.onRenderComplete({
6024
6159
  isStillComplete: () => !this._cancelled,
6025
6160
  context: e.pipeline?.context
6026
6161
  });
6027
6162
  });
6028
6163
  }
6029
6164
  _saveState({ view: e }) {
6030
- let t = this._app, n = t.settings.getEffective(), r = Object.keys(Be(Fe));
6165
+ let t = this._app, n = t.settings.getEffective(), r = Object.keys(re(we));
6031
6166
  return e && r.push("focusDistance"), {
6032
6167
  view: e ? t.cameraManager.captureView() : null,
6033
6168
  settings: r.map((e) => [e, n[e]]),
@@ -6050,4 +6185,4 @@ var Os = class {
6050
6185
  }
6051
6186
  };
6052
6187
  //#endregion
6053
- export { it as AF_DEFAULTS, Vt as ARCHIVE_FORMATS, rt as ASVGF_QUALITY_PRESETS, Xe as AUTO_FOCUS_MODES, os as AnimationManager, tt as BVH_LEAF_MARKERS, Ke as CAMERA_PRESETS, at as CAMERA_RANGES, ka as CameraManager, Na as CameraTrack, mn as ColorManagement, tn as DEFAULT_LUT_SIZE, dn as DEFAULT_MAX_EV, cn as DEFAULT_MIN_EV, qe as DEFAULT_SUN_PATH, Je as DEFAULT_TEXTURE_MATRIX, St as DEFAULT_WORKING_SPACE, C as DOWNLOAD_POLICY, Yo as DenoisingManager, f as DownloadCache, yt as ENGINE_AREAS, nt as ENGINE_DEFAULTS, k as EngineEvents, _t as EngineIssueError, Ia as GoboManager, Ja as IESManager, Ye as INTERACTIVE_RENDER_CONFIG, ht as ISSUE_CODES, gt as ISSUE_SEVERITY, ua as InteractionManager, mt as IssueLog, Oe as LEGACY_EVENT_NAMES, pt as LOG_LEVELS, ee as LightManager, dt as Logger, We as MATERIAL_DEFAULTS, T as MATERIAL_VALUE_SOURCE, ot as MAX_RESERVABLE_RENDER_SIZE, ye as MAX_SCENE_BYTES, jt as MAX_TABLE_TRANSFORMS, Ge as MEMORY_CONSTANTS, we as MemoryLedger, ct as NRD_DEFAULTS, Re as NRD_HIT_DIST_A, Ne as NRD_HIT_DIST_B, st as NRD_PRESET_KEYS, ze as NRD_QUALITY_PRESETS, Nt as OCIO_VIEW_BASE, is as OverlayManager, Fe as PRODUCTION_RENDER_CONFIG, ws as PathTracerApp, u as PipelineContext, Pe as RENDER_PROFILES, jn as RETOUCH_DEFAULTS, Mn as RETOUCH_MAX_PIXELS, An as RETOUCH_RANGES, te as RayzeeRenderer, S as RenderPipeline, d as RenderSettings, E as RenderStage, me as SAFE_SCENE_BYTES, ds as SCENE_STATE_VERSION, x as SETTING_SOURCE, Ie as SKY_PRESETS, On as SR_MAX_INPUT, kn as SR_SCALE, vt as STORAGE_KIND, D as StageExecutionMode, Cn as StorageManager, Ze as TEXTURE_CONSTANTS, Le as TRIANGLE_DATA_LAYOUT, Fa as TimelineManager, ls as TransformManager, Me as VERSION, kt as VIEW_TRANSFORMS, he as VRAMTracker, Os as VideoRenderManager, bn as acquireLock, rn as addAllOcioViews, nn as addOcioView, Tt as addViewTransform, vn as applyMatrixRGBA8, gn as bakeLut, Ce as bufferBytes, Xt as buildOcioView, Mt as buildToneMapWGSL, v as cachedObjectURL, ln as canvasColorSpaceFor, Es as captureHeadless, y as clearBindingAuditFindings, Zt as clearInputOverrides, wt as configureAssets, _e as configurePlatform, Jt as convertColor, Wt as convertEncodedRGBA8, _n as convertPixelsF32, ft as createLogger, He as dayOfYearForMonth, Te as deriveAlphaMode, b as describeAdapter, Ut as displayCanvasFit, Se as estimateSceneBytes, Yt as extractMatrix, zt as extractSceneMetadata, w as fetchFile, It as fileIdentity, fn as findNativeLinearSpace, ut as fmt, Ee as fromPortable, xt as getActiveColorManagement, Ct as getAssetConfig, g as getBindingAuditFindings, ge as getPlatform, Et as getRegistryVersion, lt as getRenderProfile, At as getViewTransform, Kt as hasColorSpace, xn as heldLockNames, Lt as identityKey, an as isColorManaged, Gt as isDataSpace, un as isDataTexture, qt as linearToSrgb, pn as listFileRules, $t as listInputOverrides, Pt as listViewTransforms, yn as makeCpuSampler, Qt as measureBakeError, p as nameFromUrl, Dt as onRegistryChange, Ds as openHeadless, Sn as openStorage, En as openZip, Bt as parseSceneMetadata, be as probeAddressSpace, Tn as readZipDirectory, Ot as removeViewTransform, Ts as renderHeadless, Dn as renderUpscaled, sn as resolveInputSpace, Ft as sameIdentity, bt as setActiveColorManagement, h as setBindingAudit, hn as setInputOverride, on as srgbToLinear, Ve as sunPosition, xe as textureBytes, en as textureInputSpace, Ue as timeForSunElevation, ue as toPortable };
6188
+ export { wt as ARCHIVE_FORMATS, Br as ASVGF_QUALITY_PRESETS, Ji as AUTO_EXPOSURE_DEFAULTS, Ca as AUTO_FOCUS_DEFAULTS, os as AnimationManager, Je as BVH_LEAF_MARKERS, ka as CameraManager, Na as CameraTrack, Xt as ColorManagement, Rt as DEFAULT_LUT_SIZE, qt as DEFAULT_MAX_EV, Wt as DEFAULT_MIN_EV, Te as DEFAULT_SUN_PATH, gt as DEFAULT_VIEW, it as DEFAULT_WORKING_SPACE, qr as DENOISER_DEFAULTS, C as DOWNLOAD_POLICY, Yo as DenoisingManager, f as DownloadCache, tt as ENGINE_AREAS, oe as ENGINE_DEFAULTS, j as EngineEvents, $e as EngineIssueError, Ia as GoboManager, Ja as IESManager, ae as INTERACTIVE_RENDER_CONFIG, Ze as ISSUE_CODES, Qe as ISSUE_SEVERITY, oa as InteractionManager, Xe as IssueLog, Pe as LEGACY_EVENT_NAMES, qe as LOG_LEVELS, ee as LightManager, Ge as Logger, ue as MATERIAL_DEFAULTS, me as MATERIAL_VALUE_SOURCE, D as MAX_RESERVABLE_RENDER_SIZE, Be as MAX_SCENE_BYTES, mt as MAX_TABLE_TRANSFORMS, Le as MemoryLedger, Ur as NRD_DEFAULTS, Vr as NRD_HIT_DIST_A, Hr as NRD_HIT_DIST_B, Wr as NRD_PRESET_KEYS, Gr as NRD_QUALITY_PRESETS, ut as OCIO_VIEW_BASE, is as OverlayManager, we as PRODUCTION_RENDER_CONFIG, ws as PathTracerApp, u as PipelineContext, mn as RETOUCH_DEFAULTS, hn as RETOUCH_MAX_PIXELS, pn as RETOUCH_RANGES, te as RayzeeRenderer, S as RenderPipeline, d as RenderSettings, E as RenderStage, Re as SAFE_SCENE_BYTES, ds as SCENE_STATE_VERSION, x as SETTING_SOURCE, Ae as SKY_DEFAULTS, dn as SR_MAX_INPUT, fn as SR_SCALE, et as STORAGE_KIND, ge as StageExecutionMode, on as StorageManager, Ye as TRIANGLE_DATA_LAYOUT, Fa as TimelineManager, ls as TransformManager, Ue as VERSION, st as VIEW_TRANSFORMS, xe as VRAMTracker, Os as VideoRenderManager, nn as acquireLock, Bt as addAllOcioViews, zt as addOcioView, ft as addViewTransform, en as applyMatrixRGBA8, Qt as bakeLut, ke as bufferBytes, Nt as buildOcioView, ht as buildToneMapWGSL, v as cachedObjectURL, Gt as canvasColorSpaceFor, Es as captureHeadless, y as clearBindingAuditFindings, Pt as clearInputOverrides, ot as configureAssets, Ee as configurePlatform, jt as convertColor, Dt as convertEncodedRGBA8, $t as convertPixelsF32, Ke as createLogger, be as dayOfYearForMonth, ie as deriveAlphaMode, b as describeAdapter, Et as displayCanvasFit, ze as estimateSceneBytes, Mt as extractMatrix, St as extractSceneMetadata, w as fetchFile, yt as fileIdentity, Jt as findNativeLinearSpace, We as fmt, ye as fromPortable, rt as getActiveColorManagement, at as getAssetConfig, g as getBindingAuditFindings, Ce as getPlatform, dt as getRegistryVersion, _t as getViewTransform, kt as hasColorSpace, rn as heldLockNames, bt as identityKey, Vt as isColorManaged, Ot as isDataSpace, Kt as isDataTexture, At as linearToSrgb, Yt as listFileRules, It as listInputOverrides, ct as listViewTransforms, tn as makeCpuSampler, Ft as measureBakeError, p as nameFromUrl, pt as onRegistryChange, Ds as openHeadless, an as openStorage, ln as openZip, Ct as parseSceneMetadata, He as probeAddressSpace, cn as readZipDirectory, lt as removeViewTransform, Ts as renderHeadless, un as renderUpscaled, Ut as resolveInputSpace, vt as sameIdentity, nt as setActiveColorManagement, h as setBindingAudit, Zt as setInputOverride, Ht as srgbToLinear, Se as sunPosition, De as textureBytes, Lt as textureInputSpace, Oe as timeForSunElevation, je as toPortable };