rayzee 7.2.0 → 7.2.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/README.md +1 -1
- package/dist/rayzee.es.js +857 -728
- package/dist/rayzee.es.js.map +1 -1
- package/dist/rayzee.umd.js +20 -20
- package/dist/rayzee.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/PathTracerApp.js +6 -1
- package/src/Processor/EmissiveTriangleBuilder.js +39 -5
- package/src/Processor/LightBVHBuilder.js +113 -27
- package/src/Processor/SceneProcessor.js +19 -1
- package/src/Stages/PathTracer.js +1 -0
- package/src/Stages/PathTracerStage.js +14 -3
- package/src/TSL/EmissiveSampling.js +3 -2
- package/src/TSL/LightBVHSampling.js +216 -25
- package/src/TSL/ShadeKernel.js +21 -6
- package/src/managers/UniformManager.js +4 -0
package/dist/rayzee.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
|
-
import { Break as d, Fn as f, If as p, Loop as m, Return 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, floatBitsToUint as ee, floor as te, fract as ne, instanceIndex as re, int as N, ivec2 as P, length as ie, lessThan as ae, localId as oe, log as se, mat3 as ce, max as F, min as le, mix as I, mod as ue, normalize as L, notEqual as de, packSnorm2x16 as fe, packUnorm2x16 as pe, pow as me, reflect as he, refract as ge, sampler as _e, select as R, sign as ve, sin as ye, smoothstep as be, sqrt as xe, step as Se, storage as Ce, struct as we, subgroupAdd as Te, subgroupBroadcast as Ee, subgroupExclusiveAdd as De, tan as Oe, texture as ke, textureLoad as z, textureStore as Ae, uint as B, uintBitsToFloat as je, uniform as V, uniformArray as Me, unpackSnorm2x16 as Ne, unpackUnorm2x16 as
|
|
3
|
-
import { ACESFilmicToneMapping as Be, AdditiveBlending as Ve, AgXToneMapping as He, AnimationMixer as Ue, BackSide as We, Box2 as Ge, Box3 as Ke, BufferGeometry as qe, ByteType as Je, CineonToneMapping as Ye, CircleGeometry as Xe, ClampToEdgeWrapping as Ze, Color as Qe, DataArrayTexture as $e, DataTexture as et, DataUtils as tt, DirectionalLight as nt, DirectionalLightHelper as rt, DoubleSide as it, EquirectangularReflectionMapping as
|
|
2
|
+
import { Break as d, Fn as f, If as p, Loop as m, Return 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, floatBitsToUint as ee, floor as te, fract as ne, instanceIndex as re, int as N, ivec2 as P, length as ie, lessThan as ae, localId as oe, log as se, mat3 as ce, max as F, min as le, mix as I, mod as ue, normalize as L, notEqual as de, packSnorm2x16 as fe, packUnorm2x16 as pe, pow as me, reflect as he, refract as ge, sampler as _e, select as R, sign as ve, sin as ye, smoothstep as be, sqrt as xe, step as Se, storage as Ce, struct as we, subgroupAdd as Te, subgroupBroadcast as Ee, subgroupExclusiveAdd as De, tan as Oe, texture as ke, textureLoad as z, textureStore as Ae, uint as B, uintBitsToFloat as je, uniform as V, uniformArray as Me, unpackSnorm2x16 as Ne, unpackUnorm2x16 as Pe, uv as H, uvec2 as Fe, uvec4 as Ie, vec2 as U, vec3 as W, vec4 as G, wgslFn as K, workgroupArray as Le, workgroupBarrier as Re, workgroupId as ze } from "three/tsl";
|
|
3
|
+
import { ACESFilmicToneMapping as Be, AdditiveBlending as Ve, AgXToneMapping as He, AnimationMixer as Ue, BackSide as We, Box2 as Ge, Box3 as Ke, BufferGeometry as qe, ByteType as Je, CineonToneMapping as Ye, CircleGeometry as Xe, ClampToEdgeWrapping as Ze, Color as Qe, DataArrayTexture as $e, DataTexture as et, DataUtils as tt, DirectionalLight as nt, DirectionalLightHelper as rt, DoubleSide as it, EquirectangularReflectionMapping as at, EventDispatcher as q, Float32BufferAttribute as ot, FloatType as st, FrontSide as ct, Group as lt, HalfFloatType as ut, IntType as dt, LinearFilter as J, LinearSRGBColorSpace as ft, LinearToneMapping as pt, LoadingManager as mt, LoopOnce as ht, LoopRepeat as gt, MathUtils as _t, Matrix3 as vt, Matrix4 as yt, Mesh as bt, MeshBasicMaterial as xt, MeshPhysicalMaterial as St, MeshStandardMaterial as Ct, NearestFilter as wt, NeutralToneMapping as Tt, NoBlending as Et, NoToneMapping as Dt, Object3D as Ot, PerspectiveCamera as kt, PointLight as At, PointLightHelper as jt, Points as Mt, PointsMaterial as Nt, Quaternion as Pt, RGBAFormat as Ft, RGBFormat as It, RGFormat as Lt, Raycaster as Rt, RectAreaLight as zt, RedFormat as Bt, ReinhardToneMapping as Vt, RepeatWrapping as Ht, SRGBColorSpace as Ut, Scene as Wt, ShortType as Gt, SphereGeometry as Kt, SpotLight as qt, SpotLightHelper as Jt, Texture as Yt, TextureLoader as Xt, Timer as Zt, UnsignedByteType as Qt, UnsignedIntType as $t, UnsignedShortType as en, Vector2 as tn, Vector3 as nn } from "three";
|
|
4
4
|
import { RectAreaLightTexturesLib as rn } from "three/addons/lights/RectAreaLightTexturesLib.js";
|
|
5
5
|
import { RectAreaLightHelper as an } from "three/addons/helpers/RectAreaLightHelper.js";
|
|
6
6
|
import { GLTFLoader as on } from "three/addons/loaders/GLTFLoader.js";
|
|
@@ -1057,7 +1057,7 @@ var wr = class {
|
|
|
1057
1057
|
area: Me(new Float32Array(208), "float"),
|
|
1058
1058
|
point: Me(new Float32Array(144), "float"),
|
|
1059
1059
|
spot: Me(new Float32Array(320), "float")
|
|
1060
|
-
}, n("cameraWorldMatrix", new yt(), "mat4"), n("cameraProjectionMatrixInverse", new yt(), "mat4"), n("cameraViewMatrix", new yt(), "mat4"), n("cameraProjectionMatrix", new yt(), "mat4"), r("enableDOF", X.enableDOF), n("focusDistance", X.focusDistance, "float"), n("focalLength", X.focalLength, "float"), n("aperture", X.aperture, "float"), n("apertureScale", 1, "float"), n("anamorphicRatio", X.anamorphicRatio ?? 1, "float"), n("sceneScale", 1, "float"), this._uniforms.set("samplingTechnique", Tn), Tn.value = X.samplingTechnique, n("fireflyThreshold", X.fireflyThreshold, "float"), r("enableEmissiveTriangleSampling", X.enableEmissiveTriangleSampling), n("emissiveBoost", X.emissiveBoost, "float"), n("emissiveTriangleCount", 0, "int"), n("emissiveTotalPower", 0, "float"), n("lightBVHNodeCount", 0, "int"), n("emissiveVec4Offset", 0, "int"), n("renderMode", X.renderMode, "int"), r("enableAlphaShadows", X.enableAlphaShadows), n("resolution", new tn(e, t), "vec2");
|
|
1060
|
+
}, n("cameraWorldMatrix", new yt(), "mat4"), n("cameraProjectionMatrixInverse", new yt(), "mat4"), n("cameraViewMatrix", new yt(), "mat4"), n("cameraProjectionMatrix", new yt(), "mat4"), r("enableDOF", X.enableDOF), n("focusDistance", X.focusDistance, "float"), n("focalLength", X.focalLength, "float"), n("aperture", X.aperture, "float"), n("apertureScale", 1, "float"), n("anamorphicRatio", X.anamorphicRatio ?? 1, "float"), n("sceneScale", 1, "float"), this._uniforms.set("samplingTechnique", Tn), Tn.value = X.samplingTechnique, n("fireflyThreshold", X.fireflyThreshold, "float"), r("enableEmissiveTriangleSampling", X.enableEmissiveTriangleSampling), n("emissiveBoost", X.emissiveBoost, "float"), n("emissiveTriangleCount", 0, "int"), n("emissiveTotalPower", 0, "float"), n("lightBVHNodeCount", 0, "int"), n("emissiveVec4Offset", 0, "int"), n("reverseMapVec4Offset", 0, "int"), n("renderMode", X.renderMode, "int"), r("enableAlphaShadows", X.enableAlphaShadows), n("resolution", new tn(e, t), "vec2");
|
|
1061
1061
|
}
|
|
1062
1062
|
_nameAll() {
|
|
1063
1063
|
for (let [e, t] of this._uniforms) t.name = Tr[e] || e;
|
|
@@ -1619,7 +1619,7 @@ function oi(e, t, n) {
|
|
|
1619
1619
|
}
|
|
1620
1620
|
var si = class {
|
|
1621
1621
|
constructor(e = 512, t = 256) {
|
|
1622
|
-
this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new et(this._pixels, e, t, Ft, st), this._texture.mapping =
|
|
1622
|
+
this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new et(this._pixels, e, t, Ft, st), this._texture.mapping = at, this._texture.colorSpace = ft, this._texture.minFilter = J, this._texture.magFilter = J, this._texture.wrapS = Ht, this._texture.wrapT = Ze, this._texture.generateMipmaps = !1;
|
|
1623
1623
|
}
|
|
1624
1624
|
render(e) {
|
|
1625
1625
|
let t = performance.now(), n = [
|
|
@@ -1637,7 +1637,7 @@ var si = class {
|
|
|
1637
1637
|
return this._texture.needsUpdate = !0, this.lastRenderTime = performance.now() - t, this._texture;
|
|
1638
1638
|
}
|
|
1639
1639
|
setResolution(e, t) {
|
|
1640
|
-
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 et(this._pixels, e, t, Ft, st), this._texture.mapping =
|
|
1640
|
+
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 et(this._pixels, e, t, Ft, st), this._texture.mapping = at, this._texture.colorSpace = ft, this._texture.minFilter = J, this._texture.magFilter = J, this._texture.wrapS = Ht, this._texture.wrapT = Ze, this._texture.generateMipmaps = !1);
|
|
1641
1641
|
}
|
|
1642
1642
|
getLastRenderTime() {
|
|
1643
1643
|
return this.lastRenderTime;
|
|
@@ -1647,7 +1647,7 @@ var si = class {
|
|
|
1647
1647
|
}
|
|
1648
1648
|
}, ci = class {
|
|
1649
1649
|
constructor(e = 512, t = 256) {
|
|
1650
|
-
this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new et(this._pixels, e, t, Ft, st), this._texture.mapping =
|
|
1650
|
+
this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new et(this._pixels, e, t, Ft, st), this._texture.mapping = at, this._texture.colorSpace = ft, this._texture.minFilter = J, this._texture.magFilter = J, this._texture.wrapS = Ht, this._texture.wrapT = Ze, this._texture.generateMipmaps = !1;
|
|
1651
1651
|
}
|
|
1652
1652
|
renderGradient(e) {
|
|
1653
1653
|
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;
|
|
@@ -1676,7 +1676,7 @@ var si = class {
|
|
|
1676
1676
|
return this._texture.needsUpdate = !0, this.lastRenderTime = performance.now() - t, this._texture;
|
|
1677
1677
|
}
|
|
1678
1678
|
setResolution(e, t) {
|
|
1679
|
-
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 et(this._pixels, e, t, Ft, st), this._texture.mapping =
|
|
1679
|
+
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 et(this._pixels, e, t, Ft, st), this._texture.mapping = at, this._texture.colorSpace = ft, this._texture.minFilter = J, this._texture.magFilter = J, this._texture.wrapS = Ht, this._texture.wrapT = Ze, this._texture.generateMipmaps = !1);
|
|
1680
1680
|
}
|
|
1681
1681
|
getLastRenderTime() {
|
|
1682
1682
|
return this.lastRenderTime;
|
|
@@ -5543,45 +5543,61 @@ var cs = 128, ls = class {
|
|
|
5543
5543
|
let t = e.length;
|
|
5544
5544
|
if (t === 0) {
|
|
5545
5545
|
let e = new Float32Array(16);
|
|
5546
|
-
return e[7] = 1, {
|
|
5546
|
+
return e[7] = 1, e[14] = 1, e[15] = -1, {
|
|
5547
5547
|
nodeData: e,
|
|
5548
5548
|
nodeCount: 1,
|
|
5549
|
-
sortedPerm: new Int32Array()
|
|
5549
|
+
sortedPerm: new Int32Array(),
|
|
5550
|
+
bitTrails: new Float32Array()
|
|
5550
5551
|
};
|
|
5551
5552
|
}
|
|
5552
5553
|
let n = new Int32Array(t);
|
|
5553
5554
|
for (let e = 0; e < t; e++) n[e] = e;
|
|
5554
|
-
let r = 2 * t + 4, i = new Float32Array(r * 16), a = 0, o = (t, r) => {
|
|
5555
|
-
let
|
|
5555
|
+
let r = 2 * t + 4, i = new Float32Array(r * 16), a = 0, o = new Float32Array(t), s = (t, r, c, l) => {
|
|
5556
|
+
let u = a++, d = u * 16, f = Infinity, p = Infinity, m = Infinity, h = -Infinity, g = -Infinity, _ = -Infinity, v = 0, y = Infinity, b = Infinity, x = Infinity, S = -Infinity, C = -Infinity, w = -Infinity;
|
|
5556
5557
|
for (let i = t; i < r; i++) {
|
|
5557
5558
|
let t = e[n[i]];
|
|
5558
|
-
|
|
5559
|
-
}
|
|
5560
|
-
i[
|
|
5561
|
-
let
|
|
5562
|
-
if (
|
|
5563
|
-
|
|
5564
|
-
let
|
|
5565
|
-
|
|
5566
|
-
|
|
5559
|
+
f = Math.min(f, t.bMinX), p = Math.min(p, t.bMinY), m = Math.min(m, t.bMinZ), h = Math.max(h, t.bMaxX), g = Math.max(g, t.bMaxY), _ = Math.max(_, t.bMaxZ), v += t.power, y = Math.min(y, t.cx), b = Math.min(b, t.cy), x = Math.min(x, t.cz), S = Math.max(S, t.cx), C = Math.max(C, t.cy), w = Math.max(w, t.cz);
|
|
5560
|
+
}
|
|
5561
|
+
i[d + 0] = f, i[d + 1] = p, i[d + 2] = m, i[d + 3] = v, i[d + 4] = h, i[d + 5] = g, i[d + 6] = _;
|
|
5562
|
+
let T = r - t, E;
|
|
5563
|
+
if (T <= this.maxLeafSize) {
|
|
5564
|
+
i[d + 7] = 1, i[d + 8] = t, i[d + 9] = T, i[d + 10] = 0, i[d + 11] = 0, E = null;
|
|
5565
|
+
for (let i = t; i < r; i++) {
|
|
5566
|
+
let t = e[n[i]];
|
|
5567
|
+
E = fs(E, ds(t)), o[i] = c;
|
|
5568
|
+
}
|
|
5569
|
+
E ||= {
|
|
5570
|
+
ax: 0,
|
|
5571
|
+
ay: 0,
|
|
5572
|
+
az: 1,
|
|
5573
|
+
cosO: -1
|
|
5574
|
+
};
|
|
5575
|
+
} else {
|
|
5576
|
+
let a = S - y, o = C - b, u = w - x, f;
|
|
5577
|
+
f = a >= o && a >= u ? 0 : o >= u ? 1 : 2;
|
|
5578
|
+
let p = [
|
|
5567
5579
|
"cx",
|
|
5568
5580
|
"cy",
|
|
5569
5581
|
"cz"
|
|
5570
|
-
][
|
|
5571
|
-
this._nthElement(n, e, t, r,
|
|
5572
|
-
let
|
|
5573
|
-
i[
|
|
5574
|
-
}
|
|
5575
|
-
return
|
|
5582
|
+
][f], m = t + r >> 1;
|
|
5583
|
+
this._nthElement(n, e, t, r, m, p), i[d + 7] = 0;
|
|
5584
|
+
let h = s(t, m, c, l + 1), g = s(m, r, c + 2 ** l, l + 1);
|
|
5585
|
+
i[d + 8] = h.nodeIndex, i[d + 9] = g.nodeIndex, i[d + 10] = 0, i[d + 11] = 0, E = fs(h.cone, g.cone);
|
|
5586
|
+
}
|
|
5587
|
+
return i[d + 12] = E.ax, i[d + 13] = E.ay, i[d + 14] = E.az, i[d + 15] = E.cosO, {
|
|
5588
|
+
nodeIndex: u,
|
|
5589
|
+
cone: E
|
|
5590
|
+
};
|
|
5576
5591
|
};
|
|
5577
|
-
|
|
5578
|
-
let
|
|
5579
|
-
for (let e = 0; e < t; e++)
|
|
5580
|
-
let
|
|
5581
|
-
return
|
|
5582
|
-
nodeData:
|
|
5592
|
+
s(0, t, 0, 0);
|
|
5593
|
+
let c = new Int32Array(t);
|
|
5594
|
+
for (let e = 0; e < t; e++) c[e] = n[e];
|
|
5595
|
+
let l = new Float32Array(a * 16);
|
|
5596
|
+
return l.set(i.subarray(0, a * 16)), console.log(`[LightBVHBuilder] Built BVH: ${a} nodes for ${t} emissive triangles`), {
|
|
5597
|
+
nodeData: l,
|
|
5583
5598
|
nodeCount: a,
|
|
5584
|
-
sortedPerm:
|
|
5599
|
+
sortedPerm: c,
|
|
5600
|
+
bitTrails: o
|
|
5585
5601
|
};
|
|
5586
5602
|
}
|
|
5587
5603
|
_nthElement(e, t, n, r, i, a) {
|
|
@@ -5594,12 +5610,58 @@ var cs = 128, ls = class {
|
|
|
5594
5610
|
l < i ? n = l + 1 : r = l;
|
|
5595
5611
|
}
|
|
5596
5612
|
}
|
|
5597
|
-
}
|
|
5613
|
+
};
|
|
5614
|
+
function ds(e) {
|
|
5615
|
+
return e.twoSided ? {
|
|
5616
|
+
ax: e.nx,
|
|
5617
|
+
ay: e.ny,
|
|
5618
|
+
az: e.nz,
|
|
5619
|
+
cosO: -1
|
|
5620
|
+
} : {
|
|
5621
|
+
ax: e.nx,
|
|
5622
|
+
ay: e.ny,
|
|
5623
|
+
az: e.nz,
|
|
5624
|
+
cosO: 1
|
|
5625
|
+
};
|
|
5626
|
+
}
|
|
5627
|
+
function fs(e, t) {
|
|
5628
|
+
if (!e) return t;
|
|
5629
|
+
if (!t || e.cosO <= -1) return e;
|
|
5630
|
+
if (t.cosO <= -1) return t;
|
|
5631
|
+
let n = Math.min(Math.max(e.cosO, -1), 1), r = Math.min(Math.max(t.cosO, -1), 1), i = Math.acos(n), a = Math.acos(r), o = Math.min(Math.max(e.ax * t.ax + e.ay * t.ay + e.az * t.az, -1), 1), s = Math.acos(o);
|
|
5632
|
+
if (Math.min(s + a, Math.PI) <= i) return e;
|
|
5633
|
+
if (Math.min(s + i, Math.PI) <= a) return t;
|
|
5634
|
+
let c = (i + a + s) * .5;
|
|
5635
|
+
if (c >= Math.PI) return {
|
|
5636
|
+
ax: e.ax,
|
|
5637
|
+
ay: e.ay,
|
|
5638
|
+
az: e.az,
|
|
5639
|
+
cosO: -1
|
|
5640
|
+
};
|
|
5641
|
+
let l = c - i, u = e.ay * t.az - e.az * t.ay, d = e.az * t.ax - e.ax * t.az, f = e.ax * t.ay - e.ay * t.ax, p = Math.sqrt(u * u + d * d + f * f);
|
|
5642
|
+
if (p < 1e-8) return {
|
|
5643
|
+
ax: e.ax,
|
|
5644
|
+
ay: e.ay,
|
|
5645
|
+
az: e.az,
|
|
5646
|
+
cosO: -1
|
|
5647
|
+
};
|
|
5648
|
+
u /= p, d /= p, f /= p;
|
|
5649
|
+
let m = Math.cos(l), h = Math.sin(l), g = u * e.ax + d * e.ay + f * e.az, _ = d * e.az - f * e.ay, v = f * e.ax - u * e.az, y = u * e.ay - d * e.ax, b = e.ax * m + _ * h + u * g * (1 - m), x = e.ay * m + v * h + d * g * (1 - m), S = e.az * m + y * h + f * g * (1 - m), C = Math.sqrt(b * b + x * x + S * S) || 1;
|
|
5650
|
+
return {
|
|
5651
|
+
ax: b / C,
|
|
5652
|
+
ay: x / C,
|
|
5653
|
+
az: S / C,
|
|
5654
|
+
cosO: Math.cos(c)
|
|
5655
|
+
};
|
|
5656
|
+
}
|
|
5657
|
+
//#endregion
|
|
5658
|
+
//#region src/Processor/EmissiveTriangleBuilder.js
|
|
5659
|
+
var ps = class {
|
|
5598
5660
|
constructor() {
|
|
5599
|
-
this.emissiveTriangles = [], this.emissiveCount = 0, this.totalEmissivePower = 0, this.emissiveIndicesArray = null, this.emissivePowerArray = null, this.cdfArray = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0;
|
|
5661
|
+
this.emissiveTriangles = [], this.emissiveCount = 0, this.totalEmissivePower = 0, this.emissiveIndicesArray = null, this.emissivePowerArray = null, this.cdfArray = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0, this.emissiveBitTrailMap = null, this._totalTriangleCount = 0;
|
|
5600
5662
|
}
|
|
5601
5663
|
extractEmissiveTriangles(e, t, n) {
|
|
5602
|
-
console.log("[EmissiveTriangleBuilder] Extracting emissive triangles..."), this.emissiveTriangles = [], this.totalEmissivePower = 0;
|
|
5664
|
+
console.log("[EmissiveTriangleBuilder] Extracting emissive triangles..."), this.emissiveTriangles = [], this.totalEmissivePower = 0, this._totalTriangleCount = n;
|
|
5603
5665
|
let r = Z.FLOATS_PER_TRIANGLE, i = Z.UV_C_MAT_OFFSET + 2;
|
|
5604
5666
|
for (let a = 0; a < n; a++) {
|
|
5605
5667
|
let n = a * r, o = Math.floor(e[n + i]), s = t[o];
|
|
@@ -5610,28 +5672,34 @@ var cs = 128, ls = class {
|
|
|
5610
5672
|
b: 0
|
|
5611
5673
|
}, l = s.emissiveIntensity || 0;
|
|
5612
5674
|
if (l > 0 && (c.r > 0 || c.g > 0 || c.b > 0)) {
|
|
5613
|
-
let t = e[n + 0], r = e[n + 1], i = e[n + 2],
|
|
5675
|
+
let t = e[n + 0], r = e[n + 1], i = e[n + 2], u = e[n + 4], d = e[n + 5], f = e[n + 6], p = e[n + 8], m = e[n + 9], h = e[n + 10], g = this._calculateTriangleArea(t, r, i, u, d, f, p, m, h), _ = (.2126 * c.r + .7152 * c.g + .0722 * c.b) * l * g, v = (d - r) * (h - i) - (f - i) * (m - r), y = (f - i) * (p - t) - (u - t) * (h - i), b = (u - t) * (m - r) - (d - r) * (p - t), x = Math.sqrt(v * v + y * y + b * b) || 1, S = s.side === 1 ? -1 : 1;
|
|
5676
|
+
v = v / x * S, y = y / x * S, b = b / x * S;
|
|
5677
|
+
let C = s.side === 2, w = (t + u + p) / 3, T = (r + d + m) / 3, E = (i + f + h) / 3, D = Math.min(t, u, p), O = Math.min(r, d, m), k = Math.min(i, f, h), A = Math.max(t, u, p), j = Math.max(r, d, m), M = Math.max(i, f, h);
|
|
5614
5678
|
this.emissiveTriangles.push({
|
|
5615
5679
|
triangleIndex: a,
|
|
5616
5680
|
materialIndex: o,
|
|
5617
|
-
power:
|
|
5618
|
-
area:
|
|
5681
|
+
power: _,
|
|
5682
|
+
area: g,
|
|
5619
5683
|
emissive: {
|
|
5620
5684
|
r: c.r,
|
|
5621
5685
|
g: c.g,
|
|
5622
5686
|
b: c.b
|
|
5623
5687
|
},
|
|
5624
5688
|
emissiveIntensity: l,
|
|
5625
|
-
cx:
|
|
5626
|
-
cy:
|
|
5627
|
-
cz:
|
|
5628
|
-
bMinX:
|
|
5629
|
-
bMinY:
|
|
5630
|
-
bMinZ:
|
|
5631
|
-
bMaxX:
|
|
5632
|
-
bMaxY:
|
|
5633
|
-
bMaxZ:
|
|
5634
|
-
|
|
5689
|
+
cx: w,
|
|
5690
|
+
cy: T,
|
|
5691
|
+
cz: E,
|
|
5692
|
+
bMinX: D,
|
|
5693
|
+
bMinY: O,
|
|
5694
|
+
bMinZ: k,
|
|
5695
|
+
bMaxX: A,
|
|
5696
|
+
bMaxY: j,
|
|
5697
|
+
bMaxZ: M,
|
|
5698
|
+
nx: v,
|
|
5699
|
+
ny: y,
|
|
5700
|
+
nz: b,
|
|
5701
|
+
twoSided: C
|
|
5702
|
+
}), this.totalEmissivePower += _;
|
|
5635
5703
|
}
|
|
5636
5704
|
}
|
|
5637
5705
|
return this.emissiveCount = this.emissiveTriangles.length, console.log(`[EmissiveTriangleBuilder] Found ${this.emissiveCount} emissive triangles (${(this.emissiveCount / n * 100).toFixed(2)}%)`), console.log(`[EmissiveTriangleBuilder] Total emissive power: ${this.totalEmissivePower.toFixed(2)}`), this._buildDataArrays(), this.emissiveCount;
|
|
@@ -5737,9 +5805,14 @@ var cs = 128, ls = class {
|
|
|
5737
5805
|
return this._buildCDF(), !0;
|
|
5738
5806
|
}
|
|
5739
5807
|
buildLightBVH() {
|
|
5740
|
-
if (this.emissiveCount === 0) return this.lightBVHNodeData = new Float32Array(16), this.lightBVHNodeData[7] = 1, this.lightBVHNodeCount = 1, 1;
|
|
5741
|
-
let { nodeData: e, nodeCount: t, sortedPerm: n } = new us().build(this.emissiveTriangles);
|
|
5742
|
-
|
|
5808
|
+
if (this.emissiveCount === 0) return this.lightBVHNodeData = new Float32Array(16), this.lightBVHNodeData[7] = 1, this.lightBVHNodeData[14] = 1, this.lightBVHNodeData[15] = -1, this.lightBVHNodeCount = 1, this.emissiveBitTrailMap = new Float32Array(Math.max(this._totalTriangleCount, 1)).fill(-1), 1;
|
|
5809
|
+
let { nodeData: e, nodeCount: t, sortedPerm: n, bitTrails: r } = new us().build(this.emissiveTriangles);
|
|
5810
|
+
this.lightBVHNodeData = e, this.lightBVHNodeCount = t, this._rebuildSortedEmissiveData(n), this.emissiveBitTrailMap = new Float32Array(Math.max(this._totalTriangleCount, 1)).fill(-1);
|
|
5811
|
+
for (let e = 0; e < n.length; e++) {
|
|
5812
|
+
let t = this.emissiveTriangles[n[e]].triangleIndex;
|
|
5813
|
+
this.emissiveBitTrailMap[t] = r[e];
|
|
5814
|
+
}
|
|
5815
|
+
return t;
|
|
5743
5816
|
}
|
|
5744
5817
|
_rebuildSortedEmissiveData(e) {
|
|
5745
5818
|
let t = e.length;
|
|
@@ -5757,9 +5830,9 @@ var cs = 128, ls = class {
|
|
|
5757
5830
|
this.emissiveTriangleData = n, console.log(`[EmissiveTriangleBuilder] Rebuilt sorted emissive data: ${t} entries`);
|
|
5758
5831
|
}
|
|
5759
5832
|
clear() {
|
|
5760
|
-
this.emissiveTriangles = [], this.emissiveCount = 0, this.totalEmissivePower = 0, this.emissiveIndicesArray = null, this.emissivePowerArray = null, this.cdfArray = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0;
|
|
5833
|
+
this.emissiveTriangles = [], this.emissiveCount = 0, this.totalEmissivePower = 0, this.emissiveIndicesArray = null, this.emissivePowerArray = null, this.cdfArray = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0, this.emissiveBitTrailMap = null, this._totalTriangleCount = 0;
|
|
5761
5834
|
}
|
|
5762
|
-
},
|
|
5835
|
+
}, ms = class {
|
|
5763
5836
|
constructor(e = "Build") {
|
|
5764
5837
|
this.label = e, this.entries = /* @__PURE__ */ new Map(), this.order = [], this.totalStart = performance.now();
|
|
5765
5838
|
}
|
|
@@ -5786,7 +5859,7 @@ var cs = 128, ls = class {
|
|
|
5786
5859
|
total: Math.round(e)
|
|
5787
5860
|
};
|
|
5788
5861
|
}
|
|
5789
|
-
},
|
|
5862
|
+
}, hs = "" + new URL("assets/BVHRefitWorker-GkmNJYvb.js", import.meta.url).href, gs = class {
|
|
5790
5863
|
constructor(e = {}) {
|
|
5791
5864
|
this.config = {
|
|
5792
5865
|
useWorkers: !0,
|
|
@@ -5801,7 +5874,7 @@ var cs = 128, ls = class {
|
|
|
5801
5874
|
treeletOptimizationPasses: 1,
|
|
5802
5875
|
treeletMinImprovement: .01,
|
|
5803
5876
|
...e
|
|
5804
|
-
}, this.triangleData = null, this.triangleCount = 0, this.materials = [], this.maps = [], this.normalMaps = [], this.bumpMaps = [], this.roughnessMaps = [], this.metalnessMaps = [], this.emissiveMaps = [], this.displacementMaps = [], this.directionalLights = [], this.cameras = [], this.spheres = [], this.bvhRoot = null, this.bvhData = null, this.materialData = null, this.instanceTable = null, this.originalToBvhMap = null, this._refitWorker = null, this._refitSharedBuffers = null, this._rebuildGeneration = 0, this._pendingRebuilds = /* @__PURE__ */ new Map(), this.albedoTextures = null, this.normalTextures = null, this.bumpTextures = null, this.roughnessTextures = null, this.metalnessTextures = null, this.emissiveTextures = null, this.displacementTextures = null, this.emissiveTriangleData = null, this.emissiveTriangleCount = 0, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0, this._initProcessors(), this.isProcessing = !1, this.processingStage = null, this.performanceMetrics = {
|
|
5877
|
+
}, this.triangleData = null, this.triangleCount = 0, this.materials = [], this.maps = [], this.normalMaps = [], this.bumpMaps = [], this.roughnessMaps = [], this.metalnessMaps = [], this.emissiveMaps = [], this.displacementMaps = [], this.directionalLights = [], this.cameras = [], this.spheres = [], this.bvhRoot = null, this.bvhData = null, this.materialData = null, this.instanceTable = null, this.originalToBvhMap = null, this._refitWorker = null, this._refitSharedBuffers = null, this._rebuildGeneration = 0, this._pendingRebuilds = /* @__PURE__ */ new Map(), this.albedoTextures = null, this.normalTextures = null, this.bumpTextures = null, this.roughnessTextures = null, this.metalnessTextures = null, this.emissiveTextures = null, this.displacementTextures = null, this.emissiveTriangleData = null, this.emissiveTriangleCount = 0, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0, this.emissiveBitTrailMap = null, this._initProcessors(), this.isProcessing = !1, this.processingStage = null, this.performanceMetrics = {
|
|
5805
5878
|
textureCreationTime: 0,
|
|
5806
5879
|
geometryExtractionTime: 0,
|
|
5807
5880
|
bvhBuildTime: 0,
|
|
@@ -5814,7 +5887,7 @@ var cs = 128, ls = class {
|
|
|
5814
5887
|
size: this.config.treeletSize,
|
|
5815
5888
|
passes: this.config.treeletOptimizationPasses,
|
|
5816
5889
|
minImprovement: this.config.treeletMinImprovement
|
|
5817
|
-
}), this.textureCreator = new os(), this.emissiveTriangleBuilder = new
|
|
5890
|
+
}), this.textureCreator = new os(), this.emissiveTriangleBuilder = new ps(), this.tlasBuilder = new es();
|
|
5818
5891
|
}
|
|
5819
5892
|
_log(e, t) {
|
|
5820
5893
|
this.config.verbose && console.log(`[SceneProcessor] ${e}`, t || "");
|
|
@@ -5822,7 +5895,7 @@ var cs = 128, ls = class {
|
|
|
5822
5895
|
async buildBVH(e) {
|
|
5823
5896
|
if (this.isProcessing) throw Error("Already processing a scene. Call dispose() first.");
|
|
5824
5897
|
this.isProcessing = !0, this.processingStage = "init";
|
|
5825
|
-
let t = new
|
|
5898
|
+
let t = new ms(`SceneProcessor (${e.name || "scene"})`);
|
|
5826
5899
|
try {
|
|
5827
5900
|
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)");
|
|
5828
5901
|
let n = !1, r = this._buildBVH().then(() => t.end("BVH construction (worker)")), i = this._createMaterialTextures().then(() => {
|
|
@@ -6089,13 +6162,13 @@ var cs = 128, ls = class {
|
|
|
6089
6162
|
}
|
|
6090
6163
|
}
|
|
6091
6164
|
_buildEmissiveData() {
|
|
6092
|
-
this.emissiveTriangleCount = this.emissiveTriangleBuilder.extractEmissiveTriangles(this.triangleData, this.materials, this.triangleCount), this.emissiveTriangleData = this.emissiveTriangleBuilder.createEmissiveRawData(), this.emissiveTotalPower = this.emissiveTriangleBuilder.totalEmissivePower, this._log("Emissive triangle extraction complete", this.emissiveTriangleBuilder.getStats()), this.emissiveTriangleBuilder.buildLightBVH(), this.lightBVHNodeData = this.emissiveTriangleBuilder.lightBVHNodeData, this.lightBVHNodeCount = this.emissiveTriangleBuilder.lightBVHNodeCount, this.emissiveTriangleData = this.emissiveTriangleBuilder.emissiveTriangleData || this.emissiveTriangleData;
|
|
6165
|
+
this.emissiveTriangleCount = this.emissiveTriangleBuilder.extractEmissiveTriangles(this.triangleData, this.materials, this.triangleCount), this.emissiveTriangleData = this.emissiveTriangleBuilder.createEmissiveRawData(), this.emissiveTotalPower = this.emissiveTriangleBuilder.totalEmissivePower, this._log("Emissive triangle extraction complete", this.emissiveTriangleBuilder.getStats()), this.emissiveTriangleBuilder.buildLightBVH(), this.lightBVHNodeData = this.emissiveTriangleBuilder.lightBVHNodeData, this.lightBVHNodeCount = this.emissiveTriangleBuilder.lightBVHNodeCount, this.emissiveTriangleData = this.emissiveTriangleBuilder.emissiveTriangleData || this.emissiveTriangleData, this.emissiveBitTrailMap = this.emissiveTriangleBuilder.emissiveBitTrailMap;
|
|
6093
6166
|
}
|
|
6094
6167
|
_createSpheres() {
|
|
6095
6168
|
return [];
|
|
6096
6169
|
}
|
|
6097
6170
|
_reset() {
|
|
6098
|
-
this._disposeTextures(), this.triangles = [], this.triangleData = null, this.triangleCount = 0, this.materials = [], this.meshTriangleRanges = null, this.maps = [], this.normalMaps = [], this.bumpMaps = [], this.roughnessMaps = [], this.metalnessMaps = [], this.emissiveMaps = [], this.displacementMaps = [], this.directionalLights = [], this.cameras = [], this.spheres = [], this.bvhRoot = null, this.bvhData = null, this.instanceTable = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0, this.performanceMetrics = {
|
|
6171
|
+
this._disposeTextures(), this.triangles = [], this.triangleData = null, this.triangleCount = 0, this.materials = [], this.meshTriangleRanges = null, this.maps = [], this.normalMaps = [], this.bumpMaps = [], this.roughnessMaps = [], this.metalnessMaps = [], this.emissiveMaps = [], this.displacementMaps = [], this.directionalLights = [], this.cameras = [], this.spheres = [], this.bvhRoot = null, this.bvhData = null, this.instanceTable = null, this.lightBVHNodeData = null, this.lightBVHNodeCount = 0, this.emissiveBitTrailMap = null, this.performanceMetrics = {
|
|
6099
6172
|
textureCreationTime: 0,
|
|
6100
6173
|
geometryExtractionTime: 0,
|
|
6101
6174
|
bvhBuildTime: 0,
|
|
@@ -6198,10 +6271,10 @@ var cs = 128, ls = class {
|
|
|
6198
6271
|
async refitBVH(e, t) {
|
|
6199
6272
|
if (!this.bvhData || !this.triangleData || !this.originalToBvhMap) throw Error("No BVH data available for refit. Run buildBVH() first.");
|
|
6200
6273
|
if (!this._refitWorker) try {
|
|
6201
|
-
this._refitWorker = new Worker(
|
|
6274
|
+
this._refitWorker = new Worker(hs, { type: "module" });
|
|
6202
6275
|
} catch (e) {
|
|
6203
6276
|
if (e.name !== "SecurityError") throw e;
|
|
6204
|
-
this._refitWorker = await Nr(
|
|
6277
|
+
this._refitWorker = await Nr(hs);
|
|
6205
6278
|
}
|
|
6206
6279
|
if (!this._refitSharedBuffers) {
|
|
6207
6280
|
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);
|
|
@@ -6270,16 +6343,19 @@ var cs = 128, ls = class {
|
|
|
6270
6343
|
metalnessMaps: this.metalnessTextures,
|
|
6271
6344
|
emissiveMaps: this.emissiveTextures,
|
|
6272
6345
|
displacementMaps: this.displacementTextures
|
|
6273
|
-
}), this.emissiveTriangleData && e.setEmissiveTriangleData(this.emissiveTriangleData, this.emissiveTriangleCount, this.emissiveTotalPower), this.lightBVHNodeData && e.setLightBVHData(this.lightBVHNodeData, this.lightBVHNodeCount), t.transferSceneLights(n), !0) : (console.error("SceneProcessor: Failed to get BVH data"), !1)) : (console.error("SceneProcessor: Failed to get triangle data"), !1);
|
|
6346
|
+
}), this.emissiveTriangleData && e.setEmissiveTriangleData(this.emissiveTriangleData, this.emissiveTriangleCount, this.emissiveTotalPower, this.emissiveBitTrailMap), this.lightBVHNodeData && e.setLightBVHData(this.lightBVHNodeData, this.lightBVHNodeCount), t.transferSceneLights(n), !0) : (console.error("SceneProcessor: Failed to get BVH data"), !1)) : (console.error("SceneProcessor: Failed to get triangle data"), !1);
|
|
6274
6347
|
}
|
|
6275
6348
|
updateMaterialEmissive(e, t, n) {
|
|
6276
6349
|
if (!this.emissiveTriangleBuilder) return null;
|
|
6277
6350
|
let r = this.materials[e];
|
|
6278
|
-
return !r || (t === "emissive" ? r.emissive = n : t === "emissiveIntensity" && (r.emissiveIntensity = n), !this.emissiveTriangleBuilder.updateMaterialEmissive(e, r, this.triangleData, this.materials, this.triangleCount)) ? null : {
|
|
6279
|
-
rawData: this.emissiveTriangleBuilder.
|
|
6351
|
+
return !r || (t === "emissive" ? r.emissive = n : t === "emissiveIntensity" && (r.emissiveIntensity = n), !this.emissiveTriangleBuilder.updateMaterialEmissive(e, r, this.triangleData, this.materials, this.triangleCount)) ? null : (this.emissiveTriangleBuilder.buildLightBVH(), this.lightBVHNodeData = this.emissiveTriangleBuilder.lightBVHNodeData, this.lightBVHNodeCount = this.emissiveTriangleBuilder.lightBVHNodeCount, this.emissiveTriangleData = this.emissiveTriangleBuilder.emissiveTriangleData, this.emissiveBitTrailMap = this.emissiveTriangleBuilder.emissiveBitTrailMap, this.emissiveTriangleCount = this.emissiveTriangleBuilder.emissiveCount, this.emissiveTotalPower = this.emissiveTriangleBuilder.totalEmissivePower, {
|
|
6352
|
+
rawData: this.emissiveTriangleBuilder.emissiveTriangleData,
|
|
6280
6353
|
emissiveCount: this.emissiveTriangleBuilder.emissiveCount,
|
|
6281
|
-
totalPower: this.emissiveTriangleBuilder.totalEmissivePower
|
|
6282
|
-
|
|
6354
|
+
totalPower: this.emissiveTriangleBuilder.totalEmissivePower,
|
|
6355
|
+
bitTrailMap: this.emissiveBitTrailMap,
|
|
6356
|
+
lightBVHNodeData: this.lightBVHNodeData,
|
|
6357
|
+
lightBVHNodeCount: this.lightBVHNodeCount
|
|
6358
|
+
});
|
|
6283
6359
|
}
|
|
6284
6360
|
_updateMeshTrianglePositions(e, t) {
|
|
6285
6361
|
let n = Z.FLOATS_PER_TRIANGLE, r = Z.POSITION_A_OFFSET, i = Z.POSITION_B_OFFSET, a = Z.POSITION_C_OFFSET, o = Z.NORMAL_A_OFFSET, s = Z.NORMAL_B_OFFSET, c = Z.NORMAL_C_OFFSET, l = e.bvhToOriginal;
|
|
@@ -6401,7 +6477,7 @@ var cs = 128, ls = class {
|
|
|
6401
6477
|
dispose() {
|
|
6402
6478
|
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;
|
|
6403
6479
|
}
|
|
6404
|
-
},
|
|
6480
|
+
}, _s = class {
|
|
6405
6481
|
constructor() {
|
|
6406
6482
|
this.lightData = {
|
|
6407
6483
|
directional: [],
|
|
@@ -6564,7 +6640,7 @@ var cs = 128, ls = class {
|
|
|
6564
6640
|
}))
|
|
6565
6641
|
};
|
|
6566
6642
|
}
|
|
6567
|
-
},
|
|
6643
|
+
}, vs = {
|
|
6568
6644
|
stbnScalarAtlas: "https://assets.rayzee.atulmourya.com/noise/stbn_scalar_atlas.png",
|
|
6569
6645
|
stbnVec2Atlas: "https://assets.rayzee.atulmourya.com/noise/stbn_vec2_atlas.png",
|
|
6570
6646
|
ortRuntimeUrl: "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/ort.webgpu.bundle.min.mjs",
|
|
@@ -6575,22 +6651,22 @@ var cs = 128, ls = class {
|
|
|
6575
6651
|
upscalerModelBaseUrl: "https://huggingface.co/notaneimu/onnx-image-models/resolve/main/",
|
|
6576
6652
|
cacheNamespace: "rayzee"
|
|
6577
6653
|
};
|
|
6578
|
-
function
|
|
6579
|
-
e && Object.assign(
|
|
6654
|
+
function ys(e) {
|
|
6655
|
+
e && Object.assign(vs, e);
|
|
6580
6656
|
}
|
|
6581
|
-
function
|
|
6582
|
-
return { ...
|
|
6657
|
+
function bs() {
|
|
6658
|
+
return { ...vs };
|
|
6583
6659
|
}
|
|
6584
6660
|
//#endregion
|
|
6585
6661
|
//#region src/Stages/PathTracerStage.js
|
|
6586
|
-
var
|
|
6662
|
+
var xs = 4, Ss = class extends qn {
|
|
6587
6663
|
constructor(e, t, n, r = {}) {
|
|
6588
6664
|
super("PathTracer", {
|
|
6589
6665
|
...r,
|
|
6590
6666
|
executionMode: Kn.ALWAYS
|
|
6591
6667
|
});
|
|
6592
6668
|
let i = r.width || 1920, a = r.height || 1080;
|
|
6593
|
-
this.camera = n, this.width = i, this.height = a, this.renderer = e, this.scene = t, this.sdfs = new
|
|
6669
|
+
this.camera = n, this.width = i, this.height = a, this.renderer = e, this.scene = t, this.sdfs = new gs(), this.lightSerializer = new _s(), this.accumulationEnabled = !0, this.isComplete = !1, this.cameras = [], this.performanceMonitor = cr(), this.completionThreshold = 0, this.renderLimitMode = "frames", this._initDataTextures(), this.storageTextures = new wr(0, 0), this.uniforms = new Er(i, a), this._defineUniformGetters(), this.materialData = new Mr(this.sdfs), this.materialData.callbacks.onReset = () => this.reset(), this.materialData.callbacks.getTriangleData = () => ({
|
|
6594
6670
|
array: this.triangleStorageAttr?.array,
|
|
6595
6671
|
count: this.triangleCount
|
|
6596
6672
|
}), this.materialData.callbacks.onTriangleDataChanged = () => {
|
|
@@ -6598,7 +6674,7 @@ var ys = 4, bs = class extends qn {
|
|
|
6598
6674
|
}, this.environment = new li(this.scene, this.uniforms), this.environment.callbacks.onReset = () => this.reset(), this.environment.callbacks.getSceneTextureNodes = () => this.shaderBuilder.getSceneTextureNodes(), this.shaderBuilder = new ko(), this._initRenderingState(), this.setupBlueNoise(), this.tempVector2 = new tn(), this.lastCameraMatrix = new yt(), this.lastProjectionMatrix = new yt(), this.lastRenderMode = -1, this.renderModeChangeTimeout = null, this.renderModeChangeDelay = 50, this.pendingRenderMode = null, this.lastInteractionModeState = !1, this.cameraChanged = !1, this.updateCompletionThreshold();
|
|
6599
6675
|
}
|
|
6600
6676
|
_initDataTextures() {
|
|
6601
|
-
this.triangleStorageAttr = null, this.triangleStorageNode = null, this.triangleCount = 0, this.bvhStorageAttr = null, this.bvhStorageNode = null, this.bvhNodeCount = 0, this.directionalLightsData = null, this.pointLightsData = null, this.spotLightsData = null, this.areaLightsData = null, this.goboMaps = null, this.iesProfiles = null, this.stbnScalarTexture = null, this.stbnVec2Texture = null, this.lightStorageAttr = new o(new Float32Array(16), 4), this.lightStorageNode = Ce(this.lightStorageAttr, "vec4", 1).toReadOnly(), this._lbvhDataCache = null, this._emissiveDataCache = null, this._instanceTable = null, this.spheres = [];
|
|
6677
|
+
this.triangleStorageAttr = null, this.triangleStorageNode = null, this.triangleCount = 0, this.bvhStorageAttr = null, this.bvhStorageNode = null, this.bvhNodeCount = 0, this.directionalLightsData = null, this.pointLightsData = null, this.spotLightsData = null, this.areaLightsData = null, this.goboMaps = null, this.iesProfiles = null, this.stbnScalarTexture = null, this.stbnVec2Texture = null, this.lightStorageAttr = new o(new Float32Array(16), 4), this.lightStorageNode = Ce(this.lightStorageAttr, "vec4", 1).toReadOnly(), this._lbvhDataCache = null, this._emissiveDataCache = null, this._bitTrailMapCache = null, this._instanceTable = null, this.spheres = [];
|
|
6602
6678
|
}
|
|
6603
6679
|
_defineUniformGetters() {
|
|
6604
6680
|
let e = this.uniforms;
|
|
@@ -6683,7 +6759,7 @@ var ys = 4, bs = class extends qn {
|
|
|
6683
6759
|
setupBlueNoise() {
|
|
6684
6760
|
let e = new Xt();
|
|
6685
6761
|
e.setCrossOrigin("anonymous");
|
|
6686
|
-
let t = (e) => (e.minFilter = wt, e.magFilter = wt, e.wrapS = Ht, e.wrapT = Ht, e.generateMipmaps = !1, e), { stbnScalarAtlas: n, stbnVec2Atlas: r } =
|
|
6762
|
+
let t = (e) => (e.minFilter = wt, e.magFilter = wt, e.wrapS = Ht, e.wrapT = Ht, e.generateMipmaps = !1, e), { stbnScalarAtlas: n, stbnVec2Atlas: r } = bs();
|
|
6687
6763
|
e.load(n, (e) => {
|
|
6688
6764
|
this.stbnScalarTexture = t(e), kn.value = e, console.log(`PathTracer: STBN scalar atlas loaded ${e.image.width}x${e.image.height}`);
|
|
6689
6765
|
}), e.load(r, (e) => {
|
|
@@ -6763,7 +6839,7 @@ var ys = 4, bs = class extends qn {
|
|
|
6763
6839
|
setBVHData(e) {
|
|
6764
6840
|
if (!e) return;
|
|
6765
6841
|
let t = e.length / 4;
|
|
6766
|
-
this.bvhStorageNode ? (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode.value = this.bvhStorageAttr, this.bvhStorageNode.bufferCount = t) : (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode = Ce(this.bvhStorageAttr, "vec4", t).toReadOnly()), this.bvhNodeCount = Math.floor(t /
|
|
6842
|
+
this.bvhStorageNode ? (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode.value = this.bvhStorageAttr, this.bvhStorageNode.bufferCount = t) : (this.bvhStorageAttr = new o(e, 4), this.bvhStorageNode = Ce(this.bvhStorageAttr, "vec4", t).toReadOnly()), this.bvhNodeCount = Math.floor(t / xs), console.log(`PathTracer: ${this.bvhNodeCount} BVH nodes (storage buffer)`);
|
|
6767
6843
|
}
|
|
6768
6844
|
setInstanceTable(e) {
|
|
6769
6845
|
this._instanceTable = e;
|
|
@@ -6897,11 +6973,11 @@ var ys = 4, bs = class extends qn {
|
|
|
6897
6973
|
this.stbnScalarTexture = e, e && (kn.value = e);
|
|
6898
6974
|
}
|
|
6899
6975
|
_rebuildLightBuffer() {
|
|
6900
|
-
let e = this._lbvhDataCache, t = this._emissiveDataCache, n = e ? e.length : 0,
|
|
6901
|
-
e &&
|
|
6976
|
+
let e = this._lbvhDataCache, t = this._emissiveDataCache, n = this._bitTrailMapCache, r = e ? e.length : 0, i = t ? t.length : 0, a = n ? Math.ceil(n.length / 4) * 4 : 0, s = Math.max(r + i + a, 4), c = new Float32Array(s);
|
|
6977
|
+
e && c.set(e, 0), t && c.set(t, r), n && c.set(n, r + i), this.lightStorageAttr = new o(c, 4), this.lightStorageNode.value = this.lightStorageAttr, this.lightStorageNode.bufferCount = c.length / 4, this.emissiveVec4Offset.value = (this.lightBVHNodeCount.value || 0) * 4, this.reverseMapVec4Offset.value = (r + i) / 4;
|
|
6902
6978
|
}
|
|
6903
|
-
setEmissiveTriangleData(e, t, n = 0) {
|
|
6904
|
-
e && (this._emissiveDataCache = e, this.emissiveTriangleCount.value = t, this.emissiveTotalPower.value = n, this._rebuildLightBuffer(), console.log(`PathTracer: ${t} emissive triangles, totalPower=${n.toFixed(4)} (storage buffer)`));
|
|
6979
|
+
setEmissiveTriangleData(e, t, n = 0, r = null) {
|
|
6980
|
+
e && (this._emissiveDataCache = e, r && (this._bitTrailMapCache = r), this.emissiveTriangleCount.value = t, this.emissiveTotalPower.value = n, this._rebuildLightBuffer(), console.log(`PathTracer: ${t} emissive triangles, totalPower=${n.toFixed(4)} (storage buffer)`));
|
|
6905
6981
|
}
|
|
6906
6982
|
setLightBVHData(e, t) {
|
|
6907
6983
|
e && (this._lbvhDataCache = e, this.lightBVHNodeCount.value = t, this._rebuildLightBuffer(), console.log(`PathTracer: Light BVH ${t} nodes`));
|
|
@@ -6928,7 +7004,7 @@ var ys = 4, bs = class extends qn {
|
|
|
6928
7004
|
dispose() {
|
|
6929
7005
|
this.renderModeChangeTimeout &&= (clearTimeout(this.renderModeChangeTimeout), null), this.cameraOptimizer?.dispose(), this.materialData?.dispose(), this.environment?.dispose(), this.shaderBuilder?.dispose(), this.uniforms?.dispose(), this.storageTextures?.dispose(), this.stbnScalarTexture?.dispose(), this.stbnVec2Texture?.dispose(), this.placeholderTexture?.dispose(), this.triangleStorageAttr = null, this.triangleStorageNode = null, this.bvhStorageAttr = null, this.bvhStorageNode = null, this.placeholderTexture = null, this.isReady = !1;
|
|
6930
7006
|
}
|
|
6931
|
-
},
|
|
7007
|
+
}, Cs = {
|
|
6932
7008
|
ORIGIN_META: 0,
|
|
6933
7009
|
DIR_FLAGS: 1,
|
|
6934
7010
|
THROUGHPUT_PDF: 2,
|
|
@@ -6936,10 +7012,10 @@ var ys = 4, bs = class extends qn {
|
|
|
6936
7012
|
MEDIUM_STACK: 4,
|
|
6937
7013
|
MEDIUM_SIGMA_A: 5,
|
|
6938
7014
|
SSS_SIGMA_S: 6
|
|
6939
|
-
},
|
|
7015
|
+
}, ws = {
|
|
6940
7016
|
DIST_TRI_BARY: 0,
|
|
6941
7017
|
NORMAL_MAT: 1
|
|
6942
|
-
},
|
|
7018
|
+
}, Ts = 0, Es = (e, t) => t === 0 ? e : e.add(t * Ts), Ds = class {
|
|
6943
7019
|
static requiredCapacity(e) {
|
|
6944
7020
|
return Math.ceil(e * 1.25);
|
|
6945
7021
|
}
|
|
@@ -6949,7 +7025,7 @@ var ys = 4, bs = class extends qn {
|
|
|
6949
7025
|
allocate(e) {
|
|
6950
7026
|
this.dispose();
|
|
6951
7027
|
let t = Math.ceil(e * 1.25);
|
|
6952
|
-
this.capacity = t,
|
|
7028
|
+
this.capacity = t, Ts = t;
|
|
6953
7029
|
let n = t * 7, r = new o(new Float32Array(n * 4), 4);
|
|
6954
7030
|
this._attrs.ray = r, this.rayBuffer = {
|
|
6955
7031
|
rw: Ce(r, "vec4"),
|
|
@@ -6974,16 +7050,16 @@ var ys = 4, bs = class extends qn {
|
|
|
6974
7050
|
dispose() {
|
|
6975
7051
|
this._attrs = {}, this.rayBuffer = null, this.rngBuffer = null, this.hitBuffer = null, this.capacity = 0;
|
|
6976
7052
|
}
|
|
6977
|
-
},
|
|
7053
|
+
}, Os = (e, t) => e.element(Es(t, Cs.ORIGIN_META)).xyz, ks = (e, t) => e.element(Es(t, Cs.DIR_FLAGS)).xyz, As = (e, t) => ee(e.element(Es(t, Cs.DIR_FLAGS)).w), js = (e, t) => e.element(Es(t, Cs.THROUGHPUT_PDF)).xyz, Ms = (e, t) => e.element(Es(t, Cs.THROUGHPUT_PDF)).w, Ns = (e, t) => e.element(Es(t, Cs.RADIANCE_ALPHA)), Ps = (e, t) => {
|
|
6978
7054
|
let n = B(e).mul(2);
|
|
6979
7055
|
return t === 0 ? n : n.add(t);
|
|
6980
|
-
},
|
|
7056
|
+
}, Fs = (e, t, n, r, i) => e.element(Ps(t, 0)).assign(Ie(fe(U(n.x, n.y)), fe(U(n.z, r)), pe(U(i.x, i.y)), pe(U(i.z, 0)))), Is = (e, t) => e.element(Ps(t, 0)), Ls = (e, t, n, r, i, a, o) => e.element(Ps(t, 1)).assign(Ie(B(n), B(r), pe(U(i, a)), B(o))), Rs = (e) => {
|
|
6981
7057
|
let t = Ne(e.x), n = Ne(e.y);
|
|
6982
7058
|
return G(W(t.x, t.y, n.x).mul(.5).add(.5), n.y);
|
|
6983
|
-
},
|
|
6984
|
-
e.element(
|
|
6985
|
-
},
|
|
6986
|
-
let n = e.element(
|
|
7059
|
+
}, zs = (e) => W(Pe(e.z), Pe(e.w).x), Bs = (e, t, n, r, i) => e.element(Es(t, Cs.ORIGIN_META)).assign(G(n, je(B(r).bitOr(B(i).shiftLeft(8))))), Vs = (e, t, n, r) => e.element(Es(t, Cs.DIR_FLAGS)).assign(G(n, je(r))), Hs = (e, t, n, r) => e.element(Es(t, Cs.THROUGHPUT_PDF)).assign(G(n, r)), Us = (e, t, n) => e.element(Es(t, Cs.RADIANCE_ALPHA)).assign(n), Ws = (e, t) => e.element(Es(t, ws.DIST_TRI_BARY)).x, Gs = (e, t) => ee(e.element(Es(t, ws.DIST_TRI_BARY)).y), Ks = (e, t) => e.element(Es(t, ws.DIST_TRI_BARY)).zw, qs = (e, t) => e.element(Es(t, ws.NORMAL_MAT)).xyz, Js = (e, t) => B(ee(e.element(Es(t, ws.NORMAL_MAT)).w).bitAnd(65535)), Ys = (e, t) => ee(e.element(Es(t, ws.NORMAL_MAT)).w).shiftRight(16), Xs = (e, t, n, r, i, a, o, s, c) => {
|
|
7060
|
+
e.element(Es(t, ws.DIST_TRI_BARY)).assign(G(n, je(r), i, a)), e.element(Es(t, ws.NORMAL_MAT)).assign(G(o, je(s.bitOr(c.shiftLeft(16)))));
|
|
7061
|
+
}, Zs = (e, t) => {
|
|
7062
|
+
let n = e.element(Es(t, Cs.MEDIUM_STACK)), r = ee(n.x);
|
|
6987
7063
|
return {
|
|
6988
7064
|
stackDepth: r.bitAnd(255),
|
|
6989
7065
|
transTraversals: r.shiftRight(8).bitAnd(255),
|
|
@@ -6992,17 +7068,17 @@ var ys = 4, bs = class extends qn {
|
|
|
6992
7068
|
ior2: n.z,
|
|
6993
7069
|
ior3: n.w
|
|
6994
7070
|
};
|
|
6995
|
-
},
|
|
6996
|
-
let n = e.element(
|
|
7071
|
+
}, Qs = (e, t, n, r, i, a, o, s = B(0)) => e.element(Es(t, Cs.MEDIUM_STACK)).assign(G(je(n.bitOr(r.shiftLeft(8)).bitOr(s.shiftLeft(16))), i, a, o)), $s = (e, t) => e.element(Es(t, Cs.MEDIUM_SIGMA_A)).xyz, ec = (e, t, n) => e.element(Es(t, Cs.MEDIUM_SIGMA_A)).assign(G(n, 0)), tc = (e, t) => N(ee(e.element(Es(t, Cs.ORIGIN_META)).w).bitAnd(255)), nc = (e, t) => N(ee(e.element(Es(t, Cs.ORIGIN_META)).w).shiftRight(8).bitAnd(255)), rc = (e, t) => {
|
|
7072
|
+
let n = e.element(Es(t, Cs.SSS_SIGMA_S));
|
|
6997
7073
|
return {
|
|
6998
7074
|
sigmaS: n.xyz,
|
|
6999
7075
|
g: n.w
|
|
7000
7076
|
};
|
|
7001
|
-
},
|
|
7077
|
+
}, ic = (e, t, n, r) => e.element(Es(t, Cs.SSS_SIGMA_S)).assign(G(n, r)), ac = {
|
|
7002
7078
|
ACTIVE_RAY_COUNT: 0,
|
|
7003
7079
|
ENTERING_COUNT: 1,
|
|
7004
7080
|
COUNT: 2
|
|
7005
|
-
},
|
|
7081
|
+
}, oc = {
|
|
7006
7082
|
BOUNCE_MASK: 255,
|
|
7007
7083
|
ACTIVE: 256,
|
|
7008
7084
|
SPECULAR: 512,
|
|
@@ -7011,12 +7087,12 @@ var ys = 4, bs = class extends qn {
|
|
|
7011
7087
|
RAY_TYPE_MASK: 63488,
|
|
7012
7088
|
HAS_HIT_OPAQUE: 65536,
|
|
7013
7089
|
AUX_LOCKED: 1 << 17
|
|
7014
|
-
},
|
|
7090
|
+
}, sc = class {
|
|
7015
7091
|
constructor(e = 0) {
|
|
7016
7092
|
this.capacity = 0, this.counters = null, this.activeIndices = null, this.activeIndicesRO = null, this.pingPong = 0, e > 0 && this.allocate(e);
|
|
7017
7093
|
}
|
|
7018
7094
|
allocate(e) {
|
|
7019
|
-
this.dispose(), this.capacity = e, this._countersAttr = new o(new Uint32Array(
|
|
7095
|
+
this.dispose(), this.capacity = e, this._countersAttr = new o(new Uint32Array(ac.COUNT), 1), this.counters = Ce(this._countersAttr, "uint").toAtomic(), this.MAX_BOUNCE_SNAPSHOTS = 32, this._bounceCountsAttr = new o(new Uint32Array(this.MAX_BOUNCE_SNAPSHOTS), 1), this.bounceCounts = Ce(this._bounceCountsAttr, "uint");
|
|
7020
7096
|
let t = new o(new Uint32Array(e), 1), n = new o(new Uint32Array(e), 1);
|
|
7021
7097
|
this._attrA = t, this._attrB = n, this.activeIndices = {
|
|
7022
7098
|
a: Ce(t, "uint"),
|
|
@@ -7025,7 +7101,7 @@ var ys = 4, bs = class extends qn {
|
|
|
7025
7101
|
a: Ce(t, "uint").toReadOnly(),
|
|
7026
7102
|
b: Ce(n, "uint").toReadOnly()
|
|
7027
7103
|
}, this.pingPong = 0;
|
|
7028
|
-
let r =
|
|
7104
|
+
let r = ac.COUNT * 4 + e * 4 * 2;
|
|
7029
7105
|
console.log(`QueueManager: Allocated capacity=${e}, total=${(r / (1024 * 1024)).toFixed(1)} MB`);
|
|
7030
7106
|
}
|
|
7031
7107
|
resize(e) {
|
|
@@ -7061,12 +7137,12 @@ var ys = 4, bs = class extends qn {
|
|
|
7061
7137
|
dispose() {
|
|
7062
7138
|
this.counters = null, this.activeIndices = null, this.activeIndicesRO = null, this.capacity = 0;
|
|
7063
7139
|
}
|
|
7064
|
-
},
|
|
7140
|
+
}, cc = {
|
|
7065
7141
|
[Ft]: 4,
|
|
7066
7142
|
[It]: 3,
|
|
7067
7143
|
[Lt]: 2,
|
|
7068
7144
|
[Bt]: 1
|
|
7069
|
-
},
|
|
7145
|
+
}, lc = {
|
|
7070
7146
|
[st]: 4,
|
|
7071
7147
|
[ut]: 2,
|
|
7072
7148
|
[Qt]: 1,
|
|
@@ -7076,23 +7152,23 @@ var ys = 4, bs = class extends qn {
|
|
|
7076
7152
|
[$t]: 4,
|
|
7077
7153
|
[dt]: 4
|
|
7078
7154
|
};
|
|
7079
|
-
function
|
|
7080
|
-
return (
|
|
7155
|
+
function uc(e) {
|
|
7156
|
+
return (cc[e.format] ?? 4) * (lc[e.type] ?? 4);
|
|
7081
7157
|
}
|
|
7082
|
-
function
|
|
7158
|
+
function dc(e) {
|
|
7083
7159
|
return e?.array?.byteLength || 0;
|
|
7084
7160
|
}
|
|
7085
|
-
function
|
|
7161
|
+
function fc(e) {
|
|
7086
7162
|
if (!e) return 0;
|
|
7087
7163
|
if (e.isRenderTarget) {
|
|
7088
7164
|
let t = e.textures?.length ? e.textures : [e.texture], n = e.width || 0, r = e.height || 0, i = e.depth || 1, a = 0;
|
|
7089
|
-
for (let e of t) e && (a += n * r * i *
|
|
7165
|
+
for (let e of t) e && (a += n * r * i * uc(e));
|
|
7090
7166
|
return a;
|
|
7091
7167
|
}
|
|
7092
7168
|
let t = e.image || {}, n = t.width ?? e.width ?? 0, r = t.height ?? e.height ?? 0, i = t.depth ?? 1;
|
|
7093
|
-
return n * r * i *
|
|
7169
|
+
return n * r * i * uc(e);
|
|
7094
7170
|
}
|
|
7095
|
-
var
|
|
7171
|
+
var pc = class {
|
|
7096
7172
|
constructor() {
|
|
7097
7173
|
this._providers = [], this.current = 0, this.peak = 0, this.byCategory = {};
|
|
7098
7174
|
}
|
|
@@ -7123,7 +7199,7 @@ var dc = class {
|
|
|
7123
7199
|
};
|
|
7124
7200
|
}
|
|
7125
7201
|
_resourceBytes(e, t) {
|
|
7126
|
-
return e ? typeof e.bytes == "number" && !e.isTexture && !e.isRenderTarget ? e.bytes : e.array && e.array.byteLength != null ? t.has(e.array) ? 0 : (t.add(e.array), e.array.byteLength) : e.isRenderTarget || e.isTexture ? t.has(e) ? 0 : (t.add(e),
|
|
7202
|
+
return e ? typeof e.bytes == "number" && !e.isTexture && !e.isRenderTarget ? e.bytes : e.array && e.array.byteLength != null ? t.has(e.array) ? 0 : (t.add(e.array), e.array.byteLength) : e.isRenderTarget || e.isTexture ? t.has(e) ? 0 : (t.add(e), fc(e)) : 0 : 0;
|
|
7127
7203
|
}
|
|
7128
7204
|
resetPeak() {
|
|
7129
7205
|
this.peak = this.current;
|
|
@@ -7132,7 +7208,7 @@ var dc = class {
|
|
|
7132
7208
|
let e = (e) => (e / 1048576).toFixed(1), t = Object.entries(this.byCategory).map(([t, n]) => `${t}=${e(n)}`);
|
|
7133
7209
|
return `VRAM current=${e(this.current)}MB peak=${e(this.peak)}MB [${t.join(" ")}]`;
|
|
7134
7210
|
}
|
|
7135
|
-
},
|
|
7211
|
+
}, mc = {
|
|
7136
7212
|
generate: [
|
|
7137
7213
|
16,
|
|
7138
7214
|
16,
|
|
@@ -7178,10 +7254,10 @@ var dc = class {
|
|
|
7178
7254
|
16,
|
|
7179
7255
|
1
|
|
7180
7256
|
]
|
|
7181
|
-
},
|
|
7257
|
+
}, hc = class {
|
|
7182
7258
|
constructor(e) {
|
|
7183
7259
|
this.renderer = e, this.kernels = /* @__PURE__ */ new Map(), this.workgroupSizes = /* @__PURE__ */ new Map(), this.timing = /* @__PURE__ */ new Map(), this.profiling = !1, this.profile = /* @__PURE__ */ new Map();
|
|
7184
|
-
for (let [e, t] of Object.entries(
|
|
7260
|
+
for (let [e, t] of Object.entries(mc)) this.workgroupSizes.set(e, t);
|
|
7185
7261
|
}
|
|
7186
7262
|
register(e, t) {
|
|
7187
7263
|
this.kernels.set(e, t), this.timing.set(e, {
|
|
@@ -7275,7 +7351,7 @@ var dc = class {
|
|
|
7275
7351
|
dispose() {
|
|
7276
7352
|
this.kernels.clear(), this.timing.clear(), this.profile.clear();
|
|
7277
7353
|
}
|
|
7278
|
-
},
|
|
7354
|
+
}, gc = 32, _c = 512, vc = 4, yc = 8, bc = 1e8, xc = () => y("int", gc).toVar(), Sc = K("\n fn RayTriangleGeometry( rayOrigin: vec3f, rayDir: vec3f, pA: vec3f, pB: vec3f, pC: vec3f, closestHitDst: f32, woopParams: vec4f ) -> vec4f {\n\n // Returns vec4(t, u, v, hit) where hit > 0.5 means intersection.\n // woopParams: (Sx, Sy, Sz, bitcast<f32>(packed kx|ky<<2|kz<<4))\n var result = vec4f( 1e20f, 0.0f, 0.0f, 0.0f );\n\n let Sx = woopParams.x;\n let Sy = woopParams.y;\n let Sz = woopParams.z;\n // Packed as regular f32 (values 0–42), not bitcast — avoids subnormal FTZ on Apple GPUs.\n let packed = i32( woopParams.w );\n let kx = packed & 3;\n let ky = ( packed >> 2 ) & 3;\n let kz = ( packed >> 4 ) & 3;\n\n let A = pA - rayOrigin;\n let B = pB - rayOrigin;\n let C = pC - rayOrigin;\n\n let Akz = A[ kz ];\n let Bkz = B[ kz ];\n let Ckz = C[ kz ];\n\n let Ax = A[ kx ] - Sx * Akz;\n let Ay = A[ ky ] - Sy * Akz;\n let Bx = B[ kx ] - Sx * Bkz;\n let By = B[ ky ] - Sy * Bkz;\n let Cx = C[ kx ] - Sx * Ckz;\n let Cy = C[ ky ] - Sy * Ckz;\n\n // Edge function tests — all three must share sign (or be exactly zero) for hit.\n let U = Cx * By - Cy * Bx;\n let V = Ax * Cy - Ay * Cx;\n let W = Bx * Ay - By * Ax;\n\n let neg = U < 0.0f || V < 0.0f || W < 0.0f;\n let pos = U > 0.0f || V > 0.0f || W > 0.0f;\n if ( !( neg && pos ) ) {\n\n let det = U + V + W;\n if ( det != 0.0f ) {\n\n let T = U * ( Sz * Akz ) + V * ( Sz * Bkz ) + W * ( Sz * Ckz );\n\n // Sign-aware bounds check on t (multiply both sides by sign(det) once).\n let detSign = select( -1.0f, 1.0f, det > 0.0f );\n let tSigned = T * detSign;\n let detAbs = abs( det );\n\n if ( tSigned > 0.0f && tSigned < closestHitDst * detAbs ) {\n\n // Match Möller-Trumbore convention: u = weight of B, v = weight of C.\n // In Woop's edge functions, U → weight of A, V → weight of B, W → weight of C.\n let invDet = 1.0f / det;\n result = vec4f( T * invDet, V * invDet, W * invDet, 1.0f );\n\n }\n\n }\n\n }\n\n return result;\n\n }\n"), Cc = K("\n fn computeWoopRayParams( rayDir: vec3f ) -> vec4f {\n\n let absDir = abs( rayDir );\n\n // kz = argmax(|dir|)\n var kz: i32 = 0;\n if ( absDir.y >= absDir.x ) { kz = 1; }\n if ( absDir.z >= absDir[ u32( kz ) ] ) { kz = 2; }\n\n var kx: i32 = ( kz + 1 ) % 3;\n var ky: i32 = ( kx + 1 ) % 3;\n\n // Preserve triangle winding when the dominant axis component is negative.\n if ( rayDir[ u32( kz ) ] < 0.0f ) {\n let tmp = kx;\n kx = ky;\n ky = tmp;\n }\n\n let dz = rayDir[ u32( kz ) ];\n let Sx = rayDir[ u32( kx ) ] / dz;\n let Sy = rayDir[ u32( ky ) ] / dz;\n let Sz = 1.0f / dz;\n\n let packed = kx | ( ky << 2 ) | ( kz << 4 );\n return vec4f( Sx, Sy, Sz, f32( packed ) );\n\n }\n"), wc = K("\n fn fastRayAABBDst( rayOrigin: vec3f, invDir: vec3f, boxMin: vec3f, boxMax: vec3f ) -> f32 {\n\n let t1 = ( boxMin - rayOrigin ) * invDir;\n let t2 = ( boxMax - rayOrigin ) * invDir;\n\n let tmin = min( t1, t2 );\n let tmax = max( t1, t2 );\n\n let tNear = max( max( tmin.x, tmin.y ), tmin.z );\n let tFar = min( min( tmax.x, tmax.y ), tmax.z ) * 1.00000024f; // Robust traversal: 2 ULP padding (Ize 2013)\n\n let isHit = tNear <= tFar && tFar > 0.0f;\n return select( 1e20f, max( tNear, 0.0f ), isHit );\n\n }\n"), Tc = f(([e, t, n, r]) => {
|
|
7279
7355
|
let i = r ?? T(!1), a = pi({
|
|
7280
7356
|
didHit: !1,
|
|
7281
7357
|
dst: M(0x56bc75e2d63100000),
|
|
@@ -7286,12 +7362,12 @@ var dc = class {
|
|
|
7286
7362
|
meshIndex: N(-1),
|
|
7287
7363
|
boxTests: N(0),
|
|
7288
7364
|
triTests: N(0)
|
|
7289
|
-
}).toVar(), o = N(-1).toVar(), s = M(0).toVar(), c = M(0).toVar(), l =
|
|
7365
|
+
}).toVar(), o = N(-1).toVar(), s = M(0).toVar(), c = M(0).toVar(), l = xc(), u = N(1).toVar();
|
|
7290
7366
|
l.element(N(0)).assign(N(0));
|
|
7291
|
-
let f = I(W(1), ve(e.direction), de(e.direction, W(0))), h = I(W(1).div(e.direction), W(
|
|
7292
|
-
return m(u.greaterThan(N(0)).and(b.lessThan(N(
|
|
7367
|
+
let f = I(W(1), ve(e.direction), de(e.direction, W(0))), h = I(W(1).div(e.direction), W(bc).mul(f), ae(_(e.direction), W(1e-8))).toVar(), g = e.origin, v = e.direction, y = Cc({ rayDir: v }).toVar(), b = N(0).toVar();
|
|
7368
|
+
return m(u.greaterThan(N(0)).and(b.lessThan(N(_c))), () => {
|
|
7293
7369
|
b.addAssign(1), u.subAssign(1);
|
|
7294
|
-
let e = l.element(u).toVar(), r = $(t, e, N(0), N(
|
|
7370
|
+
let e = l.element(u).toVar(), r = $(t, e, N(0), N(vc));
|
|
7295
7371
|
a.boxTests.addAssign(1), p(r.w.lessThan(0), () => {
|
|
7296
7372
|
p(r.w.greaterThan(M(-1.5)), () => {
|
|
7297
7373
|
let e = N(r.x).toVar(), t = N(r.y).toVar();
|
|
@@ -7300,7 +7376,7 @@ var dc = class {
|
|
|
7300
7376
|
end: t
|
|
7301
7377
|
}, ({ i: t }) => {
|
|
7302
7378
|
a.triTests.addAssign(1);
|
|
7303
|
-
let r = e.add(t).toVar(), l = $(n, r, N(0), N(
|
|
7379
|
+
let r = e.add(t).toVar(), l = $(n, r, N(0), N(yc)).xyz, u = $(n, r, N(1), N(yc)).xyz, d = $(n, r, N(2), N(yc)).xyz, f = Sc({
|
|
7304
7380
|
rayOrigin: g,
|
|
7305
7381
|
rayDir: v,
|
|
7306
7382
|
pA: l,
|
|
@@ -7310,7 +7386,7 @@ var dc = class {
|
|
|
7310
7386
|
woopParams: y
|
|
7311
7387
|
});
|
|
7312
7388
|
p(f.w.greaterThan(.5), () => {
|
|
7313
|
-
let e = f.x, t = f.y, l = f.z, u = $(n, r, N(3), N(
|
|
7389
|
+
let e = f.x, t = f.y, l = f.z, u = $(n, r, N(3), N(yc)).xyz, d = $(n, r, N(4), N(yc)).xyz, m = $(n, r, N(5), N(yc)), h = m.xyz, g = N(m.w).toVar(), _ = M(1).sub(t).sub(l), y = v.dot(L(u.mul(_).add(d.mul(t)).add(h.mul(l))));
|
|
7314
7390
|
p(i.or(g.equal(N(2))).or(g.equal(N(0)).and(y.lessThan(-1e-4))).or(g.equal(N(1)).and(y.greaterThan(1e-4))), () => {
|
|
7315
7391
|
a.didHit.assign(!0), a.dst.assign(e), o.assign(r), s.assign(t), c.assign(l);
|
|
7316
7392
|
});
|
|
@@ -7319,17 +7395,17 @@ var dc = class {
|
|
|
7319
7395
|
d();
|
|
7320
7396
|
});
|
|
7321
7397
|
}).Else(() => {
|
|
7322
|
-
p(r.z.greaterThan(.5).and(u.lessThan(N(
|
|
7398
|
+
p(r.z.greaterThan(.5).and(u.lessThan(N(gc))), () => {
|
|
7323
7399
|
l.element(u).assign(N(r.x)), u.addAssign(1);
|
|
7324
7400
|
});
|
|
7325
7401
|
});
|
|
7326
7402
|
}).Else(() => {
|
|
7327
|
-
let n = $(t, e, N(1), N(
|
|
7403
|
+
let n = $(t, e, N(1), N(vc)), i = $(t, e, N(2), N(vc)), o = $(t, e, N(3), N(vc)), s = N(r.w).toVar(), c = N(n.w).toVar(), d = wc({
|
|
7328
7404
|
rayOrigin: g,
|
|
7329
7405
|
invDir: h,
|
|
7330
7406
|
boxMin: r.xyz,
|
|
7331
7407
|
boxMax: n.xyz
|
|
7332
|
-
}).toVar(), f =
|
|
7408
|
+
}).toVar(), f = wc({
|
|
7333
7409
|
rayOrigin: g,
|
|
7334
7410
|
invDir: h,
|
|
7335
7411
|
boxMin: i.xyz,
|
|
@@ -7337,21 +7413,21 @@ var dc = class {
|
|
|
7337
7413
|
}).toVar();
|
|
7338
7414
|
p(le(d, f).lessThan(a.dst), () => {
|
|
7339
7415
|
let e = d.lessThan(f);
|
|
7340
|
-
p(R(e, f, d).lessThan(a.dst).and(u.lessThan(N(
|
|
7416
|
+
p(R(e, f, d).lessThan(a.dst).and(u.lessThan(N(gc))), () => {
|
|
7341
7417
|
l.element(u).assign(R(e, c, s)), u.addAssign(1);
|
|
7342
|
-
}), p(u.lessThan(N(
|
|
7418
|
+
}), p(u.lessThan(N(gc)), () => {
|
|
7343
7419
|
l.element(u).assign(R(e, s, c)), u.addAssign(1);
|
|
7344
7420
|
});
|
|
7345
7421
|
});
|
|
7346
7422
|
});
|
|
7347
7423
|
}), p(a.didHit, () => {
|
|
7348
7424
|
a.hitPoint.assign(e.origin.add(e.direction.mul(a.dst)));
|
|
7349
|
-
let t = M(1).sub(s).sub(c), r = $(n, o, N(3), N(
|
|
7425
|
+
let t = M(1).sub(s).sub(c), r = $(n, o, N(3), N(yc)).xyz, i = $(n, o, N(4), N(yc)).xyz, l = $(n, o, N(5), N(yc)).xyz;
|
|
7350
7426
|
a.normal.assign(L(r.mul(t).add(i.mul(s)).add(l.mul(c))));
|
|
7351
|
-
let u = $(n, o, N(6), N(
|
|
7427
|
+
let u = $(n, o, N(6), N(yc)), d = $(n, o, N(7), N(yc));
|
|
7352
7428
|
a.uv.assign(u.xy.mul(t).add(u.zw.mul(s)).add(d.xy.mul(c))), a.materialIndex.assign(N(d.z)), a.meshIndex.assign(N(d.w)), a.triangleIndex.assign(o);
|
|
7353
7429
|
}), a;
|
|
7354
|
-
}),
|
|
7430
|
+
}), Ec = f(([e, t, n, r]) => {
|
|
7355
7431
|
let i = pi({
|
|
7356
7432
|
didHit: !1,
|
|
7357
7433
|
dst: r,
|
|
@@ -7362,12 +7438,12 @@ var dc = class {
|
|
|
7362
7438
|
meshIndex: N(-1),
|
|
7363
7439
|
boxTests: N(0),
|
|
7364
7440
|
triTests: N(0)
|
|
7365
|
-
}).toVar(), a =
|
|
7441
|
+
}).toVar(), a = xc(), o = N(1).toVar();
|
|
7366
7442
|
a.element(N(0)).assign(N(0));
|
|
7367
|
-
let s = I(W(1), ve(e.direction), de(e.direction, W(0))), c = I(W(1).div(e.direction), W(
|
|
7368
|
-
return m(o.greaterThan(N(0)).and(i.didHit.not()).and(u.lessThan(N(
|
|
7443
|
+
let s = I(W(1), ve(e.direction), de(e.direction, W(0))), c = I(W(1).div(e.direction), W(bc).mul(s), ae(_(e.direction), W(1e-8))).toVar(), l = Cc({ rayDir: e.direction }).toVar(), u = N(0).toVar();
|
|
7444
|
+
return m(o.greaterThan(N(0)).and(i.didHit.not()).and(u.lessThan(N(_c))), () => {
|
|
7369
7445
|
u.addAssign(1), o.subAssign(1);
|
|
7370
|
-
let r = a.element(o).toVar(), s = $(t, r, N(0), N(
|
|
7446
|
+
let r = a.element(o).toVar(), s = $(t, r, N(0), N(vc));
|
|
7371
7447
|
p(s.w.lessThan(0), () => {
|
|
7372
7448
|
p(s.w.greaterThan(M(-1.5)), () => {
|
|
7373
7449
|
let t = N(s.x).toVar(), r = N(s.y).toVar();
|
|
@@ -7375,7 +7451,7 @@ var dc = class {
|
|
|
7375
7451
|
start: N(0),
|
|
7376
7452
|
end: r
|
|
7377
7453
|
}, ({ i: r }) => {
|
|
7378
|
-
let a = t.add(r).toVar(), o = $(n, a, N(0), N(
|
|
7454
|
+
let a = t.add(r).toVar(), o = $(n, a, N(0), N(yc)).xyz, s = $(n, a, N(1), N(yc)).xyz, c = $(n, a, N(2), N(yc)).xyz, u = Sc({
|
|
7379
7455
|
rayOrigin: e.origin,
|
|
7380
7456
|
rayDir: e.direction,
|
|
7381
7457
|
pA: o,
|
|
@@ -7385,22 +7461,22 @@ var dc = class {
|
|
|
7385
7461
|
woopParams: l
|
|
7386
7462
|
});
|
|
7387
7463
|
p(u.w.greaterThan(.5), () => {
|
|
7388
|
-
let t = $(n, a, N(7), N(
|
|
7464
|
+
let t = $(n, a, N(7), N(yc));
|
|
7389
7465
|
i.didHit.assign(!0), i.dst.assign(u.x), i.materialIndex.assign(N(t.z)), i.meshIndex.assign(N(t.w)), i.hitPoint.assign(e.origin.add(e.direction.mul(u.x))), i.uv.assign(U(u.y, u.z)), i.triangleIndex.assign(a), d();
|
|
7390
7466
|
});
|
|
7391
7467
|
});
|
|
7392
7468
|
}).Else(() => {
|
|
7393
|
-
p(s.z.greaterThan(.5).and(o.lessThan(N(
|
|
7469
|
+
p(s.z.greaterThan(.5).and(o.lessThan(N(gc))), () => {
|
|
7394
7470
|
a.element(o).assign(N(s.x)), o.addAssign(1);
|
|
7395
7471
|
});
|
|
7396
7472
|
});
|
|
7397
7473
|
}).Else(() => {
|
|
7398
|
-
let n = $(t, r, N(1), N(
|
|
7474
|
+
let n = $(t, r, N(1), N(vc)), l = $(t, r, N(2), N(vc)), u = $(t, r, N(3), N(vc)), d = N(s.w).toVar(), f = N(n.w).toVar(), m = wc({
|
|
7399
7475
|
rayOrigin: e.origin,
|
|
7400
7476
|
invDir: c,
|
|
7401
7477
|
boxMin: s.xyz,
|
|
7402
7478
|
boxMax: n.xyz
|
|
7403
|
-
}).toVar(), h =
|
|
7479
|
+
}).toVar(), h = wc({
|
|
7404
7480
|
rayOrigin: e.origin,
|
|
7405
7481
|
invDir: c,
|
|
7406
7482
|
boxMin: l.xyz,
|
|
@@ -7408,15 +7484,15 @@ var dc = class {
|
|
|
7408
7484
|
}).toVar();
|
|
7409
7485
|
p(le(m, h).lessThan(i.dst), () => {
|
|
7410
7486
|
let e = m.lessThan(h);
|
|
7411
|
-
p(R(e, h, m).lessThan(i.dst).and(o.lessThan(N(
|
|
7487
|
+
p(R(e, h, m).lessThan(i.dst).and(o.lessThan(N(gc))), () => {
|
|
7412
7488
|
a.element(o).assign(R(e, f, d)), o.addAssign(1);
|
|
7413
|
-
}), p(o.lessThan(N(
|
|
7489
|
+
}), p(o.lessThan(N(gc)), () => {
|
|
7414
7490
|
a.element(o).assign(R(e, d, f)), o.addAssign(1);
|
|
7415
7491
|
});
|
|
7416
7492
|
});
|
|
7417
7493
|
});
|
|
7418
7494
|
}), i;
|
|
7419
|
-
}),
|
|
7495
|
+
}), Dc = f(([e, t, n, r, i, a, o, s, c, l, u]) => {
|
|
7420
7496
|
let d = W(e.xy, 1), f = r.mul(G(d, 1)), m = L(ce(n[0].xyz, n[1].xyz, n[2].xyz).mul(f.xyz.div(f.w))).toVar(), h = W(n[3]).toVar(), g = h.toVar(), _ = m.toVar();
|
|
7421
7497
|
return p(i.and(a.greaterThan(0)).and(o.lessThan(64)).and(s.greaterThan(.001)), () => {
|
|
7422
7498
|
let e = a.div(o).mul(.001).mul(c).mul(l), r = Ln(t), i = r.x.mul(u.max(.01)), d = r.y, f = L(W(n[0])), p = L(W(n[1])), v = f.mul(i).add(p.mul(d)).mul(e);
|
|
@@ -7426,7 +7502,7 @@ var dc = class {
|
|
|
7426
7502
|
direction: _
|
|
7427
7503
|
});
|
|
7428
7504
|
});
|
|
7429
|
-
function
|
|
7505
|
+
function Oc(e) {
|
|
7430
7506
|
let { rayBufferRW: t, rngBufferRW: n, gBufferRW: r, resolution: i, frame: a, cameraWorldMatrix: o, cameraProjectionMatrixInverse: s, enableDOF: c, focalLength: l, aperture: u, focusDistance: d, sceneScale: m, apertureScale: h, anamorphicRatio: g, renderWidth: _, renderHeight: v, samplesPerPass: y = 1, transmissiveBounces: b, transparentBackground: x } = e, S = y | 0;
|
|
7431
7507
|
return f(() => {
|
|
7432
7508
|
let e = N(ze.x).mul(16).add(N(oe.x)), f = N(ze.y).mul(16).add(N(oe.y)), y = S > 1 ? f.div(v).toVar() : N(0), C = S > 1 ? f.sub(y.mul(v)).toVar() : f, w = S > 1 ? v.mul(N(S)) : v;
|
|
@@ -7437,51 +7513,51 @@ function Ec(e) {
|
|
|
7437
7513
|
pixelCoord: f,
|
|
7438
7514
|
rayIndex: y,
|
|
7439
7515
|
frame: a
|
|
7440
|
-
}).toVar() }).toVar(), E = Wn(f, y, N(S), T, i, a).toVar(), D = U(2).div(i), O = E.sub(.5).mul(D), k = w.add(O), A = ui.wrap(
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
}),
|
|
7516
|
+
}).toVar() }).toVar(), E = Wn(f, y, N(S), T, i, a).toVar(), D = U(2).div(i), O = E.sub(.5).mul(D), k = w.add(O), A = ui.wrap(Dc(k, T, o, s, c, l, u, d, m, h, g));
|
|
7517
|
+
Bs(t, v, A.origin, N(0), N(0)), Vs(t, v, A.direction, B(oc.ACTIVE)), Hs(t, v, G(1, 1, 1, 0).xyz, M(0)), Us(t, v, G(W(0), R(x, M(1), M(0)))), p(y.equal(N(0)), () => {
|
|
7518
|
+
Fs(r, B(_), W(0, 0, 1), M(1), W(0)), Ls(r, B(_), B(0), B(0), M(0), M(0), B(0));
|
|
7519
|
+
}), Qs(t, v, B(0), B(b), M(1), M(1), M(1)), n.element(v).assign(T);
|
|
7444
7520
|
});
|
|
7445
7521
|
});
|
|
7446
7522
|
}
|
|
7447
7523
|
//#endregion
|
|
7448
7524
|
//#region src/TSL/ExtendKernel.js
|
|
7449
|
-
function
|
|
7525
|
+
function kc(e) {
|
|
7450
7526
|
let { bvhBuffer: t, triangleBuffer: n, materialBuffer: r, rayBufferRO: i, hitBufferRW: a, activeIndicesRO: o, counters: s, maxRayCount: c } = e;
|
|
7451
7527
|
return f(() => {
|
|
7452
|
-
let e = re, r = s ? S(s.element(B(
|
|
7528
|
+
let e = re, r = s ? S(s.element(B(ac.ENTERING_COUNT))) : c;
|
|
7453
7529
|
p(e.greaterThanEqual(r), () => {
|
|
7454
7530
|
h();
|
|
7455
7531
|
});
|
|
7456
7532
|
let l = o.element(e), u = ui({
|
|
7457
|
-
origin:
|
|
7458
|
-
direction:
|
|
7459
|
-
}), d =
|
|
7460
|
-
|
|
7533
|
+
origin: Os(i, l).toVar(),
|
|
7534
|
+
direction: ks(i, l).toVar()
|
|
7535
|
+
}), d = Zs(i, l).stackDepth.greaterThan(B(0)), f = pi.wrap(Tc(u, t, n, d)).toVar();
|
|
7536
|
+
Xs(a, l, f.dst, B(f.triangleIndex), f.uv.x, f.uv.y, f.normal, B(f.materialIndex), B(f.meshIndex));
|
|
7461
7537
|
});
|
|
7462
7538
|
}
|
|
7463
7539
|
//#endregion
|
|
7464
7540
|
//#region src/TSL/Environment.js
|
|
7465
|
-
var
|
|
7541
|
+
var Ac = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, environmentMatrix: mat4x4f ) -> vec2f {\n let d = normalize( ( environmentMatrix * vec4f( direction, 0.0f ) ).xyz );\n var uv = vec2f( atan2( d.z, d.x ), acos( d.y ) );\n uv = uv / vec2f( 6.28318530717958647692f, 3.14159265358979323846f );\n uv.x = uv.x + 0.5f;\n uv.y = 1.0f - uv.y;\n return uv;\n }\n"), jc = /* @__PURE__ */ K("\n fn equirectUvToDirection( uv: vec2f, environmentMatrix: mat4x4f ) -> vec3f {\n let adjustedUv = vec2f( uv.x - 0.5f, 1.0f - uv.y );\n let theta = adjustedUv.x * 6.28318530717958647692f;\n let phi = adjustedUv.y * 3.14159265358979323846f;\n let sinPhi = sin( phi );\n let localDir = vec3f( sinPhi * cos( theta ), cos( phi ), sinPhi * sin( theta ) );\n return normalize( ( transpose( environmentMatrix ) * vec4f( localDir, 0.0f ) ).xyz );\n }\n"), Mc = f(([e, t, n, r, i, a]) => {
|
|
7466
7542
|
let o = G(0).toVar();
|
|
7467
7543
|
return p(r.equal(0), () => {
|
|
7468
7544
|
o.assign(G(0));
|
|
7469
7545
|
}).Else(() => {
|
|
7470
|
-
let s =
|
|
7546
|
+
let s = Ac({
|
|
7471
7547
|
direction: t,
|
|
7472
7548
|
environmentMatrix: n
|
|
7473
7549
|
}).toVar(), c = ke(e, s, 0).rgb.toVar(), l = ye(s.y.mul(Math.PI)).toVar(), u = A(c, Mi).mul(l), d = F(M(0), u.sub(i)).div(r), f = l.greaterThan(0).select(M(1).div(M(2 * Math.PI * Math.PI).mul(l)), M(0)), p = M(a.x).mul(M(a.y)).mul(d).mul(f);
|
|
7474
7550
|
o.assign(G(c, p));
|
|
7475
7551
|
}), o;
|
|
7476
|
-
}),
|
|
7477
|
-
let l = N(o.x).toVar(), u = o.y, d = E(s.x.mul(u.sub(1)), 0, u.sub(1)), f = N(te(d)), p = le(f.add(1), N(u).sub(1)), m = ne(d), h = I(t.load(P(l, f)).x, t.load(P(l, p)).x, m).toVar(), g = o.x, _ = o.y, v = E(s.y.mul(g.sub(1)), 0, g.sub(1)), y = E(h.mul(_.sub(1)), 0, _.sub(1)), b = N(te(v)), x = N(te(y)), S = le(b.add(1), N(g).sub(1)), C = le(x.add(1), N(_).sub(1)), w = ne(v), T = ne(y), D = t.load(P(b, x)).x, O = t.load(P(S, x)).x, k = t.load(P(b, C)).x, j = t.load(P(S, C)).x, ee = U(I(I(D, O, w), I(k, j, w), T).toVar(), h).toVar(), re =
|
|
7552
|
+
}), Nc = f(([e, t, n, r, i, a, o, s, c]) => {
|
|
7553
|
+
let l = N(o.x).toVar(), u = o.y, d = E(s.x.mul(u.sub(1)), 0, u.sub(1)), f = N(te(d)), p = le(f.add(1), N(u).sub(1)), m = ne(d), h = I(t.load(P(l, f)).x, t.load(P(l, p)).x, m).toVar(), g = o.x, _ = o.y, v = E(s.y.mul(g.sub(1)), 0, g.sub(1)), y = E(h.mul(_.sub(1)), 0, _.sub(1)), b = N(te(v)), x = N(te(y)), S = le(b.add(1), N(g).sub(1)), C = le(x.add(1), N(_).sub(1)), w = ne(v), T = ne(y), D = t.load(P(b, x)).x, O = t.load(P(S, x)).x, k = t.load(P(b, C)).x, j = t.load(P(S, C)).x, ee = U(I(I(D, O, w), I(k, j, w), T).toVar(), h).toVar(), re = jc({
|
|
7478
7554
|
uv: ee,
|
|
7479
7555
|
environmentMatrix: n
|
|
7480
7556
|
}).toVar(), ie = ke(e, ee, 0).rgb.mul(r).toVar();
|
|
7481
7557
|
c.assign(ie);
|
|
7482
7558
|
let ae = ye(ee.y.mul(Math.PI)).toVar(), oe = A(ie.div(r), Mi).mul(ae), se = F(M(0), oe.sub(a)).div(i), ce = ae.greaterThan(0).select(M(1).div(M(2 * Math.PI * Math.PI).mul(ae)), M(0));
|
|
7483
7559
|
return G(re, M(o.x).mul(M(o.y)).mul(se).mul(ce));
|
|
7484
|
-
}),
|
|
7560
|
+
}), Pc = /* @__PURE__ */ K("\n fn sampleEnvironment(\n tex: texture_2d<f32>,\n samp: sampler,\n direction: vec3f,\n environmentMatrix: mat4x4f,\n environmentIntensity: f32,\n enableEnvironmentLight: f32\n ) -> vec4f {\n if ( enableEnvironmentLight < 0.5 ) { return vec4f( 0.0 ); }\n let uv = equirectDirectionToUv( direction, environmentMatrix );\n let texSample = textureSampleLevel( tex, samp, uv, 0.0 );\n return texSample * environmentIntensity;\n }\n", [Ac]), Fc = f(([e, t, n, r]) => {
|
|
7485
7561
|
let i = t.toConst(), a = e.toVar();
|
|
7486
7562
|
a.y.subAssign(r);
|
|
7487
7563
|
let o = n.mul(n).toConst(), s = a.dot(i).toConst(), c = a.dot(a).sub(o).toConst(), l = s.mul(s).sub(c).toConst(), u = t.toVar();
|
|
@@ -7496,7 +7572,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7496
7572
|
u.assign(a.add(i.mul(le(t, r))).div(n));
|
|
7497
7573
|
});
|
|
7498
7574
|
}), u;
|
|
7499
|
-
}),
|
|
7575
|
+
}), Ic = f(([e, t]) => {
|
|
7500
7576
|
let n = W(0).toVar();
|
|
7501
7577
|
return p(e.roughness.greaterThan(.98).and(e.metalness.lessThan(.02)).and(e.transmission.equal(0)).and(e.clearcoat.equal(0)).and(e.iridescence.equal(0)), () => {
|
|
7502
7578
|
n.assign(e.color.rgb.mul(M(1).sub(e.metalness)).mul(Ei));
|
|
@@ -7520,10 +7596,10 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7520
7596
|
n.assign(d);
|
|
7521
7597
|
});
|
|
7522
7598
|
}), n;
|
|
7523
|
-
}),
|
|
7599
|
+
}), Lc = f(([e, t, n, r]) => Ic(r, _i.wrap(Ui(n, e, t)))), Rc = f(([e, t]) => {
|
|
7524
7600
|
let n = E(I(oa(t.ior).mul(t.specularColor), t.color.rgb, t.metalness).mul(t.specularIntensity), W(0), W(1)).toVar(), r = sa(e.NoH, t.roughness), i = ua(e.NoV, e.NoL, t.roughness), a = na(e.VoH, n), o = r.mul(i).mul(a).div(F(M(4).mul(e.NoV).mul(e.NoL), Oi)), s = vi.wrap(da(n, e.NoV, t.roughness)), c = o.mul(s.compensation), l = W(1).sub(s.E_total).mul(M(1).sub(t.metalness)).mul(t.color.rgb).div(Ti).add(c), u = F(t.clearcoatRoughness, Ai), d = sa(e.NoH, u), f = ua(e.NoV, e.NoL, u), p = ta(e.VoH, M(.04)), m = d.mul(f).mul(p).div(F(M(4).mul(e.NoV).mul(e.NoL), Oi)), h = M(1).sub(t.clearcoat.mul(p).mul(M(2).sub(p)));
|
|
7525
7601
|
return l.mul(h).add(W(m).mul(t.clearcoat));
|
|
7526
|
-
}),
|
|
7602
|
+
}), zc = 2 * Ti, Bc = f(([e, t, n, r]) => {
|
|
7527
7603
|
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();
|
|
7528
7604
|
return p(e.area.greaterThan(0), () => {
|
|
7529
7605
|
let u = e.position.add(e.u.mul(n.x.mul(2).sub(1))).add(e.v.mul(n.y.mul(2).sub(1))).sub(t).toVar(), d = A(u, u).toVar();
|
|
@@ -7539,7 +7615,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7539
7615
|
pdf: c,
|
|
7540
7616
|
lightType: l
|
|
7541
7617
|
});
|
|
7542
|
-
}),
|
|
7618
|
+
}), Vc = f(([e, t, n]) => {
|
|
7543
7619
|
let r = T(!1).toVar(), i = W(0, 1, 0).toVar(), a = W(0).toVar(), o = M(0).toVar(), s = M(0).toVar(), c = N(3).toVar(), l = e.position.sub(t).toVar(), u = A(l, l).toVar();
|
|
7544
7620
|
return p(u.greaterThanEqual(1e-20), () => {
|
|
7545
7621
|
let t = xe(u).toVar(), c = l.div(t).toVar(), d = A(c.negate(), e.direction).toVar(), f = D(e.angle).toVar();
|
|
@@ -7563,7 +7639,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7563
7639
|
pdf: s,
|
|
7564
7640
|
lightType: c
|
|
7565
7641
|
});
|
|
7566
|
-
}),
|
|
7642
|
+
}), Hc = f(([e, t, n]) => {
|
|
7567
7643
|
let r = T(!1).toVar(), i = W(0, 1, 0).toVar(), a = W(0).toVar(), o = M(0).toVar(), s = M(0).toVar(), c = N(2).toVar(), l = e.position.sub(t).toVar(), u = A(l, l).toVar();
|
|
7568
7644
|
return p(u.greaterThanEqual(1e-20), () => {
|
|
7569
7645
|
let t = xe(u).toVar(), d = l.div(t), f = yo({
|
|
@@ -7580,7 +7656,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7580
7656
|
pdf: s,
|
|
7581
7657
|
lightType: c
|
|
7582
7658
|
});
|
|
7583
|
-
}),
|
|
7659
|
+
}), Uc = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, h]) => {
|
|
7584
7660
|
let g = T(!1).toVar(), v = W(0, 1, 0).toVar(), y = W(0).toVar(), b = M(0).toVar(), x = M(0).toVar(), S = N(2).toVar(), C = s.add(l).add(d).add(h).toVar();
|
|
7585
7661
|
return p(C.greaterThan(N(0)), () => {
|
|
7586
7662
|
let w = M(0).toVar(), E = N(0).toVar(), k = N(-1).toVar(), A = N(-1).toVar(), j = M(0).toVar();
|
|
@@ -7656,7 +7732,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7656
7732
|
p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(l))), () => {
|
|
7657
7733
|
let o = co.wrap(ho(c, t.sub(m)));
|
|
7658
7734
|
p(o.intensity.greaterThan(0), () => {
|
|
7659
|
-
let t = U(r.y, Y(a)).toVar(), s = fo.wrap(
|
|
7735
|
+
let t = U(r.y, Y(a)).toVar(), s = fo.wrap(Bc(o, e, t, n));
|
|
7660
7736
|
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));
|
|
7661
7737
|
});
|
|
7662
7738
|
}), m.addAssign(l);
|
|
@@ -7664,7 +7740,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7664
7740
|
p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(d))), () => {
|
|
7665
7741
|
let r = lo.wrap(go(u, t.sub(m)));
|
|
7666
7742
|
p(r.intensity.greaterThan(0), () => {
|
|
7667
|
-
let t = fo.wrap(
|
|
7743
|
+
let t = fo.wrap(Hc(r, e, n));
|
|
7668
7744
|
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));
|
|
7669
7745
|
});
|
|
7670
7746
|
}), m.addAssign(d);
|
|
@@ -7672,7 +7748,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7672
7748
|
p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(h))), () => {
|
|
7673
7749
|
let r = uo.wrap(_o(f, t.sub(m)));
|
|
7674
7750
|
p(r.intensity.greaterThan(0), () => {
|
|
7675
|
-
let t = fo.wrap(
|
|
7751
|
+
let t = fo.wrap(Vc(r, e, n));
|
|
7676
7752
|
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));
|
|
7677
7753
|
});
|
|
7678
7754
|
});
|
|
@@ -7682,21 +7758,21 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7682
7758
|
p(k.equal(N(0)).and(A.greaterThanEqual(N(0))), () => {
|
|
7683
7759
|
let n = so.wrap(mo(o, A)), i = L(n.direction).toVar(), s = M(1).toVar();
|
|
7684
7760
|
p(n.angle.greaterThan(0), () => {
|
|
7685
|
-
let e = D(n.angle.mul(.5)).toVar(), t = I(e, M(1), r.y).toVar(), o = xe(F(M(0), M(1).sub(t.mul(t)))).toVar(), c = M(
|
|
7761
|
+
let e = D(n.angle.mul(.5)).toVar(), t = I(e, M(1), r.y).toVar(), o = xe(F(M(0), M(1).sub(t.mul(t)))).toVar(), c = M(zc).mul(Y(a)).toVar(), l = L(n.direction).toVar(), u = L(O(R(_(l.x).greaterThan(.9), W(0, 1, 0), W(1, 0, 0)), l)).toVar(), d = O(l, u).toVar();
|
|
7686
7762
|
i.assign(L(l.mul(t).add(u.mul(D(c)).add(d.mul(ye(c))).mul(o))));
|
|
7687
|
-
let f = M(
|
|
7763
|
+
let f = M(zc).mul(F(M(1).sub(e), 1e-10));
|
|
7688
7764
|
s.assign(M(1).div(f));
|
|
7689
7765
|
});
|
|
7690
7766
|
let c = wo(n, e);
|
|
7691
7767
|
v.assign(i), y.assign(n.color.mul(n.intensity).mul(c)), b.assign(1e6), x.assign(s.mul(t)), S.assign(N(0)), g.assign(T(!0));
|
|
7692
7768
|
}), p(k.equal(N(1)).and(A.greaterThanEqual(N(0))), () => {
|
|
7693
|
-
let n = co.wrap(ho(c, A)), i = U(r.y, Y(a)).toVar(), o = fo.wrap(
|
|
7769
|
+
let n = co.wrap(ho(c, A)), i = U(r.y, Y(a)).toVar(), o = fo.wrap(Bc(n, e, i, t));
|
|
7694
7770
|
g.assign(o.valid), v.assign(o.direction), y.assign(o.emission), b.assign(o.distance), x.assign(o.pdf), S.assign(o.lightType);
|
|
7695
7771
|
}), p(k.equal(N(2)).and(A.greaterThanEqual(N(0))), () => {
|
|
7696
|
-
let n = lo.wrap(go(u, A)), r = fo.wrap(
|
|
7772
|
+
let n = lo.wrap(go(u, A)), r = fo.wrap(Hc(n, e, t));
|
|
7697
7773
|
g.assign(r.valid), v.assign(r.direction), y.assign(r.emission), b.assign(r.distance), x.assign(r.pdf), S.assign(r.lightType);
|
|
7698
7774
|
}), p(k.equal(N(3)).and(A.greaterThanEqual(N(0))), () => {
|
|
7699
|
-
let n = uo.wrap(_o(f, A)), r = fo.wrap(
|
|
7775
|
+
let n = uo.wrap(_o(f, A)), r = fo.wrap(Vc(n, e, t));
|
|
7700
7776
|
g.assign(r.valid), v.assign(r.direction), y.assign(r.emission), b.assign(r.distance), x.assign(r.pdf), S.assign(r.lightType);
|
|
7701
7777
|
});
|
|
7702
7778
|
});
|
|
@@ -7708,7 +7784,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7708
7784
|
pdf: x,
|
|
7709
7785
|
lightType: S
|
|
7710
7786
|
});
|
|
7711
|
-
}),
|
|
7787
|
+
}), Wc = f(([e, t]) => {
|
|
7712
7788
|
let n = t.NoV, r = t.NoL.toVar(), i = t.NoH, a = M(1).sub(e.metalness).mul(M(1).sub(e.transmission)).toVar(), o = M(1).sub(a.mul(M(1).sub(e.metalness))).toVar(), s = a.add(o).toVar(), c = M(0).toVar();
|
|
7713
7789
|
return p(s.greaterThan(0), () => {
|
|
7714
7790
|
let t = M(1).div(F(s, 1e-10)).toVar();
|
|
@@ -7719,8 +7795,8 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7719
7795
|
c.addAssign(o.mul(fa(i, n, t)));
|
|
7720
7796
|
});
|
|
7721
7797
|
}), F(c, 1e-8);
|
|
7722
|
-
}),
|
|
7723
|
-
let te = W(0).toVar(), ne = e.add(t.mul(.001)).toVar(), re = f(([e, t, n]) => to(e, t, n,
|
|
7798
|
+
}), Gc = f(([e, t, n, r]) => Wc(r, _i.wrap(Ui(n, e, t)))), Kc = f(([e, t, n, r, i, a, o, s, c, l, u, d, h, g, _, v, y, b, x, S, C, w, E, D, O, k, j, ee]) => {
|
|
7799
|
+
let te = W(0).toVar(), ne = e.add(t.mul(.001)).toVar(), re = f(([e, t, n]) => to(e, t, n, Ec, b, x, S));
|
|
7724
7800
|
return p(n.emissiveIntensity.lessThanEqual(10), () => {
|
|
7725
7801
|
let f = W(1).toVar(), b = wi.wrap(Ji(n.roughness, n.metalness, s, f)), x = b.useBRDFSampling.toVar(), S = b.useLightSampling.toVar(), P = b.brdfWeight.toVar(), ie = b.lightWeight.toVar(), ae = u.add(h).add(_).add(y).toVar(), oe = M(.001).mul(M(1).add(M(s).mul(.5))).toVar(), se = ae.greaterThan(N(0)).toVar(), ce = M(0).toVar();
|
|
7726
7802
|
p(S.and(se), () => {
|
|
@@ -7738,7 +7814,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7738
7814
|
}).ElseIf(se, () => {
|
|
7739
7815
|
de.assign(T(!0));
|
|
7740
7816
|
}), p(de, () => {
|
|
7741
|
-
let e = U(ue, Y(c)).toVar(), i = fo.wrap(
|
|
7817
|
+
let e = U(ue, Y(c)).toVar(), i = fo.wrap(Uc(ne, t, n, e, s, c, l, u, d, h, g, _, v, y));
|
|
7742
7818
|
p(i.valid.and(i.pdf.greaterThan(0)), () => {
|
|
7743
7819
|
let e = F(M(0), A(t, i.direction)).toVar(), a = i.emission.x.add(i.emission.y).add(i.emission.z);
|
|
7744
7820
|
p(e.greaterThan(0).and(a.mul(e).greaterThan(oe)).and(vo({
|
|
@@ -7747,7 +7823,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7747
7823
|
})), () => {
|
|
7748
7824
|
let a = le(i.distance.sub(.001), M(1e3)), o = re(ne, i.direction, a);
|
|
7749
7825
|
p(o.greaterThan(0), () => {
|
|
7750
|
-
let a = _i.wrap(Ui(t, r, i.direction)), s =
|
|
7826
|
+
let a = _i.wrap(Ui(t, r, i.direction)), s = Ic(n, a), c = Wc(n, a).toVar(), l = M(1).toVar();
|
|
7751
7827
|
p(c.greaterThan(0).and(x), () => {
|
|
7752
7828
|
let e = i.pdf.mul(ie), t = c.mul(P);
|
|
7753
7829
|
p(i.lightType.equal(N(1)), () => {
|
|
@@ -7810,7 +7886,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7810
7886
|
});
|
|
7811
7887
|
});
|
|
7812
7888
|
}), p(ee, () => {
|
|
7813
|
-
let e = U(Y(c).toVar(), Y(c).toVar()).toVar(), i = W(0).toVar(), a =
|
|
7889
|
+
let e = U(Y(c).toVar(), Y(c).toVar()).toVar(), i = W(0).toVar(), a = Nc(C, D, E, w, O, k, j, e, i).toVar(), o = a.xyz.toVar(), s = a.w.toVar();
|
|
7814
7890
|
p(s.greaterThan(0), () => {
|
|
7815
7891
|
let e = F(M(0), A(t, o)).toVar();
|
|
7816
7892
|
p(e.greaterThan(0).and(vo({
|
|
@@ -7819,7 +7895,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7819
7895
|
})), () => {
|
|
7820
7896
|
let a = re(ne, o, M(1e3));
|
|
7821
7897
|
p(a.greaterThan(0), () => {
|
|
7822
|
-
let c = _i.wrap(Ui(t, r, o)), l =
|
|
7898
|
+
let c = _i.wrap(Ui(t, r, o)), l = Ic(n, c), u = Wc(n, c).toVar(), d = R(u.greaterThan(0), Vi({
|
|
7823
7899
|
pdf1: s,
|
|
7824
7900
|
pdf2: u
|
|
7825
7901
|
}), M(1)).toVar(), f = i.mul(l).mul(e).mul(a).mul(d).div(F(s, 1e-10));
|
|
@@ -7829,17 +7905,17 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7829
7905
|
});
|
|
7830
7906
|
});
|
|
7831
7907
|
}), te;
|
|
7832
|
-
}),
|
|
7908
|
+
}), qc = f(([e, t, n, r, i, a]) => {
|
|
7833
7909
|
let o = R(a, r, M(1).div(r)).toVar(), s = e.add(t.mul(o)).toVar(), c = A(s, s).toVar(), l = R(c.greaterThan(Oi), s.div(xe(c)), n).toVar();
|
|
7834
7910
|
p(A(l, n).lessThan(0), () => {
|
|
7835
7911
|
l.assign(l.negate());
|
|
7836
7912
|
});
|
|
7837
7913
|
let u = _(A(e, l)), d = _(A(t, l)).toVar(), f = _(A(n, l)).toVar(), m = sa(f, i), h = u.add(d.mul(o)).toVar(), g = h.mul(h), v = d.mul(o).mul(o).div(F(g, Oi));
|
|
7838
7914
|
return m.mul(f).mul(v);
|
|
7839
|
-
}),
|
|
7915
|
+
}), Jc = f(([e, t, n, r]) => {
|
|
7840
7916
|
let i = e.add(t).toVar(), a = A(i, i).toVar();
|
|
7841
7917
|
return fa(F(A(n, R(a.greaterThan(Oi), i.div(xe(a)), n)), 0), F(A(n, e), 0), r);
|
|
7842
|
-
}),
|
|
7918
|
+
}), Yc = f(([e]) => {
|
|
7843
7919
|
let t = e.specularImportance.toVar(), n = t.greaterThan(.001).toVar(), r = e.diffuseImportance.toVar(), i = r.greaterThan(.001).toVar(), a = e.transmissionImportance.toVar(), o = a.greaterThan(.001).toVar(), s = e.clearcoatImportance.toVar(), c = s.greaterThan(.001).toVar(), l = t.add(r).add(a).add(s).toVar();
|
|
7844
7920
|
return p(l.lessThan(.001), () => {
|
|
7845
7921
|
t.assign(0), r.assign(1), a.assign(0), s.assign(0), l.assign(1), n.assign(T(!1)), i.assign(T(!0)), o.assign(T(!1)), c.assign(T(!1));
|
|
@@ -7859,7 +7935,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7859
7935
|
useTransmission: o,
|
|
7860
7936
|
useClearcoat: c
|
|
7861
7937
|
});
|
|
7862
|
-
}),
|
|
7938
|
+
}), Xc = f(([e, t]) => {
|
|
7863
7939
|
let n = N(2).toVar(), r = M(0).toVar(), i = T(!1).toVar();
|
|
7864
7940
|
return p(e.useSpecular.and(i.not()), () => {
|
|
7865
7941
|
r.addAssign(e.specularWeight), p(t.lessThan(r), () => {
|
|
@@ -7876,20 +7952,20 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7876
7952
|
}), p(e.useClearcoat.and(i.not()), () => {
|
|
7877
7953
|
n.assign(4);
|
|
7878
7954
|
}), n;
|
|
7879
|
-
}),
|
|
7955
|
+
}), Zc = f(([e]) => F(e, 0).mul(Ei)), Qc = f(([e, t, n, r, i, a, o, s]) => {
|
|
7880
7956
|
let c = W(0).toVar(), l = W(0).toVar(), u = M(0).toVar(), d = M(0).toVar(), f = M(0).toVar();
|
|
7881
7957
|
return p(s.diffuseImportance.greaterThanEqual(0).and(s.specularImportance.greaterThanEqual(0)).and(s.transmissionImportance.greaterThanEqual(0)).and(s.clearcoatImportance.greaterThanEqual(0)).not(), () => {
|
|
7882
7958
|
let e = U(Y(o).toVar(), Y(o).toVar());
|
|
7883
7959
|
c.assign(ya(t, e)), l.assign(n.color.xyz), u.assign(1), d.assign(1);
|
|
7884
7960
|
}).Else(() => {
|
|
7885
|
-
let m = Ci.wrap(
|
|
7961
|
+
let m = Ci.wrap(Yc(s).toVar()), h = Y(o).toVar(), g = U(Y(o).toVar(), Y(o).toVar()).toVar(), v = Xc(m, h).toVar(), y = W(0).toVar(), b = M(0).toVar(), x = W(0).toVar();
|
|
7886
7962
|
p(v.equal(N(1)), () => {
|
|
7887
7963
|
y.assign(r), b.assign(i), x.assign(a);
|
|
7888
7964
|
}).ElseIf(v.equal(N(2)), () => {
|
|
7889
|
-
y.assign(ya(t, g)), b.assign(
|
|
7965
|
+
y.assign(ya(t, g)), b.assign(Zc(F(A(t, y), 0))), x.assign(Lc(e, y, t, n));
|
|
7890
7966
|
}).ElseIf(v.equal(N(3)), () => {
|
|
7891
7967
|
let r = A(e, t).greaterThan(0), i = ja.wrap(La(e, t, n.ior, n.roughness, r, n.dispersion, g, o, M(0)).toVar());
|
|
7892
|
-
y.assign(i.direction), b.assign(i.pdf), x.assign(
|
|
7968
|
+
y.assign(i.direction), b.assign(i.pdf), x.assign(Lc(e, y, t, n));
|
|
7893
7969
|
}).Else(() => {
|
|
7894
7970
|
y.assign(r), b.assign(i), x.assign(a);
|
|
7895
7971
|
});
|
|
@@ -7898,12 +7974,12 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7898
7974
|
let r = fa(F(A(t, L(e.add(y))), .001), F(A(t, e), .001), n.roughness);
|
|
7899
7975
|
T.addAssign(m.specularWeight.mul(r));
|
|
7900
7976
|
}), p(m.useDiffuse, () => {
|
|
7901
|
-
T.addAssign(m.diffuseWeight.mul(
|
|
7977
|
+
T.addAssign(m.diffuseWeight.mul(Zc(C)));
|
|
7902
7978
|
}), p(m.useTransmission.and(n.transmission.greaterThan(0)), () => {
|
|
7903
7979
|
let r = A(e, t).greaterThan(0);
|
|
7904
|
-
T.addAssign(m.transmissionWeight.mul(
|
|
7980
|
+
T.addAssign(m.transmissionWeight.mul(qc(e, y, t, n.ior, n.roughness, r)));
|
|
7905
7981
|
}), p(m.useClearcoat.and(n.clearcoat.greaterThan(0)), () => {
|
|
7906
|
-
T.addAssign(m.clearcoatWeight.mul(
|
|
7982
|
+
T.addAssign(m.clearcoatWeight.mul(Jc(e, y, t, n.clearcoatRoughness)));
|
|
7907
7983
|
}), b.assign(F(b, ji)), T.assign(F(T, ji));
|
|
7908
7984
|
let E = b.div(T).toVar(), D = R(v.equal(N(3)), w, C);
|
|
7909
7985
|
c.assign(y), l.assign(x.mul(D).mul(E).div(b)), u.assign(E), d.assign(b), f.assign(T);
|
|
@@ -7914,7 +7990,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7914
7990
|
pdf: d,
|
|
7915
7991
|
combinedPdf: f
|
|
7916
7992
|
});
|
|
7917
|
-
}),
|
|
7993
|
+
}), $c = f(([e, t, n, r, i, a, o, s, c, l]) => {
|
|
7918
7994
|
let u = W(0).toVar(), d = W(0).toVar(), f = M(0).toVar(), m = s.toVar();
|
|
7919
7995
|
p(o.not(), () => {
|
|
7920
7996
|
p(c, () => {
|
|
@@ -7943,7 +8019,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7943
8019
|
xi: g
|
|
7944
8020
|
}));
|
|
7945
8021
|
let r = E(A(t, u), 0, 1);
|
|
7946
|
-
f.assign(r.mul(Ei)), d.assign(
|
|
8022
|
+
f.assign(r.mul(Ei)), d.assign(Lc(e, u, t, n));
|
|
7947
8023
|
}).ElseIf(h.lessThan(y), () => {
|
|
7948
8024
|
let i = Hi({ N: t }), a = ba({
|
|
7949
8025
|
V: i.transpose().mul(e),
|
|
@@ -7952,7 +8028,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7952
8028
|
});
|
|
7953
8029
|
_.assign(i.mul(a));
|
|
7954
8030
|
let o = E(A(t, _), .001, 1);
|
|
7955
|
-
u.assign(he(e.negate(), _)), f.assign(fa(o, S, n.roughness)), d.assign(
|
|
8031
|
+
u.assign(he(e.negate(), _)), f.assign(fa(o, S, n.roughness)), d.assign(Lc(e, u, t, n));
|
|
7956
8032
|
}).ElseIf(h.lessThan(b), () => {
|
|
7957
8033
|
_.assign(_a({
|
|
7958
8034
|
N: t,
|
|
@@ -7966,9 +8042,9 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7966
8042
|
u.assign(va({
|
|
7967
8043
|
N: t,
|
|
7968
8044
|
xi: r
|
|
7969
|
-
})), o.assign(E(A(t, u), 0, 1)), f.assign(o.mul(Ei)), d.assign(
|
|
8045
|
+
})), o.assign(E(A(t, u), 0, 1)), f.assign(o.mul(Ei)), d.assign(Lc(e, u, t, n));
|
|
7970
8046
|
}).Else(() => {
|
|
7971
|
-
f.assign(ca(i, n.sheenRoughness).mul(i).div(M(4).mul(a))), f.assign(F(f, ji)), d.assign(
|
|
8047
|
+
f.assign(ca(i, n.sheenRoughness).mul(i).div(M(4).mul(a))), f.assign(F(f, ji)), d.assign(Lc(e, u, t, n));
|
|
7972
8048
|
});
|
|
7973
8049
|
}).ElseIf(h.lessThan(x), () => {
|
|
7974
8050
|
let i = E(n.clearcoatRoughness, Ai, 1);
|
|
@@ -7978,16 +8054,16 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
7978
8054
|
Xi: r
|
|
7979
8055
|
}));
|
|
7980
8056
|
let a = E(A(t, _), 0, 1);
|
|
7981
|
-
u.assign(he(e.negate(), _)), f.assign(fa(a, S, i)), f.assign(F(f, ji)), d.assign(
|
|
8057
|
+
u.assign(he(e.negate(), _)), f.assign(fa(a, S, i)), f.assign(F(f, ji)), d.assign(Lc(e, u, t, n));
|
|
7982
8058
|
}).Else(() => {
|
|
7983
8059
|
let a = A(e, t).greaterThan(0), o = ja.wrap(La(e, t, n.ior, n.roughness, a, n.dispersion, r, i, M(0)));
|
|
7984
|
-
u.assign(o.direction), f.assign(F(o.pdf, ji)), d.assign(
|
|
8060
|
+
u.assign(o.direction), f.assign(F(o.pdf, ji)), d.assign(Lc(e, u, t, n));
|
|
7985
8061
|
}), f.assign(F(f, ji)), mi({
|
|
7986
8062
|
direction: u,
|
|
7987
8063
|
value: d,
|
|
7988
8064
|
pdf: f
|
|
7989
8065
|
});
|
|
7990
|
-
}),
|
|
8066
|
+
}), el = /* @__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", [Wi, Ki]), tl = /* @__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"), nl = f(([e, t, n, r, i, a, o]) => {
|
|
7991
8067
|
let s = M(1).toVar();
|
|
7992
8068
|
return p(e.greaterThanEqual(N(3)), () => {
|
|
7993
8069
|
let c = F(F(F(t.x, t.y), t.z), 0).toVar();
|
|
@@ -8038,11 +8114,11 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8038
8114
|
});
|
|
8039
8115
|
});
|
|
8040
8116
|
}), s;
|
|
8041
|
-
}),
|
|
8117
|
+
}), rl = Cn({
|
|
8042
8118
|
brdf: "vec3",
|
|
8043
8119
|
L: "vec3",
|
|
8044
8120
|
pdf: "float"
|
|
8045
|
-
}),
|
|
8121
|
+
}), il = f(([e, t, n, r, i]) => {
|
|
8046
8122
|
let a = t.normal, o = e.direction.negate(), s = F(n.clearcoatRoughness, Ai), c = F(n.roughness, Ai), 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);
|
|
8047
8123
|
l.divAssign(f), u.divAssign(f), d.divAssign(f);
|
|
8048
8124
|
let m = Y(i), h = W(0).toVar(), g = W(0).toVar();
|
|
@@ -8065,22 +8141,22 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8065
8141
|
})), g.assign(L(o.add(h)));
|
|
8066
8142
|
});
|
|
8067
8143
|
let _ = _i.wrap(Ui(a, o, h)), v = sa(_.NoH, s).mul(_.NoH).div(M(4).mul(_.VoH)).mul(u), y = sa(_.NoH, c).mul(_.NoH).div(M(4).mul(_.VoH)).mul(l), b = _.NoL.div(Ti).mul(d), x = F(v.add(y).add(b), .001);
|
|
8068
|
-
return
|
|
8069
|
-
brdf:
|
|
8144
|
+
return rl({
|
|
8145
|
+
brdf: Rc(_, n),
|
|
8070
8146
|
L: h,
|
|
8071
8147
|
pdf: x
|
|
8072
8148
|
});
|
|
8073
|
-
}),
|
|
8149
|
+
}), al = 32, ol = 16, sl = 5, cl = 1 / 1024, ll = 8, ul = Cn({
|
|
8074
8150
|
hitPoint: "vec3",
|
|
8075
8151
|
uv: "vec2",
|
|
8076
8152
|
normal: "vec3",
|
|
8077
8153
|
height: "float"
|
|
8078
|
-
}),
|
|
8079
|
-
let o = t.hitPoint.toVar(), s = t.uv.toVar(), c = t.normal.toVar(), l = M(0).toVar(), u = t.triangleIndex, d = $(n, u, N(0), N(
|
|
8154
|
+
}), dl = f(([e, t, n, r, i, a]) => {
|
|
8155
|
+
let o = t.hitPoint.toVar(), s = t.uv.toVar(), c = t.normal.toVar(), l = M(0).toVar(), u = t.triangleIndex, d = $(n, u, N(0), N(ll)).xyz.toVar(), f = $(n, u, N(1), N(ll)).xyz, h = $(n, u, N(2), N(ll)).xyz, g = $(n, u, N(6), N(ll)).toVar(), v = $(n, u, N(7), N(ll)), y = g.xy.toVar(), b = g.zw, x = v.xy, S = f.sub(d).toVar(), C = h.sub(d).toVar(), w = b.sub(y).toVar(), T = x.sub(y).toVar(), E = w.x.mul(T.y).sub(T.x.mul(w.y)).toVar();
|
|
8080
8156
|
return p(_(E).greaterThan(1e-8), () => {
|
|
8081
8157
|
let n = M(1).div(E), u = S.mul(T.y).sub(C.mul(w.y)).mul(n).toVar(), d = C.mul(w.x).sub(S.mul(T.x)).mul(n).toVar(), f = t.normal.toVar(), h = i.displacementScale.div(M(10)), g = e.direction, v = A(g, f).toVar(), y = g.sub(f.mul(v)).toVar(), b = A(u, u), x = A(u, d), D = A(d, d), O = b.mul(D).sub(x.mul(x)).toVar();
|
|
8082
8158
|
p(_(O).greaterThan(1e-10), () => {
|
|
8083
|
-
let e = M(1).div(O), n = A(y, u), S = A(y, d), C = U(D.mul(n).sub(x.mul(S)).mul(e), b.mul(S).sub(x.mul(n)).mul(e)).toVar(), w = v.toVar(), T = F(_(w), .001), E = h.div(T).toVar(), k = N(a.equal(N(0)).select(N(
|
|
8159
|
+
let e = M(1).div(O), n = A(y, u), S = A(y, d), C = U(D.mul(n).sub(x.mul(S)).mul(e), b.mul(S).sub(x.mul(n)).mul(e)).toVar(), w = v.toVar(), T = F(_(w), .001), E = h.div(T).toVar(), k = N(a.equal(N(0)).select(N(al), N(ol))).toVar(), j = E.negate().toVar(), ee = E.sub(j).div(M(k)).toVar(), te = j.toVar(), ne = j.toVar(), re = N(0).toVar();
|
|
8084
8160
|
m({
|
|
8085
8161
|
start: N(0),
|
|
8086
8162
|
end: k,
|
|
@@ -8099,7 +8175,7 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8099
8175
|
let e = te.toVar(), n = ne.toVar();
|
|
8100
8176
|
m({
|
|
8101
8177
|
start: N(0),
|
|
8102
|
-
end: N(
|
|
8178
|
+
end: N(sl),
|
|
8103
8179
|
type: "int",
|
|
8104
8180
|
condition: "<"
|
|
8105
8181
|
}, () => {
|
|
@@ -8110,17 +8186,17 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8110
8186
|
e.assign(a);
|
|
8111
8187
|
});
|
|
8112
8188
|
});
|
|
8113
|
-
let a = e.add(n).mul(.5).toVar(), _ = t.uv.add(C.mul(a)).toVar(), v = t.hitPoint.add(g.mul(a)), y = Xa(r, i.displacementMapIndex, _, i.displacementTransform), b = y.sub(.5).mul(h), x = M(
|
|
8189
|
+
let a = e.add(n).mul(.5).toVar(), _ = t.uv.add(C.mul(a)).toVar(), v = t.hitPoint.add(g.mul(a)), y = Xa(r, i.displacementMapIndex, _, i.displacementTransform), b = y.sub(.5).mul(h), x = M(cl), S = y, T = Xa(r, i.displacementMapIndex, _.add(U(x, 0)), i.displacementTransform), E = Xa(r, i.displacementMapIndex, _.add(U(0, x)), i.displacementTransform), D = L(u).toVar(), O = L(d).toVar(), k = T.sub(S).mul(h), A = E.sub(S).mul(h), j = L(f.sub(D.mul(k)).sub(O.mul(A)));
|
|
8114
8190
|
o.assign(v), s.assign(_), c.assign(j), l.assign(b);
|
|
8115
8191
|
});
|
|
8116
8192
|
});
|
|
8117
|
-
}),
|
|
8193
|
+
}), ul({
|
|
8118
8194
|
hitPoint: o,
|
|
8119
8195
|
uv: s,
|
|
8120
8196
|
normal: c,
|
|
8121
8197
|
height: l
|
|
8122
8198
|
});
|
|
8123
|
-
}),
|
|
8199
|
+
}), fl = Cn({
|
|
8124
8200
|
position: "vec3",
|
|
8125
8201
|
normal: "vec3",
|
|
8126
8202
|
emission: "vec3",
|
|
@@ -8130,40 +8206,40 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8130
8206
|
area: "float",
|
|
8131
8207
|
cosThetaLight: "float",
|
|
8132
8208
|
valid: "bool"
|
|
8133
|
-
}),
|
|
8209
|
+
}), pl = Cn({
|
|
8134
8210
|
contribution: "vec3",
|
|
8135
8211
|
hasEmissive: "bool",
|
|
8136
8212
|
emissionOnly: "vec3",
|
|
8137
8213
|
distance: "float"
|
|
8138
|
-
}),
|
|
8214
|
+
}), ml = f(([e, t, n, r]) => {
|
|
8139
8215
|
let i = xe(r.x), a = M(1).sub(i), o = r.y.mul(i), s = M(1).sub(a).sub(o);
|
|
8140
8216
|
return e.mul(a).add(t.mul(o)).add(n.mul(s));
|
|
8141
|
-
}),
|
|
8217
|
+
}), hl = f(([e, t, n]) => ie(O(t.sub(e), n.sub(e))).mul(.5)), gl = f(([e, t, n, r]) => {
|
|
8142
8218
|
let i = L(e.sub(r)), a = L(t.sub(r)), o = L(n.sub(r)), s = _(A(i, O(a, o))), c = M(1).add(A(a, o)).add(A(i, o)).add(A(i, a));
|
|
8143
8219
|
return F(M(2).mul(b(s, F(c, M(1e-10)))), M(0));
|
|
8144
|
-
}),
|
|
8220
|
+
}), _l = f(([e, t, n, r]) => {
|
|
8145
8221
|
let i = t.sub(e), a = n.sub(e), o = n.sub(t), s = F(A(i, i), F(A(a, a), A(o, o))), c = O(i, a), l = A(c, c), u = T(!1).toVar();
|
|
8146
8222
|
return p(l.greaterThan(1e-20), () => {
|
|
8147
8223
|
let t = A(c, r.sub(e)), n = t.mul(t).div(l);
|
|
8148
8224
|
u.assign(s.greaterThan(n));
|
|
8149
8225
|
}), u;
|
|
8150
|
-
}),
|
|
8226
|
+
}), vl = Cn({
|
|
8151
8227
|
direction: "vec3",
|
|
8152
8228
|
position: "vec3",
|
|
8153
8229
|
solidAngle: "float",
|
|
8154
8230
|
valid: "bool"
|
|
8155
|
-
}),
|
|
8231
|
+
}), yl = f(([e]) => {
|
|
8156
8232
|
let t = ie(e);
|
|
8157
8233
|
return R(t.greaterThan(1e-10), e.div(t), W(0));
|
|
8158
|
-
}),
|
|
8159
|
-
let a =
|
|
8234
|
+
}), bl = f(([e, t, n, r, i]) => {
|
|
8235
|
+
let a = vl({
|
|
8160
8236
|
direction: W(0),
|
|
8161
8237
|
position: W(0),
|
|
8162
8238
|
solidAngle: M(0),
|
|
8163
8239
|
valid: !1
|
|
8164
|
-
}).toVar(), o = L(e.sub(r)), s = L(t.sub(r)), c = L(n.sub(r)), l =
|
|
8240
|
+
}).toVar(), o = L(e.sub(r)), s = L(t.sub(r)), c = L(n.sub(r)), l = gl(e, t, n, r);
|
|
8165
8241
|
return a.solidAngle.assign(l), p(l.greaterThan(1e-7), () => {
|
|
8166
|
-
let u = E(A(
|
|
8242
|
+
let u = E(A(yl(O(o, s)), yl(O(o, c))), -1, 1), d = xe(F(M(1).sub(u.mul(u)), 0)), f = v(u), m = i.x.mul(l).sub(f), h = ye(m), g = D(m), y = E(A(o, s), -1, 1), b = g.sub(u), x = h.add(d.mul(y)), S = x.mul(g).sub(b.mul(h)).mul(u).sub(x), C = x.mul(h).add(b.mul(g)).mul(d), w = E(R(_(C).greaterThan(1e-10), S.div(C), M(1)), -1, 1), T = A(c, o), k = yl(c.sub(o.mul(T))), j = xe(F(M(1).sub(w.mul(w)), 0)), ee = L(o.mul(w).add(k.mul(j))), te = A(ee, s), ne = M(1).sub(i.y.mul(M(1).sub(te))), re = xe(F(M(1).sub(ne.mul(ne)), 0)), N = yl(ee.sub(s.mul(te))), P = L(s.mul(ne).add(N.mul(re))), ie = L(O(t.sub(e), n.sub(e))), ae = A(ie, P);
|
|
8167
8243
|
p(_(ae).greaterThan(1e-10), () => {
|
|
8168
8244
|
let t = A(ie, e.sub(r)).div(ae);
|
|
8169
8245
|
p(t.greaterThan(0), () => {
|
|
@@ -8171,15 +8247,15 @@ var Oc = /* @__PURE__ */ K("\n fn equirectDirectionToUv( direction: vec3f, envir
|
|
|
8171
8247
|
});
|
|
8172
8248
|
});
|
|
8173
8249
|
}), a;
|
|
8174
|
-
}),
|
|
8250
|
+
}), xl = f(([e, t, n, r]) => {
|
|
8175
8251
|
let i = n.sub(t), a = r.sub(t), o = e.sub(t), s = A(i, i), c = A(i, a), l = A(a, a), u = A(o, i), d = A(o, a), f = M(1).div(F(s.mul(l).sub(c.mul(c)), M(1e-10))), p = l.mul(u).sub(c.mul(d)).mul(f), m = s.mul(d).sub(c.mul(u)).mul(f);
|
|
8176
8252
|
return W(M(1).sub(p).sub(m), p, m);
|
|
8177
|
-
}),
|
|
8253
|
+
}), Sl = f(([e, t, n, r]) => {
|
|
8178
8254
|
let i = xe(r.x), a = M(1).sub(i), o = r.y.mul(i), s = M(1).sub(a).sub(o);
|
|
8179
8255
|
return L(e.mul(a).add(t.mul(o)).add(n.mul(s)));
|
|
8180
8256
|
});
|
|
8181
8257
|
f(([e]) => e.emissiveIntensity.greaterThan(0).and(ie(e.emissive).greaterThan(0)));
|
|
8182
|
-
var
|
|
8258
|
+
var Cl = 8, wl = 2, Tl = Cn({
|
|
8183
8259
|
v0: "vec3",
|
|
8184
8260
|
v1: "vec3",
|
|
8185
8261
|
v2: "vec3",
|
|
@@ -8187,9 +8263,9 @@ var xl = 8, Sl = 2, Cl = Cn({
|
|
|
8187
8263
|
n1: "vec3",
|
|
8188
8264
|
n2: "vec3",
|
|
8189
8265
|
materialIndex: "int"
|
|
8190
|
-
}),
|
|
8191
|
-
let n = $(t, e, N(0), N(
|
|
8192
|
-
return
|
|
8266
|
+
}), El = f(([e, t]) => {
|
|
8267
|
+
let n = $(t, e, N(0), N(Cl)), r = $(t, e, N(1), N(Cl)), i = $(t, e, N(2), N(Cl)), a = $(t, e, N(3), N(Cl)), o = $(t, e, N(4), N(Cl)), s = $(t, e, N(5), N(Cl)), c = $(t, e, N(7), N(Cl));
|
|
8268
|
+
return Tl({
|
|
8193
8269
|
v0: n.xyz,
|
|
8194
8270
|
v1: r.xyz,
|
|
8195
8271
|
v2: i.xyz,
|
|
@@ -8198,27 +8274,27 @@ var xl = 8, Sl = 2, Cl = Cn({
|
|
|
8198
8274
|
n2: s.xyz,
|
|
8199
8275
|
materialIndex: N(c.z)
|
|
8200
8276
|
});
|
|
8201
|
-
}),
|
|
8202
|
-
let s =
|
|
8203
|
-
return p(
|
|
8204
|
-
let e =
|
|
8277
|
+
}), Dl = f(([e, t, n, r, i, a, o]) => {
|
|
8278
|
+
let s = Tl.wrap(El(e, i)), c = hl(s.v0, s.v1, s.v2), l = $(a, s.materialIndex, N(Pi.EMISSIVE_ROUGHNESS), Ni), u = $(a, s.materialIndex, N(Pi.IOR_TRANSMISSION), Ni), d = F(l.x.mul(.2126).add(l.y.mul(.7152)).add(l.z.mul(.0722)).mul(u.a).mul(c), M(1e-10)).div(F(o, M(1e-10))), f = M(0).toVar();
|
|
8279
|
+
return p(_l(s.v0, s.v1, s.v2, r), () => {
|
|
8280
|
+
let e = gl(s.v0, s.v1, s.v2, r);
|
|
8205
8281
|
f.assign(d.div(F(e, M(1e-10))));
|
|
8206
8282
|
}).Else(() => {
|
|
8207
8283
|
let e = L(O(s.v1.sub(s.v0), s.v2.sub(s.v0))), r = F(A(n.negate(), e), .001), i = t.mul(t), a = d.div(c);
|
|
8208
8284
|
f.assign(a.mul(i).div(r));
|
|
8209
8285
|
}), F(f, ji);
|
|
8210
|
-
}),
|
|
8286
|
+
}), Ol = f(([e, t, n, r]) => {
|
|
8211
8287
|
let i = N(0).toVar(), a = n.sub(1).toVar();
|
|
8212
8288
|
return m(i.lessThan(a), () => {
|
|
8213
|
-
let n = i.add(a).div(2).toVar(), o = e.element(t.add(n.mul(N(
|
|
8289
|
+
let n = i.add(a).div(2).toVar(), o = e.element(t.add(n.mul(N(wl)))).b;
|
|
8214
8290
|
p(o.lessThan(r), () => {
|
|
8215
8291
|
i.assign(n.add(1));
|
|
8216
8292
|
}).Else(() => {
|
|
8217
8293
|
a.assign(n);
|
|
8218
8294
|
});
|
|
8219
8295
|
}), i;
|
|
8220
|
-
}),
|
|
8221
|
-
let c =
|
|
8296
|
+
}), kl = f(([e, t, n, r, i, a, o, s]) => {
|
|
8297
|
+
let c = fl({
|
|
8222
8298
|
position: W(0),
|
|
8223
8299
|
normal: W(0),
|
|
8224
8300
|
emission: W(0),
|
|
@@ -8230,40 +8306,40 @@ var xl = 8, Sl = 2, Cl = Cn({
|
|
|
8230
8306
|
valid: !1
|
|
8231
8307
|
}).toVar();
|
|
8232
8308
|
return p(a.greaterThan(N(0)), () => {
|
|
8233
|
-
let l =
|
|
8234
|
-
p(
|
|
8235
|
-
let n =
|
|
8309
|
+
let l = Ol(r, i, a, Y(n)).toVar(), u = i.add(l.mul(N(wl))), d = r.element(u), f = r.element(u.add(1)), m = N(d.r), h = F(d.g, M(1e-10)), g = f.xyz, _ = f.w, v = Tl.wrap(El(m, s)), y = U(Y(n).toVar(), Y(n).toVar()), b = L(O(v.v1.sub(v.v0), v.v2.sub(v.v0)));
|
|
8310
|
+
p(_l(v.v0, v.v1, v.v2, e), () => {
|
|
8311
|
+
let n = vl.wrap(bl(v.v0, v.v1, v.v2, e, y));
|
|
8236
8312
|
p(n.valid.and(n.solidAngle.greaterThan(1e-7)), () => {
|
|
8237
8313
|
let r = n.direction, i = n.position, a = A(r, t), s = A(r, b.negate());
|
|
8238
8314
|
p(a.greaterThan(0).and(s.greaterThan(0)), () => {
|
|
8239
|
-
let t =
|
|
8315
|
+
let t = xl(i, v.v0, v.v1, v.v2), a = L(v.n0.mul(t.x).add(v.n1.mul(t.y)).add(v.n2.mul(t.z))), l = ie(i.sub(e)), u = h.div(F(o, M(1e-10))).div(n.solidAngle);
|
|
8240
8316
|
c.position.assign(i), c.normal.assign(a), c.emission.assign(g), c.direction.assign(r), c.distance.assign(l), c.pdf.assign(F(u, ji)), c.area.assign(_), c.cosThetaLight.assign(s), c.valid.assign(!0);
|
|
8241
8317
|
});
|
|
8242
8318
|
});
|
|
8243
8319
|
}).Else(() => {
|
|
8244
|
-
let n =
|
|
8320
|
+
let n = ml(v.v0, v.v1, v.v2, y), r = Sl(v.n0, v.n1, v.n2, y), i = n.sub(e), a = A(i, i), s = xe(a), l = i.div(s), u = A(l, t), d = A(l, r.negate());
|
|
8245
8321
|
p(u.greaterThan(0).and(d.greaterThan(0)), () => {
|
|
8246
8322
|
let e = h.div(F(o, M(1e-10)).mul(_)).mul(a).div(d);
|
|
8247
8323
|
c.position.assign(n), c.normal.assign(r), c.emission.assign(g), c.direction.assign(l), c.distance.assign(s), c.pdf.assign(F(e, ji)), c.area.assign(_), c.cosThetaLight.assign(d), c.valid.assign(!0);
|
|
8248
8324
|
});
|
|
8249
8325
|
});
|
|
8250
8326
|
}), c;
|
|
8251
|
-
}),
|
|
8252
|
-
let h =
|
|
8327
|
+
}), Al = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m]) => {
|
|
8328
|
+
let h = pl({
|
|
8253
8329
|
contribution: W(0),
|
|
8254
8330
|
hasEmissive: !1,
|
|
8255
8331
|
emissionOnly: W(0),
|
|
8256
8332
|
distance: M(0)
|
|
8257
8333
|
}).toVar();
|
|
8258
8334
|
return p(i.greaterThan(N(1)).and(r.roughness.greaterThan(.9)).and(r.metalness.lessThan(.1)).not(), () => {
|
|
8259
|
-
let i =
|
|
8335
|
+
let i = fl.wrap(kl(e, t, a, s, c, l, u, d));
|
|
8260
8336
|
p(i.valid.and(i.pdf.greaterThan(0)), () => {
|
|
8261
8337
|
h.hasEmissive.assign(!0), h.emissionOnly.assign(i.emission), h.distance.assign(i.distance);
|
|
8262
8338
|
let a = F(M(0), A(t, i.direction));
|
|
8263
8339
|
p(a.greaterThan(0), () => {
|
|
8264
8340
|
let s = m(e, t, r), c = e.add(s), l = i.distance.sub(.001), u = f(c, i.direction, l);
|
|
8265
8341
|
p(u.greaterThan(0), () => {
|
|
8266
|
-
let e = _i.wrap(Ui(t, n, i.direction)), s =
|
|
8342
|
+
let e = _i.wrap(Ui(t, n, i.direction)), s = Ic(r, e), c = Wc(r, e), l = R(c.greaterThan(0), Bi({
|
|
8267
8343
|
pdf1: i.pdf,
|
|
8268
8344
|
pdf2: c
|
|
8269
8345
|
}), M(1));
|
|
@@ -8272,8 +8348,11 @@ var xl = 8, Sl = 2, Cl = Cn({
|
|
|
8272
8348
|
});
|
|
8273
8349
|
});
|
|
8274
8350
|
}), h;
|
|
8275
|
-
}),
|
|
8276
|
-
let s =
|
|
8351
|
+
}), jl = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, p]) => pl.wrap(Al(e, t, n, r, i, a, o, s, c, l, u, d, f, p)).contribution), Ml = 4, Nl = 2, Pl = 32, Fl = f(([e, t, n, r]) => R(t.greaterThan(r), M(1), t.mul(r).add(e.mul(n)))), Il = f(([e, t, n, r]) => R(t.greaterThan(r), M(0), e.mul(r).sub(t.mul(n)))), Ll = f(([e, t, n, r, i, a]) => {
|
|
8352
|
+
let o = e.add(n).mul(.5), s = ie(n.sub(e)), c = a.sub(o), l = F(A(c, c), M(1e-12)), u = F(l, s.mul(.5)), d = A(r, c.div(xe(l))), f = xe(F(M(1).sub(d.mul(d)), M(0))), p = s.mul(s).mul(.25), m = E(p.div(l), M(0), M(1)), h = R(l.lessThan(p), M(-1), xe(F(M(1).sub(m), M(0)))), g = xe(F(M(1).sub(h.mul(h)), M(0))), _ = xe(F(M(1).sub(i.mul(i)), M(0))), v = Fl(f, d, _, i), y = Fl(Il(f, d, _, i), v, g, h);
|
|
8353
|
+
return F(R(y.greaterThan(M(0)), t.mul(y).div(u), M(0)), M(0));
|
|
8354
|
+
}), Rl = f(([e, t, n, r, i, a, o]) => {
|
|
8355
|
+
let s = fl({
|
|
8277
8356
|
position: W(0),
|
|
8278
8357
|
normal: W(0),
|
|
8279
8358
|
emission: W(0),
|
|
@@ -8284,16 +8363,16 @@ var xl = 8, Sl = 2, Cl = Cn({
|
|
|
8284
8363
|
cosThetaLight: M(0),
|
|
8285
8364
|
valid: !1
|
|
8286
8365
|
}).toVar(), c = M(1).toVar(), l = N(0).toVar(), u = T(!1).toVar();
|
|
8287
|
-
return m(
|
|
8288
|
-
let t = l.mul(N(
|
|
8366
|
+
return m(Pl, () => {
|
|
8367
|
+
let t = l.mul(N(Ml)), i = r.element(t.add(N(1))), a = r.element(t.add(N(2)));
|
|
8289
8368
|
p(i.w.greaterThan(.5), () => {
|
|
8290
8369
|
u.assign(T(!0)), d();
|
|
8291
8370
|
});
|
|
8292
|
-
let o = N(a.x), s = N(a.y), f = o.mul(N(
|
|
8293
|
-
p(
|
|
8371
|
+
let o = N(a.x), s = N(a.y), f = o.mul(N(Ml)), m = r.element(f), h = r.element(f.add(N(1))), g = s.mul(N(Ml)), _ = r.element(g), v = r.element(g.add(N(1))), y = r.element(f.add(N(3))), b = r.element(g.add(N(3))), x = Ll(m.xyz, m.w, h.xyz, y.xyz, y.w, e), S = Ll(_.xyz, _.w, v.xyz, b.xyz, b.w, e), C = x.add(S);
|
|
8372
|
+
p(C.lessThanEqual(M(0)), () => {
|
|
8294
8373
|
l.assign(o);
|
|
8295
8374
|
}).Else(() => {
|
|
8296
|
-
let e =
|
|
8375
|
+
let e = x.div(C);
|
|
8297
8376
|
p(Y(n).lessThan(e), () => {
|
|
8298
8377
|
c.mulAssign(e), l.assign(o);
|
|
8299
8378
|
}).Else(() => {
|
|
@@ -8301,54 +8380,99 @@ var xl = 8, Sl = 2, Cl = Cn({
|
|
|
8301
8380
|
});
|
|
8302
8381
|
});
|
|
8303
8382
|
}), p(u, () => {
|
|
8304
|
-
let u = l.mul(N(
|
|
8383
|
+
let u = l.mul(N(Ml)), f = r.element(u), h = r.element(u.add(N(2))), g = N(h.x), _ = N(h.y), v = F(f.w, M(1e-10)), y = Y(n).mul(v), b = M(0).toVar(), x = g.add(_.sub(N(1))).toVar(), S = M(1e-10).toVar();
|
|
8305
8384
|
m({
|
|
8306
8385
|
start: N(0),
|
|
8307
8386
|
end: _
|
|
8308
8387
|
}, ({ i: e }) => {
|
|
8309
|
-
let t = g.add(e), n = a.add(t.mul(N(
|
|
8388
|
+
let t = g.add(e), n = a.add(t.mul(N(Nl))), r = F(i.element(n).g, M(0));
|
|
8310
8389
|
b.addAssign(r), p(b.greaterThanEqual(y).and(r.greaterThan(M(0))), () => {
|
|
8311
8390
|
x.assign(t), S.assign(r), d();
|
|
8312
8391
|
});
|
|
8313
8392
|
}), c.mulAssign(S.div(v));
|
|
8314
|
-
let C = a.add(x.mul(N(
|
|
8315
|
-
p(
|
|
8316
|
-
let n =
|
|
8393
|
+
let C = a.add(x.mul(N(Nl))), w = i.element(C), T = i.element(C.add(N(1))), E = N(w.r), D = T.xyz, k = T.w, j = Tl.wrap(El(E, o)), ee = U(Y(n).toVar(), Y(n).toVar()), te = L(O(j.v1.sub(j.v0), j.v2.sub(j.v0)));
|
|
8394
|
+
p(_l(j.v0, j.v1, j.v2, e), () => {
|
|
8395
|
+
let n = vl.wrap(bl(j.v0, j.v1, j.v2, e, ee));
|
|
8317
8396
|
p(n.valid.and(n.solidAngle.greaterThan(M(1e-7))), () => {
|
|
8318
8397
|
let r = n.direction, i = n.position, a = A(r, t), o = A(r, te.negate());
|
|
8319
8398
|
p(a.greaterThan(M(0)).and(o.greaterThan(M(0))), () => {
|
|
8320
|
-
let t =
|
|
8399
|
+
let t = xl(i, j.v0, j.v1, j.v2), a = L(j.n0.mul(t.x).add(j.n1.mul(t.y)).add(j.n2.mul(t.z))), l = ie(i.sub(e)), u = c.div(F(n.solidAngle, M(1e-10)));
|
|
8321
8400
|
s.position.assign(i), s.normal.assign(a), s.emission.assign(D), s.direction.assign(r), s.distance.assign(l), s.pdf.assign(F(u, ji)), s.area.assign(k), s.cosThetaLight.assign(o), s.valid.assign(!0);
|
|
8322
8401
|
});
|
|
8323
8402
|
});
|
|
8324
8403
|
}).Else(() => {
|
|
8325
|
-
let n =
|
|
8404
|
+
let n = ml(j.v0, j.v1, j.v2, ee), r = Sl(j.n0, j.n1, j.n2, ee), i = n.sub(e), a = A(i, i), o = xe(a), l = i.div(o), u = A(l, t), d = A(l, r.negate());
|
|
8326
8405
|
p(u.greaterThan(M(0)).and(d.greaterThan(M(0))), () => {
|
|
8327
8406
|
let e = c.div(F(k, M(1e-10))).mul(a).div(d);
|
|
8328
8407
|
s.position.assign(n), s.normal.assign(r), s.emission.assign(D), s.direction.assign(l), s.distance.assign(o), s.pdf.assign(F(e, ji)), s.area.assign(k), s.cosThetaLight.assign(d), s.valid.assign(!0);
|
|
8329
8408
|
});
|
|
8330
8409
|
});
|
|
8331
8410
|
}), s;
|
|
8332
|
-
}),
|
|
8333
|
-
|
|
8334
|
-
|
|
8411
|
+
}), zl = f(([e, t, n, r, i, a, o, s]) => {
|
|
8412
|
+
let c = M(0).toVar(), l = N(e).toVar(), u = i.element(o.add(l.shiftRight(N(2)))), f = l.bitAnd(N(3)), h = R(f.equal(N(0)), u.x, R(f.equal(N(1)), u.y, R(f.equal(N(2)), u.z, u.w))).toVar();
|
|
8413
|
+
return p(h.greaterThanEqual(M(0)), () => {
|
|
8414
|
+
let e = N(h).toVar(), o = M(1).toVar(), u = N(0).toVar(), f = N(0).toVar(), g = T(!1).toVar();
|
|
8415
|
+
m(Pl, () => {
|
|
8416
|
+
let t = u.mul(N(Ml));
|
|
8417
|
+
p(i.element(t.add(N(1))).w.greaterThan(.5), () => {
|
|
8418
|
+
g.assign(T(!0)), d();
|
|
8419
|
+
});
|
|
8420
|
+
let n = i.element(t.add(N(2))), a = N(n.x), s = N(n.y), c = a.mul(N(Ml)), l = i.element(c), m = i.element(c.add(N(1))), h = i.element(c.add(N(3))), _ = s.mul(N(Ml)), v = i.element(_), y = i.element(_.add(N(1))), b = i.element(_.add(N(3))), x = Ll(l.xyz, l.w, m.xyz, h.xyz, h.w, r), S = Ll(v.xyz, v.w, y.xyz, b.xyz, b.w, r), C = x.add(S), w = e.shiftRight(f).bitAnd(N(1)).equal(N(1));
|
|
8421
|
+
p(C.lessThanEqual(M(0)), () => {
|
|
8422
|
+
p(w, () => {
|
|
8423
|
+
o.assign(M(0)), u.assign(s);
|
|
8424
|
+
}).Else(() => {
|
|
8425
|
+
u.assign(a);
|
|
8426
|
+
});
|
|
8427
|
+
}).Else(() => {
|
|
8428
|
+
let e = x.div(C);
|
|
8429
|
+
p(w, () => {
|
|
8430
|
+
o.mulAssign(M(1).sub(e)), u.assign(s);
|
|
8431
|
+
}).Else(() => {
|
|
8432
|
+
o.mulAssign(e), u.assign(a);
|
|
8433
|
+
});
|
|
8434
|
+
}), f.addAssign(N(1));
|
|
8435
|
+
}), p(g.and(o.greaterThan(M(0))), () => {
|
|
8436
|
+
let e = u.mul(N(Ml)), f = i.element(e), h = i.element(e.add(N(2))), g = N(h.x), _ = N(h.y), v = F(f.w, M(1e-10)), y = M(0).toVar();
|
|
8437
|
+
m({
|
|
8438
|
+
start: N(0),
|
|
8439
|
+
end: _
|
|
8440
|
+
}, ({ i: e }) => {
|
|
8441
|
+
let t = g.add(e), n = i.element(a.add(t.mul(N(Nl))));
|
|
8442
|
+
p(N(n.r).equal(l), () => {
|
|
8443
|
+
y.assign(F(n.g, M(0))), d();
|
|
8444
|
+
});
|
|
8445
|
+
}), o.mulAssign(y.div(v));
|
|
8446
|
+
let b = Tl.wrap(El(l, s));
|
|
8447
|
+
p(_l(b.v0, b.v1, b.v2, r), () => {
|
|
8448
|
+
let e = gl(b.v0, b.v1, b.v2, r);
|
|
8449
|
+
c.assign(o.div(F(e, M(1e-10))));
|
|
8450
|
+
}).Else(() => {
|
|
8451
|
+
let e = L(O(b.v1.sub(b.v0), b.v2.sub(b.v0))), r = F(A(n.negate(), e), M(.001)), i = hl(b.v0, b.v1, b.v2), a = t.mul(t), s = o.div(F(i, M(1e-10)));
|
|
8452
|
+
c.assign(s.mul(a).div(r));
|
|
8453
|
+
});
|
|
8454
|
+
});
|
|
8455
|
+
}), F(c, ji);
|
|
8456
|
+
}), Bl = 0x8ac7230489e80000;
|
|
8457
|
+
function Vl(e) {
|
|
8458
|
+
let { bvhBuffer: t, triangleBuffer: n, materialBuffer: r, envCDFTexture: i, lightBuffer: a, rayBufferRW: o, rngBufferRW: s, hitBufferRO: c, gBufferRW: l, counters: u, activeIndicesRO: d, albedoMaps: m, normalMaps: g, bumpMaps: _, metalnessMaps: v, roughnessMaps: y, emissiveMaps: b, displacementMaps: x, envTexture: C, environmentIntensity: w, envMatrix: T, enableEnvironmentLight: D, useEnvMapIS: O, groundProjectionEnabled: k, groundProjectionRadius: ee, groundProjectionHeight: te, envTotalSum: ne, envCompensationDelta: P, envResolution: ae, directionalLightsBuffer: oe, numDirectionalLights: ce, areaLightsBuffer: le, numAreaLights: I, pointLightsBuffer: ue, numPointLights: de, spotLightsBuffer: fe, numSpotLights: pe, maxBounceCount: me, maxSubsurfaceSteps: he, currentBounce: ge, transparentBackground: ve, backgroundIntensity: ye, showBackground: be, globalIlluminationIntensity: xe, cameraProjectionMatrix: Se, cameraViewMatrix: Ce, fireflyThreshold: we, frame: Te, resolution: Ee, emissiveTriangleCount: De, emissiveVec4Offset: Oe, emissiveTotalPower: ke, emissiveBoost: z, totalTriangleCount: Ae, enableEmissiveTriangleSampling: je, lightBVHNodeCount: V, reverseMapVec4Offset: Me, maxRayCount: Ne } = e, Pe = a !== void 0;
|
|
8335
8459
|
return f(() => {
|
|
8336
|
-
let e = re, Ae = u ? S(u.element(B(
|
|
8460
|
+
let e = re, Ae = u ? S(u.element(B(ac.ENTERING_COUNT))) : Ne;
|
|
8337
8461
|
p(e.greaterThanEqual(Ae), () => {
|
|
8338
8462
|
h();
|
|
8339
8463
|
});
|
|
8340
|
-
let H = d.element(e),
|
|
8341
|
-
p(
|
|
8464
|
+
let H = d.element(e), Fe = As(o, H).toVar();
|
|
8465
|
+
p(Fe.bitAnd(B(oc.ACTIVE)).equal(B(0)), () => {
|
|
8342
8466
|
h();
|
|
8343
8467
|
});
|
|
8344
|
-
let
|
|
8345
|
-
p(
|
|
8468
|
+
let Ie = Os(o, H).toVar(), K = ks(o, H).toVar(), Le = js(o, H).toVar(), Re = Ns(o, H).toVar(), ze = B(Ee.x).mul(B(Ee.y)).toVar(), Be = H.mod(ze), Ve = s.element(H).toVar(), He = Ws(c, H).toVar(), Ue = qs(c, H).toVar(), We = Ks(c, H).toVar(), Ge = Js(c, H).toVar(), Ke = Gs(c, H).toVar(), qe = tc(o, H).toVar(), Je = N(ge).toVar(), Ye = nc(o, H).toVar(), Xe = N(H.div(ze)).toVar();
|
|
8469
|
+
p(He.greaterThan(Bl), () => {
|
|
8346
8470
|
p(D, () => {
|
|
8347
|
-
let e =
|
|
8348
|
-
p(
|
|
8349
|
-
e.assign(
|
|
8471
|
+
let e = K.toVar();
|
|
8472
|
+
p(Je.equal(0).and(k), () => {
|
|
8473
|
+
e.assign(Fc(Ie, K, ee, te));
|
|
8350
8474
|
});
|
|
8351
|
-
let t =
|
|
8475
|
+
let t = Pc({
|
|
8352
8476
|
tex: C,
|
|
8353
8477
|
samp: _e(C),
|
|
8354
8478
|
direction: e,
|
|
@@ -8356,14 +8480,14 @@ function Fl(e) {
|
|
|
8356
8480
|
environmentIntensity: w,
|
|
8357
8481
|
enableEnvironmentLight: D
|
|
8358
8482
|
}).toVar();
|
|
8359
|
-
p(
|
|
8483
|
+
p(Je.equal(0).and(be.not()), () => {
|
|
8360
8484
|
t.assign(G(0));
|
|
8361
8485
|
});
|
|
8362
8486
|
let n = M(1).toVar();
|
|
8363
|
-
p(
|
|
8364
|
-
let e =
|
|
8487
|
+
p(Je.greaterThan(0).and(O), () => {
|
|
8488
|
+
let e = Ms(o, H);
|
|
8365
8489
|
p(e.greaterThan(0), () => {
|
|
8366
|
-
let t =
|
|
8490
|
+
let t = Mc(C, K, T, ne, P, ae).w;
|
|
8367
8491
|
p(t.greaterThan(0), () => {
|
|
8368
8492
|
n.assign(Vi({
|
|
8369
8493
|
pdf1: e,
|
|
@@ -8372,151 +8496,155 @@ function Fl(e) {
|
|
|
8372
8496
|
});
|
|
8373
8497
|
});
|
|
8374
8498
|
});
|
|
8375
|
-
let r = R(
|
|
8376
|
-
|
|
8377
|
-
}), p(ve.and(
|
|
8378
|
-
|
|
8379
|
-
}),
|
|
8380
|
-
});
|
|
8381
|
-
let
|
|
8382
|
-
p(
|
|
8383
|
-
let e =
|
|
8499
|
+
let r = R(Je.greaterThan(0), xe, M(1)), i = R(Je.equal(0), ye, n.mul(r));
|
|
8500
|
+
Re.assign(G(Re.xyz.add(el(Le.mul(t.xyz).mul(i), M(Je), we, N(Te))), Re.w));
|
|
8501
|
+
}), p(ve.and(Fe.bitAnd(B(oc.HAS_HIT_OPAQUE)).equal(B(0))), () => {
|
|
8502
|
+
Re.w.assign(0);
|
|
8503
|
+
}), Us(o, H, Re), Vs(o, H, K, Fe.bitAnd(B(~oc.ACTIVE))), h();
|
|
8504
|
+
});
|
|
8505
|
+
let Ze = Ie.add(K.mul(He)).toVar(), Qe = L(Ue).toVar(), $e = Zs(o, H), et = N($e.stackDepth).toVar(), tt = $e.ior1.toVar(), nt = $e.ior2.toVar(), rt = $e.ior3.toVar(), it = N($e.transTraversals).toVar(), at = M($e.wavelength).toVar();
|
|
8506
|
+
p(et.greaterThan(0), () => {
|
|
8507
|
+
let e = $s(o, H).toVar(), t = rc(o, H), n = t.sigmaS.toVar(), r = t.g.toVar();
|
|
8384
8508
|
p(F(F(n.x, n.y), n.z).lessThanEqual(0), () => {
|
|
8385
|
-
|
|
8509
|
+
Le.mulAssign(j(e.mul(He).negate()));
|
|
8386
8510
|
}).Else(() => {
|
|
8387
|
-
let t = e.add(n), i = xa.wrap(Ta(t, n,
|
|
8388
|
-
|
|
8389
|
-
let e = U(Y(
|
|
8390
|
-
|
|
8391
|
-
let a = E(F(F(
|
|
8392
|
-
p(
|
|
8393
|
-
|
|
8394
|
-
}),
|
|
8511
|
+
let t = e.add(n), i = xa.wrap(Ta(t, n, Le, He, Ve)).toVar();
|
|
8512
|
+
Le.mulAssign(i.weight), p(i.didScatter, () => {
|
|
8513
|
+
let e = U(Y(Ve), Y(Ve)), t = Ie.add(K.mul(i.t)), n = wa(K, r, e).toVar();
|
|
8514
|
+
Ye.addAssign(1);
|
|
8515
|
+
let a = E(F(F(Le.x, Le.y), Le.z), .02, 1).toVar();
|
|
8516
|
+
p(Ye.greaterThanEqual(he).or(Y(Ve).greaterThan(a)).toVar(), () => {
|
|
8517
|
+
Us(o, H, Re), Vs(o, H, K, Fe.bitAnd(B(~oc.ACTIVE))), s.element(H).assign(Ve), h();
|
|
8518
|
+
}), Le.divAssign(a), Bs(o, H, t, qe, Ye), Vs(o, H, n, Fe), Hs(o, H, Le, Ms(o, H)), Us(o, H, Re), s.element(H).assign(Ve), h();
|
|
8395
8519
|
});
|
|
8396
8520
|
});
|
|
8397
8521
|
});
|
|
8398
|
-
let q = di.wrap(Xi(N(
|
|
8522
|
+
let q = di.wrap(Xi(N(Ge), r)).toVar(), ot = We.toVar(), st = Qe.toVar();
|
|
8399
8523
|
p(q.displacementMapIndex.greaterThanEqual(N(0)).and(q.displacementScale.greaterThan(0)), () => {
|
|
8400
8524
|
let e = ui({
|
|
8401
|
-
origin:
|
|
8402
|
-
direction:
|
|
8525
|
+
origin: Ie,
|
|
8526
|
+
direction: K
|
|
8403
8527
|
}), t = pi({
|
|
8404
8528
|
didHit: !0,
|
|
8405
|
-
dst:
|
|
8406
|
-
hitPoint:
|
|
8407
|
-
normal:
|
|
8408
|
-
uv:
|
|
8409
|
-
materialIndex: N(
|
|
8529
|
+
dst: He,
|
|
8530
|
+
hitPoint: Ze,
|
|
8531
|
+
normal: Qe,
|
|
8532
|
+
uv: We,
|
|
8533
|
+
materialIndex: N(Ge),
|
|
8410
8534
|
meshIndex: N(0),
|
|
8411
|
-
triangleIndex: N(
|
|
8535
|
+
triangleIndex: N(Ke),
|
|
8412
8536
|
boxTests: N(0),
|
|
8413
8537
|
triTests: N(0)
|
|
8414
|
-
}), r =
|
|
8415
|
-
|
|
8538
|
+
}), r = ul.wrap(dl(e, t, n, x, q, Je)).toVar();
|
|
8539
|
+
ot.assign(r.uv), st.assign(r.normal), Ze.assign(r.hitPoint);
|
|
8416
8540
|
});
|
|
8417
|
-
let
|
|
8418
|
-
q.color.assign(
|
|
8419
|
-
let
|
|
8541
|
+
let ct = yi.wrap(Ya(m, g, _, v, y, b, q, ot, Qe)).toVar();
|
|
8542
|
+
q.color.assign(ct.albedo), q.metalness.assign(ct.metalness.clamp(0, 1)), q.roughness.assign(ct.roughness.clamp(.05, 1)), q.sheenRoughness.assign(q.sheenRoughness.clamp(.05, 1));
|
|
8543
|
+
let lt = ct.albedo.toVar();
|
|
8420
8544
|
p(q.displacementMapIndex.greaterThanEqual(N(0)).and(q.displacementScale.greaterThan(0)), () => {
|
|
8421
|
-
|
|
8545
|
+
Qe.assign(L(st.add(ct.normal.sub(L(Ue)))));
|
|
8422
8546
|
}).Else(() => {
|
|
8423
|
-
|
|
8424
|
-
}), p(
|
|
8425
|
-
let e =
|
|
8426
|
-
worldPos:
|
|
8547
|
+
Qe.assign(ct.normal);
|
|
8548
|
+
}), p(Je.equal(0), () => {
|
|
8549
|
+
let e = tl({
|
|
8550
|
+
worldPos: Ze,
|
|
8427
8551
|
cameraProjectionMatrix: Se,
|
|
8428
8552
|
cameraViewMatrix: Ce
|
|
8429
8553
|
});
|
|
8430
|
-
p(
|
|
8431
|
-
|
|
8554
|
+
p(Xe.equal(N(0)), () => {
|
|
8555
|
+
Fs(l, Be, W(0, 0, 1), e, W(0)), Ls(l, Be, Ke, Ys(c, H), We.x, We.y, B(1));
|
|
8432
8556
|
});
|
|
8433
8557
|
});
|
|
8434
|
-
let
|
|
8435
|
-
p(
|
|
8436
|
-
|
|
8437
|
-
}).ElseIf(
|
|
8438
|
-
|
|
8439
|
-
}).ElseIf(
|
|
8440
|
-
|
|
8441
|
-
});
|
|
8442
|
-
let
|
|
8443
|
-
origin:
|
|
8444
|
-
direction:
|
|
8445
|
-
}),
|
|
8446
|
-
|
|
8447
|
-
p(
|
|
8448
|
-
p(
|
|
8449
|
-
p(
|
|
8450
|
-
|
|
8451
|
-
et.assign(q.ior);
|
|
8452
|
-
}), p($e.equal(2), () => {
|
|
8558
|
+
let ut = M(1).toVar(), dt = M(1).toVar();
|
|
8559
|
+
p(et.equal(1), () => {
|
|
8560
|
+
ut.assign(tt);
|
|
8561
|
+
}).ElseIf(et.equal(2), () => {
|
|
8562
|
+
ut.assign(nt), dt.assign(tt);
|
|
8563
|
+
}).ElseIf(et.equal(3), () => {
|
|
8564
|
+
ut.assign(rt), dt.assign(nt);
|
|
8565
|
+
});
|
|
8566
|
+
let J = ui({
|
|
8567
|
+
origin: Ie,
|
|
8568
|
+
direction: K
|
|
8569
|
+
}), ft = ka.wrap(za(J, Qe, q, Ve, N(it), ut, dt, at)).toVar();
|
|
8570
|
+
at.assign(ft.pathWavelength), p(ft.continueRay, () => {
|
|
8571
|
+
p(ft.isTransmissive.and(ft.didReflect.not()), () => {
|
|
8572
|
+
p(ft.entering, () => {
|
|
8573
|
+
p(et.lessThan(3), () => {
|
|
8574
|
+
et.addAssign(1), p(et.equal(1), () => {
|
|
8453
8575
|
tt.assign(q.ior);
|
|
8454
|
-
}), p(
|
|
8576
|
+
}), p(et.equal(2), () => {
|
|
8455
8577
|
nt.assign(q.ior);
|
|
8456
|
-
}),
|
|
8578
|
+
}), p(et.equal(3), () => {
|
|
8579
|
+
rt.assign(q.ior);
|
|
8580
|
+
}), ec(o, H, R(q.attenuationDistance.greaterThan(0), se(F(q.attenuationColor, W(.001))).negate().div(q.attenuationDistance), W(0))), ic(o, H, W(0), M(0));
|
|
8457
8581
|
});
|
|
8458
8582
|
}).Else(() => {
|
|
8459
|
-
p(
|
|
8460
|
-
|
|
8583
|
+
p(et.greaterThan(0), () => {
|
|
8584
|
+
et.subAssign(1);
|
|
8461
8585
|
});
|
|
8462
8586
|
});
|
|
8463
|
-
}), p(
|
|
8464
|
-
p(
|
|
8465
|
-
p(
|
|
8466
|
-
|
|
8467
|
-
et.assign(q.ior);
|
|
8468
|
-
}), p($e.equal(2), () => {
|
|
8587
|
+
}), p(ft.isSubsurface.and(ft.didReflect.not()), () => {
|
|
8588
|
+
p(ft.entering, () => {
|
|
8589
|
+
p(et.lessThan(3), () => {
|
|
8590
|
+
et.addAssign(1), p(et.equal(1), () => {
|
|
8469
8591
|
tt.assign(q.ior);
|
|
8470
|
-
}), p(
|
|
8592
|
+
}), p(et.equal(2), () => {
|
|
8471
8593
|
nt.assign(q.ior);
|
|
8594
|
+
}), p(et.equal(3), () => {
|
|
8595
|
+
rt.assign(q.ior);
|
|
8472
8596
|
});
|
|
8473
8597
|
let e = Sa.wrap(Ea(q.subsurfaceColor, q.subsurfaceRadius, q.subsurfaceRadiusScale)).toVar();
|
|
8474
|
-
|
|
8598
|
+
ec(o, H, e.sigmaT.sub(e.sigmaS)), ic(o, H, e.sigmaS, E(q.subsurfaceAnisotropy, -.99, .99));
|
|
8475
8599
|
});
|
|
8476
8600
|
}).Else(() => {
|
|
8477
|
-
p(
|
|
8478
|
-
|
|
8601
|
+
p(et.greaterThan(0), () => {
|
|
8602
|
+
et.subAssign(1);
|
|
8479
8603
|
});
|
|
8480
8604
|
});
|
|
8481
|
-
}), p(
|
|
8482
|
-
|
|
8483
|
-
}),
|
|
8484
|
-
let e = R(
|
|
8485
|
-
|
|
8486
|
-
}),
|
|
8487
|
-
let
|
|
8488
|
-
p(ie(
|
|
8489
|
-
let e = R(
|
|
8490
|
-
|
|
8491
|
-
let e =
|
|
8605
|
+
}), p(ft.isTransmissive.and(it.greaterThan(0)), () => {
|
|
8606
|
+
it.subAssign(1);
|
|
8607
|
+
}), Le.mulAssign(ft.throughput);
|
|
8608
|
+
let e = R(ft.entering, Qe, Qe.negate()), t = R(ft.didReflect, e, K);
|
|
8609
|
+
Bs(o, H, Ze.add(t.mul(.001)), qe, Ye), Vs(o, H, ft.direction, Fe), Hs(o, H, Le, Ms(o, H)), Us(o, H, Re), Qs(o, H, B(et), B(it), tt, nt, rt, B(at.add(.5))), s.element(H).assign(Ve), h();
|
|
8610
|
+
}), Fe.assign(Fe.bitOr(B(oc.HAS_HIT_OPAQUE)));
|
|
8611
|
+
let pt = ct.emissive.toVar();
|
|
8612
|
+
p(ie(pt).greaterThan(0), () => {
|
|
8613
|
+
let e = R(Je.greaterThan(0), xe, M(1)), t = M(1).toVar();
|
|
8614
|
+
Pe && p(je.equal(N(1)).and(De.greaterThan(N(0))).and(Je.greaterThan(0)), () => {
|
|
8615
|
+
let e = Ms(o, H);
|
|
8492
8616
|
p(e.greaterThan(0), () => {
|
|
8493
|
-
let i =
|
|
8494
|
-
|
|
8617
|
+
let i = M(0).toVar();
|
|
8618
|
+
p(V.greaterThan(N(0)), () => {
|
|
8619
|
+
i.assign(zl(N(Ke), He, K, Ie, a, Oe, Me, n));
|
|
8620
|
+
}).Else(() => {
|
|
8621
|
+
i.assign(Dl(N(Ke), He, K, Ie, n, r, ke));
|
|
8622
|
+
}), t.assign(Bi({
|
|
8495
8623
|
pdf1: e,
|
|
8496
8624
|
pdf2: i
|
|
8497
8625
|
}));
|
|
8498
8626
|
});
|
|
8499
|
-
}),
|
|
8500
|
-
});
|
|
8501
|
-
let
|
|
8502
|
-
p(A(
|
|
8503
|
-
|
|
8504
|
-
}), p(
|
|
8505
|
-
let e = Is(
|
|
8506
|
-
|
|
8627
|
+
}), Re.assign(G(Re.xyz.add(el(pt.mul(Le).mul(e).mul(t), M(Je), we, N(Te))), Re.w));
|
|
8628
|
+
});
|
|
8629
|
+
let mt = K.negate().toVar();
|
|
8630
|
+
p(A(Qe, mt).lessThan(0), () => {
|
|
8631
|
+
Qe.assign(Qe.negate());
|
|
8632
|
+
}), p(Xe.equal(N(0)).and(Fe.bitAnd(B(oc.AUX_LOCKED)).equal(B(0))), () => {
|
|
8633
|
+
let e = Rs(Is(l, Be)).w;
|
|
8634
|
+
Fs(l, Be, Qe, e, lt.xyz);
|
|
8507
8635
|
let t = q.metalness.greaterThan(.7).and(q.roughness.lessThan(.3)), n = q.transmission.greaterThan(.5);
|
|
8508
8636
|
p(t.or(n).not(), () => {
|
|
8509
|
-
|
|
8637
|
+
Fe.assign(Fe.bitOr(B(oc.AUX_LOCKED)));
|
|
8510
8638
|
});
|
|
8511
8639
|
});
|
|
8512
|
-
let
|
|
8640
|
+
let ht = bi.wrap(qi(q.metalness, q.roughness, q.transmission, q.clearcoat, q.emissive, q.subsurface)).toVar(), gt = N(Ee.x).toVar(), _t = Un(U(M(N(Be).mod(gt)).add(.5), M(N(Be).div(gt)).add(.5)), Xe, Je, Ve, N(-1), Ee, Te).toVar(), vt = hi({
|
|
8513
8641
|
specular: M(0),
|
|
8514
8642
|
diffuse: M(0),
|
|
8515
8643
|
sheen: M(0),
|
|
8516
8644
|
clearcoat: M(0),
|
|
8517
8645
|
transmission: M(0),
|
|
8518
8646
|
iridescence: M(0)
|
|
8519
|
-
}),
|
|
8647
|
+
}), yt = Si({
|
|
8520
8648
|
F0: W(.04),
|
|
8521
8649
|
NoV: M(1),
|
|
8522
8650
|
diffuseColor: W(0),
|
|
@@ -8528,83 +8656,83 @@ function Fl(e) {
|
|
|
8528
8656
|
metalFactor: M(.5),
|
|
8529
8657
|
iorFactor: M(.67),
|
|
8530
8658
|
maxSheenColor: M(0)
|
|
8531
|
-
}),
|
|
8659
|
+
}), bt = W(0).toVar(), xt = W(0).toVar(), St = M(0).toVar();
|
|
8532
8660
|
p(q.clearcoat.greaterThan(0), () => {
|
|
8533
8661
|
let e = ui({
|
|
8534
|
-
origin:
|
|
8535
|
-
direction:
|
|
8662
|
+
origin: Ie,
|
|
8663
|
+
direction: K
|
|
8536
8664
|
}), t = pi({
|
|
8537
8665
|
didHit: !0,
|
|
8538
|
-
dst:
|
|
8539
|
-
hitPoint:
|
|
8540
|
-
normal:
|
|
8541
|
-
uv:
|
|
8542
|
-
materialIndex: N(
|
|
8666
|
+
dst: He,
|
|
8667
|
+
hitPoint: Ze,
|
|
8668
|
+
normal: Qe,
|
|
8669
|
+
uv: We,
|
|
8670
|
+
materialIndex: N(Ge),
|
|
8543
8671
|
meshIndex: N(0),
|
|
8544
8672
|
triangleIndex: N(0),
|
|
8545
8673
|
boxTests: N(0),
|
|
8546
8674
|
triTests: N(0)
|
|
8547
|
-
}), n =
|
|
8548
|
-
|
|
8675
|
+
}), n = rl.wrap(il(e, t, q, _t, Ve));
|
|
8676
|
+
bt.assign(n.L), xt.assign(n.brdf), St.assign(n.pdf);
|
|
8549
8677
|
}).Else(() => {
|
|
8550
|
-
let e = mi.wrap(
|
|
8551
|
-
|
|
8678
|
+
let e = mi.wrap($c(mt, Qe, q, _t, Ve, ht, !1, vt, !1, yt));
|
|
8679
|
+
bt.assign(e.direction), xt.assign(e.value), St.assign(e.pdf);
|
|
8552
8680
|
});
|
|
8553
|
-
let
|
|
8554
|
-
|
|
8555
|
-
let e = f(([e, i, a]) => to(e, i, a,
|
|
8681
|
+
let Ct = Kc(Ze, Qe, q, mt, bt, St, xt, Je, Ve, oe, ce, le, I, ue, de, fe, pe, t, n, r, C, w, T, i, ne, P, ae, D), wt = R(Je.greaterThan(0), xe, M(1));
|
|
8682
|
+
Re.assign(G(Re.xyz.add(el(Le.mul(Ct).mul(wt), M(Je), we, N(Te))), Re.w)), Pe && p(je.equal(N(1)).and(De.greaterThan(N(0))), () => {
|
|
8683
|
+
let e = f(([e, i, a]) => to(e, i, a, Ec, t, n, r));
|
|
8556
8684
|
p(V.greaterThan(N(0)), () => {
|
|
8557
|
-
let t =
|
|
8558
|
-
p(
|
|
8559
|
-
let n = F(M(0), A(
|
|
8685
|
+
let t = fl.wrap(Rl(Ze, Qe, Ve, a, a, Oe, n));
|
|
8686
|
+
p(Je.greaterThan(N(1)).and(q.roughness.greaterThan(.9)).and(q.metalness.lessThan(.1)).not().and(t.valid).and(t.pdf.greaterThan(0)), () => {
|
|
8687
|
+
let n = F(M(0), A(Qe, t.direction));
|
|
8560
8688
|
p(n.greaterThan(0), () => {
|
|
8561
|
-
let r = no(
|
|
8689
|
+
let r = no(Ze, Qe, q), i = Ze.add(r), a = t.distance.sub(.001), o = e(i, t.direction, a);
|
|
8562
8690
|
p(o.greaterThan(0), () => {
|
|
8563
|
-
let e =
|
|
8691
|
+
let e = Lc(mt, t.direction, Qe, q), r = Gc(mt, t.direction, Qe, q), i = R(r.greaterThan(0), Bi({
|
|
8564
8692
|
pdf1: t.pdf,
|
|
8565
8693
|
pdf2: r
|
|
8566
8694
|
}), M(1)), a = t.emission.mul(e).mul(n).div(t.pdf).mul(o).mul(z).mul(i);
|
|
8567
|
-
|
|
8695
|
+
Re.assign(G(Re.xyz.add(el(a.mul(Le).mul(wt), M(Je), we, N(Te))), Re.w));
|
|
8568
8696
|
});
|
|
8569
8697
|
});
|
|
8570
8698
|
});
|
|
8571
8699
|
}).Else(() => {
|
|
8572
|
-
let t =
|
|
8573
|
-
|
|
8700
|
+
let t = jl(Ze, Qe, mt, q, Je, Ve, z, a, Oe, De, ke, n, e, no);
|
|
8701
|
+
Re.assign(G(Re.xyz.add(el(t.mul(Le).mul(wt), M(Je), we, N(Te))), Re.w));
|
|
8574
8702
|
});
|
|
8575
8703
|
});
|
|
8576
|
-
let
|
|
8577
|
-
|
|
8578
|
-
let
|
|
8579
|
-
p(
|
|
8580
|
-
|
|
8581
|
-
}),
|
|
8582
|
-
|
|
8583
|
-
}),
|
|
8704
|
+
let Tt = gi.wrap(ga(q, Je, ht)).toVar(), Et = po.wrap(Qc(mt, Qe, q, bt, St, xt, Ve, Tt)).toVar(), Dt = Et.direction.toVar(), Ot = F(Et.combinedPdf, .001).toVar();
|
|
8705
|
+
Le.mulAssign(Et.throughput);
|
|
8706
|
+
let kt = nl(Je, Le, ht, Dt, Ve, D, O).toVar();
|
|
8707
|
+
p(kt.lessThanEqual(0), () => {
|
|
8708
|
+
Us(o, H, Re), Vs(o, H, K, Fe.bitAnd(B(~oc.ACTIVE))), s.element(H).assign(Ve), h();
|
|
8709
|
+
}), Le.divAssign(kt), p(qe.greaterThanEqual(me), () => {
|
|
8710
|
+
Us(o, H, Re), Vs(o, H, K, Fe.bitAnd(B(~oc.ACTIVE))), s.element(H).assign(Ve), h();
|
|
8711
|
+
}), Bs(o, H, Ze.add(Qe.mul(.001)), qe.add(1), Ye), Vs(o, H, Dt, Fe), Hs(o, H, Le, Ot), Us(o, H, Re), Qs(o, H, B(et), B(it), tt, nt, rt, B(at.add(.5))), s.element(H).assign(Ve);
|
|
8584
8712
|
});
|
|
8585
8713
|
}
|
|
8586
8714
|
//#endregion
|
|
8587
8715
|
//#region src/TSL/CompactKernel.js
|
|
8588
|
-
function
|
|
8716
|
+
function Hl(e) {
|
|
8589
8717
|
let { rayBufferRO: t, activeIndicesReadRO: n, activeIndicesWriteRW: r, counters: i, currentActiveCount: a } = e;
|
|
8590
8718
|
return f(() => {
|
|
8591
|
-
let e = re, o = i ? S(i.element(B(
|
|
8719
|
+
let e = re, o = i ? S(i.element(B(ac.ENTERING_COUNT))) : a;
|
|
8592
8720
|
p(e.greaterThanEqual(o), () => {
|
|
8593
8721
|
h();
|
|
8594
8722
|
});
|
|
8595
8723
|
let s = n.element(e);
|
|
8596
|
-
p(
|
|
8597
|
-
let e = x(i.element(B(
|
|
8724
|
+
p(As(t, s).bitAnd(B(oc.ACTIVE)).notEqual(B(0)), () => {
|
|
8725
|
+
let e = x(i.element(B(ac.ACTIVE_RAY_COUNT)), B(1));
|
|
8598
8726
|
r.element(e).assign(s);
|
|
8599
8727
|
});
|
|
8600
8728
|
});
|
|
8601
8729
|
}
|
|
8602
|
-
function
|
|
8730
|
+
function Ul(e) {
|
|
8603
8731
|
let { rayBufferRO: t, activeIndicesReadRO: n, activeIndicesWriteRW: r, counters: i, currentActiveCount: a } = e;
|
|
8604
8732
|
return f(() => {
|
|
8605
|
-
let e = re, o = i ? S(i.element(B(
|
|
8733
|
+
let e = re, o = i ? S(i.element(B(ac.ENTERING_COUNT))) : a, s = e.lessThan(o), c = n.element(e), l = As(t, c), u = s.and(l.bitAnd(B(oc.ACTIVE)).notEqual(B(0))), d = R(u, B(1), B(0)), f = De(d).toVar(), m = Te(d).toVar(), h = De(B(1)).toVar(), g = B(0).toVar();
|
|
8606
8734
|
p(h.equal(B(0)), () => {
|
|
8607
|
-
g.assign(x(i.element(B(
|
|
8735
|
+
g.assign(x(i.element(B(ac.ACTIVE_RAY_COUNT)), m));
|
|
8608
8736
|
});
|
|
8609
8737
|
let _ = Ee(g, B(0)).toVar();
|
|
8610
8738
|
p(u, () => {
|
|
@@ -8612,25 +8740,25 @@ function Ll(e) {
|
|
|
8612
8740
|
});
|
|
8613
8741
|
});
|
|
8614
8742
|
}
|
|
8615
|
-
var
|
|
8616
|
-
function
|
|
8743
|
+
var Wl = /* @__PURE__ */ K("\n fn nanInfToRed( c: vec3f ) -> vec3f {\n let isNan = c.x != c.x || c.y != c.y || c.z != c.z;\n let isInf = abs( c.x ) > 1e30f || abs( c.y ) > 1e30f || abs( c.z ) > 1e30f;\n if ( isNan || isInf ) { return vec3f( 1.0f, 0.0f, 0.0f ); }\n return vec3f( 0.0f );\n }\n");
|
|
8744
|
+
function Gl(e) {
|
|
8617
8745
|
let { rayBufferRO: t, gBufferRO: n, writeColorTex: r, writeNDTex: i, writeAlbedoTex: a, resolution: o, frame: s, enableAccumulation: c, hasPreviousAccumulated: l, accumulationAlpha: u, cameraIsMoving: d, transparentBackground: m, prevAccumTexture: h, prevNormalDepthTexture: g, prevAlbedoTexture: _, renderWidth: v, renderHeight: y, samplesPerPass: b = 1, visMode: x } = e, S = b | 0;
|
|
8618
8746
|
return f(() => {
|
|
8619
8747
|
let e = N(ze.x).mul(16).add(N(oe.x)), f = N(ze.y).mul(16).add(N(oe.y));
|
|
8620
8748
|
p(e.lessThan(v).and(f.lessThan(y)), () => {
|
|
8621
8749
|
let v = B(f.mul(N(o.x)).add(e)), y = (() => {
|
|
8622
|
-
if (S <= 1) return
|
|
8623
|
-
let e =
|
|
8624
|
-
for (let r = 1; r < S; r++) e.addAssign(
|
|
8750
|
+
if (S <= 1) return Ns(t, v);
|
|
8751
|
+
let e = Ns(t, v).toVar(), n = B(o.x).mul(B(o.y)).toVar();
|
|
8752
|
+
for (let r = 1; r < S; r++) e.addAssign(Ns(t, v.add(B(r).mul(n))));
|
|
8625
8753
|
return e.assign(e.div(M(S))), e;
|
|
8626
|
-
})(), b =
|
|
8754
|
+
})(), b = Is(n, v), C = Rs(b), w = G(zs(b), 0), T = y.xyz.toVar(), E = C.toVar(), D = w.xyz.toVar(), O = R(m, y.w, M(1)).toVar(), k = U(M(e).add(.5), M(f).add(.5)).div(o);
|
|
8627
8755
|
p(c.and(d.not()).and(s.greaterThan(B(0))).and(l).and(x.notEqual(N(11))), () => {
|
|
8628
8756
|
let e = ke(h, k, 0).toVar();
|
|
8629
8757
|
T.assign(I(e.xyz, y.xyz, u)), E.assign(I(ke(g, k, 0), E, u)), D.assign(I(ke(_, k, 0).xyz, D, u)), p(m, () => {
|
|
8630
8758
|
O.assign(I(e.w, y.w, u));
|
|
8631
8759
|
});
|
|
8632
8760
|
}), p(x.equal(N(11)), () => {
|
|
8633
|
-
T.assign(
|
|
8761
|
+
T.assign(Wl(T));
|
|
8634
8762
|
});
|
|
8635
8763
|
let A = Fe(B(e), B(f));
|
|
8636
8764
|
Ae(r, A, G(T, O)).toWriteOnly(), Ae(i, A, E).toWriteOnly(), Ae(a, A, G(D, 1)).toWriteOnly();
|
|
@@ -8639,11 +8767,11 @@ function zl(e) {
|
|
|
8639
8767
|
}
|
|
8640
8768
|
//#endregion
|
|
8641
8769
|
//#region src/TSL/Debugger.js
|
|
8642
|
-
var
|
|
8770
|
+
var Kl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n return vec3f( 1.0f - depth );\n }\n"), ql = /* @__PURE__ */ K("\n fn visualizeNormal( normal: vec3f ) -> vec3f {\n return normal * 0.5f + 0.5f;\n }\n"), Jl = /* @__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"), Yl = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m, h, g, _, v, y, b, x, S]) => {
|
|
8643
8771
|
let C = G(1, 0, 1, 1).toVar(), w = ui({
|
|
8644
8772
|
origin: e,
|
|
8645
8773
|
direction: t
|
|
8646
|
-
}), T = pi.wrap(
|
|
8774
|
+
}), T = pi.wrap(Tc(w, n, r).toVar());
|
|
8647
8775
|
return p(l.equal(N(7)), () => {
|
|
8648
8776
|
let e = M(T.triTests).div(u);
|
|
8649
8777
|
C.assign(R(e.lessThan(1), G(W(e), 1), G(1, 0, 0, 1)));
|
|
@@ -8652,7 +8780,7 @@ var Bl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
8652
8780
|
C.assign(R(e.lessThan(1), G(W(e), 1), G(1, 0, 0, 1)));
|
|
8653
8781
|
}), p(l.equal(N(10)), () => {
|
|
8654
8782
|
p(c, () => {
|
|
8655
|
-
let e =
|
|
8783
|
+
let e = Pc({
|
|
8656
8784
|
tex: a,
|
|
8657
8785
|
samp: _e(a),
|
|
8658
8786
|
direction: t,
|
|
@@ -8700,18 +8828,18 @@ var Bl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
8700
8828
|
C.assign(G(.5, .5, 1, 1));
|
|
8701
8829
|
}).Else(() => {
|
|
8702
8830
|
let e = di.wrap(Xi(T.materialIndex, i)).toVar(), t = L(yi.wrap(Ya(m, h, g, _, v, y, e, T.uv, T.normal)).toVar().normal);
|
|
8703
|
-
C.assign(G(
|
|
8831
|
+
C.assign(G(ql({ normal: t }), 1));
|
|
8704
8832
|
});
|
|
8705
8833
|
}), p(l.equal(N(2)), () => {
|
|
8706
8834
|
p(T.didHit.not(), () => {
|
|
8707
8835
|
C.assign(G(W(1), 1));
|
|
8708
8836
|
}).Else(() => {
|
|
8709
|
-
let e =
|
|
8837
|
+
let e = Jl({
|
|
8710
8838
|
worldPos: T.hitPoint,
|
|
8711
8839
|
cameraProjectionMatrix: b,
|
|
8712
8840
|
cameraViewMatrix: x
|
|
8713
8841
|
});
|
|
8714
|
-
C.assign(G(
|
|
8842
|
+
C.assign(G(Kl({ depth: e }), 1));
|
|
8715
8843
|
});
|
|
8716
8844
|
}), p(l.equal(N(3)), () => {
|
|
8717
8845
|
p(T.didHit.not(), () => {
|
|
@@ -8730,10 +8858,10 @@ var Bl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
8730
8858
|
}).toVar(), x = ui({
|
|
8731
8859
|
origin: T.hitPoint.add(u.mul(.001)),
|
|
8732
8860
|
direction: b
|
|
8733
|
-
}), w = pi.wrap(
|
|
8861
|
+
}), w = pi.wrap(Tc(x, n, r).toVar()), E = W(0).toVar();
|
|
8734
8862
|
p(w.didHit.not(), () => {
|
|
8735
8863
|
p(c, () => {
|
|
8736
|
-
E.assign(
|
|
8864
|
+
E.assign(Pc({
|
|
8737
8865
|
tex: a,
|
|
8738
8866
|
samp: _e(a),
|
|
8739
8867
|
direction: b,
|
|
@@ -8745,7 +8873,7 @@ var Bl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
8745
8873
|
}).Else(() => {
|
|
8746
8874
|
let e = di.wrap(Xi(w.materialIndex, i)).toVar(), t = yi.wrap(Ya(m, h, g, _, v, y, e, w.uv, w.normal)).toVar();
|
|
8747
8875
|
E.assign(t.emissive), p(c, () => {
|
|
8748
|
-
let e = L(t.normal).toVar(), n =
|
|
8876
|
+
let e = L(t.normal).toVar(), n = Pc({
|
|
8749
8877
|
tex: a,
|
|
8750
8878
|
samp: _e(a),
|
|
8751
8879
|
direction: e,
|
|
@@ -8761,7 +8889,7 @@ var Bl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
8761
8889
|
});
|
|
8762
8890
|
}), p(l.equal(N(6)), () => {
|
|
8763
8891
|
p(T.didHit, () => {
|
|
8764
|
-
let e = T.normal.toVar(), n = L(t.sub(e.mul(A(t, e).mul(2)))).toVar(), r =
|
|
8892
|
+
let e = T.normal.toVar(), n = L(t.sub(e.mul(A(t, e).mul(2)))).toVar(), r = Pc({
|
|
8765
8893
|
tex: a,
|
|
8766
8894
|
samp: _e(a),
|
|
8767
8895
|
direction: n,
|
|
@@ -8771,7 +8899,7 @@ var Bl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
8771
8899
|
}).xyz, i = r.div(r.add(1));
|
|
8772
8900
|
C.assign(G(i, 1));
|
|
8773
8901
|
}).Else(() => {
|
|
8774
|
-
let e =
|
|
8902
|
+
let e = Pc({
|
|
8775
8903
|
tex: a,
|
|
8776
8904
|
samp: _e(a),
|
|
8777
8905
|
direction: t,
|
|
@@ -8783,19 +8911,19 @@ var Bl = /* @__PURE__ */ K("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
|
|
|
8783
8911
|
});
|
|
8784
8912
|
}), C;
|
|
8785
8913
|
});
|
|
8786
|
-
function
|
|
8914
|
+
function Xl(e) {
|
|
8787
8915
|
let { writeColorTex: t, writeNDTex: n, writeAlbedoTex: r, resolution: i, renderWidth: a, renderHeight: o, cameraWorldMatrix: s, cameraProjectionMatrixInverse: c, cameraProjectionMatrix: l, cameraViewMatrix: u, enableDOF: d, focalLength: m, aperture: h, focusDistance: g, sceneScale: _, apertureScale: v, anamorphicRatio: y, bvhBuffer: b, triangleBuffer: x, materialBuffer: S, envTexture: C, environmentMatrix: w, environmentIntensity: T, enableEnvironmentLight: E, visMode: D, debugVisScale: O, albedoMaps: k, normalMaps: A, bumpMaps: j, metalnessMaps: ee, roughnessMaps: te, emissiveMaps: ne, frame: re, samplesPerPass: P = 1 } = e;
|
|
8788
8916
|
return f(() => {
|
|
8789
8917
|
let e = N(ze.x).mul(16).add(N(oe.x)), f = N(ze.y).mul(16).add(N(oe.y));
|
|
8790
8918
|
p(e.lessThan(a).and(f.lessThan(o)), () => {
|
|
8791
8919
|
let a = U(M(e).add(.5), M(f).add(.5)), o = Pn({ state: B(f.mul(N(i.x)).add(e)).add(B(1)) }).toVar(), ie = a.div(i).mul(2).sub(1).toVar();
|
|
8792
8920
|
ie.y.assign(ie.y.negate());
|
|
8793
|
-
let ae = ui.wrap(
|
|
8921
|
+
let ae = ui.wrap(Dc(ie, o, s, c, d, m, h, g, _, v, y)), oe = G(1, 0, 1, 1).toVar();
|
|
8794
8922
|
p(D.equal(N(9)), () => {
|
|
8795
8923
|
let e = Wn(a, N(0), N(P), o, i, re);
|
|
8796
8924
|
oe.assign(G(e, 1, 1));
|
|
8797
8925
|
}).Else(() => {
|
|
8798
|
-
oe.assign(
|
|
8926
|
+
oe.assign(Yl(ae.origin, ae.direction, b, x, S, C, w, T, E, D, O, a, i, k, A, j, ee, te, ne, l, u, re));
|
|
8799
8927
|
});
|
|
8800
8928
|
let se = Fe(B(e), B(f));
|
|
8801
8929
|
Ae(t, se, oe).toWriteOnly(), Ae(n, se, G(.5, .5, 1, 1)).toWriteOnly(), Ae(r, se, G(oe.xyz, 1)).toWriteOnly();
|
|
@@ -8804,9 +8932,9 @@ function Wl(e) {
|
|
|
8804
8932
|
}
|
|
8805
8933
|
//#endregion
|
|
8806
8934
|
//#region src/Stages/PathTracer.js
|
|
8807
|
-
var
|
|
8935
|
+
var Zl = class extends Ss {
|
|
8808
8936
|
constructor(e, t, n, r = {}) {
|
|
8809
|
-
super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1, this._useDynamicDispatch = !0, this._useSubgroupCompact = !1, this._multiSampleMaxPixels = X.wavefrontMultiSampleMaxPixels ?? 589824, this._samplesPerPass = 1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._bounceEarlyExitThreshold = 100, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this.vramTracker = new
|
|
8937
|
+
super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1, this._useDynamicDispatch = !0, this._useSubgroupCompact = !1, this._multiSampleMaxPixels = X.wavefrontMultiSampleMaxPixels ?? 589824, this._samplesPerPass = 1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._bounceEarlyExitThreshold = 100, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this.vramTracker = new pc(), this._registerVRAMProviders(), console.log("PathTracer: initialized (wavefront)");
|
|
8810
8938
|
}
|
|
8811
8939
|
_registerVRAMProviders() {
|
|
8812
8940
|
let e = this.vramTracker;
|
|
@@ -8949,7 +9077,7 @@ var Gl = class extends bs {
|
|
|
8949
9077
|
let n = this.storageTextures.renderWidth, r = this.storageTextures.renderHeight;
|
|
8950
9078
|
if (n === e && r === t || !(this.materialData?.materialCount > 0)) return;
|
|
8951
9079
|
this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackFrameCounter = 0, this._readbackGeneration++;
|
|
8952
|
-
let i = this._resolveSamplesPerPass(n, r), a =
|
|
9080
|
+
let i = this._resolveSamplesPerPass(n, r), a = Ds.requiredCapacity(n * r * i);
|
|
8953
9081
|
!this._packedBuffers || a > this._packedBuffers.capacity || i !== this._samplesPerPass ? (this._kernelManager && this._kernelManager.dispose(), this._wavefrontReady = !1, this._buildWavefrontKernels()) : this._resizeWavefrontInPlace(n, r);
|
|
8954
9082
|
}
|
|
8955
9083
|
_resizeWavefrontInPlace(e, t) {
|
|
@@ -8966,15 +9094,15 @@ var Gl = class extends bs {
|
|
|
8966
9094
|
let t = this.storageTextures.renderWidth, n = this.storageTextures.renderHeight;
|
|
8967
9095
|
this._samplesPerPass = this._resolveSamplesPerPass(t, n);
|
|
8968
9096
|
let r = this._samplesPerPass | 0, i = t * n, a = i * r;
|
|
8969
|
-
this._bounceEarlyExitThreshold !== -1 && (this._bounceEarlyExitThreshold = Math.max(100, Math.floor(a / 1e3))), this._packedBuffers ? this._packedBuffers.resize(a) : this._packedBuffers = new
|
|
8970
|
-
let s =
|
|
9097
|
+
this._bounceEarlyExitThreshold !== -1 && (this._bounceEarlyExitThreshold = Math.max(100, Math.floor(a / 1e3))), this._packedBuffers ? this._packedBuffers.resize(a) : this._packedBuffers = new Ds(a);
|
|
9098
|
+
let s = Ds.requiredCapacity(i) * 2;
|
|
8971
9099
|
this._gBufferAttr = new o(new Uint32Array(s * 4), 4);
|
|
8972
9100
|
let c = Ce(this._gBufferAttr, "uvec4"), l = Ce(this._gBufferAttr, "uvec4").toReadOnly();
|
|
8973
|
-
this._queueManager ? this._queueManager.resize(this._packedBuffers.capacity) : this._queueManager = new
|
|
9101
|
+
this._queueManager ? this._queueManager.resize(this._packedBuffers.capacity) : this._queueManager = new sc(this._packedBuffers.capacity), this._kernelManager ||= new hc(this.renderer);
|
|
8974
9102
|
let u = this._packedBuffers, d = this._queueManager;
|
|
8975
9103
|
this._wfRenderWidth.value = t, this._wfRenderHeight.value = n, this._wfMaxRayCount.value = a;
|
|
8976
9104
|
let m = this.shaderBuilder.prevColorTexNode, g = this.shaderBuilder.prevNormalDepthTexNode, _ = this.shaderBuilder.prevAlbedoTexNode, v = this.storageTextures.getWriteTextures(), y = d.getCounters(), b = f(() => {
|
|
8977
|
-
C(y.element(B(
|
|
9105
|
+
C(y.element(B(ac.ACTIVE_RAY_COUNT)), B(0));
|
|
8978
9106
|
});
|
|
8979
9107
|
this._kernelManager.register("resetCounters", b().compute([
|
|
8980
9108
|
1,
|
|
@@ -8986,7 +9114,7 @@ var Gl = class extends bs {
|
|
|
8986
9114
|
1
|
|
8987
9115
|
]));
|
|
8988
9116
|
let x = f(() => {
|
|
8989
|
-
C(y.element(B(
|
|
9117
|
+
C(y.element(B(ac.ACTIVE_RAY_COUNT)), B(0));
|
|
8990
9118
|
});
|
|
8991
9119
|
this._kernelManager.register("resetActiveCounter", x().compute([
|
|
8992
9120
|
1,
|
|
@@ -8998,8 +9126,8 @@ var Gl = class extends bs {
|
|
|
8998
9126
|
1
|
|
8999
9127
|
]));
|
|
9000
9128
|
let w = d.getBounceCounts(), T = this._wfCurrentBounce, E = f(() => {
|
|
9001
|
-
let e = S(y.element(B(
|
|
9002
|
-
w.element(t).assign(e), C(y.element(B(
|
|
9129
|
+
let e = S(y.element(B(ac.ACTIVE_RAY_COUNT))), t = B(T).clamp(B(0), B(d.MAX_BOUNCE_SNAPSHOTS - 1));
|
|
9130
|
+
w.element(t).assign(e), C(y.element(B(ac.ENTERING_COUNT)), e);
|
|
9003
9131
|
});
|
|
9004
9132
|
this._kernelManager.register("snapshotBounceCount", E().compute([
|
|
9005
9133
|
1,
|
|
@@ -9013,7 +9141,7 @@ var Gl = class extends bs {
|
|
|
9013
9141
|
let D = d.activeIndices.a, O = f(() => {
|
|
9014
9142
|
let e = re;
|
|
9015
9143
|
D.element(e).assign(e), p(e.equal(B(0)), () => {
|
|
9016
|
-
C(y.element(B(
|
|
9144
|
+
C(y.element(B(ac.ACTIVE_RAY_COUNT)), this._wfMaxRayCount), C(y.element(B(ac.ENTERING_COUNT)), this._wfMaxRayCount);
|
|
9017
9145
|
});
|
|
9018
9146
|
});
|
|
9019
9147
|
this._kernelManager.register("initActiveIndices", O().compute([
|
|
@@ -9025,7 +9153,7 @@ var Gl = class extends bs {
|
|
|
9025
9153
|
1,
|
|
9026
9154
|
1
|
|
9027
9155
|
]));
|
|
9028
|
-
let k =
|
|
9156
|
+
let k = Oc({
|
|
9029
9157
|
rayBufferRW: u.rayBuffer.rw,
|
|
9030
9158
|
rngBufferRW: u.rngBuffer.rw,
|
|
9031
9159
|
gBufferRW: c,
|
|
@@ -9067,7 +9195,7 @@ var Gl = class extends bs {
|
|
|
9067
9195
|
emissiveMaps: F,
|
|
9068
9196
|
displacementMaps: le
|
|
9069
9197
|
};
|
|
9070
|
-
let ue =
|
|
9198
|
+
let ue = kc({
|
|
9071
9199
|
bvhBuffer: A,
|
|
9072
9200
|
triangleBuffer: j,
|
|
9073
9201
|
materialBuffer: M,
|
|
@@ -9086,7 +9214,7 @@ var Gl = class extends bs {
|
|
|
9086
9214
|
1,
|
|
9087
9215
|
1
|
|
9088
9216
|
]));
|
|
9089
|
-
let L =
|
|
9217
|
+
let L = Vl({
|
|
9090
9218
|
gBufferRW: c,
|
|
9091
9219
|
envCompensationDelta: this.envCompensationDelta,
|
|
9092
9220
|
bvhBuffer: A,
|
|
@@ -9142,6 +9270,7 @@ var Gl = class extends bs {
|
|
|
9142
9270
|
totalTriangleCount: this.totalTriangleCount,
|
|
9143
9271
|
enableEmissiveTriangleSampling: this.enableEmissiveTriangleSampling,
|
|
9144
9272
|
lightBVHNodeCount: this.lightBVHNodeCount,
|
|
9273
|
+
reverseMapVec4Offset: this.reverseMapVec4Offset,
|
|
9145
9274
|
currentBounce: this._wfCurrentBounce,
|
|
9146
9275
|
maxRayCount: this._wfMaxRayCount
|
|
9147
9276
|
});
|
|
@@ -9156,7 +9285,7 @@ var Gl = class extends bs {
|
|
|
9156
9285
|
]));
|
|
9157
9286
|
let de = this._useSubgroupCompact && (this.renderer.hasFeature ? this.renderer.hasFeature("subgroups") : !1);
|
|
9158
9287
|
this._compactIsSubgroup = de;
|
|
9159
|
-
let fe = (de ?
|
|
9288
|
+
let fe = (de ? Ul : Hl)({
|
|
9160
9289
|
rayBufferRO: u.rayBuffer.ro,
|
|
9161
9290
|
activeIndicesReadRO: d.getActiveReadRO(),
|
|
9162
9291
|
activeIndicesWriteRW: d.getActiveWrite(),
|
|
@@ -9173,7 +9302,7 @@ var Gl = class extends bs {
|
|
|
9173
9302
|
1
|
|
9174
9303
|
]));
|
|
9175
9304
|
let pe = f(() => {
|
|
9176
|
-
C(y.element(B(
|
|
9305
|
+
C(y.element(B(ac.ENTERING_COUNT)), this._wfMaxRayCount);
|
|
9177
9306
|
});
|
|
9178
9307
|
this._kernelManager.register("enterFull", pe().compute([
|
|
9179
9308
|
1,
|
|
@@ -9186,7 +9315,7 @@ var Gl = class extends bs {
|
|
|
9186
9315
|
]));
|
|
9187
9316
|
let me = d.activeIndicesRO.b, he = d.activeIndices.a, ge = f(() => {
|
|
9188
9317
|
let e = re;
|
|
9189
|
-
p(e.greaterThanEqual(S(y.element(B(
|
|
9318
|
+
p(e.greaterThanEqual(S(y.element(B(ac.ACTIVE_RAY_COUNT)))), () => {
|
|
9190
9319
|
h();
|
|
9191
9320
|
}), he.element(e).assign(me.element(e));
|
|
9192
9321
|
});
|
|
@@ -9199,7 +9328,7 @@ var Gl = class extends bs {
|
|
|
9199
9328
|
1,
|
|
9200
9329
|
1
|
|
9201
9330
|
]));
|
|
9202
|
-
let _e =
|
|
9331
|
+
let _e = Gl({
|
|
9203
9332
|
rayBufferRO: u.rayBuffer.ro,
|
|
9204
9333
|
gBufferRO: l,
|
|
9205
9334
|
writeColorTex: v.color,
|
|
@@ -9229,7 +9358,7 @@ var Gl = class extends bs {
|
|
|
9229
9358
|
16,
|
|
9230
9359
|
1
|
|
9231
9360
|
]));
|
|
9232
|
-
let R =
|
|
9361
|
+
let R = Xl({
|
|
9233
9362
|
writeColorTex: v.color,
|
|
9234
9363
|
writeNDTex: v.normalDepth,
|
|
9235
9364
|
writeAlbedoTex: v.albedo,
|
|
@@ -9294,7 +9423,7 @@ var Gl = class extends bs {
|
|
|
9294
9423
|
dispose() {
|
|
9295
9424
|
super.dispose(), this._packedBuffers?.dispose(), this._queueManager?.dispose(), this._kernelManager?.dispose(), this._gBufferAttr?.dispose?.(), this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1;
|
|
9296
9425
|
}
|
|
9297
|
-
},
|
|
9426
|
+
}, Ql = class extends qn {
|
|
9298
9427
|
constructor(e, t = {}) {
|
|
9299
9428
|
super("NormalDepth", {
|
|
9300
9429
|
...t,
|
|
@@ -9351,7 +9480,7 @@ var Gl = class extends bs {
|
|
|
9351
9480
|
let m = W(M(d).add(.5).div(s).mul(2).sub(1), M(f).add(.5).div(c).mul(2).sub(1).negate(), 1), h = o.mul(G(m, 1)), g = L(ce(a[0].xyz, a[1].xyz, a[2].xyz).mul(h.xyz.div(h.w))), _ = ui({
|
|
9352
9481
|
origin: W(a[3]),
|
|
9353
9482
|
direction: g
|
|
9354
|
-
}), v = pi.wrap(
|
|
9483
|
+
}), v = pi.wrap(Tc(_, t, e)), y = v.normal.mul(.5).add(.5), b = v.dst, x = v.didHit.select(G(y, b), G(0, 0, 0, M(1e6)));
|
|
9355
9484
|
Ae(l, Fe(B(d), B(f)), x).toWriteOnly();
|
|
9356
9485
|
let S = v.normal.toVar();
|
|
9357
9486
|
p(v.didHit, () => {
|
|
@@ -9402,7 +9531,7 @@ var Gl = class extends bs {
|
|
|
9402
9531
|
dispose() {
|
|
9403
9532
|
this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose(), this._shadingRT?.dispose(), this._rtA?.dispose(), this._rtB?.dispose();
|
|
9404
9533
|
}
|
|
9405
|
-
},
|
|
9534
|
+
}, $l = class extends qn {
|
|
9406
9535
|
constructor(e, t, n = {}) {
|
|
9407
9536
|
super("MotionVector", {
|
|
9408
9537
|
...n,
|
|
@@ -9511,7 +9640,7 @@ var Gl = class extends bs {
|
|
|
9511
9640
|
dispose() {
|
|
9512
9641
|
this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose(), this.screenSpaceTarget?.dispose(), this.worldSpaceTarget?.dispose(), this._normalDepthTexNode?.dispose();
|
|
9513
9642
|
}
|
|
9514
|
-
},
|
|
9643
|
+
}, eu = (e) => R(e.equal(e), e, M(0)).clamp(0, 1e7), tu = (e) => W(eu(e.x), eu(e.y), eu(e.z)), nu = class extends qn {
|
|
9515
9644
|
constructor(e, t = {}) {
|
|
9516
9645
|
super("ASVGF", {
|
|
9517
9646
|
...t,
|
|
@@ -9552,7 +9681,7 @@ var Gl = class extends bs {
|
|
|
9552
9681
|
let e = this._colorTexNode, t = this._albedoTexNode, n = this._motionTexNode, r = this._readTemporalTexNode, i = this.gradientNoiseFloor, a = this.gradientSigmaScale, o = this._gradientStorageTex, s = this.resW, c = this.resH, l = Le("float", 144), u = Le("float", 144);
|
|
9553
9682
|
this._gradientNode = f(() => {
|
|
9554
9683
|
let d = oe.x, f = oe.y, m = f.mul(8).add(d), h = N(ze.x).mul(8).sub(2).toVar(), g = N(ze.y).mul(8).sub(2).toVar(), v = (i) => {
|
|
9555
|
-
let a = i.mod(B(12)), o = i.div(B(12)), d = h.add(N(a)).clamp(N(0), N(s).sub(1)), f = g.add(N(o)).clamp(N(0), N(c).sub(1)), p = z(e, P(d, f)).xyz, m = z(t, P(d, f)).xyz, _ = zi(
|
|
9684
|
+
let a = i.mod(B(12)), o = i.div(B(12)), d = h.add(N(a)).clamp(N(0), N(s).sub(1)), f = g.add(N(o)).clamp(N(0), N(c).sub(1)), p = z(e, P(d, f)).xyz, m = z(t, P(d, f)).xyz, _ = zi(tu(p.div(F(m, W(lr))))).toVar();
|
|
9556
9685
|
l.element(i).assign(_);
|
|
9557
9686
|
let v = z(n, P(d, f)), y = M(d).sub(v.x.mul(s)), b = M(f).sub(v.y.mul(c)), x = N(y.add(.5)).clamp(N(0), N(s).sub(1)), S = N(b.add(.5)).clamp(N(0), N(c).sub(1)), C = v.w.greaterThan(.5), w = z(r, P(x, S)).xyz, T = C.select(zi(w), _);
|
|
9558
9687
|
u.element(i).assign(T);
|
|
@@ -9599,7 +9728,7 @@ var Gl = class extends bs {
|
|
|
9599
9728
|
return f(() => {
|
|
9600
9729
|
let f = N(ze.x).mul(8).add(N(oe.x)), y = N(ze.y).mul(8).add(N(oe.y));
|
|
9601
9730
|
p(f.lessThan(N(g)).and(y.lessThan(N(v))), () => {
|
|
9602
|
-
let b = P(f, y), x = z(t, b).xyz, S = z(n, b).xyz, C = F(S, W(lr)), w =
|
|
9731
|
+
let b = P(f, y), x = z(t, b).xyz, S = z(n, b).xyz, C = F(S, W(lr)), w = tu(x.div(C)), T = G(w, 1).toVar(), E = G(x, 1).toVar();
|
|
9603
9732
|
p(m.greaterThan(.5).and(h.lessThan(.5)), () => {
|
|
9604
9733
|
let e = z(r, b), t = e.w.greaterThan(.5), n = M(f).sub(e.x.mul(g)), c = M(y).sub(e.y.mul(v)), m = n.greaterThanEqual(0).and(n.lessThan(M(g))).and(c.greaterThanEqual(0)).and(c.lessThan(M(v)));
|
|
9605
9734
|
p(t.and(m), () => {
|
|
@@ -9608,7 +9737,7 @@ var Gl = class extends bs {
|
|
|
9608
9737
|
return i.mul(l).mul(u);
|
|
9609
9738
|
}, oe = ae(D, k, te), se = ae(O, k, ne), ce = ae(D, ee, re), ue = ae(O, ee, ie), L = oe.add(se).add(ce).add(ue);
|
|
9610
9739
|
p(L.greaterThan(M(.01)), () => {
|
|
9611
|
-
let e = z(o, P(D, k)), t = z(o, P(O, k)), n = z(o, P(D, ee)), r = z(o, P(O, ee)), i = M(1).div(L), a = e.xyz.mul(oe).add(t.xyz.mul(se)).add(n.xyz.mul(ce)).add(r.xyz.mul(ue)).mul(i), c = e.w.mul(oe).add(t.w.mul(se)).add(n.w.mul(ce)).add(r.w.mul(ue)).mul(i), f = z(s, b).x.mul(d).clamp(0, 1), p =
|
|
9740
|
+
let e = z(o, P(D, k)), t = z(o, P(O, k)), n = z(o, P(D, ee)), r = z(o, P(O, ee)), i = M(1).div(L), a = e.xyz.mul(oe).add(t.xyz.mul(se)).add(n.xyz.mul(ce)).add(r.xyz.mul(ue)).mul(i), c = e.w.mul(oe).add(t.w.mul(se)).add(n.w.mul(ce)).add(r.w.mul(ue)).mul(i), f = z(s, b).x.mul(d).clamp(0, 1), p = tu(I(a, w, I(F(M(1).div(c.add(1)), u), M(1), f))), m = le(c.add(1), l);
|
|
9612
9741
|
T.assign(G(p, m)), E.assign(G(p.mul(C), 1));
|
|
9613
9742
|
});
|
|
9614
9743
|
});
|
|
@@ -9717,7 +9846,7 @@ var Gl = class extends bs {
|
|
|
9717
9846
|
dispose() {
|
|
9718
9847
|
this._gradientNode?.dispose(), this._temporalNodeA?.dispose(), this._temporalNodeB?.dispose(), this._temporalTexA?.dispose(), this._temporalTexB?.dispose(), this._outputModulatedTex?.dispose(), this._gradientStorageTex?.dispose(), this._demodulatedRT?.dispose(), this._outputRT?.dispose(), this._gradientRT?.dispose(), this._heatmapComputeNode?.dispose(), this._heatmapStorageTex?.dispose(), this.heatmapTarget?.dispose(), this._colorTexNode?.dispose(), this._albedoTexNode?.dispose(), this._motionTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._prevNormalDepthTexNode?.dispose(), this._readTemporalTexNode?.dispose(), this._gradientReadTexNode?.dispose(), this._heatmapRawColorTexNode?.dispose(), this._heatmapColorTexNode?.dispose(), this._heatmapTemporalTexNode?.dispose(), this._heatmapNDTexNode?.dispose(), this._heatmapMotionTexNode?.dispose(), this._heatmapGradientTexNode?.dispose();
|
|
9719
9848
|
}
|
|
9720
|
-
},
|
|
9849
|
+
}, ru = (e) => R(e.equal(e), e, M(0)).clamp(0, 1e7), iu = /* @__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"), au = class extends qn {
|
|
9721
9850
|
constructor(e, t = {}) {
|
|
9722
9851
|
super("VarianceEstimation", {
|
|
9723
9852
|
...t,
|
|
@@ -9743,9 +9872,9 @@ var Gl = class extends bs {
|
|
|
9743
9872
|
let n = this._colorTexNode, r = this.temporalAlpha, i = this.varianceBoost, a = this.resW, o = this.resH, s = Le("float", 100);
|
|
9744
9873
|
return f(() => {
|
|
9745
9874
|
let c = oe.x, l = oe.y, u = l.mul(8).add(c), d = N(ze.x).mul(8).sub(1), f = N(ze.y).mul(8).sub(1), m = u.mod(10), h = u.div(10), g = z(n, P(d.add(N(m)).clamp(N(0), N(a).sub(1)), f.add(N(h)).clamp(N(0), N(o).sub(1)))).xyz;
|
|
9746
|
-
s.element(u).assign(
|
|
9875
|
+
s.element(u).assign(ru(zi(g))), p(u.lessThan(B(36)), () => {
|
|
9747
9876
|
let e = u.add(B(64)), t = e.mod(10), r = e.div(10), i = z(n, P(d.add(N(t)).clamp(N(0), N(a).sub(1)), f.add(N(r)).clamp(N(0), N(o).sub(1)))).xyz;
|
|
9748
|
-
s.element(e).assign(
|
|
9877
|
+
s.element(e).assign(ru(zi(i)));
|
|
9749
9878
|
}), Re();
|
|
9750
9879
|
let _ = N(ze.x).mul(8).add(N(c)), v = N(ze.y).mul(8).add(N(l));
|
|
9751
9880
|
p(_.lessThan(N(a)).and(v.lessThan(N(o))), () => {
|
|
@@ -9756,7 +9885,7 @@ var Gl = class extends bs {
|
|
|
9756
9885
|
}
|
|
9757
9886
|
n.divAssign(9), a.divAssign(9);
|
|
9758
9887
|
let o = F(a.sub(n.mul(n)), M(0)), u = s.element(l.add(1).mul(10).add(c.add(1))), d = z(t, P(_, v));
|
|
9759
|
-
Ae(e, Fe(B(_), B(v)),
|
|
9888
|
+
Ae(e, Fe(B(_), B(v)), iu(u, d.x, d.y, r, o, i)).toWriteOnly();
|
|
9760
9889
|
});
|
|
9761
9890
|
})().compute([
|
|
9762
9891
|
this._dispatchX,
|
|
@@ -9799,7 +9928,7 @@ var Gl = class extends bs {
|
|
|
9799
9928
|
dispose() {
|
|
9800
9929
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._colorTexNode?.dispose(), this._readTexNodeA?.dispose(), this._readTexNodeB?.dispose();
|
|
9801
9930
|
}
|
|
9802
|
-
},
|
|
9931
|
+
}, ou = /* @__PURE__ */ K("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n sigmaL: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) / sigmaL );\n // clamp dot to [0,1]: miss-ray normals decode to (-1,-1,-1) with\n // dot=3 → pow saturates to +inf → inf*0 = NaN. See project_tsl_pitfalls.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), phiNorm );\n let depW = exp( -abs( centerDepth - sDepth ) / max( centerDepth * phiDep, 0.001 ) );\n let maxDiff = max( max( abs( centerColor.x - sColor.x ),\n abs( centerColor.y - sColor.y ) ),\n abs( centerColor.z - sColor.z ) );\n let avgLum = max( ( centerLum + sLum ) * 0.5, 0.0001 );\n let colW = exp( -( maxDiff / avgLum ) / max( phiCol, 0.0001 ) );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), su = class extends qn {
|
|
9803
9932
|
constructor(e, t = {}) {
|
|
9804
9933
|
super("BilateralFiltering", {
|
|
9805
9934
|
...t,
|
|
@@ -9851,7 +9980,7 @@ var Gl = class extends bs {
|
|
|
9851
9980
|
p(f.lessThan(N(h)).and(v.lessThan(N(g))), () => {
|
|
9852
9981
|
let p = P(f, v), y = z(t, p).xyz, b = z(n, p), x = z(r, p).xyz.mul(2).sub(1), S = b.w, C = zi(y), w = F(z(i, p).xyz, W(lr)), T = F(zi(w), M(lr)).toVar(), E = z(a, p), D = I(E.z, F(E.z, E.w), u), O = l.mul(xe(F(D, M(0)))).div(T).add(M(1e-4)), k = W(0).toVar(), A = M(0).toVar();
|
|
9853
9982
|
for (let e = 0; e < 5; e++) for (let i = 0; i < 5; i++) {
|
|
9854
|
-
let a = i - 2, l = e - 2, u = _[e * 5 + i], p = f.add(d.mul(a)).clamp(N(0), N(h).sub(1)), m = v.add(d.mul(l)).clamp(N(0), N(g).sub(1)), b = z(t, P(p, m)).xyz, w = z(n, P(p, m)), T = z(r, P(p, m)).xyz.mul(2).sub(1), E = w.w, D =
|
|
9983
|
+
let a = i - 2, l = e - 2, u = _[e * 5 + i], p = f.add(d.mul(a)).clamp(N(0), N(h).sub(1)), m = v.add(d.mul(l)).clamp(N(0), N(g).sub(1)), b = z(t, P(p, m)).xyz, w = z(n, P(p, m)), T = z(r, P(p, m)).xyz.mul(2).sub(1), E = w.w, D = ou(C, zi(b), x, T, S, E, y, b, M(u), O, s, c, o);
|
|
9855
9984
|
k.addAssign(b.mul(D)), A.addAssign(D);
|
|
9856
9985
|
}
|
|
9857
9986
|
let j = k.div(F(A, M(1e-4))), ee = m.equal(N(1)).select(j.mul(w), j);
|
|
@@ -9899,7 +10028,7 @@ var Gl = class extends bs {
|
|
|
9899
10028
|
dispose() {
|
|
9900
10029
|
this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._readTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._shadingNormalTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varianceTexNode?.dispose();
|
|
9901
10030
|
}
|
|
9902
|
-
},
|
|
10031
|
+
}, cu = class extends qn {
|
|
9903
10032
|
constructor(e, t = {}) {
|
|
9904
10033
|
super("EdgeAwareFiltering", {
|
|
9905
10034
|
...t,
|
|
@@ -9982,7 +10111,7 @@ var Gl = class extends bs {
|
|
|
9982
10111
|
dispose() {
|
|
9983
10112
|
this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this.outputTarget?.dispose(), this._inputTexNode?.dispose(), this._ndTexNode?.dispose();
|
|
9984
10113
|
}
|
|
9985
|
-
},
|
|
10114
|
+
}, lu = 256, uu = -8, du = 6 - uu, fu = du / lu, pu = 1e4, mu = /* @__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"), hu = class extends qn {
|
|
9986
10115
|
constructor(e, t = {}) {
|
|
9987
10116
|
super("AutoExposure", {
|
|
9988
10117
|
...t,
|
|
@@ -9998,7 +10127,7 @@ var Gl = class extends bs {
|
|
|
9998
10127
|
depthBuffer: !1,
|
|
9999
10128
|
stencilBuffer: !1
|
|
10000
10129
|
};
|
|
10001
|
-
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = st, this._downsampleStorageTex.format = Ft, this._downsampleStorageTex.minFilter = wt, this._downsampleStorageTex.magFilter = wt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = st, this._reductionStorageTex.format = Ft, this._reductionStorageTex.minFilter = wt, this._reductionStorageTex.magFilter = wt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(
|
|
10130
|
+
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = st, this._downsampleStorageTex.format = Ft, this._downsampleStorageTex.minFilter = wt, this._downsampleStorageTex.magFilter = wt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = st, this._reductionStorageTex.format = Ft, this._reductionStorageTex.minFilter = wt, this._reductionStorageTex.magFilter = wt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(lu, "uint").toAtomic();
|
|
10002
10131
|
}
|
|
10003
10132
|
_buildCompute() {
|
|
10004
10133
|
this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
|
|
@@ -10032,7 +10161,7 @@ var Gl = class extends bs {
|
|
|
10032
10161
|
for (let i = 0; i < 16; i++) {
|
|
10033
10162
|
let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = z(e, P(N(o), N(s))), l = c.x, u = c.y;
|
|
10034
10163
|
p(u.greaterThan(0), () => {
|
|
10035
|
-
let e = B(l.div(u).sub(M(
|
|
10164
|
+
let e = B(l.div(u).sub(M(uu)).div(M(du)).mul(M(lu)).floor().clamp(0, M(lu - 1))), r = M(o).add(.5).div(M(64)), i = M(s).add(.5).div(M(64)), a = r.sub(.5), c = i.sub(.5), d = B(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(M(pu)));
|
|
10036
10165
|
x(t.element(e), d);
|
|
10037
10166
|
});
|
|
10038
10167
|
}
|
|
@@ -10050,14 +10179,14 @@ var Gl = class extends bs {
|
|
|
10050
10179
|
let e = this._histogramBuffer, t = this._reductionStorageTex, n = this.lowPercentileU, r = this.highPercentileU;
|
|
10051
10180
|
this._histogramAnalyzeNode = f(() => {
|
|
10052
10181
|
let i = M(0).toVar();
|
|
10053
|
-
m(
|
|
10182
|
+
m(lu, ({ i: t }) => {
|
|
10054
10183
|
i.addAssign(M(S(e.element(t))));
|
|
10055
10184
|
});
|
|
10056
10185
|
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();
|
|
10057
|
-
m(
|
|
10186
|
+
m(lu, ({ i: t }) => {
|
|
10058
10187
|
let n = M(S(e.element(t)));
|
|
10059
10188
|
u.assign(s), s.addAssign(n), p(u.lessThan(o).and(s.greaterThan(a)), () => {
|
|
10060
|
-
let e = M(
|
|
10189
|
+
let e = M(uu).add(M(t).add(.5).mul(M(fu)));
|
|
10061
10190
|
c.addAssign(e.mul(n)), l.addAssign(n);
|
|
10062
10191
|
});
|
|
10063
10192
|
});
|
|
@@ -10072,7 +10201,7 @@ var Gl = class extends bs {
|
|
|
10072
10201
|
_buildAdaptationCompute() {
|
|
10073
10202
|
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;
|
|
10074
10203
|
this._adaptationComputeNode = f(() => {
|
|
10075
|
-
let u = z(e, P(N(0), N(0))).x, d =
|
|
10204
|
+
let u = z(e, P(N(0), N(0))).x, d = mu(u, l, n, r, i, a, o, s, c);
|
|
10076
10205
|
t.element(B(0)).assign(d);
|
|
10077
10206
|
})().compute(1, [
|
|
10078
10207
|
1,
|
|
@@ -10139,7 +10268,7 @@ var Gl = class extends bs {
|
|
|
10139
10268
|
};
|
|
10140
10269
|
//#endregion
|
|
10141
10270
|
//#region src/TSL/SSRC.js
|
|
10142
|
-
function
|
|
10271
|
+
function gu({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode: r, readPrevNDTexNode: i, writeCacheTex: a, writePrevNDTex: o, resW: s, resH: c, temporalAlpha: l, phiNormal: u, phiDepth: d, maxHistory: m, framesSinceReset: h }) {
|
|
10143
10272
|
return f(() => {
|
|
10144
10273
|
let f = N(ze.x).mul(8).add(N(oe.x)), g = N(ze.y).mul(8).add(N(oe.y));
|
|
10145
10274
|
p(f.lessThan(N(s)).and(g.lessThan(N(c))), () => {
|
|
@@ -10161,7 +10290,7 @@ function uu({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode:
|
|
|
10161
10290
|
});
|
|
10162
10291
|
});
|
|
10163
10292
|
}
|
|
10164
|
-
function
|
|
10293
|
+
function _u({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r, resW: i, resH: a, spatialRadius: o, spatialWeight: s, phiNormal: c, phiDepth: l }) {
|
|
10165
10294
|
let u = [
|
|
10166
10295
|
[1, 0],
|
|
10167
10296
|
[-1, 0],
|
|
@@ -10187,7 +10316,7 @@ function du({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r,
|
|
|
10187
10316
|
}
|
|
10188
10317
|
//#endregion
|
|
10189
10318
|
//#region src/Stages/SSRC.js
|
|
10190
|
-
var
|
|
10319
|
+
var vu = class extends qn {
|
|
10191
10320
|
constructor(e, t = {}) {
|
|
10192
10321
|
super("SSRC", {
|
|
10193
10322
|
...t,
|
|
@@ -10269,12 +10398,12 @@ var fu = class extends qn {
|
|
|
10269
10398
|
phiNormal: this.phiNormal,
|
|
10270
10399
|
phiDepth: this.phiDepth,
|
|
10271
10400
|
maxHistory: this.maxHistory
|
|
10272
|
-
}, t =
|
|
10401
|
+
}, t = gu({
|
|
10273
10402
|
...e,
|
|
10274
10403
|
writeCacheTex: this._cacheTexA,
|
|
10275
10404
|
writePrevNDTex: this._prevNDTexA,
|
|
10276
10405
|
framesSinceReset: this._framesSinceReset
|
|
10277
|
-
}), n =
|
|
10406
|
+
}), n = gu({
|
|
10278
10407
|
...e,
|
|
10279
10408
|
writeCacheTex: this._cacheTexB,
|
|
10280
10409
|
writePrevNDTex: this._prevNDTexB,
|
|
@@ -10288,7 +10417,7 @@ var fu = class extends qn {
|
|
|
10288
10417
|
8,
|
|
10289
10418
|
1
|
|
10290
10419
|
];
|
|
10291
|
-
this._pass1NodeA = t().compute(r, i), this._pass1NodeB = n().compute(r, i), this._pass2Node =
|
|
10420
|
+
this._pass1NodeA = t().compute(r, i), this._pass1NodeB = n().compute(r, i), this._pass2Node = _u({
|
|
10292
10421
|
colorTexNode: this._colorTexNode,
|
|
10293
10422
|
ndTexNode: this._ndTexNode,
|
|
10294
10423
|
readCacheTexNode: this._readPass1CacheTexNode,
|
|
@@ -10301,13 +10430,13 @@ var fu = class extends qn {
|
|
|
10301
10430
|
phiDepth: this.phiDepth
|
|
10302
10431
|
})().compute(r, i);
|
|
10303
10432
|
}
|
|
10304
|
-
},
|
|
10433
|
+
}, yu = class extends qn {
|
|
10305
10434
|
constructor(n, r = {}) {
|
|
10306
10435
|
super("Compositor", {
|
|
10307
10436
|
...r,
|
|
10308
10437
|
executionMode: Kn.ALWAYS
|
|
10309
10438
|
}), this.renderer = n, this.saturation = V(r.saturation ?? 1), this._transparentBackground = V(0, "int"), this._sourceTexNode = new c();
|
|
10310
|
-
let i = this._sourceTexNode.sample(
|
|
10439
|
+
let i = this._sourceTexNode.sample(H()), a = I(W(A(i.xyz, Mi)), i.xyz, this.saturation), o = R(this._transparentBackground, i.w, 1);
|
|
10311
10440
|
this.compositorMaterial = new e(), this.compositorMaterial.colorNode = G(a, o), this.compositorMaterial.blending = Et, this.compositorQuad = new t(this.compositorMaterial);
|
|
10312
10441
|
}
|
|
10313
10442
|
_resolveSourceTexture(e) {
|
|
@@ -10327,7 +10456,7 @@ var fu = class extends qn {
|
|
|
10327
10456
|
dispose() {
|
|
10328
10457
|
this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this.compositorQuad = null;
|
|
10329
10458
|
}
|
|
10330
|
-
},
|
|
10459
|
+
}, bu = class {
|
|
10331
10460
|
constructor() {
|
|
10332
10461
|
this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
|
|
10333
10462
|
frame: 0,
|
|
@@ -10449,7 +10578,7 @@ var fu = class extends qn {
|
|
|
10449
10578
|
dispose() {
|
|
10450
10579
|
this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
|
|
10451
10580
|
}
|
|
10452
|
-
},
|
|
10581
|
+
}, xu = class extends q {
|
|
10453
10582
|
constructor() {
|
|
10454
10583
|
super(), this._onceCallbacks = /* @__PURE__ */ new Map();
|
|
10455
10584
|
}
|
|
@@ -10487,9 +10616,9 @@ var fu = class extends qn {
|
|
|
10487
10616
|
eventNames() {
|
|
10488
10617
|
return this._listeners ? Object.keys(this._listeners) : [];
|
|
10489
10618
|
}
|
|
10490
|
-
},
|
|
10619
|
+
}, Su = class {
|
|
10491
10620
|
constructor(e, t, n) {
|
|
10492
|
-
this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new
|
|
10621
|
+
this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new bu(), this.eventBus = new xu(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
|
|
10493
10622
|
enabled: !1,
|
|
10494
10623
|
logSkipped: !1,
|
|
10495
10624
|
timings: /* @__PURE__ */ new Map(),
|
|
@@ -10621,7 +10750,7 @@ var fu = class extends qn {
|
|
|
10621
10750
|
let e = this.getInfo();
|
|
10622
10751
|
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();
|
|
10623
10752
|
}
|
|
10624
|
-
},
|
|
10753
|
+
}, Cu = class {
|
|
10625
10754
|
constructor() {
|
|
10626
10755
|
this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1;
|
|
10627
10756
|
}
|
|
@@ -10643,7 +10772,7 @@ var fu = class extends qn {
|
|
|
10643
10772
|
resumeFromPause() {
|
|
10644
10773
|
this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
|
|
10645
10774
|
}
|
|
10646
|
-
},
|
|
10775
|
+
}, wu = class extends q {
|
|
10647
10776
|
constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
|
|
10648
10777
|
super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new Rt(), this.focusMode = !1, this.focusPointIndicator = null, this.afPointPlacementMode = !1, this.handleAFPointClick = this.handleAFPointClick.bind(this), this.selectedObject = null, this.selectMode = !1, this.clickTimeout = null, this.mouseDownPosition = null, this.dragThreshold = 5, this.handleFocusClick = this.handleFocusClick.bind(this), this.handleSelectClick = this.handleSelectClick.bind(this), this.handleSelectDoubleClick = this.handleSelectDoubleClick.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), this.handleMouseUp = this.handleMouseUp.bind(this), this.handleContextMenu = this.handleContextMenu.bind(this), this.handleContextPointerDown = this.handleContextPointerDown.bind(this), this.handleContextPointerUp = this.handleContextPointerUp.bind(this), this.contextPointerDownPosition = null, this.canvas.addEventListener("pointerdown", this.handleContextPointerDown), this.canvas.addEventListener("pointerup", this.handleContextPointerUp), this.canvas.addEventListener("contextmenu", this.handleContextMenu), this._overlayManager = null, this._transformManager = null, this._appDispatch = null, this._orbitControls = null;
|
|
10649
10778
|
}
|
|
@@ -10864,18 +10993,18 @@ var fu = class extends qn {
|
|
|
10864
10993
|
dispose() {
|
|
10865
10994
|
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;
|
|
10866
10995
|
}
|
|
10867
|
-
},
|
|
10996
|
+
}, Tu = {
|
|
10868
10997
|
STRING: "string",
|
|
10869
10998
|
NUMBER: "number",
|
|
10870
10999
|
WORD: "word",
|
|
10871
11000
|
LBRACKET: "[",
|
|
10872
11001
|
RBRACKET: "]"
|
|
10873
|
-
},
|
|
10874
|
-
function
|
|
11002
|
+
}, Eu = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f", Du = (e) => e >= "0" && e <= "9", Ou = (e, t, n) => !!(Du(e) || e === "." && Du(t) || (e === "-" || e === "+") && (Du(t) || t === "." && Du(n)));
|
|
11003
|
+
function ku(e) {
|
|
10875
11004
|
let t = [], n = e.length, r = 0;
|
|
10876
11005
|
for (; r < n;) {
|
|
10877
11006
|
let i = e[r];
|
|
10878
|
-
if (
|
|
11007
|
+
if (Eu(i)) {
|
|
10879
11008
|
r++;
|
|
10880
11009
|
continue;
|
|
10881
11010
|
}
|
|
@@ -10884,11 +11013,11 @@ function Cu(e) {
|
|
|
10884
11013
|
continue;
|
|
10885
11014
|
}
|
|
10886
11015
|
if (i === "[") {
|
|
10887
|
-
t.push({ type:
|
|
11016
|
+
t.push({ type: Tu.LBRACKET }), r++;
|
|
10888
11017
|
continue;
|
|
10889
11018
|
}
|
|
10890
11019
|
if (i === "]") {
|
|
10891
|
-
t.push({ type:
|
|
11020
|
+
t.push({ type: Tu.RBRACKET }), r++;
|
|
10892
11021
|
continue;
|
|
10893
11022
|
}
|
|
10894
11023
|
if (i === "\"") {
|
|
@@ -10897,12 +11026,12 @@ function Cu(e) {
|
|
|
10897
11026
|
for (; r < n && e[r] !== "\"";) r++;
|
|
10898
11027
|
if (r >= n) throw Error("PBRT tokenizer: unterminated string literal");
|
|
10899
11028
|
t.push({
|
|
10900
|
-
type:
|
|
11029
|
+
type: Tu.STRING,
|
|
10901
11030
|
value: e.slice(i, r)
|
|
10902
11031
|
}), r++;
|
|
10903
11032
|
continue;
|
|
10904
11033
|
}
|
|
10905
|
-
if (
|
|
11034
|
+
if (Ou(i, e[r + 1], e[r + 2])) {
|
|
10906
11035
|
let i = r;
|
|
10907
11036
|
for (r++; r < n;) {
|
|
10908
11037
|
let t = e[r];
|
|
@@ -10912,16 +11041,16 @@ function Cu(e) {
|
|
|
10912
11041
|
let a = e.slice(i, r), o = Number(a);
|
|
10913
11042
|
if (Number.isNaN(o)) throw Error(`PBRT tokenizer: invalid number "${a}"`);
|
|
10914
11043
|
t.push({
|
|
10915
|
-
type:
|
|
11044
|
+
type: Tu.NUMBER,
|
|
10916
11045
|
value: o
|
|
10917
11046
|
});
|
|
10918
11047
|
continue;
|
|
10919
11048
|
}
|
|
10920
11049
|
{
|
|
10921
11050
|
let i = r;
|
|
10922
|
-
for (; r < n && !
|
|
11051
|
+
for (; r < n && !Eu(e[r]) && e[r] !== "\"" && e[r] !== "[" && e[r] !== "]" && e[r] !== "#";) r++;
|
|
10923
11052
|
t.push({
|
|
10924
|
-
type:
|
|
11053
|
+
type: Tu.WORD,
|
|
10925
11054
|
value: e.slice(i, r)
|
|
10926
11055
|
});
|
|
10927
11056
|
}
|
|
@@ -10930,7 +11059,7 @@ function Cu(e) {
|
|
|
10930
11059
|
}
|
|
10931
11060
|
//#endregion
|
|
10932
11061
|
//#region src/Processor/PBRT/PBRTMath.js
|
|
10933
|
-
function
|
|
11062
|
+
function Au() {
|
|
10934
11063
|
return [
|
|
10935
11064
|
1,
|
|
10936
11065
|
0,
|
|
@@ -10950,7 +11079,7 @@ function wu() {
|
|
|
10950
11079
|
1
|
|
10951
11080
|
];
|
|
10952
11081
|
}
|
|
10953
|
-
function
|
|
11082
|
+
function ju(e, t) {
|
|
10954
11083
|
let n = e[0], r = e[1], i = e[2], a = e[3], o = e[4], s = e[5], c = e[6], l = e[7], u = e[8], d = e[9], f = e[10], p = e[11], m = e[12], h = e[13], g = e[14], _ = e[15], v = t[0], y = t[1], b = t[2], x = t[3], S = t[4], C = t[5], w = t[6], T = t[7], E = t[8], D = t[9], O = t[10], k = t[11], A = t[12], j = t[13], M = t[14], ee = t[15];
|
|
10955
11084
|
return [
|
|
10956
11085
|
n * v + o * y + u * b + m * x,
|
|
@@ -10971,7 +11100,7 @@ function Tu(e, t) {
|
|
|
10971
11100
|
a * A + l * j + p * M + _ * ee
|
|
10972
11101
|
];
|
|
10973
11102
|
}
|
|
10974
|
-
function
|
|
11103
|
+
function Mu(e, t, n) {
|
|
10975
11104
|
return [
|
|
10976
11105
|
1,
|
|
10977
11106
|
0,
|
|
@@ -10991,7 +11120,7 @@ function Eu(e, t, n) {
|
|
|
10991
11120
|
1
|
|
10992
11121
|
];
|
|
10993
11122
|
}
|
|
10994
|
-
function
|
|
11123
|
+
function Nu(e, t, n) {
|
|
10995
11124
|
return [
|
|
10996
11125
|
e,
|
|
10997
11126
|
0,
|
|
@@ -11011,7 +11140,7 @@ function Du(e, t, n) {
|
|
|
11011
11140
|
1
|
|
11012
11141
|
];
|
|
11013
11142
|
}
|
|
11014
|
-
function
|
|
11143
|
+
function Pu(e, t, n, r) {
|
|
11015
11144
|
let i = Math.hypot(t, n, r) || 1;
|
|
11016
11145
|
t /= i, n /= i, r /= i;
|
|
11017
11146
|
let a = e * Math.PI / 180, o = Math.cos(a), s = Math.sin(a), c = 1 - o, l = c * t * t + o, u = c * t * n - s * r, d = c * t * r + s * n, f = c * t * n + s * r, p = c * n * n + o, m = c * n * r - s * t;
|
|
@@ -11034,21 +11163,21 @@ function Ou(e, t, n, r) {
|
|
|
11034
11163
|
1
|
|
11035
11164
|
];
|
|
11036
11165
|
}
|
|
11037
|
-
function
|
|
11166
|
+
function Fu(e, t) {
|
|
11038
11167
|
return [
|
|
11039
11168
|
e[0] - t[0],
|
|
11040
11169
|
e[1] - t[1],
|
|
11041
11170
|
e[2] - t[2]
|
|
11042
11171
|
];
|
|
11043
11172
|
}
|
|
11044
|
-
function
|
|
11173
|
+
function Iu(e, t) {
|
|
11045
11174
|
return [
|
|
11046
11175
|
e[1] * t[2] - e[2] * t[1],
|
|
11047
11176
|
e[2] * t[0] - e[0] * t[2],
|
|
11048
11177
|
e[0] * t[1] - e[1] * t[0]
|
|
11049
11178
|
];
|
|
11050
11179
|
}
|
|
11051
|
-
function
|
|
11180
|
+
function Lu(e) {
|
|
11052
11181
|
let t = Math.hypot(e[0], e[1], e[2]) || 1;
|
|
11053
11182
|
return [
|
|
11054
11183
|
e[0] / t,
|
|
@@ -11056,8 +11185,8 @@ function ju(e) {
|
|
|
11056
11185
|
e[2] / t
|
|
11057
11186
|
];
|
|
11058
11187
|
}
|
|
11059
|
-
function
|
|
11060
|
-
let r =
|
|
11188
|
+
function Ru(e, t, n) {
|
|
11189
|
+
let r = Lu(Fu(t, e)), i = Lu(Iu(Lu(n), r)), a = Iu(r, i);
|
|
11061
11190
|
return [
|
|
11062
11191
|
i[0],
|
|
11063
11192
|
i[1],
|
|
@@ -11077,9 +11206,9 @@ function Mu(e, t, n) {
|
|
|
11077
11206
|
1
|
|
11078
11207
|
];
|
|
11079
11208
|
}
|
|
11080
|
-
function
|
|
11209
|
+
function zu(e) {
|
|
11081
11210
|
let t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8], u = e[9], d = e[10], f = e[11], p = e[12], m = e[13], h = e[14], g = e[15], _ = u * h * c - m * d * c + m * s * f - o * h * f - u * s * g + o * d * g, v = p * d * c - l * h * c - p * s * f + a * h * f + l * s * g - a * d * g, y = l * m * c - p * u * c + p * o * f - a * m * f - l * o * g + a * u * g, b = p * u * s - l * m * s - p * o * d + a * m * d + l * o * h - a * u * h, x = t * _ + n * v + r * y + i * b;
|
|
11082
|
-
if (x === 0) return
|
|
11211
|
+
if (x === 0) return Au();
|
|
11083
11212
|
let S = 1 / x;
|
|
11084
11213
|
return [
|
|
11085
11214
|
_ * S,
|
|
@@ -11102,7 +11231,7 @@ function Nu(e) {
|
|
|
11102
11231
|
}
|
|
11103
11232
|
//#endregion
|
|
11104
11233
|
//#region src/Processor/PBRT/PBRTParser.js
|
|
11105
|
-
var
|
|
11234
|
+
var Bu = class {
|
|
11106
11235
|
constructor(e = {}) {
|
|
11107
11236
|
this.resolveInclude = e.resolveInclude || (() => {
|
|
11108
11237
|
throw Error("PBRTParser: Include used but no resolveInclude provided");
|
|
@@ -11116,14 +11245,14 @@ var Pu = class {
|
|
|
11116
11245
|
instances: [],
|
|
11117
11246
|
objects: /* @__PURE__ */ new Map(),
|
|
11118
11247
|
warnings: []
|
|
11119
|
-
}, this.ctm =
|
|
11248
|
+
}, this.ctm = Au(), this.state = {
|
|
11120
11249
|
material: null,
|
|
11121
11250
|
areaLight: null,
|
|
11122
11251
|
reverseOrientation: !1
|
|
11123
11252
|
}, this.attributeStack = [], this.transformStack = [], this.coordSystems = /* @__PURE__ */ new Map(), this.currentObject = null, this.objectBeginCTM = null, this.dirStack = [""], this.tokens = [], this.pos = 0, this._warnedUnknown = /* @__PURE__ */ new Set();
|
|
11124
11253
|
}
|
|
11125
11254
|
parse(e, t = "") {
|
|
11126
|
-
return this.dirStack = [t], this._run(
|
|
11255
|
+
return this.dirStack = [t], this._run(ku(e)), this.ir;
|
|
11127
11256
|
}
|
|
11128
11257
|
_peek() {
|
|
11129
11258
|
return this.tokens[this.pos];
|
|
@@ -11133,12 +11262,12 @@ var Pu = class {
|
|
|
11133
11262
|
}
|
|
11134
11263
|
_expectNumber(e) {
|
|
11135
11264
|
let t = this._next();
|
|
11136
|
-
if (!t || t.type !==
|
|
11265
|
+
if (!t || t.type !== Tu.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
|
|
11137
11266
|
return t.value;
|
|
11138
11267
|
}
|
|
11139
11268
|
_expectString(e) {
|
|
11140
11269
|
let t = this._next();
|
|
11141
|
-
if (!t || t.type !==
|
|
11270
|
+
if (!t || t.type !== Tu.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
|
|
11142
11271
|
return t.value;
|
|
11143
11272
|
}
|
|
11144
11273
|
_readNumbers(e) {
|
|
@@ -11147,17 +11276,17 @@ var Pu = class {
|
|
|
11147
11276
|
return t;
|
|
11148
11277
|
}
|
|
11149
11278
|
_readBracketedOrBareNumbers(e) {
|
|
11150
|
-
if (this._peek() && this._peek().type ===
|
|
11279
|
+
if (this._peek() && this._peek().type === Tu.LBRACKET) {
|
|
11151
11280
|
this._next();
|
|
11152
11281
|
let e = [];
|
|
11153
|
-
for (; this._peek() && this._peek().type !==
|
|
11282
|
+
for (; this._peek() && this._peek().type !== Tu.RBRACKET;) e.push(this._expectNumber("transform element"));
|
|
11154
11283
|
return this._next(), e;
|
|
11155
11284
|
}
|
|
11156
11285
|
return this._readNumbers(e);
|
|
11157
11286
|
}
|
|
11158
11287
|
_parseParams() {
|
|
11159
11288
|
let e = {};
|
|
11160
|
-
for (; this._peek() && this._peek().type ===
|
|
11289
|
+
for (; this._peek() && this._peek().type === Tu.STRING;) {
|
|
11161
11290
|
let t = this._next().value.trim().split(/\s+/), n = t[0], r = t[1] === void 0 ? t[0] : t[1];
|
|
11162
11291
|
e[r] = {
|
|
11163
11292
|
type: n,
|
|
@@ -11168,23 +11297,23 @@ var Pu = class {
|
|
|
11168
11297
|
}
|
|
11169
11298
|
_parseParamValue() {
|
|
11170
11299
|
let e = [];
|
|
11171
|
-
if (this._peek() && this._peek().type ===
|
|
11172
|
-
for (this._next(); this._peek() && this._peek().type !==
|
|
11300
|
+
if (this._peek() && this._peek().type === Tu.LBRACKET) {
|
|
11301
|
+
for (this._next(); this._peek() && this._peek().type !== Tu.RBRACKET;) e.push(this._coerceValueToken(this._next()));
|
|
11173
11302
|
this._next();
|
|
11174
11303
|
} else e.push(this._coerceValueToken(this._next()));
|
|
11175
11304
|
return e;
|
|
11176
11305
|
}
|
|
11177
11306
|
_coerceValueToken(e) {
|
|
11178
11307
|
if (!e) throw Error("PBRT parser: unexpected EOF in parameter value");
|
|
11179
|
-
if (e.type ===
|
|
11180
|
-
if (e.type ===
|
|
11308
|
+
if (e.type === Tu.NUMBER || e.type === Tu.STRING) return e.value;
|
|
11309
|
+
if (e.type === Tu.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
|
|
11181
11310
|
throw Error(`PBRT parser: unexpected token in parameter value: ${e.type}`);
|
|
11182
11311
|
}
|
|
11183
11312
|
_run(e) {
|
|
11184
11313
|
let t = this.tokens, n = this.pos;
|
|
11185
11314
|
for (this.tokens = e, this.pos = 0; this.pos < this.tokens.length;) {
|
|
11186
11315
|
let e = this._next();
|
|
11187
|
-
if (e.type !==
|
|
11316
|
+
if (e.type !== Tu.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
|
|
11188
11317
|
this._directive(e.value);
|
|
11189
11318
|
}
|
|
11190
11319
|
this.tokens = t, this.pos = n;
|
|
@@ -11192,25 +11321,25 @@ var Pu = class {
|
|
|
11192
11321
|
_directive(e) {
|
|
11193
11322
|
switch (e) {
|
|
11194
11323
|
case "Identity":
|
|
11195
|
-
this.ctm =
|
|
11324
|
+
this.ctm = Au();
|
|
11196
11325
|
break;
|
|
11197
11326
|
case "Translate": {
|
|
11198
11327
|
let [e, t, n] = this._readNumbers(3);
|
|
11199
|
-
this.ctm =
|
|
11328
|
+
this.ctm = ju(this.ctm, Mu(e, t, n));
|
|
11200
11329
|
break;
|
|
11201
11330
|
}
|
|
11202
11331
|
case "Scale": {
|
|
11203
11332
|
let [e, t, n] = this._readNumbers(3);
|
|
11204
|
-
this.ctm =
|
|
11333
|
+
this.ctm = ju(this.ctm, Nu(e, t, n));
|
|
11205
11334
|
break;
|
|
11206
11335
|
}
|
|
11207
11336
|
case "Rotate": {
|
|
11208
11337
|
let [e, t, n, r] = this._readNumbers(4);
|
|
11209
|
-
this.ctm =
|
|
11338
|
+
this.ctm = ju(this.ctm, Pu(e, t, n, r));
|
|
11210
11339
|
break;
|
|
11211
11340
|
}
|
|
11212
11341
|
case "LookAt": {
|
|
11213
|
-
let e = this._readNumbers(9), t =
|
|
11342
|
+
let e = this._readNumbers(9), t = Ru([
|
|
11214
11343
|
e[0],
|
|
11215
11344
|
e[1],
|
|
11216
11345
|
e[2]
|
|
@@ -11223,7 +11352,7 @@ var Pu = class {
|
|
|
11223
11352
|
e[7],
|
|
11224
11353
|
e[8]
|
|
11225
11354
|
]);
|
|
11226
|
-
this.ctm =
|
|
11355
|
+
this.ctm = ju(this.ctm, zu(t));
|
|
11227
11356
|
break;
|
|
11228
11357
|
}
|
|
11229
11358
|
case "Transform":
|
|
@@ -11231,7 +11360,7 @@ var Pu = class {
|
|
|
11231
11360
|
break;
|
|
11232
11361
|
case "ConcatTransform": {
|
|
11233
11362
|
let e = this._readBracketedOrBareNumbers(16);
|
|
11234
|
-
this.ctm =
|
|
11363
|
+
this.ctm = ju(this.ctm, e);
|
|
11235
11364
|
break;
|
|
11236
11365
|
}
|
|
11237
11366
|
case "CoordinateSystem":
|
|
@@ -11247,7 +11376,7 @@ var Pu = class {
|
|
|
11247
11376
|
this.ir.camera = {
|
|
11248
11377
|
type: e,
|
|
11249
11378
|
params: t,
|
|
11250
|
-
cameraToWorld:
|
|
11379
|
+
cameraToWorld: zu(this.ctm)
|
|
11251
11380
|
};
|
|
11252
11381
|
break;
|
|
11253
11382
|
}
|
|
@@ -11271,7 +11400,7 @@ var Pu = class {
|
|
|
11271
11400
|
this._skipTypeAndParams();
|
|
11272
11401
|
break;
|
|
11273
11402
|
case "WorldBegin":
|
|
11274
|
-
this.ctm =
|
|
11403
|
+
this.ctm = Au(), this.state = {
|
|
11275
11404
|
material: null,
|
|
11276
11405
|
areaLight: null,
|
|
11277
11406
|
reverseOrientation: !1
|
|
@@ -11316,7 +11445,7 @@ var Pu = class {
|
|
|
11316
11445
|
this._readNumbers(2);
|
|
11317
11446
|
break;
|
|
11318
11447
|
case "MediumInterface":
|
|
11319
|
-
this._peek() && this._peek().type ===
|
|
11448
|
+
this._peek() && this._peek().type === Tu.STRING && this._next(), this._peek() && this._peek().type === Tu.STRING && this._next();
|
|
11320
11449
|
break;
|
|
11321
11450
|
case "MakeNamedMedium":
|
|
11322
11451
|
this._skipNamedAndParams();
|
|
@@ -11424,7 +11553,7 @@ var Pu = class {
|
|
|
11424
11553
|
}
|
|
11425
11554
|
}
|
|
11426
11555
|
_emitShape(e) {
|
|
11427
|
-
this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM =
|
|
11556
|
+
this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM = ju(zu(this.objectBeginCTM), e.ctm), this.ir.objects.get(this.currentObject).push(e));
|
|
11428
11557
|
}
|
|
11429
11558
|
_include(e) {
|
|
11430
11559
|
let t = this.resolveInclude(e, this.dirStack[this.dirStack.length - 1]);
|
|
@@ -11433,13 +11562,13 @@ var Pu = class {
|
|
|
11433
11562
|
return;
|
|
11434
11563
|
}
|
|
11435
11564
|
let n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
|
|
11436
|
-
this.dirStack.push(n), this._run(
|
|
11565
|
+
this.dirStack.push(n), this._run(ku(t)), this.dirStack.pop();
|
|
11437
11566
|
}
|
|
11438
11567
|
_skipTypeAndParams() {
|
|
11439
|
-
this._peek() && this._peek().type ===
|
|
11568
|
+
this._peek() && this._peek().type === Tu.STRING && this._next(), this._parseParams();
|
|
11440
11569
|
}
|
|
11441
11570
|
_skipNamedAndParams() {
|
|
11442
|
-
this._peek() && this._peek().type ===
|
|
11571
|
+
this._peek() && this._peek().type === Tu.STRING && this._next(), this._parseParams();
|
|
11443
11572
|
}
|
|
11444
11573
|
_num(e, t) {
|
|
11445
11574
|
return e && e.value.length ? e.value[0] : t;
|
|
@@ -11453,7 +11582,7 @@ var Pu = class {
|
|
|
11453
11582
|
_warnUnknown(e) {
|
|
11454
11583
|
this._warnedUnknown.has(e) || (this._warnedUnknown.add(e), this._warn(`Unsupported directive ignored: ${e}`));
|
|
11455
11584
|
}
|
|
11456
|
-
},
|
|
11585
|
+
}, Vu = {
|
|
11457
11586
|
au: [
|
|
11458
11587
|
1,
|
|
11459
11588
|
.78,
|
|
@@ -11509,12 +11638,12 @@ var Pu = class {
|
|
|
11509
11638
|
.9,
|
|
11510
11639
|
.9
|
|
11511
11640
|
]
|
|
11512
|
-
},
|
|
11641
|
+
}, Hu = [
|
|
11513
11642
|
.92,
|
|
11514
11643
|
.92,
|
|
11515
11644
|
.92
|
|
11516
11645
|
];
|
|
11517
|
-
function
|
|
11646
|
+
function Uu(e) {
|
|
11518
11647
|
let t = Math.max(1e3, Math.min(4e4, e)) / 100, n, r, i;
|
|
11519
11648
|
t <= 66 ? (n = 255, r = 99.47 * Math.log(t) - 161.12) : (n = 329.7 * (t - 60) ** -.1332, r = 288.12 * (t - 60) ** -.0755), i = t >= 66 ? 255 : t <= 19 ? 0 : 138.52 * Math.log(t - 10) - 305.04;
|
|
11520
11649
|
let a = (e) => Math.max(0, Math.min(255, e)) / 255;
|
|
@@ -11524,15 +11653,15 @@ function Lu(e) {
|
|
|
11524
11653
|
a(i) ** 2.2
|
|
11525
11654
|
];
|
|
11526
11655
|
}
|
|
11527
|
-
function
|
|
11656
|
+
function Wu(e, t, n) {
|
|
11528
11657
|
let r = e[t];
|
|
11529
11658
|
return r && typeof r.value[0] == "number" ? r.value[0] : n;
|
|
11530
11659
|
}
|
|
11531
|
-
function
|
|
11660
|
+
function Gu(e, t, n) {
|
|
11532
11661
|
let r = e[t];
|
|
11533
11662
|
return r && typeof r.value[0] == "string" ? r.value[0] : n;
|
|
11534
11663
|
}
|
|
11535
|
-
async function
|
|
11664
|
+
async function Ku(e, t, n, r = null) {
|
|
11536
11665
|
let i = e[t];
|
|
11537
11666
|
if (!i) return {
|
|
11538
11667
|
rgb: r,
|
|
@@ -11571,14 +11700,14 @@ async function Bu(e, t, n, r = null) {
|
|
|
11571
11700
|
};
|
|
11572
11701
|
}
|
|
11573
11702
|
if (i.type === "blackbody") return {
|
|
11574
|
-
rgb:
|
|
11703
|
+
rgb: Uu(i.value[0]),
|
|
11575
11704
|
texture: null
|
|
11576
11705
|
};
|
|
11577
11706
|
if (i.type === "spectrum") {
|
|
11578
11707
|
if (typeof i.value[0] == "string") {
|
|
11579
|
-
let e =
|
|
11580
|
-
return e &&
|
|
11581
|
-
rgb:
|
|
11708
|
+
let e = qu(i.value[0]);
|
|
11709
|
+
return e && Vu[e] ? {
|
|
11710
|
+
rgb: Vu[e].slice(),
|
|
11582
11711
|
texture: null
|
|
11583
11712
|
} : (n.warn(`named spectrum "${i.value[0]}" approximated to gray`), {
|
|
11584
11713
|
rgb: [
|
|
@@ -11606,18 +11735,18 @@ async function Bu(e, t, n, r = null) {
|
|
|
11606
11735
|
texture: null
|
|
11607
11736
|
};
|
|
11608
11737
|
}
|
|
11609
|
-
function
|
|
11738
|
+
function qu(e) {
|
|
11610
11739
|
let t = e.toLowerCase().match(/metal-([a-z]+)/);
|
|
11611
11740
|
if (t) return t[1];
|
|
11612
|
-
for (let t of Object.keys(
|
|
11741
|
+
for (let t of Object.keys(Vu)) if (e.toLowerCase().includes(t)) return t;
|
|
11613
11742
|
return null;
|
|
11614
11743
|
}
|
|
11615
|
-
function
|
|
11744
|
+
function Ju(e, t) {
|
|
11616
11745
|
if (e.roughness && typeof e.roughness.value[0] == "number") return e.roughness.value[0];
|
|
11617
|
-
let n =
|
|
11746
|
+
let n = Wu(e, "uroughness", null), r = Wu(e, "vroughness", null);
|
|
11618
11747
|
return n !== null && r !== null ? (n + r) / 2 : n === null ? t : n;
|
|
11619
11748
|
}
|
|
11620
|
-
async function
|
|
11749
|
+
async function Yu(e, t) {
|
|
11621
11750
|
let n = e?.type || "diffuse", r = e?.params || {}, i = new St({
|
|
11622
11751
|
side: it,
|
|
11623
11752
|
roughness: 1,
|
|
@@ -11629,7 +11758,7 @@ async function Uu(e, t) {
|
|
|
11629
11758
|
};
|
|
11630
11759
|
switch (n) {
|
|
11631
11760
|
case "diffuse":
|
|
11632
|
-
o(await
|
|
11761
|
+
o(await Ku(r, "reflectance", t, [
|
|
11633
11762
|
.5,
|
|
11634
11763
|
.5,
|
|
11635
11764
|
.5
|
|
@@ -11637,14 +11766,14 @@ async function Uu(e, t) {
|
|
|
11637
11766
|
break;
|
|
11638
11767
|
case "conductor":
|
|
11639
11768
|
case "metal": {
|
|
11640
|
-
let e = await
|
|
11769
|
+
let e = await Ku(r, "reflectance", t, null), n = r.eta, s = r.k, c = n && n.type === "spectrum" && typeof n.value[0] == "string";
|
|
11641
11770
|
if (e.rgb || e.texture) o(e);
|
|
11642
11771
|
else if (n && s && !c) {
|
|
11643
|
-
let e = (await
|
|
11772
|
+
let e = (await Ku(r, "eta", t, [
|
|
11644
11773
|
.2,
|
|
11645
11774
|
.92,
|
|
11646
11775
|
1.1
|
|
11647
|
-
])).rgb, n = (await
|
|
11776
|
+
])).rgb, n = (await Ku(r, "k", t, [
|
|
11648
11777
|
3.9,
|
|
11649
11778
|
2.45,
|
|
11650
11779
|
2.14
|
|
@@ -11654,28 +11783,28 @@ async function Uu(e, t) {
|
|
|
11654
11783
|
i(e[1], n[1]),
|
|
11655
11784
|
i(e[2], n[2])
|
|
11656
11785
|
]);
|
|
11657
|
-
} else a(n ? (await
|
|
11658
|
-
i.metalness = 1, i.roughness =
|
|
11786
|
+
} else a(n ? (await Ku(r, "eta", t, Hu)).rgb || Hu : Vu.cu);
|
|
11787
|
+
i.metalness = 1, i.roughness = Ju(r, .1);
|
|
11659
11788
|
break;
|
|
11660
11789
|
}
|
|
11661
11790
|
case "dielectric":
|
|
11662
11791
|
case "thindielectric":
|
|
11663
|
-
i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior =
|
|
11792
|
+
i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = Wu(r, "eta", 1.5), i.roughness = Ju(r, 0), i.thickness = n === "thindielectric" ? 0 : Wu(r, "thickness", 0);
|
|
11664
11793
|
break;
|
|
11665
11794
|
case "coateddiffuse":
|
|
11666
|
-
o(await
|
|
11795
|
+
o(await Ku(r, "reflectance", t, [
|
|
11667
11796
|
.5,
|
|
11668
11797
|
.5,
|
|
11669
11798
|
.5
|
|
11670
|
-
])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness =
|
|
11799
|
+
])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness = Ju(r, 0);
|
|
11671
11800
|
break;
|
|
11672
11801
|
case "diffusetransmission": {
|
|
11673
|
-
let e = await
|
|
11802
|
+
let e = await Ku(r, "transmittance", t, [
|
|
11674
11803
|
.25,
|
|
11675
11804
|
.25,
|
|
11676
11805
|
.25
|
|
11677
11806
|
]);
|
|
11678
|
-
o(await
|
|
11807
|
+
o(await Ku(r, "reflectance", t, [
|
|
11679
11808
|
.25,
|
|
11680
11809
|
.25,
|
|
11681
11810
|
.25
|
|
@@ -11688,9 +11817,9 @@ async function Uu(e, t) {
|
|
|
11688
11817
|
i.transmission = 1, i.ior = 1, i.roughness = 0, i.color.setRGB(1, 1, 1);
|
|
11689
11818
|
break;
|
|
11690
11819
|
case "mix": {
|
|
11691
|
-
let e = r.materials?.value || [], n = Math.max(0, Math.min(1,
|
|
11820
|
+
let e = r.materials?.value || [], n = Math.max(0, Math.min(1, Wu(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
|
|
11692
11821
|
if (a && o) {
|
|
11693
|
-
let [e, r] = await Promise.all([
|
|
11822
|
+
let [e, r] = await Promise.all([Yu(a, t), Yu(o, t)]), s = (e, t) => e * (1 - n) + t * n;
|
|
11694
11823
|
i.color.lerpColors(e.color, r.color, n), i.roughness = s(e.roughness, r.roughness), i.metalness = s(e.metalness, r.metalness), i.ior = s(e.ior ?? 1.5, r.ior ?? 1.5), i.transmission = s(e.transmission ?? 0, r.transmission ?? 0), i.thickness = s(e.thickness ?? 0, r.thickness ?? 0), i.clearcoat = s(e.clearcoat ?? 0, r.clearcoat ?? 0), i.clearcoatRoughness = s(e.clearcoatRoughness ?? 0, r.clearcoatRoughness ?? 0), i.emissive.lerpColors(e.emissive, r.emissive, n), i.emissiveIntensity = s(e.emissiveIntensity ?? 0, r.emissiveIntensity ?? 0), i.map = (n < .5 ? e.map : r.map) || null;
|
|
11695
11824
|
break;
|
|
11696
11825
|
}
|
|
@@ -11700,7 +11829,7 @@ async function Uu(e, t) {
|
|
|
11700
11829
|
case "subsurface":
|
|
11701
11830
|
case "hair":
|
|
11702
11831
|
case "measured":
|
|
11703
|
-
t.warn(`material "${n}" not supported — using diffuse approximation`), a((await
|
|
11832
|
+
t.warn(`material "${n}" not supported — using diffuse approximation`), a((await Ku(r, "reflectance", t, [
|
|
11704
11833
|
.5,
|
|
11705
11834
|
.5,
|
|
11706
11835
|
.5
|
|
@@ -11714,7 +11843,7 @@ async function Uu(e, t) {
|
|
|
11714
11843
|
}
|
|
11715
11844
|
//#endregion
|
|
11716
11845
|
//#region src/Processor/PBRT/PBRTSceneBuilder.js
|
|
11717
|
-
var
|
|
11846
|
+
var Xu = [
|
|
11718
11847
|
1,
|
|
11719
11848
|
0,
|
|
11720
11849
|
0,
|
|
@@ -11731,7 +11860,7 @@ var Wu = [
|
|
|
11731
11860
|
0,
|
|
11732
11861
|
0,
|
|
11733
11862
|
1
|
|
11734
|
-
],
|
|
11863
|
+
], Zu = class {
|
|
11735
11864
|
constructor(e = {}) {
|
|
11736
11865
|
this.resolvePLY = e.resolvePLY || (async () => null), this.resolveImage = e.resolveImage || (async () => null), this.resolveEnvironment = e.resolveEnvironment || e.resolveImage || (async () => null), this.convertHandedness = e.convertHandedness === !0, this.warnings = [], this.report = [], this._materialCache = /* @__PURE__ */ new Map(), this._textureCache = /* @__PURE__ */ new Map();
|
|
11737
11866
|
}
|
|
@@ -11767,7 +11896,7 @@ var Wu = [
|
|
|
11767
11896
|
continue;
|
|
11768
11897
|
}
|
|
11769
11898
|
for (let e of i) {
|
|
11770
|
-
let i =
|
|
11899
|
+
let i = ju(r.ctm, e.relativeCTM || e.ctm), a = await this._buildShapeMesh(e, i, `instance_${n++}`);
|
|
11771
11900
|
a && t.add(a);
|
|
11772
11901
|
}
|
|
11773
11902
|
}
|
|
@@ -11779,7 +11908,7 @@ var Wu = [
|
|
|
11779
11908
|
i.map && !a && (this.warn(`${n} (${e.type}, "${e.material?.type || "diffuse"}") has a texture map but no UVs — dropping map, using base color`), o = i.clone(), o.map = null);
|
|
11780
11909
|
let s = new bt(r, o);
|
|
11781
11910
|
s.name = n;
|
|
11782
|
-
let c = this.convertHandedness ?
|
|
11911
|
+
let c = this.convertHandedness ? ju(Xu, t) : t;
|
|
11783
11912
|
new yt().fromArray(c).decompose(s.position, s.quaternion, s.scale), s.updateMatrix(), r.computeBoundingBox();
|
|
11784
11913
|
let l = r.boundingBox ? r.boundingBox.clone().applyMatrix4(s.matrix).getSize(new nn()) : new nn();
|
|
11785
11914
|
return this.report.push({
|
|
@@ -11834,7 +11963,7 @@ var Wu = [
|
|
|
11834
11963
|
return i.setAttribute("position", new ot(Float32Array.from(t), 3)), i.setIndex(r), i.computeVertexNormals(), i;
|
|
11835
11964
|
}
|
|
11836
11965
|
async _plyMesh(e) {
|
|
11837
|
-
let t =
|
|
11966
|
+
let t = Gu(e, "filename", null);
|
|
11838
11967
|
if (!t) return this.warn("plymesh missing filename"), null;
|
|
11839
11968
|
try {
|
|
11840
11969
|
let e = await this.resolvePLY(t);
|
|
@@ -11844,10 +11973,10 @@ var Wu = [
|
|
|
11844
11973
|
}
|
|
11845
11974
|
}
|
|
11846
11975
|
_sphere(e) {
|
|
11847
|
-
return new Kt(
|
|
11976
|
+
return new Kt(Wu(e, "radius", 1), 48, 32);
|
|
11848
11977
|
}
|
|
11849
11978
|
_disk(e) {
|
|
11850
|
-
let t =
|
|
11979
|
+
let t = Wu(e, "radius", 1), n = Wu(e, "innerradius", 0), r = Wu(e, "height", 0), i = [], a = [];
|
|
11851
11980
|
for (let e = 0; e < 48; e++) {
|
|
11852
11981
|
let o = e / 48 * Math.PI * 2, s = (e + 1) / 48 * Math.PI * 2, c = i.length / 3;
|
|
11853
11982
|
i.push(Math.cos(o) * n, Math.sin(o) * n, r), i.push(Math.cos(o) * t, Math.sin(o) * t, r), i.push(Math.cos(s) * t, Math.sin(s) * t, r), i.push(Math.cos(s) * n, Math.sin(s) * n, r), a.push(c, c + 1, c + 2, c, c + 2, c + 3);
|
|
@@ -11862,15 +11991,15 @@ var Wu = [
|
|
|
11862
11991
|
resolveNamedTexture: (e) => this._resolveNamedTexture(e),
|
|
11863
11992
|
namedMaterials: this.ir.namedMaterials,
|
|
11864
11993
|
warn: (e) => this.warn(e)
|
|
11865
|
-
}, r = await
|
|
11994
|
+
}, r = await Yu(e.material, n);
|
|
11866
11995
|
return e.areaLight && await this._applyAreaLight(r, e.areaLight, n), t.set(e.areaLight, r), r;
|
|
11867
11996
|
}
|
|
11868
11997
|
async _applyAreaLight(e, t, n) {
|
|
11869
|
-
let r = await
|
|
11998
|
+
let r = await Ku(t.params, "L", n, [
|
|
11870
11999
|
1,
|
|
11871
12000
|
1,
|
|
11872
12001
|
1
|
|
11873
|
-
]), i =
|
|
12002
|
+
]), i = Wu(t.params, "scale", 1), a = r.rgb || [
|
|
11874
12003
|
1,
|
|
11875
12004
|
1,
|
|
11876
12005
|
1
|
|
@@ -11882,7 +12011,7 @@ var Wu = [
|
|
|
11882
12011
|
let t = this.ir.namedTextures.get(e), n = null;
|
|
11883
12012
|
if (!t) this.warn(`named texture "${e}" not defined`);
|
|
11884
12013
|
else if (t.class === "imagemap") {
|
|
11885
|
-
let r =
|
|
12014
|
+
let r = Gu(t.params, "filename", null);
|
|
11886
12015
|
if (r) try {
|
|
11887
12016
|
let t = await this.resolveImage(r);
|
|
11888
12017
|
t ? n = { texture: t } : this.warn(`image not found for texture "${e}": ${r}`);
|
|
@@ -11970,7 +12099,7 @@ var Wu = [
|
|
|
11970
12099
|
return c.name = "PBRT Camera", c.up.copy(a.normalize()), c.position.copy(r), c.lookAt(o), c.updateMatrixWorld(!0), c;
|
|
11971
12100
|
}
|
|
11972
12101
|
_verticalFov(e, t) {
|
|
11973
|
-
let n =
|
|
12102
|
+
let n = Wu(e, "fov", 90);
|
|
11974
12103
|
if (t >= 1) return n;
|
|
11975
12104
|
let r = n * Math.PI / 180;
|
|
11976
12105
|
return 2 * Math.atan(Math.tan(r / 2) / t) * 180 / Math.PI;
|
|
@@ -11978,15 +12107,15 @@ var Wu = [
|
|
|
11978
12107
|
async _buildEnvironment(e) {
|
|
11979
12108
|
let t = e.find((e) => e.type === "infinite");
|
|
11980
12109
|
if (!t) return null;
|
|
11981
|
-
let n =
|
|
12110
|
+
let n = Wu(t.params, "scale", 1), r = Gu(t.params, "filename", null);
|
|
11982
12111
|
if (r) try {
|
|
11983
12112
|
let e = await this.resolveEnvironment(r);
|
|
11984
|
-
if (e) return e.mapping =
|
|
12113
|
+
if (e) return e.mapping = at, { texture: e };
|
|
11985
12114
|
this.warn(`infinite-light image not found: ${r}`);
|
|
11986
12115
|
} catch (e) {
|
|
11987
12116
|
this.warn(`failed to load infinite-light image ${r}: ${e.message}`);
|
|
11988
12117
|
}
|
|
11989
|
-
let i = ((await
|
|
12118
|
+
let i = ((await Ku(t.params, "L", {
|
|
11990
12119
|
resolveNamedTexture: async () => null,
|
|
11991
12120
|
warn: (e) => this.warn(e)
|
|
11992
12121
|
}, [
|
|
@@ -12000,25 +12129,25 @@ var Wu = [
|
|
|
12000
12129
|
]).map((e) => e * n), a = new Float32Array(8);
|
|
12001
12130
|
for (let e = 0; e < 2; e++) a[e * 4 + 0] = i[0], a[e * 4 + 1] = i[1], a[e * 4 + 2] = i[2], a[e * 4 + 3] = 1;
|
|
12002
12131
|
let o = new et(a, 2, 1, Ft, st);
|
|
12003
|
-
return o.mapping =
|
|
12132
|
+
return o.mapping = at, o.minFilter = J, o.magFilter = J, o.needsUpdate = !0, { texture: o };
|
|
12004
12133
|
}
|
|
12005
12134
|
_reportUnsupportedLights(e) {
|
|
12006
12135
|
for (let t of e) t.type !== "infinite" && this.warn(`light "${t.type}" not supported (only infinite lights and emissive area lights are mapped)`);
|
|
12007
12136
|
}
|
|
12008
|
-
},
|
|
12009
|
-
function
|
|
12137
|
+
}, Qu = new TextDecoder();
|
|
12138
|
+
function $u(e) {
|
|
12010
12139
|
let t = e.replace(/\\/g, "/").split("/"), n = [];
|
|
12011
12140
|
for (let e of t) e === "" || e === "." || (e === ".." ? n.pop() : n.push(e));
|
|
12012
12141
|
return n.join("/");
|
|
12013
12142
|
}
|
|
12014
|
-
function
|
|
12015
|
-
return !e || t.startsWith("/") ?
|
|
12143
|
+
function ed(e, t) {
|
|
12144
|
+
return !e || t.startsWith("/") ? $u(t) : $u(`${e}/${t}`);
|
|
12016
12145
|
}
|
|
12017
|
-
var
|
|
12146
|
+
var td = class {
|
|
12018
12147
|
constructor(e) {
|
|
12019
12148
|
this.byPath = /* @__PURE__ */ new Map(), this.byBase = /* @__PURE__ */ new Map();
|
|
12020
12149
|
for (let t in e) {
|
|
12021
|
-
let n =
|
|
12150
|
+
let n = $u(t).toLowerCase(), r = {
|
|
12022
12151
|
norm: n,
|
|
12023
12152
|
bytes: e[t]
|
|
12024
12153
|
};
|
|
@@ -12028,13 +12157,13 @@ var Yu = class {
|
|
|
12028
12157
|
}
|
|
12029
12158
|
}
|
|
12030
12159
|
find(e) {
|
|
12031
|
-
let t =
|
|
12160
|
+
let t = $u(e).toLowerCase();
|
|
12032
12161
|
if (this.byPath.has(t)) return this.byPath.get(t).bytes;
|
|
12033
12162
|
let n = this.byBase.get(t.split("/").pop());
|
|
12034
12163
|
return n ? (n.find((e) => e.norm.endsWith("/" + t)) || n[0]).bytes : null;
|
|
12035
12164
|
}
|
|
12036
12165
|
};
|
|
12037
|
-
function
|
|
12166
|
+
function nd(e) {
|
|
12038
12167
|
let t = Object.keys(e).filter((e) => e.toLowerCase().endsWith(".pbrt"));
|
|
12039
12168
|
if (t.length === 0) return null;
|
|
12040
12169
|
let n = t.filter((e) => /(^|\/)(scene|main)\.pbrt$/i.test(e)), r = n.length ? n : t;
|
|
@@ -12043,17 +12172,17 @@ function Xu(e) {
|
|
|
12043
12172
|
return n === r ? e.length - t.length : n - r;
|
|
12044
12173
|
}), r[0];
|
|
12045
12174
|
}
|
|
12046
|
-
async function
|
|
12047
|
-
let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new
|
|
12175
|
+
async function rd(e) {
|
|
12176
|
+
let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new td(t), s = e.entryPath || nd(t);
|
|
12048
12177
|
if (!s) throw Error("PBRT loader: no .pbrt file found in archive");
|
|
12049
12178
|
let c = o.find(s);
|
|
12050
12179
|
if (!c) throw Error(`PBRT loader: entry "${s}" not readable`);
|
|
12051
|
-
let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new
|
|
12052
|
-
let n = o.find(
|
|
12053
|
-
return n ?
|
|
12054
|
-
} }).parse(
|
|
12180
|
+
let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new Bu({ resolveInclude: (e, t) => {
|
|
12181
|
+
let n = o.find(ed(t, e)) || o.find(e);
|
|
12182
|
+
return n ? Qu.decode(n) : null;
|
|
12183
|
+
} }).parse(Qu.decode(c), l), d = (e) => e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
|
|
12055
12184
|
return {
|
|
12056
|
-
...await new
|
|
12185
|
+
...await new Zu({
|
|
12057
12186
|
convertHandedness: a,
|
|
12058
12187
|
resolvePLY: async (e) => {
|
|
12059
12188
|
let t = o.find(e);
|
|
@@ -12073,7 +12202,7 @@ async function Zu(e) {
|
|
|
12073
12202
|
}
|
|
12074
12203
|
//#endregion
|
|
12075
12204
|
//#region src/Processor/AssetLoader.js
|
|
12076
|
-
var
|
|
12205
|
+
var id = {
|
|
12077
12206
|
glb: {
|
|
12078
12207
|
type: "model",
|
|
12079
12208
|
name: "GLB (GLTF Binary)"
|
|
@@ -12138,7 +12267,7 @@ var Qu = {
|
|
|
12138
12267
|
type: "archive",
|
|
12139
12268
|
name: "ZIP Archive"
|
|
12140
12269
|
}
|
|
12141
|
-
},
|
|
12270
|
+
}, ad = class extends q {
|
|
12142
12271
|
constructor(e, t, n) {
|
|
12143
12272
|
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;
|
|
12144
12273
|
}
|
|
@@ -12149,7 +12278,7 @@ var Qu = {
|
|
|
12149
12278
|
this.renderer = e;
|
|
12150
12279
|
}
|
|
12151
12280
|
getFileFormat(e) {
|
|
12152
|
-
return
|
|
12281
|
+
return id[e.split(".").pop().toLowerCase()] || null;
|
|
12153
12282
|
}
|
|
12154
12283
|
readFileAsArrayBuffer(e) {
|
|
12155
12284
|
return new Promise((t, n) => {
|
|
@@ -12275,7 +12404,7 @@ var Qu = {
|
|
|
12275
12404
|
}
|
|
12276
12405
|
async loadEnvironmentByExtension(e, t) {
|
|
12277
12406
|
let n;
|
|
12278
|
-
return t === "hdr" || t === "exr" ? n = await (t === "hdr" ? this.loaderCache.hdr || (this.loaderCache.hdr = new sn().setDataType(st)) : this.loaderCache.exr || (this.loaderCache.exr = new un().setDataType(st))).loadAsync(e) : (this.loaderCache.texture || (this.loaderCache.texture = new Xt()), n = await this.loaderCache.texture.loadAsync(e)), n.mapping =
|
|
12407
|
+
return t === "hdr" || t === "exr" ? n = await (t === "hdr" ? this.loaderCache.hdr || (this.loaderCache.hdr = new sn().setDataType(st)) : this.loaderCache.exr || (this.loaderCache.exr = new un().setDataType(st))).loadAsync(e) : (this.loaderCache.texture || (this.loaderCache.texture = new Xt()), n = await this.loaderCache.texture.loadAsync(e)), n.mapping = at, n.minFilter = J, n.magFilter = J, n;
|
|
12279
12408
|
}
|
|
12280
12409
|
applyEnvironmentToScene(e) {
|
|
12281
12410
|
this.scene.background = e, this.scene.environment = e;
|
|
@@ -12283,7 +12412,7 @@ var Qu = {
|
|
|
12283
12412
|
async loadArchiveFromFile(e, t) {
|
|
12284
12413
|
try {
|
|
12285
12414
|
let n = await this.readFileAsArrayBuffer(e), r = mn(new Uint8Array(n));
|
|
12286
|
-
return
|
|
12415
|
+
return nd(r) ? await this.loadPBRTFromZip(r, t) : await this.processObjMtlPairsInZip(r, t) || await this.findAndLoadModelFromZip(r, t);
|
|
12287
12416
|
} catch (e) {
|
|
12288
12417
|
throw console.error("Error loading ZIP archive:", e), e;
|
|
12289
12418
|
}
|
|
@@ -12297,7 +12426,7 @@ var Qu = {
|
|
|
12297
12426
|
let { PLYLoader: e } = await import("three/examples/jsm/loaders/PLYLoader.js");
|
|
12298
12427
|
this.loaderCache.ply = new e();
|
|
12299
12428
|
}
|
|
12300
|
-
let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await
|
|
12429
|
+
let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await rd({
|
|
12301
12430
|
vfs: e,
|
|
12302
12431
|
plyParser: (e) => this.loaderCache.ply.parse(e),
|
|
12303
12432
|
imageFromBytes: (e, t) => this._pbrtTextureFromBytes(e, t),
|
|
@@ -12396,7 +12525,7 @@ var Qu = {
|
|
|
12396
12525
|
}
|
|
12397
12526
|
for (let t in e) {
|
|
12398
12527
|
let n = t.split(".").pop().toLowerCase();
|
|
12399
|
-
if (
|
|
12528
|
+
if (id[n] && id[n].type === "model") return console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e);
|
|
12400
12529
|
}
|
|
12401
12530
|
throw Error("No supported model files found in the ZIP archive");
|
|
12402
12531
|
}
|
|
@@ -12554,7 +12683,7 @@ var Qu = {
|
|
|
12554
12683
|
return null;
|
|
12555
12684
|
}
|
|
12556
12685
|
async createGLTFLoader() {
|
|
12557
|
-
let { dracoDecoderPath: e, ktx2TranscoderPath: t } =
|
|
12686
|
+
let { dracoDecoderPath: e, ktx2TranscoderPath: t } = bs(), n = new cn();
|
|
12558
12687
|
n.setDecoderConfig({ type: "js" }), n.setDecoderPath(e);
|
|
12559
12688
|
let r = new ln();
|
|
12560
12689
|
r.setTranscoderPath(t), this.renderer && (r.detectSupport(this.renderer), r.workerConfig = {
|
|
@@ -12843,7 +12972,7 @@ var Qu = {
|
|
|
12843
12972
|
}), e;
|
|
12844
12973
|
}
|
|
12845
12974
|
async onModelLoad(e) {
|
|
12846
|
-
let t = new
|
|
12975
|
+
let t = new ms("onModelLoad");
|
|
12847
12976
|
t.start("Camera extraction");
|
|
12848
12977
|
let n = this.extractCamerasFromModel(e);
|
|
12849
12978
|
t.end("Camera extraction"), t.start("Camera setup");
|
|
@@ -12922,10 +13051,10 @@ var Qu = {
|
|
|
12922
13051
|
getSupportedFormats(e = null) {
|
|
12923
13052
|
if (e) {
|
|
12924
13053
|
let t = {};
|
|
12925
|
-
for (let [n, r] of Object.entries(
|
|
13054
|
+
for (let [n, r] of Object.entries(id)) r.type === e && (t[n] = r);
|
|
12926
13055
|
return t;
|
|
12927
13056
|
}
|
|
12928
|
-
return
|
|
13057
|
+
return id;
|
|
12929
13058
|
}
|
|
12930
13059
|
dispose() {
|
|
12931
13060
|
for (let e in this.loaderCache) {
|
|
@@ -12937,7 +13066,7 @@ var Qu = {
|
|
|
12937
13066
|
removeAllEventListeners() {
|
|
12938
13067
|
this._listeners = void 0;
|
|
12939
13068
|
}
|
|
12940
|
-
},
|
|
13069
|
+
}, od = {
|
|
12941
13070
|
maxBounces: {
|
|
12942
13071
|
uniform: "maxBounces",
|
|
12943
13072
|
reset: !0
|
|
@@ -13056,10 +13185,10 @@ var Qu = {
|
|
|
13056
13185
|
},
|
|
13057
13186
|
renderMode: { handler: "handleRenderMode" },
|
|
13058
13187
|
environmentRotation: { handler: "handleEnvironmentRotation" }
|
|
13059
|
-
},
|
|
13188
|
+
}, sd = {
|
|
13060
13189
|
bounces: "maxBounces",
|
|
13061
13190
|
debugMode: "visMode"
|
|
13062
|
-
},
|
|
13191
|
+
}, cd = class extends q {
|
|
13063
13192
|
constructor(e = X) {
|
|
13064
13193
|
super(), this._values = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._delegates = {}, this._initDefaults(e);
|
|
13065
13194
|
}
|
|
@@ -13101,7 +13230,7 @@ var Qu = {
|
|
|
13101
13230
|
let i = this._values.get(e);
|
|
13102
13231
|
if (i === t) return;
|
|
13103
13232
|
this._values.set(e, t);
|
|
13104
|
-
let a =
|
|
13233
|
+
let a = od[e];
|
|
13105
13234
|
a && (this._applyRoute(a, t, i), (n === void 0 ? a.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
13106
13235
|
type: Yn.SETTING_CHANGED,
|
|
13107
13236
|
key: e,
|
|
@@ -13115,7 +13244,7 @@ var Qu = {
|
|
|
13115
13244
|
let e = this._values.get(r);
|
|
13116
13245
|
if (e === i) continue;
|
|
13117
13246
|
this._values.set(r, i);
|
|
13118
|
-
let a =
|
|
13247
|
+
let a = od[r];
|
|
13119
13248
|
a && (this._applyRoute(a, i, e), (a.reset ?? !0) && (n = !0), t || this.dispatchEvent({
|
|
13120
13249
|
type: Yn.SETTING_CHANGED,
|
|
13121
13250
|
key: r,
|
|
@@ -13133,7 +13262,7 @@ var Qu = {
|
|
|
13133
13262
|
}
|
|
13134
13263
|
applyAll() {
|
|
13135
13264
|
for (let [e, t] of this._values) {
|
|
13136
|
-
let n =
|
|
13265
|
+
let n = od[e];
|
|
13137
13266
|
n && this._applyRoute(n, t, void 0);
|
|
13138
13267
|
}
|
|
13139
13268
|
}
|
|
@@ -13141,10 +13270,10 @@ var Qu = {
|
|
|
13141
13270
|
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);
|
|
13142
13271
|
}
|
|
13143
13272
|
_initDefaults(e) {
|
|
13144
|
-
for (let t of Object.keys(
|
|
13145
|
-
for (let [t, n] of Object.entries(
|
|
13273
|
+
for (let t of Object.keys(od)) t in e && this._values.set(t, e[t]);
|
|
13274
|
+
for (let [t, n] of Object.entries(sd)) t in e && this._values.set(n, e[t]);
|
|
13146
13275
|
}
|
|
13147
|
-
},
|
|
13276
|
+
}, ld = class extends q {
|
|
13148
13277
|
constructor(e) {
|
|
13149
13278
|
super();
|
|
13150
13279
|
let t = e.clientWidth, n = e.clientHeight;
|
|
@@ -13265,7 +13394,7 @@ var Qu = {
|
|
|
13265
13394
|
dispose() {
|
|
13266
13395
|
this.controls?.dispose();
|
|
13267
13396
|
}
|
|
13268
|
-
},
|
|
13397
|
+
}, ud = class extends q {
|
|
13269
13398
|
constructor(e, t, n, r = {}) {
|
|
13270
13399
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null;
|
|
13271
13400
|
}
|
|
@@ -13418,14 +13547,14 @@ var Qu = {
|
|
|
13418
13547
|
], n.distance = e.distance ?? 0, n.penumbra = e.penumbra ?? 0, n.decay = e.decay ?? 2) : e.type === "PointLight" && (n.distance = e.distance ?? 0, n.decay = e.decay ?? 2);
|
|
13419
13548
|
return (e.type === "SpotLight" || e.type === "DirectionalLight") && e.userData?.gobo && (n.gobo = e.userData.gobo.name, n.goboIntensity = e.userData.gobo.intensity, n.goboInverted = !!e.userData.gobo.inverted, e.type === "DirectionalLight" && (n.goboScale = e.userData.gobo.scale ?? 5)), e.type === "SpotLight" && e.userData?.ies && (n.ies = e.userData.ies.name, n.iesIntensity = e.userData.ies.intensity ?? 1, n.fixtureLumens = e.userData.ies.fixtureLumens ?? null), n;
|
|
13420
13549
|
}
|
|
13421
|
-
},
|
|
13550
|
+
}, dd = class {
|
|
13422
13551
|
constructor(e, t = {}) {
|
|
13423
13552
|
this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._size = 256;
|
|
13424
13553
|
}
|
|
13425
13554
|
async loadLibrary(e, { size: t = 256 } = {}) {
|
|
13426
13555
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
13427
13556
|
this._size = t;
|
|
13428
|
-
let n = await Promise.all(e.map((e) =>
|
|
13557
|
+
let n = await Promise.all(e.map((e) => fd(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
|
|
13429
13558
|
s.width = r, s.height = i;
|
|
13430
13559
|
let c = s.getContext("2d", { willReadFrequently: !0 });
|
|
13431
13560
|
for (let e = 0; e < a; e++) {
|
|
@@ -13454,7 +13583,7 @@ var Qu = {
|
|
|
13454
13583
|
o.userData.gobo = {
|
|
13455
13584
|
name: e.name,
|
|
13456
13585
|
index: e.index,
|
|
13457
|
-
intensity:
|
|
13586
|
+
intensity: pd(r),
|
|
13458
13587
|
inverted: !!i,
|
|
13459
13588
|
scale: Math.max(1e-4, a)
|
|
13460
13589
|
};
|
|
@@ -13496,28 +13625,28 @@ var Qu = {
|
|
|
13496
13625
|
return t && t.isSpotLight ? t : null;
|
|
13497
13626
|
}
|
|
13498
13627
|
};
|
|
13499
|
-
function
|
|
13628
|
+
function fd(e) {
|
|
13500
13629
|
return new Promise((t, n) => {
|
|
13501
13630
|
let r = new Image();
|
|
13502
13631
|
r.crossOrigin = "anonymous", r.onload = () => t(r), r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load gobo image: ${e}`)), r.src = e;
|
|
13503
13632
|
});
|
|
13504
13633
|
}
|
|
13505
|
-
function
|
|
13634
|
+
function pd(e) {
|
|
13506
13635
|
return Math.max(0, Math.min(1, e));
|
|
13507
13636
|
}
|
|
13508
13637
|
//#endregion
|
|
13509
13638
|
//#region src/Processor/IESParser.js
|
|
13510
|
-
function
|
|
13639
|
+
function md(e, t = "ies") {
|
|
13511
13640
|
let n = e.search(/TILT\s*=/i);
|
|
13512
13641
|
if (n < 0) throw Error(`IES (${t}): missing TILT line`);
|
|
13513
13642
|
let r = e.indexOf("\n", n);
|
|
13514
13643
|
if (r < 0) throw Error(`IES (${t}): truncated TILT line`);
|
|
13515
13644
|
let i = e.slice(n, r).match(/TILT\s*=\s*(\w+)/i), a = i ? i[1].toUpperCase() : "NONE", o = e.slice(r);
|
|
13516
13645
|
if (a === "INCLUDE") {
|
|
13517
|
-
let e =
|
|
13518
|
-
o =
|
|
13646
|
+
let e = vd(o), t = 2 + 2 * Number(e[1]);
|
|
13647
|
+
o = yd(o, t);
|
|
13519
13648
|
}
|
|
13520
|
-
let s =
|
|
13649
|
+
let s = vd(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
|
|
13521
13650
|
l(), l(), l(), l();
|
|
13522
13651
|
let g = l();
|
|
13523
13652
|
if (l(), l(), !Number.isFinite(p) || p <= 0) throw Error(`IES (${t}): invalid vertical angle count ${p}`);
|
|
@@ -13543,18 +13672,18 @@ function cd(e, t = "ies") {
|
|
|
13543
13672
|
name: t
|
|
13544
13673
|
};
|
|
13545
13674
|
}
|
|
13546
|
-
function
|
|
13675
|
+
function hd(e, t, n) {
|
|
13547
13676
|
let r = new Uint8Array(t * n), { verticalAngles: i, horizontalAngles: a, candela: o, maxCandela: s } = e;
|
|
13548
13677
|
if (s <= 0) return r;
|
|
13549
13678
|
let c = i[i.length - 1], l = a[a.length - 1], u = a[0], d = a.length === 1 || l === u;
|
|
13550
13679
|
for (let e = 0; e < n; e++) {
|
|
13551
|
-
let f = (e + .5) / n * c, p =
|
|
13680
|
+
let f = (e + .5) / n * c, p = bd(i, f), m = Math.min(p + 1, i.length - 1), h = i[m] - i[p], g = h > 0 ? (f - i[p]) / h : 0;
|
|
13552
13681
|
for (let n = 0; n < t; n++) {
|
|
13553
13682
|
let i;
|
|
13554
|
-
if (d) i =
|
|
13683
|
+
if (d) i = xd(o[p][0], o[m][0], g);
|
|
13555
13684
|
else {
|
|
13556
|
-
let e = u + (n + .5) / t * (l - u), r =
|
|
13557
|
-
i =
|
|
13685
|
+
let e = u + (n + .5) / t * (l - u), r = bd(a, e), s = Math.min(r + 1, a.length - 1), c = a[s] - a[r], d = c > 0 ? (e - a[r]) / c : 0, f = o[p][r], h = o[p][s], _ = o[m][r], v = o[m][s];
|
|
13686
|
+
i = xd(xd(f, h, d), xd(_, v, d), g);
|
|
13558
13687
|
}
|
|
13559
13688
|
let c = Math.min(1, Math.max(0, i / s));
|
|
13560
13689
|
r[e * t + n] = Math.round(c * 255);
|
|
@@ -13562,7 +13691,7 @@ function ld(e, t, n) {
|
|
|
13562
13691
|
}
|
|
13563
13692
|
return r;
|
|
13564
13693
|
}
|
|
13565
|
-
function
|
|
13694
|
+
function gd(e, t = .1) {
|
|
13566
13695
|
let { verticalAngles: n, horizontalAngles: r, candela: i, maxCandela: a } = e, o = Math.PI / 4;
|
|
13567
13696
|
if (a <= 0 || !n?.length) return o;
|
|
13568
13697
|
let s = a * t, c = r.length, l = n[n.length - 1], u = !1;
|
|
@@ -13577,7 +13706,7 @@ function ud(e, t = .1) {
|
|
|
13577
13706
|
let d = l * Math.PI / 180;
|
|
13578
13707
|
return Math.min(Math.max(d, 5 * Math.PI / 180), 89 * Math.PI / 180);
|
|
13579
13708
|
}
|
|
13580
|
-
function
|
|
13709
|
+
function _d(e, t, n = .7) {
|
|
13581
13710
|
let { verticalAngles: r, horizontalAngles: i, candela: a, maxCandela: o } = e;
|
|
13582
13711
|
if (o <= 0 || !r?.length || t <= 0) return 0;
|
|
13583
13712
|
let s = o * n, c = i.length, l = 0;
|
|
@@ -13590,15 +13719,15 @@ function dd(e, t, n = .7) {
|
|
|
13590
13719
|
let u = t * 180 / Math.PI, d = u > 0 ? 1 - l / u : 0;
|
|
13591
13720
|
return Math.min(Math.max(d, 0), 1);
|
|
13592
13721
|
}
|
|
13593
|
-
function
|
|
13722
|
+
function vd(e) {
|
|
13594
13723
|
return e.split(/\s+/).filter((e) => e.length > 0);
|
|
13595
13724
|
}
|
|
13596
|
-
function
|
|
13725
|
+
function yd(e, t) {
|
|
13597
13726
|
let n = /\S+/g, r = 0;
|
|
13598
13727
|
for (; n.exec(e) !== null;) if (r++, r === t) return e.slice(n.lastIndex);
|
|
13599
13728
|
return "";
|
|
13600
13729
|
}
|
|
13601
|
-
function
|
|
13730
|
+
function bd(e, t) {
|
|
13602
13731
|
if (t <= e[0]) return 0;
|
|
13603
13732
|
if (t >= e[e.length - 1]) return e.length - 1;
|
|
13604
13733
|
let n = 0, r = e.length - 1;
|
|
@@ -13608,12 +13737,12 @@ function md(e, t) {
|
|
|
13608
13737
|
}
|
|
13609
13738
|
return n;
|
|
13610
13739
|
}
|
|
13611
|
-
function
|
|
13740
|
+
function xd(e, t, n) {
|
|
13612
13741
|
return e + (t - e) * n;
|
|
13613
13742
|
}
|
|
13614
13743
|
//#endregion
|
|
13615
13744
|
//#region src/managers/IESManager.js
|
|
13616
|
-
var
|
|
13745
|
+
var Sd = class {
|
|
13617
13746
|
constructor(e, t = {}) {
|
|
13618
13747
|
this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._gridWidth = 128, this._gridHeight = 128;
|
|
13619
13748
|
}
|
|
@@ -13624,11 +13753,11 @@ var gd = class {
|
|
|
13624
13753
|
try {
|
|
13625
13754
|
let r = await fetch(e.url);
|
|
13626
13755
|
if (!r.ok) throw Error(`HTTP ${r.status}`);
|
|
13627
|
-
let i =
|
|
13756
|
+
let i = md(await r.text(), e.name);
|
|
13628
13757
|
return {
|
|
13629
13758
|
it: e,
|
|
13630
13759
|
profile: i,
|
|
13631
|
-
grid:
|
|
13760
|
+
grid: hd(i, t, n)
|
|
13632
13761
|
};
|
|
13633
13762
|
} catch (t) {
|
|
13634
13763
|
return console.warn(`IESManager: failed to load "${e.name}": ${t.message}`), null;
|
|
@@ -13642,14 +13771,14 @@ var gd = class {
|
|
|
13642
13771
|
let r = t[e];
|
|
13643
13772
|
o[n + e * 4 + 0] = r, o[n + e * 4 + 1] = r, o[n + e * 4 + 2] = r, o[n + e * 4 + 3] = 255;
|
|
13644
13773
|
}
|
|
13645
|
-
let i = r[e].profile, c =
|
|
13774
|
+
let i = r[e].profile, c = gd(i);
|
|
13646
13775
|
s.push({
|
|
13647
13776
|
name: r[e].it.name,
|
|
13648
13777
|
index: e,
|
|
13649
13778
|
maxCandela: i.maxCandela,
|
|
13650
13779
|
photometricType: i.photometricType,
|
|
13651
13780
|
suggestedAngle: c,
|
|
13652
|
-
suggestedPenumbra:
|
|
13781
|
+
suggestedPenumbra: _d(i, c),
|
|
13653
13782
|
lumens: i.lumens
|
|
13654
13783
|
});
|
|
13655
13784
|
}
|
|
@@ -13682,7 +13811,7 @@ var gd = class {
|
|
|
13682
13811
|
l = Number.isFinite(e.lumens) ? e.lumens : null, i.userData.ies = {
|
|
13683
13812
|
name: e.name,
|
|
13684
13813
|
index: e.index,
|
|
13685
|
-
intensity:
|
|
13814
|
+
intensity: Cd(n),
|
|
13686
13815
|
fixtureLumens: l
|
|
13687
13816
|
}, r && (Number.isFinite(e.suggestedAngle) && (i.angle = e.suggestedAngle, o = e.suggestedAngle), Number.isFinite(e.suggestedPenumbra) && (i.penumbra = e.suggestedPenumbra, s = e.suggestedPenumbra), i.decay = 2, c = 2);
|
|
13688
13817
|
}
|
|
@@ -13705,44 +13834,44 @@ var gd = class {
|
|
|
13705
13834
|
return t && t.isSpotLight ? t : null;
|
|
13706
13835
|
}
|
|
13707
13836
|
};
|
|
13708
|
-
function
|
|
13837
|
+
function Cd(e) {
|
|
13709
13838
|
return Math.max(0, Math.min(1, e));
|
|
13710
13839
|
}
|
|
13711
13840
|
//#endregion
|
|
13712
13841
|
//#region src/Processor/ToneMapCPU.js
|
|
13713
|
-
var
|
|
13714
|
-
function
|
|
13715
|
-
i[0] =
|
|
13842
|
+
var wd = (e) => Math.min(Math.max(e, 0), 1);
|
|
13843
|
+
function Td(e, t, n, r, i) {
|
|
13844
|
+
i[0] = wd(e), i[1] = wd(t), i[2] = wd(n);
|
|
13716
13845
|
}
|
|
13717
|
-
function
|
|
13718
|
-
i[0] =
|
|
13846
|
+
function Ed(e, t, n, r, i) {
|
|
13847
|
+
i[0] = wd(e * r), i[1] = wd(t * r), i[2] = wd(n * r);
|
|
13719
13848
|
}
|
|
13720
|
-
function
|
|
13721
|
-
e *= r, t *= r, n *= r, i[0] =
|
|
13849
|
+
function Dd(e, t, n, r, i) {
|
|
13850
|
+
e *= r, t *= r, n *= r, i[0] = wd(e / (e + 1)), i[1] = wd(t / (t + 1)), i[2] = wd(n / (n + 1));
|
|
13722
13851
|
}
|
|
13723
|
-
function
|
|
13852
|
+
function Od(e, t, n, r, i) {
|
|
13724
13853
|
e = Math.max(e * r - .004, 0), t = Math.max(t * r - .004, 0), n = Math.max(n * r - .004, 0);
|
|
13725
13854
|
let a = (e) => (e * (6.2 * e + .5) / (e * (6.2 * e + 1.7) + .06)) ** 2.2;
|
|
13726
13855
|
i[0] = a(e), i[1] = a(t), i[2] = a(n);
|
|
13727
13856
|
}
|
|
13728
|
-
function
|
|
13857
|
+
function kd(e, t, n, r, i) {
|
|
13729
13858
|
e = e * r / .6, t = t * r / .6, n = n * r / .6;
|
|
13730
13859
|
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);
|
|
13731
|
-
a = c(a), o = c(o), s = c(s), i[0] =
|
|
13860
|
+
a = c(a), o = c(o), s = c(s), i[0] = wd(1.60475 * a - .53108 * o - .07367 * s), i[1] = wd(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = wd(-.00327 * a - .07276 * o + 1.07602 * s);
|
|
13732
13861
|
}
|
|
13733
|
-
function
|
|
13862
|
+
function Ad(e, t, n, r, i) {
|
|
13734
13863
|
e *= r, t *= r, n *= r;
|
|
13735
13864
|
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;
|
|
13736
|
-
c =
|
|
13865
|
+
c = wd((Math.log2(Math.max(c, 1e-10)) - d) / f), l = wd((Math.log2(Math.max(l, 1e-10)) - d) / f), u = wd((Math.log2(Math.max(u, 1e-10)) - d) / f);
|
|
13737
13866
|
let p = (e) => {
|
|
13738
13867
|
let t = e * e, n = t * t;
|
|
13739
13868
|
return 15.5 * n * t - 40.14 * n * e + 31.96 * n - 6.868 * t * e + .4298 * t + .1191 * e - .00232;
|
|
13740
13869
|
};
|
|
13741
13870
|
c = p(c), l = p(l), u = p(u);
|
|
13742
13871
|
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;
|
|
13743
|
-
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] =
|
|
13872
|
+
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = wd(1.6605 * m - .5876 * h - .0728 * g), i[1] = wd(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = wd(-.0182 * m - .1006 * h + 1.1187 * g);
|
|
13744
13873
|
}
|
|
13745
|
-
function
|
|
13874
|
+
function jd(e, t, n, r, i) {
|
|
13746
13875
|
let a = .76;
|
|
13747
13876
|
e *= r, t *= r, n *= r;
|
|
13748
13877
|
let o = Math.min(e, Math.min(t, n)), s = o < .08 ? o - 6.25 * o * o : .04;
|
|
@@ -13757,43 +13886,43 @@ function Td(e, t, n, r, i) {
|
|
|
13757
13886
|
let f = 1 - 1 / (.15 * (c - u) + 1);
|
|
13758
13887
|
i[0] = e + (u - e) * f, i[1] = t + (u - t) * f, i[2] = n + (u - n) * f;
|
|
13759
13888
|
}
|
|
13760
|
-
var
|
|
13761
|
-
[Dt,
|
|
13762
|
-
[pt,
|
|
13763
|
-
[Vt,
|
|
13764
|
-
[Ye,
|
|
13765
|
-
[Be,
|
|
13766
|
-
[He,
|
|
13767
|
-
[Tt,
|
|
13768
|
-
]),
|
|
13769
|
-
function
|
|
13889
|
+
var Md = new Map([
|
|
13890
|
+
[Dt, Td],
|
|
13891
|
+
[pt, Ed],
|
|
13892
|
+
[Vt, Dd],
|
|
13893
|
+
[Ye, Od],
|
|
13894
|
+
[Be, kd],
|
|
13895
|
+
[He, Ad],
|
|
13896
|
+
[Tt, jd]
|
|
13897
|
+
]), Nd = 1 / 2.2;
|
|
13898
|
+
function Pd(e) {
|
|
13770
13899
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
13771
13900
|
}
|
|
13772
|
-
var
|
|
13773
|
-
function
|
|
13901
|
+
var Fd = .2126, Id = .7152, Ld = .0722;
|
|
13902
|
+
function Rd(e, t) {
|
|
13774
13903
|
if (t === 1) return;
|
|
13775
|
-
let n = e[0] *
|
|
13904
|
+
let n = e[0] * Fd + e[1] * Id + e[2] * Ld;
|
|
13776
13905
|
e[0] = n + (e[0] - n) * t, e[1] = n + (e[1] - n) * t, e[2] = n + (e[2] - n) * t;
|
|
13777
13906
|
}
|
|
13778
13907
|
//#endregion
|
|
13779
13908
|
//#region src/Passes/OIDNDenoiser.js
|
|
13780
|
-
var
|
|
13781
|
-
async function
|
|
13782
|
-
if (!
|
|
13909
|
+
var zd = null, Bd = null;
|
|
13910
|
+
async function Vd() {
|
|
13911
|
+
if (!zd) {
|
|
13783
13912
|
let [e, t] = await Promise.all([import("oidn-web"), import("@tensorflow/tfjs-core")]);
|
|
13784
|
-
|
|
13913
|
+
zd = e.initUNetFromURL, Bd = t.engine;
|
|
13785
13914
|
}
|
|
13786
|
-
return
|
|
13915
|
+
return zd;
|
|
13787
13916
|
}
|
|
13788
|
-
function
|
|
13789
|
-
if (
|
|
13790
|
-
let e =
|
|
13917
|
+
function Hd() {
|
|
13918
|
+
if (Bd) try {
|
|
13919
|
+
let e = Bd();
|
|
13791
13920
|
e?.registryFactory && "webgpu-oidn" in e.registryFactory && e.removeBackend("webgpu-oidn");
|
|
13792
13921
|
} catch (e) {
|
|
13793
13922
|
console.warn("OIDNDenoiser: failed to clear cached TFJS backend", e);
|
|
13794
13923
|
}
|
|
13795
13924
|
}
|
|
13796
|
-
var
|
|
13925
|
+
var Ud = new Float32Array(3), Wd = {
|
|
13797
13926
|
QUALITY_MODELS: {
|
|
13798
13927
|
fast: "rt_hdr_alb_nrm_small",
|
|
13799
13928
|
balance: "rt_hdr_alb_nrm",
|
|
@@ -13805,7 +13934,7 @@ var Ld = new Float32Array(3), Rd = {
|
|
|
13805
13934
|
debugGbufferMaps: !0,
|
|
13806
13935
|
tileSize: 256
|
|
13807
13936
|
}
|
|
13808
|
-
},
|
|
13937
|
+
}, Gd = class extends q {
|
|
13809
13938
|
constructor(e, t, n, r, i = {}) {
|
|
13810
13939
|
if (super(), !e || !t || !n || !r) throw Error("OIDNDenoiser requires output canvas, renderer, scene, and camera");
|
|
13811
13940
|
this.renderer = t, this.scene = n, this.camera = r, this.input = t.domElement, this.output = e, this.extractGBufferData = i.extractGBufferData || null, this.getMRTRenderTarget = i.getMRTRenderTarget || null, this.backendParamsGetter = i.backendParams || null, this.getGPUTextures = i.getGPUTextures || null, this.getExposure = i.getExposure || (() => 1), this.getToneMapping = i.getToneMapping || (() => Be), this.getSaturation = i.getSaturation || (() => 1), this.getTransparentBackground = i.getTransparentBackground || (() => !1), this.isGPUMode = !!this.backendParamsGetter, this.gpuDevice = null, this._gpuInputBuffers = {
|
|
@@ -13816,7 +13945,7 @@ var Ld = new Float32Array(3), Rd = {
|
|
|
13816
13945
|
width: 0,
|
|
13817
13946
|
height: 0
|
|
13818
13947
|
}, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
|
|
13819
|
-
...
|
|
13948
|
+
...Wd.DEFAULT_OPTIONS,
|
|
13820
13949
|
...i
|
|
13821
13950
|
}, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this.state = {
|
|
13822
13951
|
isDenoising: !1,
|
|
@@ -13869,7 +13998,7 @@ var Ld = new Float32Array(3), Rd = {
|
|
|
13869
13998
|
let e = this.backendParamsGetter();
|
|
13870
13999
|
this.gpuDevice = e?.device ?? null, t = e?.device ? e : void 0;
|
|
13871
14000
|
}
|
|
13872
|
-
this.unet = await (await
|
|
14001
|
+
this.unet = await (await Vd())(e, t, {
|
|
13873
14002
|
aux: !0,
|
|
13874
14003
|
hdr: !0,
|
|
13875
14004
|
maxTileSize: this.tileSize
|
|
@@ -13884,14 +14013,14 @@ var Ld = new Float32Array(3), Rd = {
|
|
|
13884
14013
|
}
|
|
13885
14014
|
}
|
|
13886
14015
|
_generateTzaUrl() {
|
|
13887
|
-
let { oidnWeightsBaseUrl: e } =
|
|
14016
|
+
let { oidnWeightsBaseUrl: e } = bs(), { QUALITY_MODELS: t } = Wd;
|
|
13888
14017
|
return `${e}${t[this.quality] || t.balance}.tza`;
|
|
13889
14018
|
}
|
|
13890
14019
|
async updateConfiguration(e) {
|
|
13891
14020
|
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());
|
|
13892
14021
|
}
|
|
13893
14022
|
async updateQuality(e) {
|
|
13894
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
14023
|
+
if (!Object.prototype.hasOwnProperty.call(Wd.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(Wd.QUALITY_MODELS).join(", ")}`);
|
|
13895
14024
|
await this.updateConfiguration({ oidnQuality: e });
|
|
13896
14025
|
}
|
|
13897
14026
|
async start() {
|
|
@@ -14072,10 +14201,10 @@ var Ld = new Float32Array(3), Rd = {
|
|
|
14072
14201
|
d.copyBufferToBuffer(e.data, r, u, a, c);
|
|
14073
14202
|
}
|
|
14074
14203
|
r.queue.submit([d.finish()]), u.mapAsync(GPUMapMode.READ).then(() => {
|
|
14075
|
-
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l =
|
|
14204
|
+
let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l = Md.get(this.getToneMapping()) || Md.get(Be), d = this._cachedAlpha, f = this._cachedAlphaWidth;
|
|
14076
14205
|
for (let i = 0, a = e.length; i < a; i += 4) {
|
|
14077
14206
|
let a = e[i] * r, s = e[i + 1] * r, u = e[i + 2] * r;
|
|
14078
|
-
if (c !== 1 && (
|
|
14207
|
+
if (c !== 1 && (Ud[0] = a, Ud[1] = s, Ud[2] = u, Rd(Ud, c), a = Ud[0], s = Ud[1], u = Ud[2]), l(a, s, u, 1, Ud), t.data[i] = Pd(Ud[0]) * 255 + .5 | 0, t.data[i + 1] = Pd(Ud[1]) * 255 + .5 | 0, t.data[i + 2] = Pd(Ud[2]) * 255 + .5 | 0, d) {
|
|
14079
14208
|
let e = (i >> 2) % o, r = (i >> 2) / o | 0;
|
|
14080
14209
|
t.data[i + 3] = d[(n.y + r) * f + n.x + e];
|
|
14081
14210
|
} else t.data[i + 3] = 255;
|
|
@@ -14112,10 +14241,10 @@ var Ld = new Float32Array(3), Rd = {
|
|
|
14112
14241
|
try {
|
|
14113
14242
|
let o = r.createCommandEncoder({ label: "oidn-readback" });
|
|
14114
14243
|
o.copyBufferToBuffer(e, 0, a, 0, i), r.queue.submit([o.finish()]), await a.mapAsync(GPUMapMode.READ);
|
|
14115
|
-
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d =
|
|
14244
|
+
let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d = Md.get(this.getToneMapping()) || Md.get(Be), f = this._cachedAlpha;
|
|
14116
14245
|
for (let e = 0, t = s.length; e < t; e += 4) {
|
|
14117
14246
|
let t = s[e] * l, n = s[e + 1] * l, r = s[e + 2] * l;
|
|
14118
|
-
u !== 1 && (
|
|
14247
|
+
u !== 1 && (Ud[0] = t, Ud[1] = n, Ud[2] = r, Rd(Ud, u), t = Ud[0], n = Ud[1], r = Ud[2]), d(t, n, r, 1, Ud), c.data[e] = Pd(Ud[0]) * 255 + .5 | 0, c.data[e + 1] = Pd(Ud[1]) * 255 + .5 | 0, c.data[e + 2] = Pd(Ud[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
|
|
14119
14248
|
}
|
|
14120
14249
|
a.unmap(), this.ctx.putImageData(c, 0, 0);
|
|
14121
14250
|
} finally {
|
|
@@ -14136,9 +14265,9 @@ var Ld = new Float32Array(3), Rd = {
|
|
|
14136
14265
|
this._pendingStagingBuffers.clear();
|
|
14137
14266
|
}
|
|
14138
14267
|
dispose() {
|
|
14139
|
-
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(),
|
|
14268
|
+
this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), Hd(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), console.log("OIDNDenoiser disposed");
|
|
14140
14269
|
}
|
|
14141
|
-
},
|
|
14270
|
+
}, Kd = "" + new URL("assets/AIUpscalerWorker-AXN-lKWN.js", import.meta.url).href, qd = {
|
|
14142
14271
|
fast: {
|
|
14143
14272
|
2: "2x-spanx2-ch48.onnx",
|
|
14144
14273
|
4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
|
|
@@ -14152,17 +14281,17 @@ var Ld = new Float32Array(3), Rd = {
|
|
|
14152
14281
|
4: "4xNomos2_hq_mosr_fp32.onnx"
|
|
14153
14282
|
}
|
|
14154
14283
|
};
|
|
14155
|
-
function
|
|
14156
|
-
let { upscalerModelBaseUrl: e } =
|
|
14157
|
-
for (let n in
|
|
14284
|
+
function Jd() {
|
|
14285
|
+
let { upscalerModelBaseUrl: e } = bs(), t = {};
|
|
14286
|
+
for (let n in qd) {
|
|
14158
14287
|
t[n] = {};
|
|
14159
|
-
for (let r in
|
|
14288
|
+
for (let r in qd[n]) t[n][r] = e + qd[n][r];
|
|
14160
14289
|
}
|
|
14161
14290
|
return t;
|
|
14162
14291
|
}
|
|
14163
|
-
var
|
|
14292
|
+
var Yd = {
|
|
14164
14293
|
get QUALITY_PRESETS() {
|
|
14165
|
-
return
|
|
14294
|
+
return Jd();
|
|
14166
14295
|
},
|
|
14167
14296
|
TILE_SIZE: 512,
|
|
14168
14297
|
TILE_OVERLAP: 16,
|
|
@@ -14173,17 +14302,17 @@ var Ud = {
|
|
|
14173
14302
|
}],
|
|
14174
14303
|
graphOptimizationLevel: "all"
|
|
14175
14304
|
}
|
|
14176
|
-
},
|
|
14305
|
+
}, Xd = class extends q {
|
|
14177
14306
|
constructor(e, t, n = {}) {
|
|
14178
14307
|
if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
|
|
14179
|
-
this.renderer = t, this.input = t.domElement, this.output = e, this.getSourceCanvas = n.getSourceCanvas || null, this.getGPUTextures = n.getGPUTextures || null, this.getExposure = n.getExposure || (() => 1), this.getToneMapping = n.getToneMapping || (() => Be), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize ||
|
|
14308
|
+
this.renderer = t, this.input = t.domElement, this.output = e, this.getSourceCanvas = n.getSourceCanvas || null, this.getGPUTextures = n.getGPUTextures || null, this.getExposure = n.getExposure || (() => 1), this.getToneMapping = n.getToneMapping || (() => Be), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize || Yd.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
|
|
14180
14309
|
isUpscaling: !1,
|
|
14181
14310
|
isLoading: !1,
|
|
14182
14311
|
abortController: null
|
|
14183
14312
|
}, 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;
|
|
14184
14313
|
}
|
|
14185
14314
|
async _ensureSession() {
|
|
14186
|
-
let e =
|
|
14315
|
+
let e = Yd.QUALITY_PRESETS[this.quality];
|
|
14187
14316
|
if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
|
|
14188
14317
|
let t = e[this.scaleFactor];
|
|
14189
14318
|
if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
|
|
@@ -14194,19 +14323,19 @@ var Ud = {
|
|
|
14194
14323
|
});
|
|
14195
14324
|
try {
|
|
14196
14325
|
if (!this._worker) try {
|
|
14197
|
-
this._worker = new Worker(
|
|
14326
|
+
this._worker = new Worker(Kd, { type: "module" });
|
|
14198
14327
|
} catch (e) {
|
|
14199
14328
|
if (e.name !== "SecurityError") throw e;
|
|
14200
|
-
this._worker = await Nr(
|
|
14329
|
+
this._worker = await Nr(Kd);
|
|
14201
14330
|
}
|
|
14202
14331
|
await new Promise((e, n) => {
|
|
14203
14332
|
let r = (t) => {
|
|
14204
14333
|
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)));
|
|
14205
|
-
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } =
|
|
14334
|
+
}, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } = bs();
|
|
14206
14335
|
this._worker.addEventListener("message", r), this._worker.postMessage({
|
|
14207
14336
|
type: "load",
|
|
14208
14337
|
url: t,
|
|
14209
|
-
sessionOptions:
|
|
14338
|
+
sessionOptions: Yd.SESSION_OPTIONS,
|
|
14210
14339
|
ortRuntimeUrl: i,
|
|
14211
14340
|
ortWasmPaths: a,
|
|
14212
14341
|
cacheNamespace: o
|
|
@@ -14276,8 +14405,8 @@ var Ud = {
|
|
|
14276
14405
|
willReadFrequently: !0,
|
|
14277
14406
|
alpha: !0
|
|
14278
14407
|
});
|
|
14279
|
-
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn =
|
|
14280
|
-
let o =
|
|
14408
|
+
this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = Md.get(this.getToneMapping()) || Md.get(Be), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
|
|
14409
|
+
let o = Yd.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
|
|
14281
14410
|
for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
|
|
14282
14411
|
if (e.aborted) throw new DOMException("Aborted", "AbortError");
|
|
14283
14412
|
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);
|
|
@@ -14350,7 +14479,7 @@ var Ud = {
|
|
|
14350
14479
|
let u = ((n + e) * o + (t + i)) * 4, d = e * r + i;
|
|
14351
14480
|
if (s) {
|
|
14352
14481
|
let e = this._hdrToneMapFn, t = this._hdrExposure, n = this._hdrSaturation, r = a[u] * t, i = a[u + 1] * t, o = a[u + 2] * t;
|
|
14353
|
-
n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o,
|
|
14482
|
+
n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, Rd(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] ** +Nd, l[c + d] = this._tmOut[1] ** +Nd, l[2 * c + d] = this._tmOut[2] ** +Nd;
|
|
14354
14483
|
} else l[d] = a[u] / 255, l[c + d] = a[u + 1] / 255, l[2 * c + d] = a[u + 2] / 255;
|
|
14355
14484
|
}
|
|
14356
14485
|
return l;
|
|
@@ -14408,10 +14537,10 @@ var Ud = {
|
|
|
14408
14537
|
this._backupCanvas = document.createElement("canvas"), this._backupCanvas.width = e.width, this._backupCanvas.height = e.height;
|
|
14409
14538
|
let t = this._backupCanvas.getContext("2d");
|
|
14410
14539
|
if (e.isHDR) {
|
|
14411
|
-
let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s =
|
|
14540
|
+
let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = Md.get(this.getToneMapping()) || Md.get(Be), c = this.getExposure(), l = this.getSaturation(), u = new Float32Array(3);
|
|
14412
14541
|
for (let e = 0, t = r * i; e < t; e++) {
|
|
14413
14542
|
let t = e * 4, r = n[t] * c, i = n[t + 1] * c, a = n[t + 2] * c;
|
|
14414
|
-
l !== 1 && (u[0] = r, u[1] = i, u[2] = a,
|
|
14543
|
+
l !== 1 && (u[0] = r, u[1] = i, u[2] = a, Rd(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +Nd * 255 + .5 | 0, o[t + 1] = u[1] ** +Nd * 255 + .5 | 0, o[t + 2] = u[2] ** +Nd * 255 + .5 | 0, o[t + 3] = 255;
|
|
14415
14544
|
}
|
|
14416
14545
|
t.putImageData(a, 0, 0);
|
|
14417
14546
|
} else t.putImageData(e, 0, 0);
|
|
@@ -14423,7 +14552,7 @@ var Ud = {
|
|
|
14423
14552
|
this.hdr = !!e;
|
|
14424
14553
|
}
|
|
14425
14554
|
setQuality(e) {
|
|
14426
|
-
if (!
|
|
14555
|
+
if (!Yd.QUALITY_PRESETS[e]) {
|
|
14427
14556
|
console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
|
|
14428
14557
|
return;
|
|
14429
14558
|
}
|
|
@@ -14446,7 +14575,7 @@ var Ud = {
|
|
|
14446
14575
|
async dispose() {
|
|
14447
14576
|
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");
|
|
14448
14577
|
}
|
|
14449
|
-
},
|
|
14578
|
+
}, Zd = class extends q {
|
|
14450
14579
|
constructor({ renderer: e, mainCanvas: t, scene: n, camera: r, stages: i, pipeline: a, getExposure: o, getSaturation: s, getTransparentBg: c }) {
|
|
14451
14580
|
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;
|
|
14452
14581
|
}
|
|
@@ -14467,7 +14596,7 @@ var Ud = {
|
|
|
14467
14596
|
setupDenoiser() {
|
|
14468
14597
|
if (!this.denoiserCanvas) return;
|
|
14469
14598
|
let e = this._stages.pathTracer;
|
|
14470
|
-
this.denoiser = new
|
|
14599
|
+
this.denoiser = new Gd(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
|
|
14471
14600
|
...X,
|
|
14472
14601
|
backendParams: () => ({
|
|
14473
14602
|
device: this.renderer.backend.device,
|
|
@@ -14492,7 +14621,7 @@ var Ud = {
|
|
|
14492
14621
|
setupUpscaler() {
|
|
14493
14622
|
if (!this.denoiserCanvas) return;
|
|
14494
14623
|
let e = this._stages.pathTracer;
|
|
14495
|
-
this.upscaler = new
|
|
14624
|
+
this.upscaler = new Xd(this.denoiserCanvas, this.renderer, {
|
|
14496
14625
|
scaleFactor: X.upscalerScale || 2,
|
|
14497
14626
|
quality: X.upscalerQuality || "fast",
|
|
14498
14627
|
getSourceCanvas: () => this.denoiser?.enabled ? null : this.renderer.domElement,
|
|
@@ -14636,7 +14765,7 @@ var Ud = {
|
|
|
14636
14765
|
let t = dr[e];
|
|
14637
14766
|
t && (this._stages.asvgf?.updateParameters(t), this._stages.bilateralFilter?.updateParameters(t), this._stages.variance && t.varianceBoost !== void 0 && (this._stages.variance.varianceBoost.value = t.varianceBoost));
|
|
14638
14767
|
}
|
|
14639
|
-
},
|
|
14768
|
+
}, Qd = class {
|
|
14640
14769
|
constructor() {
|
|
14641
14770
|
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;
|
|
14642
14771
|
}
|
|
@@ -14660,7 +14789,7 @@ var Ud = {
|
|
|
14660
14789
|
dispose() {
|
|
14661
14790
|
this.visible = !1;
|
|
14662
14791
|
}
|
|
14663
|
-
},
|
|
14792
|
+
}, $d = class {
|
|
14664
14793
|
constructor(n, r, i) {
|
|
14665
14794
|
this.layer = "scene", this.visible = !0, this._outlineNode = gn(r, i, {
|
|
14666
14795
|
selectedObjects: [],
|
|
@@ -14694,7 +14823,7 @@ var Ud = {
|
|
|
14694
14823
|
dispose() {
|
|
14695
14824
|
this.visible = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
|
|
14696
14825
|
}
|
|
14697
|
-
},
|
|
14826
|
+
}, ef = class {
|
|
14698
14827
|
constructor(e, t) {
|
|
14699
14828
|
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;
|
|
14700
14829
|
}
|
|
@@ -14709,11 +14838,11 @@ var Ud = {
|
|
|
14709
14838
|
}
|
|
14710
14839
|
setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
|
|
14711
14840
|
this.setHelperScene(e);
|
|
14712
|
-
let s = new
|
|
14841
|
+
let s = new Qd();
|
|
14713
14842
|
this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener("resolution_changed", (e) => {
|
|
14714
14843
|
s.setRenderSize(e.width, e.height);
|
|
14715
14844
|
}), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
|
|
14716
|
-
let c = new
|
|
14845
|
+
let c = new $d(this.renderer, t, this.camera);
|
|
14717
14846
|
this.register("outline", c);
|
|
14718
14847
|
}
|
|
14719
14848
|
_wireDenoiserTileEvents(e, t) {
|
|
@@ -14780,7 +14909,7 @@ var Ud = {
|
|
|
14780
14909
|
for (let e of this._helpers.values()) e.dispose?.();
|
|
14781
14910
|
this._helpers.clear(), this._hudCanvas.parentElement && this._hudCanvas.parentElement.removeChild(this._hudCanvas);
|
|
14782
14911
|
}
|
|
14783
|
-
},
|
|
14912
|
+
}, tf = class extends q {
|
|
14784
14913
|
constructor() {
|
|
14785
14914
|
super(), this.mixer = null, this.timer = new Zt(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._tempVec = new nn(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this.wakeCallback = null;
|
|
14786
14915
|
}
|
|
@@ -14880,7 +15009,7 @@ var Ud = {
|
|
|
14880
15009
|
dispose() {
|
|
14881
15010
|
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;
|
|
14882
15011
|
}
|
|
14883
|
-
},
|
|
15012
|
+
}, nf = class {
|
|
14884
15013
|
constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
|
|
14885
15014
|
this._app = r, this._orbitControls = n, this._camera = e, this._controls = new _n(e, t), this._gizmoScene = new Wt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new nn(), this._normalMatrix = new vt(), this._refitInFlight = !1, this._baselineComputed = !1, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
|
|
14886
15015
|
}
|
|
@@ -14991,15 +15120,15 @@ var Ud = {
|
|
|
14991
15120
|
dispose() {
|
|
14992
15121
|
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;
|
|
14993
15122
|
}
|
|
14994
|
-
},
|
|
15123
|
+
}, rf = /* @__PURE__ */ new WeakMap(), af = class extends q {
|
|
14995
15124
|
constructor(e, t = {}) {
|
|
14996
15125
|
super();
|
|
14997
15126
|
try {
|
|
14998
|
-
|
|
15127
|
+
rf.get(e)?.dispose();
|
|
14999
15128
|
} catch (e) {
|
|
15000
15129
|
console.warn("PathTracerApp: prior canvas owner dispose failed", e);
|
|
15001
15130
|
}
|
|
15002
|
-
|
|
15131
|
+
rf.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new cd(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new tf(), 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 Cu(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1;
|
|
15003
15132
|
}
|
|
15004
15133
|
_addTrackedListener(e, t, n) {
|
|
15005
15134
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -15148,7 +15277,7 @@ var Ud = {
|
|
|
15148
15277
|
}
|
|
15149
15278
|
async loadSceneData() {
|
|
15150
15279
|
this.interactionManager?.deselect(), this.animationManager.dispose(), this._animRefitInFlight = !1;
|
|
15151
|
-
let e = new
|
|
15280
|
+
let e = new ms("loadSceneData"), t = this.meshScene.environment, n = null;
|
|
15152
15281
|
if (t?.image?.data && (e.start("Environment CDF build (worker)"), this.stages.pathTracer.scene.environment = t, n = this.stages.pathTracer.environment.buildEnvironmentCDF().then(() => e.end("Environment CDF build (worker)"))), e.start("BVH build (SceneProcessor)"), await this._sdf.buildBVH(this.meshScene), e.end("BVH build (SceneProcessor)"), $n({
|
|
15153
15282
|
status: "Transferring data to GPU...",
|
|
15154
15283
|
progress: 86
|
|
@@ -15277,7 +15406,7 @@ var Ud = {
|
|
|
15277
15406
|
setMaterialProperty(e, t, n) {
|
|
15278
15407
|
if (this.stages.pathTracer?.materialData.updateMaterialProperty(e, t, n), ["emissive", "emissiveIntensity"].includes(t) && this.stages.pathTracer?.enableEmissiveTriangleSampling?.value) {
|
|
15279
15408
|
let r = this._sdf.updateMaterialEmissive(e, t, n);
|
|
15280
|
-
r && this.stages.pathTracer.setEmissiveTriangleData(r.rawData, r.emissiveCount, r.totalPower);
|
|
15409
|
+
r && (this.stages.pathTracer.setEmissiveTriangleData(r.rawData, r.emissiveCount, r.totalPower, r.bitTrailMap), r.lightBVHNodeData && this.stages.pathTracer.setLightBVHData(r.lightBVHNodeData, r.lightBVHNodeCount));
|
|
15281
15410
|
}
|
|
15282
15411
|
this.reset();
|
|
15283
15412
|
}
|
|
@@ -15320,32 +15449,32 @@ var Ud = {
|
|
|
15320
15449
|
}), await this.renderer.init(), r.setLTC(rn.init()), this.renderer.outputColorSpace = a, this.renderer.toneMapping = Be, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
|
|
15321
15450
|
}
|
|
15322
15451
|
_initCameraManager() {
|
|
15323
|
-
this.cameraManager = new
|
|
15452
|
+
this.cameraManager = new ld(this.canvas);
|
|
15324
15453
|
}
|
|
15325
15454
|
_initScenes() {
|
|
15326
15455
|
this.scene = new Wt(), this.meshScene = new Wt(), this._sceneHelpers = new wn();
|
|
15327
15456
|
}
|
|
15328
15457
|
_initAssetPipeline() {
|
|
15329
|
-
this._sdf = new
|
|
15458
|
+
this._sdf = new gs(), this.assetLoader = new ad(this.meshScene, this.cameraManager.camera, this.cameraManager.controls), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
|
|
15330
15459
|
this.needsReset = !0, this.wake();
|
|
15331
15460
|
});
|
|
15332
15461
|
}
|
|
15333
15462
|
_initPipeline() {
|
|
15334
15463
|
this._createStages();
|
|
15335
15464
|
let { clientWidth: e, clientHeight: t } = this.canvas;
|
|
15336
|
-
this.pipeline = new
|
|
15465
|
+
this.pipeline = new Su(this.renderer, e || 1, t || 1), this.pipeline.addStage(this.stages.pathTracer), this.pipeline.addStage(this.stages.normalDepth), this.pipeline.addStage(this.stages.motionVector), this.pipeline.addStage(this.stages.ssrc), this.pipeline.addStage(this.stages.asvgf), this.pipeline.addStage(this.stages.variance), this.pipeline.addStage(this.stages.bilateralFilter), this.pipeline.addStage(this.stages.edgeFilter), this.pipeline.addStage(this.stages.autoExposure), this.pipeline.addStage(this.stages.compositor);
|
|
15337
15466
|
let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
|
|
15338
15467
|
this.pipeline.setSize(n, r);
|
|
15339
15468
|
}
|
|
15340
15469
|
_initManagers() {
|
|
15341
|
-
this.interactionManager = new
|
|
15470
|
+
this.interactionManager = new wu({
|
|
15342
15471
|
scene: this.meshScene,
|
|
15343
15472
|
camera: this.cameraManager.camera,
|
|
15344
15473
|
canvas: this.canvas,
|
|
15345
15474
|
assetLoader: this.assetLoader,
|
|
15346
15475
|
pathTracer: null,
|
|
15347
15476
|
floorPlane: this.assetLoader.floorPlane
|
|
15348
|
-
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new
|
|
15477
|
+
}), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new ud(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new dd(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Sd(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new nf({
|
|
15349
15478
|
camera: this.cameraManager.camera,
|
|
15350
15479
|
canvas: this.canvas,
|
|
15351
15480
|
orbitControls: this.cameraManager.controls,
|
|
@@ -15415,10 +15544,10 @@ var Ud = {
|
|
|
15415
15544
|
this.transformManager?.setMeshData(this._sdf.meshes);
|
|
15416
15545
|
}
|
|
15417
15546
|
_createStages() {
|
|
15418
|
-
this.stages.pathTracer = new
|
|
15547
|
+
this.stages.pathTracer = new Zl(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new Ql(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new $l(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.ssrc = new vu(this.renderer, { enabled: !1 }), this.stages.asvgf = new nu(this.renderer, { enabled: !1 }), this.stages.variance = new au(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new su(this.renderer, { enabled: !1 }), this.stages.edgeFilter = new cu(this.renderer, { enabled: !1 }), this.stages.autoExposure = new hu(this.renderer, { enabled: X.autoExposure ?? !1 }), this.stages.compositor = new yu(this.renderer, { saturation: this.settings.get("saturation") ?? X.saturation });
|
|
15419
15548
|
}
|
|
15420
15549
|
_setupDenoisingManager() {
|
|
15421
|
-
this.denoisingManager = new
|
|
15550
|
+
this.denoisingManager = new Zd({
|
|
15422
15551
|
renderer: this.renderer,
|
|
15423
15552
|
mainCanvas: this.canvas,
|
|
15424
15553
|
scene: this.scene,
|
|
@@ -15462,7 +15591,7 @@ var Ud = {
|
|
|
15462
15591
|
this.scene.updateMatrixWorld(), this.overlayManager?.render(), this.transformManager?.render(this.renderer);
|
|
15463
15592
|
}
|
|
15464
15593
|
_setupOverlayManager() {
|
|
15465
|
-
this.overlayManager = new
|
|
15594
|
+
this.overlayManager = new ef(this.renderer, this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
|
|
15466
15595
|
helperScene: this._sceneHelpers,
|
|
15467
15596
|
meshScene: this.meshScene,
|
|
15468
15597
|
pipeline: this.pipeline,
|
|
@@ -15478,7 +15607,7 @@ var Ud = {
|
|
|
15478
15607
|
_forwardEvents(e, t) {
|
|
15479
15608
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
15480
15609
|
}
|
|
15481
|
-
},
|
|
15610
|
+
}, of = class {
|
|
15482
15611
|
constructor(e) {
|
|
15483
15612
|
this._app = e, this._cancelled = !1, this._rendering = !1;
|
|
15484
15613
|
}
|
|
@@ -15578,6 +15707,6 @@ var Ud = {
|
|
|
15578
15707
|
}
|
|
15579
15708
|
};
|
|
15580
15709
|
//#endregion
|
|
15581
|
-
export { gr as AF_DEFAULTS, dr as ASVGF_QUALITY_PRESETS, hr as AUTO_FOCUS_MODES,
|
|
15710
|
+
export { gr as AF_DEFAULTS, dr as ASVGF_QUALITY_PRESETS, hr as AUTO_FOCUS_MODES, tf as AnimationManager, _r as BVH_LEAF_MARKERS, mr as CAMERA_PRESETS, fr as CAMERA_RANGES, ld as CameraManager, yr as DEFAULT_TEXTURE_MATRIX, Zd as DenoisingManager, X as ENGINE_DEFAULTS, Yn as EngineEvents, dd as GoboManager, Sd as IESManager, xr as INTERACTIVE_RENDER_CONFIG, wu as InteractionManager, ud as LightManager, Sr as MEMORY_CONSTANTS, ef as OverlayManager, br as PRODUCTION_RENDER_CONFIG, af as PathTracerApp, bu as PipelineContext, Su as RenderPipeline, cd as RenderSettings, qn as RenderStage, pr as SKY_PRESETS, Kn as StageExecutionMode, vr as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, nf as TransformManager, pc as VRAMTracker, of as VideoRenderManager, dc as bufferBytes, ys as configureAssets, bs as getAssetConfig, fc as textureBytes };
|
|
15582
15711
|
|
|
15583
15712
|
//# sourceMappingURL=rayzee.es.js.map
|