rayzee 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rayzee.es.js CHANGED
@@ -1,23 +1,23 @@
1
1
  import { MeshBasicNodeMaterial as e, QuadMesh as t, ReadbackBuffer as n, RectAreaLightNode as r, RenderTarget as i, SRGBColorSpace as a, StorageInstancedBufferAttribute as o, StorageTexture as s, TextureNode as c, WebGPUBackend as l, WebGPURenderer as u } from "three/webgpu";
2
2
  import { Break as d, Continue as f, Fn as p, If as m, Loop as h, TWO_PI as g, abs as _, acos as v, array as y, atan as b, atomicAdd as x, atomicLoad as S, atomicStore as C, attributeArray as w, bool as T, clamp as E, cos as D, cross as O, cubeTexture as k, dot as A, exp as j, float as M, floor as ee, fract as te, int as N, ivec2 as P, length as ne, lessThan as re, localId as F, log as ie, mat3 as ae, max as I, min as oe, mix as L, mod as se, normalize as R, notEqual as ce, pow as le, reflect as ue, refract as de, sampler as fe, select as z, sign as pe, sin as me, smoothstep as he, sqrt as ge, step as _e, storage as ve, struct as ye, texture as be, textureLoad as B, textureStore as xe, uint as V, uniform as H, uniformArray as Se, uv as Ce, uvec2 as we, vec2 as U, vec3 as W, vec4 as G, wgslFn as K, workgroupArray as Te, workgroupBarrier as Ee, workgroupId as De } from "three/tsl";
3
- import { ACESFilmicToneMapping as Oe, AdditiveBlending as ke, AgXToneMapping as Ae, AnimationMixer as je, BackSide as Me, Box2 as Ne, Box3 as Pe, CineonToneMapping as Fe, CircleGeometry as Ie, ClampToEdgeWrapping as Le, Color as Re, DataArrayTexture as ze, DataTexture as Be, DataUtils as Ve, DirectionalLight as He, DirectionalLightHelper as Ue, DoubleSide as We, EquirectangularReflectionMapping as Ge, EventDispatcher as Ke, FloatType as qe, FrontSide as Je, HalfFloatType as Ye, LinearFilter as q, LinearSRGBColorSpace as Xe, LinearToneMapping as Ze, LoadingManager as Qe, LoopOnce as $e, LoopRepeat as et, MathUtils as tt, Matrix3 as nt, Matrix4 as rt, Mesh as it, MeshBasicMaterial as at, MeshPhysicalMaterial as ot, MeshStandardMaterial as st, NearestFilter as J, NeutralToneMapping as ct, NoBlending as lt, NoToneMapping as ut, Object3D as dt, PerspectiveCamera as ft, PointLight as pt, PointLightHelper as mt, Points as ht, PointsMaterial as gt, Quaternion as _t, RGBAFormat as vt, Raycaster as yt, RectAreaLight as bt, ReinhardToneMapping as xt, RepeatWrapping as St, SRGBColorSpace as Ct, Scene as wt, SphereGeometry as Tt, SpotLight as Et, SpotLightHelper as Dt, TextureLoader as Ot, Timer as kt, TimestampQuery as At, UnsignedByteType as jt, Vector2 as Mt, Vector3 as Nt } from "three";
4
- import { RectAreaLightTexturesLib as Pt } from "three/addons/lights/RectAreaLightTexturesLib.js";
5
- import { RectAreaLightHelper as Ft } from "three/addons/helpers/RectAreaLightHelper.js";
6
- import { GLTFLoader as It } from "three/addons/loaders/GLTFLoader.js";
7
- import { HDRLoader as Lt } from "three/addons/loaders/HDRLoader.js";
8
- import { DRACOLoader as Rt } from "three/addons/loaders/DRACOLoader.js";
9
- import { KTX2Loader as zt } from "three/addons/loaders/KTX2Loader.js";
10
- import { EXRLoader as Bt } from "three/addons/loaders/EXRLoader.js";
11
- import { createMeshesFromMultiMaterialMesh as Vt } from "three/addons/utils/SceneUtils.js";
12
- import { MeshoptDecoder as Ht } from "three/addons/libs/meshopt_decoder.module.js";
13
- import { strFromU8 as Ut, unzipSync as Wt } from "three/addons/libs/fflate.module.js";
14
- import { OrbitControls as Gt } from "three/addons/controls/OrbitControls.js";
15
- import { outline as Kt } from "three/addons/tsl/display/OutlineNode.js";
16
- import { TransformControls as qt } from "three/addons/controls/TransformControls.js";
3
+ import { ACESFilmicToneMapping as Oe, AdditiveBlending as ke, AgXToneMapping as Ae, AnimationMixer as je, BackSide as Me, Box2 as Ne, Box3 as Pe, CineonToneMapping as Fe, CircleGeometry as Ie, ClampToEdgeWrapping as Le, Color as Re, DataArrayTexture as ze, DataTexture as Be, DataUtils as Ve, DirectionalLight as He, DirectionalLightHelper as Ue, DoubleSide as We, EquirectangularReflectionMapping as Ge, EventDispatcher as Ke, FloatType as qe, FrontSide as Je, HalfFloatType as Ye, LinearFilter as q, LinearSRGBColorSpace as Xe, LinearToneMapping as Ze, LoadingManager as Qe, LoopOnce as $e, LoopRepeat as et, MathUtils as tt, Matrix3 as nt, Matrix4 as rt, Mesh as it, MeshBasicMaterial as at, MeshPhysicalMaterial as ot, MeshStandardMaterial as st, NearestFilter as ct, NeutralToneMapping as lt, NoBlending as ut, NoToneMapping as dt, Object3D as ft, PerspectiveCamera as pt, PointLight as mt, PointLightHelper as ht, Points as gt, PointsMaterial as _t, Quaternion as vt, RGBAFormat as yt, Raycaster as bt, RectAreaLight as xt, ReinhardToneMapping as St, RepeatWrapping as Ct, SRGBColorSpace as wt, Scene as Tt, SphereGeometry as Et, SpotLight as Dt, SpotLightHelper as Ot, TextureLoader as kt, Timer as At, TimestampQuery as jt, UnsignedByteType as Mt, Vector2 as Nt, Vector3 as Pt } from "three";
4
+ import { RectAreaLightTexturesLib as Ft } from "three/addons/lights/RectAreaLightTexturesLib.js";
5
+ import { RectAreaLightHelper as It } from "three/addons/helpers/RectAreaLightHelper.js";
6
+ import { GLTFLoader as Lt } from "three/addons/loaders/GLTFLoader.js";
7
+ import { HDRLoader as Rt } from "three/addons/loaders/HDRLoader.js";
8
+ import { DRACOLoader as zt } from "three/addons/loaders/DRACOLoader.js";
9
+ import { KTX2Loader as Bt } from "three/addons/loaders/KTX2Loader.js";
10
+ import { EXRLoader as Vt } from "three/addons/loaders/EXRLoader.js";
11
+ import { createMeshesFromMultiMaterialMesh as Ht } from "three/addons/utils/SceneUtils.js";
12
+ import { MeshoptDecoder as Ut } from "three/addons/libs/meshopt_decoder.module.js";
13
+ import { strFromU8 as Wt, unzipSync as Gt } from "three/addons/libs/fflate.module.js";
14
+ import { OrbitControls as Kt } from "three/addons/controls/OrbitControls.js";
15
+ import { outline as qt } from "three/addons/tsl/display/OutlineNode.js";
16
+ import { TransformControls as Jt } from "three/addons/controls/TransformControls.js";
17
17
  //#region src/TSL/patches.js
18
- var Jt = l.prototype.createNodeBuilder;
18
+ var Yt = l.prototype.createNodeBuilder;
19
19
  l.prototype.createNodeBuilder = function(e, t) {
20
- let n = Jt.call(this, e, t);
20
+ let n = Yt.call(this, e, t);
21
21
  return Object.defineProperty(n, "allowGlobalVariables", {
22
22
  get() {
23
23
  return this.material !== null;
@@ -26,22 +26,22 @@ l.prototype.createNodeBuilder = function(e, t) {
26
26
  configurable: !0
27
27
  }), n;
28
28
  };
29
- function Yt(e, t) {
29
+ function Xt(e, t) {
30
30
  return new Proxy(e, { get(e, n, r) {
31
31
  if (typeof n == "string" && t.has(n)) return e.get(n);
32
32
  let i = Reflect.get(e, n, r);
33
- return n === "toVar" && typeof i == "function" ? (...n) => Yt(i.apply(e, n), t) : i;
33
+ return n === "toVar" && typeof i == "function" ? (...n) => Xt(i.apply(e, n), t) : i;
34
34
  } });
35
35
  }
36
- function Xt(e, t = null) {
37
- let n = ye(e, t), r = new Set(Object.keys(e)), i = (...e) => Yt(n(...e), r);
38
- return i.layout = n.layout, i.isStruct = !0, i.wrap = (e) => Yt(e, r), i;
36
+ function Zt(e, t = null) {
37
+ let n = ye(e, t), r = new Set(Object.keys(e)), i = (...e) => Xt(n(...e), r);
38
+ return i.layout = n.layout, i.isStruct = !0, i.wrap = (e) => Xt(e, r), i;
39
39
  }
40
40
  //#endregion
41
41
  //#region src/SceneHelpers.js
42
- var Zt = class {
42
+ var Qt = class {
43
43
  constructor() {
44
- this.scene = new wt(), this._helpers = /* @__PURE__ */ new Map(), this.visible = !1;
44
+ this.scene = new Tt(), this._helpers = /* @__PURE__ */ new Map(), this.visible = !1;
45
45
  }
46
46
  add(e) {
47
47
  if (this._helpers.has(e.uuid)) return this._helpers.get(e.uuid);
@@ -76,47 +76,39 @@ var Zt = class {
76
76
  this.clear();
77
77
  }
78
78
  _createHelper(e) {
79
- return e.isRectAreaLight ? new Ft(e) : e.isPointLight ? new mt(e, .5) : e.isSpotLight ? new Dt(e) : e.isDirectionalLight ? new Ue(e, .5) : null;
79
+ return e.isRectAreaLight ? new It(e) : e.isPointLight ? new ht(e, .5) : e.isSpotLight ? new Ot(e) : e.isDirectionalLight ? new Ue(e, .5) : null;
80
80
  }
81
- }, Qt = H(0, "int"), $t = Qt, en = new Be(new Float32Array([
81
+ }, $t = H(0, "int"), en = $t, tn = new Be(new Float32Array([
82
82
  .5,
83
83
  .5,
84
84
  .5,
85
85
  1
86
86
  ]), 1, 1);
87
- en.type = qe, en.needsUpdate = !0;
88
- var tn = new Be(new Float32Array([
87
+ tn.type = qe, tn.needsUpdate = !0;
88
+ var nn = new Be(new Float32Array([
89
89
  .5,
90
90
  .5,
91
91
  0,
92
92
  1
93
93
  ]), 1, 1);
94
- tn.type = qe, tn.needsUpdate = !0;
95
- var nn = be(en);
96
- nn.setUpdateMatrix(!1);
94
+ nn.type = qe, nn.needsUpdate = !0;
97
95
  var rn = be(tn);
98
96
  rn.setUpdateMatrix(!1);
99
- var an = M(.7548776662466927), on = M(.5698402909980532), sn = /* @__PURE__ */ K("\n fn getSobolDirectionVector( index: i32 ) -> u32 {\n\n switch ( index ) {\n case 0: { return 2147483648u; }\n case 1: { return 1073741824u; }\n case 2: { return 536870912u; }\n case 3: { return 268435456u; }\n case 4: { return 134217728u; }\n case 5: { return 67108864u; }\n case 6: { return 33554432u; }\n case 7: { return 16777216u; }\n case 8: { return 8388608u; }\n case 9: { return 4194304u; }\n case 10: { return 2097152u; }\n case 11: { return 1048576u; }\n case 12: { return 524288u; }\n case 13: { return 262144u; }\n case 14: { return 131072u; }\n case 15: { return 65536u; }\n case 16: { return 32768u; }\n case 17: { return 16384u; }\n case 18: { return 8192u; }\n case 19: { return 4096u; }\n case 20: { return 2048u; }\n case 21: { return 1024u; }\n case 22: { return 512u; }\n case 23: { return 256u; }\n case 24: { return 128u; }\n case 25: { return 64u; }\n case 26: { return 32u; }\n case 27: { return 16u; }\n case 28: { return 8u; }\n case 29: { return 4u; }\n case 30: { return 2u; }\n default: { return 1u; }\n }\n\n }\n"), cn = /* @__PURE__ */ K("\n fn pcgHash( state: u32 ) -> u32 {\n\n var s = state;\n s = s * 747796405u + 2891336453u;\n s = ( ( s >> ( ( s >> 28u ) + 4u ) ) ^ s ) * 277803737u;\n s = ( s >> 22u ) ^ s;\n return s;\n\n }\n"), ln = /* @__PURE__ */ K("\n fn wang_hash( seed: u32 ) -> u32 {\n\n var s = seed;\n s = ( s ^ 61u ) ^ ( s >> 16u );\n s = s * 9u;\n s = s ^ ( s >> 4u );\n s = s * 0x27d4eb2du;\n s = s ^ ( s >> 15u );\n return s;\n\n }\n"), un = (e) => (e.assign(e.mul(1664525).add(1013904223)), M(e.shiftRight(8)).mul(1 / 16777216)), dn = (e) => (e.assign(cn({ state: e })), M(e.shiftRight(8)).mul(1 / 16777216)), fn = (e) => {
100
- let t = un(e).mul(g).toVar();
101
- return U(D(t), me(t)).mul(ge(un(e)));
97
+ var an = be(nn);
98
+ an.setUpdateMatrix(!1);
99
+ var on = M(.7548776662466927), sn = M(.5698402909980532), cn = /* @__PURE__ */ K("\n fn getSobolDirectionVector( index: i32 ) -> u32 {\n\n switch ( index ) {\n case 0: { return 2147483648u; }\n case 1: { return 1073741824u; }\n case 2: { return 536870912u; }\n case 3: { return 268435456u; }\n case 4: { return 134217728u; }\n case 5: { return 67108864u; }\n case 6: { return 33554432u; }\n case 7: { return 16777216u; }\n case 8: { return 8388608u; }\n case 9: { return 4194304u; }\n case 10: { return 2097152u; }\n case 11: { return 1048576u; }\n case 12: { return 524288u; }\n case 13: { return 262144u; }\n case 14: { return 131072u; }\n case 15: { return 65536u; }\n case 16: { return 32768u; }\n case 17: { return 16384u; }\n case 18: { return 8192u; }\n case 19: { return 4096u; }\n case 20: { return 2048u; }\n case 21: { return 1024u; }\n case 22: { return 512u; }\n case 23: { return 256u; }\n case 24: { return 128u; }\n case 25: { return 64u; }\n case 26: { return 32u; }\n case 27: { return 16u; }\n case 28: { return 8u; }\n case 29: { return 4u; }\n case 30: { return 2u; }\n default: { return 1u; }\n }\n\n }\n"), ln = /* @__PURE__ */ K("\n fn pcgHash( state: u32 ) -> u32 {\n\n var s = state;\n s = s * 747796405u + 2891336453u;\n s = ( ( s >> ( ( s >> 28u ) + 4u ) ) ^ s ) * 277803737u;\n s = ( s >> 22u ) ^ s;\n return s;\n\n }\n"), un = /* @__PURE__ */ K("\n fn wang_hash( seed: u32 ) -> u32 {\n\n var s = seed;\n s = ( s ^ 61u ) ^ ( s >> 16u );\n s = s * 9u;\n s = s ^ ( s >> 4u );\n s = s * 0x27d4eb2du;\n s = s ^ ( s >> 15u );\n return s;\n\n }\n"), dn = (e) => (e.assign(e.mul(1664525).add(1013904223)), M(e.shiftRight(8)).mul(1 / 16777216)), J = (e) => (e.assign(ln({ state: e })), M(e.shiftRight(8)).mul(1 / 16777216)), fn = (e) => {
100
+ let t = dn(e).mul(g).toVar();
101
+ return U(D(t), me(t)).mul(ge(dn(e)));
102
102
  }, pn = (e, t, n, r) => {
103
- let i = V(r).bitAnd(V(63)), a = M(n).add(M(t).mul(7)), o = N(te(a.mul(an).add(.5)).mul(128)), s = N(te(a.mul(on).add(.5)).mul(128)), c = N(e.x).add(o).bitAnd(N(127)), l = N(e.y).add(s).bitAnd(N(127)), u = N(i).bitAnd(N(7)), d = N(i).shiftRight(N(3));
103
+ let i = V(r).bitAnd(V(63)), a = M(n).add(M(t).mul(7)), o = N(te(a.mul(on).add(.5)).mul(128)), s = N(te(a.mul(sn).add(.5)).mul(128)), c = N(e.x).add(o).bitAnd(N(127)), l = N(e.y).add(s).bitAnd(N(127)), u = N(i).bitAnd(N(7)), d = N(i).shiftRight(N(3));
104
104
  return P(u.mul(N(128)).add(c), d.mul(N(128)).add(l));
105
105
  }, mn = (e, t, n, r) => {
106
106
  let i = pn(e, t, n, r);
107
- return rn.load(i).xy;
108
- }, hn = /* @__PURE__ */ K("\n fn haltonScrambled( index: i32, base: i32, scramble: u32 ) -> f32 {\n\n var result = 0.0f;\n var f = 1.0f;\n var i = index + 1;\n var s = scramble;\n var iter = 0;\n\n while ( i > 0 && iter < 32 ) {\n\n iter += 1;\n f /= f32( base );\n\n // Additive permutation per digit: (digit + s_k) mod base\n // Guaranteed bijection within [0, base) for any s_k\n var digit = i % base;\n digit = ( digit + i32( s % u32( base ) ) ) % base;\n result += f * f32( digit );\n i /= base;\n\n // Evolve scramble per digit position for position-dependent permutations\n s = s * 747796405u + 2891336453u;\n\n }\n\n return result;\n\n }\n"), gn = /* @__PURE__ */ K("\n fn owen_scrambled_sobol( index: u32, dimension: u32, seed: u32 ) -> f32 {\n\n var result = 0u;\n for ( var i = 0; i < 32; i++ ) {\n\n if ( ( index & ( 1u << u32( i ) ) ) != 0u ) {\n\n result ^= getSobolDirectionVector( i );\n\n }\n\n }\n\n // Mix dimension into seed for inter-dimensional decorrelation\n // (Van der Corput base is shared; Owen scrambling with distinct seeds\n // produces decorrelated sequences across dimensions)\n let dimSeed = seed ^ ( dimension * 0x9e3779b9u + 0x6a09e667u );\n result = owen_scramble( result, dimSeed );\n return f32( result ) / 4294967296.0f;\n\n }\n", [sn, /* @__PURE__ */ K("\n fn owen_scramble( x: u32, seed: u32 ) -> u32 {\n\n var v = x;\n v ^= v * 0x3d20adeau;\n v += seed;\n v *= ( seed >> 16u ) | 1u;\n v ^= v >> 15u;\n v *= 0x5851f42du;\n v ^= v >> 12u;\n v *= 0x4c957f2du;\n v ^= v >> 18u;\n return v;\n\n }\n")]), _n = (e, t, n, r, i, a, o, s) => {
109
- let c = z(a.notEqual(N(-1)), a, $t), l = G(0).toVar();
107
+ return an.load(i).xy;
108
+ }, hn = /* @__PURE__ */ K("\n fn haltonScrambled( index: i32, base: i32, scramble: u32 ) -> f32 {\n\n var result = 0.0f;\n var f = 1.0f;\n var i = index + 1;\n var s = scramble;\n var iter = 0;\n\n while ( i > 0 && iter < 32 ) {\n\n iter += 1;\n f /= f32( base );\n\n // Additive permutation per digit: (digit + s_k) mod base\n // Guaranteed bijection within [0, base) for any s_k\n var digit = i % base;\n digit = ( digit + i32( s % u32( base ) ) ) % base;\n result += f * f32( digit );\n i /= base;\n\n // Evolve scramble per digit position for position-dependent permutations\n s = s * 747796405u + 2891336453u;\n\n }\n\n return result;\n\n }\n"), gn = /* @__PURE__ */ K("\n fn owen_scrambled_sobol( index: u32, dimension: u32, seed: u32 ) -> f32 {\n\n var result = 0u;\n for ( var i = 0; i < 32; i++ ) {\n\n if ( ( index & ( 1u << u32( i ) ) ) != 0u ) {\n\n result ^= getSobolDirectionVector( i );\n\n }\n\n }\n\n // Mix dimension into seed for inter-dimensional decorrelation\n // (Van der Corput base is shared; Owen scrambling with distinct seeds\n // produces decorrelated sequences across dimensions)\n let dimSeed = seed ^ ( dimension * 0x9e3779b9u + 0x6a09e667u );\n result = owen_scramble( result, dimSeed );\n return f32( result ) / 4294967296.0f;\n\n }\n", [cn, /* @__PURE__ */ K("\n fn owen_scramble( x: u32, seed: u32 ) -> u32 {\n\n var v = x;\n v ^= v * 0x3d20adeau;\n v += seed;\n v *= ( seed >> 16u ) | 1u;\n v ^= v >> 15u;\n v *= 0x5851f42du;\n v ^= v >> 12u;\n v *= 0x4c957f2du;\n v ^= v >> 18u;\n return v;\n\n }\n")]), _n = (e, t, n, r, i, a, o, s) => {
109
+ let c = z(a.notEqual(N(-1)), a, en), l = G(0).toVar();
110
110
  return m(c.equal(N(0)), () => {
111
111
  m(i.greaterThan(N(2)), () => {
112
- l.x.assign(un(r)), m(i.greaterThan(N(1)), () => {
113
- l.y.assign(un(r));
114
- }), m(i.greaterThan(N(2)), () => {
115
- l.z.assign(un(r));
116
- }), m(i.greaterThan(N(3)), () => {
117
- l.w.assign(un(r));
118
- });
119
- }).Else(() => {
120
112
  l.x.assign(dn(r)), m(i.greaterThan(N(1)), () => {
121
113
  l.y.assign(dn(r));
122
114
  }), m(i.greaterThan(N(2)), () => {
@@ -124,9 +116,17 @@ var an = M(.7548776662466927), on = M(.5698402909980532), sn = /* @__PURE__ */ K
124
116
  }), m(i.greaterThan(N(3)), () => {
125
117
  l.w.assign(dn(r));
126
118
  });
119
+ }).Else(() => {
120
+ l.x.assign(J(r)), m(i.greaterThan(N(1)), () => {
121
+ l.y.assign(J(r));
122
+ }), m(i.greaterThan(N(2)), () => {
123
+ l.z.assign(J(r));
124
+ }), m(i.greaterThan(N(3)), () => {
125
+ l.w.assign(J(r));
126
+ });
127
127
  });
128
128
  }).ElseIf(c.equal(N(1)), () => {
129
- let r = cn({ state: V(e.x).add(V(e.y).mul(V(o.x))).bitXor(s.mul(V(2654435769))).bitXor(V(n).mul(V(1367130551))) }).toVar();
129
+ let r = ln({ state: V(e.x).add(V(e.y).mul(V(o.x))).bitXor(s.mul(V(2654435769))).bitXor(V(n).mul(V(1367130551))) }).toVar();
130
130
  l.x.assign(hn({
131
131
  index: t,
132
132
  base: N(2),
@@ -151,7 +151,7 @@ var an = M(.7548776662466927), on = M(.5698402909980532), sn = /* @__PURE__ */ K
151
151
  }));
152
152
  });
153
153
  }).ElseIf(c.equal(N(2)), () => {
154
- let r = cn({ state: V(e.x).add(V(e.y).mul(V(o.x))).bitXor(s.mul(V(2654435769))).bitXor(V(n).mul(V(1367130551))) }).toVar();
154
+ let r = ln({ state: V(e.x).add(V(e.y).mul(V(o.x))).bitXor(s.mul(V(2654435769))).bitXor(V(n).mul(V(1367130551))) }).toVar();
155
155
  l.x.assign(gn({
156
156
  index: V(t),
157
157
  dimension: V(0),
@@ -191,17 +191,17 @@ var an = M(.7548776662466927), on = M(.5698402909980532), sn = /* @__PURE__ */ K
191
191
  o.assign(vn(e, t, N(0), r, N(-1), i, a));
192
192
  }).Else(() => {
193
193
  let i = N(ge(M(n))), s = n.add(i).sub(1).div(i), c = se(t, i.mul(s)), l = se(c, i), u = c.div(i), d = U(M(l), M(u)).div(U(M(i), M(s))), f = U(0).toVar();
194
- m($t.greaterThanEqual(N(3)), () => {
194
+ m(en.greaterThanEqual(N(3)), () => {
195
195
  f.assign(mn(e, t, N(0), a));
196
196
  }).Else(() => {
197
- let i = un(r).toVar(), o = un(r).toVar();
197
+ let i = dn(r).toVar(), o = dn(r).toVar();
198
198
  f.assign(U(i, o)), m(n.greaterThan(N(4)), () => {
199
199
  let n = mn(e, t, N(0), a).mul(.1);
200
200
  f.assign(L(f, n, .2));
201
201
  });
202
202
  }), f.divAssign(U(M(i), M(s))), o.assign(d.add(f));
203
203
  }), o;
204
- }, bn = /* @__PURE__ */ K("\n fn getDecorrelatedSeed( pixelCoord: vec2f, rayIndex: i32, frame: u32 ) -> u32 {\n\n // Use multiple primes for better decorrelation\n let pixelSeed = u32( pixelCoord.x ) * 2654435761u + u32( pixelCoord.y ) * 3266489917u;\n let raySeed = u32( rayIndex ) * 668265263u;\n let frameSeed = frame * 374761393u;\n\n // Multiple rounds of hashing for better quality\n var seed = wang_hash( pixelSeed );\n seed = pcgHash( seed ^ raySeed );\n seed = wang_hash( seed + frameSeed );\n return seed;\n\n }\n", [ln, cn]), xn = {
204
+ }, bn = /* @__PURE__ */ K("\n fn getDecorrelatedSeed( pixelCoord: vec2f, rayIndex: i32, frame: u32 ) -> u32 {\n\n // Use multiple primes for better decorrelation\n let pixelSeed = u32( pixelCoord.x ) * 2654435761u + u32( pixelCoord.y ) * 3266489917u;\n let raySeed = u32( rayIndex ) * 668265263u;\n let frameSeed = frame * 374761393u;\n\n // Multiple rounds of hashing for better quality\n var seed = wang_hash( pixelSeed );\n seed = pcgHash( seed ^ raySeed );\n seed = wang_hash( seed + frameSeed );\n return seed;\n\n }\n", [un, ln]), xn = {
205
205
  ALWAYS: "always",
206
206
  PER_CYCLE: "per_cycle",
207
207
  PER_TILE: "per_tile",
@@ -579,7 +579,7 @@ function Ln() {
579
579
  //#region src/Processor/StorageTexturePool.js
580
580
  function Rn(e, t) {
581
581
  let n = new s(e, t);
582
- return n.type = qe, n.format = vt, n.minFilter = q, n.magFilter = q, n;
582
+ return n.type = qe, n.format = yt, n.minFilter = q, n.magFilter = q, n;
583
583
  }
584
584
  var zn = class {
585
585
  constructor(e, t) {
@@ -588,9 +588,9 @@ var zn = class {
588
588
  create(e, t) {
589
589
  this.dispose(), this.renderWidth = e, this.renderHeight = t, this.writeColor = Rn(e, t), this.writeNormalDepth = Rn(e, t), this.writeAlbedo = Rn(e, t), this.readTarget = new i(e, t, {
590
590
  type: qe,
591
- format: vt,
592
- minFilter: J,
593
- magFilter: J,
591
+ format: yt,
592
+ minFilter: ct,
593
+ magFilter: ct,
594
594
  depthBuffer: !1,
595
595
  stencilBuffer: !1,
596
596
  count: 3
@@ -1102,12 +1102,12 @@ var zn = class {
1102
1102
  let r = H(t, n);
1103
1103
  return this._uniforms.set(e, r), r;
1104
1104
  }, r = (e, t) => (this._booleans.add(e), n(e, +!!t, "int"));
1105
- n("frame", 0, "uint"), n("maxBounces", X.bounces, "int"), n("samplesPerPixel", X.samplesPerPixel, "int"), n("maxSamples", X.maxSamples, "int"), n("transmissiveBounces", X.transmissiveBounces, "int"), n("visMode", X.debugMode, "int"), n("debugVisScale", X.debugVisScale, "float"), r("enableAccumulation", !0), n("accumulationAlpha", 0, "float"), r("cameraIsMoving", !1), r("hasPreviousAccumulated", !1), n("environmentIntensity", X.environmentIntensity, "float"), n("backgroundIntensity", X.backgroundIntensity, "float"), r("showBackground", X.showBackground), r("transparentBackground", X.transparentBackground), r("enableEnvironment", X.enableEnvironment), n("environmentMatrix", new rt(), "mat4"), r("useEnvMapIS", X.useImportanceSampledEnvironment), n("envTotalSum", 0, "float"), n("envCompensationDelta", 0, "float"), n("envResolution", new Mt(1, 1), "vec2"), n("sunDirection", new Nt(0, 1, 0), "vec3"), n("sunAngularSize", .0087, "float"), r("hasSun", !1), n("globalIlluminationIntensity", X.globalIlluminationIntensity, "float"), n("exposure", X.exposure, "float"), n("numDirectionalLights", 0, "int"), n("numAreaLights", 0, "int"), n("numPointLights", 0, "int"), n("numSpotLights", 0, "int"), this._lightBuffers = {
1105
+ n("frame", 0, "uint"), n("maxBounces", X.bounces, "int"), n("samplesPerPixel", X.samplesPerPixel, "int"), n("maxSamples", X.maxSamples, "int"), n("transmissiveBounces", X.transmissiveBounces, "int"), n("visMode", X.debugMode, "int"), n("debugVisScale", X.debugVisScale, "float"), r("enableAccumulation", !0), n("accumulationAlpha", 0, "float"), r("cameraIsMoving", !1), r("hasPreviousAccumulated", !1), n("environmentIntensity", X.environmentIntensity, "float"), n("backgroundIntensity", X.backgroundIntensity, "float"), r("showBackground", X.showBackground), r("transparentBackground", X.transparentBackground), r("enableEnvironment", X.enableEnvironment), n("environmentMatrix", new rt(), "mat4"), r("useEnvMapIS", X.useImportanceSampledEnvironment), n("envTotalSum", 0, "float"), n("envCompensationDelta", 0, "float"), n("envResolution", new Nt(1, 1), "vec2"), n("sunDirection", new Pt(0, 1, 0), "vec3"), n("sunAngularSize", .0087, "float"), r("hasSun", !1), n("globalIlluminationIntensity", X.globalIlluminationIntensity, "float"), n("exposure", X.exposure, "float"), n("numDirectionalLights", 0, "int"), n("numAreaLights", 0, "int"), n("numPointLights", 0, "int"), n("numSpotLights", 0, "int"), this._lightBuffers = {
1106
1106
  directional: Se(new Float32Array(128), "float"),
1107
1107
  area: Se(new Float32Array(208), "float"),
1108
1108
  point: Se(new Float32Array(144), "float"),
1109
1109
  spot: Se(new Float32Array(224), "float")
1110
- }, n("cameraWorldMatrix", new rt(), "mat4"), n("cameraProjectionMatrixInverse", new rt(), "mat4"), n("cameraViewMatrix", new rt(), "mat4"), n("cameraProjectionMatrix", new rt(), "mat4"), r("enableDOF", X.enableDOF), n("focusDistance", X.focusDistance, "float"), n("focalLength", X.focalLength, "float"), n("aperture", X.aperture, "float"), n("apertureScale", 1, "float"), n("anamorphicRatio", X.anamorphicRatio ?? 1, "float"), n("sceneScale", 1, "float"), this._uniforms.set("samplingTechnique", Qt), Qt.value = X.samplingTechnique, r("useAdaptiveSampling", X.adaptiveSampling), n("adaptiveSamplingMin", X.adaptiveSamplingMin ?? 1, "int"), n("adaptiveSamplingMax", X.adaptiveSamplingMax, "int"), n("fireflyThreshold", X.fireflyThreshold, "float"), r("enableEmissiveTriangleSampling", X.enableEmissiveTriangleSampling), n("emissiveBoost", X.emissiveBoost, "float"), n("emissiveTriangleCount", 0, "int"), n("emissiveTotalPower", 0, "float"), n("lightBVHNodeCount", 0, "int"), n("emissiveVec4Offset", 0, "int"), n("renderMode", X.renderMode, "int"), r("enableAlphaShadows", X.enableAlphaShadows), n("resolution", new Mt(e, t), "vec2"), n("totalTriangleCount", 0, "int");
1110
+ }, n("cameraWorldMatrix", new rt(), "mat4"), n("cameraProjectionMatrixInverse", new rt(), "mat4"), n("cameraViewMatrix", new rt(), "mat4"), n("cameraProjectionMatrix", new rt(), "mat4"), r("enableDOF", X.enableDOF), n("focusDistance", X.focusDistance, "float"), n("focalLength", X.focalLength, "float"), n("aperture", X.aperture, "float"), n("apertureScale", 1, "float"), n("anamorphicRatio", X.anamorphicRatio ?? 1, "float"), n("sceneScale", 1, "float"), this._uniforms.set("samplingTechnique", $t), $t.value = X.samplingTechnique, r("useAdaptiveSampling", X.adaptiveSampling), n("adaptiveSamplingMin", X.adaptiveSamplingMin ?? 1, "int"), n("adaptiveSamplingMax", X.adaptiveSamplingMax, "int"), n("fireflyThreshold", X.fireflyThreshold, "float"), r("enableEmissiveTriangleSampling", X.enableEmissiveTriangleSampling), n("emissiveBoost", X.emissiveBoost, "float"), n("emissiveTriangleCount", 0, "int"), n("emissiveTotalPower", 0, "float"), n("lightBVHNodeCount", 0, "int"), n("emissiveVec4Offset", 0, "int"), n("renderMode", X.renderMode, "int"), r("enableAlphaShadows", X.enableAlphaShadows), n("resolution", new Nt(e, t), "vec2"), n("totalTriangleCount", 0, "int");
1111
1111
  }
1112
1112
  _nameAll() {
1113
1113
  for (let [e, t] of this._uniforms) t.name = Qn[e] || e;
@@ -1447,7 +1447,7 @@ function dr(e) {
1447
1447
  e = r instanceof Int8Array || r instanceof Int16Array || r instanceof Int32Array ? 2 ** (8 * r.BYTES_PER_ELEMENT - 1) - 1 : 2 ** (8 * r.BYTES_PER_ELEMENT) - 1, a = new Float32Array(r.length);
1448
1448
  for (let t = 0, n = r.length; t < n; t++) a[t] = r[t] / e;
1449
1449
  }
1450
- if (!i && e.colorSpace === Ct && (i = !0), i) for (let e = 0, t = a.length; e < t; e += 4) a[e] = ur(a[e]), a[e + 1] = ur(a[e + 1]), a[e + 2] = ur(a[e + 2]);
1450
+ if (!i && e.colorSpace === wt && (i = !0), i) for (let e = 0, t = a.length; e < t; e += 4) a[e] = ur(a[e]), a[e + 1] = ur(a[e + 1]), a[e + 2] = ur(a[e + 2]);
1451
1451
  if (e.flipY) {
1452
1452
  let e = new Float32Array(a.length);
1453
1453
  for (let r = 0; r < n; r++) {
@@ -1652,7 +1652,7 @@ function Nr(e, t, n) {
1652
1652
  }
1653
1653
  var Pr = class {
1654
1654
  constructor(e = 512, t = 256) {
1655
- this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new Be(this._pixels, e, t, vt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Xe, this._texture.minFilter = q, this._texture.magFilter = q, this._texture.wrapS = St, this._texture.wrapT = Le, this._texture.generateMipmaps = !1;
1655
+ this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Xe, this._texture.minFilter = q, this._texture.magFilter = q, this._texture.wrapS = Ct, this._texture.wrapT = Le, this._texture.generateMipmaps = !1;
1656
1656
  }
1657
1657
  render(e) {
1658
1658
  let t = performance.now(), n = [
@@ -1670,7 +1670,7 @@ var Pr = class {
1670
1670
  return this._texture.needsUpdate = !0, this.lastRenderTime = performance.now() - t, this._texture;
1671
1671
  }
1672
1672
  setResolution(e, t) {
1673
- this.width === e && this.height === t || (this.width = e, this.height = t, this._pixels = new Float32Array(e * t * 4), this._texture.dispose(), this._texture = new Be(this._pixels, e, t, vt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Xe, this._texture.minFilter = q, this._texture.magFilter = q, this._texture.wrapS = St, this._texture.wrapT = Le, this._texture.generateMipmaps = !1);
1673
+ this.width === e && this.height === t || (this.width = e, this.height = t, this._pixels = new Float32Array(e * t * 4), this._texture.dispose(), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Xe, this._texture.minFilter = q, this._texture.magFilter = q, this._texture.wrapS = Ct, this._texture.wrapT = Le, this._texture.generateMipmaps = !1);
1674
1674
  }
1675
1675
  getLastRenderTime() {
1676
1676
  return this.lastRenderTime;
@@ -1680,7 +1680,7 @@ var Pr = class {
1680
1680
  }
1681
1681
  }, Fr = class {
1682
1682
  constructor(e = 512, t = 256) {
1683
- this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new Be(this._pixels, e, t, vt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Xe, this._texture.minFilter = q, this._texture.magFilter = q, this._texture.wrapS = St, this._texture.wrapT = Le, this._texture.generateMipmaps = !1;
1683
+ this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Xe, this._texture.minFilter = q, this._texture.magFilter = q, this._texture.wrapS = Ct, this._texture.wrapT = Le, this._texture.generateMipmaps = !1;
1684
1684
  }
1685
1685
  renderGradient(e) {
1686
1686
  let t = performance.now(), { width: n, height: r } = this, i = this._pixels, a = e.zenithColor.r, o = e.zenithColor.g, s = e.zenithColor.b, c = e.horizonColor.r, l = e.horizonColor.g, u = e.horizonColor.b, d = e.groundColor.r, f = e.groundColor.g, p = e.groundColor.b;
@@ -1709,7 +1709,7 @@ var Pr = class {
1709
1709
  return this._texture.needsUpdate = !0, this.lastRenderTime = performance.now() - t, this._texture;
1710
1710
  }
1711
1711
  setResolution(e, t) {
1712
- this.width === e && this.height === t || (this.width = e, this.height = t, this._pixels = new Float32Array(e * t * 4), this._texture.dispose(), this._texture = new Be(this._pixels, e, t, vt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Xe, this._texture.minFilter = q, this._texture.magFilter = q, this._texture.wrapS = St, this._texture.wrapT = Le, this._texture.generateMipmaps = !1);
1712
+ this.width === e && this.height === t || (this.width = e, this.height = t, this._pixels = new Float32Array(e * t * 4), this._texture.dispose(), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Xe, this._texture.minFilter = q, this._texture.magFilter = q, this._texture.wrapS = Ct, this._texture.wrapT = Le, this._texture.generateMipmaps = !1);
1713
1713
  }
1714
1714
  getLastRenderTime() {
1715
1715
  return this.lastRenderTime;
@@ -1724,7 +1724,7 @@ var Pr = class {
1724
1724
  0,
1725
1725
  0,
1726
1726
  1
1727
- ]), 1, 1, vt, qe), this._envPlaceholder.needsUpdate = !0, this.environmentTexture = this._envPlaceholder, this.envTexSize = new Mt(), this.envCDFStorageAttr = null, this.envCDFStorageNode = null, this._initCDFStorageBuffers(), this.environmentRotationMatrix = new rt(), this.cdfBuildTime = 0, this.envParams = {
1727
+ ]), 1, 1, yt, qe), this._envPlaceholder.needsUpdate = !0, this.environmentTexture = this._envPlaceholder, this.envTexSize = new Nt(), this.envCDFStorageAttr = null, this.envCDFStorageNode = null, this._initCDFStorageBuffers(), this.environmentRotationMatrix = new rt(), this.cdfBuildTime = 0, this.envParams = {
1728
1728
  mode: "hdri",
1729
1729
  gradientZenithColor: new Re(X.gradientZenithColor),
1730
1730
  gradientHorizonColor: new Re(X.gradientHorizonColor),
@@ -1859,7 +1859,7 @@ var Pr = class {
1859
1859
  }
1860
1860
  _calculateInitialSunDirection() {
1861
1861
  let e = X.skySunAzimuth * (Math.PI / 180), t = X.skySunElevation * (Math.PI / 180);
1862
- return new Nt(Math.cos(t) * Math.sin(e), Math.sin(t), Math.cos(t) * Math.cos(e)).normalize();
1862
+ return new Pt(Math.cos(t) * Math.sin(e), Math.sin(t), Math.cos(t) * Math.cos(e)).normalize();
1863
1863
  }
1864
1864
  _notifyReset() {
1865
1865
  this.callbacks.onReset && this.callbacks.onReset();
@@ -1867,10 +1867,10 @@ var Pr = class {
1867
1867
  dispose() {
1868
1868
  this.proceduralSkyRenderer = null, this.simpleSkyRenderer = null, this.envCDFStorageAttr?.dispose?.(), this.envCDFStorageAttr = null, this.envCDFStorageNode = null, this.environmentTexture && this.environmentTexture !== this._envPlaceholder && this.environmentTexture.dispose?.(), this._envPlaceholder?.dispose(), this._envPlaceholder = null, this.environmentTexture = null, this._previousHDRI = null;
1869
1869
  }
1870
- }, Lr = Xt({
1870
+ }, Lr = Zt({
1871
1871
  origin: "vec3",
1872
1872
  direction: "vec3"
1873
- }), Rr = Xt({
1873
+ }), Rr = Zt({
1874
1874
  color: "vec4",
1875
1875
  emissive: "vec3",
1876
1876
  emissiveIntensity: "float",
@@ -1915,7 +1915,7 @@ var Pr = class {
1915
1915
  iridescence: "float",
1916
1916
  iridescenceIOR: "float",
1917
1917
  iridescenceThicknessRange: "vec2"
1918
- }), zr = Xt({
1918
+ }), zr = Zt({
1919
1919
  color: "vec4",
1920
1920
  ior: "float",
1921
1921
  transmission: "float",
@@ -1928,12 +1928,12 @@ var Pr = class {
1928
1928
  alphaMode: "int",
1929
1929
  albedoTransform: "mat3"
1930
1930
  });
1931
- Xt({
1931
+ Zt({
1932
1932
  position: "vec3",
1933
1933
  radius: "float",
1934
1934
  material: Rr
1935
1935
  });
1936
- var Br = Xt({
1936
+ var Br = Zt({
1937
1937
  didHit: "bool",
1938
1938
  dst: "float",
1939
1939
  hitPoint: "vec3",
@@ -1945,7 +1945,7 @@ var Br = Xt({
1945
1945
  boxTests: "int",
1946
1946
  triTests: "int"
1947
1947
  });
1948
- Xt({
1948
+ Zt({
1949
1949
  posA: "vec3",
1950
1950
  posB: "vec3",
1951
1951
  posC: "vec3",
@@ -1958,41 +1958,41 @@ Xt({
1958
1958
  material: Rr,
1959
1959
  materialIndex: "int",
1960
1960
  meshIndex: "int"
1961
- }), Xt({
1961
+ }), Zt({
1962
1962
  color: "vec4",
1963
1963
  samples: "int"
1964
1964
  });
1965
- var Vr = Xt({
1965
+ var Vr = Zt({
1966
1966
  direction: "vec3",
1967
1967
  value: "vec3",
1968
1968
  pdf: "float"
1969
- }), Hr = Xt({
1969
+ }), Hr = Zt({
1970
1970
  specular: "float",
1971
1971
  diffuse: "float",
1972
1972
  sheen: "float",
1973
1973
  clearcoat: "float",
1974
1974
  transmission: "float",
1975
1975
  iridescence: "float"
1976
- }), Ur = Xt({
1976
+ }), Ur = Zt({
1977
1977
  diffuseImportance: "float",
1978
1978
  specularImportance: "float",
1979
1979
  transmissionImportance: "float",
1980
1980
  clearcoatImportance: "float",
1981
1981
  envmapImportance: "float"
1982
- }), Wr = Xt({
1982
+ }), Wr = Zt({
1983
1983
  NoL: "float",
1984
1984
  NoV: "float",
1985
1985
  NoH: "float",
1986
1986
  VoH: "float",
1987
1987
  LoH: "float"
1988
- }), Gr = Xt({
1988
+ }), Gr = Zt({
1989
1989
  albedo: "vec4",
1990
1990
  emissive: "vec3",
1991
1991
  metalness: "float",
1992
1992
  roughness: "float",
1993
1993
  normal: "vec3",
1994
1994
  hasTextures: "bool"
1995
- }), Kr = Xt({
1995
+ }), Kr = Zt({
1996
1996
  isMetallic: "bool",
1997
1997
  isRough: "bool",
1998
1998
  isSmooth: "bool",
@@ -2000,7 +2000,7 @@ var Vr = Xt({
2000
2000
  hasClearcoat: "bool",
2001
2001
  isEmissive: "bool",
2002
2002
  complexityScore: "float"
2003
- }), qr = Xt({
2003
+ }), qr = Zt({
2004
2004
  albedoUV: "vec2",
2005
2005
  normalUV: "vec2",
2006
2006
  metalnessUV: "vec2",
@@ -2011,7 +2011,7 @@ var Vr = Xt({
2011
2011
  metalRoughSameUV: "bool",
2012
2012
  albedoEmissiveSameUV: "bool",
2013
2013
  allSameUV: "bool"
2014
- }), Jr = Xt({
2014
+ }), Jr = Zt({
2015
2015
  F0: "vec3",
2016
2016
  NoV: "float",
2017
2017
  diffuseColor: "vec3",
@@ -2023,7 +2023,7 @@ var Vr = Xt({
2023
2023
  metalFactor: "float",
2024
2024
  iorFactor: "float",
2025
2025
  maxSheenColor: "float"
2026
- }), Yr = Xt({
2026
+ }), Yr = Zt({
2027
2027
  envWeight: "float",
2028
2028
  specularWeight: "float",
2029
2029
  diffuseWeight: "float",
@@ -2035,7 +2035,7 @@ var Vr = Xt({
2035
2035
  useDiffuse: "bool",
2036
2036
  useTransmission: "bool",
2037
2037
  useClearcoat: "bool"
2038
- }), Xr = Xt({
2038
+ }), Xr = Zt({
2039
2039
  brdfWeight: "float",
2040
2040
  lightWeight: "float",
2041
2041
  envWeight: "float",
@@ -2043,7 +2043,7 @@ var Vr = Xt({
2043
2043
  useLightSampling: "bool",
2044
2044
  useEnvSampling: "bool"
2045
2045
  });
2046
- Xt({
2046
+ Zt({
2047
2047
  traversals: "int",
2048
2048
  transmissiveTraversals: "int",
2049
2049
  rayType: "int",
@@ -2526,7 +2526,7 @@ var mi = K("\n fn constructTBN( N: vec3f ) -> mat3x3f {\n\n var majorAxis: vec3
2526
2526
  });
2527
2527
  i.assign(be(e, a).depth(N(t)).r);
2528
2528
  }), i;
2529
- }), $i = 32, ea = 16, ta = 5, na = 1 / 1024, ra = 8, ia = Xt({
2529
+ }), $i = 32, ea = 16, ta = 5, na = 1 / 1024, ra = 8, ia = Zt({
2530
2530
  hitPoint: "vec3",
2531
2531
  uv: "vec2",
2532
2532
  normal: "vec3",
@@ -2714,11 +2714,12 @@ var sa = p(([e, t]) => {
2714
2714
  iorFactor: oe(M(2).div(n.ior), 1).toVar(),
2715
2715
  maxSheenColor: I(n.sheenColor.r, I(n.sheenColor.g, n.sheenColor.b)).toVar()
2716
2716
  });
2717
- }), Ea = /* @__PURE__ */ K("\n fn ImportanceSampleGGX( N: vec3f, roughness: f32, Xi: vec2f ) -> vec3f {\n let alpha = roughness * roughness;\n let phi = 6.28318530717958647692f * Xi.x;\n let cosTheta = sqrt( ( 1.0f - Xi.y ) / ( 1.0f + ( alpha * alpha - 1.0f ) * Xi.y ) );\n let sinTheta = sqrt( max( 0.0f, 1.0f - cosTheta * cosTheta ) );\n let H = vec3f( cos( phi ) * sinTheta, sin( phi ) * sinTheta, cosTheta );\n // TBN construction\n let up = select( vec3f( 1.0f, 0.0f, 0.0f ), vec3f( 0.0f, 0.0f, 1.0f ), abs( N.z ) < 0.999f );\n let tangent = normalize( cross( up, N ) );\n let bitangent = cross( N, tangent );\n return normalize( tangent * H.x + bitangent * H.y + N * H.z );\n }\n"), Da = /* @__PURE__ */ K("\n fn ImportanceSampleCosine( N: vec3f, xi: vec2f ) -> vec3f {\n let T = normalize( cross( N, N.yzx + vec3f( 0.1f, 0.2f, 0.3f ) ) );\n let B = cross( N, T );\n let phi = 6.28318530717958647692f * xi.x;\n let cosTheta = sqrt( 1.0f - xi.y );\n let sinTheta = sqrt( xi.y );\n let localDir = vec3f( sinTheta * cos( phi ), sinTheta * sin( phi ), cosTheta );\n return normalize( T * localDir.x + B * localDir.y + N * localDir.z );\n }\n"), Oa = /* @__PURE__ */ K("\n fn cosineWeightedSample( N: vec3f, xi: vec2f ) -> vec3f {\n let T = normalize( cross( N, N.yzx + vec3f( 0.1f, 0.2f, 0.3f ) ) );\n let B = cross( N, T );\n let phi = 6.28318530717958647692f * xi.y;\n let cosTheta = sqrt( 1.0f - xi.x );\n let sinTheta = sqrt( xi.x );\n let localDir = vec3f( sinTheta * cos( phi ), sinTheta * sin( phi ), cosTheta );\n return normalize( T * localDir.x + B * localDir.y + N * localDir.z );\n }\n"), ka = /* @__PURE__ */ K("\n fn sampleGGXVNDF( V: vec3f, roughness: f32, Xi: vec2f ) -> vec3f {\n let alpha = roughness * roughness;\n // Transform view direction to local space\n let Vh = normalize( vec3f( alpha * V.x, alpha * V.y, V.z ) );\n // Construct orthonormal basis around view direction\n let lensq = Vh.x * Vh.x + Vh.y * Vh.y;\n let T1 = select( vec3f( 1.0f, 0.0f, 0.0f ), vec3f( -Vh.y, Vh.x, 0.0f ) / sqrt( lensq ), lensq > 1e-8f );\n let T2 = cross( Vh, T1 );\n // Sample point with polar coordinates (r, phi)\n let r = sqrt( Xi.x );\n let phi = 6.28318530717958647692f * Xi.y;\n let t1 = r * cos( phi );\n let t2tmp = r * sin( phi );\n let s = 0.5f * ( 1.0f + Vh.z );\n let t2 = ( 1.0f - s ) * sqrt( 1.0f - t1 * t1 ) + s * t2tmp;\n // Compute normal\n let Nh = T1 * t1 + T2 * t2 + Vh * sqrt( max( 0.0f, 1.0f - t1 * t1 - t2 * t2 ) );\n // Transform the normal back to the ellipsoid configuration\n return normalize( vec3f( alpha * Nh.x, alpha * Nh.y, max( 0.0f, Nh.z ) ) );\n }\n"), Aa = Xt({
2717
+ }), Ea = /* @__PURE__ */ K("\n fn ImportanceSampleGGX( N: vec3f, roughness: f32, Xi: vec2f ) -> vec3f {\n let alpha = roughness * roughness;\n let phi = 6.28318530717958647692f * Xi.x;\n let cosTheta = sqrt( ( 1.0f - Xi.y ) / ( 1.0f + ( alpha * alpha - 1.0f ) * Xi.y ) );\n let sinTheta = sqrt( max( 0.0f, 1.0f - cosTheta * cosTheta ) );\n let H = vec3f( cos( phi ) * sinTheta, sin( phi ) * sinTheta, cosTheta );\n // TBN construction\n let up = select( vec3f( 1.0f, 0.0f, 0.0f ), vec3f( 0.0f, 0.0f, 1.0f ), abs( N.z ) < 0.999f );\n let tangent = normalize( cross( up, N ) );\n let bitangent = cross( N, tangent );\n return normalize( tangent * H.x + bitangent * H.y + N * H.z );\n }\n"), Da = /* @__PURE__ */ K("\n fn ImportanceSampleCosine( N: vec3f, xi: vec2f ) -> vec3f {\n let T = normalize( cross( N, N.yzx + vec3f( 0.1f, 0.2f, 0.3f ) ) );\n let B = cross( N, T );\n let phi = 6.28318530717958647692f * xi.x;\n let cosTheta = sqrt( 1.0f - xi.y );\n let sinTheta = sqrt( xi.y );\n let localDir = vec3f( sinTheta * cos( phi ), sinTheta * sin( phi ), cosTheta );\n return normalize( T * localDir.x + B * localDir.y + N * localDir.z );\n }\n"), Oa = /* @__PURE__ */ K("\n fn cosineWeightedSample( N: vec3f, xi: vec2f ) -> vec3f {\n let T = normalize( cross( N, N.yzx + vec3f( 0.1f, 0.2f, 0.3f ) ) );\n let B = cross( N, T );\n let phi = 6.28318530717958647692f * xi.y;\n let cosTheta = sqrt( 1.0f - xi.x );\n let sinTheta = sqrt( xi.x );\n let localDir = vec3f( sinTheta * cos( phi ), sinTheta * sin( phi ), cosTheta );\n return normalize( T * localDir.x + B * localDir.y + N * localDir.z );\n }\n"), ka = /* @__PURE__ */ K("\n fn sampleGGXVNDF( V: vec3f, roughness: f32, Xi: vec2f ) -> vec3f {\n let alpha = roughness * roughness;\n // Transform view direction to local space\n let Vh = normalize( vec3f( alpha * V.x, alpha * V.y, V.z ) );\n // Construct orthonormal basis around view direction\n let lensq = Vh.x * Vh.x + Vh.y * Vh.y;\n let T1 = select( vec3f( 1.0f, 0.0f, 0.0f ), vec3f( -Vh.y, Vh.x, 0.0f ) / sqrt( lensq ), lensq > 1e-8f );\n let T2 = cross( Vh, T1 );\n // Sample point with polar coordinates (r, phi)\n let r = sqrt( Xi.x );\n let phi = 6.28318530717958647692f * Xi.y;\n let t1 = r * cos( phi );\n let t2tmp = r * sin( phi );\n let s = 0.5f * ( 1.0f + Vh.z );\n let t2 = ( 1.0f - s ) * sqrt( 1.0f - t1 * t1 ) + s * t2tmp;\n // Compute normal\n let Nh = T1 * t1 + T2 * t2 + Vh * sqrt( max( 0.0f, 1.0f - t1 * t1 - t2 * t2 ) );\n // Transform the normal back to the ellipsoid configuration\n return normalize( vec3f( alpha * Nh.x, alpha * Nh.y, max( 0.0f, Nh.z ) ) );\n }\n"), Aa = Zt({
2718
2718
  direction: "vec3",
2719
2719
  throughput: "vec3",
2720
- didReflect: "bool"
2721
- }), ja = Xt({
2720
+ didReflect: "bool",
2721
+ pathWavelength: "float"
2722
+ }), ja = Zt({
2722
2723
  continueRay: "bool",
2723
2724
  isTransmissive: "bool",
2724
2725
  isAlphaSkip: "bool",
@@ -2726,25 +2727,28 @@ var sa = p(([e, t]) => {
2726
2727
  entering: "bool",
2727
2728
  direction: "vec3",
2728
2729
  throughput: "vec3",
2729
- alpha: "float"
2730
+ alpha: "float",
2731
+ pathWavelength: "float"
2730
2732
  });
2731
- Xt({
2733
+ Zt({
2732
2734
  ior: "float",
2733
2735
  attenuationColor: "vec3",
2734
2736
  attenuationDistance: "float",
2735
2737
  dispersion: "float"
2736
2738
  });
2737
- var Ma = Xt({
2739
+ var Ma = Zt({
2738
2740
  wavelength: "float",
2739
2741
  ior: "float",
2740
2742
  colorWeight: "vec3"
2741
- }), Na = Xt({
2743
+ }), Na = Zt({
2742
2744
  direction: "vec3",
2743
2745
  halfVector: "vec3",
2744
2746
  didReflect: "bool",
2745
- pdf: "float"
2747
+ pdf: "float",
2748
+ colorWeight: "vec3",
2749
+ pathWavelength: "float"
2746
2750
  });
2747
- Xt({
2751
+ Zt({
2748
2752
  m0_ior: "float",
2749
2753
  m0_attenuationColor: "vec3",
2750
2754
  m0_attenuationDistance: "float",
@@ -2763,34 +2767,26 @@ Xt({
2763
2767
  m3_dispersion: "float",
2764
2768
  depth: "int"
2765
2769
  });
2766
- var Pa = p(([e, t, n]) => {
2767
- let r = L(M(380), M(700), n).toVar(), i = r.div(1e3), a = e, o = t.mul(.03), s = a.add(o.div(i.mul(i))).toVar(), c = W(0).toVar();
2768
- return m(r.greaterThanEqual(380).and(r.lessThan(420)), () => {
2769
- c.assign(W(.9, 0, 1));
2770
- }), m(r.greaterThanEqual(420).and(r.lessThan(480)), () => {
2771
- c.assign(W(0, 0, 1));
2772
- }), m(r.greaterThanEqual(480).and(r.lessThan(500)), () => {
2773
- c.assign(W(0, 1, 1));
2774
- }), m(r.greaterThanEqual(500).and(r.lessThan(530)), () => {
2775
- c.assign(W(0, 1, 0));
2776
- }), m(r.greaterThanEqual(530).and(r.lessThan(570)), () => {
2777
- c.assign(W(1, 1, 0));
2778
- }), m(r.greaterThanEqual(570).and(r.lessThan(620)), () => {
2779
- c.assign(W(1, .5, 0));
2780
- }), m(r.greaterThanEqual(620).and(r.lessThanEqual(700)), () => {
2781
- c.assign(W(1, 0, 0));
2782
- }), c.assign(le(c, W(.4))), c.assign(E(c, W(0), W(2))), Ma({
2770
+ var Pa = /* @__PURE__ */ p(([e, t, n]) => {
2771
+ let r = n.div(1e3);
2772
+ return e.add(t.mul(.03).div(r.mul(r)));
2773
+ }), Fa = /* @__PURE__ */ p(([e, t, n, r]) => {
2774
+ let i = z(e.lessThan(t), n, r), a = e.sub(t).mul(i);
2775
+ return j(M(-.5).mul(a).mul(a));
2776
+ }), Ia = /* @__PURE__ */ p(([e]) => W(Fa(e, 442, .0624, .0374).mul(.362).add(Fa(e, 599.8, .0264, .0323).mul(1.056)).sub(Fa(e, 501.1, .049, .0382).mul(.065)), Fa(e, 568.8, .0213, .0247).mul(.821).add(Fa(e, 530.9, .0613, .0322).mul(.286)), Fa(e, 437, .0845, .0278).mul(1.217).add(Fa(e, 459, .0385, .0725).mul(.681)))), La = p(([e, t, n]) => {
2777
+ let r = L(M(380), M(700), n).toVar(), i = Pa(e, t, r).toVar(), a = Ia(r).toVar();
2778
+ return Ma({
2783
2779
  wavelength: r,
2784
- ior: s,
2785
- colorWeight: c
2780
+ ior: i,
2781
+ colorWeight: I(W(a.x.mul(3.2406).sub(a.y.mul(1.5372)).sub(a.z.mul(.4986)), a.x.mul(-.9689).add(a.y.mul(1.8758)).add(a.z.mul(.0415)), a.x.mul(.0557).sub(a.y.mul(.204)).add(a.z.mul(1.057))).toVar(), W(0)).mul(W(1.819, 2.773, 2.928)).toVar()
2786
2782
  });
2787
- }), Fa = /* @__PURE__ */ K("\n fn calculateBeerLawAbsorption( attenuationColor: vec3f, attenuationDistance: f32, thickness: f32 ) -> vec3f {\n if ( attenuationDistance <= 0.0f ) { return vec3f( 1.0f ); }\n // Convert RGB attenuation color to absorption coefficients\n let absorption = -log( max( attenuationColor, vec3f( 0.001f ) ) ) / attenuationDistance;\n // Apply Beer's law\n return exp( -absorption * thickness );\n }\n");
2783
+ }), Ra = /* @__PURE__ */ K("\n fn calculateBeerLawAbsorption( attenuationColor: vec3f, attenuationDistance: f32, thickness: f32 ) -> vec3f {\n if ( attenuationDistance <= 0.0f ) { return vec3f( 1.0f ); }\n // Convert RGB attenuation color to absorption coefficients\n let absorption = -log( max( attenuationColor, vec3f( 0.001f ) ) ) / attenuationDistance;\n // Apply Beer's law\n return exp( -absorption * thickness );\n }\n");
2788
2784
  p(([e, t, n, r]) => {
2789
2785
  let i = z(r, M(1), n.ior).toVar(), a = z(r, n.ior, M(1)).toVar(), o = _(A(t, e)), s = i.mul(i).div(a.mul(a)).mul(M(1).sub(o.mul(o))), c = M(0).toVar();
2790
2786
  return m(s.lessThanEqual(1), () => {
2791
2787
  let e = sa(o, da(a, i)), t = M(1).sub(e).mul(n.transmission).toVar();
2792
2788
  m(r.not().and(n.attenuationDistance.greaterThan(0)), () => {
2793
- let e = Fa({
2789
+ let e = Ra({
2794
2790
  attenuationColor: n.attenuationColor,
2795
2791
  attenuationDistance: n.attenuationDistance,
2796
2792
  thickness: n.thickness
@@ -2799,118 +2795,104 @@ p(([e, t, n, r]) => {
2799
2795
  }), c.assign(E(t, 0, 1));
2800
2796
  }), c;
2801
2797
  });
2802
- var Ia = p(([e, t, n, r, i, a, o, s]) => {
2803
- let c = Na({
2798
+ var za = p(([e, t, n, r, i, a, o, s, c]) => {
2799
+ let l = Na({
2804
2800
  direction: W(0),
2805
2801
  halfVector: W(0),
2806
2802
  didReflect: !1,
2807
- pdf: M(0)
2803
+ pdf: M(0),
2804
+ colorWeight: W(1),
2805
+ pathWavelength: c
2808
2806
  }).toVar();
2809
2807
  return m(r.lessThanEqual(.05).and(a.greaterThan(0)), () => {
2810
- c.halfVector.assign(t), c.didReflect.assign(!1);
2811
- let r = n, o = z(i, M(1).div(r), r).toVar(), l = Ma.wrap(Pa(n, a, dn(s)));
2812
- o.assign(z(i, M(1).div(l.ior), l.ior));
2808
+ l.halfVector.assign(t), l.didReflect.assign(!1);
2809
+ let r = n, o = z(i, M(1).div(r), r).toVar();
2810
+ m(c.greaterThan(0), () => {
2811
+ let e = Pa(n, a, c);
2812
+ o.assign(z(i, M(1).div(e), e));
2813
+ }).Else(() => {
2814
+ let e = Ma.wrap(La(n, a, J(s)));
2815
+ o.assign(z(i, M(1).div(e.ior), e.ior)), l.colorWeight.assign(e.colorWeight), l.pathWavelength.assign(e.wavelength);
2816
+ });
2813
2817
  let u = de(e.negate(), t, o).toVar();
2814
2818
  m(A(u, u).lessThan(.001), () => {
2815
- c.direction.assign(ue(e.negate(), t)), c.didReflect.assign(!0), c.pdf.assign(1);
2819
+ l.direction.assign(ue(e.negate(), t)), l.didReflect.assign(!0), l.pdf.assign(1);
2816
2820
  }).Else(() => {
2817
- c.direction.assign(u), c.pdf.assign(1);
2821
+ l.direction.assign(u), l.pdf.assign(1);
2818
2822
  });
2819
2823
  }).Else(() => {
2820
- let l = I(ti, r), u = Ea({
2824
+ let u = I(ti, r), d = Ea({
2821
2825
  N: t,
2822
- roughness: l,
2826
+ roughness: u,
2823
2827
  Xi: o
2824
2828
  }).toVar();
2825
- c.halfVector.assign(u);
2826
- let d = z(i, M(1).div(n), n).toVar();
2829
+ l.halfVector.assign(d);
2830
+ let f = z(i, M(1).div(n), n).toVar();
2827
2831
  m(a.greaterThan(0), () => {
2828
- let e = Ma.wrap(Pa(n, a, dn(s)));
2829
- d.assign(z(i, M(1).div(e.ior), e.ior));
2832
+ m(c.greaterThan(0), () => {
2833
+ let e = Pa(n, a, c);
2834
+ f.assign(z(i, M(1).div(e), e));
2835
+ }).Else(() => {
2836
+ let e = Ma.wrap(La(n, a, J(s)));
2837
+ f.assign(z(i, M(1).div(e.ior), e.ior)), l.colorWeight.assign(e.colorWeight), l.pathWavelength.assign(e.wavelength);
2838
+ });
2830
2839
  });
2831
- let f = E(A(u, e), .001, 1), p = de(e.negate(), u, d).toVar();
2832
- m(A(p, p).lessThan(.001), () => {
2833
- c.direction.assign(ue(e.negate(), u)), c.didReflect.assign(!0);
2834
- let n = E(A(t, u), .001, 1), r = E(A(e, u), .001, 1);
2835
- c.pdf.assign(ya(n, r, l));
2840
+ let p = E(A(d, e), .001, 1), h = de(e.negate(), d, f).toVar();
2841
+ m(A(h, h).lessThan(.001), () => {
2842
+ l.direction.assign(ue(e.negate(), d)), l.didReflect.assign(!0);
2843
+ let n = E(A(t, d), .001, 1), r = E(A(e, d), .001, 1);
2844
+ l.pdf.assign(ya(n, r, u));
2836
2845
  }).Else(() => {
2837
- c.direction.assign(p), c.didReflect.assign(!1);
2838
- let e = E(A(t, u), .001, 1), n = E(A(u, p), .001, 1), r = pa(e, l), i = f.add(d.mul(n)), a = _(n).div(i.mul(i));
2839
- c.pdf.assign(r.mul(e).mul(a));
2846
+ l.direction.assign(h), l.didReflect.assign(!1);
2847
+ let e = E(A(t, d), .001, 1), n = E(A(d, h), .001, 1), r = pa(e, u), i = p.add(f.mul(n)), a = _(n).div(i.mul(i));
2848
+ l.pdf.assign(r.mul(e).mul(a));
2840
2849
  });
2841
- }), c;
2842
- }), La = p(([e, t, n, r, i, a, o]) => {
2843
- let s = Aa({
2850
+ }), l;
2851
+ }), Ba = p(([e, t, n, r, i, a, o, s]) => {
2852
+ let c = Aa({
2844
2853
  direction: W(0),
2845
2854
  throughput: W(1),
2846
- didReflect: !1
2847
- }).toVar(), c = z(r, t, t.negate()).toVar(), l = e.negate().toVar(), u = z(r, a, n.ior).toVar(), d = z(r, n.ior, o).toVar(), f = _(A(c, e)), p = u.mul(u).div(d.mul(d)).mul(M(1).sub(f.mul(f))).greaterThan(1).toVar(), h = da(d, u), g = z(p, M(1), sa(f, h)).toVar(), y = M(0).toVar();
2848
- m(p, () => {
2855
+ didReflect: !1,
2856
+ pathWavelength: s
2857
+ }).toVar(), l = z(r, t, t.negate()).toVar(), u = e.negate().toVar(), d = z(r, a, n.ior).toVar(), f = z(r, n.ior, o).toVar(), p = _(A(l, e)), h = d.mul(d).div(f.mul(f)).mul(M(1).sub(p.mul(p))).greaterThan(1).toVar(), g = da(f, d), v = z(h, M(1), sa(p, g)).toVar(), y = M(0).toVar();
2858
+ m(h, () => {
2849
2859
  y.assign(1);
2850
2860
  }).Else(() => {
2851
- let e = L(g, M(.95), n.metalness).toVar();
2861
+ let e = L(v, M(.95), n.metalness).toVar();
2852
2862
  y.assign(e);
2853
2863
  }), y.assign(E(y, .05, .95));
2854
- let b = p.or(dn(i).lessThan(y)).toVar();
2855
- s.didReflect.assign(b);
2856
- let x = U(dn(i).toVar(), dn(i).toVar());
2864
+ let b = h.or(J(i).lessThan(y)).toVar();
2865
+ c.didReflect.assign(b);
2866
+ let x = U(J(i).toVar(), J(i).toVar());
2857
2867
  return m(b, () => {
2858
2868
  m(n.roughness.greaterThan(.05), () => {
2859
- let e = Na.wrap(Ia(l, c, n.ior, n.roughness, r, M(0), x, i));
2860
- s.direction.assign(e.direction);
2869
+ let e = Na.wrap(za(u, l, n.ior, n.roughness, r, M(0), x, i, M(0)));
2870
+ c.direction.assign(e.direction);
2861
2871
  }).Else(() => {
2862
- s.direction.assign(ue(e, c));
2863
- }), s.throughput.assign(n.color.xyz.mul(g).div(I(y, .05)));
2872
+ c.direction.assign(ue(e, l));
2873
+ }), c.throughput.assign(n.color.xyz.mul(v).div(I(y, .05)));
2864
2874
  }).Else(() => {
2865
2875
  m(n.roughness.greaterThan(.05).or(n.dispersion.greaterThan(0)), () => {
2866
- let t = Na.wrap(Ia(l, c, n.ior, n.roughness, r, n.dispersion, x, i));
2867
- m(t.didReflect, () => {
2868
- s.direction.assign(t.direction), s.didReflect.assign(!0), s.throughput.assign(n.color.xyz.div(I(M(1).sub(y), .05)));
2876
+ let e = Na.wrap(za(u, l, n.ior, n.roughness, r, n.dispersion, x, i, s));
2877
+ c.pathWavelength.assign(e.pathWavelength), m(e.didReflect, () => {
2878
+ c.direction.assign(e.direction), c.didReflect.assign(!0), c.throughput.assign(n.color.xyz.div(I(M(1).sub(y), .05)));
2869
2879
  }).Else(() => {
2870
- s.direction.assign(t.direction), m(n.dispersion.greaterThan(0), () => {
2871
- let t = R(e), r = R(s.direction), i = M(1).sub(_(A(c, t))), a = v(E(A(t, r), -1, 1)), o = R(t.add(c)), l = me(o.x.mul(15)).mul(D(o.y.mul(12))).mul(me(o.z.mul(18))), u = me(r.x.mul(8).add(r.y.mul(6)).add(r.z.mul(10))), d = a.mul(n.dispersion).mul(3), f = l.mul(.3), p = u.mul(.2), h = i.mul(.4), g = te(d.add(f).add(p).add(h)).toVar(), y = W(0).toVar();
2872
- m(g.lessThan(.143), () => {
2873
- let e = g.div(.143);
2874
- y.assign(L(W(.8, 0, 0), W(1, 0, 0), e));
2875
- }), m(g.greaterThanEqual(.143).and(g.lessThan(.286)), () => {
2876
- let e = g.sub(.143).div(.143);
2877
- y.assign(L(W(1, 0, 0), W(1, .6, 0), e));
2878
- }), m(g.greaterThanEqual(.286).and(g.lessThan(.429)), () => {
2879
- let e = g.sub(.286).div(.143);
2880
- y.assign(L(W(1, .6, 0), W(1, 1, 0), e));
2881
- }), m(g.greaterThanEqual(.429).and(g.lessThan(.571)), () => {
2882
- let e = g.sub(.429).div(.142);
2883
- y.assign(L(W(1, 1, 0), W(0, 1, 0), e));
2884
- }), m(g.greaterThanEqual(.571).and(g.lessThan(.714)), () => {
2885
- let e = g.sub(.571).div(.143);
2886
- y.assign(L(W(0, 1, 0), W(0, .4, 1), e));
2887
- }), m(g.greaterThanEqual(.714).and(g.lessThan(.857)), () => {
2888
- let e = g.sub(.714).div(.143);
2889
- y.assign(L(W(0, .4, 1), W(.3, 0, .8), e));
2890
- }), m(g.greaterThanEqual(.857), () => {
2891
- let e = g.sub(.857).div(.143);
2892
- y.assign(L(W(.3, 0, .8), W(.6, 0, 1), e));
2893
- });
2894
- let b = E(n.dispersion.div(5), 0, 1), x = M(1).add(i.mul(1.5)), S = b.mul(x), C = l.add(u), w = M(.5).add(M(.5).mul(me(C.mul(3.14159)))), T = E(S.mul(w), 0, .8);
2895
- s.throughput.assign(L(W(1), y, T));
2896
- }).Else(() => {
2897
- s.throughput.assign(W(1));
2898
- });
2880
+ c.direction.assign(e.direction), c.throughput.assign(e.colorWeight);
2899
2881
  });
2900
2882
  }).Else(() => {
2901
- s.direction.assign(de(e, c, u.div(d))), s.throughput.assign(W(1));
2902
- }), m(s.didReflect.not(), () => {
2903
- s.throughput.mulAssign(n.color.xyz), s.throughput.mulAssign(u.mul(u).div(I(d.mul(d), ei))), m(r.and(n.attenuationDistance.greaterThan(0)), () => {
2904
- s.throughput.mulAssign(Fa({
2883
+ c.direction.assign(de(e, l, d.div(f))), c.throughput.assign(W(1));
2884
+ }), m(c.didReflect.not(), () => {
2885
+ c.throughput.mulAssign(n.color.xyz), c.throughput.mulAssign(d.mul(d).div(I(f.mul(f), ei))), m(r.and(n.attenuationDistance.greaterThan(0)), () => {
2886
+ c.throughput.mulAssign(Ra({
2905
2887
  attenuationColor: n.attenuationColor,
2906
2888
  attenuationDistance: n.attenuationDistance,
2907
2889
  thickness: n.thickness
2908
2890
  }));
2909
- }), s.throughput.mulAssign(M(1).sub(g).div(I(M(1).sub(y), .05)));
2891
+ }), c.throughput.mulAssign(M(1).sub(v).div(I(M(1).sub(y), .05)));
2910
2892
  });
2911
- }), s;
2912
- }), Ra = p(([e, t, n, r, i, a, o, s]) => {
2913
- let c = ja({
2893
+ }), c;
2894
+ }), Va = p(([e, t, n, r, i, a, o, s, c]) => {
2895
+ let l = ja({
2914
2896
  continueRay: !1,
2915
2897
  isTransmissive: !1,
2916
2898
  isAlphaSkip: !1,
@@ -2918,32 +2900,33 @@ var Ia = p(([e, t, n, r, i, a, o, s]) => {
2918
2900
  entering: !1,
2919
2901
  direction: e.direction,
2920
2902
  throughput: W(1),
2921
- alpha: M(1)
2903
+ alpha: M(1),
2904
+ pathWavelength: c
2922
2905
  }).toVar();
2923
2906
  return m(r.alphaMode.equal(N(0)).and(r.transmission.lessThanEqual(0)), () => {}).Else(() => {
2924
- let t = dn(i), l = dn(i), u = cn({ state: i }), d = T(!1).toVar();
2907
+ let t = J(i), u = J(i), d = ln({ state: i }), f = T(!1).toVar();
2925
2908
  m(r.alphaMode.equal(N(2)), () => {
2926
2909
  let n = r.color.a.mul(r.opacity);
2927
2910
  m(t.greaterThan(n), () => {
2928
- c.continueRay.assign(!0), c.direction.assign(e.direction), c.throughput.assign(W(1)), c.alpha.assign(0), c.isAlphaSkip.assign(!0), d.assign(!0);
2911
+ l.continueRay.assign(!0), l.direction.assign(e.direction), l.throughput.assign(W(1)), l.alpha.assign(0), l.isAlphaSkip.assign(!0), f.assign(!0);
2929
2912
  }).Else(() => {
2930
- c.alpha.assign(n);
2913
+ l.alpha.assign(n);
2931
2914
  });
2932
- }), m(d.not().and(r.alphaMode.equal(N(1))), () => {
2915
+ }), m(f.not().and(r.alphaMode.equal(N(1))), () => {
2933
2916
  let t = z(r.alphaTest.greaterThan(0), r.alphaTest, M(.5));
2934
2917
  m(r.color.a.lessThan(t), () => {
2935
- c.continueRay.assign(!0), c.direction.assign(e.direction), c.throughput.assign(W(1)), c.alpha.assign(0), c.isAlphaSkip.assign(!0), d.assign(!0);
2918
+ l.continueRay.assign(!0), l.direction.assign(e.direction), l.throughput.assign(W(1)), l.alpha.assign(0), l.isAlphaSkip.assign(!0), f.assign(!0);
2936
2919
  }).Else(() => {
2937
- c.alpha.assign(1);
2920
+ l.alpha.assign(1);
2938
2921
  });
2939
- }), m(d.not().and(r.transmission.greaterThan(0)).and(a.greaterThan(N(0))), () => {
2940
- m(l.lessThan(r.transmission), () => {
2941
- let t = A(e.direction, n).lessThan(0), i = Aa.wrap(La(e.direction, n, r, t, u, o, s));
2942
- c.direction.assign(i.direction), c.throughput.assign(i.throughput), c.continueRay.assign(!0), c.isTransmissive.assign(!0), c.didReflect.assign(i.didReflect), c.entering.assign(t), c.alpha.assign(M(1).sub(r.transmission));
2922
+ }), m(f.not().and(r.transmission.greaterThan(0)).and(a.greaterThan(N(0))), () => {
2923
+ m(u.lessThan(r.transmission), () => {
2924
+ let t = A(e.direction, n).lessThan(0), i = Aa.wrap(Ba(e.direction, n, r, t, d, o, s, c));
2925
+ l.direction.assign(i.direction), l.throughput.assign(i.throughput), l.continueRay.assign(!0), l.isTransmissive.assign(!0), l.didReflect.assign(i.didReflect), l.entering.assign(t), l.alpha.assign(M(1).sub(r.transmission)), l.pathWavelength.assign(i.pathWavelength);
2943
2926
  });
2944
2927
  });
2945
- }), c;
2946
- }), za = p(([e, t, n, r]) => {
2928
+ }), l;
2929
+ }), Ha = p(([e, t, n, r]) => {
2947
2930
  let i = W(0).toVar();
2948
2931
  return m(r.roughness.greaterThan(.98).and(r.metalness.lessThan(.02)).and(r.transmission.equal(0)).and(r.clearcoat.equal(0)).and(r.iridescence.equal(0)), () => {
2949
2932
  i.assign(r.color.rgb.mul(M(1).sub(r.metalness)).mul(Qr));
@@ -2967,17 +2950,17 @@ var Ia = p(([e, t, n, r, i, a, o, s]) => {
2967
2950
  i.assign(p);
2968
2951
  });
2969
2952
  }), i;
2970
- }), Ba = p(([e, t]) => {
2953
+ }), Ua = p(([e, t]) => {
2971
2954
  let n = E(L(fa(t.ior).mul(t.specularColor), t.color.rgb, t.metalness).mul(t.specularIntensity), W(0), W(1)).toVar(), r = pa(e.NoH, t.roughness), i = ga(e.NoV, e.NoL, t.roughness), a = ca(e.VoH, n).toVar(), o = r.mul(i).mul(a).div(I(M(4).mul(e.NoV).mul(e.NoL), ei)).mul(_a(n, e.NoV, t.roughness)), s = va(n, e.NoV, t.roughness), c = W(1).sub(s).mul(M(1).sub(t.metalness)).mul(t.color.rgb).div(Zr).add(o), l = I(t.clearcoatRoughness, ni), u = pa(e.NoH, l), d = ga(e.NoV, e.NoL, l), f = sa(e.VoH, M(.04)), p = u.mul(d).mul(f).div(I(M(4).mul(e.NoV).mul(e.NoL), ei)), m = M(1).sub(t.clearcoat.mul(f).mul(M(2).sub(f)));
2972
2955
  return c.mul(m).add(W(p).mul(t.clearcoat));
2973
- }), Va = Xt({
2956
+ }), Wa = Zt({
2974
2957
  brdf: "vec3",
2975
2958
  L: "vec3",
2976
2959
  pdf: "float"
2977
- }), Ha = p(([e, t, n, r, i]) => {
2960
+ }), Ga = p(([e, t, n, r, i]) => {
2978
2961
  let a = t.normal, o = e.direction.negate(), s = I(n.clearcoatRoughness, ni), c = I(n.roughness, ni), l = M(1).sub(c).mul(M(.5).add(M(.5).mul(n.metalness))).toVar(), u = n.clearcoat.mul(M(1).sub(s)).toVar(), d = M(1).sub(l).mul(M(1).sub(n.metalness)).toVar(), f = l.add(u).add(d);
2979
2962
  l.divAssign(f), u.divAssign(f), d.divAssign(f);
2980
- let p = dn(i), h = W(0).toVar(), g = W(0).toVar();
2963
+ let p = J(i), h = W(0).toVar(), g = W(0).toVar();
2981
2964
  m(p.lessThan(u), () => {
2982
2965
  g.assign(Ea({
2983
2966
  N: a,
@@ -2997,17 +2980,17 @@ var Ia = p(([e, t, n, r, i, a, o, s]) => {
2997
2980
  })), g.assign(R(o.add(h)));
2998
2981
  });
2999
2982
  let _ = Wr.wrap(hi(a, o, h)), v = pa(_.NoH, s).mul(_.NoH).div(M(4).mul(_.VoH)).mul(u), y = pa(_.NoH, c).mul(_.NoH).div(M(4).mul(_.VoH)).mul(l), b = _.NoL.div(Zr).mul(d), x = I(v.add(y).add(b), .001);
3000
- return Va({
3001
- brdf: Ba(_, n),
2983
+ return Wa({
2984
+ brdf: Ua(_, n),
3002
2985
  L: h,
3003
2986
  pdf: x
3004
2987
  });
3005
- }), Ua = Xt({
2988
+ }), Ka = Zt({
3006
2989
  direction: "vec3",
3007
2990
  color: "vec3",
3008
2991
  intensity: "float",
3009
2992
  angle: "float"
3010
- }), Wa = Xt({
2993
+ }), qa = Zt({
3011
2994
  position: "vec3",
3012
2995
  u: "vec3",
3013
2996
  v: "vec3",
@@ -3015,13 +2998,13 @@ var Ia = p(([e, t, n, r, i, a, o, s]) => {
3015
2998
  intensity: "float",
3016
2999
  normal: "vec3",
3017
3000
  area: "float"
3018
- }), Ga = Xt({
3001
+ }), Ja = Zt({
3019
3002
  position: "vec3",
3020
3003
  color: "vec3",
3021
3004
  intensity: "float",
3022
3005
  distance: "float",
3023
3006
  decay: "float"
3024
- }), Ka = Xt({
3007
+ }), Ya = Zt({
3025
3008
  position: "vec3",
3026
3009
  direction: "vec3",
3027
3010
  color: "vec3",
@@ -3030,30 +3013,30 @@ var Ia = p(([e, t, n, r, i, a, o, s]) => {
3030
3013
  penumbra: "float",
3031
3014
  distance: "float",
3032
3015
  decay: "float"
3033
- }), qa = Xt({
3016
+ }), Xa = Zt({
3034
3017
  direction: "vec3",
3035
3018
  emission: "vec3",
3036
3019
  pdf: "float",
3037
3020
  distance: "float",
3038
3021
  lightType: "int",
3039
3022
  valid: "bool"
3040
- }), Ja = Xt({
3023
+ }), Za = Zt({
3041
3024
  direction: "vec3",
3042
3025
  throughput: "vec3",
3043
3026
  misWeight: "float",
3044
3027
  pdf: "float",
3045
3028
  combinedPdf: "float"
3046
- }), Ya = p(([e, t]) => {
3029
+ }), Qa = p(([e, t]) => {
3047
3030
  let n = t.mul(8);
3048
- return Ua({
3031
+ return Ka({
3049
3032
  direction: R(W(e.element(n), e.element(n.add(1)), e.element(n.add(2)))),
3050
3033
  color: W(e.element(n.add(3)), e.element(n.add(4)), e.element(n.add(5))),
3051
3034
  intensity: e.element(n.add(6)),
3052
3035
  angle: e.element(n.add(7))
3053
3036
  });
3054
- }), Xa = p(([e, t]) => {
3037
+ }), $a = p(([e, t]) => {
3055
3038
  let n = t.mul(13), r = W(e.element(n.add(3)), e.element(n.add(4)), e.element(n.add(5))).toVar(), i = W(e.element(n.add(6)), e.element(n.add(7)), e.element(n.add(8))).toVar(), a = O(r, i);
3056
- return Wa({
3039
+ return qa({
3057
3040
  position: W(e.element(n), e.element(n.add(1)), e.element(n.add(2))),
3058
3041
  u: r,
3059
3042
  v: i,
@@ -3062,18 +3045,18 @@ var Ia = p(([e, t, n, r, i, a, o, s]) => {
3062
3045
  normal: R(a),
3063
3046
  area: ne(a).mul(4)
3064
3047
  });
3065
- }), Za = p(([e, t]) => {
3048
+ }), eo = p(([e, t]) => {
3066
3049
  let n = t.mul(9);
3067
- return Ga({
3050
+ return Ja({
3068
3051
  position: W(e.element(n), e.element(n.add(1)), e.element(n.add(2))),
3069
3052
  color: W(e.element(n.add(3)), e.element(n.add(4)), e.element(n.add(5))),
3070
3053
  intensity: e.element(n.add(6)),
3071
3054
  distance: e.element(n.add(7)),
3072
3055
  decay: e.element(n.add(8))
3073
3056
  });
3074
- }), Qa = p(([e, t]) => {
3057
+ }), to = p(([e, t]) => {
3075
3058
  let n = t.mul(14);
3076
- return Ka({
3059
+ return Ya({
3077
3060
  position: W(e.element(n), e.element(n.add(1)), e.element(n.add(2))),
3078
3061
  direction: R(W(e.element(n.add(3)), e.element(n.add(4)), e.element(n.add(5)))),
3079
3062
  color: W(e.element(n.add(6)), e.element(n.add(7)), e.element(n.add(8))),
@@ -3083,7 +3066,7 @@ var Ia = p(([e, t, n, r, i, a, o, s]) => {
3083
3066
  distance: e.element(n.add(12)),
3084
3067
  decay: e.element(n.add(13))
3085
3068
  });
3086
- }), $a = /* @__PURE__ */ K("\n fn isDirectionValid( direction: vec3f, surfaceNormal: vec3f ) -> bool {\n return dot( direction, surfaceNormal ) > 0.0f;\n }\n"), eo = /* @__PURE__ */ K("\n fn getDistanceAttenuation( lightDistance: f32, cutoffDistance: f32, decayExponent: f32 ) -> f32 {\n var distanceFalloff = 1.0f / max( pow( lightDistance, decayExponent ), 0.01f );\n if ( cutoffDistance > 0.0f ) {\n let ratio = pow( lightDistance / cutoffDistance, 4.0f );\n distanceFalloff *= pow( clamp( 1.0f - ratio, 0.0f, 1.0f ), 2.0f );\n }\n return distanceFalloff;\n }\n"), to = /* @__PURE__ */ K("\n fn getSpotAttenuation( coneCosine: f32, penumbraCosine: f32, angleCosine: f32 ) -> f32 {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n }\n"), no = p(([e, t, n]) => {
3069
+ }), no = /* @__PURE__ */ K("\n fn isDirectionValid( direction: vec3f, surfaceNormal: vec3f ) -> bool {\n return dot( direction, surfaceNormal ) > 0.0f;\n }\n"), ro = /* @__PURE__ */ K("\n fn getDistanceAttenuation( lightDistance: f32, cutoffDistance: f32, decayExponent: f32 ) -> f32 {\n var distanceFalloff = 1.0f / max( pow( lightDistance, decayExponent ), 0.01f );\n if ( cutoffDistance > 0.0f ) {\n let ratio = pow( lightDistance / cutoffDistance, 4.0f );\n distanceFalloff *= pow( clamp( 1.0f - ratio, 0.0f, 1.0f ), 2.0f );\n }\n return distanceFalloff;\n }\n"), io = /* @__PURE__ */ K("\n fn getSpotAttenuation( coneCosine: f32, penumbraCosine: f32, angleCosine: f32 ) -> f32 {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n }\n"), ao = p(([e, t, n]) => {
3087
3070
  let r = e.normal, i = A(r, n), a = M(-1).toVar();
3088
3071
  return m(i.lessThan(-1e-4), () => {
3089
3072
  let o = M(1).div(i), s = A(e.position.sub(t), r).mul(o).toVar();
@@ -3094,14 +3077,14 @@ var Ia = p(([e, t, n, r, i, a, o, s]) => {
3094
3077
  });
3095
3078
  });
3096
3079
  }), a;
3097
- }), ro = null, io = null;
3098
- function ao(e) {
3099
- ro = e;
3080
+ }), oo = null, so = null;
3081
+ function co(e) {
3082
+ oo = e;
3100
3083
  }
3101
- function oo(e) {
3102
- io = e;
3084
+ function lo(e) {
3085
+ so = e;
3103
3086
  }
3104
- var so = p(([e, t, n, r, i, a, o, s]) => {
3087
+ var uo = p(([e, t, n, r, i, a, o, s]) => {
3105
3088
  let c = M(1).toVar(), l = e.toVar(), u = M(n).toVar();
3106
3089
  return h({
3107
3090
  start: N(0),
@@ -3119,14 +3102,14 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3119
3102
  c.assign(0), d();
3120
3103
  });
3121
3104
  let p = zr.wrap(Ci(n.materialIndex, s)), h = T(!1).toVar();
3122
- io && m(io.equal(N(1)), () => {
3105
+ so && m(so.equal(N(1)), () => {
3123
3106
  let e = M(1).toVar();
3124
- ro && m(p.albedoMapIndex.greaterThanEqual(N(0)), () => {
3107
+ oo && m(p.albedoMapIndex.greaterThanEqual(N(0)), () => {
3125
3108
  let t = n.uv.x, r = n.uv.y, i = M(1).sub(t).sub(r), a = N(8), s = $(o, n.triangleIndex, N(6), a), c = $(o, n.triangleIndex, N(7), a), l = Hi({
3126
3109
  uv: s.xy.mul(i).add(s.zw.mul(t)).add(c.xy.mul(r)),
3127
3110
  transform: p.albedoTransform
3128
3111
  });
3129
- e.assign(be(ro, l).depth(N(p.albedoMapIndex)).a);
3112
+ e.assign(be(oo, l).depth(N(p.albedoMapIndex)).a);
3130
3113
  }), m(p.alphaMode.equal(N(1)), () => {
3131
3114
  let t = p.color.a.mul(e), n = z(p.alphaTest.greaterThan(0), p.alphaTest, M(.5));
3132
3115
  m(t.lessThan(n), () => {
@@ -3144,7 +3127,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3144
3127
  }).ElseIf(p.transmission.greaterThan(0), () => {
3145
3128
  let e = A(t, n.normal).lessThan(0), r = z(e, n.normal, n.normal.negate());
3146
3129
  m(e.not().and(p.attenuationDistance.greaterThan(0)), () => {
3147
- let e = ne(n.hitPoint.sub(l)), t = Fa(p.attenuationColor, p.attenuationDistance, e);
3130
+ let e = ne(n.hitPoint.sub(l)), t = Ra(p.attenuationColor, p.attenuationDistance, e);
3148
3131
  c.mulAssign(t.x.add(t.y).add(t.z).div(3));
3149
3132
  });
3150
3133
  let i = sa(_(A(t, r)), da(p.ior, M(1))), a = M(1).sub(i).mul(p.transmission);
@@ -3159,14 +3142,14 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3159
3142
  c.assign(0), d();
3160
3143
  });
3161
3144
  }), c;
3162
- }), co = p(([e, t, n]) => {
3145
+ }), fo = p(([e, t, n]) => {
3163
3146
  let r = I(M(1e-4), ne(e).mul(1e-6)).toVar().toVar();
3164
3147
  return m(n.transmission.greaterThan(0), () => {
3165
3148
  r.mulAssign(2);
3166
3149
  }), m(n.roughness.lessThan(.1), () => {
3167
3150
  r.mulAssign(1.5);
3168
3151
  }), t.mul(r);
3169
- }), lo = p(([e, t, n, r, i]) => {
3152
+ }), po = p(([e, t, n, r, i]) => {
3170
3153
  let a = I(M(0), A(n, e.direction)), o = M(0).toVar();
3171
3154
  return m(a.greaterThan(0), () => {
3172
3155
  let t = e.intensity.mul(A(e.color, ii)), n = M(1).toVar();
@@ -3178,7 +3161,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3178
3161
  let s = M(1).div(M(1).add(M(i).mul(.5)));
3179
3162
  o.assign(t.mul(a).mul(n).mul(s));
3180
3163
  }), o;
3181
- }), uo = p(([e, t, n, r]) => {
3164
+ }), mo = p(([e, t, n, r]) => {
3182
3165
  let i = e.position.sub(t), a = ne(i), o = a.mul(a), s = i.div(a), c = I(A(n, s), 0), l = M(0).toVar();
3183
3166
  return m(c.greaterThan(0), () => {
3184
3167
  let t = I(A(s, e.normal).negate(), 0);
@@ -3196,7 +3179,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3196
3179
  }), l.assign(i.mul(n).mul(c).mul(t).mul(a));
3197
3180
  });
3198
3181
  }), l;
3199
- }), fo = p(([e, t, n, r]) => {
3182
+ }), ho = p(([e, t, n, r]) => {
3200
3183
  let i = e.position.sub(t), a = A(i, i), o = M(0).toVar();
3201
3184
  return m(a.greaterThanEqual(.001), () => {
3202
3185
  let t = ge(a), s = i.div(t), c = I(M(0), A(n, s));
@@ -3213,7 +3196,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3213
3196
  }), o.assign(n.mul(t).mul(c).mul(i));
3214
3197
  });
3215
3198
  }), o;
3216
- }), po = p(([e, t, n, r]) => {
3199
+ }), go = p(([e, t, n, r]) => {
3217
3200
  let i = e.position.sub(t), a = A(i, i), o = M(0).toVar();
3218
3201
  return m(a.greaterThanEqual(.001), () => {
3219
3202
  let t = i.div(ge(a)), s = I(M(0), A(n, t));
@@ -3225,7 +3208,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3225
3208
  });
3226
3209
  });
3227
3210
  }), o;
3228
- }), mo = 2 * Zr, ho = p(([e, t, n, r]) => {
3211
+ }), _o = 2 * Zr, vo = p(([e, t, n, r]) => {
3229
3212
  let i = T(!1).toVar(), a = W(0, 1, 0).toVar(), o = W(0).toVar(), s = M(0).toVar(), c = M(0).toVar(), l = N(2).toVar();
3230
3213
  return m(e.area.greaterThan(0), () => {
3231
3214
  let u = e.position.add(e.u.mul(n.x.mul(2).sub(1))).add(e.v.mul(n.y.mul(2).sub(1))).toVar().sub(t).toVar(), d = A(u, u).toVar();
@@ -3233,7 +3216,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3233
3216
  let t = ge(d).toVar(), n = u.div(t).toVar(), f = R(O(e.u, e.v)).toVar(), p = A(n.negate(), f).toVar();
3234
3217
  l.assign(N(1)), o.assign(e.color.mul(e.intensity)), s.assign(t), a.assign(n), c.assign(d.div(I(e.area.mul(I(p, .001)), 1e-10)).mul(r)), i.assign(p.greaterThan(0));
3235
3218
  });
3236
- }), qa({
3219
+ }), Xa({
3237
3220
  valid: i,
3238
3221
  direction: a,
3239
3222
  emission: o,
@@ -3241,23 +3224,23 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3241
3224
  pdf: c,
3242
3225
  lightType: l
3243
3226
  });
3244
- }), go = p(([e, t, n, r]) => {
3227
+ }), yo = p(([e, t, n, r]) => {
3245
3228
  let i = T(!1).toVar(), a = W(0, 1, 0).toVar(), o = W(0).toVar(), s = M(0).toVar(), c = M(0).toVar(), l = N(3).toVar(), u = e.position.sub(t).toVar(), d = ne(u).toVar();
3246
3229
  return m(d.greaterThanEqual(1e-10), () => {
3247
3230
  let t = u.div(d).toVar(), n = A(t.negate(), e.direction).toVar(), l = D(e.angle).toVar();
3248
3231
  a.assign(t), s.assign(d), c.assign(r), i.assign(n.greaterThanEqual(l)), m(i, () => {
3249
- let t = to({
3232
+ let t = io({
3250
3233
  coneCosine: l,
3251
3234
  penumbraCosine: D(e.angle.mul(M(1).sub(e.penumbra))).max(l.add(1e-5)).toVar(),
3252
3235
  angleCosine: n
3253
- }), r = eo({
3236
+ }), r = ro({
3254
3237
  lightDistance: d,
3255
3238
  cutoffDistance: e.distance,
3256
3239
  decayExponent: e.decay
3257
3240
  });
3258
3241
  o.assign(e.color.mul(e.intensity).mul(r).mul(t));
3259
3242
  });
3260
- }), qa({
3243
+ }), Xa({
3261
3244
  valid: i,
3262
3245
  direction: a,
3263
3246
  emission: o,
@@ -3265,16 +3248,16 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3265
3248
  pdf: c,
3266
3249
  lightType: l
3267
3250
  });
3268
- }), _o = p(([e, t, n]) => {
3251
+ }), bo = p(([e, t, n]) => {
3269
3252
  let r = T(!1).toVar(), i = W(0, 1, 0).toVar(), a = W(0).toVar(), o = M(0).toVar(), s = M(0).toVar(), c = N(2).toVar(), l = e.position.sub(t).toVar(), u = ne(l).toVar();
3270
3253
  return m(u.greaterThanEqual(1e-10), () => {
3271
- let t = l.div(u).toVar(), d = eo({
3254
+ let t = l.div(u).toVar(), d = ro({
3272
3255
  lightDistance: u,
3273
3256
  cutoffDistance: e.distance,
3274
3257
  decayExponent: e.decay
3275
3258
  });
3276
3259
  c.assign(N(2)), i.assign(t), o.assign(u), a.assign(e.color.mul(e.intensity).mul(d)), s.assign(n), r.assign(T(!0));
3277
- }), qa({
3260
+ }), Xa({
3278
3261
  valid: r,
3279
3262
  direction: i,
3280
3263
  emission: a,
@@ -3282,7 +3265,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3282
3265
  pdf: s,
3283
3266
  lightType: c
3284
3267
  });
3285
- }), vo = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p]) => {
3268
+ }), xo = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p]) => {
3286
3269
  let g = T(!1).toVar(), v = W(0, 1, 0).toVar(), y = W(0).toVar(), b = M(0).toVar(), x = M(0).toVar(), S = N(2).toVar(), C = s.add(l).add(d).add(p).toVar();
3287
3270
  return m(C.greaterThan(N(0)), () => {
3288
3271
  let w = M(0).toVar(), E = N(0).toVar();
@@ -3294,8 +3277,8 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3294
3277
  condition: "<"
3295
3278
  }, ({ i: r }) => {
3296
3279
  m(E.lessThan(N(16)), () => {
3297
- let a = Ua.wrap(Ya(o, r));
3298
- w.addAssign(lo(a, e, t, n, i)), E.addAssign(1);
3280
+ let a = Ka.wrap(Qa(o, r));
3281
+ w.addAssign(po(a, e, t, n, i)), E.addAssign(1);
3299
3282
  });
3300
3283
  });
3301
3284
  }), m(l.greaterThan(N(0)), () => {
@@ -3306,7 +3289,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3306
3289
  condition: "<"
3307
3290
  }, ({ i: r }) => {
3308
3291
  m(E.lessThan(N(16)), () => {
3309
- let i = Wa.wrap(Xa(c, r)), a = z(i.intensity.greaterThan(0), uo(i, e, t, n), M(0));
3292
+ let i = qa.wrap($a(c, r)), a = z(i.intensity.greaterThan(0), mo(i, e, t, n), M(0));
3310
3293
  w.addAssign(a), E.addAssign(1);
3311
3294
  });
3312
3295
  });
@@ -3318,8 +3301,8 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3318
3301
  condition: "<"
3319
3302
  }, ({ i: r }) => {
3320
3303
  m(E.lessThan(N(16)), () => {
3321
- let i = Ga.wrap(Za(u, r));
3322
- w.addAssign(fo(i, e, t, n)), E.addAssign(1);
3304
+ let i = Ja.wrap(eo(u, r));
3305
+ w.addAssign(ho(i, e, t, n)), E.addAssign(1);
3323
3306
  });
3324
3307
  });
3325
3308
  }), m(p.greaterThan(N(0)), () => {
@@ -3330,8 +3313,8 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3330
3313
  condition: "<"
3331
3314
  }, ({ i: r }) => {
3332
3315
  m(E.lessThan(N(16)), () => {
3333
- let i = Ka.wrap(Qa(f, r));
3334
- w.addAssign(po(i, e, t, n)), E.addAssign(1);
3316
+ let i = Ya.wrap(to(f, r));
3317
+ w.addAssign(go(i, e, t, n)), E.addAssign(1);
3335
3318
  });
3336
3319
  });
3337
3320
  }), m(w.lessThanEqual(0), () => {
@@ -3340,32 +3323,32 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3340
3323
  let i = T(!1).toVar(), h = N(0).toVar();
3341
3324
  m(s.greaterThan(N(0)), () => {
3342
3325
  m(i.not().and(t.greaterThanEqual(h)).and(t.lessThan(h.add(s))), () => {
3343
- let e = Ua.wrap(Ya(o, t.sub(h)));
3326
+ let e = Ka.wrap(Qa(o, t.sub(h)));
3344
3327
  m(e.intensity.greaterThan(0), () => {
3345
3328
  v.assign(R(e.direction)), y.assign(e.color.mul(e.intensity)), b.assign(1e6), S.assign(N(0)), g.assign(T(!0)), i.assign(T(!0));
3346
3329
  });
3347
3330
  }), h.addAssign(s);
3348
3331
  }), m(l.greaterThan(N(0)), () => {
3349
3332
  m(i.not().and(t.greaterThanEqual(h)).and(t.lessThan(h.add(l))), () => {
3350
- let o = Wa.wrap(Xa(c, t.sub(h)));
3333
+ let o = qa.wrap($a(c, t.sub(h)));
3351
3334
  m(o.intensity.greaterThan(0), () => {
3352
- let t = U(r.y, dn(a)).toVar(), s = qa.wrap(ho(o, e, t, n));
3335
+ let t = U(r.y, J(a)).toVar(), s = Xa.wrap(vo(o, e, t, n));
3353
3336
  g.assign(s.valid), v.assign(s.direction), y.assign(s.emission), b.assign(s.distance), x.assign(s.pdf), S.assign(s.lightType), i.assign(T(!0));
3354
3337
  });
3355
3338
  }), h.addAssign(l);
3356
3339
  }), m(d.greaterThan(N(0)), () => {
3357
3340
  m(i.not().and(t.greaterThanEqual(h)).and(t.lessThan(h.add(d))), () => {
3358
- let r = Ga.wrap(Za(u, t.sub(h)));
3341
+ let r = Ja.wrap(eo(u, t.sub(h)));
3359
3342
  m(r.intensity.greaterThan(0), () => {
3360
- let t = qa.wrap(_o(r, e, n));
3343
+ let t = Xa.wrap(bo(r, e, n));
3361
3344
  g.assign(t.valid), v.assign(t.direction), y.assign(t.emission), b.assign(t.distance), x.assign(t.pdf), S.assign(t.lightType), i.assign(T(!0));
3362
3345
  });
3363
3346
  }), h.addAssign(d);
3364
3347
  }), m(p.greaterThan(N(0)), () => {
3365
3348
  m(i.not().and(t.greaterThanEqual(h)).and(t.lessThan(h.add(p))), () => {
3366
- let o = Ka.wrap(Qa(f, t.sub(h)));
3349
+ let o = Ya.wrap(to(f, t.sub(h)));
3367
3350
  m(o.intensity.greaterThan(0), () => {
3368
- let t = U(r.y, dn(a)).toVar(), s = qa.wrap(go(o, e, t, n));
3351
+ let t = U(r.y, J(a)).toVar(), s = Xa.wrap(yo(o, e, t, n));
3369
3352
  g.assign(s.valid), v.assign(s.direction), y.assign(s.emission), b.assign(s.distance), x.assign(s.pdf), S.assign(s.lightType), i.assign(T(!0));
3370
3353
  });
3371
3354
  });
@@ -3382,7 +3365,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3382
3365
  condition: "<"
3383
3366
  }, ({ i: r }) => {
3384
3367
  m(E.lessThan(N(16)).and(A.lessThan(N(0))), () => {
3385
- let a = lo(Ua.wrap(Ya(o, r)), e, t, n, i).toVar(), s = k.toVar();
3368
+ let a = po(Ka.wrap(Qa(o, r)), e, t, n, i).toVar(), s = k.toVar();
3386
3369
  k.addAssign(a), m(C.greaterThan(s).and(C.lessThanEqual(k)), () => {
3387
3370
  A.assign(0), j.assign(r), ee.assign(a);
3388
3371
  });
@@ -3396,7 +3379,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3396
3379
  condition: "<"
3397
3380
  }, ({ i: r }) => {
3398
3381
  m(E.lessThan(N(16)).and(A.lessThan(N(0))), () => {
3399
- let i = Wa.wrap(Xa(c, r)), a = z(i.intensity.greaterThan(0), uo(i, e, t, n), M(0)).toVar(), o = k.toVar();
3382
+ let i = qa.wrap($a(c, r)), a = z(i.intensity.greaterThan(0), mo(i, e, t, n), M(0)).toVar(), o = k.toVar();
3400
3383
  k.addAssign(a), m(C.greaterThan(o).and(C.lessThanEqual(k)), () => {
3401
3384
  A.assign(1), j.assign(r), ee.assign(a);
3402
3385
  });
@@ -3410,7 +3393,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3410
3393
  condition: "<"
3411
3394
  }, ({ i: r }) => {
3412
3395
  m(E.lessThan(N(16)).and(A.lessThan(N(0))), () => {
3413
- let i = fo(Ga.wrap(Za(u, r)), e, t, n).toVar(), a = k.toVar();
3396
+ let i = ho(Ja.wrap(eo(u, r)), e, t, n).toVar(), a = k.toVar();
3414
3397
  k.addAssign(i), m(C.greaterThan(a).and(C.lessThanEqual(k)), () => {
3415
3398
  A.assign(2), j.assign(r), ee.assign(i);
3416
3399
  });
@@ -3424,7 +3407,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3424
3407
  condition: "<"
3425
3408
  }, ({ i: r }) => {
3426
3409
  m(E.lessThan(N(16)).and(A.lessThan(N(0))), () => {
3427
- let i = po(Ka.wrap(Qa(f, r)), e, t, n).toVar(), a = k.toVar();
3410
+ let i = go(Ya.wrap(to(f, r)), e, t, n).toVar(), a = k.toVar();
3428
3411
  k.addAssign(i), m(C.greaterThan(a).and(C.lessThanEqual(k)), () => {
3429
3412
  A.assign(3), j.assign(r), ee.assign(i);
3430
3413
  });
@@ -3433,25 +3416,25 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3433
3416
  });
3434
3417
  let te = ee.div(I(w, 1e-10)).toVar();
3435
3418
  m(A.equal(N(0)).and(j.greaterThanEqual(N(0))), () => {
3436
- let e = Ua.wrap(Ya(o, j)), t = R(e.direction).toVar(), n = M(1).toVar();
3419
+ let e = Ka.wrap(Qa(o, j)), t = R(e.direction).toVar(), n = M(1).toVar();
3437
3420
  m(e.angle.greaterThan(0), () => {
3438
- let i = D(e.angle.mul(.5)).toVar(), o = L(i, M(1), r.y).toVar(), s = ge(I(M(0), M(1).sub(o.mul(o)))).toVar(), c = M(mo).mul(dn(a)).toVar(), l = R(e.direction).toVar(), u = R(O(z(_(l.x).greaterThan(.9), W(0, 1, 0), W(1, 0, 0)), l)).toVar(), d = O(l, u).toVar();
3421
+ let i = D(e.angle.mul(.5)).toVar(), o = L(i, M(1), r.y).toVar(), s = ge(I(M(0), M(1).sub(o.mul(o)))).toVar(), c = M(_o).mul(J(a)).toVar(), l = R(e.direction).toVar(), u = R(O(z(_(l.x).greaterThan(.9), W(0, 1, 0), W(1, 0, 0)), l)).toVar(), d = O(l, u).toVar();
3439
3422
  t.assign(R(l.mul(o).add(u.mul(D(c)).add(d.mul(me(c))).mul(s))));
3440
- let f = M(mo).mul(I(M(1).sub(i), 1e-10)).toVar();
3423
+ let f = M(_o).mul(I(M(1).sub(i), 1e-10)).toVar();
3441
3424
  n.assign(M(1).div(f));
3442
3425
  }), v.assign(t), y.assign(e.color.mul(e.intensity)), b.assign(1e6), x.assign(n.mul(te)), S.assign(N(0)), g.assign(T(!0));
3443
3426
  }), m(A.equal(N(1)).and(j.greaterThanEqual(N(0))), () => {
3444
- let t = Wa.wrap(Xa(c, j)), n = U(r.y, dn(a)).toVar(), i = qa.wrap(ho(t, e, n, te));
3427
+ let t = qa.wrap($a(c, j)), n = U(r.y, J(a)).toVar(), i = Xa.wrap(vo(t, e, n, te));
3445
3428
  g.assign(i.valid), v.assign(i.direction), y.assign(i.emission), b.assign(i.distance), x.assign(i.pdf), S.assign(i.lightType);
3446
3429
  }), m(A.equal(N(2)).and(j.greaterThanEqual(N(0))), () => {
3447
- let t = Ga.wrap(Za(u, j)), n = qa.wrap(_o(t, e, te));
3430
+ let t = Ja.wrap(eo(u, j)), n = Xa.wrap(bo(t, e, te));
3448
3431
  g.assign(n.valid), v.assign(n.direction), y.assign(n.emission), b.assign(n.distance), x.assign(n.pdf), S.assign(n.lightType);
3449
3432
  }), m(A.equal(N(3)).and(j.greaterThanEqual(N(0))), () => {
3450
- let t = Ka.wrap(Qa(f, j)), n = U(r.y, dn(a)).toVar(), i = qa.wrap(go(t, e, n, te));
3433
+ let t = Ya.wrap(to(f, j)), n = U(r.y, J(a)).toVar(), i = Xa.wrap(yo(t, e, n, te));
3451
3434
  g.assign(i.valid), v.assign(i.direction), y.assign(i.emission), b.assign(i.distance), x.assign(i.pdf), S.assign(i.lightType);
3452
3435
  });
3453
3436
  });
3454
- }), qa({
3437
+ }), Xa({
3455
3438
  valid: g,
3456
3439
  direction: v,
3457
3440
  emission: y,
@@ -3459,7 +3442,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3459
3442
  pdf: x,
3460
3443
  lightType: S
3461
3444
  });
3462
- }), yo = p(([e, t, n, r]) => {
3445
+ }), So = p(([e, t, n, r]) => {
3463
3446
  let i = I(M(0), A(n, e)).toVar(), a = I(M(0), A(n, t)).toVar(), o = R(e.add(t)).toVar(), s = I(M(0), A(n, o)).toVar();
3464
3447
  I(M(0), A(e, o)).toVar();
3465
3448
  let c = M(1).sub(r.metalness).mul(M(1).sub(r.transmission)).toVar(), l = M(1).sub(c.mul(M(1).sub(r.metalness))).toVar(), u = c.add(l).toVar(), d = M(0).toVar();
@@ -3472,7 +3455,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3472
3455
  d.addAssign(l.mul(ba(s, i, e)));
3473
3456
  });
3474
3457
  }), I(d, 1e-8);
3475
- }), bo = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, g, _, v, y, b, x, S, C, w, E, D, O, k, j, ee]) => {
3458
+ }), Co = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, g, _, v, y, b, x, S, C, w, E, D, O, k, j, ee]) => {
3476
3459
  let te = W(0).toVar(), P = e.add(t.mul(.001)).toVar();
3477
3460
  return m(n.emissiveIntensity.lessThanEqual(10), () => {
3478
3461
  let s = W(1).toVar(), ne = Xr.wrap(bi(n.roughness, n.metalness, n.transmission, c, s)), re = ne.useBRDFSampling.toVar(), F = ne.useLightSampling.toVar(), ie = ne.brdfWeight.toVar(), ae = ne.lightWeight.toVar(), L = d.add(p).add(_).add(y).toVar(), se = M(.001).mul(M(1).add(M(c).mul(.5))).toVar(), R = L.greaterThan(N(0)).toVar(), ce = M(0).toVar();
@@ -3483,7 +3466,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3483
3466
  }), m(ce.lessThanEqual(0), () => {
3484
3467
  ce.assign(1), re.assign(T(!0)), ie.assign(1);
3485
3468
  });
3486
- let le = dn(l).toVar(), ue = dn(l).toVar(), de = le, fe = T(!1).toVar(), pe = T(!1).toVar(), me = z(R, ae, M(0)).toVar(), he = M(1).div(I(ce, 1e-10)).toVar(), ge = me.mul(he).toVar();
3469
+ let le = J(l).toVar(), ue = J(l).toVar(), de = le, fe = T(!1).toVar(), pe = T(!1).toVar(), me = z(R, ae, M(0)).toVar(), he = M(1).div(I(ce, 1e-10)).toVar(), ge = me.mul(he).toVar();
3487
3470
  m(de.lessThan(ge).and(F).and(R), () => {
3488
3471
  fe.assign(T(!0));
3489
3472
  }).ElseIf(re, () => {
@@ -3491,16 +3474,16 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3491
3474
  }).ElseIf(R, () => {
3492
3475
  fe.assign(T(!0));
3493
3476
  }), m(fe, () => {
3494
- let e = U(ue, dn(l)).toVar(), i = qa.wrap(vo(P, t, n, e, c, l, u, d, f, p, g, _, v, y));
3477
+ let e = U(ue, J(l)).toVar(), i = Xa.wrap(xo(P, t, n, e, c, l, u, d, f, p, g, _, v, y));
3495
3478
  m(i.valid.and(i.pdf.greaterThan(0)), () => {
3496
3479
  let e = I(M(0), A(t, i.direction)).toVar(), a = i.emission.x.add(i.emission.y).add(i.emission.z).toVar();
3497
- m(e.greaterThan(0).and(a.mul(e).greaterThan(se)).and($a({
3480
+ m(e.greaterThan(0).and(a.mul(e).greaterThan(se)).and(no({
3498
3481
  direction: i.direction,
3499
3482
  surfaceNormal: t
3500
3483
  })), () => {
3501
- let a = oe(i.distance.sub(.001), M(1e3)).toVar(), o = so(P, i.direction, a, l, Pi, b, x, S);
3484
+ let a = oe(i.distance.sub(.001), M(1e3)).toVar(), o = uo(P, i.direction, a, l, Pi, b, x, S);
3502
3485
  m(o.greaterThan(0), () => {
3503
- let a = za(r, i.direction, t, n), s = yo(r, i.direction, t, n).toVar(), c = M(1).toVar();
3486
+ let a = Ha(r, i.direction, t, n), s = So(r, i.direction, t, n).toVar(), c = M(1).toVar();
3504
3487
  m(s.greaterThan(0).and(re), () => {
3505
3488
  let e = i.pdf.mul(ae).toVar(), t = s.mul(ie).toVar();
3506
3489
  m(i.lightType.equal(N(1)), () => {
@@ -3518,7 +3501,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3518
3501
  }), m(pe, () => {
3519
3502
  m(a.greaterThan(0).and(re), () => {
3520
3503
  let r = I(M(0), A(t, i)).toVar();
3521
- m(r.greaterThan(0).and($a({
3504
+ m(r.greaterThan(0).and(no({
3522
3505
  direction: i,
3523
3506
  surfaceNormal: t
3524
3507
  })), () => {
@@ -3530,11 +3513,11 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3530
3513
  type: "int",
3531
3514
  condition: "<"
3532
3515
  }, ({ i: r }) => {
3533
- let a = Wa.wrap(Xa(f, r));
3516
+ let a = qa.wrap($a(f, r));
3534
3517
  m(a.intensity.greaterThan(0), () => {
3535
- let o = uo(a, e, t, n).toVar();
3518
+ let o = mo(a, e, t, n).toVar();
3536
3519
  m(o.greaterThanEqual(se), () => {
3537
- m(no(a, P, i).toVar().greaterThan(0), () => {
3520
+ m(ao(a, P, i).toVar().greaterThan(0), () => {
3538
3521
  m(o.greaterThan(c), () => {
3539
3522
  c.assign(o), u.assign(r);
3540
3523
  }), s.assign(T(!0));
@@ -3542,9 +3525,9 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3542
3525
  });
3543
3526
  });
3544
3527
  }), m(s.and(u.greaterThanEqual(N(0))), () => {
3545
- let e = Wa.wrap(Xa(f, u)), t = no(e, P, i).toVar();
3528
+ let e = qa.wrap($a(f, u)), t = ao(e, P, i).toVar();
3546
3529
  m(t.greaterThan(0), () => {
3547
- let n = so(P, i, oe(t.sub(.001), M(1e3)).toVar(), l, Pi, b, x, S);
3530
+ let n = uo(P, i, oe(t.sub(.001), M(1e3)).toVar(), l, Pi, b, x, S);
3548
3531
  m(n.greaterThan(0), () => {
3549
3532
  let s = I(M(0), A(i, e.normal).negate()).toVar();
3550
3533
  m(s.greaterThan(0), () => {
@@ -3563,16 +3546,16 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3563
3546
  });
3564
3547
  });
3565
3548
  }), m(ee, () => {
3566
- let e = U(dn(l).toVar(), dn(l).toVar()).toVar(), i = W(0).toVar(), a = Bi(C, D, E, w, O, k, j, e, i).toVar(), o = a.xyz.toVar(), s = a.w.toVar();
3549
+ let e = U(J(l).toVar(), J(l).toVar()).toVar(), i = W(0).toVar(), a = Bi(C, D, E, w, O, k, j, e, i).toVar(), o = a.xyz.toVar(), s = a.w.toVar();
3567
3550
  m(s.greaterThan(0), () => {
3568
3551
  let e = I(M(0), A(t, o)).toVar();
3569
- m(e.greaterThan(0).and($a({
3552
+ m(e.greaterThan(0).and(no({
3570
3553
  direction: o,
3571
3554
  surfaceNormal: t
3572
3555
  })), () => {
3573
- let a = so(P, o, M(1e3), l, Pi, b, x, S);
3556
+ let a = uo(P, o, M(1e3), l, Pi, b, x, S);
3574
3557
  m(a.greaterThan(0), () => {
3575
- let c = za(r, o, t, n), l = yo(r, o, t, n).toVar(), u = z(l.greaterThan(0), pi({
3558
+ let c = Ha(r, o, t, n), l = So(r, o, t, n).toVar(), u = z(l.greaterThan(0), pi({
3576
3559
  pdf1: s,
3577
3560
  pdf2: l
3578
3561
  }), M(1)).toVar(), d = i.mul(c).mul(e).mul(a).mul(u).div(I(s, 1e-10));
@@ -3582,17 +3565,17 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3582
3565
  });
3583
3566
  });
3584
3567
  }), te;
3585
- }), xo = p(([e, t, n, r, i, a]) => {
3568
+ }), wo = p(([e, t, n, r, i, a]) => {
3586
3569
  let o = z(a, r, M(1).div(r)).toVar(), s = e.add(t.mul(o)).toVar(), c = A(s, s).toVar(), l = z(c.greaterThan(ei), s.div(ge(c)), n).toVar();
3587
3570
  m(A(l, n).lessThan(0), () => {
3588
3571
  l.assign(l.negate());
3589
3572
  });
3590
3573
  let u = _(A(e, l)).toVar(), d = _(A(t, l)).toVar(), f = _(A(n, l)).toVar(), p = pa(f, i).toVar(), h = u.add(d.mul(o)).toVar(), g = h.mul(h).toVar(), v = d.mul(o).mul(o).div(I(g, ei)).toVar();
3591
3574
  return p.mul(f).mul(v);
3592
- }), So = p(([e, t, n, r]) => {
3575
+ }), To = p(([e, t, n, r]) => {
3593
3576
  let i = e.add(t).toVar(), a = A(i, i).toVar();
3594
3577
  return ba(I(A(n, z(a.greaterThan(ei), i.div(ge(a)), n).toVar()), 0).toVar(), I(A(n, e), 0).toVar(), r);
3595
- }), Co = p(([e, t, n, r, i]) => {
3578
+ }), Eo = p(([e, t, n, r, i]) => {
3596
3579
  let a = e.specularImportance.toVar(), o = a.greaterThan(.001).toVar(), s = e.diffuseImportance.toVar(), c = s.greaterThan(.001).toVar(), l = e.transmissionImportance.toVar(), u = l.greaterThan(.001).toVar(), d = e.clearcoatImportance.toVar(), f = d.greaterThan(.001).toVar(), p = a.add(s).add(l).add(d).toVar();
3597
3580
  return m(p.lessThan(.001), () => {
3598
3581
  a.assign(0), s.assign(1), l.assign(0), d.assign(0), p.assign(1), o.assign(T(!1)), c.assign(T(!0)), u.assign(T(!1)), f.assign(T(!1));
@@ -3612,7 +3595,7 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3612
3595
  useTransmission: u,
3613
3596
  useClearcoat: f
3614
3597
  });
3615
- }), wo = p(([e, t]) => {
3598
+ }), Do = p(([e, t]) => {
3616
3599
  let n = N(2).toVar(), r = M(1).toVar(), i = M(0).toVar(), a = T(!1).toVar();
3617
3600
  return m(e.useSpecular.and(a.not()), () => {
3618
3601
  i.addAssign(e.specularWeight), m(t.lessThan(i), () => {
@@ -3631,22 +3614,22 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3631
3614
  }), m(a.not(), () => {
3632
3615
  n.assign(2), r.assign(z(e.useDiffuse, e.diffuseWeight, M(1)));
3633
3616
  }), U(M(n), r);
3634
- }), To = p(([e]) => I(e, 0).mul(Qr)), Eo = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, h, g, v, y]) => {
3617
+ }), Oo = p(([e]) => I(e, 0).mul(Qr)), ko = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, h, g, v, y]) => {
3635
3618
  let b = W(0).toVar(), x = W(0).toVar(), S = M(0).toVar(), C = M(0).toVar(), w = M(0).toVar();
3636
3619
  return m(l.diffuseImportance.greaterThanEqual(0).and(l.specularImportance.greaterThanEqual(0)).and(l.transmissionImportance.greaterThanEqual(0)).and(l.clearcoatImportance.greaterThanEqual(0)).and(l.envmapImportance.greaterThanEqual(0)).toVar().not(), () => {
3637
- let e = U(dn(c).toVar(), dn(c).toVar()).toVar();
3620
+ let e = U(J(c).toVar(), J(c).toVar()).toVar();
3638
3621
  b.assign(Oa(t, e)), x.assign(n.color.xyz), S.assign(1), C.assign(1);
3639
3622
  }).Else(() => {
3640
- let o = Yr.wrap(Co(l, s, n, v, y).toVar()), u = dn(c).toVar(), d = U(dn(c).toVar(), dn(c).toVar()).toVar(), f = wo(o, u).toVar(), p = N(f.x).toVar();
3623
+ let o = Yr.wrap(Eo(l, s, n, v, y).toVar()), u = J(c).toVar(), d = U(J(c).toVar(), J(c).toVar()).toVar(), f = Do(o, u).toVar(), p = N(f.x).toVar();
3641
3624
  f.y.toVar();
3642
3625
  let h = W(0).toVar(), g = M(0).toVar(), T = W(0).toVar();
3643
3626
  m(p.equal(N(1)), () => {
3644
3627
  h.assign(r), g.assign(i), T.assign(a);
3645
3628
  }).ElseIf(p.equal(N(2)), () => {
3646
- h.assign(Oa(t, d)), g.assign(To(I(A(t, h), 0))), T.assign(za(e, h, t, n));
3629
+ h.assign(Oa(t, d)), g.assign(Oo(I(A(t, h), 0))), T.assign(Ha(e, h, t, n));
3647
3630
  }).ElseIf(p.equal(N(3)), () => {
3648
- let r = A(e, t).greaterThan(0).toVar(), i = Na.wrap(Ia(e, t, n.ior, n.roughness, r, n.dispersion, d, c).toVar());
3649
- h.assign(i.direction), g.assign(i.pdf), T.assign(za(e, h, t, n));
3631
+ let r = A(e, t).greaterThan(0).toVar(), i = Na.wrap(za(e, t, n.ior, n.roughness, r, n.dispersion, d, c, M(0)).toVar());
3632
+ h.assign(i.direction), g.assign(i.pdf), T.assign(Ha(e, h, t, n));
3650
3633
  }).Else(() => {
3651
3634
  h.assign(r), g.assign(i), T.assign(a);
3652
3635
  });
@@ -3655,25 +3638,25 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3655
3638
  let r = ba(I(A(t, R(e.add(h))), .001), I(A(t, e), .001), n.roughness);
3656
3639
  k.addAssign(o.specularWeight.mul(r));
3657
3640
  }), m(o.useDiffuse, () => {
3658
- let e = To(D).toVar();
3641
+ let e = Oo(D).toVar();
3659
3642
  k.addAssign(o.diffuseWeight.mul(e));
3660
3643
  }), m(o.useTransmission.and(n.transmission.greaterThan(0)), () => {
3661
- let r = A(e, t).greaterThan(0).toVar(), i = xo(e, h, t, n.ior, n.roughness, r).toVar();
3644
+ let r = A(e, t).greaterThan(0).toVar(), i = wo(e, h, t, n.ior, n.roughness, r).toVar();
3662
3645
  k.addAssign(o.transmissionWeight.mul(i));
3663
3646
  }), m(o.useClearcoat.and(n.clearcoat.greaterThan(0)), () => {
3664
- let r = So(e, h, t, n.clearcoatRoughness).toVar();
3647
+ let r = To(e, h, t, n.clearcoatRoughness).toVar();
3665
3648
  k.addAssign(o.clearcoatWeight.mul(r));
3666
3649
  }), g.assign(I(g, ri)), k.assign(I(k, ri));
3667
3650
  let j = g.div(k).toVar(), ee = z(p.equal(N(3)), O, D), te = T.mul(ee).mul(j).div(g).toVar();
3668
3651
  b.assign(h), x.assign(te), S.assign(j), C.assign(g), w.assign(k);
3669
- }), Ja({
3652
+ }), Za({
3670
3653
  direction: b,
3671
3654
  throughput: x,
3672
3655
  misWeight: S,
3673
3656
  pdf: C,
3674
3657
  combinedPdf: w
3675
3658
  });
3676
- }), Do = Xt({
3659
+ }), Ao = Zt({
3677
3660
  position: "vec3",
3678
3661
  normal: "vec3",
3679
3662
  emission: "vec3",
@@ -3683,40 +3666,40 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3683
3666
  area: "float",
3684
3667
  cosThetaLight: "float",
3685
3668
  valid: "bool"
3686
- }), Oo = Xt({
3669
+ }), jo = Zt({
3687
3670
  contribution: "vec3",
3688
3671
  hasEmissive: "bool",
3689
3672
  emissionOnly: "vec3",
3690
3673
  distance: "float"
3691
- }), ko = p(([e, t, n, r]) => {
3674
+ }), Mo = p(([e, t, n, r]) => {
3692
3675
  let i = ge(r.x), a = M(1).sub(i), o = r.y.mul(i), s = M(1).sub(a).sub(o);
3693
3676
  return e.mul(a).add(t.mul(o)).add(n.mul(s));
3694
- }), Ao = p(([e, t, n]) => ne(O(t.sub(e), n.sub(e))).mul(.5)), jo = p(([e, t, n, r]) => {
3677
+ }), No = p(([e, t, n]) => ne(O(t.sub(e), n.sub(e))).mul(.5)), Po = p(([e, t, n, r]) => {
3695
3678
  let i = R(e.sub(r)), a = R(t.sub(r)), o = R(n.sub(r)), s = _(A(i, O(a, o))), c = M(1).add(A(a, o)).add(A(i, o)).add(A(i, a));
3696
3679
  return I(M(2).mul(b(s, I(c, M(1e-10)))), M(0));
3697
- }), Mo = p(([e, t, n, r]) => {
3680
+ }), Fo = p(([e, t, n, r]) => {
3698
3681
  let i = t.sub(e), a = n.sub(e), o = n.sub(t), s = I(A(i, i), I(A(a, a), A(o, o))), c = O(i, a), l = A(c, c), u = T(!1).toVar();
3699
3682
  return m(l.greaterThan(1e-20), () => {
3700
3683
  let t = A(c, r.sub(e)), n = t.mul(t).div(l);
3701
3684
  u.assign(s.greaterThan(n));
3702
3685
  }), u;
3703
- }), No = Xt({
3686
+ }), Io = Zt({
3704
3687
  direction: "vec3",
3705
3688
  position: "vec3",
3706
3689
  solidAngle: "float",
3707
3690
  valid: "bool"
3708
- }), Po = p(([e]) => {
3691
+ }), Lo = p(([e]) => {
3709
3692
  let t = ne(e);
3710
3693
  return z(t.greaterThan(1e-10), e.div(t), W(0));
3711
- }), Fo = p(([e, t, n, r, i]) => {
3712
- let a = No({
3694
+ }), Ro = p(([e, t, n, r, i]) => {
3695
+ let a = Io({
3713
3696
  direction: W(0),
3714
3697
  position: W(0),
3715
3698
  solidAngle: M(0),
3716
3699
  valid: !1
3717
- }).toVar(), o = R(e.sub(r)), s = R(t.sub(r)), c = R(n.sub(r)), l = jo(e, t, n, r);
3700
+ }).toVar(), o = R(e.sub(r)), s = R(t.sub(r)), c = R(n.sub(r)), l = Po(e, t, n, r);
3718
3701
  return a.solidAngle.assign(l), m(l.greaterThan(1e-7), () => {
3719
- let u = E(A(Po(O(o, s)), Po(O(o, c))), -1, 1), d = ge(I(M(1).sub(u.mul(u)), 0)), f = v(u), p = i.x.mul(l).sub(f), h = me(p), g = D(p), y = E(A(o, s), -1, 1), b = g.sub(u), x = h.add(d.mul(y)), S = x.mul(g).sub(b.mul(h)).mul(u).sub(x), C = x.mul(h).add(b.mul(g)).mul(d), w = E(z(_(C).greaterThan(1e-10), S.div(C), M(1)), -1, 1), T = A(c, o), k = Po(c.sub(o.mul(T))), j = ge(I(M(1).sub(w.mul(w)), 0)), ee = R(o.mul(w).add(k.mul(j))), te = A(ee, s), N = M(1).sub(i.y.mul(M(1).sub(te))), P = ge(I(M(1).sub(N.mul(N)), 0)), ne = Po(ee.sub(s.mul(te))), re = R(s.mul(N).add(ne.mul(P))), F = R(O(t.sub(e), n.sub(e))), ie = A(F, re);
3702
+ let u = E(A(Lo(O(o, s)), Lo(O(o, c))), -1, 1), d = ge(I(M(1).sub(u.mul(u)), 0)), f = v(u), p = i.x.mul(l).sub(f), h = me(p), g = D(p), y = E(A(o, s), -1, 1), b = g.sub(u), x = h.add(d.mul(y)), S = x.mul(g).sub(b.mul(h)).mul(u).sub(x), C = x.mul(h).add(b.mul(g)).mul(d), w = E(z(_(C).greaterThan(1e-10), S.div(C), M(1)), -1, 1), T = A(c, o), k = Lo(c.sub(o.mul(T))), j = ge(I(M(1).sub(w.mul(w)), 0)), ee = R(o.mul(w).add(k.mul(j))), te = A(ee, s), N = M(1).sub(i.y.mul(M(1).sub(te))), P = ge(I(M(1).sub(N.mul(N)), 0)), ne = Lo(ee.sub(s.mul(te))), re = R(s.mul(N).add(ne.mul(P))), F = R(O(t.sub(e), n.sub(e))), ie = A(F, re);
3720
3703
  m(_(ie).greaterThan(1e-10), () => {
3721
3704
  let t = A(F, e.sub(r)).div(ie);
3722
3705
  m(t.greaterThan(0), () => {
@@ -3724,15 +3707,15 @@ var so = p(([e, t, n, r, i, a, o, s]) => {
3724
3707
  });
3725
3708
  });
3726
3709
  }), a;
3727
- }), Io = p(([e, t, n, r]) => {
3710
+ }), zo = p(([e, t, n, r]) => {
3728
3711
  let i = n.sub(t), a = r.sub(t), o = e.sub(t), s = A(i, i), c = A(i, a), l = A(a, a), u = A(o, i), d = A(o, a), f = M(1).div(I(s.mul(l).sub(c.mul(c)), M(1e-10))), p = l.mul(u).sub(c.mul(d)).mul(f), m = s.mul(d).sub(c.mul(u)).mul(f);
3729
3712
  return W(M(1).sub(p).sub(m), p, m);
3730
- }), Lo = p(([e, t, n, r]) => {
3713
+ }), Bo = p(([e, t, n, r]) => {
3731
3714
  let i = ge(r.x), a = M(1).sub(i), o = r.y.mul(i), s = M(1).sub(a).sub(o);
3732
3715
  return R(e.mul(a).add(t.mul(o)).add(n.mul(s)));
3733
3716
  });
3734
3717
  p(([e]) => e.emissiveIntensity.greaterThan(0).and(ne(e.emissive).greaterThan(0)));
3735
- var Ro = 8, zo = 2, Bo = Xt({
3718
+ var Vo = 8, Ho = 2, Uo = Zt({
3736
3719
  v0: "vec3",
3737
3720
  v1: "vec3",
3738
3721
  v2: "vec3",
@@ -3740,9 +3723,9 @@ var Ro = 8, zo = 2, Bo = Xt({
3740
3723
  n1: "vec3",
3741
3724
  n2: "vec3",
3742
3725
  materialIndex: "int"
3743
- }), Vo = p(([e, t]) => {
3744
- let n = $(t, e, N(0), N(Ro)), r = $(t, e, N(1), N(Ro)), i = $(t, e, N(2), N(Ro)), a = $(t, e, N(3), N(Ro)), o = $(t, e, N(4), N(Ro)), s = $(t, e, N(5), N(Ro)), c = $(t, e, N(7), N(Ro));
3745
- return Bo({
3726
+ }), Wo = p(([e, t]) => {
3727
+ let n = $(t, e, N(0), N(Vo)), r = $(t, e, N(1), N(Vo)), i = $(t, e, N(2), N(Vo)), a = $(t, e, N(3), N(Vo)), o = $(t, e, N(4), N(Vo)), s = $(t, e, N(5), N(Vo)), c = $(t, e, N(7), N(Vo));
3728
+ return Uo({
3746
3729
  v0: n.xyz,
3747
3730
  v1: r.xyz,
3748
3731
  v2: i.xyz,
@@ -3751,27 +3734,27 @@ var Ro = 8, zo = 2, Bo = Xt({
3751
3734
  n2: s.xyz,
3752
3735
  materialIndex: N(c.z)
3753
3736
  });
3754
- }), Ho = p(([e, t, n, r, i, a, o]) => {
3755
- let s = Bo.wrap(Vo(e, i)), c = Ao(s.v0, s.v1, s.v2), l = $(a, s.materialIndex, N(oi.EMISSIVE_ROUGHNESS), ai), u = $(a, s.materialIndex, N(oi.IOR_TRANSMISSION), ai), d = I(l.x.add(l.y).add(l.z).div(3).mul(u.a).mul(c), M(1e-10)).div(I(o, M(1e-10))), f = M(0).toVar();
3756
- return m(Mo(s.v0, s.v1, s.v2, r), () => {
3757
- let e = jo(s.v0, s.v1, s.v2, r);
3737
+ }), Go = p(([e, t, n, r, i, a, o]) => {
3738
+ let s = Uo.wrap(Wo(e, i)), c = No(s.v0, s.v1, s.v2), l = $(a, s.materialIndex, N(oi.EMISSIVE_ROUGHNESS), ai), u = $(a, s.materialIndex, N(oi.IOR_TRANSMISSION), ai), d = I(l.x.add(l.y).add(l.z).div(3).mul(u.a).mul(c), M(1e-10)).div(I(o, M(1e-10))), f = M(0).toVar();
3739
+ return m(Fo(s.v0, s.v1, s.v2, r), () => {
3740
+ let e = Po(s.v0, s.v1, s.v2, r);
3758
3741
  f.assign(d.div(I(e, M(1e-10))));
3759
3742
  }).Else(() => {
3760
3743
  let e = R(O(s.v1.sub(s.v0), s.v2.sub(s.v0))), r = I(A(n.negate(), e), .001), i = t.mul(t), a = d.div(c);
3761
3744
  f.assign(a.mul(i).div(r));
3762
3745
  }), I(f, ri);
3763
- }), Uo = p(([e, t, n, r]) => {
3746
+ }), Ko = p(([e, t, n, r]) => {
3764
3747
  let i = N(0).toVar(), a = n.sub(1).toVar();
3765
3748
  return h(i.lessThan(a), () => {
3766
- let n = i.add(a).div(2).toVar(), o = e.element(t.add(n.mul(N(zo)))).b;
3749
+ let n = i.add(a).div(2).toVar(), o = e.element(t.add(n.mul(N(Ho)))).b;
3767
3750
  m(o.lessThan(r), () => {
3768
3751
  i.assign(n.add(1));
3769
3752
  }).Else(() => {
3770
3753
  a.assign(n);
3771
3754
  });
3772
3755
  }), i;
3773
- }), Wo = p(([e, t, n, r, i, a, o, s, c]) => {
3774
- let l = Do({
3756
+ }), qo = p(([e, t, n, r, i, a, o, s, c]) => {
3757
+ let l = Ao({
3775
3758
  position: W(0),
3776
3759
  normal: W(0),
3777
3760
  emission: W(0),
@@ -3783,40 +3766,40 @@ var Ro = 8, zo = 2, Bo = Xt({
3783
3766
  valid: !1
3784
3767
  }).toVar();
3785
3768
  return m(o.greaterThan(N(0)), () => {
3786
- let n = Uo(i, a, o, dn(r)).toVar(), u = a.add(n.mul(N(zo))), d = i.element(u), f = i.element(u.add(1)), p = N(d.r), h = I(d.g, M(1e-10)), g = f.xyz, _ = f.w, v = Bo.wrap(Vo(p, c)), y = U(dn(r).toVar(), dn(r).toVar()), b = R(O(v.v1.sub(v.v0), v.v2.sub(v.v0)));
3787
- m(Mo(v.v0, v.v1, v.v2, e), () => {
3788
- let n = No.wrap(Fo(v.v0, v.v1, v.v2, e, y));
3769
+ let n = Ko(i, a, o, J(r)).toVar(), u = a.add(n.mul(N(Ho))), d = i.element(u), f = i.element(u.add(1)), p = N(d.r), h = I(d.g, M(1e-10)), g = f.xyz, _ = f.w, v = Uo.wrap(Wo(p, c)), y = U(J(r).toVar(), J(r).toVar()), b = R(O(v.v1.sub(v.v0), v.v2.sub(v.v0)));
3770
+ m(Fo(v.v0, v.v1, v.v2, e), () => {
3771
+ let n = Io.wrap(Ro(v.v0, v.v1, v.v2, e, y));
3789
3772
  m(n.valid.and(n.solidAngle.greaterThan(1e-7)), () => {
3790
3773
  let r = n.direction, i = n.position, a = A(r, t), o = A(r, b.negate());
3791
3774
  m(a.greaterThan(0).and(o.greaterThan(0)), () => {
3792
- let t = Io(i, v.v0, v.v1, v.v2), a = R(v.n0.mul(t.x).add(v.n1.mul(t.y)).add(v.n2.mul(t.z))), c = ne(i.sub(e)), u = h.div(I(s, M(1e-10))).div(n.solidAngle);
3775
+ let t = zo(i, v.v0, v.v1, v.v2), a = R(v.n0.mul(t.x).add(v.n1.mul(t.y)).add(v.n2.mul(t.z))), c = ne(i.sub(e)), u = h.div(I(s, M(1e-10))).div(n.solidAngle);
3793
3776
  l.position.assign(i), l.normal.assign(a), l.emission.assign(g), l.direction.assign(r), l.distance.assign(c), l.pdf.assign(I(u, ri)), l.area.assign(_), l.cosThetaLight.assign(o), l.valid.assign(!0);
3794
3777
  });
3795
3778
  });
3796
3779
  }).Else(() => {
3797
- let n = ko(v.v0, v.v1, v.v2, y), r = Lo(v.n0, v.n1, v.n2, y), i = n.sub(e), a = A(i, i), o = ge(a), c = i.div(o), u = A(c, t), d = A(c, r.negate());
3780
+ let n = Mo(v.v0, v.v1, v.v2, y), r = Bo(v.n0, v.n1, v.n2, y), i = n.sub(e), a = A(i, i), o = ge(a), c = i.div(o), u = A(c, t), d = A(c, r.negate());
3798
3781
  m(u.greaterThan(0).and(d.greaterThan(0)), () => {
3799
3782
  let e = h.div(I(s, M(1e-10)).mul(_)).mul(a).div(d);
3800
3783
  l.position.assign(n), l.normal.assign(r), l.emission.assign(g), l.direction.assign(c), l.distance.assign(o), l.pdf.assign(I(e, ri)), l.area.assign(_), l.cosThetaLight.assign(d), l.valid.assign(!0);
3801
3784
  });
3802
3785
  });
3803
3786
  }), l;
3804
- }), Go = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, h, g]) => {
3805
- let _ = Oo({
3787
+ }), Jo = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, h, g]) => {
3788
+ let _ = jo({
3806
3789
  contribution: W(0),
3807
3790
  hasEmissive: !1,
3808
3791
  emissionOnly: W(0),
3809
3792
  distance: M(0)
3810
3793
  }).toVar();
3811
3794
  return m(a.greaterThan(N(1)).and(r.roughness.greaterThan(.9)).and(r.metalness.lessThan(.1)).not(), () => {
3812
- let a = Do.wrap(Wo(e, t, i, o, c, l, u, d, f));
3795
+ let a = Ao.wrap(qo(e, t, i, o, c, l, u, d, f));
3813
3796
  m(a.valid.and(a.pdf.greaterThan(0)), () => {
3814
3797
  _.hasEmissive.assign(!0), _.emissionOnly.assign(a.emission), _.distance.assign(a.distance);
3815
3798
  let i = I(M(0), A(t, a.direction));
3816
3799
  m(i.greaterThan(0), () => {
3817
3800
  let c = g(e, t, r), l = e.add(c), u = a.distance.sub(.001), d = p(l, a.direction, u, o);
3818
3801
  m(d.greaterThan(0), () => {
3819
- let e = h(n, a.direction, t, r), o = yo(n, a.direction, t, r), c = z(o.greaterThan(0), fi({
3802
+ let e = h(n, a.direction, t, r), o = So(n, a.direction, t, r), c = z(o.greaterThan(0), fi({
3820
3803
  pdf1: a.pdf,
3821
3804
  pdf2: o
3822
3805
  }), M(1));
@@ -3825,8 +3808,8 @@ var Ro = 8, zo = 2, Bo = Xt({
3825
3808
  });
3826
3809
  });
3827
3810
  }), _;
3828
- }), Ko = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h]) => Oo.wrap(Go(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h)).contribution), qo = 4, Jo = 2, Yo = 32, Xo = p(([e, t, n, r, i, a, o]) => {
3829
- let s = Do({
3811
+ }), Yo = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h]) => jo.wrap(Jo(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h)).contribution), Xo = 4, Zo = 2, Qo = 32, $o = p(([e, t, n, r, i, a, o]) => {
3812
+ let s = Ao({
3830
3813
  position: W(0),
3831
3814
  normal: W(0),
3832
3815
  emission: W(0),
@@ -3837,65 +3820,65 @@ var Ro = 8, zo = 2, Bo = Xt({
3837
3820
  cosThetaLight: M(0),
3838
3821
  valid: !1
3839
3822
  }).toVar(), c = M(1).toVar(), l = N(0).toVar(), u = T(!1).toVar();
3840
- return h(Yo, () => {
3841
- let t = l.mul(N(qo)), i = r.element(t.add(N(1))), a = r.element(t.add(N(2)));
3823
+ return h(Qo, () => {
3824
+ let t = l.mul(N(Xo)), i = r.element(t.add(N(1))), a = r.element(t.add(N(2)));
3842
3825
  m(i.w.greaterThan(.5), () => {
3843
3826
  u.assign(T(!0)), d();
3844
3827
  });
3845
- let o = N(a.x), s = N(a.y), f = o.mul(N(qo)), p = r.element(f), h = r.element(f.add(N(1))), g = s.mul(N(qo)), _ = r.element(g), v = r.element(g.add(N(1))), y = W(p.x.add(h.x).mul(.5), p.y.add(h.y).mul(.5), p.z.add(h.z).mul(.5)), b = W(_.x.add(v.x).mul(.5), _.y.add(v.y).mul(.5), _.z.add(v.z).mul(.5)), x = y.sub(e), S = b.sub(e), C = I(A(x, x), M(.01)), w = I(A(S, S), M(.01)), E = I(p.w, M(0)), D = I(_.w, M(0)), O = E.div(C), k = D.div(w), j = O.add(k);
3828
+ let o = N(a.x), s = N(a.y), f = o.mul(N(Xo)), p = r.element(f), h = r.element(f.add(N(1))), g = s.mul(N(Xo)), _ = r.element(g), v = r.element(g.add(N(1))), y = W(p.x.add(h.x).mul(.5), p.y.add(h.y).mul(.5), p.z.add(h.z).mul(.5)), b = W(_.x.add(v.x).mul(.5), _.y.add(v.y).mul(.5), _.z.add(v.z).mul(.5)), x = y.sub(e), S = b.sub(e), C = I(A(x, x), M(.01)), w = I(A(S, S), M(.01)), E = I(p.w, M(0)), D = I(_.w, M(0)), O = E.div(C), k = D.div(w), j = O.add(k);
3846
3829
  m(j.lessThanEqual(M(0)), () => {
3847
3830
  l.assign(o);
3848
3831
  }).Else(() => {
3849
3832
  let e = O.div(j);
3850
- m(dn(n).lessThan(e), () => {
3833
+ m(J(n).lessThan(e), () => {
3851
3834
  c.mulAssign(e), l.assign(o);
3852
3835
  }).Else(() => {
3853
3836
  c.mulAssign(M(1).sub(e)), l.assign(s);
3854
3837
  });
3855
3838
  });
3856
3839
  }), m(u, () => {
3857
- let u = l.mul(N(qo)), f = r.element(u), p = r.element(u.add(N(2))), g = N(p.x), _ = N(p.y), v = I(f.w, M(1e-10)), y = dn(n).mul(v), b = M(0).toVar(), x = g.add(_.sub(N(1))).toVar(), S = M(1e-10).toVar();
3840
+ let u = l.mul(N(Xo)), f = r.element(u), p = r.element(u.add(N(2))), g = N(p.x), _ = N(p.y), v = I(f.w, M(1e-10)), y = J(n).mul(v), b = M(0).toVar(), x = g.add(_.sub(N(1))).toVar(), S = M(1e-10).toVar();
3858
3841
  h({
3859
3842
  start: N(0),
3860
3843
  end: _
3861
3844
  }, ({ i: e }) => {
3862
- let t = g.add(e), n = a.add(t.mul(N(Jo))), r = I(i.element(n).g, M(0));
3845
+ let t = g.add(e), n = a.add(t.mul(N(Zo))), r = I(i.element(n).g, M(0));
3863
3846
  b.addAssign(r), m(b.greaterThanEqual(y).and(r.greaterThan(M(0))), () => {
3864
3847
  x.assign(t), S.assign(r), d();
3865
3848
  });
3866
3849
  }), c.mulAssign(S.div(v));
3867
- let C = a.add(x.mul(N(Jo))), w = i.element(C), T = i.element(C.add(N(1))), E = N(w.r), D = T.xyz, k = T.w, j = Bo.wrap(Vo(E, o)), ee = U(dn(n).toVar(), dn(n).toVar()), te = R(O(j.v1.sub(j.v0), j.v2.sub(j.v0)));
3868
- m(Mo(j.v0, j.v1, j.v2, e), () => {
3869
- let n = No.wrap(Fo(j.v0, j.v1, j.v2, e, ee));
3850
+ let C = a.add(x.mul(N(Zo))), w = i.element(C), T = i.element(C.add(N(1))), E = N(w.r), D = T.xyz, k = T.w, j = Uo.wrap(Wo(E, o)), ee = U(J(n).toVar(), J(n).toVar()), te = R(O(j.v1.sub(j.v0), j.v2.sub(j.v0)));
3851
+ m(Fo(j.v0, j.v1, j.v2, e), () => {
3852
+ let n = Io.wrap(Ro(j.v0, j.v1, j.v2, e, ee));
3870
3853
  m(n.valid.and(n.solidAngle.greaterThan(M(1e-7))), () => {
3871
3854
  let r = n.direction, i = n.position, a = A(r, t), o = A(r, te.negate());
3872
3855
  m(a.greaterThan(M(0)).and(o.greaterThan(M(0))), () => {
3873
- let t = Io(i, j.v0, j.v1, j.v2), a = R(j.n0.mul(t.x).add(j.n1.mul(t.y)).add(j.n2.mul(t.z))), l = ne(i.sub(e)), u = c.div(I(n.solidAngle, M(1e-10)));
3856
+ let t = zo(i, j.v0, j.v1, j.v2), a = R(j.n0.mul(t.x).add(j.n1.mul(t.y)).add(j.n2.mul(t.z))), l = ne(i.sub(e)), u = c.div(I(n.solidAngle, M(1e-10)));
3874
3857
  s.position.assign(i), s.normal.assign(a), s.emission.assign(D), s.direction.assign(r), s.distance.assign(l), s.pdf.assign(I(u, ri)), s.area.assign(k), s.cosThetaLight.assign(o), s.valid.assign(!0);
3875
3858
  });
3876
3859
  });
3877
3860
  }).Else(() => {
3878
- let n = ko(j.v0, j.v1, j.v2, ee), r = Lo(j.n0, j.n1, j.n2, ee), i = n.sub(e), a = A(i, i), o = ge(a), l = i.div(o), u = A(l, t), d = A(l, r.negate());
3861
+ let n = Mo(j.v0, j.v1, j.v2, ee), r = Bo(j.n0, j.n1, j.n2, ee), i = n.sub(e), a = A(i, i), o = ge(a), l = i.div(o), u = A(l, t), d = A(l, r.negate());
3879
3862
  m(u.greaterThan(M(0)).and(d.greaterThan(M(0))), () => {
3880
3863
  let e = c.div(I(k, M(1e-10))).mul(a).div(d);
3881
3864
  s.position.assign(n), s.normal.assign(r), s.emission.assign(D), s.direction.assign(l), s.distance.assign(o), s.pdf.assign(I(e, ri)), s.area.assign(k), s.cosThetaLight.assign(d), s.valid.assign(!0);
3882
3865
  });
3883
3866
  });
3884
3867
  }), s;
3885
- }), Zo = 0, Qo = 1, $o = 2, es = 3, ts = Xt({
3868
+ }), es = 0, ts = 1, ns = 2, rs = 3, is = Zt({
3886
3869
  radiance: "vec4",
3887
3870
  objectNormal: "vec3",
3888
3871
  objectColor: "vec3",
3889
3872
  objectID: "float",
3890
3873
  firstHitPoint: "vec3",
3891
3874
  firstHitDistance: "float"
3892
- }), ns = p(([e, t, n, r, i]) => {
3875
+ }), as = p(([e, t, n, r, i]) => {
3893
3876
  let a = i.toVar();
3894
3877
  return m(n.not().or(r.notEqual(t)), () => {
3895
3878
  a.assign(yi(e.metalness, e.roughness, e.transmission, e.clearcoat, e.emissive));
3896
3879
  }), a;
3897
- }), rs = p(([e, t, n, r, i, a, o, s, c, l, u, d, f]) => {
3898
- let p = W(0).toVar(), h = W(0).toVar(), g = M(0).toVar(), _ = Kr.wrap(ns(n, r, o, s, c)).toVar(), v = u.toVar();
3880
+ }), os = p(([e, t, n, r, i, a, o, s, c, l, u, d, f]) => {
3881
+ let p = W(0).toVar(), h = W(0).toVar(), g = M(0).toVar(), _ = Kr.wrap(as(n, r, o, s, c)).toVar(), v = u.toVar();
3899
3882
  m(l.not(), () => {
3900
3883
  m(d, () => {
3901
3884
  v.assign(Ca(n, _, f));
@@ -3916,14 +3899,14 @@ var Ro = 8, zo = 2, Bo = Xt({
3916
3899
  v.assign(Ca(n, _, e));
3917
3900
  });
3918
3901
  });
3919
- let y = i.x.toVar(), b = U(i.y, dn(a)).toVar(), x = W(0).toVar(), S = v.diffuse.toVar(), C = S.add(v.specular).toVar(), w = C.add(v.sheen).toVar(), D = w.add(v.clearcoat).toVar(), O = T(!1).toVar();
3902
+ let y = i.x.toVar(), b = U(i.y, J(a)).toVar(), x = W(0).toVar(), S = v.diffuse.toVar(), C = S.add(v.specular).toVar(), w = C.add(v.sheen).toVar(), D = w.add(v.clearcoat).toVar(), O = T(!1).toVar();
3920
3903
  m(y.lessThan(S).and(O.not()), () => {
3921
3904
  p.assign(Da({
3922
3905
  N: t,
3923
3906
  xi: b
3924
3907
  }));
3925
3908
  let r = E(A(t, p), 0, 1);
3926
- g.assign(r.mul(Qr)), h.assign(za(e, p, t, n)), O.assign(T(!0));
3909
+ g.assign(r.mul(Qr)), h.assign(Ha(e, p, t, n)), O.assign(T(!0));
3927
3910
  });
3928
3911
  let k = E(A(t, e), .001, 1).toVar();
3929
3912
  return m(y.lessThan(C).and(O.not()), () => {
@@ -3934,7 +3917,7 @@ var Ro = 8, zo = 2, Bo = Xt({
3934
3917
  });
3935
3918
  x.assign(r.mul(a));
3936
3919
  let o = E(A(t, x), .001, 1);
3937
- p.assign(ue(e.negate(), x)), g.assign(ba(o, k, n.roughness)), h.assign(za(e, p, t, n)), O.assign(T(!0));
3920
+ p.assign(ue(e.negate(), x)), g.assign(ba(o, k, n.roughness)), h.assign(Ha(e, p, t, n)), O.assign(T(!0));
3938
3921
  }), m(y.lessThan(w).and(O.not()), () => {
3939
3922
  x.assign(Ea({
3940
3923
  N: t,
@@ -3948,9 +3931,9 @@ var Ro = 8, zo = 2, Bo = Xt({
3948
3931
  p.assign(Da({
3949
3932
  N: t,
3950
3933
  xi: i
3951
- })), o.assign(E(A(t, p), 0, 1)), g.assign(o.mul(Qr)), h.assign(za(e, p, t, n));
3934
+ })), o.assign(E(A(t, p), 0, 1)), g.assign(o.mul(Qr)), h.assign(Ha(e, p, t, n));
3952
3935
  }).Else(() => {
3953
- g.assign(ma(r, n.sheenRoughness).mul(r).div(M(4).mul(a))), g.assign(I(g, ri)), h.assign(za(e, p, t, n));
3936
+ g.assign(ma(r, n.sheenRoughness).mul(r).div(M(4).mul(a))), g.assign(I(g, ri)), h.assign(Ha(e, p, t, n));
3954
3937
  }), O.assign(T(!0));
3955
3938
  }), m(y.lessThan(D).and(O.not()), () => {
3956
3939
  let r = E(n.clearcoatRoughness, ni, 1);
@@ -3960,17 +3943,17 @@ var Ro = 8, zo = 2, Bo = Xt({
3960
3943
  Xi: i
3961
3944
  }));
3962
3945
  let a = E(A(t, x), 0, 1);
3963
- p.assign(ue(e.negate(), x)), g.assign(ba(a, k, r)), g.assign(I(g, ri)), h.assign(za(e, p, t, n)), O.assign(T(!0));
3946
+ p.assign(ue(e.negate(), x)), g.assign(ba(a, k, r)), g.assign(I(g, ri)), h.assign(Ha(e, p, t, n)), O.assign(T(!0));
3964
3947
  }), m(O.not(), () => {
3965
- let r = A(e, t).greaterThan(0).toVar(), o = Na.wrap(Ia(e, t, n.ior, n.roughness, r, n.dispersion, i, a));
3966
- p.assign(o.direction), g.assign(I(o.pdf, ri)), h.assign(za(e, p, t, n));
3948
+ let r = A(e, t).greaterThan(0).toVar(), o = Na.wrap(za(e, t, n.ior, n.roughness, r, n.dispersion, i, a, M(0)));
3949
+ p.assign(o.direction), g.assign(I(o.pdf, ri)), h.assign(Ha(e, p, t, n));
3967
3950
  }), g.assign(I(g, ri)), Vr({
3968
3951
  direction: p,
3969
3952
  value: h,
3970
3953
  pdf: g
3971
3954
  });
3972
- }), is = p(([e, t, n, r, i, a, o, s, c]) => {
3973
- let l = I(ui({ v: e }), 0).toVar(), u = Kr.wrap(ns(n, r, i, a, o)).toVar(), d = u.complexityScore.toVar();
3955
+ }), ss = p(([e, t, n, r, i, a, o, s, c]) => {
3956
+ let l = I(ui({ v: e }), 0).toVar(), u = Kr.wrap(as(n, r, i, a, o)).toVar(), d = u.complexityScore.toVar();
3974
3957
  m(u.isMetallic.and(u.isSmooth), () => {
3975
3958
  d.addAssign(.15);
3976
3959
  }), m(u.isTransmissive.and(u.hasClearcoat), () => {
@@ -3985,15 +3968,15 @@ var Ro = 8, zo = 2, Bo = Xt({
3985
3968
  });
3986
3969
  let p = he(M(.001), M(.1), l);
3987
3970
  return l.mul(L(d.mul(.7), f, .3)).mul(p);
3988
- }), as = p(([e, t, n, r, i, a, o, s, c, l, u, d, f]) => {
3971
+ }), cs = p(([e, t, n, r, i, a, o, s, c, l, u, d, f]) => {
3989
3972
  let p = M(1).toVar();
3990
3973
  return m(e.greaterThanEqual(N(3)), () => {
3991
3974
  let h = I(ui({ v: t }), 0).toVar();
3992
3975
  m(h.lessThan(8e-4).and(e.greaterThan(N(4))), () => {
3993
- let e = I(h.mul(125), .01), t = dn(a);
3976
+ let e = I(h.mul(125), .01), t = J(a);
3994
3977
  p.assign(z(t.lessThan(e), e, M(0)));
3995
3978
  }).Else(() => {
3996
- let g = Kr.wrap(ns(n, r, o, s, c)).toVar(), _ = g.complexityScore.toVar();
3979
+ let g = Kr.wrap(as(n, r, o, s, c)).toVar(), _ = g.complexityScore.toVar();
3997
3980
  m(g.isMetallic.and(g.isSmooth).and(e.lessThan(N(7))), () => {
3998
3981
  _.addAssign(.3);
3999
3982
  }), m(g.isTransmissive.and(e.lessThan(N(6))), () => {
@@ -4013,7 +3996,7 @@ var Ro = 8, zo = 2, Bo = Xt({
4013
3996
  m(o.and(l), () => {
4014
3997
  y.assign(u);
4015
3998
  }).Else(() => {
4016
- y.assign(is(t, i, n, r, o, s, c, d, f));
3999
+ y.assign(ss(t, i, n, r, o, s, c, d, f));
4017
4000
  });
4018
4001
  let b = L(E(_.mul(.4).add(h.mul(.6)).mul(1.2), .15, .95), E(h.mul(.4).add(_.mul(.1)), .03, .6), E(M(e.sub(v)).div(10), 0, 1)).toVar();
4019
4002
  b.assign(L(b, I(b, y), .4)), m(_.greaterThan(.5), () => {
@@ -4024,12 +4007,12 @@ var Ro = 8, zo = 2, Bo = Xt({
4024
4007
  b.mulAssign(S);
4025
4008
  let C = z(g.isEmissive, M(.04), M(.02));
4026
4009
  b.assign(I(b, C));
4027
- let w = dn(a);
4010
+ let w = J(a);
4028
4011
  p.assign(z(w.lessThan(b), b, M(0)));
4029
4012
  });
4030
4013
  });
4031
4014
  }), p;
4032
- }), os = p(([e, t, n, r, i, a, o, s]) => {
4015
+ }), ls = p(([e, t, n, r, i, a, o, s]) => {
4033
4016
  let c = G(0).toVar();
4034
4017
  return m(e.and(o.not()), () => {
4035
4018
  c.assign(G(0));
@@ -4048,10 +4031,10 @@ var Ro = 8, zo = 2, Bo = Xt({
4048
4031
  c.assign(o);
4049
4032
  });
4050
4033
  }), c;
4051
- }), ss = /* @__PURE__ */ K("\n fn regularizePathContribution( contribution: vec3f, pathLength: f32, fireflyThreshold: f32, frame: i32 ) -> vec3f {\n let threshold = calculateFireflyThreshold( fireflyThreshold, i32( pathLength ), frame );\n return applySoftSuppressionRGB( contribution, threshold, 0.5f );\n }\n", [gi, vi]), cs = p(([e, t, n, r, i, a, o, s, c, l, u, g, _, v, y, b, x, S, C, w, D, O, k, j, ee, te, P, re, F, ie, ae, oe, L, se, ce, le, ue, de, fe, pe, me, he, ge, _e, ve, ye, be, B, xe, V]) => {
4052
- let H = W(0).toVar(), Se = W(1).toVar(), Ce = M(1).toVar(), we = T(!1).toVar(), U = M(0).toVar(), K = W(0).toVar(), Te = W(0).toVar(), Ee = M(-1e3).toVar(), De = e.origin.toVar(), Oe = M(1e10).toVar(), ke = T(!1).toVar(), Ae = N(0).toVar(), je = M(1).toVar(), Me = M(1).toVar(), Ne = M(1).toVar(), Pe = oe.toVar(), Fe = L.toVar(), Ie = N(Zo).toVar(), Le = T(!0).toVar(), Re = T(!1).toVar(), ze = T(!1).toVar(), Be = T(!1).toVar();
4034
+ }), us = /* @__PURE__ */ K("\n fn regularizePathContribution( contribution: vec3f, pathLength: f32, fireflyThreshold: f32, frame: i32 ) -> vec3f {\n let threshold = calculateFireflyThreshold( fireflyThreshold, i32( pathLength ), frame );\n return applySoftSuppressionRGB( contribution, threshold, 0.5f );\n }\n", [gi, vi]), ds = p(([e, t, n, r, i, a, o, s, c, l, u, g, _, v, y, b, x, S, C, w, D, O, k, j, ee, te, P, re, F, ie, ae, oe, L, se, ce, le, ue, de, fe, pe, me, he, ge, _e, ve, ye, be, B, xe, V]) => {
4035
+ let H = W(0).toVar(), Se = W(1).toVar(), Ce = M(1).toVar(), we = T(!1).toVar(), U = M(0).toVar(), K = W(0).toVar(), Te = W(0).toVar(), Ee = M(-1e3).toVar(), De = e.origin.toVar(), Oe = M(1e10).toVar(), ke = T(!1).toVar(), Ae = N(0).toVar(), je = M(1).toVar(), Me = M(1).toVar(), Ne = M(1).toVar(), Pe = M(0).toVar(), Fe = oe.toVar(), Ie = L.toVar(), Le = N(es).toVar(), Re = T(!0).toVar(), ze = T(!1).toVar(), Be = T(!1).toVar(), Ve = T(!1).toVar();
4053
4036
  T(!1).toVar();
4054
- let Ve = M(0).toVar(), He = N(-1).toVar(), Ue = Kr({
4037
+ let He = M(0).toVar(), Ue = N(-1).toVar(), We = Kr({
4055
4038
  isMetallic: !1,
4056
4039
  isRough: !1,
4057
4040
  isSmooth: !1,
@@ -4059,14 +4042,14 @@ var Ro = 8, zo = 2, Bo = Xt({
4059
4042
  hasClearcoat: !1,
4060
4043
  isEmissive: !1,
4061
4044
  complexityScore: M(0)
4062
- }).toVar(), We = Hr({
4045
+ }).toVar(), Ge = Hr({
4063
4046
  specular: M(.5),
4064
4047
  diffuse: M(.5),
4065
4048
  sheen: M(0),
4066
4049
  clearcoat: M(0),
4067
4050
  transmission: M(0),
4068
4051
  iridescence: M(0)
4069
- }).toVar(), Ge = Jr({
4052
+ }).toVar(), Ke = Jr({
4070
4053
  F0: W(.04),
4071
4054
  NoV: M(1),
4072
4055
  diffuseColor: W(0),
@@ -4078,31 +4061,31 @@ var Ro = 8, zo = 2, Bo = Xt({
4078
4061
  metalFactor: M(.5),
4079
4062
  iorFactor: M(1),
4080
4063
  maxSheenColor: M(0)
4081
- }).toVar(), Ke = N(0).toVar(), qe = e.origin.toVar(), Je = e.direction.toVar();
4064
+ }).toVar(), qe = N(0).toVar(), Je = e.origin.toVar(), Ye = e.direction.toVar();
4082
4065
  return h({
4083
4066
  start: N(0),
4084
4067
  end: oe.add(L).add(1),
4085
4068
  type: "int",
4086
4069
  condition: "<"
4087
4070
  }, ({ i: e }) => {
4088
- Pe.assign(oe.sub(Ke)), Le.assign(e.equal(N(0))), m(Ke.greaterThan(oe), () => {
4071
+ Fe.assign(oe.sub(qe)), Re.assign(e.equal(N(0))), m(qe.greaterThan(oe), () => {
4089
4072
  d();
4090
4073
  });
4091
4074
  let r = z(e.greaterThan(N(0)), de, M(1)), h = Lr({
4092
- origin: qe,
4093
- direction: Je
4075
+ origin: Je,
4076
+ direction: Ye
4094
4077
  }), L = Br.wrap(Ni(h, i, a, o)).toVar();
4095
4078
  m(L.didHit.not(), () => {
4096
- let t = os(Le, Je, k, ee, j, ie, ce, se), n = M(1).toVar();
4079
+ let t = ls(Re, Ye, k, ee, j, ie, ce, se), n = M(1).toVar();
4097
4080
  m(U.greaterThan(0).and(ie).and(ae), () => {
4098
- let e = zi(k, Je, ee, P, re, F).w.toVar();
4081
+ let e = zi(k, Ye, ee, P, re, F).w.toVar();
4099
4082
  m(e.greaterThan(0), () => {
4100
4083
  n.assign(pi({
4101
4084
  pdf1: U,
4102
4085
  pdf2: e
4103
4086
  }));
4104
4087
  });
4105
- }), H.addAssign(ss({
4088
+ }), H.addAssign(us({
4106
4089
  contribution: t.xyz.mul(Se).mul(r).mul(n),
4107
4090
  pathLength: M(e),
4108
4091
  fireflyThreshold: ue,
@@ -4113,31 +4096,31 @@ var Ro = 8, zo = 2, Bo = Xt({
4113
4096
  Ce.mulAssign(t.a);
4114
4097
  }), d();
4115
4098
  });
4116
- let G = Rr.wrap(Si(L.materialIndex, o)).toVar(), Ye = L.uv.toVar(), q = L.normal.toVar();
4099
+ let G = Rr.wrap(Si(L.materialIndex, o)).toVar(), q = L.uv.toVar(), Xe = L.normal.toVar();
4117
4100
  m(G.displacementMapIndex.greaterThanEqual(N(0)).and(G.displacementScale.greaterThan(0)), () => {
4118
4101
  let t = ia.wrap(aa(h, L, a, v, G, e)).toVar();
4119
- Ye.assign(t.uv), q.assign(t.normal), L.hitPoint.assign(t.hitPoint);
4102
+ q.assign(t.uv), Xe.assign(t.normal), L.hitPoint.assign(t.hitPoint);
4120
4103
  });
4121
- let Xe = Gr.wrap(Zi(s, c, l, u, g, _, G, Ye, L.normal)).toVar();
4122
- G.color.assign(Xe.albedo), G.metalness.assign(E(Xe.metalness, 0, 1)), G.roughness.assign(E(Xe.roughness, ti, 1));
4123
- let Ze = Xe.normal.toVar();
4104
+ let Ze = Gr.wrap(Zi(s, c, l, u, g, _, G, q, L.normal)).toVar();
4105
+ G.color.assign(Ze.albedo), G.metalness.assign(E(Ze.metalness, 0, 1)), G.roughness.assign(E(Ze.roughness, ti, 1));
4106
+ let Qe = Ze.normal.toVar();
4124
4107
  m(G.displacementMapIndex.greaterThanEqual(N(0)).and(G.displacementScale.greaterThan(0)), () => {
4125
- Ze.assign(R(q.add(Xe.normal.sub(L.normal))));
4108
+ Qe.assign(R(Xe.add(Ze.normal.sub(L.normal))));
4126
4109
  });
4127
- let Qe = M(1).toVar(), $e = M(1).toVar();
4110
+ let $e = M(1).toVar(), et = M(1).toVar();
4128
4111
  m(Ae.equal(N(1)), () => {
4129
- Qe.assign(je);
4112
+ $e.assign(je);
4130
4113
  }).ElseIf(Ae.equal(N(2)), () => {
4131
- Qe.assign(Me), $e.assign(je);
4114
+ $e.assign(Me), et.assign(je);
4132
4115
  }).ElseIf(Ae.equal(N(3)), () => {
4133
- Qe.assign(Ne), $e.assign(Me);
4116
+ $e.assign(Ne), et.assign(Me);
4134
4117
  });
4135
- let et = ja.wrap(Ra(h, L.hitPoint, Ze, G, t, Fe, Qe, $e)).toVar();
4136
- m(et.continueRay, () => {
4118
+ let tt = ja.wrap(Va(h, L.hitPoint, Qe, G, t, Ie, $e, et, Pe)).toVar();
4119
+ Pe.assign(tt.pathWavelength), m(tt.continueRay, () => {
4137
4120
  let e = T(!1).toVar();
4138
- m(et.isTransmissive.and(Fe.greaterThan(N(0))), () => {
4139
- Fe.subAssign(1), Ie.assign(N($o)), e.assign(T(!0)), m(et.didReflect.not(), () => {
4140
- m(et.entering, () => {
4121
+ m(tt.isTransmissive.and(Ie.greaterThan(N(0))), () => {
4122
+ Ie.subAssign(1), Le.assign(N(ns)), e.assign(T(!0)), m(tt.didReflect.not(), () => {
4123
+ m(tt.entering, () => {
4141
4124
  m(Ae.lessThan(N(3)), () => {
4142
4125
  Ae.addAssign(1), m(Ae.equal(N(1)), () => {
4143
4126
  je.assign(G.ior);
@@ -4153,66 +4136,66 @@ var Ro = 8, zo = 2, Bo = Xt({
4153
4136
  });
4154
4137
  });
4155
4138
  });
4156
- }).ElseIf(et.isAlphaSkip, () => {
4139
+ }).ElseIf(tt.isAlphaSkip, () => {
4157
4140
  e.assign(T(!0));
4158
- }), Se.mulAssign(et.throughput), m(le.not(), () => {
4159
- Ce.mulAssign(et.alpha);
4141
+ }), Se.mulAssign(tt.throughput), m(le.not(), () => {
4142
+ Ce.mulAssign(tt.alpha);
4160
4143
  });
4161
- let t = z(et.entering, Ze, Ze.negate()), n = z(et.didReflect, t, Je);
4162
- qe.assign(L.hitPoint.add(n.mul(.001))), Je.assign(et.direction), Le.assign(T(!1)), Re.assign(T(!1)), Be.assign(T(!1)), m(e.not(), () => {
4163
- Ke.addAssign(1);
4144
+ let t = z(tt.entering, Qe, Qe.negate()), n = z(tt.didReflect, t, Ye);
4145
+ Je.assign(L.hitPoint.add(n.mul(.001))), Ye.assign(tt.direction), Re.assign(T(!1)), ze.assign(T(!1)), Ve.assign(T(!1)), m(e.not(), () => {
4146
+ qe.addAssign(1);
4164
4147
  }), f();
4165
4148
  }), m(le.not(), () => {
4166
- Ce.mulAssign(et.alpha);
4149
+ Ce.mulAssign(tt.alpha);
4167
4150
  }), we.assign(T(!0));
4168
- let tt = vn(B, n, e, t, N(-1), xe, V).toVar(), nt = Je.negate().toVar();
4169
- G.sheenRoughness.assign(E(G.sheenRoughness, ti, 1)), m(Be.not(), () => {
4170
- Ge.assign(Ta(Ze, nt, G, Xe, Ue)), Be.assign(T(!0));
4151
+ let nt = vn(B, n, e, t, N(-1), xe, V).toVar(), rt = Ye.negate().toVar();
4152
+ G.sheenRoughness.assign(E(G.sheenRoughness, ti, 1)), m(Ve.not(), () => {
4153
+ Ke.assign(Ta(Qe, rt, G, Ze, We)), Ve.assign(T(!0));
4171
4154
  });
4172
- let rt = W(0).toVar(), it = W(0).toVar(), at = M(0).toVar();
4155
+ let it = W(0).toVar(), at = W(0).toVar(), ot = M(0).toVar();
4173
4156
  m(G.clearcoat.greaterThan(0), () => {
4174
- let e = Va.wrap(Ha(h, L, G, tt, t));
4175
- rt.assign(e.L), it.assign(e.brdf), at.assign(e.pdf);
4157
+ let e = Wa.wrap(Ga(h, L, G, nt, t));
4158
+ it.assign(e.L), at.assign(e.brdf), ot.assign(e.pdf);
4176
4159
  }).Else(() => {
4177
- let e = Vr.wrap(rs(nt, Ze, G, L.materialIndex, tt, t, ze, He, Ue, Re, We, Be, Ge));
4178
- rt.assign(e.direction), it.assign(e.value), at.assign(e.pdf), m(He.notEqual(L.materialIndex).or(ze.not()), () => {
4179
- Ue.assign(yi(G.metalness, G.roughness, G.transmission, G.clearcoat, G.emissive));
4180
- }), ze.assign(T(!0)), He.assign(L.materialIndex), Re.assign(T(!0));
4181
- }), m(ne(Xe.emissive).greaterThan(0), () => {
4160
+ let e = Vr.wrap(os(rt, Qe, G, L.materialIndex, nt, t, Be, Ue, We, ze, Ge, Ve, Ke));
4161
+ it.assign(e.direction), at.assign(e.value), ot.assign(e.pdf), m(Ue.notEqual(L.materialIndex).or(Be.not()), () => {
4162
+ We.assign(yi(G.metalness, G.roughness, G.transmission, G.clearcoat, G.emissive));
4163
+ }), Be.assign(T(!0)), Ue.assign(L.materialIndex), ze.assign(T(!0));
4164
+ }), m(ne(Ze.emissive).greaterThan(0), () => {
4182
4165
  let t = M(1).toVar();
4183
4166
  m(pe.equal(N(1)).and(ge.greaterThan(N(0))).and(U.greaterThan(0)), () => {
4184
- let e = Ho(L.triangleIndex, L.dst, Je, qe, a, o, _e);
4167
+ let e = Go(L.triangleIndex, L.dst, Ye, Je, a, o, _e);
4185
4168
  t.assign(fi({
4186
4169
  pdf1: U,
4187
4170
  pdf2: e
4188
4171
  }));
4189
- }), H.addAssign(ss({
4190
- contribution: Xe.emissive.mul(Se).mul(r).mul(t),
4172
+ }), H.addAssign(us({
4173
+ contribution: Ze.emissive.mul(Se).mul(r).mul(t),
4191
4174
  pathLength: M(e),
4192
4175
  fireflyThreshold: ue,
4193
4176
  frame: N(V)
4194
4177
  }));
4195
4178
  });
4196
- let ot = bo(L.hitPoint, Ze, G, nt, rt, at, it, n, e, t, y, b, x, S, C, w, D, O, i, a, o, k, j, ee, te, P, re, F, ie);
4197
- H.addAssign(ss({
4198
- contribution: ot.mul(Se).mul(r),
4179
+ let st = Co(L.hitPoint, Qe, G, rt, it, ot, at, n, e, t, y, b, x, S, C, w, D, O, i, a, o, k, j, ee, te, P, re, F, ie);
4180
+ H.addAssign(us({
4181
+ contribution: st.mul(Se).mul(r),
4199
4182
  pathLength: M(e),
4200
4183
  fireflyThreshold: ue,
4201
4184
  frame: N(V)
4202
4185
  })), m(pe.equal(N(1)).and(ge.greaterThan(N(0))), () => {
4203
- let n = p(([e, t, n, r]) => so(e, t, n, r, Pi, i, a, o));
4186
+ let n = p(([e, t, n, r]) => uo(e, t, n, r, Pi, i, a, o));
4204
4187
  m(be.greaterThan(N(0)), () => {
4205
- let i = Do.wrap(Xo(L.hitPoint, Ze, t, ye, me, he, a));
4188
+ let i = Ao.wrap($o(L.hitPoint, Qe, t, ye, me, he, a));
4206
4189
  m(e.greaterThan(N(1)).and(G.roughness.greaterThan(.9)).and(G.metalness.lessThan(.1)).not().and(i.valid).and(i.pdf.greaterThan(0)), () => {
4207
- let a = I(M(0), A(Ze, i.direction));
4190
+ let a = I(M(0), A(Qe, i.direction));
4208
4191
  m(a.greaterThan(0), () => {
4209
- let o = co(L.hitPoint, Ze, G), s = L.hitPoint.add(o), c = i.distance.sub(.001), l = n(s, i.direction, c, t);
4192
+ let o = fo(L.hitPoint, Qe, G), s = L.hitPoint.add(o), c = i.distance.sub(.001), l = n(s, i.direction, c, t);
4210
4193
  m(l.greaterThan(0), () => {
4211
- let t = za(nt, i.direction, Ze, G), n = yo(nt, i.direction, Ze, G), o = z(n.greaterThan(0), fi({
4194
+ let t = Ha(rt, i.direction, Qe, G), n = So(rt, i.direction, Qe, G), o = z(n.greaterThan(0), fi({
4212
4195
  pdf1: i.pdf,
4213
4196
  pdf2: n
4214
4197
  }), M(1)), s = i.emission.mul(t).mul(a).div(i.pdf).mul(l).mul(ve).mul(o);
4215
- H.addAssign(ss({
4198
+ H.addAssign(us({
4216
4199
  contribution: s.mul(Se).mul(r),
4217
4200
  pathLength: M(e),
4218
4201
  fireflyThreshold: ue,
@@ -4222,38 +4205,38 @@ var Ro = 8, zo = 2, Bo = Xt({
4222
4205
  });
4223
4206
  });
4224
4207
  }).Else(() => {
4225
- let i = Ko(L.hitPoint, Ze, nt, G, fe, e, t, ve, me, he, ge, _e, a, n, za, co);
4226
- H.addAssign(ss({
4208
+ let i = Yo(L.hitPoint, Qe, rt, G, fe, e, t, ve, me, he, ge, _e, a, n, Ha, fo);
4209
+ H.addAssign(us({
4227
4210
  contribution: i.mul(Se).mul(r),
4228
4211
  pathLength: M(e),
4229
4212
  fireflyThreshold: ue,
4230
4213
  frame: N(V)
4231
4214
  }));
4232
4215
  });
4233
- }), m(Re.not().or(e.equal(N(0))), () => {
4234
- Ue.assign(Kr.wrap(ns(G, L.materialIndex, ze, He, Ue))), ze.assign(T(!0)), He.assign(L.materialIndex);
4216
+ }), m(ze.not().or(e.equal(N(0))), () => {
4217
+ We.assign(Kr.wrap(as(G, L.materialIndex, Be, Ue, We))), Be.assign(T(!0)), Ue.assign(L.materialIndex);
4235
4218
  });
4236
- let st = Ur.wrap(wa(G, e, Ue, j, ae, ie)), J = Ja.wrap(Eo(nt, Ze, G, rt, at, it, n, e, t, st, k, j, ee, P, re, F, ie, ae));
4237
- Se.mulAssign(J.throughput), qe.assign(L.hitPoint.add(Ze.mul(.001))), Je.assign(J.direction), U.assign(J.combinedPdf), Le.assign(T(!1)), m(G.metalness.greaterThan(.7).and(G.roughness.lessThan(.3)), () => {
4238
- Ie.assign(N(Qo));
4219
+ let ct = Ur.wrap(wa(G, e, We, j, ae, ie)), lt = Za.wrap(ko(rt, Qe, G, it, ot, at, n, e, t, ct, k, j, ee, P, re, F, ie, ae));
4220
+ Se.mulAssign(lt.throughput), Je.assign(L.hitPoint.add(Qe.mul(.001))), Ye.assign(lt.direction), U.assign(lt.combinedPdf), Re.assign(T(!1)), m(G.metalness.greaterThan(.7).and(G.roughness.lessThan(.3)), () => {
4221
+ Le.assign(N(ts));
4239
4222
  }).ElseIf(G.transmission.greaterThan(.5), () => {
4240
- Ie.assign(N($o));
4223
+ Le.assign(N(ns));
4241
4224
  }).Else(() => {
4242
- Ie.assign(N(es));
4225
+ Le.assign(N(rs));
4243
4226
  }), m(e.equal(N(0)).and(L.didHit), () => {
4244
4227
  De.assign(L.hitPoint), Oe.assign(L.dst);
4245
4228
  }), m(ke.not().and(L.didHit), () => {
4246
- K.assign(Ze), Te.assign(G.color.xyz), Ee.assign(M(L.materialIndex));
4229
+ K.assign(Qe), Te.assign(G.color.xyz), Ee.assign(M(L.materialIndex));
4247
4230
  let e = G.metalness.greaterThan(.7).and(G.roughness.lessThan(.3)), t = G.transmission.greaterThan(.5);
4248
4231
  m(e.or(t).not(), () => {
4249
4232
  ke.assign(T(!0));
4250
4233
  });
4251
4234
  });
4252
- let ct = as(e, Se, G, L.materialIndex, Je, t, ze, He, Ue, Re, Ve, ie, ae);
4253
- m(ct.lessThanEqual(0), () => {
4235
+ let ut = cs(e, Se, G, L.materialIndex, Ye, t, Be, Ue, We, ze, He, ie, ae);
4236
+ m(ut.lessThanEqual(0), () => {
4254
4237
  d();
4255
- }), Se.divAssign(ct), Ke.addAssign(1), Re.assign(T(!1)), Be.assign(T(!1));
4256
- }), ts({
4238
+ }), Se.divAssign(ut), qe.addAssign(1), ze.assign(T(!1)), Ve.assign(T(!1));
4239
+ }), is({
4257
4240
  radiance: G(H, Ce),
4258
4241
  objectNormal: K,
4259
4242
  objectColor: Te,
@@ -4261,7 +4244,7 @@ var Ro = 8, zo = 2, Bo = Xt({
4261
4244
  firstHitPoint: De,
4262
4245
  firstHitDistance: Oe
4263
4246
  });
4264
- }), ls = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n return vec3f( 1.0f - depth );\n }\n"), us = /* @__PURE__ */ K("\n fn visualizeNormal( normal: vec3f ) -> vec3f {\n return normal * 0.5f + 0.5f;\n }\n"), ds = /* @__PURE__ */ K("\n fn computeNDCDepthLocal( worldPos: vec3f, cameraProjectionMatrix: mat4x4f, cameraViewMatrix: mat4x4f ) -> f32 {\n let clipPos = cameraProjectionMatrix * cameraViewMatrix * vec4f( worldPos, 1.0f );\n let ndcDepth = clipPos.z / clipPos.w * 0.5f + 0.5f;\n return clamp( ndcDepth, 0.0f, 1.0f );\n }\n"), fs = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, h, g, _, v, y, b, x, S]) => {
4247
+ }), fs = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n return vec3f( 1.0f - depth );\n }\n"), ps = /* @__PURE__ */ K("\n fn visualizeNormal( normal: vec3f ) -> vec3f {\n return normal * 0.5f + 0.5f;\n }\n"), ms = /* @__PURE__ */ K("\n fn computeNDCDepthLocal( worldPos: vec3f, cameraProjectionMatrix: mat4x4f, cameraViewMatrix: mat4x4f ) -> f32 {\n let clipPos = cameraProjectionMatrix * cameraViewMatrix * vec4f( worldPos, 1.0f );\n let ndcDepth = clipPos.z / clipPos.w * 0.5f + 0.5f;\n return clamp( ndcDepth, 0.0f, 1.0f );\n }\n"), hs = p(([e, t, n, r, i, a, o, s, c, l, u, d, f, p, h, g, _, v, y, b, x, S]) => {
4265
4248
  let C = G(1, 0, 1, 1).toVar(), w = Lr({
4266
4249
  origin: e,
4267
4250
  direction: t
@@ -4322,18 +4305,18 @@ var Ro = 8, zo = 2, Bo = Xt({
4322
4305
  C.assign(G(.5, .5, 1, 1));
4323
4306
  }).Else(() => {
4324
4307
  let e = Rr.wrap(Si(T.materialIndex, i)).toVar(), t = R(Gr.wrap(Zi(p, h, g, _, v, y, e, T.uv, T.normal)).toVar().normal);
4325
- C.assign(G(us({ normal: t }), 1));
4308
+ C.assign(G(ps({ normal: t }), 1));
4326
4309
  });
4327
4310
  }), m(l.equal(N(2)), () => {
4328
4311
  m(T.didHit.not(), () => {
4329
4312
  C.assign(G(W(1), 1));
4330
4313
  }).Else(() => {
4331
- let e = ds({
4314
+ let e = ms({
4332
4315
  worldPos: T.hitPoint,
4333
4316
  cameraProjectionMatrix: b,
4334
4317
  cameraViewMatrix: x
4335
4318
  });
4336
- C.assign(G(ls({ depth: e }), 1));
4319
+ C.assign(G(fs({ depth: e }), 1));
4337
4320
  });
4338
4321
  }), m(l.equal(N(3)), () => {
4339
4322
  m(T.didHit.not(), () => {
@@ -4346,9 +4329,9 @@ var Ro = 8, zo = 2, Bo = Xt({
4346
4329
  m(T.didHit.not(), () => {
4347
4330
  C.assign(G(0, 0, 0, 1));
4348
4331
  }).Else(() => {
4349
- let e = Rr.wrap(Si(T.materialIndex, i)).toVar(), t = Gr.wrap(Zi(p, h, g, _, v, y, e, T.uv, T.normal)).toVar(), l = t.albedo.rgb.toVar(), u = R(t.normal).toVar(), f = cn({ state: ln({ seed: V(d.x).mul(V(1973)).add(V(d.y).mul(V(9277))).add(S.mul(V(26699))) }) }).toVar(), b = Oa({
4332
+ let e = Rr.wrap(Si(T.materialIndex, i)).toVar(), t = Gr.wrap(Zi(p, h, g, _, v, y, e, T.uv, T.normal)).toVar(), l = t.albedo.rgb.toVar(), u = R(t.normal).toVar(), f = ln({ state: un({ seed: V(d.x).mul(V(1973)).add(V(d.y).mul(V(9277))).add(S.mul(V(26699))) }) }).toVar(), b = Oa({
4350
4333
  N: u,
4351
- xi: U(dn(f).toVar(), dn(f).toVar()).toVar()
4334
+ xi: U(J(f).toVar(), J(f).toVar()).toVar()
4352
4335
  }).toVar(), x = Lr({
4353
4336
  origin: T.hitPoint.add(u.mul(.001)).toVar(),
4354
4337
  direction: b
@@ -4406,10 +4389,10 @@ var Ro = 8, zo = 2, Bo = Xt({
4406
4389
  }), C;
4407
4390
  });
4408
4391
  p(([e, t]) => {
4409
- let n = dn(t), r = W(.25 / 255, -.25 / 255, .25 / 255).toVar();
4392
+ let n = J(t), r = W(.25 / 255, -.25 / 255, .25 / 255).toVar();
4410
4393
  return r.assign(L(r.mul(2), r.mul(-2), n)), e.add(r);
4411
4394
  });
4412
- var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjectionMatrix: mat4x4f, cameraViewMatrix: mat4x4f ) -> f32 {\n let clipPos = cameraProjectionMatrix * cameraViewMatrix * vec4f( worldPos, 1.0f );\n let ndcDepth = clipPos.z / clipPos.w * 0.5f + 0.5f;\n return clamp( ndcDepth, 0.0f, 1.0f );\n }\n"), ms = p(([e, t, n, r, i]) => {
4395
+ var gs = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjectionMatrix: mat4x4f, cameraViewMatrix: mat4x4f ) -> f32 {\n let clipPos = cameraProjectionMatrix * cameraViewMatrix * vec4f( worldPos, 1.0f );\n let ndcDepth = clipPos.z / clipPos.w * 0.5f + 0.5f;\n return clamp( ndcDepth, 0.0f, 1.0f );\n }\n"), _s = p(([e, t, n, r, i]) => {
4413
4396
  let a = be(n, e.div(t), 0), o = N(0).toVar();
4414
4397
  return m(a.b.greaterThan(.5), () => {
4415
4398
  o.assign(0);
@@ -4417,7 +4400,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4417
4400
  let e = N(ee(a.r.mul(M(i)).add(.5)));
4418
4401
  o.assign(E(e, r, i));
4419
4402
  }), o;
4420
- }), hs = (e) => {
4403
+ }), vs = (e) => {
4421
4404
  let { pixelCoord: t, writeColorTex: n, writeNDTex: r, writeAlbedoTex: i, resolution: a, frame: o, samplesPerPixel: s, visMode: c, cameraWorldMatrix: l, cameraProjectionMatrixInverse: u, cameraViewMatrix: f, cameraProjectionMatrix: p, bvhBuffer: g, triangleBuffer: _, materialBuffer: v, albedoMaps: y, normalMaps: b, bumpMaps: x, metalnessMaps: S, roughnessMaps: C, emissiveMaps: w, displacementMaps: T, directionalLightsBuffer: E, numDirectionalLights: D, areaLightsBuffer: O, numAreaLights: k, pointLightsBuffer: A, numPointLights: j, spotLightsBuffer: ee, numSpotLights: te, envTexture: P, environmentIntensity: ne, envMatrix: re, envCDFBuffer: F, envTotalSum: ie, envCompensationDelta: ae, envResolution: I, enableEnvironmentLight: oe, useEnvMapIS: se, maxBounceCount: ce, transmissiveBounces: le, showBackground: ue, transparentBackground: de, backgroundIntensity: fe, fireflyThreshold: pe, globalIlluminationIntensity: me, totalTriangleCount: he, enableEmissiveTriangleSampling: ge, emissiveTriangleBuffer: _e, emissiveVec4Offset: ve, emissiveTriangleCount: ye, emissiveTotalPower: B, emissiveBoost: H, lightBVHBuffer: Se, lightBVHNodeCount: Ce, debugVisScale: K, enableAccumulation: Te, hasPreviousAccumulated: Ee, prevAccumTexture: De, prevNormalDepthTexture: Oe, prevAlbedoTexture: ke, accumulationAlpha: Ae, cameraIsMoving: je, useAdaptiveSampling: Me, adaptiveSamplingTexture: Ne, adaptiveSamplingMin: Pe, adaptiveSamplingMax: Fe, enableDOF: Ie, focalLength: Le, aperture: Re, focusDistance: ze, sceneScale: Be, apertureScale: Ve, anamorphicRatio: He } = e, Ue = we(V(N(t.x)), V(N(t.y))), We = t.div(a), Ge = t.div(a).mul(2).sub(1).toVar();
4422
4405
  Ge.y.assign(Ge.y.negate());
4423
4406
  let Ke = G(0).toVar(), qe = N(0).toVar(), Je = bn({
@@ -4426,7 +4409,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4426
4409
  frame: o
4427
4410
  }).toVar(), Ye = N(t.y).mul(N(a.x)).add(N(t.x)).toVar(), q = W(0, 0, 1).toVar(), Xe = M(1).toVar(), Ze = M(0).toVar(), Qe = N(s).toVar();
4428
4411
  m(o.greaterThan(V(2)).and(Me), () => {
4429
- let e = ms(t, a, Ne, Pe, Fe);
4412
+ let e = _s(t, a, Ne, Pe, Fe);
4430
4413
  Qe.assign(e), m(Qe.equal(N(0)), () => {
4431
4414
  m(Te.and(Ee), () => {
4432
4415
  let e = be(De, We, 0);
@@ -4445,18 +4428,18 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4445
4428
  type: "int",
4446
4429
  condition: "<"
4447
4430
  }, ({ i: e }) => {
4448
- let n = cn({ state: Je.add(V(e)) }).toVar(), r = yn(t, e, Qe, n, a, o).toVar();
4431
+ let n = ln({ state: Je.add(V(e)) }).toVar(), r = yn(t, e, Qe, n, a, o).toVar();
4449
4432
  m(c.equal(N(9)), () => {
4450
4433
  Ke.assign(G(r, 1, 1)), qe.assign(1), d();
4451
4434
  });
4452
4435
  let i = r.sub(.5).mul(nt), s = Ge.add(i), h = Lr.wrap(Fi(s, n, l, u, Ie, Le, Re, ze, Be, Ve, He)), M = G(0).toVar();
4453
4436
  m(c.greaterThan(N(0)), () => {
4454
- M.assign(fs(h.origin, h.direction, g, _, v, P, re, ne, oe, c, K, t, a, y, b, x, S, C, w, p, f, o));
4437
+ M.assign(hs(h.origin, h.direction, g, _, v, P, re, ne, oe, c, K, t, a, y, b, x, S, C, w, p, f, o));
4455
4438
  }).Else(() => {
4456
- let r = ts.wrap(cs(h, n, e, Ye, g, _, v, y, b, x, S, C, w, T, E, D, O, k, A, j, ee, te, P, ne, re, F, ie, ae, I, oe, se, ce, le, fe, ue, de, pe, me, he, ge, _e, ve, ye, B, H, Se, Ce, t, a, o));
4439
+ let r = is.wrap(ds(h, n, e, Ye, g, _, v, y, b, x, S, C, w, T, E, D, O, k, A, j, ee, te, P, ne, re, F, ie, ae, I, oe, se, ce, le, fe, ue, de, pe, me, he, ge, _e, ve, ye, B, H, Se, Ce, t, a, o));
4457
4440
  M.assign(r.radiance), m(e.equal(N(0)), () => {
4458
4441
  $e.assign(r.objectNormal), et.assign(r.objectColor), tt.assign(r.objectID), m(r.firstHitDistance.lessThan(1e9), () => {
4459
- q.assign(R(r.objectNormal)), Xe.assign(ps({
4442
+ q.assign(R(r.objectNormal)), Xe.assign(gs({
4460
4443
  worldPos: r.firstHitPoint,
4461
4444
  cameraProjectionMatrix: p,
4462
4445
  cameraViewMatrix: f
@@ -4474,7 +4457,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4474
4457
  ot.assign(L(e.w, Ze, Ae));
4475
4458
  });
4476
4459
  }), xe(n, Ue, G(rt.xyz, ot)).toWriteOnly(), xe(r, Ue, it).toWriteOnly(), xe(i, Ue, G(at, 1)).toWriteOnly();
4477
- }, gs = class {
4460
+ }, ys = class {
4478
4461
  constructor(e = "Build") {
4479
4462
  this.label = e, this.entries = /* @__PURE__ */ new Map(), this.order = [], this.totalStart = performance.now();
4480
4463
  }
@@ -4501,7 +4484,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4501
4484
  total: Math.round(e)
4502
4485
  };
4503
4486
  }
4504
- }, _s = 8, vs = class {
4487
+ }, bs = 8, xs = class {
4505
4488
  constructor() {
4506
4489
  this.computeNode = null, this.prevColorTexNode = null, this.prevNormalDepthTexNode = null, this.prevAlbedoTexNode = null, this.adaptiveSamplingTexNode = null, this.tileOffsetX = H(0, "int"), this.tileOffsetY = H(0, "int"), this.renderWidth = H(1920, "int"), this.renderHeight = H(1080, "int"), this._dispatchX = 0, this._dispatchY = 0, this._dispatchSize = [
4507
4490
  0,
@@ -4510,12 +4493,12 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4510
4493
  ], this._sceneTextureNodes = null, this._compiled = !1;
4511
4494
  }
4512
4495
  setupCompute(e) {
4513
- let { stage: t, storageTextures: n } = e, r = new gs("setupCompute");
4496
+ let { stage: t, storageTextures: n } = e, r = new ys("setupCompute");
4514
4497
  r.start("Create texture nodes");
4515
4498
  let i = this._createTextureNodes(t, n);
4516
4499
  r.end("Create texture nodes"), r.start("Build compute node (TSL)");
4517
4500
  let a = n.renderWidth, o = n.renderHeight;
4518
- this._dispatchX = Math.ceil(a / _s), this._dispatchY = Math.ceil(o / _s), this.renderWidth.value = a, this.renderHeight.value = o;
4501
+ this._dispatchX = Math.ceil(a / bs), this._dispatchY = Math.ceil(o / bs), this.renderWidth.value = a, this.renderHeight.value = o;
4519
4502
  let s = n.getWriteTextures();
4520
4503
  this.computeNode = this._buildComputeNode(t, i, s.color, s.normalDepth, s.albedo), this._compiled = !1, r.end("Build compute node (TSL)"), r.print();
4521
4504
  }
@@ -4527,11 +4510,11 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4527
4510
  return this._sceneTextureNodes;
4528
4511
  }
4529
4512
  setSize(e, t) {
4530
- this._dispatchX = Math.ceil(e / _s), this._dispatchY = Math.ceil(t / _s), this.computeNode && (this._dispatchSize[0] = this._dispatchX, this._dispatchSize[1] = this._dispatchY, this.computeNode.dispatchSize = this._dispatchSize), this.renderWidth.value = e, this.renderHeight.value = t, this.tileOffsetX.value = 0, this.tileOffsetY.value = 0;
4513
+ this._dispatchX = Math.ceil(e / bs), this._dispatchY = Math.ceil(t / bs), this.computeNode && (this._dispatchSize[0] = this._dispatchX, this._dispatchSize[1] = this._dispatchY, this.computeNode.dispatchSize = this._dispatchSize), this.renderWidth.value = e, this.renderHeight.value = t, this.tileOffsetX.value = 0, this.tileOffsetY.value = 0;
4531
4514
  }
4532
4515
  setTileDispatch(e, t, n, r) {
4533
4516
  this.tileOffsetX.value = e, this.tileOffsetY.value = t;
4534
- let i = Math.ceil(n / _s), a = Math.ceil(r / _s);
4517
+ let i = Math.ceil(n / bs), a = Math.ceil(r / bs);
4535
4518
  this.computeNode && (this._dispatchSize[0] = i, this._dispatchSize[1] = a, this.computeNode.dispatchSize = this._dispatchSize);
4536
4519
  }
4537
4520
  setFullScreenDispatch() {
@@ -4542,7 +4525,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4542
4525
  }
4543
4526
  _createTextureNodes(e, t) {
4544
4527
  let n = e.triangleStorageNode, r = e.bvhStorageNode, i = e.materialData.materialStorageNode, a = e.lightStorageNode;
4545
- oo(e.uniforms.get("enableAlphaShadows"));
4528
+ lo(e.uniforms.get("enableAlphaShadows"));
4546
4529
  let o = be(e.environment.environmentTexture), s = new c();
4547
4530
  this.adaptiveSamplingTexNode = s;
4548
4531
  let l = e.environment.envCDFStorageNode, u = t.getReadTextures();
@@ -4556,7 +4539,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4556
4539
  ]), 1, 1, 1);
4557
4540
  return e.minFilter = q, e.magFilter = q, e.generateMipmaps = !1, e.needsUpdate = !0, be(e);
4558
4541
  }, f = e.materialData, p = f.albedoMaps ? be(f.albedoMaps) : d(), m = f.normalMaps ? be(f.normalMaps) : d(), h = f.bumpMaps ? be(f.bumpMaps) : d(), g = f.metalnessMaps ? be(f.metalnessMaps) : d(), _ = f.roughnessMaps ? be(f.roughnessMaps) : d(), v = f.emissiveMaps ? be(f.emissiveMaps) : d(), y = f.displacementMaps ? be(f.displacementMaps) : d();
4559
- ao(p);
4542
+ co(p);
4560
4543
  let b = {
4561
4544
  triStorage: n,
4562
4545
  bvhStorage: r,
@@ -4578,9 +4561,9 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4578
4561
  _buildComputeNode(e, t, n, r, i) {
4579
4562
  let { triStorage: a, bvhStorage: o, matStorage: s, lightBufferStorage: c, envTex: l, adaptiveSamplingTex: u, envCDFStorage: d, albedoMapsTex: f, normalMapsTex: h, bumpMapsTex: g, metalnessMapsTex: _, roughnessMapsTex: v, emissiveMapsTex: y, displacementMapsTex: b } = t, x = this.tileOffsetX, S = this.tileOffsetY, C = this.renderWidth, w = this.renderHeight, T = this.prevColorTexNode, E = this.prevNormalDepthTexNode, D = this.prevAlbedoTexNode;
4580
4563
  return p(() => {
4581
- let t = x.add(N(De.x).mul(_s)).add(N(F.x)), p = S.add(N(De.y).mul(_s)).add(N(F.y));
4564
+ let t = x.add(N(De.x).mul(bs)).add(N(F.x)), p = S.add(N(De.y).mul(bs)).add(N(F.y));
4582
4565
  m(t.lessThan(C).and(p.lessThan(w)), () => {
4583
- hs({
4566
+ vs({
4584
4567
  pixelCoord: U(M(t).add(.5), M(p).add(.5)),
4585
4568
  writeColorTex: n,
4586
4569
  writeNDTex: r,
@@ -4662,15 +4645,15 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4662
4645
  this._dispatchY,
4663
4646
  1
4664
4647
  ], [
4665
- _s,
4666
- _s,
4648
+ bs,
4649
+ bs,
4667
4650
  1
4668
4651
  ]);
4669
4652
  }
4670
4653
  dispose() {
4671
4654
  this.computeNode?.dispose(), this.computeNode = null, this.prevColorTexNode = null, this.prevNormalDepthTexNode = null, this.prevAlbedoTexNode = null, this.adaptiveSamplingTexNode = null, this._sceneTextureNodes = null, this._compiled = !1;
4672
4655
  }
4673
- }, ys = class {
4656
+ }, Ss = class {
4674
4657
  constructor(e, t) {
4675
4658
  this.traversalCost = e, this.intersectionCost = t, this.maxTreeletLeaves = 7, this.minImprovement = .02, this.topologyCache = /* @__PURE__ */ new Map();
4676
4659
  for (let e = 3; e <= this.maxTreeletLeaves; e++) this.topologyCache.set(e, this.generateTopologies(e));
@@ -4861,10 +4844,10 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4861
4844
  }
4862
4845
  buildSubtree(e, t, n) {
4863
4846
  if (typeof e == "number") {
4864
- let r = t[n[e]], i = new bs();
4847
+ let r = t[n[e]], i = new Cs();
4865
4848
  return i.minX = r.minX, i.minY = r.minY, i.minZ = r.minZ, i.maxX = r.maxX, i.maxY = r.maxY, i.maxZ = r.maxZ, i.triangleOffset = r.triangleOffset, i.triangleCount = r.triangleCount, i;
4866
4849
  }
4867
- let r = this.buildSubtree(e[0], t, n), i = this.buildSubtree(e[1], t, n), a = new bs();
4850
+ let r = this.buildSubtree(e[0], t, n), i = this.buildSubtree(e[1], t, n), a = new Cs();
4868
4851
  return a.leftChild = r, a.rightChild = i, a.minX = Math.min(r.minX, i.minX), a.minY = Math.min(r.minY, i.minY), a.minZ = Math.min(r.minZ, i.minZ), a.maxX = Math.max(r.maxX, i.maxX), a.maxY = Math.max(r.maxY, i.maxY), a.maxZ = Math.max(r.maxZ, i.maxZ), a;
4869
4852
  }
4870
4853
  setTreeletSize(e) {
@@ -4878,11 +4861,11 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
4878
4861
  getStatistics() {
4879
4862
  return { ...this.stats };
4880
4863
  }
4881
- }, bs = class {
4864
+ }, Cs = class {
4882
4865
  constructor() {
4883
4866
  this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.leftChild = null, this.rightChild = null, this.triangleOffset = 0, this.triangleCount = 0;
4884
4867
  }
4885
- }, xs = class {
4868
+ }, ws = class {
4886
4869
  constructor(e, t) {
4887
4870
  this.traversalCost = e, this.intersectionCost = t, this.batchSizeRatio = .02, this.maxIterations = 2, this.timeBudgetMs = 15e3, this.stats = {
4888
4871
  reinsertionsApplied: 0,
@@ -5047,7 +5030,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5047
5030
  }
5048
5031
  return this.stats.timeMs = performance.now() - n, this.stats;
5049
5032
  }
5050
- }, Ss = "" + new URL("assets/BVHWorker-CNJ0UBQz.js", import.meta.url).href, Cs = {
5033
+ }, Ts = "" + new URL("assets/BVHWorker-CNJ0UBQz.js", import.meta.url).href, Es = {
5051
5034
  FLOATS_PER_TRIANGLE: 32,
5052
5035
  POSITION_A_OFFSET: 0,
5053
5036
  POSITION_B_OFFSET: 4,
@@ -5057,11 +5040,11 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5057
5040
  NORMAL_C_OFFSET: 20,
5058
5041
  UV_AB_OFFSET: 24,
5059
5042
  UV_C_MAT_OFFSET: 28
5060
- }, ws = Cs.FLOATS_PER_TRIANGLE, Ts = class {
5043
+ }, Ds = Es.FLOATS_PER_TRIANGLE, Os = class {
5061
5044
  constructor() {
5062
5045
  this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.leftChild = null, this.rightChild = null, this.triangleOffset = 0, this.triangleCount = 0;
5063
5046
  }
5064
- }, Es = class {
5047
+ }, ks = class {
5065
5048
  constructor() {
5066
5049
  this.useWorker = !0, this.maxLeafSize = 8, this.numBins = 32, this.minBins = 8, this.maxBins = 64, this.totalNodes = 0, this.processedTriangles = 0, this.totalTriangles = 0, this.lastProgressUpdate = 0, this.progressUpdateInterval = 100, this.traversalCost = 1, this.intersectionCost = 2.5, this.useMortonCodes = !0, this.mortonBits = 10, this.mortonClusterThreshold = 128, this.enableObjectMedianFallback = !0, this.enableSpatialMedianFallback = !0, this.splitStats = {
5067
5050
  sahSplits: 0,
@@ -5121,9 +5104,9 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5121
5104
  e.enabled !== void 0 && (this.enableReinsertionOptimization = e.enabled), e.batchSizeRatio !== void 0 && (this.reinsertionBatchSizeRatio = Math.max(.005, Math.min(.1, e.batchSizeRatio))), e.maxIterations !== void 0 && (this.reinsertionMaxIterations = Math.max(1, Math.min(5, e.maxIterations)));
5122
5105
  }
5123
5106
  initializeTriangleArrays() {
5124
- let e = this.totalTriangles, t = this.triangles, n = Cs.POSITION_A_OFFSET, r = Cs.POSITION_B_OFFSET, i = Cs.POSITION_C_OFFSET;
5107
+ let e = this.totalTriangles, t = this.triangles, n = Es.POSITION_A_OFFSET, r = Es.POSITION_B_OFFSET, i = Es.POSITION_C_OFFSET;
5125
5108
  for (let a = 0; a < e; a++) {
5126
- let e = a * ws, o = t[e + n], s = t[e + n + 1], c = t[e + n + 2], l = t[e + r], u = t[e + r + 1], d = t[e + r + 2], f = t[e + i], p = t[e + i + 1], m = t[e + i + 2], h = a * 3;
5109
+ let e = a * Ds, o = t[e + n], s = t[e + n + 1], c = t[e + n + 2], l = t[e + r], u = t[e + r + 1], d = t[e + r + 2], f = t[e + i], p = t[e + i + 1], m = t[e + i + 2], h = a * 3;
5127
5110
  this.centroids[h] = (o + l + f) / 3, this.centroids[h + 1] = (s + u + p) / 3, this.centroids[h + 2] = (c + d + m) / 3, this.bMin[h] = o < l ? o < f ? o : f : l < f ? l : f, this.bMin[h + 1] = s < u ? s < p ? s : p : u < p ? u : p, this.bMin[h + 2] = c < d ? c < m ? c : m : d < m ? d : m, this.bMax[h] = o > l ? o > f ? o : f : l > f ? l : f, this.bMax[h + 1] = s > u ? s > p ? s : p : u > p ? u : p, this.bMax[h + 2] = c > d ? c > m ? c : m : d > m ? d : m, this.indices[a] = a;
5128
5111
  }
5129
5112
  }
@@ -5168,11 +5151,11 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5168
5151
  this.splitStats.mortonSortTime += performance.now() - t;
5169
5152
  }
5170
5153
  build(e, t = 30, n = null) {
5171
- return this.totalTriangles = e.byteLength / (ws * 4), this.processedTriangles = 0, this.lastProgressUpdate = performance.now(), this.useWorker && typeof Worker < "u" ? new Promise((r, i) => {
5154
+ return this.totalTriangles = e.byteLength / (Ds * 4), this.processedTriangles = 0, this.lastProgressUpdate = performance.now(), this.useWorker && typeof Worker < "u" ? new Promise((r, i) => {
5172
5155
  let a = (a) => {
5173
5156
  let o = this.totalTriangles, s = typeof SharedArrayBuffer < "u";
5174
5157
  console.log(`[BVHBuilder] SharedArrayBuffer: ${s ? "enabled" : "unavailable (using transfer fallback)"}`);
5175
- let c = s ? new SharedArrayBuffer(o * ws * 4) : null;
5158
+ let c = s ? new SharedArrayBuffer(o * Ds * 4) : null;
5176
5159
  a.onmessage = (e) => {
5177
5160
  let { bvhData: t, triangles: o, originalToBvh: s, error: l, progress: u, treeletStats: d } = e.data;
5178
5161
  if (l) {
@@ -5215,9 +5198,9 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5215
5198
  a.postMessage(u, [l]);
5216
5199
  };
5217
5200
  try {
5218
- a(new Worker(Ss, { type: "module" }));
5201
+ a(new Worker(Ts, { type: "module" }));
5219
5202
  } catch (i) {
5220
- i.name === "SecurityError" ? or(Ss).then(a).catch(() => {
5203
+ i.name === "SecurityError" ? or(Ts).then(a).catch(() => {
5221
5204
  console.warn("Worker fetch fallback failed, using synchronous build"), r(this._buildSyncAndFlatten(e, t, n));
5222
5205
  }) : (console.warn("Worker creation failed, falling back to synchronous build:", i), r(this._buildSyncAndFlatten(e, t, n)));
5223
5206
  }
@@ -5236,7 +5219,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5236
5219
  }
5237
5220
  buildSync(e, t = 30, n = null, r = null) {
5238
5221
  let i = performance.now();
5239
- this.totalNodes = 0, this.processedTriangles = 0, this.triangles = e, this.totalTriangles = e.byteLength / (ws * 4), this.lastProgressUpdate = performance.now(), this.splitStats = {
5222
+ this.totalNodes = 0, this.processedTriangles = 0, this.triangles = e, this.totalTriangles = e.byteLength / (Ds * 4), this.lastProgressUpdate = performance.now(), this.splitStats = {
5240
5223
  sahSplits: 0,
5241
5224
  objectMedianSplits: 0,
5242
5225
  spatialMedianSplits: 0,
@@ -5261,7 +5244,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5261
5244
  this.centroids = new Float32Array(a * 3), this.bMin = new Float32Array(a * 3), this.bMax = new Float32Array(a * 3), this.indices = new Uint32Array(a), this.mortonCodes = new Uint32Array(a), this.initializeTriangleArrays(), this.splitStats.initTime = performance.now() - o, this.sortTrianglesByMortonCode();
5262
5245
  let s = performance.now(), c = this.buildNodeRecursive(0, a, t, n);
5263
5246
  if (this.splitStats.sahBuildTime = performance.now() - s, this.enableTreeletOptimization && this.totalTriangles > 1e3) {
5264
- let e = this.totalTriangles > this.treeletComplexityThreshold, t = e ? 3 : this.treeletSize, r = e ? 10 : this.maxTreeletsPerScene, i = new ys(this.traversalCost, this.intersectionCost);
5247
+ let e = this.totalTriangles > this.treeletComplexityThreshold, t = e ? 3 : this.treeletSize, r = e ? 10 : this.maxTreeletsPerScene, i = new Ss(this.traversalCost, this.intersectionCost);
5265
5248
  i.setTreeletSize(t), i.setMinImprovement(this.treeletMinImprovement), i.setMaxTreelets(r);
5266
5249
  let a = performance.now();
5267
5250
  for (let e = 0; e < this.treeletOptimizationPasses; e++) {
@@ -5283,7 +5266,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5283
5266
  this.splitStats.treeletsProcessed = s.treeletsProcessed, this.splitStats.treeletsImproved = s.treeletsImproved, this.splitStats.averageSAHImprovement = s.averageSAHImprovement;
5284
5267
  }
5285
5268
  if (this.enableReinsertionOptimization && this.totalTriangles > 1e3) {
5286
- let e = new xs(this.traversalCost, this.intersectionCost);
5269
+ let e = new ws(this.traversalCost, this.intersectionCost);
5287
5270
  e.setBatchSizeRatio(this.reinsertionBatchSizeRatio), e.setMaxIterations(this.reinsertionMaxIterations);
5288
5271
  let t = n ? (e) => {
5289
5272
  n(e);
@@ -5298,10 +5281,10 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5298
5281
  }
5299
5282
  let l = performance.now();
5300
5283
  this.applySAOrdering(c), this.splitStats.saOrderTime = performance.now() - l;
5301
- let u = performance.now(), d = this.triangles, f = r || new Float32Array(a * ws);
5284
+ let u = performance.now(), d = this.triangles, f = r || new Float32Array(a * Ds);
5302
5285
  for (let e = 0; e < a; e++) {
5303
- let t = this.indices[e] * ws, n = e * ws;
5304
- f.set(d.subarray(t, t + ws), n);
5286
+ let t = this.indices[e] * Ds, n = e * Ds;
5287
+ f.set(d.subarray(t, t + Ds), n);
5305
5288
  }
5306
5289
  this.reorderedTriangleData = f;
5307
5290
  let p = new Uint32Array(a);
@@ -5317,7 +5300,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5317
5300
  n - this.lastProgressUpdate < this.progressUpdateInterval || (this.lastProgressUpdate = n, t(Math.min(Math.floor(this.processedTriangles / this.totalTriangles * 100), 99)));
5318
5301
  }
5319
5302
  buildNodeRecursiveToDepth(e, t, n, r, i, a, o, s, c, l, u) {
5320
- let d = new Ts();
5303
+ let d = new Os();
5321
5304
  this.totalNodes++;
5322
5305
  let f = t - e;
5323
5306
  if (a === void 0 ? this.updateNodeBounds(d, e, t) : (d.minX = a, d.minY = o, d.minZ = s, d.maxX = c, d.maxY = l, d.maxZ = u), f <= this.maxLeafSize || n <= 0) return d.triangleOffset = e, d.triangleCount = f, this.updateProgress(f, i), d;
@@ -5358,7 +5341,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5358
5341
  return h === e || h === t ? (d.triangleOffset = e, d.triangleCount = f, this.updateProgress(f, i), d) : (d.leftChild = this.buildNodeRecursiveToDepth(e, h, n - 1, r - 1, i, g, _, v, y, b, x), d.rightChild = this.buildNodeRecursiveToDepth(h, t, n - 1, r - 1, i, S, C, w, T, E, D), d);
5359
5342
  }
5360
5343
  buildNodeRecursive(e, t, n, r, i, a, o, s, c, l) {
5361
- let u = new Ts();
5344
+ let u = new Os();
5362
5345
  this.totalNodes++;
5363
5346
  let d = t - e;
5364
5347
  if (i === void 0 ? this.updateNodeBounds(u, e, t) : (u.minX = i, u.minY = a, u.minZ = o, u.maxX = s, u.maxY = c, u.maxZ = l), d <= this.maxLeafSize || n <= 0) return u.triangleOffset = e, u.triangleCount = d, this.updateProgress(d, r), u;
@@ -5656,7 +5639,7 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5656
5639
  let o = r - e, s = i - t, c = a - n;
5657
5640
  return 2 * (o * s + s * c + c * o);
5658
5641
  }
5659
- }, Ds = {
5642
+ }, As = {
5660
5643
  FLOATS_PER_TRIANGLE: 32,
5661
5644
  POSITION_A_OFFSET: 0,
5662
5645
  POSITION_B_OFFSET: 4,
@@ -5664,28 +5647,28 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5664
5647
  NORMAL_A_OFFSET: 12,
5665
5648
  NORMAL_B_OFFSET: 16,
5666
5649
  NORMAL_C_OFFSET: 20
5667
- }, Os = Ds.FLOATS_PER_TRIANGLE, ks = 16, As = -1, js = -2, Ms = class {
5650
+ }, js = As.FLOATS_PER_TRIANGLE, Ms = 16, Ns = -1, Ps = -2, Fs = class {
5668
5651
  constructor() {
5669
5652
  this._bounds = null, this._boundsNodeCount = 0;
5670
5653
  }
5671
5654
  updateTrianglePositions(e, t, n) {
5672
5655
  let r = n.length;
5673
5656
  for (let i = 0; i < r; i++) {
5674
- let r = n[i], a = i * Os, o = r * 9, s = t[o], c = t[o + 1], l = t[o + 2], u = t[o + 3], d = t[o + 4], f = t[o + 5], p = t[o + 6], m = t[o + 7], h = t[o + 8];
5675
- e[a + Ds.POSITION_A_OFFSET] = s, e[a + Ds.POSITION_A_OFFSET + 1] = c, e[a + Ds.POSITION_A_OFFSET + 2] = l, e[a + Ds.POSITION_B_OFFSET] = u, e[a + Ds.POSITION_B_OFFSET + 1] = d, e[a + Ds.POSITION_B_OFFSET + 2] = f, e[a + Ds.POSITION_C_OFFSET] = p, e[a + Ds.POSITION_C_OFFSET + 1] = m, e[a + Ds.POSITION_C_OFFSET + 2] = h;
5657
+ let r = n[i], a = i * js, o = r * 9, s = t[o], c = t[o + 1], l = t[o + 2], u = t[o + 3], d = t[o + 4], f = t[o + 5], p = t[o + 6], m = t[o + 7], h = t[o + 8];
5658
+ e[a + As.POSITION_A_OFFSET] = s, e[a + As.POSITION_A_OFFSET + 1] = c, e[a + As.POSITION_A_OFFSET + 2] = l, e[a + As.POSITION_B_OFFSET] = u, e[a + As.POSITION_B_OFFSET + 1] = d, e[a + As.POSITION_B_OFFSET + 2] = f, e[a + As.POSITION_C_OFFSET] = p, e[a + As.POSITION_C_OFFSET + 1] = m, e[a + As.POSITION_C_OFFSET + 2] = h;
5676
5659
  let g = u - s, _ = d - c, v = f - l, y = p - s, b = m - c, x = h - l, S = _ * x - v * b, C = v * y - g * x, w = g * b - _ * y;
5677
- e[a + Ds.NORMAL_A_OFFSET] = S, e[a + Ds.NORMAL_A_OFFSET + 1] = C, e[a + Ds.NORMAL_A_OFFSET + 2] = w, e[a + Ds.NORMAL_B_OFFSET] = S, e[a + Ds.NORMAL_B_OFFSET + 1] = C, e[a + Ds.NORMAL_B_OFFSET + 2] = w, e[a + Ds.NORMAL_C_OFFSET] = S, e[a + Ds.NORMAL_C_OFFSET + 1] = C, e[a + Ds.NORMAL_C_OFFSET + 2] = w;
5660
+ e[a + As.NORMAL_A_OFFSET] = S, e[a + As.NORMAL_A_OFFSET + 1] = C, e[a + As.NORMAL_A_OFFSET + 2] = w, e[a + As.NORMAL_B_OFFSET] = S, e[a + As.NORMAL_B_OFFSET + 1] = C, e[a + As.NORMAL_B_OFFSET + 2] = w, e[a + As.NORMAL_C_OFFSET] = S, e[a + As.NORMAL_C_OFFSET + 1] = C, e[a + As.NORMAL_C_OFFSET + 2] = w;
5678
5661
  }
5679
5662
  }
5680
5663
  refitRange(e, t, n, r) {
5681
5664
  r > this._boundsNodeCount && (this._bounds = new Float32Array(r * 6), this._boundsNodeCount = r);
5682
5665
  let i = this._bounds, a = n + r;
5683
5666
  for (let r = a - 1; r >= n; r--) {
5684
- let a = r * ks, o = (r - n) * 6;
5685
- if (e[a + 3] === As) {
5667
+ let a = r * Ms, o = (r - n) * 6;
5668
+ if (e[a + 3] === Ns) {
5686
5669
  let n = e[a], r = e[a + 1], s = Infinity, c = Infinity, l = Infinity, u = -Infinity, d = -Infinity, f = -Infinity;
5687
5670
  for (let e = 0; e < r; e++) {
5688
- let r = (n + e) * Os, i = t[r + Ds.POSITION_A_OFFSET], a = t[r + Ds.POSITION_A_OFFSET + 1], o = t[r + Ds.POSITION_A_OFFSET + 2], p = t[r + Ds.POSITION_B_OFFSET], m = t[r + Ds.POSITION_B_OFFSET + 1], h = t[r + Ds.POSITION_B_OFFSET + 2], g = t[r + Ds.POSITION_C_OFFSET], _ = t[r + Ds.POSITION_C_OFFSET + 1], v = t[r + Ds.POSITION_C_OFFSET + 2];
5671
+ let r = (n + e) * js, i = t[r + As.POSITION_A_OFFSET], a = t[r + As.POSITION_A_OFFSET + 1], o = t[r + As.POSITION_A_OFFSET + 2], p = t[r + As.POSITION_B_OFFSET], m = t[r + As.POSITION_B_OFFSET + 1], h = t[r + As.POSITION_B_OFFSET + 2], g = t[r + As.POSITION_C_OFFSET], _ = t[r + As.POSITION_C_OFFSET + 1], v = t[r + As.POSITION_C_OFFSET + 2];
5689
5672
  s = Math.min(s, i, p, g), c = Math.min(c, a, m, _), l = Math.min(l, o, h, v), u = Math.max(u, i, p, g), d = Math.max(d, a, m, _), f = Math.max(f, o, h, v);
5690
5673
  }
5691
5674
  i[o] = s, i[o + 1] = c, i[o + 2] = l, i[o + 3] = u, i[o + 4] = d, i[o + 5] = f;
@@ -5699,15 +5682,15 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5699
5682
  n !== this._boundsNodeCount && (this._bounds = new Float32Array(n * 6), this._boundsNodeCount = n);
5700
5683
  let r = this._bounds;
5701
5684
  for (let i = n - 1; i >= 0; i--) {
5702
- let n = i * ks, a = i * 6, o = e[n + 3];
5703
- if (o === As) {
5685
+ let n = i * Ms, a = i * 6, o = e[n + 3];
5686
+ if (o === Ns) {
5704
5687
  let i = e[n], o = e[n + 1], s = Infinity, c = Infinity, l = Infinity, u = -Infinity, d = -Infinity, f = -Infinity;
5705
5688
  for (let e = 0; e < o; e++) {
5706
- let n = (i + e) * Os, r = t[n + Ds.POSITION_A_OFFSET], a = t[n + Ds.POSITION_A_OFFSET + 1], o = t[n + Ds.POSITION_A_OFFSET + 2], p = t[n + Ds.POSITION_B_OFFSET], m = t[n + Ds.POSITION_B_OFFSET + 1], h = t[n + Ds.POSITION_B_OFFSET + 2], g = t[n + Ds.POSITION_C_OFFSET], _ = t[n + Ds.POSITION_C_OFFSET + 1], v = t[n + Ds.POSITION_C_OFFSET + 2];
5689
+ let n = (i + e) * js, r = t[n + As.POSITION_A_OFFSET], a = t[n + As.POSITION_A_OFFSET + 1], o = t[n + As.POSITION_A_OFFSET + 2], p = t[n + As.POSITION_B_OFFSET], m = t[n + As.POSITION_B_OFFSET + 1], h = t[n + As.POSITION_B_OFFSET + 2], g = t[n + As.POSITION_C_OFFSET], _ = t[n + As.POSITION_C_OFFSET + 1], v = t[n + As.POSITION_C_OFFSET + 2];
5707
5690
  s = Math.min(s, r, p, g), c = Math.min(c, a, m, _), l = Math.min(l, o, h, v), u = Math.max(u, r, p, g), d = Math.max(d, a, m, _), f = Math.max(f, o, h, v);
5708
5691
  }
5709
5692
  r[a] = s, r[a + 1] = c, r[a + 2] = l, r[a + 3] = u, r[a + 4] = d, r[a + 5] = f;
5710
- } else if (o === js) {
5693
+ } else if (o === Ps) {
5711
5694
  let t = e[n] * 6;
5712
5695
  r[a] = r[t], r[a + 1] = r[t + 1], r[a + 2] = r[t + 2], r[a + 3] = r[t + 3], r[a + 4] = r[t + 4], r[a + 5] = r[t + 5];
5713
5696
  } else {
@@ -5716,19 +5699,19 @@ var ps = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
5716
5699
  }
5717
5700
  }
5718
5701
  }
5719
- }, Ns = "" + new URL("assets/BVHSubtreeWorker-D9GImjGj.js", import.meta.url).href, Ps = 32, Fs = 5e4, Is = 8;
5720
- function Ls(e, t, n, r) {
5721
- let i = e.byteLength / (Ps * 4), a = Math.min(navigator.hardwareConcurrency || 4, Is), o = Math.ceil(Math.log2(a * 2.5 + 1));
5702
+ }, Is = "" + new URL("assets/BVHSubtreeWorker-D9GImjGj.js", import.meta.url).href, Ls = 32, Rs = 5e4, zs = 8;
5703
+ function Bs(e, t, n, r) {
5704
+ let i = e.byteLength / (Ls * 4), a = Math.min(navigator.hardwareConcurrency || 4, zs), o = Math.ceil(Math.log2(a * 2.5 + 1));
5722
5705
  return console.log(`[ParallelBVH] Parallel build: ${i.toLocaleString()} triangles, ${a} workers, parallelDepth=${o}`), new Promise((s, c) => {
5723
5706
  (async () => {
5724
5707
  let c = new SharedArrayBuffer(e.byteLength);
5725
5708
  new Float32Array(c).set(e);
5726
- let l = new SharedArrayBuffer(i * 3 * 4), u = new SharedArrayBuffer(i * 3 * 4), d = new SharedArrayBuffer(i * 3 * 4), f = new SharedArrayBuffer(i * 4), p = new SharedArrayBuffer(i * 4), m = new SharedArrayBuffer(i * Ps * 4), h;
5709
+ let l = new SharedArrayBuffer(i * 3 * 4), u = new SharedArrayBuffer(i * 3 * 4), d = new SharedArrayBuffer(i * 3 * 4), f = new SharedArrayBuffer(i * 4), p = new SharedArrayBuffer(i * 4), m = new SharedArrayBuffer(i * Ls * 4), h;
5727
5710
  try {
5728
- h = new Worker(Ss, { type: "module" });
5711
+ h = new Worker(Ts, { type: "module" });
5729
5712
  } catch (e) {
5730
5713
  if (e.name !== "SecurityError") throw e;
5731
- h = await or(Ss);
5714
+ h = await or(Ts);
5732
5715
  }
5733
5716
  let g = null, _ = [h], v = { id: null }, y = !1, b = () => {
5734
5717
  v.id &&= (clearTimeout(v.id), null);
@@ -5739,7 +5722,7 @@ function Ls(e, t, n, r) {
5739
5722
  if (y) return;
5740
5723
  y = !0, console.warn(`[ParallelBVH] Parallel build failed (${e}), falling back to single worker`), b();
5741
5724
  let i = new ArrayBuffer(c.byteLength);
5742
- new Float32Array(i).set(new Float32Array(c)), s(zs(new Float32Array(i), t, n, r));
5725
+ new Float32Array(i).set(new Float32Array(c)), s(Hs(new Float32Array(i), t, n, r));
5743
5726
  };
5744
5727
  h.onerror = (e) => {
5745
5728
  x(`coordinator error: ${e.message}`);
@@ -5754,7 +5737,7 @@ function Ls(e, t, n, r) {
5754
5737
  return;
5755
5738
  }
5756
5739
  if (t.type === "phase1Result") {
5757
- g = t.splitStats, Rs(t, a, c, l, u, d, f, m, i, n, h, _, b, x, s, v, r).catch((e) => x(e.message));
5740
+ g = t.splitStats, Vs(t, a, c, l, u, d, f, m, i, n, h, _, b, x, s, v, r).catch((e) => x(e.message));
5758
5741
  return;
5759
5742
  }
5760
5743
  if (t.type === "assembleResult") {
@@ -5788,7 +5771,7 @@ function Ls(e, t, n, r) {
5788
5771
  });
5789
5772
  });
5790
5773
  }
5791
- async function Rs(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g) {
5774
+ async function Vs(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g) {
5792
5775
  let { topFlatData: _, topNodeCount: v, frontierTasks: y, frontierMap: b } = e;
5793
5776
  if (!y || y.length === 0) {
5794
5777
  console.log("[ParallelBVH] No frontier tasks, assembling with top-level tree only"), u.postMessage({
@@ -5837,10 +5820,10 @@ async function Rs(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g) {
5837
5820
  if (t.length === 0) continue;
5838
5821
  let s;
5839
5822
  try {
5840
- s = new Worker(Ns, { type: "module" });
5823
+ s = new Worker(Is, { type: "module" });
5841
5824
  } catch (e) {
5842
5825
  if (e.name !== "SecurityError") throw e;
5843
- s = await or(Ns);
5826
+ s = await or(Is);
5844
5827
  }
5845
5828
  d.push(s), s.onerror = (e) => {
5846
5829
  p(`subtree worker error: ${e.message}`);
@@ -5891,17 +5874,17 @@ async function Rs(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g) {
5891
5874
  });
5892
5875
  }
5893
5876
  }
5894
- function zs(e, t, n, r) {
5877
+ function Hs(e, t, n, r) {
5895
5878
  return new Promise((i, a) => {
5896
5879
  (async () => {
5897
5880
  let o;
5898
5881
  try {
5899
- o = new Worker(Ss, { type: "module" });
5882
+ o = new Worker(Ts, { type: "module" });
5900
5883
  } catch (e) {
5901
5884
  if (e.name !== "SecurityError") throw e;
5902
- o = await or(Ss);
5885
+ o = await or(Ts);
5903
5886
  }
5904
- let s = e.byteLength / (Ps * 4), c = typeof SharedArrayBuffer < "u" ? new SharedArrayBuffer(s * Ps * 4) : null;
5887
+ let s = e.byteLength / (Ls * 4), c = typeof SharedArrayBuffer < "u" ? new SharedArrayBuffer(s * Ls * 4) : null;
5905
5888
  o.onmessage = (e) => {
5906
5889
  let { bvhData: t, triangles: r, originalToBvh: s, error: l, progress: u, treeletStats: d } = e.data;
5907
5890
  if (l) {
@@ -5939,16 +5922,16 @@ function zs(e, t, n, r) {
5939
5922
  });
5940
5923
  });
5941
5924
  }
5942
- function Bs(e) {
5943
- return typeof Worker < "u" && typeof SharedArrayBuffer < "u" && e >= Fs;
5925
+ function Us(e) {
5926
+ return typeof Worker < "u" && typeof SharedArrayBuffer < "u" && e >= Rs;
5944
5927
  }
5945
5928
  //#endregion
5946
5929
  //#region src/Processor/TLASBuilder.js
5947
- var Vs = 16, Hs = class {
5930
+ var Ws = 16, Gs = class {
5948
5931
  constructor() {
5949
5932
  this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.leftChild = null, this.rightChild = null, this.entryIndex = -1;
5950
5933
  }
5951
- }, Us = class {
5934
+ }, Ks = class {
5952
5935
  constructor() {
5953
5936
  this._flatBuffer = null, this._flatBufferCapacity = 0;
5954
5937
  }
@@ -5966,7 +5949,7 @@ var Vs = 16, Hs = class {
5966
5949
  };
5967
5950
  }
5968
5951
  _buildRecursive(e, t) {
5969
- let n = new Hs();
5952
+ let n = new Gs();
5970
5953
  if (t.length === 1) {
5971
5954
  let r = e[t[0]].worldAABB;
5972
5955
  return n.minX = r.minX, n.minY = r.minY, n.minZ = r.minZ, n.maxX = r.maxX, n.maxY = r.maxY, n.maxZ = r.maxZ, n.entryIndex = t[0], n;
@@ -6003,12 +5986,12 @@ var Vs = 16, Hs = class {
6003
5986
  let e = r.pop();
6004
5987
  e._flatIndex = n.length, n.push(e), e.rightChild && r.push(e.rightChild), e.leftChild && r.push(e.leftChild);
6005
5988
  }
6006
- let i = n.length * Vs;
5989
+ let i = n.length * Ws;
6007
5990
  i > this._flatBufferCapacity && (this._flatBuffer = new Float32Array(i), this._flatBufferCapacity = i);
6008
5991
  let a = this._flatBuffer;
6009
5992
  a.fill(0, 0, i);
6010
5993
  for (let e = 0; e < n.length; e++) {
6011
- let r = n[e], i = e * Vs;
5994
+ let r = n[e], i = e * Ws;
6012
5995
  if (r.leftChild) {
6013
5996
  let e = r.leftChild, t = r.rightChild;
6014
5997
  a[i] = e.minX, a[i + 1] = e.minY, a[i + 2] = e.minZ, a[i + 3] = e._flatIndex, a[i + 4] = e.maxX, a[i + 5] = e.maxY, a[i + 6] = e.maxZ, a[i + 7] = t._flatIndex, a[i + 8] = t.minX, a[i + 9] = t.minY, a[i + 10] = t.minZ, a[i + 12] = t.maxX, a[i + 13] = t.maxY, a[i + 14] = t.maxZ;
@@ -6050,7 +6033,7 @@ var Vs = 16, Hs = class {
6050
6033
  }
6051
6034
  return t;
6052
6035
  }
6053
- }, Ws = class {
6036
+ }, qs = class {
6054
6037
  constructor() {
6055
6038
  this.entries = [], this.totalBLASNodes = 0, this.tlasNodeCount = 0;
6056
6039
  }
@@ -6127,7 +6110,7 @@ var Vs = 16, Hs = class {
6127
6110
  clear() {
6128
6111
  this.entries = [], this.totalBLASNodes = 0, this.tlasNodeCount = 0;
6129
6112
  }
6130
- }, Gs = "" + new URL("assets/TexturesWorker-DBqGmVdR.js", import.meta.url).href, Ks = class {
6113
+ }, Js = "" + new URL("assets/TexturesWorker-DBqGmVdR.js", import.meta.url).href, Ys = class {
6131
6114
  constructor() {
6132
6115
  this.canvasContextPairs = [], this.maxPoolSize = qn.CANVAS_POOL_SIZE;
6133
6116
  }
@@ -6167,7 +6150,7 @@ var Vs = 16, Hs = class {
6167
6150
  dispose() {
6168
6151
  this.canvasContextPairs = [];
6169
6152
  }
6170
- }, qs = class {
6153
+ }, Xs = class {
6171
6154
  constructor(e = {}) {
6172
6155
  this.pools = /* @__PURE__ */ new Map(), this.memoryUsage = 0, this.maxMemoryUsage = e.maxMemory || Zn.MAX_BUFFER_MEMORY, this.allocatedBuffers = /* @__PURE__ */ new WeakMap(), this.sizeStrategy = e.sizeStrategy || "adaptive";
6173
6156
  }
@@ -6225,7 +6208,7 @@ var Vs = 16, Hs = class {
6225
6208
  let e = this.getMemoryStats();
6226
6209
  return e.utilizationPercentage > 90 ? (console.warn(`Memory pool critical: ${e.utilizationPercentage.toFixed(1)}% used (${(e.currentUsage / (1024 * 1024)).toFixed(1)}MB / ${(e.maxUsage / (1024 * 1024)).toFixed(1)}MB)`), "critical") : e.utilizationPercentage > 70 ? (console.warn(`Memory pool high: ${e.utilizationPercentage.toFixed(1)}% used (${(e.currentUsage / (1024 * 1024)).toFixed(1)}MB / ${(e.maxUsage / (1024 * 1024)).toFixed(1)}MB)`), "high") : "normal";
6227
6210
  }
6228
- }, Js = class {
6211
+ }, Zs = class {
6229
6212
  constructor(e = qn.CACHE_SIZE_LIMIT) {
6230
6213
  this.cache = /* @__PURE__ */ new Map(), this.accessOrder = [], this.maxSize = e;
6231
6214
  }
@@ -6262,12 +6245,12 @@ var Vs = 16, Hs = class {
6262
6245
  e && e.dispose && e.dispose();
6263
6246
  }), this.cache.clear(), this.accessOrder = [];
6264
6247
  }
6265
- }, Ys = class {
6248
+ }, Qs = class {
6266
6249
  constructor(e = {}) {
6267
- this.useWorkers = typeof Worker < "u", this.maxConcurrentWorkers = qn.MAX_CONCURRENT_WORKERS, this.activeWorkers = 0, this.canvasPool = new Ks(), this.bufferPool = new qs({
6250
+ this.useWorkers = typeof Worker < "u", this.maxConcurrentWorkers = qn.MAX_CONCURRENT_WORKERS, this.activeWorkers = 0, this.canvasPool = new Ys(), this.bufferPool = new Xs({
6268
6251
  maxMemory: e.maxBufferMemory || Zn.MAX_BUFFER_MEMORY,
6269
6252
  sizeStrategy: e.bufferSizeStrategy || "adaptive"
6270
- }), this.textureCache = new Js(), this.capabilities = this.detectCapabilities(), this.optimalMethod = this.selectOptimalMethod();
6253
+ }), this.textureCache = new Zs(), this.capabilities = this.detectCapabilities(), this.optimalMethod = this.selectOptimalMethod();
6271
6254
  }
6272
6255
  detectCapabilities() {
6273
6256
  return {
@@ -6324,10 +6307,10 @@ var Vs = 16, Hs = class {
6324
6307
  try {
6325
6308
  let t;
6326
6309
  try {
6327
- t = new Worker(Gs, { type: "module" });
6310
+ t = new Worker(Js, { type: "module" });
6328
6311
  } catch (e) {
6329
6312
  if (e.name !== "SecurityError") throw e;
6330
- t = await or(Gs);
6313
+ t = await or(Js);
6331
6314
  }
6332
6315
  let n = await this.prepareTexturesForWorkerDirect(e), r = await new Promise((e, r) => {
6333
6316
  t.onmessage = (t) => {
@@ -6594,7 +6577,7 @@ var Vs = 16, Hs = class {
6594
6577
  let l = performance.now();
6595
6578
  try {
6596
6579
  if (!t || t.length === 0) throw Error("No materials provided for texture creation");
6597
- this.textureCache.dispose(), this.textureCache = new Js();
6580
+ this.textureCache.dispose(), this.textureCache = new Zs();
6598
6581
  let e = [];
6599
6582
  n && n.length > 0 && e.push(this.createTexturesToDataTexture(n).then((e) => ({
6600
6583
  type: "albedo",
@@ -6645,7 +6628,7 @@ var Vs = 16, Hs = class {
6645
6628
  let { type: t, texture: n } = e.value;
6646
6629
  if (n) switch (t) {
6647
6630
  case "albedo":
6648
- n.colorSpace = Ct, d.albedoTexture = n;
6631
+ n.colorSpace = wt, d.albedoTexture = n;
6649
6632
  break;
6650
6633
  case "normal":
6651
6634
  d.normalTexture = n;
@@ -6660,7 +6643,7 @@ var Vs = 16, Hs = class {
6660
6643
  d.metalnessTexture = n;
6661
6644
  break;
6662
6645
  case "emissive":
6663
- n.colorSpace = Ct, d.emissiveTexture = n;
6646
+ n.colorSpace = wt, d.emissiveTexture = n;
6664
6647
  break;
6665
6648
  case "displacement":
6666
6649
  d.displacementTexture = n;
@@ -6689,7 +6672,7 @@ var Vs = 16, Hs = class {
6689
6672
  }
6690
6673
  createDataArrayTextureFromBuffer(e, t, n, r) {
6691
6674
  let i = new ze(e, t, n, r);
6692
- i.minFilter = q, i.magFilter = q, i.format = vt, i.type = jt, i.needsUpdate = !0, i.generateMipmaps = !1, i.userData = {
6675
+ i.minFilter = q, i.magFilter = q, i.format = yt, i.type = Mt, i.needsUpdate = !0, i.generateMipmaps = !1, i.userData = {
6693
6676
  buffer: e,
6694
6677
  bufferType: Uint8Array
6695
6678
  };
@@ -6701,12 +6684,12 @@ var Vs = 16, Hs = class {
6701
6684
  async _normalizeTexturesForProcessing(e) {
6702
6685
  let t = [], n = [], r = [];
6703
6686
  for (let n of e) if (n?.image) {
6704
- if (n.isCompressedTexture && n.format === vt && n.mipmaps?.[0]?.data) {
6687
+ if (n.isCompressedTexture && n.format === yt && n.mipmaps?.[0]?.data) {
6705
6688
  let e = n.mipmaps[0], i = t.length;
6706
6689
  t.push(null), r.push({
6707
6690
  index: i,
6708
6691
  flipY: n.flipY,
6709
- promise: Xs(e.data, e.width, e.height)
6692
+ promise: $s(e.data, e.width, e.height)
6710
6693
  });
6711
6694
  continue;
6712
6695
  }
@@ -6719,7 +6702,7 @@ var Vs = 16, Hs = class {
6719
6702
  t.push(null), r.push({
6720
6703
  index: e,
6721
6704
  flipY: n.flipY,
6722
- promise: Xs(n.image.data, n.image.width, n.image.height)
6705
+ promise: $s(n.image.data, n.image.width, n.image.height)
6723
6706
  });
6724
6707
  continue;
6725
6708
  }
@@ -6762,7 +6745,7 @@ var Vs = 16, Hs = class {
6762
6745
  255,
6763
6746
  255
6764
6747
  ]), 1, 1, 1);
6765
- return e.minFilter = q, e.magFilter = q, e.format = vt, e.type = jt, e.needsUpdate = !0, e.generateMipmaps = !1, e;
6748
+ return e.minFilter = q, e.magFilter = q, e.format = yt, e.type = Mt, e.needsUpdate = !0, e.generateMipmaps = !1, e;
6766
6749
  }
6767
6750
  combineTextureResults(e) {
6768
6751
  return e[0];
@@ -6771,16 +6754,16 @@ var Vs = 16, Hs = class {
6771
6754
  this.canvasPool.dispose(), this.bufferPool.dispose(), this.textureCache.dispose();
6772
6755
  }
6773
6756
  };
6774
- function Xs(e, t, n) {
6757
+ function $s(e, t, n) {
6775
6758
  let r = new Uint8ClampedArray(e.buffer, e.byteOffset, e.byteLength);
6776
6759
  return createImageBitmap(new ImageData(r, t, n));
6777
6760
  }
6778
6761
  //#endregion
6779
6762
  //#region src/Processor/GeometryExtractor.js
6780
- var Zs = 128, Qs = class {
6763
+ var ec = 128, tc = class {
6781
6764
  constructor() {
6782
6765
  this._vectorPool = {
6783
- vec3: Array(9).fill().map(() => new Nt()),
6766
+ vec3: Array(9).fill().map(() => new Pt()),
6784
6767
  vec2: [
6785
6768
  ,
6786
6769
  ,
@@ -6788,7 +6771,7 @@ var Zs = 128, Qs = class {
6788
6771
  ,
6789
6772
  ,
6790
6773
  ,
6791
- ].fill().map(() => new Mt())
6774
+ ].fill().map(() => new Nt())
6792
6775
  }, this._matrixPool = {
6793
6776
  mat3: new nt(),
6794
6777
  mat4: new rt()
@@ -6847,7 +6830,7 @@ var Zs = 128, Qs = class {
6847
6830
  let t = e.userData.gltfExtensions.KHR_materials_unlit.alphaMode;
6848
6831
  return t === "BLEND" ? 2 : +(t === "MASK");
6849
6832
  }
6850
- return e.alphaTest > 0 ? 1 : e.transparent && e.opacity < 1 || e.map && e.map.format === vt && e.transparent ? 2 : 0;
6833
+ return e.alphaTest > 0 ? 1 : e.transparent && e.opacity < 1 || e.map && e.map.format === yt && e.transparent ? 2 : 0;
6851
6834
  }
6852
6835
  getMaterialType(e) {
6853
6836
  return e.isMeshPhysicalMaterial ? "physical" : e.isMeshStandardMaterial ? "standard" : e.isMeshPhongMaterial ? "phong" : e.isMeshLambertMaterial ? "lambert" : e.isMeshBasicMaterial ? "basic" : e.isMeshToonMaterial ? "toon" : "unknown";
@@ -6992,7 +6975,7 @@ var Zs = 128, Qs = class {
6992
6975
  n || (n = /* @__PURE__ */ new Map(), this._textureIndexCache.set(t, n));
6993
6976
  let r = e.source.uuid, i = n.get(r);
6994
6977
  if (i !== void 0) return i;
6995
- if (t.length < Zs) {
6978
+ if (t.length < ec) {
6996
6979
  t.push(e);
6997
6980
  let i = t.length - 1;
6998
6981
  return n.set(r, i), i;
@@ -7081,7 +7064,7 @@ var Zs = 128, Qs = class {
7081
7064
  sceneFeatures: this.sceneFeatures
7082
7065
  };
7083
7066
  }
7084
- }, $s = class {
7067
+ }, nc = class {
7085
7068
  constructor() {
7086
7069
  this.maxLeafSize = 8;
7087
7070
  }
@@ -7140,7 +7123,7 @@ var Zs = 128, Qs = class {
7140
7123
  l < i ? n = l + 1 : r = l;
7141
7124
  }
7142
7125
  }
7143
- }, ec = class {
7126
+ }, rc = class {
7144
7127
  constructor() {
7145
7128
  this.emissiveTriangles = [], this.emissiveCount = 0, this.totalEmissivePower = 0, this.emissiveIndicesArray = null, this.emissivePowerArray = null, this.cdfArray = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0;
7146
7129
  }
@@ -7221,7 +7204,7 @@ var Zs = 128, Qs = class {
7221
7204
  };
7222
7205
  }
7223
7206
  createEmissiveTexture() {
7224
- if (this.emissiveCount === 0) return new Be(new Float32Array(4), 1, 1, vt, qe);
7207
+ if (this.emissiveCount === 0) return new Be(new Float32Array(4), 1, 1, yt, qe);
7225
7208
  let e = new Float32Array(this.emissiveCount * 4);
7226
7209
  for (let t = 0; t < this.emissiveCount; t++) {
7227
7210
  let n = t * 4;
@@ -7229,8 +7212,8 @@ var Zs = 128, Qs = class {
7229
7212
  }
7230
7213
  let t = Math.ceil(Math.sqrt(this.emissiveCount)), n = Math.ceil(this.emissiveCount / t), r = t * n * 4, i = new Float32Array(r);
7231
7214
  i.set(e);
7232
- let a = new Be(i, t, n, vt, qe);
7233
- return a.needsUpdate = !0, a.generateMipmaps = !1, a.minFilter = J, a.magFilter = J, console.log(`[EmissiveTriangleBuilder] Created ${t}x${n} emissive texture (${this.emissiveCount} emissives)`), a;
7215
+ let a = new Be(i, t, n, yt, qe);
7216
+ return a.needsUpdate = !0, a.generateMipmaps = !1, a.minFilter = ct, a.magFilter = ct, console.log(`[EmissiveTriangleBuilder] Created ${t}x${n} emissive texture (${this.emissiveCount} emissives)`), a;
7234
7217
  }
7235
7218
  createEmissiveRawData() {
7236
7219
  if (this.emissiveCount === 0) return new Float32Array(8);
@@ -7284,7 +7267,7 @@ var Zs = 128, Qs = class {
7284
7267
  }
7285
7268
  buildLightBVH() {
7286
7269
  if (this.emissiveCount === 0) return this.lightBVHNodeData = new Float32Array(16), this.lightBVHNodeData[7] = 1, this.lightBVHNodeCount = 1, 1;
7287
- let { nodeData: e, nodeCount: t, sortedPerm: n } = new $s().build(this.emissiveTriangles);
7270
+ let { nodeData: e, nodeCount: t, sortedPerm: n } = new nc().build(this.emissiveTriangles);
7288
7271
  return this.lightBVHNodeData = e, this.lightBVHNodeCount = t, this._rebuildSortedEmissiveData(n), t;
7289
7272
  }
7290
7273
  _rebuildSortedEmissiveData(e) {
@@ -7305,7 +7288,7 @@ var Zs = 128, Qs = class {
7305
7288
  clear() {
7306
7289
  this.emissiveTriangles = [], this.emissiveCount = 0, this.totalEmissivePower = 0, this.emissiveIndicesArray = null, this.emissivePowerArray = null, this.cdfArray = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0;
7307
7290
  }
7308
- }, tc = "" + new URL("assets/BVHRefitWorker-GkmNJYvb.js", import.meta.url).href, nc = class {
7291
+ }, ic = "" + new URL("assets/BVHRefitWorker-GkmNJYvb.js", import.meta.url).href, ac = class {
7309
7292
  constructor(e = {}) {
7310
7293
  this.config = {
7311
7294
  useWorkers: !0,
@@ -7328,12 +7311,12 @@ var Zs = 128, Qs = class {
7328
7311
  };
7329
7312
  }
7330
7313
  _initProcessors() {
7331
- this.geometryExtractor = new Qs(), this.bvhBuilder = new Es(), this.bvhBuilder.maxLeafSize = this.config.maxLeafSize, this.bvhBuilder.setTreeletConfig({
7314
+ this.geometryExtractor = new tc(), this.bvhBuilder = new ks(), this.bvhBuilder.maxLeafSize = this.config.maxLeafSize, this.bvhBuilder.setTreeletConfig({
7332
7315
  enabled: this.config.enableTreeletOptimization,
7333
7316
  size: this.config.treeletSize,
7334
7317
  passes: this.config.treeletOptimizationPasses,
7335
7318
  minImprovement: this.config.treeletMinImprovement
7336
- }), this.textureCreator = new Ys(), this.emissiveTriangleBuilder = new ec(), this.tlasBuilder = new Us();
7319
+ }), this.textureCreator = new Qs(), this.emissiveTriangleBuilder = new rc(), this.tlasBuilder = new Ks();
7337
7320
  }
7338
7321
  _log(e, t) {
7339
7322
  this.config.verbose && console.log(`[SceneProcessor] ${e}`, t || "");
@@ -7341,7 +7324,7 @@ var Zs = 128, Qs = class {
7341
7324
  async buildBVH(e) {
7342
7325
  if (this.isProcessing) throw Error("Already processing a scene. Call dispose() first.");
7343
7326
  this.isProcessing = !0, this.processingStage = "init";
7344
- let t = new gs(`SceneProcessor (${e.name || "scene"})`);
7327
+ let t = new ys(`SceneProcessor (${e.name || "scene"})`);
7345
7328
  try {
7346
7329
  this._reset(), this._log("Starting scene processing"), this.processingStage = "extraction", t.start("Geometry extraction"), await this._extractGeometry(e), t.end("Geometry extraction"), this.performanceMetrics.geometryExtractionTime = t.getDuration("Geometry extraction"), this.processingStage = "bvh", t.start("BVH construction (worker)"), t.start("Material textures (parallel)");
7347
7330
  let n = !1, r = this._buildBVH().then(() => t.end("BVH construction (worker)")), i = this._createMaterialTextures().then(() => {
@@ -7402,11 +7385,11 @@ var Zs = 128, Qs = class {
7402
7385
  try {
7403
7386
  let t = Z.FLOATS_PER_TRIANGLE, n = this.meshTriangleRanges;
7404
7387
  if (!n || n.length === 0) throw Error("No mesh triangle ranges available for TLAS/BLAS build");
7405
- this.instanceTable = new Ws(), this.instanceTable.allocate(n.length);
7388
+ this.instanceTable = new qs(), this.instanceTable.allocate(n.length);
7406
7389
  let r = n.length, i = this.config.enableTreeletOptimization, a = [], o = [];
7407
7390
  for (let e = 0; e < r; e++) {
7408
7391
  let t = n[e];
7409
- t.count !== 0 && (t.count >= 2e5 && Bs(t.count) ? o.push({
7392
+ t.count !== 0 && (t.count >= 2e5 && Us(t.count) ? o.push({
7410
7393
  m: e,
7411
7394
  range: t
7412
7395
  }) : a.push({
@@ -7432,7 +7415,7 @@ var Zs = 128, Qs = class {
7432
7415
  status: `Building BLAS ${e + o.length}/${c}...`,
7433
7416
  progress: 25 + Math.floor(e / c * 45)
7434
7417
  });
7435
- }), u = o.map(({ m: e, range: n }) => Ls(this.triangleData.slice(n.start * t, (n.start + n.count) * t), this.config.bvhDepth, null, {
7418
+ }), u = o.map(({ m: e, range: n }) => Bs(this.triangleData.slice(n.start * t, (n.start + n.count) * t), this.config.bvhDepth, null, {
7436
7419
  maxLeafSize: this.bvhBuilder.maxLeafSize,
7437
7420
  numBins: this.bvhBuilder.numBins,
7438
7421
  maxBins: this.bvhBuilder.maxBins,
@@ -7538,13 +7521,13 @@ var Zs = 128, Qs = class {
7538
7521
  for (let e = 0; e < i; e++) {
7539
7522
  let e;
7540
7523
  try {
7541
- e = new Worker(Ss, { type: "module" });
7524
+ e = new Worker(Ts, { type: "module" });
7542
7525
  } catch (t) {
7543
7526
  if (t.name !== "SecurityError") {
7544
7527
  l(t);
7545
7528
  return;
7546
7529
  }
7547
- e = await or(Ss);
7530
+ e = await or(Ts);
7548
7531
  }
7549
7532
  e.onmessage = (t) => f(e, t), e.onerror = (e) => {
7550
7533
  u.forEach((e) => e.terminate()), l(e);
@@ -7717,10 +7700,10 @@ var Zs = 128, Qs = class {
7717
7700
  async refitBVH(e, t) {
7718
7701
  if (!this.bvhData || !this.triangleData || !this.originalToBvhMap) throw Error("No BVH data available for refit. Run buildBVH() first.");
7719
7702
  if (!this._refitWorker) try {
7720
- this._refitWorker = new Worker(tc, { type: "module" });
7703
+ this._refitWorker = new Worker(ic, { type: "module" });
7721
7704
  } catch (e) {
7722
7705
  if (e.name !== "SecurityError") throw e;
7723
- this._refitWorker = await or(tc);
7706
+ this._refitWorker = await or(ic);
7724
7707
  }
7725
7708
  if (!this._refitSharedBuffers) {
7726
7709
  let t = new SharedArrayBuffer(this.bvhData.byteLength), n = new SharedArrayBuffer(this.triangleData.byteLength), r = new SharedArrayBuffer(e.byteLength), i = new Float32Array(t), a = new Float32Array(n);
@@ -7753,7 +7736,7 @@ var Zs = 128, Qs = class {
7753
7736
  refitBLASes(e, t, n) {
7754
7737
  if (!this.instanceTable || !this.bvhData || !this.triangleData) throw Error("No TLAS/BLAS data available. Run buildBVH() first.");
7755
7738
  let r = performance.now();
7756
- this._blasRefitter ||= new Ms();
7739
+ this._blasRefitter ||= new Fs();
7757
7740
  for (let r of e) {
7758
7741
  let e = this.instanceTable.entries[r];
7759
7742
  e && (this._updateMeshTrianglePositions(e, t), n && this._patchMeshSmoothNormals(e, n), this._blasRefitter.refitRange(this.bvhData, this.triangleData, e.blasOffset, e.blasNodeCount), this.instanceTable.recomputeAABB(r, this.bvhData, this.triangleData));
@@ -7884,10 +7867,10 @@ var Zs = 128, Qs = class {
7884
7867
  n && n.terminate();
7885
7868
  let r;
7886
7869
  try {
7887
- r = new Worker(Ss, { type: "module" }), i(t, e, r);
7870
+ r = new Worker(Ts, { type: "module" }), i(t, e, r);
7888
7871
  } catch (n) {
7889
7872
  if (n.name !== "SecurityError") throw n;
7890
- or(Ss).then((n) => i(t, e, n));
7873
+ or(Ts).then((n) => i(t, e, n));
7891
7874
  }
7892
7875
  }
7893
7876
  }
@@ -7920,7 +7903,7 @@ var Zs = 128, Qs = class {
7920
7903
  dispose() {
7921
7904
  this._log("Disposing resources"), this._disposeRefitWorker(), this._disposeTextures(), this._reset(), this.textureCreator &&= (this.textureCreator.dispose(), null), this.geometryExtractor = null, this.bvhBuilder = null, this.tlasBuilder = null, this._blasRefitter = null;
7922
7905
  }
7923
- }, rc = class {
7906
+ }, oc = class {
7924
7907
  constructor() {
7925
7908
  this.lightData = {
7926
7909
  directional: [],
@@ -7947,10 +7930,10 @@ var Zs = 128, Qs = class {
7947
7930
  addDirectionalLight(e) {
7948
7931
  if (e.intensity <= 0) return;
7949
7932
  e.updateMatrixWorld();
7950
- let t = e.getWorldPosition(new Nt()), n;
7933
+ let t = e.getWorldPosition(new Pt()), n;
7951
7934
  if (e.target) {
7952
7935
  e.target.updateMatrixWorld();
7953
- let r = e.target.getWorldPosition(new Nt());
7936
+ let r = e.target.getWorldPosition(new Pt());
7954
7937
  n = t.sub(r).normalize();
7955
7938
  } else n = t.normalize();
7956
7939
  let r = this.calculateLightImportance(e, "directional"), i = e.userData.angle || e.angle || 0;
@@ -7972,7 +7955,7 @@ var Zs = 128, Qs = class {
7972
7955
  addRectAreaLight(e) {
7973
7956
  if (e.intensity <= 0) return;
7974
7957
  e.updateMatrixWorld();
7975
- let t = e.getWorldPosition(new Nt()), n = e.getWorldQuaternion(new _t()), r = e.getWorldScale(new Nt()), i = e.width * r.x * .5, a = e.height * r.y * .5, o = new Nt(i, 0, 0).applyQuaternion(n), s = new Nt(0, -a, 0).applyQuaternion(n), c = this.calculateLightImportance(e, "area");
7958
+ let t = e.getWorldPosition(new Pt()), n = e.getWorldQuaternion(new vt()), r = e.getWorldScale(new Pt()), i = e.width * r.x * .5, a = e.height * r.y * .5, o = new Pt(i, 0, 0).applyQuaternion(n), s = new Pt(0, -a, 0).applyQuaternion(n), c = this.calculateLightImportance(e, "area");
7976
7959
  this.areaLightCache.push({
7977
7960
  data: [
7978
7961
  t.x,
@@ -7996,7 +7979,7 @@ var Zs = 128, Qs = class {
7996
7979
  addPointLight(e) {
7997
7980
  if (e.intensity <= 0) return;
7998
7981
  e.updateMatrixWorld();
7999
- let t = e.getWorldPosition(new Nt()), n = this.calculateLightImportance(e, "point");
7982
+ let t = e.getWorldPosition(new Pt()), n = this.calculateLightImportance(e, "point");
8000
7983
  this.pointLightCache.push({
8001
7984
  data: [
8002
7985
  t.x,
@@ -8016,7 +7999,7 @@ var Zs = 128, Qs = class {
8016
7999
  addSpotLight(e) {
8017
8000
  if (e.intensity <= 0) return;
8018
8001
  e.updateMatrixWorld();
8019
- let t = e.getWorldPosition(new Nt()), n = (e.target ? e.target.getWorldPosition(new Nt()) : new Nt(0, 0, -1)).sub(t).normalize(), r = this.calculateLightImportance(e, "spot");
8002
+ let t = e.getWorldPosition(new Pt()), n = (e.target ? e.target.getWorldPosition(new Pt()) : new Pt(0, 0, -1)).sub(t).normalize(), r = this.calculateLightImportance(e, "spot");
8020
8003
  this.spotLightCache.push({
8021
8004
  data: [
8022
8005
  t.x,
@@ -8073,7 +8056,7 @@ var Zs = 128, Qs = class {
8073
8056
  }))
8074
8057
  };
8075
8058
  }
8076
- }, ic = {
8059
+ }, sc = {
8077
8060
  stbnScalarAtlas: "https://assets.rayzee.atulmourya.com/noise/stbn_scalar_atlas.png",
8078
8061
  stbnVec2Atlas: "https://assets.rayzee.atulmourya.com/noise/stbn_vec2_atlas.png",
8079
8062
  ortRuntimeUrl: "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/ort.webgpu.bundle.min.mjs",
@@ -8084,27 +8067,27 @@ var Zs = 128, Qs = class {
8084
8067
  upscalerModelBaseUrl: "https://huggingface.co/notaneimu/onnx-image-models/resolve/main/",
8085
8068
  cacheNamespace: "rayzee"
8086
8069
  };
8087
- function ac(e) {
8088
- e && Object.assign(ic, e);
8070
+ function cc(e) {
8071
+ e && Object.assign(sc, e);
8089
8072
  }
8090
- function oc() {
8091
- return { ...ic };
8073
+ function lc() {
8074
+ return { ...sc };
8092
8075
  }
8093
8076
  //#endregion
8094
8077
  //#region src/Stages/PathTracer.js
8095
- var sc = 4, cc = class extends Sn {
8078
+ var uc = 4, dc = class extends Sn {
8096
8079
  constructor(e, t, n, r = {}) {
8097
8080
  super("PathTracer", {
8098
8081
  ...r,
8099
8082
  executionMode: xn.ALWAYS
8100
8083
  });
8101
8084
  let i = r.width || 1920, a = r.height || 1080;
8102
- this.camera = n, this.width = i, this.height = a, this.renderer = e, this.scene = t, this.tileManager = new Cn(i, a, X.tiles), this.sdfs = new nc(), this.lightSerializer = new rc(), this.accumulationEnabled = !0, this.isComplete = !1, this.cameras = [], this.performanceMonitor = Ln(), this.completionThreshold = 0, this.renderLimitMode = "frames", this._initDataTextures(), this.storageTextures = new zn(0, 0), this.uniforms = new $n(i, a), this._defineUniformGetters(), this.materialData = new ar(this.sdfs), this.materialData.callbacks.onReset = () => this.reset(), this.materialData.callbacks.getTriangleData = () => ({
8085
+ this.camera = n, this.width = i, this.height = a, this.renderer = e, this.scene = t, this.tileManager = new Cn(i, a, X.tiles), this.sdfs = new ac(), this.lightSerializer = new oc(), this.accumulationEnabled = !0, this.isComplete = !1, this.cameras = [], this.performanceMonitor = Ln(), this.completionThreshold = 0, this.renderLimitMode = "frames", this._initDataTextures(), this.storageTextures = new zn(0, 0), this.uniforms = new $n(i, a), this._defineUniformGetters(), this.materialData = new ar(this.sdfs), this.materialData.callbacks.onReset = () => this.reset(), this.materialData.callbacks.getTriangleData = () => ({
8103
8086
  array: this.triangleStorageAttr?.array,
8104
8087
  count: this.triangleCount
8105
8088
  }), this.materialData.callbacks.onTriangleDataChanged = () => {
8106
8089
  this.triangleStorageAttr && (this.triangleStorageAttr.needsUpdate = !0);
8107
- }, this.environment = new Ir(this.scene, this.uniforms), this.environment.callbacks.onReset = () => this.reset(), this.environment.callbacks.getSceneTextureNodes = () => this.shaderBuilder.getSceneTextureNodes(), this.shaderBuilder = new vs(), this._initRenderingState(), this.setupBlueNoise(), this.tempVector2 = new Mt(), this.lastCameraMatrix = new rt(), this.lastProjectionMatrix = new rt(), this.lastRenderMode = -1, this.tileCompletionFrame = 0, this.renderModeChangeTimeout = null, this.renderModeChangeDelay = 50, this.pendingRenderMode = null, this.adaptiveSamplingFrameToggle = !1, this.lastInteractionModeState = !1, this.cameraChanged = !1, this.tileChanged = !1, this.updateCompletionThreshold();
8090
+ }, this.environment = new Ir(this.scene, this.uniforms), this.environment.callbacks.onReset = () => this.reset(), this.environment.callbacks.getSceneTextureNodes = () => this.shaderBuilder.getSceneTextureNodes(), this.shaderBuilder = new xs(), this._initRenderingState(), this.setupBlueNoise(), this.tempVector2 = new Nt(), this.lastCameraMatrix = new rt(), this.lastProjectionMatrix = new rt(), this.lastRenderMode = -1, this.tileCompletionFrame = 0, this.renderModeChangeTimeout = null, this.renderModeChangeDelay = 50, this.pendingRenderMode = null, this.adaptiveSamplingFrameToggle = !1, this.lastInteractionModeState = !1, this.cameraChanged = !1, this.tileChanged = !1, this.updateCompletionThreshold();
8108
8091
  }
8109
8092
  _initDataTextures() {
8110
8093
  this.triangleStorageAttr = null, this.triangleStorageNode = null, this.triangleCount = 0, this.bvhStorageAttr = null, this.bvhStorageNode = null, this.bvhNodeCount = 0, this.directionalLightsData = null, this.pointLightsData = null, this.spotLightsData = null, this.areaLightsData = null, this.stbnScalarTexture = null, this.stbnVec2Texture = null, this.lightStorageAttr = new o(new Float32Array(16), 4), this.lightStorageNode = ve(this.lightStorageAttr, "vec4", 1).toReadOnly(), this._lbvhDataCache = null, this._emissiveDataCache = null, this._instanceTable = null, this.adaptiveSamplingTexture = null, this.spheres = [];
@@ -8199,13 +8182,13 @@ var sc = 4, cc = class extends Sn {
8199
8182
  });
8200
8183
  }
8201
8184
  setupBlueNoise() {
8202
- let e = new Ot();
8185
+ let e = new kt();
8203
8186
  e.setCrossOrigin("anonymous");
8204
- let t = (e) => (e.minFilter = J, e.magFilter = J, e.wrapS = St, e.wrapT = St, e.generateMipmaps = !1, e), { stbnScalarAtlas: n, stbnVec2Atlas: r } = oc();
8187
+ let t = (e) => (e.minFilter = ct, e.magFilter = ct, e.wrapS = Ct, e.wrapT = Ct, e.generateMipmaps = !1, e), { stbnScalarAtlas: n, stbnVec2Atlas: r } = lc();
8205
8188
  e.load(n, (e) => {
8206
- this.stbnScalarTexture = t(e), nn.value = e, console.log(`PathTracer: STBN scalar atlas loaded ${e.image.width}x${e.image.height}`);
8189
+ this.stbnScalarTexture = t(e), rn.value = e, console.log(`PathTracer: STBN scalar atlas loaded ${e.image.width}x${e.image.height}`);
8207
8190
  }), e.load(r, (e) => {
8208
- this.stbnVec2Texture = t(e), rn.value = e, console.log(`PathTracer: STBN vec2 atlas loaded ${e.image.width}x${e.image.height}`);
8191
+ this.stbnVec2Texture = t(e), an.value = e, console.log(`PathTracer: STBN vec2 atlas loaded ${e.image.width}x${e.image.height}`);
8209
8192
  });
8210
8193
  }
8211
8194
  setupEventListeners() {
@@ -8287,7 +8270,7 @@ var sc = 4, cc = class extends Sn {
8287
8270
  setBVHData(e) {
8288
8271
  if (!e) return;
8289
8272
  let t = e.length / 4;
8290
- this.bvhStorageNode ? (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode.value = this.bvhStorageAttr, this.bvhStorageNode.bufferCount = t) : (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode = ve(this.bvhStorageAttr, "vec4", t).toReadOnly()), this.bvhNodeCount = Math.floor(t / sc), console.log(`PathTracer: ${this.bvhNodeCount} BVH nodes (storage buffer)`);
8273
+ this.bvhStorageNode ? (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode.value = this.bvhStorageAttr, this.bvhStorageNode.bufferCount = t) : (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode = ve(this.bvhStorageAttr, "vec4", t).toReadOnly()), this.bvhNodeCount = Math.floor(t / uc), console.log(`PathTracer: ${this.bvhNodeCount} BVH nodes (storage buffer)`);
8291
8274
  }
8292
8275
  setInstanceTable(e) {
8293
8276
  this._instanceTable = e;
@@ -8452,7 +8435,7 @@ var sc = 4, cc = class extends Sn {
8452
8435
  this.uniforms.set(e, t);
8453
8436
  }
8454
8437
  setBlueNoiseTexture(e) {
8455
- this.stbnScalarTexture = e, e && (nn.value = e);
8438
+ this.stbnScalarTexture = e, e && (rn.value = e);
8456
8439
  }
8457
8440
  _rebuildLightBuffer() {
8458
8441
  let e = this._lbvhDataCache, t = this._emissiveDataCache, n = e ? e.length : 0, r = t ? t.length : 0, i = Math.max(n + r, 4), a = new Float32Array(i);
@@ -8486,18 +8469,18 @@ var sc = 4, cc = class extends Sn {
8486
8469
  dispose() {
8487
8470
  this.renderModeChangeTimeout &&= (clearTimeout(this.renderModeChangeTimeout), null), this.tileManager?.dispose(), this.cameraOptimizer?.dispose(), this.materialData?.dispose(), this.environment?.dispose(), this.shaderBuilder?.dispose(), this.uniforms?.dispose(), this.storageTextures?.dispose(), this.stbnScalarTexture?.dispose(), this.stbnVec2Texture?.dispose(), this.placeholderTexture?.dispose(), this.triangleStorageAttr = null, this.triangleStorageNode = null, this.bvhStorageAttr = null, this.bvhStorageNode = null, this.placeholderTexture = null, this.isReady = !1;
8488
8471
  }
8489
- }, lc = class extends Sn {
8472
+ }, fc = class extends Sn {
8490
8473
  constructor(e, t = {}) {
8491
8474
  super("NormalDepth", {
8492
8475
  ...t,
8493
8476
  executionMode: xn.ALWAYS
8494
8477
  }), this.renderer = e, this.pathTracer = t.pathTracer, this._dirty = !0, this.cameraWorldMatrix = H(new rt(), "mat4"), this.cameraProjectionMatrixInverse = H(new rt(), "mat4"), this.resolutionWidth = H(t.width || 1), this.resolutionHeight = H(t.height || 1);
8495
8478
  let n = t.width || 1, r = t.height || 1;
8496
- this._outputStorageTex = new s(n, r), this._outputStorageTex.type = Ye, this._outputStorageTex.format = vt, this._outputStorageTex.minFilter = J, this._outputStorageTex.magFilter = J, this.renderTarget = new i(n, r, {
8479
+ this._outputStorageTex = new s(n, r), this._outputStorageTex.type = Ye, this._outputStorageTex.format = yt, this._outputStorageTex.minFilter = ct, this._outputStorageTex.magFilter = ct, this.renderTarget = new i(n, r, {
8497
8480
  type: Ye,
8498
- format: vt,
8499
- minFilter: J,
8500
- magFilter: J,
8481
+ format: yt,
8482
+ minFilter: ct,
8483
+ magFilter: ct,
8501
8484
  depthBuffer: !1,
8502
8485
  stencilBuffer: !1
8503
8486
  }), 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;
@@ -8564,19 +8547,19 @@ var sc = 4, cc = class extends Sn {
8564
8547
  dispose() {
8565
8548
  this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this.renderTarget?.dispose();
8566
8549
  }
8567
- }, uc = class extends Sn {
8550
+ }, pc = class extends Sn {
8568
8551
  constructor(e, t, n = {}) {
8569
8552
  super("MotionVector", {
8570
8553
  ...n,
8571
8554
  executionMode: xn.ALWAYS
8572
8555
  }), this.renderer = e, this.camera = t, this.pathTracer = n.pathTracer || null;
8573
8556
  let r = n.width || 1, a = n.height || 1;
8574
- this.prevViewProjectionMatrix = new rt(), this.currentViewProjectionMatrix = new rt(), this.matricesInitialized = !1, this.isFirstFrame = !0, this.frameCount = 0, this.cameraWorldMatrix = H(new rt(), "mat4"), this.cameraProjectionMatrixInverse = H(new rt(), "mat4"), this.prevVP = H(new rt(), "mat4"), this.isFirstFrameU = H(1), this.deltaTime = H(1 / 60), this.velocityScale = H(1), this.resolutionWidth = H(r), this.resolutionHeight = H(a), this._normalDepthTexNode = new c(), this._screenSpaceStorageTex = new s(r, a), this._screenSpaceStorageTex.type = Ye, this._screenSpaceStorageTex.format = vt, this._screenSpaceStorageTex.minFilter = J, this._screenSpaceStorageTex.magFilter = J, this._worldSpaceStorageTex = new s(r, a), this._worldSpaceStorageTex.type = Ye, this._worldSpaceStorageTex.format = vt, this._worldSpaceStorageTex.minFilter = J, this._worldSpaceStorageTex.magFilter = J;
8557
+ this.prevViewProjectionMatrix = new rt(), this.currentViewProjectionMatrix = new rt(), this.matricesInitialized = !1, this.isFirstFrame = !0, this.frameCount = 0, this.cameraWorldMatrix = H(new rt(), "mat4"), this.cameraProjectionMatrixInverse = H(new rt(), "mat4"), this.prevVP = H(new rt(), "mat4"), this.isFirstFrameU = H(1), this.deltaTime = H(1 / 60), this.velocityScale = H(1), this.resolutionWidth = H(r), this.resolutionHeight = H(a), this._normalDepthTexNode = new c(), this._screenSpaceStorageTex = new s(r, a), this._screenSpaceStorageTex.type = Ye, this._screenSpaceStorageTex.format = yt, this._screenSpaceStorageTex.minFilter = ct, this._screenSpaceStorageTex.magFilter = ct, this._worldSpaceStorageTex = new s(r, a), this._worldSpaceStorageTex.type = Ye, this._worldSpaceStorageTex.format = yt, this._worldSpaceStorageTex.minFilter = ct, this._worldSpaceStorageTex.magFilter = ct;
8575
8558
  let o = {
8576
8559
  type: Ye,
8577
- format: vt,
8578
- minFilter: J,
8579
- magFilter: J,
8560
+ format: yt,
8561
+ minFilter: ct,
8562
+ magFilter: ct,
8580
8563
  depthBuffer: !1,
8581
8564
  stencilBuffer: !1
8582
8565
  };
@@ -8673,18 +8656,18 @@ var sc = 4, cc = class extends Sn {
8673
8656
  dispose() {
8674
8657
  this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose(), this.screenSpaceTarget?.dispose(), this.worldSpaceTarget?.dispose(), this._normalDepthTexNode?.dispose();
8675
8658
  }
8676
- }, dc = class extends Sn {
8659
+ }, mc = class extends Sn {
8677
8660
  constructor(e, t = {}) {
8678
8661
  super("ASVGF", {
8679
8662
  ...t,
8680
8663
  executionMode: xn.PER_CYCLE
8681
8664
  }), this.renderer = e, this.temporalAlpha = H(t.temporalAlpha ?? .1), this.phiColor = H(t.phiColor ?? 10), this.maxAccumFrames = H(t.maxAccumFrames ?? 32), this.varianceClip = H(t.varianceClip ?? 1), this.resW = H(t.width || 1), this.resH = H(t.height || 1), this.temporalEnabled = !0, this.temporalEnabledU = H(1), this._colorTexNode = new c(), this._motionTexNode = new c(), this._readTemporalTexNode = new c();
8682
8665
  let n = t.width || 1, r = t.height || 1;
8683
- this._temporalTexA = new s(n, r), this._temporalTexA.type = Ye, this._temporalTexA.format = vt, this._temporalTexA.minFilter = q, this._temporalTexA.magFilter = q, this._temporalTexB = new s(n, r), this._temporalTexB.type = Ye, this._temporalTexB.format = vt, this._temporalTexB.minFilter = q, this._temporalTexB.magFilter = q, this._gradientStorageTex = new s(n, r), this._gradientStorageTex.type = Ye, this._gradientStorageTex.format = vt, this._gradientStorageTex.minFilter = q, this._gradientStorageTex.magFilter = q, this.currentMoments = 0, this._compiled = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildGradientCompute(), this._buildTemporalCompute(), this.showHeatmap = !1, this.debugMode = H(0, "int"), this._heatmapStorageTex = new s(n, r), this._heatmapStorageTex.type = qe, this._heatmapStorageTex.format = vt, this._heatmapStorageTex.minFilter = J, this._heatmapStorageTex.magFilter = J, this.heatmapTarget = new i(n, r, {
8666
+ this._temporalTexA = new s(n, r), this._temporalTexA.type = Ye, this._temporalTexA.format = yt, this._temporalTexA.minFilter = q, this._temporalTexA.magFilter = q, this._temporalTexB = new s(n, r), this._temporalTexB.type = Ye, this._temporalTexB.format = yt, this._temporalTexB.minFilter = q, this._temporalTexB.magFilter = q, this._gradientStorageTex = new s(n, r), this._gradientStorageTex.type = Ye, this._gradientStorageTex.format = yt, this._gradientStorageTex.minFilter = q, this._gradientStorageTex.magFilter = q, this.currentMoments = 0, this._compiled = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildGradientCompute(), this._buildTemporalCompute(), this.showHeatmap = !1, this.debugMode = H(0, "int"), this._heatmapStorageTex = new s(n, r), this._heatmapStorageTex.type = qe, this._heatmapStorageTex.format = yt, this._heatmapStorageTex.minFilter = ct, this._heatmapStorageTex.magFilter = ct, this.heatmapTarget = new i(n, r, {
8684
8667
  type: qe,
8685
- format: vt,
8686
- minFilter: J,
8687
- magFilter: J,
8668
+ format: yt,
8669
+ minFilter: ct,
8670
+ magFilter: ct,
8688
8671
  depthBuffer: !1,
8689
8672
  stencilBuffer: !1
8690
8673
  }), this._heatmapRawColorTexNode = new c(), this._heatmapColorTexNode = new c(), this._heatmapTemporalTexNode = new c(), this._heatmapNDTexNode = new c(), this._heatmapMotionTexNode = new c(), this._heatmapGradientTexNode = new c(), this._buildHeatmapCompute(), this.frameCount = 0;
@@ -8847,14 +8830,14 @@ var sc = 4, cc = class extends Sn {
8847
8830
  dispose() {
8848
8831
  this._gradientNode?.dispose(), this._temporalNodeA?.dispose(), this._temporalNodeB?.dispose(), this._temporalTexA?.dispose(), this._temporalTexB?.dispose(), this._gradientStorageTex?.dispose(), this._heatmapComputeNode?.dispose(), this._heatmapStorageTex?.dispose(), this.heatmapTarget?.dispose(), this._colorTexNode?.dispose(), this._motionTexNode?.dispose(), this._readTemporalTexNode?.dispose(), this._heatmapRawColorTexNode?.dispose(), this._heatmapColorTexNode?.dispose(), this._heatmapTemporalTexNode?.dispose(), this._heatmapNDTexNode?.dispose(), this._heatmapMotionTexNode?.dispose(), this._heatmapGradientTexNode?.dispose();
8849
8832
  }
8850
- }, fc = /* @__PURE__ */ K("\n fn temporalAccumulate(\n lum: f32,\n prevMean: f32,\n prevMeanSq: f32,\n alpha: f32,\n spatialVariance: f32,\n varianceBoost: f32\n ) -> vec4f {\n\n let newMean = prevMean + ( lum - prevMean ) * alpha;\n let newMeanSq = prevMeanSq + ( lum * lum - prevMeanSq ) * alpha;\n let temporalVariance = max( newMeanSq - newMean * newMean, 0.0 );\n\n return vec4f(\n newMean,\n newMeanSq,\n temporalVariance * varianceBoost,\n spatialVariance * varianceBoost\n );\n\n }\n"), pc = class extends Sn {
8833
+ }, hc = /* @__PURE__ */ K("\n fn temporalAccumulate(\n lum: f32,\n prevMean: f32,\n prevMeanSq: f32,\n alpha: f32,\n spatialVariance: f32,\n varianceBoost: f32\n ) -> vec4f {\n\n let newMean = prevMean + ( lum - prevMean ) * alpha;\n let newMeanSq = prevMeanSq + ( lum * lum - prevMeanSq ) * alpha;\n let temporalVariance = max( newMeanSq - newMean * newMean, 0.0 );\n\n return vec4f(\n newMean,\n newMeanSq,\n temporalVariance * varianceBoost,\n spatialVariance * varianceBoost\n );\n\n }\n"), gc = class extends Sn {
8851
8834
  constructor(e, t = {}) {
8852
8835
  super("VarianceEstimation", {
8853
8836
  ...t,
8854
8837
  executionMode: xn.ALWAYS
8855
8838
  }), this.renderer = e, this.inputTextureName = t.inputTextureName || "pathtracer:color", this.varianceBoost = H(t.varianceBoost ?? 1), this.temporalAlpha = H(t.temporalAlpha ?? .1), this.resW = H(t.width || 1), this.resH = H(t.height || 1), this._colorTexNode = new c();
8856
8839
  let n = t.width || 1, r = t.height || 1;
8857
- this._storageTexA = new s(n, r), this._storageTexA.type = qe, this._storageTexA.format = vt, this._storageTexA.minFilter = q, this._storageTexA.magFilter = q, this._storageTexB = new s(n, r), this._storageTexB.type = qe, this._storageTexB.format = vt, this._storageTexB.minFilter = q, this._storageTexB.magFilter = q, this.currentMoments = 0, this._compiled = !1, this._needsWarmReset = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildCompute();
8840
+ this._storageTexA = new s(n, r), this._storageTexA.type = qe, this._storageTexA.format = yt, this._storageTexA.minFilter = q, this._storageTexA.magFilter = q, this._storageTexB = new s(n, r), this._storageTexB.type = qe, this._storageTexB.format = yt, this._storageTexB.minFilter = q, this._storageTexB.magFilter = q, this.currentMoments = 0, this._compiled = !1, this._needsWarmReset = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildCompute();
8858
8841
  }
8859
8842
  setupEventListeners() {
8860
8843
  this.on("pathtracer:viewpointChanged", () => this.reset());
@@ -8879,7 +8862,7 @@ var sc = 4, cc = class extends Sn {
8879
8862
  }
8880
8863
  n.divAssign(9), a.divAssign(9);
8881
8864
  let o = I(a.sub(n.mul(n)), M(0)), u = s.element(l.add(1).mul(10).add(c.add(1))), d = B(t, P(_, v));
8882
- xe(e, we(V(_), V(v)), fc(u, d.x, d.y, r, o, i)).toWriteOnly();
8865
+ xe(e, we(V(_), V(v)), hc(u, d.x, d.y, r, o, i)).toWriteOnly();
8883
8866
  });
8884
8867
  })().compute([
8885
8868
  this._dispatchX,
@@ -8922,14 +8905,14 @@ var sc = 4, cc = class extends Sn {
8922
8905
  dispose() {
8923
8906
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._colorTexNode?.dispose(), this._readTexNodeA?.dispose(), this._readTexNodeB?.dispose();
8924
8907
  }
8925
- }, mc = /* @__PURE__ */ K("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n phiLum: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) * phiLum );\n // clamp dot to [0,1] not just max(., 0): miss-ray normals decode to\n // non-unit (-1,-1,-1) with dot=3, which would saturate pow to +inf\n // and poison output via inf*0 = NaN. See project_tsl_pitfalls memory.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), phiNorm );\n let depW = exp( -abs( centerDepth - sDepth ) / max( 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 colW = exp( -maxDiff * phiCol );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), hc = class extends Sn {
8908
+ }, _c = /* @__PURE__ */ K("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n phiLum: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) * phiLum );\n // clamp dot to [0,1] not just max(., 0): miss-ray normals decode to\n // non-unit (-1,-1,-1) with dot=3, which would saturate pow to +inf\n // and poison output via inf*0 = NaN. See project_tsl_pitfalls memory.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), phiNorm );\n let depW = exp( -abs( centerDepth - sDepth ) / max( 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 colW = exp( -maxDiff * phiCol );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), vc = class extends Sn {
8926
8909
  constructor(e, t = {}) {
8927
8910
  super("BilateralFiltering", {
8928
8911
  ...t,
8929
8912
  executionMode: xn.ALWAYS
8930
8913
  }), this.renderer = e, this.inputTextureName = t.inputTextureName || "asvgf:output", this.normalDepthTextureName = t.normalDepthTextureName || "pathtracer:normalDepth", this.iterations = t.iterations ?? 4, this.phiColor = H(t.phiColor ?? 10), this.phiNormal = H(t.phiNormal ?? 128), this.phiDepth = H(t.phiDepth ?? 1), this.phiLuminance = H(t.phiLuminance ?? 4), this.stepSizeU = H(1, "int"), this.resW = H(t.width || 1), this.resH = H(t.height || 1), this._readTexNode = new c(), this._normalDepthTexNode = new c();
8931
8914
  let n = t.width || 1, r = t.height || 1;
8932
- this._storageTexA = new s(n, r), this._storageTexA.type = Ye, this._storageTexA.format = vt, this._storageTexA.minFilter = q, this._storageTexA.magFilter = q, this._storageTexB = new s(n, r), this._storageTexB.type = Ye, this._storageTexB.format = vt, this._storageTexB.minFilter = q, this._storageTexB.magFilter = q, this._compiled = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildCompute();
8915
+ this._storageTexA = new s(n, r), this._storageTexA.type = Ye, this._storageTexA.format = yt, this._storageTexA.minFilter = q, this._storageTexA.magFilter = q, this._storageTexB = new s(n, r), this._storageTexB.type = Ye, this._storageTexB.format = yt, this._storageTexB.minFilter = q, this._storageTexB.magFilter = q, this._compiled = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildCompute();
8933
8916
  }
8934
8917
  _buildCompute() {
8935
8918
  this._computeNodeA = this._buildComputeForDirection(this._storageTexA), this._computeNodeB = this._buildComputeForDirection(this._storageTexB);
@@ -8967,7 +8950,7 @@ var sc = 4, cc = class extends Sn {
8967
8950
  m(d.lessThan(N(c)).and(f.lessThan(N(l))), () => {
8968
8951
  let p = P(d, f), m = B(t, p).xyz, h = B(n, p), g = h.xyz.mul(2).sub(1), _ = h.w, v = di(m), y = W(0).toVar(), b = M(0).toVar();
8969
8952
  for (let e = 0; e < 5; e++) for (let p = 0; p < 5; p++) {
8970
- let h = p - 2, x = e - 2, S = u[e * 5 + p], C = d.add(s.mul(h)).clamp(N(0), N(c).sub(1)), w = f.add(s.mul(x)).clamp(N(0), N(l).sub(1)), T = B(t, P(C, w)).xyz, E = B(n, P(C, w)), D = E.xyz.mul(2).sub(1), O = E.w, k = mc(v, di(T), g, D, _, O, m, T, M(S), o, i, a, r);
8953
+ let h = p - 2, x = e - 2, S = u[e * 5 + p], C = d.add(s.mul(h)).clamp(N(0), N(c).sub(1)), w = f.add(s.mul(x)).clamp(N(0), N(l).sub(1)), T = B(t, P(C, w)).xyz, E = B(n, P(C, w)), D = E.xyz.mul(2).sub(1), O = E.w, k = _c(v, di(T), g, D, _, O, m, T, M(S), o, i, a, r);
8971
8954
  y.addAssign(T.mul(k)), b.addAssign(k);
8972
8955
  }
8973
8956
  let x = y.div(I(b, M(1e-4)));
@@ -9012,18 +8995,18 @@ var sc = 4, cc = class extends Sn {
9012
8995
  dispose() {
9013
8996
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._readTexNode?.dispose(), this._normalDepthTexNode?.dispose();
9014
8997
  }
9015
- }, gc = /* @__PURE__ */ K("\n fn computeSamplingGuidance(\n temporalVariance: f32,\n spatialVariance: f32,\n meanLuminance: f32,\n threshold: f32,\n frame: i32,\n minFrames: i32,\n convThreshold: f32,\n sensitivity: f32,\n convSpeedScale: f32\n ) -> vec4f {\n\n // The path tracer accumulates via alpha = 1/(frame+1), so temporal variance\n // of the accumulated output shrinks as ~sigma²/(frame+1)². Scale by (frame+1)\n // to get accumulated image quality ~sigma²/N — decreases as image converges.\n let frameScale = f32( frame + 1 );\n let effectiveVariance = temporalVariance * frameScale;\n\n // Normalize by luminance² — converts absolute variance to relative (CV²).\n // Floor of 0.01 prevents noise amplification for near-black pixels\n // (linear luminance < 0.1 → below perceptual visibility threshold).\n let normFactor = max( meanLuminance * meanLuminance, 0.01 );\n let normalizedVariance = effectiveVariance / normFactor;\n\n let varianceRatio = clamp( normalizedVariance / threshold, 0.0, 1.0 );\n\n // Apply sensitivity — higher values assign more samples to noisy pixels\n var normalizedSamples = clamp( varianceRatio * sensitivity, 0.0, 1.0 );\n\n // Small spatial boost for noisy neighbourhoods (un-scaled — provides\n // a minor secondary signal that naturally diminishes as image converges)\n let spatialBoost = clamp( spatialVariance / ( threshold * 4.0 ), 0.0, 0.2 );\n normalizedSamples = clamp( normalizedSamples + spatialBoost, 0.0, 1.0 );\n\n // Warm-up: variance estimates need a few frames to stabilise\n if ( frame < minFrames ) {\n\n let warmupFactor = f32( frame ) / f32( minFrames );\n normalizedSamples = mix( 1.0, normalizedSamples, warmupFactor * warmupFactor );\n\n }\n\n // Convergence: mark pixel only when per-frame noise is truly negligible.\n // convSpeedScale controls aggressiveness: higher = easier to converge\n // (scales the threshold up, so more pixels qualify as converged).\n let scaledConvThreshold = convThreshold * convSpeedScale;\n var converged = 0.0;\n if ( normalizedVariance < scaledConvThreshold && frame > minFrames ) {\n\n converged = 1.0;\n\n }\n\n return vec4f(\n normalizedSamples,\n varianceRatio,\n converged,\n 1.0\n );\n\n }\n"), _c = /* @__PURE__ */ K("\n fn heatmapGradient( t: f32, normalizedVariance: f32, converged: f32 ) -> vec4f {\n\n let r = clamp( ( t - 0.5 ) * 4.0, 0.0, 1.0 );\n let g = clamp( t * 4.0, 0.0, 1.0 ) - clamp( ( t - 0.75 ) * 4.0, 0.0, 1.0 );\n let b = 1.0 - clamp( ( t - 0.25 ) * 4.0, 0.0, 1.0 );\n\n var color = vec3f( r, g, b );\n\n // Convergence: desaturate converged pixels\n if ( converged > 0.5 ) {\n\n let gray = color.x * 0.299 + color.y * 0.587 + color.z * 0.114;\n color = mix( color, vec3f( gray ), 0.6 );\n\n }\n\n // Brightness modulation\n color *= 0.7 + normalizedVariance * 0.3;\n\n return vec4f( color, 1.0 );\n\n }\n"), vc = class extends Sn {
8998
+ }, yc = /* @__PURE__ */ K("\n fn computeSamplingGuidance(\n temporalVariance: f32,\n spatialVariance: f32,\n meanLuminance: f32,\n threshold: f32,\n frame: i32,\n minFrames: i32,\n convThreshold: f32,\n sensitivity: f32,\n convSpeedScale: f32\n ) -> vec4f {\n\n // The path tracer accumulates via alpha = 1/(frame+1), so temporal variance\n // of the accumulated output shrinks as ~sigma²/(frame+1)². Scale by (frame+1)\n // to get accumulated image quality ~sigma²/N — decreases as image converges.\n let frameScale = f32( frame + 1 );\n let effectiveVariance = temporalVariance * frameScale;\n\n // Normalize by luminance² — converts absolute variance to relative (CV²).\n // Floor of 0.01 prevents noise amplification for near-black pixels\n // (linear luminance < 0.1 → below perceptual visibility threshold).\n let normFactor = max( meanLuminance * meanLuminance, 0.01 );\n let normalizedVariance = effectiveVariance / normFactor;\n\n let varianceRatio = clamp( normalizedVariance / threshold, 0.0, 1.0 );\n\n // Apply sensitivity — higher values assign more samples to noisy pixels\n var normalizedSamples = clamp( varianceRatio * sensitivity, 0.0, 1.0 );\n\n // Small spatial boost for noisy neighbourhoods (un-scaled — provides\n // a minor secondary signal that naturally diminishes as image converges)\n let spatialBoost = clamp( spatialVariance / ( threshold * 4.0 ), 0.0, 0.2 );\n normalizedSamples = clamp( normalizedSamples + spatialBoost, 0.0, 1.0 );\n\n // Warm-up: variance estimates need a few frames to stabilise\n if ( frame < minFrames ) {\n\n let warmupFactor = f32( frame ) / f32( minFrames );\n normalizedSamples = mix( 1.0, normalizedSamples, warmupFactor * warmupFactor );\n\n }\n\n // Convergence: mark pixel only when per-frame noise is truly negligible.\n // convSpeedScale controls aggressiveness: higher = easier to converge\n // (scales the threshold up, so more pixels qualify as converged).\n let scaledConvThreshold = convThreshold * convSpeedScale;\n var converged = 0.0;\n if ( normalizedVariance < scaledConvThreshold && frame > minFrames ) {\n\n converged = 1.0;\n\n }\n\n return vec4f(\n normalizedSamples,\n varianceRatio,\n converged,\n 1.0\n );\n\n }\n"), bc = /* @__PURE__ */ K("\n fn heatmapGradient( t: f32, normalizedVariance: f32, converged: f32 ) -> vec4f {\n\n let r = clamp( ( t - 0.5 ) * 4.0, 0.0, 1.0 );\n let g = clamp( t * 4.0, 0.0, 1.0 ) - clamp( ( t - 0.75 ) * 4.0, 0.0, 1.0 );\n let b = 1.0 - clamp( ( t - 0.25 ) * 4.0, 0.0, 1.0 );\n\n var color = vec3f( r, g, b );\n\n // Convergence: desaturate converged pixels\n if ( converged > 0.5 ) {\n\n let gray = color.x * 0.299 + color.y * 0.587 + color.z * 0.114;\n color = mix( color, vec3f( gray ), 0.6 );\n\n }\n\n // Brightness modulation\n color *= 0.7 + normalizedVariance * 0.3;\n\n return vec4f( color, 1.0 );\n\n }\n"), xc = class extends Sn {
9016
8999
  constructor(e, t = {}) {
9017
9000
  super("AdaptiveSampling", {
9018
9001
  ...t,
9019
9002
  executionMode: xn.PER_CYCLE
9020
9003
  }), this.renderer = e, this.frameNumber = 0, this.delayByFrames = t.delayByFrames ?? 2, this.showAdaptiveSamplingHelper = !1, this.adaptiveSamplingMax = H(t.adaptiveSamplingMax ?? X.adaptiveSamplingMax ?? 32, "int"), this.varianceThreshold = H(t.varianceThreshold ?? X.adaptiveSamplingVarianceThreshold ?? .01), this.materialBias = H(t.materialBias ?? X.adaptiveSamplingMaterialBias ?? 1.2), this.edgeBias = H(t.edgeBias ?? X.adaptiveSamplingEdgeBias ?? 1.5), this.convergenceSpeed = H(t.convergenceSpeed ?? X.adaptiveSamplingConvergenceSpeed ?? 2), this.frameNumberUniform = H(0, "int"), this.resolutionWidth = H(t.width || 1024), this.resolutionHeight = H(t.height || 1024), this.minConvergenceFrames = H(10), this.convergenceThreshold = H(.01);
9021
9004
  let n = t.width || 1, r = t.height || 1;
9022
- this._outputStorageTex = new s(n, r), this._outputStorageTex.type = Ye, this._outputStorageTex.format = vt, this._outputStorageTex.minFilter = q, this._outputStorageTex.magFilter = q, this._heatmapStorageTex = new s(n, r), this._heatmapStorageTex.type = qe, this._heatmapStorageTex.format = vt, this._heatmapStorageTex.minFilter = J, this._heatmapStorageTex.magFilter = J, this.heatmapTarget = new i(n, r, {
9023
- format: vt,
9005
+ this._outputStorageTex = new s(n, r), this._outputStorageTex.type = Ye, this._outputStorageTex.format = yt, this._outputStorageTex.minFilter = q, this._outputStorageTex.magFilter = q, this._heatmapStorageTex = new s(n, r), this._heatmapStorageTex.type = qe, this._heatmapStorageTex.format = yt, this._heatmapStorageTex.minFilter = ct, this._heatmapStorageTex.magFilter = ct, this.heatmapTarget = new i(n, r, {
9006
+ format: yt,
9024
9007
  type: qe,
9025
- minFilter: J,
9026
- magFilter: J,
9008
+ minFilter: ct,
9009
+ magFilter: ct,
9027
9010
  depthBuffer: !1,
9028
9011
  stencilBuffer: !1
9029
9012
  }), this._dispatchX = Math.ceil(n / 16), this._dispatchY = Math.ceil(r / 16), this._varianceTexNode = new c(), this._buildCompute(), this._buildHeatmapCompute();
@@ -9036,7 +9019,7 @@ var sc = 4, cc = class extends Sn {
9036
9019
  this._computeNode = p(() => {
9037
9020
  let u = N(De.x).mul(16).add(N(F.x)), d = N(De.y).mul(16).add(N(F.y));
9038
9021
  m(u.lessThan(N(s)).and(d.lessThan(N(c))), () => {
9039
- let s = B(e, P(u, d)), c = gc(s.z, s.w, s.x, t, N(i), N(a), o, n, r);
9022
+ let s = B(e, P(u, d)), c = yc(s.z, s.w, s.x, t, N(i), N(a), o, n, r);
9040
9023
  xe(l, we(V(u), V(d)), c).toWriteOnly();
9041
9024
  });
9042
9025
  })().compute([
@@ -9054,7 +9037,7 @@ var sc = 4, cc = class extends Sn {
9054
9037
  this._heatmapComputeNode = p(() => {
9055
9038
  let i = N(De.x).mul(16).add(N(F.x)), a = N(De.y).mul(16).add(N(F.y));
9056
9039
  m(i.lessThan(N(n)).and(a.lessThan(N(r))), () => {
9057
- let n = B(e, P(i, a)), r = _c(n.x.clamp(0, 1), n.y, n.z);
9040
+ let n = B(e, P(i, a)), r = bc(n.x.clamp(0, 1), n.y, n.z);
9058
9041
  xe(t, we(V(i), V(a)), r).toWriteOnly();
9059
9042
  });
9060
9043
  })().compute([
@@ -9113,18 +9096,18 @@ var sc = 4, cc = class extends Sn {
9113
9096
  dispose() {
9114
9097
  this._computeNode?.dispose(), this._heatmapComputeNode?.dispose(), this._heatmapStorageTex?.dispose(), this._outputStorageTex?.dispose(), this.heatmapTarget?.dispose(), this._varianceTexNode?.dispose(), this._computeNode = null, this._heatmapComputeNode = null, this._heatmapStorageTex = null, this._outputStorageTex = null, this.heatmapTarget = null, this._varianceTexNode = null;
9115
9098
  }
9116
- }, yc = class extends Sn {
9099
+ }, Sc = class extends Sn {
9117
9100
  constructor(e, t = {}) {
9118
9101
  super("EdgeAwareFiltering", {
9119
9102
  ...t,
9120
9103
  executionMode: xn.PER_CYCLE
9121
9104
  }), this.renderer = e, this.filterStrength = H(t.filterStrength ?? .75), this.strengthDecaySpeed = H(t.strengthDecaySpeed ?? .05), this.edgeThreshold = H(t.edgeThreshold ?? 1), this.phiNormal = H(t.phiNormal ?? 128), this.phiDepth = H(t.phiDepth ?? 1), this.iterationCount = H(0), this.resW = H(t.width || 1), this.resH = H(t.height || 1), this._iterations = 0, this._inputTexNode = new c(), this._ndTexNode = new c();
9122
9105
  let n = 2048, r = t.width || 1, a = t.height || 1;
9123
- this._outputStorageTex = new s(n, n), this._outputStorageTex.type = Ye, this._outputStorageTex.format = vt, this._outputStorageTex.minFilter = J, this._outputStorageTex.magFilter = J, this._srcRegion = new Ne(new Mt(0, 0), new Mt(0, 0)), this.outputTarget = new i(r, a, {
9106
+ this._outputStorageTex = new s(n, n), this._outputStorageTex.type = Ye, this._outputStorageTex.format = yt, this._outputStorageTex.minFilter = ct, this._outputStorageTex.magFilter = ct, this._srcRegion = new Ne(new Nt(0, 0), new Nt(0, 0)), this.outputTarget = new i(r, a, {
9124
9107
  type: Ye,
9125
- format: vt,
9126
- minFilter: J,
9127
- magFilter: J,
9108
+ format: yt,
9109
+ minFilter: ct,
9110
+ magFilter: ct,
9128
9111
  depthBuffer: !1,
9129
9112
  stencilBuffer: !1
9130
9113
  }), this._dispatchX = Math.ceil(r / 16), this._dispatchY = Math.ceil(a / 16), this._buildCompute();
@@ -9196,7 +9179,7 @@ var sc = 4, cc = class extends Sn {
9196
9179
  dispose() {
9197
9180
  this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this.outputTarget?.dispose(), this._inputTexNode?.dispose(), this._ndTexNode?.dispose();
9198
9181
  }
9199
- }, bc = 256, xc = -8, Sc = 6 - xc, Cc = Sc / bc, wc = 1e4, Tc = /* @__PURE__ */ K("\n fn adaptExposure(\n geoMean: f32,\n prevExposure: f32,\n keyValue: f32,\n minExp: f32,\n maxExp: f32,\n speedBright: f32,\n speedDark: f32,\n dt: f32,\n isFirstFrame: f32\n ) -> vec4f {\n\n let targetExp = clamp( keyValue / max( geoMean, 0.001 ), minExp, maxExp );\n var newExposure = targetExp;\n\n // Temporal smoothing (skip on first frame)\n if ( isFirstFrame < 0.5 ) {\n\n // Asymmetric speed: brighter scenes adapt faster\n let speed = select( speedDark, speedBright, targetExp < prevExposure );\n let alpha = 1.0 - exp( -dt * speed );\n newExposure = mix( prevExposure, targetExp, alpha );\n\n }\n\n return vec4f( newExposure, geoMean, targetExp, 1.0 );\n\n }\n"), Ec = class extends Sn {
9182
+ }, Cc = 256, wc = -8, Tc = 6 - wc, Ec = Tc / Cc, Dc = 1e4, Oc = /* @__PURE__ */ K("\n fn adaptExposure(\n geoMean: f32,\n prevExposure: f32,\n keyValue: f32,\n minExp: f32,\n maxExp: f32,\n speedBright: f32,\n speedDark: f32,\n dt: f32,\n isFirstFrame: f32\n ) -> vec4f {\n\n let targetExp = clamp( keyValue / max( geoMean, 0.001 ), minExp, maxExp );\n var newExposure = targetExp;\n\n // Temporal smoothing (skip on first frame)\n if ( isFirstFrame < 0.5 ) {\n\n // Asymmetric speed: brighter scenes adapt faster\n let speed = select( speedDark, speedBright, targetExp < prevExposure );\n let alpha = 1.0 - exp( -dt * speed );\n newExposure = mix( prevExposure, targetExp, alpha );\n\n }\n\n return vec4f( newExposure, geoMean, targetExp, 1.0 );\n\n }\n"), kc = class extends Sn {
9200
9183
  constructor(e, t = {}) {
9201
9184
  super("AutoExposure", {
9202
9185
  ...t,
@@ -9206,13 +9189,13 @@ var sc = 4, cc = class extends Sn {
9206
9189
  _initRenderTargets() {
9207
9190
  let e = {
9208
9191
  type: qe,
9209
- format: vt,
9210
- minFilter: J,
9211
- magFilter: J,
9192
+ format: yt,
9193
+ minFilter: ct,
9194
+ magFilter: ct,
9212
9195
  depthBuffer: !1,
9213
9196
  stencilBuffer: !1
9214
9197
  };
9215
- this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = qe, this._downsampleStorageTex.format = vt, this._downsampleStorageTex.minFilter = J, this._downsampleStorageTex.magFilter = J, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = qe, this._reductionStorageTex.format = vt, this._reductionStorageTex.minFilter = J, this._reductionStorageTex.magFilter = J, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(bc, "uint").toAtomic();
9198
+ this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = qe, this._downsampleStorageTex.format = yt, this._downsampleStorageTex.minFilter = ct, this._downsampleStorageTex.magFilter = ct, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = qe, this._reductionStorageTex.format = yt, this._reductionStorageTex.minFilter = ct, this._reductionStorageTex.magFilter = ct, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(Cc, "uint").toAtomic();
9216
9199
  }
9217
9200
  _buildCompute() {
9218
9201
  this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
@@ -9246,7 +9229,7 @@ var sc = 4, cc = class extends Sn {
9246
9229
  for (let i = 0; i < 16; i++) {
9247
9230
  let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = B(e, P(N(o), N(s))), l = c.x, u = c.y;
9248
9231
  m(u.greaterThan(0), () => {
9249
- let e = V(l.div(u).sub(M(xc)).div(M(Sc)).mul(M(bc)).floor().clamp(0, M(bc - 1))), r = M(o).add(.5).div(M(64)), i = M(s).add(.5).div(M(64)), a = r.sub(.5), c = i.sub(.5), d = V(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(M(wc)));
9232
+ let e = V(l.div(u).sub(M(wc)).div(M(Tc)).mul(M(Cc)).floor().clamp(0, M(Cc - 1))), r = M(o).add(.5).div(M(64)), i = M(s).add(.5).div(M(64)), a = r.sub(.5), c = i.sub(.5), d = V(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(M(Dc)));
9250
9233
  x(t.element(e), d);
9251
9234
  });
9252
9235
  }
@@ -9264,14 +9247,14 @@ var sc = 4, cc = class extends Sn {
9264
9247
  let e = this._histogramBuffer, t = this._reductionStorageTex, n = this.lowPercentileU, r = this.highPercentileU;
9265
9248
  this._histogramAnalyzeNode = p(() => {
9266
9249
  let i = M(0).toVar();
9267
- h(bc, ({ i: t }) => {
9250
+ h(Cc, ({ i: t }) => {
9268
9251
  i.addAssign(M(S(e.element(t))));
9269
9252
  });
9270
9253
  let a = i.mul(n), o = i.mul(r), s = M(0).toVar(), c = M(0).toVar(), l = M(0).toVar(), u = M(0).toVar();
9271
- h(bc, ({ i: t }) => {
9254
+ h(Cc, ({ i: t }) => {
9272
9255
  let n = M(S(e.element(t)));
9273
9256
  u.assign(s), s.addAssign(n), m(u.lessThan(o).and(s.greaterThan(a)), () => {
9274
- let e = M(xc).add(M(t).add(.5).mul(M(Cc)));
9257
+ let e = M(wc).add(M(t).add(.5).mul(M(Ec)));
9275
9258
  c.addAssign(e.mul(n)), l.addAssign(n);
9276
9259
  });
9277
9260
  });
@@ -9286,7 +9269,7 @@ var sc = 4, cc = class extends Sn {
9286
9269
  _buildAdaptationCompute() {
9287
9270
  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;
9288
9271
  this._adaptationComputeNode = p(() => {
9289
- let u = B(e, P(N(0), N(0))).x, d = Tc(u, l, n, r, i, a, o, s, c);
9272
+ let u = B(e, P(N(0), N(0))).x, d = Oc(u, l, n, r, i, a, o, s, c);
9290
9273
  t.element(V(0)).assign(d);
9291
9274
  })().compute(1, [
9292
9275
  1,
@@ -9353,7 +9336,7 @@ var sc = 4, cc = class extends Sn {
9353
9336
  };
9354
9337
  //#endregion
9355
9338
  //#region src/TSL/SSRC.js
9356
- function Dc({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode: r, readPrevNDTexNode: i, writeCacheTex: a, writePrevNDTex: o, resW: s, resH: c, temporalAlpha: l, phiNormal: u, phiDepth: d, maxHistory: f, framesSinceReset: h }) {
9339
+ function Ac({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode: r, readPrevNDTexNode: i, writeCacheTex: a, writePrevNDTex: o, resW: s, resH: c, temporalAlpha: l, phiNormal: u, phiDepth: d, maxHistory: f, framesSinceReset: h }) {
9357
9340
  return p(() => {
9358
9341
  let p = N(De.x).mul(8).add(N(F.x)), g = N(De.y).mul(8).add(N(F.y));
9359
9342
  m(p.lessThan(N(s)).and(g.lessThan(N(c))), () => {
@@ -9375,7 +9358,7 @@ function Dc({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode:
9375
9358
  });
9376
9359
  });
9377
9360
  }
9378
- function Oc({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r, resW: i, resH: a, spatialRadius: o, spatialWeight: s, phiNormal: c, phiDepth: l }) {
9361
+ function jc({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r, resW: i, resH: a, spatialRadius: o, spatialWeight: s, phiNormal: c, phiDepth: l }) {
9379
9362
  let u = [
9380
9363
  [1, 0],
9381
9364
  [-1, 0],
@@ -9401,12 +9384,12 @@ function Oc({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r,
9401
9384
  }
9402
9385
  //#endregion
9403
9386
  //#region src/Stages/SSRC.js
9404
- var kc = class extends Sn {
9387
+ var Mc = class extends Sn {
9405
9388
  constructor(e, t = {}) {
9406
9389
  super("SSRC", {
9407
9390
  ...t,
9408
9391
  executionMode: xn.PER_CYCLE
9409
- }), this.renderer = e, this.resW = H(1), this.resH = H(1), this.temporalAlpha = H(t.temporalAlpha ?? .1), this.phiNormal = H(t.phiNormal ?? 128), this.phiDepth = H(t.phiDepth ?? .5), this.maxHistory = H(t.maxHistory ?? 128), this.spatialRadius = H(t.spatialRadius ?? 4, "int"), this.spatialWeight = H(t.spatialWeight ?? .4), this._framesSinceReset = H(0, "int"), this._colorTexNode = new c(), this._ndTexNode = new c(), this._motionTexNode = new c(), this._readCacheTexNode = new c(), this._readPrevNDTexNode = new c(), this._readPass1CacheTexNode = new c(), this._cacheTexA = this._createStorageTex(1, 1, J), this._cacheTexB = this._createStorageTex(1, 1, J), this._prevNDTexA = this._createStorageTex(1, 1, J), this._prevNDTexB = this._createStorageTex(1, 1, J), this._outputTex = this._createStorageTex(1, 1, q), this._currentPingPong = 0, this._dispatchX = 1, this._dispatchY = 1, this._buildComputeNodes();
9392
+ }), this.renderer = e, this.resW = H(1), this.resH = H(1), this.temporalAlpha = H(t.temporalAlpha ?? .1), this.phiNormal = H(t.phiNormal ?? 128), this.phiDepth = H(t.phiDepth ?? .5), this.maxHistory = H(t.maxHistory ?? 128), this.spatialRadius = H(t.spatialRadius ?? 4, "int"), this.spatialWeight = H(t.spatialWeight ?? .4), this._framesSinceReset = H(0, "int"), this._colorTexNode = new c(), this._ndTexNode = new c(), this._motionTexNode = new c(), this._readCacheTexNode = new c(), this._readPrevNDTexNode = new c(), this._readPass1CacheTexNode = new c(), this._cacheTexA = this._createStorageTex(1, 1, ct), this._cacheTexB = this._createStorageTex(1, 1, ct), this._prevNDTexA = this._createStorageTex(1, 1, ct), this._prevNDTexB = this._createStorageTex(1, 1, ct), this._outputTex = this._createStorageTex(1, 1, q), this._currentPingPong = 0, this._dispatchX = 1, this._dispatchY = 1, this._buildComputeNodes();
9410
9393
  }
9411
9394
  setupEventListeners() {
9412
9395
  this.on("pipeline:reset", () => this._resetCache()), this.on("camera:moved", () => this._resetCache());
@@ -9458,7 +9441,7 @@ var kc = class extends Sn {
9458
9441
  }
9459
9442
  _createStorageTex(e, t, n) {
9460
9443
  let r = new s(e, t);
9461
- return r.type = Ye, r.format = vt, r.minFilter = n, r.magFilter = n, r;
9444
+ return r.type = Ye, r.format = yt, r.minFilter = n, r.magFilter = n, r;
9462
9445
  }
9463
9446
  _resetCache() {
9464
9447
  this._currentPingPong = 0, this._framesSinceReset.value = 0;
@@ -9476,12 +9459,12 @@ var kc = class extends Sn {
9476
9459
  phiNormal: this.phiNormal,
9477
9460
  phiDepth: this.phiDepth,
9478
9461
  maxHistory: this.maxHistory
9479
- }, t = Dc({
9462
+ }, t = Ac({
9480
9463
  ...e,
9481
9464
  writeCacheTex: this._cacheTexA,
9482
9465
  writePrevNDTex: this._prevNDTexA,
9483
9466
  framesSinceReset: this._framesSinceReset
9484
- }), n = Dc({
9467
+ }), n = Ac({
9485
9468
  ...e,
9486
9469
  writeCacheTex: this._cacheTexB,
9487
9470
  writePrevNDTex: this._prevNDTexB,
@@ -9495,7 +9478,7 @@ var kc = class extends Sn {
9495
9478
  8,
9496
9479
  1
9497
9480
  ];
9498
- this._pass1NodeA = t().compute(r, i), this._pass1NodeB = n().compute(r, i), this._pass2Node = Oc({
9481
+ this._pass1NodeA = t().compute(r, i), this._pass1NodeB = n().compute(r, i), this._pass2Node = jc({
9499
9482
  colorTexNode: this._colorTexNode,
9500
9483
  ndTexNode: this._ndTexNode,
9501
9484
  readCacheTexNode: this._readPass1CacheTexNode,
@@ -9508,14 +9491,14 @@ var kc = class extends Sn {
9508
9491
  phiDepth: this.phiDepth
9509
9492
  })().compute(r, i);
9510
9493
  }
9511
- }, Ac = class extends Sn {
9494
+ }, Nc = class extends Sn {
9512
9495
  constructor(n, r = {}) {
9513
9496
  super("Compositor", {
9514
9497
  ...r,
9515
9498
  executionMode: xn.ALWAYS
9516
9499
  }), this.renderer = n, this.saturation = H(r.saturation ?? 1), this._transparentBackground = H(0, "int"), this._sourceTexNode = new c();
9517
9500
  let i = this._sourceTexNode.sample(Ce()), a = L(W(A(i.xyz, ii)), i.xyz, this.saturation), o = z(this._transparentBackground, i.w, 1);
9518
- this.compositorMaterial = new e(), this.compositorMaterial.colorNode = G(a, o), this.compositorMaterial.blending = lt, this.compositorQuad = new t(this.compositorMaterial);
9501
+ this.compositorMaterial = new e(), this.compositorMaterial.colorNode = G(a, o), this.compositorMaterial.blending = ut, this.compositorQuad = new t(this.compositorMaterial);
9519
9502
  }
9520
9503
  _resolveSourceTexture(e) {
9521
9504
  return e.getTexture("bloom:output") || e.getTexture("edgeFiltering:output") || e.getTexture("asvgf:output") || e.getTexture("ssrc:output") || e.getTexture("pathtracer:color");
@@ -9534,7 +9517,7 @@ var kc = class extends Sn {
9534
9517
  dispose() {
9535
9518
  this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this.compositorQuad = null;
9536
9519
  }
9537
- }, jc = class {
9520
+ }, Pc = class {
9538
9521
  constructor() {
9539
9522
  this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
9540
9523
  frame: 0,
@@ -9657,7 +9640,7 @@ var kc = class extends Sn {
9657
9640
  dispose() {
9658
9641
  this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
9659
9642
  }
9660
- }, Mc = class extends Ke {
9643
+ }, Fc = class extends Ke {
9661
9644
  constructor() {
9662
9645
  super(), this._onceCallbacks = /* @__PURE__ */ new Map();
9663
9646
  }
@@ -9695,9 +9678,9 @@ var kc = class extends Sn {
9695
9678
  eventNames() {
9696
9679
  return this._listeners ? Object.keys(this._listeners) : [];
9697
9680
  }
9698
- }, Nc = class {
9681
+ }, Ic = class {
9699
9682
  constructor(e, t, n) {
9700
- this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new jc(), this.eventBus = new Mc(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
9683
+ this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new Pc(), this.eventBus = new Fc(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
9701
9684
  enabled: !1,
9702
9685
  logSkipped: !1,
9703
9686
  timings: /* @__PURE__ */ new Map(),
@@ -9829,7 +9812,7 @@ var kc = class extends Sn {
9829
9812
  let e = this.getInfo();
9830
9813
  console.group("[Pipeline] Info"), console.log("Stages:", e.stages), console.log("Context Textures:", e.textures), console.log("Context Render Targets:", e.renderTargets), console.log("Context Uniforms:", e.uniforms), console.log("Event Types:", e.events), console.log("State:", e.contextState), console.groupEnd();
9831
9814
  }
9832
- }, Pc = class {
9815
+ }, Lc = class {
9833
9816
  constructor() {
9834
9817
  this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1;
9835
9818
  }
@@ -9851,9 +9834,9 @@ var kc = class extends Sn {
9851
9834
  resumeFromPause() {
9852
9835
  this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
9853
9836
  }
9854
- }, Fc = class extends Ke {
9837
+ }, Rc = class extends Ke {
9855
9838
  constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
9856
- super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new yt(), 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;
9839
+ super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new bt(), 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;
9857
9840
  }
9858
9841
  setDependencies({ overlayManager: e, transformManager: t, appDispatch: n, orbitControls: r }) {
9859
9842
  this._overlayManager = e || null, this._transformManager = t || null, this._appDispatch = n || null, this._orbitControls = r || null;
@@ -9894,7 +9877,7 @@ var kc = class extends Sn {
9894
9877
  }
9895
9878
  }
9896
9879
  showFocusPoint(e) {
9897
- this.focusPointIndicator && this.scene.remove(this.focusPointIndicator), this.focusPointIndicator = new it(new Tt(this.assetLoader.getSceneScale() * .02, 16, 16), new at({
9880
+ this.focusPointIndicator && this.scene.remove(this.focusPointIndicator), this.focusPointIndicator = new it(new Et(this.assetLoader.getSceneScale() * .02, 16, 16), new at({
9898
9881
  color: 65280,
9899
9882
  transparent: !0,
9900
9883
  opacity: .8,
@@ -10072,7 +10055,7 @@ var kc = class extends Sn {
10072
10055
  dispose() {
10073
10056
  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;
10074
10057
  }
10075
- }, Ic = {
10058
+ }, zc = {
10076
10059
  glb: {
10077
10060
  type: "model",
10078
10061
  name: "GLB (GLTF Binary)"
@@ -10137,7 +10120,7 @@ var kc = class extends Sn {
10137
10120
  type: "archive",
10138
10121
  name: "ZIP Archive"
10139
10122
  }
10140
- }, Lc = class extends Ke {
10123
+ }, Bc = class extends Ke {
10141
10124
  constructor(e, t, n) {
10142
10125
  super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this._externalModel = null, this.floorPlane = null, this.sceneScale = 1, this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null;
10143
10126
  }
@@ -10148,7 +10131,7 @@ var kc = class extends Sn {
10148
10131
  this.renderer = e;
10149
10132
  }
10150
10133
  getFileFormat(e) {
10151
- return Ic[e.split(".").pop().toLowerCase()] || null;
10134
+ return zc[e.split(".").pop().toLowerCase()] || null;
10152
10135
  }
10153
10136
  readFileAsArrayBuffer(e) {
10154
10137
  return new Promise((t, n) => {
@@ -10274,14 +10257,14 @@ var kc = class extends Sn {
10274
10257
  }
10275
10258
  async loadEnvironmentByExtension(e, t) {
10276
10259
  let n;
10277
- return t === "hdr" || t === "exr" ? n = await (t === "hdr" ? this.loaderCache.hdr || (this.loaderCache.hdr = new Lt().setDataType(qe)) : this.loaderCache.exr || (this.loaderCache.exr = new Bt().setDataType(qe))).loadAsync(e) : (this.loaderCache.texture || (this.loaderCache.texture = new Ot()), n = await this.loaderCache.texture.loadAsync(e)), n.mapping = Ge, n.minFilter = q, n.magFilter = q, n;
10260
+ return t === "hdr" || t === "exr" ? n = await (t === "hdr" ? this.loaderCache.hdr || (this.loaderCache.hdr = new Rt().setDataType(qe)) : this.loaderCache.exr || (this.loaderCache.exr = new Vt().setDataType(qe))).loadAsync(e) : (this.loaderCache.texture || (this.loaderCache.texture = new kt()), n = await this.loaderCache.texture.loadAsync(e)), n.mapping = Ge, n.minFilter = q, n.magFilter = q, n;
10278
10261
  }
10279
10262
  applyEnvironmentToScene(e) {
10280
10263
  this.scene.background = e, this.scene.environment = e;
10281
10264
  }
10282
10265
  async loadArchiveFromFile(e, t) {
10283
10266
  try {
10284
- let n = await this.readFileAsArrayBuffer(e), r = Wt(new Uint8Array(n));
10267
+ let n = await this.readFileAsArrayBuffer(e), r = Gt(new Uint8Array(n));
10285
10268
  return await this.processObjMtlPairsInZip(r, t) || await this.findAndLoadModelFromZip(r, t);
10286
10269
  } catch (e) {
10287
10270
  throw console.error("Error loading ZIP archive:", e), e;
@@ -10341,7 +10324,7 @@ var kc = class extends Sn {
10341
10324
  }
10342
10325
  for (let t in e) {
10343
10326
  let n = t.split(".").pop().toLowerCase();
10344
- if (Ic[n] && Ic[n].type === "model") return console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e);
10327
+ if (zc[n] && zc[n].type === "model") return console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e);
10345
10328
  }
10346
10329
  throw Error("No supported model files found in the ZIP archive");
10347
10330
  }
@@ -10372,7 +10355,7 @@ var kc = class extends Sn {
10372
10355
  break;
10373
10356
  case "dae":
10374
10357
  {
10375
- let n = Ut(e), r = new File([new Blob([n])], t);
10358
+ let n = Wt(e), r = new File([new Blob([n])], t);
10376
10359
  o = await this.loadColladaFromFile(r, t);
10377
10360
  }
10378
10361
  break;
@@ -10399,7 +10382,7 @@ var kc = class extends Sn {
10399
10382
  }
10400
10383
  async handleGltfFromZip(e, t, n, r) {
10401
10384
  if (e === "gltf") {
10402
- let e = Ut(t), i = new Qe(), a = n.split("/").slice(0, -1).join("/");
10385
+ let e = Wt(t), i = new Qe(), a = n.split("/").slice(0, -1).join("/");
10403
10386
  i.setURLModifier((e) => this.resolveZipResource(e, a, r));
10404
10387
  let o = await this.createGLTFLoader();
10405
10388
  o.manager = i;
@@ -10415,7 +10398,7 @@ var kc = class extends Sn {
10415
10398
  } else return await this.loadGLBFromArrayBuffer(t.buffer, n);
10416
10399
  }
10417
10400
  async handleObjFromZip(e, t, n) {
10418
- let r = Ut(e), i = r.match(/mtllib\s+([^\s]+)/), a = null;
10401
+ let r = Wt(e), i = r.match(/mtllib\s+([^\s]+)/), a = null;
10419
10402
  i && i[1] && (a = await this.loadMtlFromZip(i[1], t, n));
10420
10403
  let { OBJLoader: o } = await import("three/examples/jsm/loaders/OBJLoader.js"), s = new o();
10421
10404
  a && s.setMaterials(a);
@@ -10429,7 +10412,7 @@ var kc = class extends Sn {
10429
10412
  e.split("/").pop()
10430
10413
  ];
10431
10414
  for (let e of i) if (n[e]) {
10432
- let { MTLLoader: t } = await import("three/examples/jsm/loaders/MTLLoader.js"), i = Ut(n[e]), a = new Qe();
10415
+ let { MTLLoader: t } = await import("three/examples/jsm/loaders/MTLLoader.js"), i = Wt(n[e]), a = new Qe();
10433
10416
  a.setURLModifier((e) => this.resolveZipResource(e, r, n));
10434
10417
  let o = new t(a).parse(i, r);
10435
10418
  return o.preload(), o;
@@ -10455,7 +10438,7 @@ var kc = class extends Sn {
10455
10438
  d.preload();
10456
10439
  let f = new a(s);
10457
10440
  f.setMaterials(d);
10458
- let p = Ut(e.content), m = f.parse(p);
10441
+ let p = Wt(e.content), m = f.parse(p);
10459
10442
  return this.releaseTargetModel(), this.targetModel = m, await this.onModelLoad(this.targetModel), o.forEach((e) => URL.revokeObjectURL(e)), this.dispatchEvent({
10460
10443
  type: "load",
10461
10444
  model: m,
@@ -10463,7 +10446,7 @@ var kc = class extends Sn {
10463
10446
  }), m;
10464
10447
  }
10465
10448
  prepareFixedMtlContent(e) {
10466
- return Ut(e.content).replace(RegExp(`${e.path.split("/").pop()}\\s+`, "g"), " ").replace(/([a-zA-Z_]+)([\\/])/g, "$1 $2");
10449
+ return Wt(e.content).replace(RegExp(`${e.path.split("/").pop()}\\s+`, "g"), " ").replace(/([a-zA-Z_]+)([\\/])/g, "$1 $2");
10467
10450
  }
10468
10451
  resolveTextureInZip(e, t, n, r, i, a) {
10469
10452
  let o = e.split("?")[0].split("#")[0].replace(/^\.\/|^\//, ""), s = r.path.split("/").pop();
@@ -10499,9 +10482,9 @@ var kc = class extends Sn {
10499
10482
  return null;
10500
10483
  }
10501
10484
  async createGLTFLoader() {
10502
- let { dracoDecoderPath: e, ktx2TranscoderPath: t } = oc(), n = new Rt();
10485
+ let { dracoDecoderPath: e, ktx2TranscoderPath: t } = lc(), n = new zt();
10503
10486
  n.setDecoderConfig({ type: "js" }), n.setDecoderPath(e);
10504
- let r = new zt();
10487
+ let r = new Bt();
10505
10488
  r.setTranscoderPath(t), this.renderer && (r.detectSupport(this.renderer), r.workerConfig = {
10506
10489
  astcSupported: !1,
10507
10490
  etc1Supported: !1,
@@ -10510,8 +10493,8 @@ var kc = class extends Sn {
10510
10493
  bptcSupported: !1,
10511
10494
  pvrtcSupported: !1
10512
10495
  });
10513
- let i = new It();
10514
- return i.setDRACOLoader(n), i.setKTX2Loader(r), i.setMeshoptDecoder(Ht), i;
10496
+ let i = new Lt();
10497
+ return i.setDRACOLoader(n), i.setKTX2Loader(r), i.setMeshoptDecoder(Ut), i;
10515
10498
  }
10516
10499
  _disposeGLTFLoader(e) {
10517
10500
  e && (e.dracoLoader?.dispose(), e.ktx2Loader?.dispose());
@@ -10672,8 +10655,8 @@ var kc = class extends Sn {
10672
10655
  let n = this.loaderCache.ply.parse(e), r;
10673
10656
  if (n.index !== null) r = new it(n, new st());
10674
10657
  else {
10675
- let e = new gt({ size: .01 });
10676
- e.vertexColors = n.hasAttribute("color"), r = new ht(n, e);
10658
+ let e = new _t({ size: .01 });
10659
+ e.vertexColors = n.hasAttribute("color"), r = new gt(n, e);
10677
10660
  }
10678
10661
  return r.name = t, this.releaseTargetModel(), this.targetModel = r, On({
10679
10662
  isLoading: !0,
@@ -10788,13 +10771,13 @@ var kc = class extends Sn {
10788
10771
  }), e;
10789
10772
  }
10790
10773
  async onModelLoad(e) {
10791
- let t = new gs("onModelLoad");
10774
+ let t = new ys("onModelLoad");
10792
10775
  t.start("Camera extraction");
10793
10776
  let n = this.extractCamerasFromModel(e);
10794
10777
  t.end("Camera extraction"), t.start("Camera setup");
10795
- let r = new Pe().setFromObject(e), i = r.getCenter(new Nt()), a = r.getSize(new Nt());
10778
+ let r = new Pe().setFromObject(e), i = r.getCenter(new Pt()), a = r.getSize(new Pt());
10796
10779
  this.controls.target.copy(i);
10797
- let o = Math.max(a.x, a.y, a.z), s = this.camera.fov * (Math.PI / 180), c = Math.abs(o / Math.sin(s / 2) / 2), l = Math.PI / 6, u = new Nt(Math.cos(l) * c, c / Math.sqrt(2), Math.sin(l) * c);
10780
+ let o = Math.max(a.x, a.y, a.z), s = this.camera.fov * (Math.PI / 180), c = Math.abs(o / Math.sin(s / 2) / 2), l = Math.PI / 6, u = new Pt(Math.cos(l) * c, c / Math.sqrt(2), Math.sin(l) * c);
10798
10781
  if (this.camera.position.copy(u.add(i)), this.camera.lookAt(i), this.camera.near = o / 100, this.camera.far = o * 100, this.camera.updateProjectionMatrix(), this.controls.maxDistance = c * 10, this.controls.saveState(), this.controls.update(), t.end("Camera setup"), this.floorPlane) {
10799
10782
  let e = r.min.y;
10800
10783
  this.floorPlane.position.y = e, this.floorPlane.rotation.x = -Math.PI / 2, this.floorPlane.scale.setScalar(o * 5);
@@ -10832,12 +10815,12 @@ var kc = class extends Sn {
10832
10815
  e.traverse((e) => {
10833
10816
  let n = e.userData;
10834
10817
  if (e.isRectAreaLight && !t.includes(e.uuid) && t.push(e.uuid), e.name.startsWith("RectAreaLightPlaceholder") && n.name && n.type === "RectAreaLight") {
10835
- let r = new bt(new Re(...n.color), n.intensity * .1 / Math.PI, n.width, n.height);
10818
+ let r = new xt(new Re(...n.color), n.intensity * .1 / Math.PI, n.width, n.height);
10836
10819
  r.position.z = -2, r.name = n.name, e.add(r), t.push(r.uuid);
10837
10820
  }
10838
10821
  if (e.isMesh && Array.isArray(e.material)) {
10839
10822
  console.log("Found multi-material mesh:", e.name);
10840
- let t = Vt(e);
10823
+ let t = Ht(e);
10841
10824
  e.parent && (e.parent.add(t), e.parent.remove(e));
10842
10825
  }
10843
10826
  });
@@ -10867,10 +10850,10 @@ var kc = class extends Sn {
10867
10850
  getSupportedFormats(e = null) {
10868
10851
  if (e) {
10869
10852
  let t = {};
10870
- for (let [n, r] of Object.entries(Ic)) r.type === e && (t[n] = r);
10853
+ for (let [n, r] of Object.entries(zc)) r.type === e && (t[n] = r);
10871
10854
  return t;
10872
10855
  }
10873
- return Ic;
10856
+ return zc;
10874
10857
  }
10875
10858
  dispose() {
10876
10859
  for (let e in this.loaderCache) {
@@ -10882,7 +10865,7 @@ var kc = class extends Sn {
10882
10865
  removeAllEventListeners() {
10883
10866
  this._listeners = void 0;
10884
10867
  }
10885
- }, Rc = {
10868
+ }, Vc = {
10886
10869
  maxBounces: {
10887
10870
  uniform: "maxBounces",
10888
10871
  reset: !0
@@ -10993,11 +10976,11 @@ var kc = class extends Sn {
10993
10976
  },
10994
10977
  renderMode: { handler: "handleRenderMode" },
10995
10978
  environmentRotation: { handler: "handleEnvironmentRotation" }
10996
- }, zc = {
10979
+ }, Hc = {
10997
10980
  bounces: "maxBounces",
10998
10981
  adaptiveSampling: "useAdaptiveSampling",
10999
10982
  debugMode: "visMode"
11000
- }, Bc = class extends Ke {
10983
+ }, Uc = class extends Ke {
11001
10984
  constructor(e = X) {
11002
10985
  super(), this._values = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._delegates = {}, this._initDefaults(e);
11003
10986
  }
@@ -11039,7 +11022,7 @@ var kc = class extends Sn {
11039
11022
  let i = this._values.get(e);
11040
11023
  if (i === t) return;
11041
11024
  this._values.set(e, t);
11042
- let a = Rc[e];
11025
+ let a = Vc[e];
11043
11026
  a && (this._applyRoute(a, t, i), (n === void 0 ? a.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
11044
11027
  type: Y.SETTING_CHANGED,
11045
11028
  key: e,
@@ -11053,7 +11036,7 @@ var kc = class extends Sn {
11053
11036
  let e = this._values.get(r);
11054
11037
  if (e === i) continue;
11055
11038
  this._values.set(r, i);
11056
- let a = Rc[r];
11039
+ let a = Vc[r];
11057
11040
  a && (this._applyRoute(a, i, e), (a.reset ?? !0) && (n = !0), t || this.dispatchEvent({
11058
11041
  type: Y.SETTING_CHANGED,
11059
11042
  key: r,
@@ -11071,7 +11054,7 @@ var kc = class extends Sn {
11071
11054
  }
11072
11055
  applyAll() {
11073
11056
  for (let [e, t] of this._values) {
11074
- let n = Rc[e];
11057
+ let n = Vc[e];
11075
11058
  n && this._applyRoute(n, t, void 0);
11076
11059
  }
11077
11060
  }
@@ -11079,14 +11062,14 @@ var kc = class extends Sn {
11079
11062
  e.uniform ? (this._pathTracer?.setUniform(e.uniform, t), e.after && this._pathTracer?.[e.after]?.()) : e.handler ? this._handlers[e.handler]?.(t, n) : e.delegate && this._delegates[e.delegate]?.updateParam?.(e.param, t);
11080
11063
  }
11081
11064
  _initDefaults(e) {
11082
- for (let t of Object.keys(Rc)) t in e && this._values.set(t, e[t]);
11083
- for (let [t, n] of Object.entries(zc)) t in e && this._values.set(n, e[t]);
11065
+ for (let t of Object.keys(Vc)) t in e && this._values.set(t, e[t]);
11066
+ for (let [t, n] of Object.entries(Hc)) t in e && this._values.set(n, e[t]);
11084
11067
  }
11085
- }, Vc = class extends Ke {
11068
+ }, Wc = class extends Ke {
11086
11069
  constructor(e) {
11087
11070
  super();
11088
11071
  let t = e.clientWidth, n = e.clientHeight;
11089
- this.camera = new ft(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new Gt(this.camera, e), this.controls.screenSpacePanning = !0, this.controls.zoomToCursor = !0, this.controls.saveState(), this.interactionManager = null, this.cameras = [this.camera], this.currentCameraIndex = 0, this.autoFocusMode = Gn.SMOOTHING_FACTOR ? "auto" : "manual", this.afScreenPoint = {
11072
+ this.camera = new pt(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new Kt(this.camera, e), this.controls.screenSpacePanning = !0, this.controls.zoomToCursor = !0, this.controls.saveState(), this.interactionManager = null, this.cameras = [this.camera], this.currentCameraIndex = 0, this.autoFocusMode = Gn.SMOOTHING_FACTOR ? "auto" : "manual", this.afScreenPoint = {
11090
11073
  x: .5,
11091
11074
  y: .5
11092
11075
  }, this.afSmoothingFactor = Gn.SMOOTHING_FACTOR, this._lastValidFocusDistance = null, this._smoothedFocusDistance = null, this._afPointDirty = !1, this._defaultCameraState = null, this._onResize = null, this._onReset = null, this._getSettings = null;
@@ -11115,7 +11098,7 @@ var kc = class extends Sn {
11115
11098
  } else {
11116
11099
  let n = this.cameras[e];
11117
11100
  if (this.camera.position.copy(n.position), this.camera.quaternion.copy(n.quaternion), this.camera.fov = n.fov, this.camera.near = n.near, this.camera.far = n.far, this.camera.updateProjectionMatrix(), this.camera.updateMatrixWorld(!0), this.controls) {
11118
- let e = new Nt(0, 0, -1).applyQuaternion(n.quaternion), r = t || 5;
11101
+ let e = new Pt(0, 0, -1).applyQuaternion(n.quaternion), r = t || 5;
11119
11102
  this.controls.target.copy(this.camera.position).addScaledVector(e, r), this.controls.update();
11120
11103
  }
11121
11104
  }
@@ -11198,7 +11181,7 @@ var kc = class extends Sn {
11198
11181
  dispose() {
11199
11182
  this.controls?.dispose();
11200
11183
  }
11201
- }, Hc = class extends Ke {
11184
+ }, Gc = class extends Ke {
11202
11185
  constructor(e, t, n, r = {}) {
11203
11186
  super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null;
11204
11187
  }
@@ -11247,12 +11230,12 @@ var kc = class extends Sn {
11247
11230
  if (!t) return null;
11248
11231
  let n;
11249
11232
  if (e === "DirectionalLight") n = new He(t.color, t.intensity), n.position.fromArray(t.position);
11250
- else if (e === "PointLight") n = new pt(t.color, t.intensity), n.position.fromArray(t.position);
11233
+ else if (e === "PointLight") n = new mt(t.color, t.intensity), n.position.fromArray(t.position);
11251
11234
  else if (e === "SpotLight") {
11252
- n = new Et(t.color, t.intensity), n.position.fromArray(t.position), n.angle = tt.degToRad(t.angle);
11253
- let e = new dt();
11235
+ n = new Dt(t.color, t.intensity), n.position.fromArray(t.position), n.angle = tt.degToRad(t.angle);
11236
+ let e = new ft();
11254
11237
  this.scene.add(e), n.target = e;
11255
- } else e === "RectAreaLight" && (n = new bt(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0));
11238
+ } else e === "RectAreaLight" && (n = new xt(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0));
11256
11239
  let r = this.scene.getObjectsByProperty("isLight", !0).length;
11257
11240
  return n.name = `${e.replace("Light", "")} ${r + 1}`, this.scene.add(n), this.updateLights(), this._syncHelpers(), this._onReset?.(), this._buildDescriptor(n);
11258
11241
  }
@@ -11279,7 +11262,7 @@ var kc = class extends Sn {
11279
11262
  for (let e of t) {
11280
11263
  let t = e.clone();
11281
11264
  if (e.updateWorldMatrix(!0, !1), e.getWorldPosition(t.position), e.getWorldQuaternion(t.quaternion), e.getWorldScale(t.scale), t.isRectAreaLight && (t.width *= t.scale.x, t.height *= t.scale.y, t.scale.set(1, 1, 1)), (e.isSpotLight || e.isDirectionalLight) && e.target) {
11282
- let n = new dt();
11265
+ let n = new ft();
11283
11266
  e.target.updateWorldMatrix(!0, !1), e.target.getWorldPosition(n.position), this.scene.add(n), t.target = n;
11284
11267
  }
11285
11268
  this.scene.add(t);
@@ -11351,39 +11334,39 @@ var kc = class extends Sn {
11351
11334
  ]);
11352
11335
  return n;
11353
11336
  }
11354
- }, Uc = (e) => Math.min(Math.max(e, 0), 1);
11355
- function Wc(e, t, n, r, i) {
11356
- i[0] = Uc(e), i[1] = Uc(t), i[2] = Uc(n);
11337
+ }, Kc = (e) => Math.min(Math.max(e, 0), 1);
11338
+ function qc(e, t, n, r, i) {
11339
+ i[0] = Kc(e), i[1] = Kc(t), i[2] = Kc(n);
11357
11340
  }
11358
- function Gc(e, t, n, r, i) {
11359
- i[0] = Uc(e * r), i[1] = Uc(t * r), i[2] = Uc(n * r);
11341
+ function Jc(e, t, n, r, i) {
11342
+ i[0] = Kc(e * r), i[1] = Kc(t * r), i[2] = Kc(n * r);
11360
11343
  }
11361
- function Kc(e, t, n, r, i) {
11362
- e *= r, t *= r, n *= r, i[0] = Uc(e / (e + 1)), i[1] = Uc(t / (t + 1)), i[2] = Uc(n / (n + 1));
11344
+ function Yc(e, t, n, r, i) {
11345
+ e *= r, t *= r, n *= r, i[0] = Kc(e / (e + 1)), i[1] = Kc(t / (t + 1)), i[2] = Kc(n / (n + 1));
11363
11346
  }
11364
- function qc(e, t, n, r, i) {
11347
+ function Xc(e, t, n, r, i) {
11365
11348
  e = Math.max(e * r - .004, 0), t = Math.max(t * r - .004, 0), n = Math.max(n * r - .004, 0);
11366
11349
  let a = (e) => (e * (6.2 * e + .5) / (e * (6.2 * e + 1.7) + .06)) ** 2.2;
11367
11350
  i[0] = a(e), i[1] = a(t), i[2] = a(n);
11368
11351
  }
11369
- function Jc(e, t, n, r, i) {
11352
+ function Zc(e, t, n, r, i) {
11370
11353
  e = e * r / .6, t = t * r / .6, n = n * r / .6;
11371
11354
  let a = .59719 * e + .35458 * t + .04823 * n, o = .076 * e + .90834 * t + .01566 * n, s = .0284 * e + .13383 * t + .83777 * n, c = (e) => (e * (e + .0245786) - 90537e-9) / (e * (.983729 * e + .432951) + .238081);
11372
- a = c(a), o = c(o), s = c(s), i[0] = Uc(1.60475 * a - .53108 * o - .07367 * s), i[1] = Uc(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = Uc(-.00327 * a - .07276 * o + 1.07602 * s);
11355
+ a = c(a), o = c(o), s = c(s), i[0] = Kc(1.60475 * a - .53108 * o - .07367 * s), i[1] = Kc(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = Kc(-.00327 * a - .07276 * o + 1.07602 * s);
11373
11356
  }
11374
- function Yc(e, t, n, r, i) {
11357
+ function Qc(e, t, n, r, i) {
11375
11358
  e *= r, t *= r, n *= r;
11376
11359
  let a = .6274 * e + .3293 * t + .0433 * n, o = .0691 * e + .9195 * t + .0113 * n, s = .0164 * e + .088 * t + .8956 * n, c = .856627153315983 * a + .0951212405381588 * o + .0482516061458583 * s, l = .137318972929847 * a + .761241990602591 * o + .101439036467562 * s, u = .11189821299995 * a + .0767994186031903 * o + .811302368396859 * s, d = -12.47393, f = 4.026069 - d;
11377
- c = Uc((Math.log2(Math.max(c, 1e-10)) - d) / f), l = Uc((Math.log2(Math.max(l, 1e-10)) - d) / f), u = Uc((Math.log2(Math.max(u, 1e-10)) - d) / f);
11360
+ c = Kc((Math.log2(Math.max(c, 1e-10)) - d) / f), l = Kc((Math.log2(Math.max(l, 1e-10)) - d) / f), u = Kc((Math.log2(Math.max(u, 1e-10)) - d) / f);
11378
11361
  let p = (e) => {
11379
11362
  let t = e * e, n = t * t;
11380
11363
  return 15.5 * n * t - 40.14 * n * e + 31.96 * n - 6.868 * t * e + .4298 * t + .1191 * e - .00232;
11381
11364
  };
11382
11365
  c = p(c), l = p(l), u = p(u);
11383
11366
  let m = 1.1271005818144368 * c - .11060664309660323 * l - .016493938717834573 * u, h = -.1413297634984383 * c + 1.157823702216272 * l - .016493938717834257 * u, g = -.14132976349843826 * c - .11060664309660294 * l + 1.2519364065950405 * u;
11384
- m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = Uc(1.6605 * m - .5876 * h - .0728 * g), i[1] = Uc(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = Uc(-.0182 * m - .1006 * h + 1.1187 * g);
11367
+ m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = Kc(1.6605 * m - .5876 * h - .0728 * g), i[1] = Kc(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = Kc(-.0182 * m - .1006 * h + 1.1187 * g);
11385
11368
  }
11386
- function Xc(e, t, n, r, i) {
11369
+ function $c(e, t, n, r, i) {
11387
11370
  let a = .76;
11388
11371
  e *= r, t *= r, n *= r;
11389
11372
  let o = Math.min(e, Math.min(t, n)), s = o < .08 ? o - 6.25 * o * o : .04;
@@ -11398,43 +11381,43 @@ function Xc(e, t, n, r, i) {
11398
11381
  let f = 1 - 1 / (.15 * (c - u) + 1);
11399
11382
  i[0] = e + (u - e) * f, i[1] = t + (u - t) * f, i[2] = n + (u - n) * f;
11400
11383
  }
11401
- var Zc = new Map([
11402
- [ut, Wc],
11403
- [Ze, Gc],
11404
- [xt, Kc],
11405
- [Fe, qc],
11406
- [Oe, Jc],
11407
- [Ae, Yc],
11408
- [ct, Xc]
11409
- ]), Qc = 1 / 2.2;
11410
- function $c(e) {
11384
+ var el = new Map([
11385
+ [dt, qc],
11386
+ [Ze, Jc],
11387
+ [St, Yc],
11388
+ [Fe, Xc],
11389
+ [Oe, Zc],
11390
+ [Ae, Qc],
11391
+ [lt, $c]
11392
+ ]), tl = 1 / 2.2;
11393
+ function nl(e) {
11411
11394
  return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
11412
11395
  }
11413
- var el = .2126, tl = .7152, nl = .0722;
11414
- function rl(e, t) {
11396
+ var rl = .2126, il = .7152, al = .0722;
11397
+ function ol(e, t) {
11415
11398
  if (t === 1) return;
11416
- let n = e[0] * el + e[1] * tl + e[2] * nl;
11399
+ let n = e[0] * rl + e[1] * il + e[2] * al;
11417
11400
  e[0] = n + (e[0] - n) * t, e[1] = n + (e[1] - n) * t, e[2] = n + (e[2] - n) * t;
11418
11401
  }
11419
11402
  //#endregion
11420
11403
  //#region src/Passes/OIDNDenoiser.js
11421
- var il = null, al = null;
11422
- async function ol() {
11423
- if (!il) {
11404
+ var sl = null, cl = null;
11405
+ async function ll() {
11406
+ if (!sl) {
11424
11407
  let [e, t] = await Promise.all([import("oidn-web"), import("@tensorflow/tfjs-core")]);
11425
- il = e.initUNetFromURL, al = t.engine;
11408
+ sl = e.initUNetFromURL, cl = t.engine;
11426
11409
  }
11427
- return il;
11410
+ return sl;
11428
11411
  }
11429
- function sl() {
11430
- if (al) try {
11431
- let e = al();
11412
+ function ul() {
11413
+ if (cl) try {
11414
+ let e = cl();
11432
11415
  e?.registryFactory && "webgpu-oidn" in e.registryFactory && e.removeBackend("webgpu-oidn");
11433
11416
  } catch (e) {
11434
11417
  console.warn("OIDNDenoiser: failed to clear cached TFJS backend", e);
11435
11418
  }
11436
11419
  }
11437
- var cl = new Float32Array(3), ll = {
11420
+ var dl = new Float32Array(3), fl = {
11438
11421
  QUALITY_MODELS: {
11439
11422
  fast: "rt_hdr_alb_nrm_small",
11440
11423
  balance: "rt_hdr_alb_nrm",
@@ -11446,7 +11429,7 @@ var cl = new Float32Array(3), ll = {
11446
11429
  debugGbufferMaps: !0,
11447
11430
  tileSize: 256
11448
11431
  }
11449
- }, ul = class extends Ke {
11432
+ }, pl = class extends Ke {
11450
11433
  constructor(e, t, n, r, i = {}) {
11451
11434
  if (super(), !e || !t || !n || !r) throw Error("OIDNDenoiser requires output canvas, renderer, scene, and camera");
11452
11435
  this.renderer = t, this.scene = n, this.camera = r, this.input = t.domElement, this.output = e, this.extractGBufferData = i.extractGBufferData || null, this.getMRTRenderTarget = i.getMRTRenderTarget || null, this.backendParamsGetter = i.backendParams || null, this.getGPUTextures = i.getGPUTextures || null, this.getExposure = i.getExposure || (() => 1), this.getToneMapping = i.getToneMapping || (() => Oe), this.getSaturation = i.getSaturation || (() => 1), this.getTransparentBackground = i.getTransparentBackground || (() => !1), this.isGPUMode = !!this.backendParamsGetter, this.gpuDevice = null, this._gpuInputBuffers = {
@@ -11457,7 +11440,7 @@ var cl = new Float32Array(3), ll = {
11457
11440
  width: 0,
11458
11441
  height: 0
11459
11442
  }, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
11460
- ...ll.DEFAULT_OPTIONS,
11443
+ ...fl.DEFAULT_OPTIONS,
11461
11444
  ...i
11462
11445
  }, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this.state = {
11463
11446
  isDenoising: !1,
@@ -11510,7 +11493,7 @@ var cl = new Float32Array(3), ll = {
11510
11493
  let e = this.backendParamsGetter();
11511
11494
  this.gpuDevice = e?.device ?? null, t = e?.device ? e : void 0;
11512
11495
  }
11513
- this.unet = await (await ol())(e, t, {
11496
+ this.unet = await (await ll())(e, t, {
11514
11497
  aux: !0,
11515
11498
  hdr: !0,
11516
11499
  maxTileSize: this.tileSize
@@ -11525,14 +11508,14 @@ var cl = new Float32Array(3), ll = {
11525
11508
  }
11526
11509
  }
11527
11510
  _generateTzaUrl() {
11528
- let { oidnWeightsBaseUrl: e } = oc(), { QUALITY_MODELS: t } = ll;
11511
+ let { oidnWeightsBaseUrl: e } = lc(), { QUALITY_MODELS: t } = fl;
11529
11512
  return `${e}${t[this.quality] || t.balance}.tza`;
11530
11513
  }
11531
11514
  async updateConfiguration(e) {
11532
11515
  Object.keys(e).some((t) => this.config[t] !== e[t]) && (Object.assign(this.config, e), this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, await this._setupUNetDenoiser());
11533
11516
  }
11534
11517
  async updateQuality(e) {
11535
- if (!Object.prototype.hasOwnProperty.call(ll.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(ll.QUALITY_MODELS).join(", ")}`);
11518
+ if (!Object.prototype.hasOwnProperty.call(fl.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(fl.QUALITY_MODELS).join(", ")}`);
11536
11519
  await this.updateConfiguration({ oidnQuality: e });
11537
11520
  }
11538
11521
  async start() {
@@ -11713,10 +11696,10 @@ var cl = new Float32Array(3), ll = {
11713
11696
  d.copyBufferToBuffer(e.data, r, u, a, c);
11714
11697
  }
11715
11698
  r.queue.submit([d.finish()]), u.mapAsync(GPUMapMode.READ).then(() => {
11716
- let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l = Zc.get(this.getToneMapping()) || Zc.get(Oe), d = this._cachedAlpha, f = this._cachedAlphaWidth;
11699
+ let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l = el.get(this.getToneMapping()) || el.get(Oe), d = this._cachedAlpha, f = this._cachedAlphaWidth;
11717
11700
  for (let i = 0, a = e.length; i < a; i += 4) {
11718
11701
  let a = e[i] * r, s = e[i + 1] * r, u = e[i + 2] * r;
11719
- if (c !== 1 && (cl[0] = a, cl[1] = s, cl[2] = u, rl(cl, c), a = cl[0], s = cl[1], u = cl[2]), l(a, s, u, 1, cl), t.data[i] = $c(cl[0]) * 255 + .5 | 0, t.data[i + 1] = $c(cl[1]) * 255 + .5 | 0, t.data[i + 2] = $c(cl[2]) * 255 + .5 | 0, d) {
11702
+ if (c !== 1 && (dl[0] = a, dl[1] = s, dl[2] = u, ol(dl, c), a = dl[0], s = dl[1], u = dl[2]), l(a, s, u, 1, dl), t.data[i] = nl(dl[0]) * 255 + .5 | 0, t.data[i + 1] = nl(dl[1]) * 255 + .5 | 0, t.data[i + 2] = nl(dl[2]) * 255 + .5 | 0, d) {
11720
11703
  let e = (i >> 2) % o, r = (i >> 2) / o | 0;
11721
11704
  t.data[i + 3] = d[(n.y + r) * f + n.x + e];
11722
11705
  } else t.data[i + 3] = 255;
@@ -11753,10 +11736,10 @@ var cl = new Float32Array(3), ll = {
11753
11736
  try {
11754
11737
  let o = r.createCommandEncoder({ label: "oidn-readback" });
11755
11738
  o.copyBufferToBuffer(e, 0, a, 0, i), r.queue.submit([o.finish()]), await a.mapAsync(GPUMapMode.READ);
11756
- let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d = Zc.get(this.getToneMapping()) || Zc.get(Oe), f = this._cachedAlpha;
11739
+ let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d = el.get(this.getToneMapping()) || el.get(Oe), f = this._cachedAlpha;
11757
11740
  for (let e = 0, t = s.length; e < t; e += 4) {
11758
11741
  let t = s[e] * l, n = s[e + 1] * l, r = s[e + 2] * l;
11759
- u !== 1 && (cl[0] = t, cl[1] = n, cl[2] = r, rl(cl, u), t = cl[0], n = cl[1], r = cl[2]), d(t, n, r, 1, cl), c.data[e] = $c(cl[0]) * 255 + .5 | 0, c.data[e + 1] = $c(cl[1]) * 255 + .5 | 0, c.data[e + 2] = $c(cl[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
11742
+ u !== 1 && (dl[0] = t, dl[1] = n, dl[2] = r, ol(dl, u), t = dl[0], n = dl[1], r = dl[2]), d(t, n, r, 1, dl), c.data[e] = nl(dl[0]) * 255 + .5 | 0, c.data[e + 1] = nl(dl[1]) * 255 + .5 | 0, c.data[e + 2] = nl(dl[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
11760
11743
  }
11761
11744
  a.unmap(), this.ctx.putImageData(c, 0, 0);
11762
11745
  } finally {
@@ -11777,9 +11760,9 @@ var cl = new Float32Array(3), ll = {
11777
11760
  this._pendingStagingBuffers.clear();
11778
11761
  }
11779
11762
  dispose() {
11780
- this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), sl(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), console.log("OIDNDenoiser disposed");
11763
+ this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), ul(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), console.log("OIDNDenoiser disposed");
11781
11764
  }
11782
- }, dl = "" + new URL("assets/AIUpscalerWorker-AXN-lKWN.js", import.meta.url).href, fl = {
11765
+ }, ml = "" + new URL("assets/AIUpscalerWorker-AXN-lKWN.js", import.meta.url).href, hl = {
11783
11766
  fast: {
11784
11767
  2: "2x-spanx2-ch48.onnx",
11785
11768
  4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
@@ -11793,17 +11776,17 @@ var cl = new Float32Array(3), ll = {
11793
11776
  4: "4xNomos2_hq_mosr_fp32.onnx"
11794
11777
  }
11795
11778
  };
11796
- function pl() {
11797
- let { upscalerModelBaseUrl: e } = oc(), t = {};
11798
- for (let n in fl) {
11779
+ function gl() {
11780
+ let { upscalerModelBaseUrl: e } = lc(), t = {};
11781
+ for (let n in hl) {
11799
11782
  t[n] = {};
11800
- for (let r in fl[n]) t[n][r] = e + fl[n][r];
11783
+ for (let r in hl[n]) t[n][r] = e + hl[n][r];
11801
11784
  }
11802
11785
  return t;
11803
11786
  }
11804
- var ml = {
11787
+ var _l = {
11805
11788
  get QUALITY_PRESETS() {
11806
- return pl();
11789
+ return gl();
11807
11790
  },
11808
11791
  TILE_SIZE: 512,
11809
11792
  TILE_OVERLAP: 16,
@@ -11814,17 +11797,17 @@ var ml = {
11814
11797
  }],
11815
11798
  graphOptimizationLevel: "all"
11816
11799
  }
11817
- }, hl = class extends Ke {
11800
+ }, vl = class extends Ke {
11818
11801
  constructor(e, t, n = {}) {
11819
11802
  if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
11820
- 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 || (() => Oe), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize || ml.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
11803
+ 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 || (() => Oe), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize || _l.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
11821
11804
  isUpscaling: !1,
11822
11805
  isLoading: !1,
11823
11806
  abortController: null
11824
11807
  }, this._worker = null, this._currentModelUrl = null, this._tileId = 0, this._pendingWorkerHandlers = /* @__PURE__ */ new Set(), this._upscaledAlpha = null, this._upscaledAlphaWidth = 0, this._backupCanvas = null, this._baseWidth = e.width, this._baseHeight = e.height, this._hdrStagingBuffer = null, this._hdrStagingWidth = 0, this._hdrStagingHeight = 0;
11825
11808
  }
11826
11809
  async _ensureSession() {
11827
- let e = ml.QUALITY_PRESETS[this.quality];
11810
+ let e = _l.QUALITY_PRESETS[this.quality];
11828
11811
  if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
11829
11812
  let t = e[this.scaleFactor];
11830
11813
  if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
@@ -11835,19 +11818,19 @@ var ml = {
11835
11818
  });
11836
11819
  try {
11837
11820
  if (!this._worker) try {
11838
- this._worker = new Worker(dl, { type: "module" });
11821
+ this._worker = new Worker(ml, { type: "module" });
11839
11822
  } catch (e) {
11840
11823
  if (e.name !== "SecurityError") throw e;
11841
- this._worker = await or(dl);
11824
+ this._worker = await or(ml);
11842
11825
  }
11843
11826
  await new Promise((e, n) => {
11844
11827
  let r = (t) => {
11845
11828
  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)));
11846
- }, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } = oc();
11829
+ }, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } = lc();
11847
11830
  this._worker.addEventListener("message", r), this._worker.postMessage({
11848
11831
  type: "load",
11849
11832
  url: t,
11850
- sessionOptions: ml.SESSION_OPTIONS,
11833
+ sessionOptions: _l.SESSION_OPTIONS,
11851
11834
  ortRuntimeUrl: i,
11852
11835
  ortWasmPaths: a,
11853
11836
  cacheNamespace: o
@@ -11917,8 +11900,8 @@ var ml = {
11917
11900
  willReadFrequently: !0,
11918
11901
  alpha: !0
11919
11902
  });
11920
- this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = Zc.get(this.getToneMapping()) || Zc.get(Oe), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
11921
- let o = ml.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
11903
+ this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = el.get(this.getToneMapping()) || el.get(Oe), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
11904
+ let o = _l.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
11922
11905
  for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
11923
11906
  if (e.aborted) throw new DOMException("Aborted", "AbortError");
11924
11907
  let l = Math.min(u * c, Math.max(0, n - s)), p = Math.min(o * c, Math.max(0, r - s)), m = Math.min(s, n - l), h = Math.min(s, r - p), g = this._extractTile(t, l, p, m, h), _ = await this._inferTile(g, m, h), v = l * i, y = p * i, b = m * i, x = h * i, S = this._tensorToImageData(_, b, x, v, y);
@@ -11991,7 +11974,7 @@ var ml = {
11991
11974
  let u = ((n + e) * o + (t + i)) * 4, d = e * r + i;
11992
11975
  if (s) {
11993
11976
  let e = this._hdrToneMapFn, t = this._hdrExposure, n = this._hdrSaturation, r = a[u] * t, i = a[u + 1] * t, o = a[u + 2] * t;
11994
- n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, rl(this._tmOut, n), r = this._tmOut[0], i = this._tmOut[1], o = this._tmOut[2]), e(r, i, o, 1, this._tmOut), l[d] = this._tmOut[0] ** +Qc, l[c + d] = this._tmOut[1] ** +Qc, l[2 * c + d] = this._tmOut[2] ** +Qc;
11977
+ n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, ol(this._tmOut, n), r = this._tmOut[0], i = this._tmOut[1], o = this._tmOut[2]), e(r, i, o, 1, this._tmOut), l[d] = this._tmOut[0] ** +tl, l[c + d] = this._tmOut[1] ** +tl, l[2 * c + d] = this._tmOut[2] ** +tl;
11995
11978
  } else l[d] = a[u] / 255, l[c + d] = a[u + 1] / 255, l[2 * c + d] = a[u + 2] / 255;
11996
11979
  }
11997
11980
  return l;
@@ -12049,10 +12032,10 @@ var ml = {
12049
12032
  this._backupCanvas = document.createElement("canvas"), this._backupCanvas.width = e.width, this._backupCanvas.height = e.height;
12050
12033
  let t = this._backupCanvas.getContext("2d");
12051
12034
  if (e.isHDR) {
12052
- let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = Zc.get(this.getToneMapping()) || Zc.get(Oe), c = this.getExposure(), l = this.getSaturation(), u = new Float32Array(3);
12035
+ let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = el.get(this.getToneMapping()) || el.get(Oe), c = this.getExposure(), l = this.getSaturation(), u = new Float32Array(3);
12053
12036
  for (let e = 0, t = r * i; e < t; e++) {
12054
12037
  let t = e * 4, r = n[t] * c, i = n[t + 1] * c, a = n[t + 2] * c;
12055
- l !== 1 && (u[0] = r, u[1] = i, u[2] = a, rl(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +Qc * 255 + .5 | 0, o[t + 1] = u[1] ** +Qc * 255 + .5 | 0, o[t + 2] = u[2] ** +Qc * 255 + .5 | 0, o[t + 3] = 255;
12038
+ l !== 1 && (u[0] = r, u[1] = i, u[2] = a, ol(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +tl * 255 + .5 | 0, o[t + 1] = u[1] ** +tl * 255 + .5 | 0, o[t + 2] = u[2] ** +tl * 255 + .5 | 0, o[t + 3] = 255;
12056
12039
  }
12057
12040
  t.putImageData(a, 0, 0);
12058
12041
  } else t.putImageData(e, 0, 0);
@@ -12064,7 +12047,7 @@ var ml = {
12064
12047
  this.hdr = !!e;
12065
12048
  }
12066
12049
  setQuality(e) {
12067
- if (!ml.QUALITY_PRESETS[e]) {
12050
+ if (!_l.QUALITY_PRESETS[e]) {
12068
12051
  console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
12069
12052
  return;
12070
12053
  }
@@ -12087,7 +12070,7 @@ var ml = {
12087
12070
  async dispose() {
12088
12071
  this.abort(), this._cleanupPendingWorkerHandlers(), this._worker &&= (this._worker.postMessage({ type: "dispose" }), this._worker.terminate(), null), this._currentModelUrl = null, this._backupCanvas = null, this._upscaledAlpha = null, this.state.abortController = null, this._hdrStagingBuffer?.destroy(), this._hdrStagingBuffer = null, this._hdrStagingWidth = 0, this._hdrStagingHeight = 0, console.log("AIUpscaler disposed");
12089
12072
  }
12090
- }, gl = class extends Ke {
12073
+ }, yl = class extends Ke {
12091
12074
  constructor({ renderer: e, mainCanvas: t, scene: n, camera: r, stages: i, pipeline: a, getExposure: o, getSaturation: s, getTransparentBg: c }) {
12092
12075
  super(), this.renderer = e, this.mainCanvas = t, this.denoiserCanvas = this._createDenoiserCanvas(t), this.scene = n, this.camera = r, this.pipeline = a, this._stages = i, this._getExposure = o, this._getSaturation = s, this._getTransparentBg = c, this.denoiser = null, this.upscaler = null, this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._pendingStartUpscaler = null, this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null;
12093
12076
  }
@@ -12108,7 +12091,7 @@ var ml = {
12108
12091
  setupDenoiser() {
12109
12092
  if (!this.denoiserCanvas) return;
12110
12093
  let e = this._stages.pathTracer;
12111
- this.denoiser = new ul(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
12094
+ this.denoiser = new pl(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
12112
12095
  ...X,
12113
12096
  backendParams: () => ({
12114
12097
  device: this.renderer.backend.device,
@@ -12133,7 +12116,7 @@ var ml = {
12133
12116
  setupUpscaler() {
12134
12117
  if (!this.denoiserCanvas) return;
12135
12118
  let e = this._stages.pathTracer;
12136
- this.upscaler = new hl(this.denoiserCanvas, this.renderer, {
12119
+ this.upscaler = new vl(this.denoiserCanvas, this.renderer, {
12137
12120
  scaleFactor: X.upscalerScale || 2,
12138
12121
  quality: X.upscalerQuality || "fast",
12139
12122
  getSourceCanvas: () => this.denoiser?.enabled ? null : this.renderer.domElement,
@@ -12294,7 +12277,7 @@ var ml = {
12294
12277
  let t = Bn[e];
12295
12278
  t && this._stages.asvgf?.updateParameters(t);
12296
12279
  }
12297
- }, _l = class {
12280
+ }, bl = class {
12298
12281
  constructor() {
12299
12282
  this.layer = "hud", this.visible = !1, this._tileBounds = null, this._imageWidth = 1, this._imageHeight = 1, this.enabled = !0, this._borderColor = "rgba(255, 0, 0, 0.6)", this._borderWidthRatio = 1 / 540, this._borderWidthMin = 1.5, this._borderWidthMax = 4;
12300
12283
  }
@@ -12318,9 +12301,9 @@ var ml = {
12318
12301
  dispose() {
12319
12302
  this.visible = !1;
12320
12303
  }
12321
- }, vl = class {
12304
+ }, xl = class {
12322
12305
  constructor(n, r, i) {
12323
- this.layer = "scene", this.visible = !0, this._outlineNode = Kt(r, i, {
12306
+ this.layer = "scene", this.visible = !0, this._outlineNode = qt(r, i, {
12324
12307
  selectedObjects: [],
12325
12308
  edgeThickness: H(1),
12326
12309
  edgeGlow: H(0)
@@ -12352,7 +12335,7 @@ var ml = {
12352
12335
  dispose() {
12353
12336
  this.visible = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
12354
12337
  }
12355
- }, yl = class {
12338
+ }, Sl = class {
12356
12339
  constructor(e, t) {
12357
12340
  this.renderer = e, this.camera = t, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = document.createElement("canvas"), this._hudCanvas.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;", this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null;
12358
12341
  }
@@ -12367,13 +12350,13 @@ var ml = {
12367
12350
  }
12368
12351
  setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
12369
12352
  this.setHelperScene(e);
12370
- let s = new _l();
12353
+ let s = new bl();
12371
12354
  this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener("resolution_changed", (e) => {
12372
12355
  s.setRenderSize(e.width, e.height);
12373
12356
  }), n.eventBus.on("tile:changed", (e) => {
12374
12357
  e.renderMode === 1 && e.tileBounds && (s.setActiveTile(e.tileBounds), s.show());
12375
12358
  }), n.eventBus.on("pipeline:reset", () => s.hide()), i.addEventListener(Y.RENDER_COMPLETE, () => s.hide()), this._wireDenoiserTileEvents(s, r);
12376
- let c = new vl(this.renderer, t, this.camera);
12359
+ let c = new xl(this.renderer, t, this.camera);
12377
12360
  this.register("outline", c);
12378
12361
  }
12379
12362
  _wireDenoiserTileEvents(e, t) {
@@ -12440,9 +12423,9 @@ var ml = {
12440
12423
  for (let e of this._helpers.values()) e.dispose?.();
12441
12424
  this._helpers.clear(), this._hudCanvas.parentElement && this._hudCanvas.parentElement.removeChild(this._hudCanvas);
12442
12425
  }
12443
- }, bl = class extends Ke {
12426
+ }, Cl = class extends Ke {
12444
12427
  constructor() {
12445
- super(), this.mixer = null, this.timer = new kt(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._tempVec = new Nt(), this._skinnedCache = null, this._totalTriangleCount = 0, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this.wakeCallback = null;
12428
+ super(), this.mixer = null, this.timer = new At(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._tempVec = new Pt(), this._skinnedCache = null, this._totalTriangleCount = 0, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this.wakeCallback = null;
12446
12429
  }
12447
12430
  init(e, t, n, r, i) {
12448
12431
  if (this.dispose(), !r || r.length === 0) return;
@@ -12540,9 +12523,9 @@ var ml = {
12540
12523
  dispose() {
12541
12524
  this.mixer &&= (this.mixer.stopAllAction(), this.mixer.uncacheRoot(this._mixerRoot), null), this.actions = [], this.isPlaying = !1, this.timer.reset(), this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._skinnedCache = null, this._clipsCache = null;
12542
12525
  }
12543
- }, xl = class {
12526
+ }, wl = class {
12544
12527
  constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
12545
- this._app = r, this._orbitControls = n, this._camera = e, this._controls = new qt(e, t), this._gizmoScene = new wt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new Nt(), this._normalMatrix = new nt(), this._refitInFlight = !1, this._baselineComputed = !1, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
12528
+ this._app = r, this._orbitControls = n, this._camera = e, this._controls = new Jt(e, t), this._gizmoScene = new Tt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new Pt(), this._normalMatrix = new nt(), this._refitInFlight = !1, this._baselineComputed = !1, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
12546
12529
  }
12547
12530
  setMeshData(e, t) {
12548
12531
  this._meshes = e, this._meshTriRanges = [], this._skinnedCache = [], this._normalCache = [];
@@ -12651,15 +12634,15 @@ var ml = {
12651
12634
  dispose() {
12652
12635
  this._controls.removeEventListener("dragging-changed", this._onDraggingChanged), this._controls.removeEventListener("objectChange", this._onObjectChange), this.detach(), this._gizmoScene.remove(this._controls.getHelper()), this._controls.dispose(), this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._baselineComputed = !1, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
12653
12636
  }
12654
- }, Sl = /* @__PURE__ */ new WeakMap(), Cl = class extends Ke {
12637
+ }, Tl = /* @__PURE__ */ new WeakMap(), El = class extends Ke {
12655
12638
  constructor(e, t = {}) {
12656
12639
  super();
12657
12640
  try {
12658
- Sl.get(e)?.dispose();
12641
+ Tl.get(e)?.dispose();
12659
12642
  } catch (e) {
12660
12643
  console.warn("PathTracerApp: prior canvas owner dispose failed", e);
12661
12644
  }
12662
- Sl.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new Bc(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new bl(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this.completion = new Pc(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1;
12645
+ Tl.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new Uc(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Cl(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this.completion = new Lc(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1;
12663
12646
  }
12664
12647
  _addTrackedListener(e, t, n) {
12665
12648
  e && (e.addEventListener(t, n), this._trackedListeners.push({
@@ -12708,7 +12691,7 @@ var ml = {
12708
12691
  context: this.pipeline?.context
12709
12692
  }), this.dispatchEvent({ type: "RenderComplete" }), this.dispatchEvent({ type: Y.RENDER_COMPLETE }));
12710
12693
  }
12711
- this._renderHelperOverlay(), this.dispatchEvent({ type: Y.FRAME }), this.renderer.resolveTimestampsAsync?.(At.RENDER), this.renderer.resolveTimestampsAsync?.(At.COMPUTE);
12694
+ this._renderHelperOverlay(), this.dispatchEvent({ type: Y.FRAME }), this.renderer.resolveTimestampsAsync?.(jt.RENDER), this.renderer.resolveTimestampsAsync?.(jt.COMPUTE);
12712
12695
  }
12713
12696
  }
12714
12697
  stopAnimation() {
@@ -12804,7 +12787,7 @@ var ml = {
12804
12787
  }
12805
12788
  async loadSceneData() {
12806
12789
  this.interactionManager?.deselect(), this.animationManager.dispose(), this._animRefitInFlight = !1;
12807
- let e = new gs("loadSceneData"), t = this.meshScene.environment, n = null;
12790
+ let e = new ys("loadSceneData"), t = this.meshScene.environment, n = null;
12808
12791
  if (t?.image?.data && (e.start("Environment CDF build (worker)"), this.stages.pathTracer.scene.environment = t, n = this.stages.pathTracer.environment.buildEnvironmentCDF().then(() => e.end("Environment CDF build (worker)"))), e.start("BVH build (SceneProcessor)"), await this._sdf.buildBVH(this.meshScene), e.end("BVH build (SceneProcessor)"), On({
12809
12792
  status: "Transferring data to GPU...",
12810
12793
  progress: 86
@@ -12937,35 +12920,35 @@ var ml = {
12937
12920
  maxStorageBufferBindingSize: t.maxStorageBufferBindingSize,
12938
12921
  maxColorAttachmentBytesPerSample: 128
12939
12922
  }
12940
- }), await this.renderer.init(), r.setLTC(Pt.init()), this.renderer.workingColorSpace = a, this.renderer.outputColorSpace = a, this.renderer.toneMapping = Oe, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
12923
+ }), await this.renderer.init(), r.setLTC(Ft.init()), this.renderer.workingColorSpace = a, this.renderer.outputColorSpace = a, this.renderer.toneMapping = Oe, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
12941
12924
  }
12942
12925
  _initCameraManager() {
12943
- this.cameraManager = new Vc(this.canvas);
12926
+ this.cameraManager = new Wc(this.canvas);
12944
12927
  }
12945
12928
  _initScenes() {
12946
- this.scene = new wt(), this.meshScene = new wt(), this._sceneHelpers = new Zt();
12929
+ this.scene = new Tt(), this.meshScene = new Tt(), this._sceneHelpers = new Qt();
12947
12930
  }
12948
12931
  _initAssetPipeline() {
12949
- this._sdf = new nc(), this.assetLoader = new Lc(this.meshScene, this.cameraManager.camera, this.cameraManager.controls), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
12932
+ this._sdf = new ac(), this.assetLoader = new Bc(this.meshScene, this.cameraManager.camera, this.cameraManager.controls), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
12950
12933
  this.needsReset = !0, this.wake();
12951
12934
  });
12952
12935
  }
12953
12936
  _initPipeline() {
12954
12937
  this._createStages();
12955
12938
  let { clientWidth: e, clientHeight: t } = this.canvas;
12956
- this.pipeline = new Nc(this.renderer, e || 1, t || 1), this.pipeline.addStage(this.stages.pathTracer), this.pipeline.addStage(this.stages.normalDepth), this.pipeline.addStage(this.stages.motionVector), this.pipeline.addStage(this.stages.ssrc), this.pipeline.addStage(this.stages.asvgf), this.pipeline.addStage(this.stages.variance), this.pipeline.addStage(this.stages.bilateralFilter), this.pipeline.addStage(this.stages.adaptiveSampling), this.pipeline.addStage(this.stages.edgeFilter), this.pipeline.addStage(this.stages.autoExposure), this.pipeline.addStage(this.stages.compositor);
12939
+ this.pipeline = new Ic(this.renderer, e || 1, t || 1), this.pipeline.addStage(this.stages.pathTracer), this.pipeline.addStage(this.stages.normalDepth), this.pipeline.addStage(this.stages.motionVector), this.pipeline.addStage(this.stages.ssrc), this.pipeline.addStage(this.stages.asvgf), this.pipeline.addStage(this.stages.variance), this.pipeline.addStage(this.stages.bilateralFilter), this.pipeline.addStage(this.stages.adaptiveSampling), this.pipeline.addStage(this.stages.edgeFilter), this.pipeline.addStage(this.stages.autoExposure), this.pipeline.addStage(this.stages.compositor);
12957
12940
  let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
12958
12941
  this.pipeline.setSize(n, r);
12959
12942
  }
12960
12943
  _initManagers() {
12961
- this.interactionManager = new Fc({
12944
+ this.interactionManager = new Rc({
12962
12945
  scene: this.meshScene,
12963
12946
  camera: this.cameraManager.camera,
12964
12947
  canvas: this.canvas,
12965
12948
  assetLoader: this.assetLoader,
12966
12949
  pathTracer: null,
12967
12950
  floorPlane: this.assetLoader.floorPlane
12968
- }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new Hc(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new xl({
12951
+ }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new Gc(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new wl({
12969
12952
  camera: this.cameraManager.camera,
12970
12953
  canvas: this.canvas,
12971
12954
  orbitControls: this.cameraManager.controls,
@@ -13036,13 +13019,13 @@ var ml = {
13036
13019
  }
13037
13020
  _createStages() {
13038
13021
  let e = this.settings.get("adaptiveSamplingMax"), t = this.settings.get("useAdaptiveSampling");
13039
- this.stages.pathTracer = new cc(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new lc(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new uc(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.ssrc = new kc(this.renderer, { enabled: !1 }), this.stages.asvgf = new dc(this.renderer, { enabled: !1 }), this.stages.variance = new pc(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new hc(this.renderer, { enabled: !1 }), this.stages.adaptiveSampling = new vc(this.renderer, {
13022
+ this.stages.pathTracer = new dc(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new fc(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new pc(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.ssrc = new Mc(this.renderer, { enabled: !1 }), this.stages.asvgf = new mc(this.renderer, { enabled: !1 }), this.stages.variance = new gc(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new vc(this.renderer, { enabled: !1 }), this.stages.adaptiveSampling = new xc(this.renderer, {
13040
13023
  adaptiveSamplingMax: e,
13041
13024
  enabled: t
13042
- }), this.stages.edgeFilter = new yc(this.renderer, { enabled: !1 }), this.stages.autoExposure = new Ec(this.renderer, { enabled: X.autoExposure ?? !1 }), this.stages.compositor = new Ac(this.renderer, { saturation: this.settings.get("saturation") ?? X.saturation });
13025
+ }), this.stages.edgeFilter = new Sc(this.renderer, { enabled: !1 }), this.stages.autoExposure = new kc(this.renderer, { enabled: X.autoExposure ?? !1 }), this.stages.compositor = new Nc(this.renderer, { saturation: this.settings.get("saturation") ?? X.saturation });
13043
13026
  }
13044
13027
  _setupDenoisingManager() {
13045
- this.denoisingManager = new gl({
13028
+ this.denoisingManager = new yl({
13046
13029
  renderer: this.renderer,
13047
13030
  mainCanvas: this.canvas,
13048
13031
  scene: this.scene,
@@ -13085,7 +13068,7 @@ var ml = {
13085
13068
  this.scene.updateMatrixWorld(), this.overlayManager?.render(), this.transformManager?.render(this.renderer);
13086
13069
  }
13087
13070
  _setupOverlayManager() {
13088
- this.overlayManager = new yl(this.renderer, this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
13071
+ this.overlayManager = new Sl(this.renderer, this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
13089
13072
  helperScene: this._sceneHelpers,
13090
13073
  meshScene: this.meshScene,
13091
13074
  pipeline: this.pipeline,
@@ -13101,7 +13084,7 @@ var ml = {
13101
13084
  _forwardEvents(e, t) {
13102
13085
  if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
13103
13086
  }
13104
- }, wl = class {
13087
+ }, Dl = class {
13105
13088
  constructor(e) {
13106
13089
  this._app = e, this._cancelled = !1, this._rendering = !1;
13107
13090
  }
@@ -13201,6 +13184,6 @@ var ml = {
13201
13184
  }
13202
13185
  };
13203
13186
  //#endregion
13204
- export { Gn as AF_DEFAULTS, Bn as ASVGF_QUALITY_PRESETS, Wn as AUTO_FOCUS_MODES, bl as AnimationManager, Kn as BVH_LEAF_MARKERS, Un as CAMERA_PRESETS, Vn as CAMERA_RANGES, Vc as CameraManager, Jn as DEFAULT_TEXTURE_MATRIX, gl as DenoisingManager, X as ENGINE_DEFAULTS, Y as EngineEvents, Xn as INTERACTIVE_RENDER_CONFIG, Fc as InteractionManager, Hc as LightManager, Zn as MEMORY_CONSTANTS, yl as OverlayManager, Yn as PRODUCTION_RENDER_CONFIG, Cl as PathTracerApp, jc as PipelineContext, Nc as RenderPipeline, Bc as RenderSettings, Sn as RenderStage, Hn as SKY_PRESETS, xn as StageExecutionMode, qn as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, xl as TransformManager, wl as VideoRenderManager, ac as configureAssets, oc as getAssetConfig };
13187
+ export { Gn as AF_DEFAULTS, Bn as ASVGF_QUALITY_PRESETS, Wn as AUTO_FOCUS_MODES, Cl as AnimationManager, Kn as BVH_LEAF_MARKERS, Un as CAMERA_PRESETS, Vn as CAMERA_RANGES, Wc as CameraManager, Jn as DEFAULT_TEXTURE_MATRIX, yl as DenoisingManager, X as ENGINE_DEFAULTS, Y as EngineEvents, Xn as INTERACTIVE_RENDER_CONFIG, Rc as InteractionManager, Gc as LightManager, Zn as MEMORY_CONSTANTS, Sl as OverlayManager, Yn as PRODUCTION_RENDER_CONFIG, El as PathTracerApp, Pc as PipelineContext, Ic as RenderPipeline, Uc as RenderSettings, Sn as RenderStage, Hn as SKY_PRESETS, xn as StageExecutionMode, qn as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, wl as TransformManager, Dl as VideoRenderManager, cc as configureAssets, lc as getAssetConfig };
13205
13188
 
13206
13189
  //# sourceMappingURL=rayzee.es.js.map