rayzee 5.10.1 → 5.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/rayzee.es.js +222 -190
- package/dist/rayzee.es.js.map +1 -1
- package/dist/rayzee.umd.js +17 -17
- package/dist/rayzee.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/PathTracerApp.js +9 -2
- package/src/Processor/TextureCreator.js +42 -15
- package/src/TSL/PathTracerCore.js +24 -3
- package/src/managers/OverlayManager.js +14 -2
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
2
|
import { Break as d, Continue as f, Fn as p, If as m, Loop as h, TWO_PI as g, abs as _, acos as v, array as y, atan as b, atomicAdd as x, atomicLoad as S, atomicStore as C, attributeArray as w, bool as T, clamp as E, cos as D, cross as O, cubeTexture as k, dot as A, exp as j, float as M, floor as ee, fract as te, int as N, ivec2 as P, length as ne, lessThan as re, localId as F, log as ie, mat3 as ae, max as I, min as oe, mix as L, mod as se, normalize as R, notEqual as ce, pow as le, reflect as ue, refract as de, sampler as fe, select as z, sign as pe, sin as me, smoothstep as he, sqrt as ge, step as _e, storage as ve, struct as ye, texture as be, textureLoad as B, textureStore as xe, uint as V, uniform as H, uniformArray as Se, uv as Ce, uvec2 as we, vec2 as U, vec3 as W, vec4 as G, wgslFn as K, workgroupArray as Te, workgroupBarrier as Ee, workgroupId as De } from "three/tsl";
|
|
3
|
-
import { ACESFilmicToneMapping as Oe, AdditiveBlending as ke, AgXToneMapping as Ae, AnimationMixer as je, BackSide as Me, Box2 as Ne, Box3 as Pe, CineonToneMapping as Fe, CircleGeometry as Ie, ClampToEdgeWrapping as Le, Color as Re, DataArrayTexture as ze, DataTexture as Be, DataUtils as Ve, DirectionalLight as He, DirectionalLightHelper as Ue, DoubleSide as We, EquirectangularReflectionMapping as Ge, EventDispatcher as Ke, FloatType as qe, FrontSide as Je, HalfFloatType as Ye, LinearFilter as
|
|
3
|
+
import { ACESFilmicToneMapping as Oe, AdditiveBlending as ke, AgXToneMapping as Ae, AnimationMixer as je, BackSide as Me, Box2 as Ne, Box3 as Pe, CineonToneMapping as Fe, CircleGeometry as Ie, ClampToEdgeWrapping as Le, Color as Re, DataArrayTexture as ze, DataTexture as Be, DataUtils as Ve, DirectionalLight as He, DirectionalLightHelper as Ue, DoubleSide as We, EquirectangularReflectionMapping as Ge, EventDispatcher as Ke, FloatType as qe, FrontSide as Je, HalfFloatType as Ye, LinearFilter as Xe, LinearSRGBColorSpace as Ze, LinearToneMapping as Qe, LoadingManager as $e, LoopOnce as et, LoopRepeat as tt, MathUtils as nt, Matrix3 as rt, Matrix4 as it, Mesh as at, MeshBasicMaterial as ot, MeshPhysicalMaterial as st, MeshStandardMaterial as ct, NearestFilter as q, NeutralToneMapping as lt, NoBlending as ut, NoToneMapping as dt, Object3D as ft, PerspectiveCamera as pt, PointLight as mt, PointLightHelper as ht, Points as gt, PointsMaterial as _t, Quaternion as vt, RGBAFormat as yt, Raycaster as bt, RectAreaLight as xt, ReinhardToneMapping as St, RepeatWrapping as Ct, SRGBColorSpace as wt, Scene as Tt, SphereGeometry as Et, SpotLight as Dt, SpotLightHelper as Ot, TextureLoader as kt, Timer as At, TimestampQuery as jt, UnsignedByteType as Mt, Vector2 as Nt, Vector3 as Pt } from "three";
|
|
4
4
|
import { RectAreaLightTexturesLib as Ft } from "three/addons/lights/RectAreaLightTexturesLib.js";
|
|
5
5
|
import { RectAreaLightHelper as It } from "three/addons/helpers/RectAreaLightHelper.js";
|
|
6
6
|
import Lt from "stats-gl";
|
|
@@ -593,7 +593,7 @@ function zn() {
|
|
|
593
593
|
//#region src/Processor/StorageTexturePool.js
|
|
594
594
|
function Bn(e, t) {
|
|
595
595
|
let n = new s(e, t);
|
|
596
|
-
return n.type = qe, n.format = yt, n.minFilter =
|
|
596
|
+
return n.type = qe, n.format = yt, n.minFilter = Xe, n.magFilter = Xe, n;
|
|
597
597
|
}
|
|
598
598
|
var Vn = class {
|
|
599
599
|
constructor(e, t) {
|
|
@@ -603,8 +603,8 @@ var Vn = class {
|
|
|
603
603
|
this.dispose(), this.renderWidth = e, this.renderHeight = t, this.writeColor = Bn(e, t), this.writeNormalDepth = Bn(e, t), this.writeAlbedo = Bn(e, t), this.readTarget = new i(e, t, {
|
|
604
604
|
type: qe,
|
|
605
605
|
format: yt,
|
|
606
|
-
minFilter:
|
|
607
|
-
magFilter:
|
|
606
|
+
minFilter: q,
|
|
607
|
+
magFilter: q,
|
|
608
608
|
depthBuffer: !1,
|
|
609
609
|
stencilBuffer: !1,
|
|
610
610
|
count: 3
|
|
@@ -1116,12 +1116,12 @@ var Vn = class {
|
|
|
1116
1116
|
let r = H(t, n);
|
|
1117
1117
|
return this._uniforms.set(e, r), r;
|
|
1118
1118
|
}, r = (e, t) => (this._booleans.add(e), n(e, +!!t, "int"));
|
|
1119
|
-
n("frame", 0, "uint"), n("maxBounces", X.bounces, "int"), n("samplesPerPixel", X.samplesPerPixel, "int"), n("maxSamples", X.maxSamples, "int"), n("transmissiveBounces", X.transmissiveBounces, "int"), n("visMode", X.debugMode, "int"), n("debugVisScale", X.debugVisScale, "float"), r("enableAccumulation", !0), n("accumulationAlpha", 0, "float"), r("cameraIsMoving", !1), r("hasPreviousAccumulated", !1), n("environmentIntensity", X.environmentIntensity, "float"), n("backgroundIntensity", X.backgroundIntensity, "float"), r("showBackground", X.showBackground), r("transparentBackground", X.transparentBackground), r("enableEnvironment", X.enableEnvironment), n("environmentMatrix", new
|
|
1119
|
+
n("frame", 0, "uint"), n("maxBounces", X.bounces, "int"), n("samplesPerPixel", X.samplesPerPixel, "int"), n("maxSamples", X.maxSamples, "int"), n("transmissiveBounces", X.transmissiveBounces, "int"), n("visMode", X.debugMode, "int"), n("debugVisScale", X.debugVisScale, "float"), r("enableAccumulation", !0), n("accumulationAlpha", 0, "float"), r("cameraIsMoving", !1), r("hasPreviousAccumulated", !1), n("environmentIntensity", X.environmentIntensity, "float"), n("backgroundIntensity", X.backgroundIntensity, "float"), r("showBackground", X.showBackground), r("transparentBackground", X.transparentBackground), r("enableEnvironment", X.enableEnvironment), n("environmentMatrix", new it(), "mat4"), r("useEnvMapIS", X.useImportanceSampledEnvironment), n("envTotalSum", 0, "float"), n("envCompensationDelta", 0, "float"), n("envResolution", new Nt(1, 1), "vec2"), n("sunDirection", new Pt(0, 1, 0), "vec3"), n("sunAngularSize", .0087, "float"), r("hasSun", !1), n("globalIlluminationIntensity", X.globalIlluminationIntensity, "float"), n("exposure", X.exposure, "float"), n("numDirectionalLights", 0, "int"), n("numAreaLights", 0, "int"), n("numPointLights", 0, "int"), n("numSpotLights", 0, "int"), this._lightBuffers = {
|
|
1120
1120
|
directional: Se(new Float32Array(128), "float"),
|
|
1121
1121
|
area: Se(new Float32Array(208), "float"),
|
|
1122
1122
|
point: Se(new Float32Array(144), "float"),
|
|
1123
1123
|
spot: Se(new Float32Array(224), "float")
|
|
1124
|
-
}, n("cameraWorldMatrix", new
|
|
1124
|
+
}, n("cameraWorldMatrix", new it(), "mat4"), n("cameraProjectionMatrixInverse", new it(), "mat4"), n("cameraViewMatrix", new it(), "mat4"), n("cameraProjectionMatrix", new it(), "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, r("useAdaptiveSampling", X.adaptiveSampling), n("adaptiveSamplingMin", X.adaptiveSamplingMin ?? 1, "int"), n("adaptiveSamplingMax", X.adaptiveSamplingMax, "int"), n("fireflyThreshold", X.fireflyThreshold, "float"), r("enableEmissiveTriangleSampling", X.enableEmissiveTriangleSampling), n("emissiveBoost", X.emissiveBoost, "float"), n("emissiveTriangleCount", 0, "int"), n("emissiveTotalPower", 0, "float"), n("lightBVHNodeCount", 0, "int"), n("emissiveVec4Offset", 0, "int"), n("renderMode", X.renderMode, "int"), r("enableAlphaShadows", X.enableAlphaShadows), n("resolution", new Nt(e, t), "vec2"), n("totalTriangleCount", 0, "int");
|
|
1125
1125
|
}
|
|
1126
1126
|
_nameAll() {
|
|
1127
1127
|
for (let [e, t] of this._uniforms) t.name = er[e] || e;
|
|
@@ -1666,7 +1666,7 @@ function Fr(e, t, n) {
|
|
|
1666
1666
|
}
|
|
1667
1667
|
var Ir = class {
|
|
1668
1668
|
constructor(e = 512, t = 256) {
|
|
1669
|
-
this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace =
|
|
1669
|
+
this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Ze, this._texture.minFilter = Xe, this._texture.magFilter = Xe, this._texture.wrapS = Ct, this._texture.wrapT = Le, this._texture.generateMipmaps = !1;
|
|
1670
1670
|
}
|
|
1671
1671
|
render(e) {
|
|
1672
1672
|
let t = performance.now(), n = [
|
|
@@ -1684,7 +1684,7 @@ var Ir = class {
|
|
|
1684
1684
|
return this._texture.needsUpdate = !0, this.lastRenderTime = performance.now() - t, this._texture;
|
|
1685
1685
|
}
|
|
1686
1686
|
setResolution(e, t) {
|
|
1687
|
-
this.width === e && this.height === t || (this.width = e, this.height = t, this._pixels = new Float32Array(e * t * 4), this._texture.dispose(), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace =
|
|
1687
|
+
this.width === e && this.height === t || (this.width = e, this.height = t, this._pixels = new Float32Array(e * t * 4), this._texture.dispose(), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Ze, this._texture.minFilter = Xe, this._texture.magFilter = Xe, this._texture.wrapS = Ct, this._texture.wrapT = Le, this._texture.generateMipmaps = !1);
|
|
1688
1688
|
}
|
|
1689
1689
|
getLastRenderTime() {
|
|
1690
1690
|
return this.lastRenderTime;
|
|
@@ -1694,7 +1694,7 @@ var Ir = class {
|
|
|
1694
1694
|
}
|
|
1695
1695
|
}, Lr = class {
|
|
1696
1696
|
constructor(e = 512, t = 256) {
|
|
1697
|
-
this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace =
|
|
1697
|
+
this.width = e, this.height = t, this.lastRenderTime = 0, this._pixels = new Float32Array(e * t * 4), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Ze, this._texture.minFilter = Xe, this._texture.magFilter = Xe, this._texture.wrapS = Ct, this._texture.wrapT = Le, this._texture.generateMipmaps = !1;
|
|
1698
1698
|
}
|
|
1699
1699
|
renderGradient(e) {
|
|
1700
1700
|
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;
|
|
@@ -1723,7 +1723,7 @@ var Ir = class {
|
|
|
1723
1723
|
return this._texture.needsUpdate = !0, this.lastRenderTime = performance.now() - t, this._texture;
|
|
1724
1724
|
}
|
|
1725
1725
|
setResolution(e, t) {
|
|
1726
|
-
this.width === e && this.height === t || (this.width = e, this.height = t, this._pixels = new Float32Array(e * t * 4), this._texture.dispose(), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace =
|
|
1726
|
+
this.width === e && this.height === t || (this.width = e, this.height = t, this._pixels = new Float32Array(e * t * 4), this._texture.dispose(), this._texture = new Be(this._pixels, e, t, yt, qe), this._texture.mapping = Ge, this._texture.colorSpace = Ze, this._texture.minFilter = Xe, this._texture.magFilter = Xe, this._texture.wrapS = Ct, this._texture.wrapT = Le, this._texture.generateMipmaps = !1);
|
|
1727
1727
|
}
|
|
1728
1728
|
getLastRenderTime() {
|
|
1729
1729
|
return this.lastRenderTime;
|
|
@@ -1738,7 +1738,7 @@ var Ir = class {
|
|
|
1738
1738
|
0,
|
|
1739
1739
|
0,
|
|
1740
1740
|
1
|
|
1741
|
-
]), 1, 1, yt, qe), this._envPlaceholder.needsUpdate = !0, this.environmentTexture = this._envPlaceholder, this.envTexSize = new Nt(), this.envCDFStorageAttr = null, this.envCDFStorageNode = null, this._initCDFStorageBuffers(), this.environmentRotationMatrix = new
|
|
1741
|
+
]), 1, 1, yt, qe), this._envPlaceholder.needsUpdate = !0, this.environmentTexture = this._envPlaceholder, this.envTexSize = new Nt(), this.envCDFStorageAttr = null, this.envCDFStorageNode = null, this._initCDFStorageBuffers(), this.environmentRotationMatrix = new it(), this.cdfBuildTime = 0, this.envParams = {
|
|
1742
1742
|
mode: "hdri",
|
|
1743
1743
|
gradientZenithColor: new Re(X.gradientZenithColor),
|
|
1744
1744
|
gradientHorizonColor: new Re(X.gradientHorizonColor),
|
|
@@ -4435,9 +4435,9 @@ var qo = 8, Jo = 2, Yo = Qt({
|
|
|
4435
4435
|
});
|
|
4436
4436
|
}), c;
|
|
4437
4437
|
}), gs = /* @__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", [yi, xi]), _s = p(([e, t, n, r, i, a, o, s, c, l, u, g, _, v, y, b, x, S, C, w, D, O, k, j, ee, te, P, re, F, ie, ae, oe, L, se, ce, le, ue, de, fe, pe, me, he, ge, _e, ve, ye, be, B, xe, V]) => {
|
|
4438
|
-
let H = W(0).toVar(), Se = W(1).toVar(), Ce = M(1).toVar(), we = T(!1).toVar(), U = M(0).toVar(), K = W(0).toVar(), Te = W(0).toVar(), Ee = M(-1e3).toVar(), De = e.origin.toVar(), Oe = M(1e10).toVar(), ke =
|
|
4438
|
+
let H = W(0).toVar(), Se = W(1).toVar(), Ce = M(1).toVar(), we = T(!1).toVar(), U = M(0).toVar(), K = W(0).toVar(), Te = W(0).toVar(), Ee = M(-1e3).toVar(), De = e.origin.toVar(), Oe = M(1e10).toVar(), ke = T(!1).toVar(), Ae = N(0).toVar(), je = M(1).toVar(), Me = M(1).toVar(), Ne = M(1).toVar(), Pe = oe.toVar(), Fe = L.toVar(), Ie = N(os).toVar(), Le = T(!0).toVar(), Re = T(!1).toVar(), ze = T(!1).toVar(), Be = T(!1).toVar();
|
|
4439
4439
|
T(!1).toVar();
|
|
4440
|
-
let
|
|
4440
|
+
let Ve = M(0).toVar(), He = N(-1).toVar(), Ue = Jr({
|
|
4441
4441
|
isMetallic: !1,
|
|
4442
4442
|
isRough: !1,
|
|
4443
4443
|
isSmooth: !1,
|
|
@@ -4445,14 +4445,14 @@ var qo = 8, Jo = 2, Yo = Qt({
|
|
|
4445
4445
|
hasClearcoat: !1,
|
|
4446
4446
|
isEmissive: !1,
|
|
4447
4447
|
complexityScore: M(0)
|
|
4448
|
-
}).toVar(),
|
|
4448
|
+
}).toVar(), We = Wr({
|
|
4449
4449
|
specular: M(.5),
|
|
4450
4450
|
diffuse: M(.5),
|
|
4451
4451
|
sheen: M(0),
|
|
4452
4452
|
clearcoat: M(0),
|
|
4453
4453
|
transmission: M(0),
|
|
4454
4454
|
iridescence: M(0)
|
|
4455
|
-
}).toVar(),
|
|
4455
|
+
}).toVar(), Ge = Xr({
|
|
4456
4456
|
F0: W(.04),
|
|
4457
4457
|
NoV: M(1),
|
|
4458
4458
|
diffuseColor: W(0),
|
|
@@ -4464,24 +4464,24 @@ var qo = 8, Jo = 2, Yo = Qt({
|
|
|
4464
4464
|
metalFactor: M(.5),
|
|
4465
4465
|
iorFactor: M(1),
|
|
4466
4466
|
maxSheenColor: M(0)
|
|
4467
|
-
}).toVar(),
|
|
4467
|
+
}).toVar(), Ke = N(0).toVar(), qe = e.origin.toVar(), Je = e.direction.toVar();
|
|
4468
4468
|
return h({
|
|
4469
4469
|
start: N(0),
|
|
4470
4470
|
end: oe.add(L).add(1),
|
|
4471
4471
|
type: "int",
|
|
4472
4472
|
condition: "<"
|
|
4473
4473
|
}, ({ i: e }) => {
|
|
4474
|
-
|
|
4474
|
+
Pe.assign(oe.sub(Ke)), Le.assign(e.equal(N(0))), m(Ke.greaterThan(oe), () => {
|
|
4475
4475
|
d();
|
|
4476
4476
|
});
|
|
4477
4477
|
let r = z(e.greaterThan(N(0)), de, M(1)), h = zr({
|
|
4478
|
-
origin:
|
|
4479
|
-
direction:
|
|
4478
|
+
origin: qe,
|
|
4479
|
+
direction: Je
|
|
4480
4480
|
}), L = Hr.wrap(Ii(h, i, a, o)).toVar();
|
|
4481
4481
|
m(L.didHit.not(), () => {
|
|
4482
|
-
let t = hs(
|
|
4482
|
+
let t = hs(Le, Je, k, ee, j, ie, ce, se), n = M(1).toVar();
|
|
4483
4483
|
m(U.greaterThan(0).and(ie).and(ae), () => {
|
|
4484
|
-
let e = Hi(k,
|
|
4484
|
+
let e = Hi(k, Je, ee, P, re, F).w.toVar();
|
|
4485
4485
|
m(e.greaterThan(0), () => {
|
|
4486
4486
|
n.assign(gi({
|
|
4487
4487
|
pdf1: U,
|
|
@@ -4499,102 +4499,102 @@ var qo = 8, Jo = 2, Yo = Qt({
|
|
|
4499
4499
|
Ce.mulAssign(t.a);
|
|
4500
4500
|
}), d();
|
|
4501
4501
|
});
|
|
4502
|
-
let G = Br.wrap(Ti(L.materialIndex, o)).toVar(),
|
|
4502
|
+
let G = Br.wrap(Ti(L.materialIndex, o)).toVar(), Ye = L.uv.toVar(), Xe = L.normal.toVar();
|
|
4503
4503
|
m(G.displacementMapIndex.greaterThanEqual(N(0)).and(G.displacementScale.greaterThan(0)), () => {
|
|
4504
4504
|
let t = sa.wrap(ca(h, L, a, v, G, e)).toVar();
|
|
4505
|
-
|
|
4505
|
+
Ye.assign(t.uv), Xe.assign(t.normal), L.hitPoint.assign(t.hitPoint);
|
|
4506
4506
|
});
|
|
4507
|
-
let
|
|
4508
|
-
G.color.assign(
|
|
4509
|
-
let
|
|
4507
|
+
let Ze = qr.wrap(ea(s, c, l, u, g, _, G, Ye, L.normal)).toVar();
|
|
4508
|
+
G.color.assign(Ze.albedo), G.metalness.assign(E(Ze.metalness, 0, 1)), G.roughness.assign(E(Ze.roughness, ii, 1));
|
|
4509
|
+
let Qe = Ze.normal.toVar();
|
|
4510
4510
|
m(G.displacementMapIndex.greaterThanEqual(N(0)).and(G.displacementScale.greaterThan(0)), () => {
|
|
4511
|
-
|
|
4512
|
-
});
|
|
4513
|
-
let
|
|
4514
|
-
m(
|
|
4515
|
-
|
|
4516
|
-
}).ElseIf(
|
|
4517
|
-
|
|
4518
|
-
}).ElseIf(
|
|
4519
|
-
|
|
4520
|
-
});
|
|
4521
|
-
let
|
|
4522
|
-
m(
|
|
4511
|
+
Qe.assign(R(Xe.add(Ze.normal.sub(L.normal))));
|
|
4512
|
+
});
|
|
4513
|
+
let $e = M(1).toVar(), et = M(1).toVar();
|
|
4514
|
+
m(Ae.equal(N(1)), () => {
|
|
4515
|
+
$e.assign(je);
|
|
4516
|
+
}).ElseIf(Ae.equal(N(2)), () => {
|
|
4517
|
+
$e.assign(Me), et.assign(je);
|
|
4518
|
+
}).ElseIf(Ae.equal(N(3)), () => {
|
|
4519
|
+
$e.assign(Ne), et.assign(Me);
|
|
4520
|
+
});
|
|
4521
|
+
let tt = Ia.wrap(Wa(h, L.hitPoint, Qe, G, t, Fe, $e, et)).toVar();
|
|
4522
|
+
m(tt.continueRay, () => {
|
|
4523
4523
|
let e = T(!1).toVar();
|
|
4524
|
-
m(
|
|
4525
|
-
|
|
4526
|
-
m(
|
|
4527
|
-
m(
|
|
4528
|
-
|
|
4529
|
-
Ae.assign(G.ior);
|
|
4530
|
-
}).ElseIf(ke.equal(N(2)), () => {
|
|
4524
|
+
m(tt.isTransmissive.and(Fe.greaterThan(N(0))), () => {
|
|
4525
|
+
Fe.subAssign(1), Ie.assign(N(cs)), e.assign(T(!0)), m(tt.didReflect.not(), () => {
|
|
4526
|
+
m(tt.entering, () => {
|
|
4527
|
+
m(Ae.lessThan(N(3)), () => {
|
|
4528
|
+
Ae.addAssign(1), m(Ae.equal(N(1)), () => {
|
|
4531
4529
|
je.assign(G.ior);
|
|
4532
|
-
}).ElseIf(
|
|
4530
|
+
}).ElseIf(Ae.equal(N(2)), () => {
|
|
4533
4531
|
Me.assign(G.ior);
|
|
4532
|
+
}).ElseIf(Ae.equal(N(3)), () => {
|
|
4533
|
+
Ne.assign(G.ior);
|
|
4534
4534
|
});
|
|
4535
4535
|
});
|
|
4536
4536
|
}).Else(() => {
|
|
4537
|
-
m(
|
|
4538
|
-
|
|
4537
|
+
m(Ae.greaterThan(N(0)), () => {
|
|
4538
|
+
Ae.subAssign(1);
|
|
4539
4539
|
});
|
|
4540
4540
|
});
|
|
4541
4541
|
});
|
|
4542
|
-
}).ElseIf(
|
|
4542
|
+
}).ElseIf(tt.isAlphaSkip, () => {
|
|
4543
4543
|
e.assign(T(!0));
|
|
4544
|
-
}), Se.mulAssign(
|
|
4545
|
-
Ce.mulAssign(
|
|
4544
|
+
}), Se.mulAssign(tt.throughput), m(le.not(), () => {
|
|
4545
|
+
Ce.mulAssign(tt.alpha);
|
|
4546
4546
|
});
|
|
4547
|
-
let t = z(
|
|
4548
|
-
|
|
4549
|
-
|
|
4547
|
+
let t = z(tt.entering, Qe, Qe.negate()), n = z(tt.didReflect, t, Je);
|
|
4548
|
+
qe.assign(L.hitPoint.add(n.mul(.001))), Je.assign(tt.direction), Le.assign(T(!1)), Re.assign(T(!1)), Be.assign(T(!1)), m(e.not(), () => {
|
|
4549
|
+
Ke.addAssign(1);
|
|
4550
4550
|
}), f();
|
|
4551
4551
|
}), m(le.not(), () => {
|
|
4552
|
-
Ce.mulAssign(
|
|
4552
|
+
Ce.mulAssign(tt.alpha);
|
|
4553
4553
|
}), we.assign(T(!0));
|
|
4554
|
-
let
|
|
4555
|
-
G.sheenRoughness.assign(E(G.sheenRoughness, ii, 1)), m(
|
|
4556
|
-
|
|
4554
|
+
let nt = bn(B, n, e, t, N(-1), xe, V).toVar(), rt = Je.negate().toVar();
|
|
4555
|
+
G.sheenRoughness.assign(E(G.sheenRoughness, ii, 1)), m(Be.not(), () => {
|
|
4556
|
+
Ge.assign(Oa(Qe, rt, G, Ze, Ue)), Be.assign(T(!0));
|
|
4557
4557
|
});
|
|
4558
|
-
let
|
|
4558
|
+
let it = W(0).toVar(), at = W(0).toVar(), ot = M(0).toVar();
|
|
4559
4559
|
m(G.clearcoat.greaterThan(0), () => {
|
|
4560
|
-
let e = qa.wrap(Ja(h, L, G,
|
|
4561
|
-
|
|
4560
|
+
let e = qa.wrap(Ja(h, L, G, nt, t));
|
|
4561
|
+
it.assign(e.L), at.assign(e.brdf), ot.assign(e.pdf);
|
|
4562
4562
|
}).Else(() => {
|
|
4563
|
-
let e = Ur.wrap(fs(
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
}),
|
|
4567
|
-
}), m(ne(
|
|
4563
|
+
let e = Ur.wrap(fs(rt, Qe, G, L.materialIndex, nt, t, ze, He, Ue, Re, We, Be, Ge));
|
|
4564
|
+
it.assign(e.direction), at.assign(e.value), ot.assign(e.pdf), m(He.notEqual(L.materialIndex).or(ze.not()), () => {
|
|
4565
|
+
Ue.assign(Si(G.metalness, G.roughness, G.transmission, G.clearcoat, G.emissive));
|
|
4566
|
+
}), ze.assign(T(!0)), He.assign(L.materialIndex), Re.assign(T(!0));
|
|
4567
|
+
}), m(ne(Ze.emissive).greaterThan(0), () => {
|
|
4568
4568
|
let t = M(1).toVar();
|
|
4569
4569
|
m(pe.equal(N(1)).and(ge.greaterThan(N(0))).and(U.greaterThan(0)), () => {
|
|
4570
|
-
let e = Zo(L.triangleIndex, L.dst,
|
|
4570
|
+
let e = Zo(L.triangleIndex, L.dst, Je, qe, a, o, _e);
|
|
4571
4571
|
t.assign(hi({
|
|
4572
4572
|
pdf1: U,
|
|
4573
4573
|
pdf2: e
|
|
4574
4574
|
}));
|
|
4575
4575
|
}), H.addAssign(gs({
|
|
4576
|
-
contribution:
|
|
4576
|
+
contribution: Ze.emissive.mul(Se).mul(r).mul(t),
|
|
4577
4577
|
pathLength: M(e),
|
|
4578
4578
|
fireflyThreshold: ue,
|
|
4579
4579
|
frame: N(V)
|
|
4580
4580
|
}));
|
|
4581
4581
|
});
|
|
4582
|
-
let
|
|
4582
|
+
let st = Oo(L.hitPoint, Qe, G, rt, it, ot, at, n, e, t, y, b, x, S, C, w, D, O, i, a, o, k, j, ee, te, P, re, F, ie);
|
|
4583
4583
|
H.addAssign(gs({
|
|
4584
|
-
contribution:
|
|
4584
|
+
contribution: st.mul(Se).mul(r),
|
|
4585
4585
|
pathLength: M(e),
|
|
4586
4586
|
fireflyThreshold: ue,
|
|
4587
4587
|
frame: N(V)
|
|
4588
4588
|
})), m(pe.equal(N(1)).and(ge.greaterThan(N(0))), () => {
|
|
4589
4589
|
let n = p(([e, t, n, r]) => ho(e, t, n, r, Li, i, a, o));
|
|
4590
4590
|
m(be.greaterThan(N(0)), () => {
|
|
4591
|
-
let i = Fo.wrap(as(L.hitPoint,
|
|
4591
|
+
let i = Fo.wrap(as(L.hitPoint, Qe, t, ye, me, he, a));
|
|
4592
4592
|
m(e.greaterThan(N(1)).and(G.roughness.greaterThan(.9)).and(G.metalness.lessThan(.1)).not().and(i.valid).and(i.pdf.greaterThan(0)), () => {
|
|
4593
|
-
let a = I(M(0), A(
|
|
4593
|
+
let a = I(M(0), A(Qe, i.direction));
|
|
4594
4594
|
m(a.greaterThan(0), () => {
|
|
4595
|
-
let o = go(L.hitPoint,
|
|
4595
|
+
let o = go(L.hitPoint, Qe, G), s = L.hitPoint.add(o), c = i.distance.sub(.001), l = n(s, i.direction, c, t);
|
|
4596
4596
|
m(l.greaterThan(0), () => {
|
|
4597
|
-
let t = Ga(
|
|
4597
|
+
let t = Ga(rt, i.direction, Qe, G), n = Do(rt, i.direction, Qe, G), o = z(n.greaterThan(0), hi({
|
|
4598
4598
|
pdf1: i.pdf,
|
|
4599
4599
|
pdf2: n
|
|
4600
4600
|
}), M(1)), s = i.emission.mul(t).mul(a).div(i.pdf).mul(l).mul(ve).mul(o);
|
|
@@ -4608,7 +4608,7 @@ var qo = 8, Jo = 2, Yo = Qt({
|
|
|
4608
4608
|
});
|
|
4609
4609
|
});
|
|
4610
4610
|
}).Else(() => {
|
|
4611
|
-
let i = ts(L.hitPoint,
|
|
4611
|
+
let i = ts(L.hitPoint, Qe, rt, G, fe, e, t, ve, me, he, ge, _e, a, n, Ga, go);
|
|
4612
4612
|
H.addAssign(gs({
|
|
4613
4613
|
contribution: i.mul(Se).mul(r),
|
|
4614
4614
|
pathLength: M(e),
|
|
@@ -4616,23 +4616,29 @@ var qo = 8, Jo = 2, Yo = Qt({
|
|
|
4616
4616
|
frame: N(V)
|
|
4617
4617
|
}));
|
|
4618
4618
|
});
|
|
4619
|
-
}), m(
|
|
4620
|
-
|
|
4619
|
+
}), m(Re.not().or(e.equal(N(0))), () => {
|
|
4620
|
+
Ue.assign(Jr.wrap(ds(G, L.materialIndex, ze, He, Ue))), ze.assign(T(!0)), He.assign(L.materialIndex);
|
|
4621
4621
|
});
|
|
4622
|
-
let
|
|
4623
|
-
Se.mulAssign(
|
|
4624
|
-
|
|
4622
|
+
let ct = Gr.wrap(Da(G, e, Ue, j, ae, ie)), q = eo.wrap(Po(rt, Qe, G, it, ot, at, n, e, t, ct, k, j, ee, P, re, F, ie, ae));
|
|
4623
|
+
Se.mulAssign(q.throughput), qe.assign(L.hitPoint.add(Qe.mul(.001))), Je.assign(q.direction), U.assign(q.combinedPdf), Le.assign(T(!1)), m(G.metalness.greaterThan(.7).and(G.roughness.lessThan(.3)), () => {
|
|
4624
|
+
Ie.assign(N(ss));
|
|
4625
4625
|
}).ElseIf(G.transmission.greaterThan(.5), () => {
|
|
4626
|
-
|
|
4626
|
+
Ie.assign(N(cs));
|
|
4627
4627
|
}).Else(() => {
|
|
4628
|
-
|
|
4628
|
+
Ie.assign(N(ls));
|
|
4629
4629
|
}), m(e.equal(N(0)).and(L.didHit), () => {
|
|
4630
|
-
|
|
4630
|
+
De.assign(L.hitPoint), Oe.assign(L.dst);
|
|
4631
|
+
}), m(ke.not().and(L.didHit), () => {
|
|
4632
|
+
K.assign(Qe), Te.assign(G.color.xyz), Ee.assign(M(L.materialIndex));
|
|
4633
|
+
let e = G.metalness.greaterThan(.7).and(G.roughness.lessThan(.3)), t = G.transmission.greaterThan(.5);
|
|
4634
|
+
m(e.or(t).not(), () => {
|
|
4635
|
+
ke.assign(T(!0));
|
|
4636
|
+
});
|
|
4631
4637
|
});
|
|
4632
|
-
let
|
|
4633
|
-
m(
|
|
4638
|
+
let lt = ms(e, Se, G, L.materialIndex, Je, t, ze, He, Ue, Re, Ve, ie, ae);
|
|
4639
|
+
m(lt.lessThanEqual(0), () => {
|
|
4634
4640
|
d();
|
|
4635
|
-
}), Se.divAssign(
|
|
4641
|
+
}), Se.divAssign(lt), Ke.addAssign(1), Re.assign(T(!1)), Be.assign(T(!1));
|
|
4636
4642
|
}), us({
|
|
4637
4643
|
radiance: G(H, Ce),
|
|
4638
4644
|
objectNormal: K,
|
|
@@ -4804,56 +4810,56 @@ var Ss = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4804
4810
|
pixelCoord: t,
|
|
4805
4811
|
rayIndex: N(0),
|
|
4806
4812
|
frame: o
|
|
4807
|
-
}).toVar(), Ye = N(t.y).mul(N(a.x)).add(N(t.x)).toVar(),
|
|
4813
|
+
}).toVar(), Ye = N(t.y).mul(N(a.x)).add(N(t.x)).toVar(), Xe = W(0, 0, 1).toVar(), Ze = M(1).toVar(), Qe = M(0).toVar(), $e = N(s).toVar();
|
|
4808
4814
|
m(o.greaterThan(V(2)).and(Me), () => {
|
|
4809
4815
|
let e = Cs(t, a, Ne, Pe, Fe);
|
|
4810
|
-
|
|
4816
|
+
$e.assign(e), m($e.equal(N(0)), () => {
|
|
4811
4817
|
m(Te.and(Ee), () => {
|
|
4812
4818
|
let e = be(De, We, 0);
|
|
4813
|
-
Ke.assign(e),
|
|
4819
|
+
Ke.assign(e), Qe.assign(e.w);
|
|
4814
4820
|
let t = be(Oe, We, 0);
|
|
4815
|
-
|
|
4821
|
+
Xe.assign(t.xyz.mul(2).sub(1)), Ze.assign(t.w);
|
|
4816
4822
|
}).Else(() => {
|
|
4817
|
-
|
|
4823
|
+
$e.assign(1);
|
|
4818
4824
|
});
|
|
4819
4825
|
});
|
|
4820
4826
|
});
|
|
4821
|
-
let
|
|
4827
|
+
let et = W(0).toVar(), tt = W(0).toVar(), nt = M(-1e3).toVar(), rt = U(2).div(a).toVar();
|
|
4822
4828
|
h({
|
|
4823
4829
|
start: N(0),
|
|
4824
|
-
end:
|
|
4830
|
+
end: $e,
|
|
4825
4831
|
type: "int",
|
|
4826
4832
|
condition: "<"
|
|
4827
4833
|
}, ({ i: e }) => {
|
|
4828
|
-
let n = dn({ state: Je.add(V(e)) }).toVar(), r = xn(t, e,
|
|
4834
|
+
let n = dn({ state: Je.add(V(e)) }).toVar(), r = xn(t, e, $e, n, a, o).toVar();
|
|
4829
4835
|
m(c.equal(N(9)), () => {
|
|
4830
4836
|
Ke.assign(G(r, 1, 1)), qe.assign(1), d();
|
|
4831
4837
|
});
|
|
4832
|
-
let i = r.sub(.5).mul(
|
|
4838
|
+
let i = r.sub(.5).mul(rt), s = Ge.add(i), h = zr.wrap(Ri(s, n, l, u, Ie, Le, Re, ze, Be, Ve, He)), M = G(0).toVar();
|
|
4833
4839
|
m(c.greaterThan(N(0)), () => {
|
|
4834
4840
|
M.assign(xs(h.origin, h.direction, g, _, v, P, re, ne, oe, c, K, t, a, y, b, x, S, C, w, p, f, o));
|
|
4835
4841
|
}).Else(() => {
|
|
4836
4842
|
let r = us.wrap(_s(h, n, e, Ye, g, _, v, y, b, x, S, C, w, T, E, D, O, k, A, j, ee, te, P, ne, re, F, ie, ae, I, oe, se, ce, le, fe, ue, de, pe, me, he, ge, _e, ve, ye, B, H, Se, Ce, t, a, o));
|
|
4837
4843
|
M.assign(r.radiance), m(e.equal(N(0)), () => {
|
|
4838
|
-
|
|
4839
|
-
|
|
4844
|
+
et.assign(r.objectNormal), tt.assign(r.objectColor), nt.assign(r.objectID), m(r.firstHitDistance.lessThan(1e9), () => {
|
|
4845
|
+
Xe.assign(R(r.objectNormal)), Ze.assign(Ss({
|
|
4840
4846
|
worldPos: r.firstHitPoint,
|
|
4841
4847
|
cameraProjectionMatrix: p,
|
|
4842
4848
|
cameraViewMatrix: f
|
|
4843
4849
|
}));
|
|
4844
4850
|
});
|
|
4845
4851
|
});
|
|
4846
|
-
}), Ke.addAssign(M),
|
|
4852
|
+
}), Ke.addAssign(M), Qe.addAssign(M.w), qe.addAssign(1);
|
|
4847
4853
|
}), m(qe.greaterThan(N(0)), () => {
|
|
4848
|
-
Ke.divAssign(M(qe)),
|
|
4854
|
+
Ke.divAssign(M(qe)), Qe.divAssign(M(qe));
|
|
4849
4855
|
});
|
|
4850
|
-
let
|
|
4856
|
+
let it = Ke.xyz.toVar(), at = G(Xe.mul(.5).add(.5), Ze).toVar(), ot = W(tt).toVar(), st = z(de, Qe, M(1)).toVar();
|
|
4851
4857
|
m(Te.and(je.not()).and(o.greaterThan(V(0))).and(Ee), () => {
|
|
4852
4858
|
let e = be(De, We, 0).toVar();
|
|
4853
|
-
|
|
4854
|
-
|
|
4859
|
+
it.assign(L(e.xyz, Ke.xyz, Ae)), at.assign(L(be(Oe, We, 0), at, Ae)), ot.assign(L(be(ke, We, 0).xyz, ot, Ae)), m(de, () => {
|
|
4860
|
+
st.assign(L(e.w, Qe, Ae));
|
|
4855
4861
|
});
|
|
4856
|
-
}), xe(n, Ue, G(
|
|
4862
|
+
}), xe(n, Ue, G(it.xyz, st)).toWriteOnly(), xe(r, Ue, at).toWriteOnly(), xe(i, Ue, G(ot, 1)).toWriteOnly();
|
|
4857
4863
|
}, Ts = class {
|
|
4858
4864
|
constructor(e = "Build") {
|
|
4859
4865
|
this.label = e, this.entries = /* @__PURE__ */ new Map(), this.order = [], this.totalStart = performance.now();
|
|
@@ -4934,7 +4940,7 @@ var Ss = /* @__PURE__ */ K("\n fn computeNDCDepth( worldPos: vec3f, cameraProjec
|
|
|
4934
4940
|
255,
|
|
4935
4941
|
255
|
|
4936
4942
|
]), 1, 1, 1);
|
|
4937
|
-
return e.minFilter =
|
|
4943
|
+
return e.minFilter = Xe, e.magFilter = Xe, e.generateMipmaps = !1, e.needsUpdate = !0, be(e);
|
|
4938
4944
|
}, f = e.materialData, p = f.albedoMaps ? be(f.albedoMaps) : d(), m = f.normalMaps ? be(f.normalMaps) : d(), h = f.bumpMaps ? be(f.bumpMaps) : d(), g = f.metalnessMaps ? be(f.metalnessMaps) : d(), _ = f.roughnessMaps ? be(f.roughnessMaps) : d(), v = f.emissiveMaps ? be(f.emissiveMaps) : d(), y = f.displacementMaps ? be(f.displacementMaps) : d();
|
|
4939
4945
|
po(p);
|
|
4940
4946
|
let b = {
|
|
@@ -6612,8 +6618,8 @@ var Xs = 16, Zs = class {
|
|
|
6612
6618
|
generateHash(e) {
|
|
6613
6619
|
let t = "";
|
|
6614
6620
|
for (let n of e) if (n?.image) {
|
|
6615
|
-
let e = n.image.width || 0, r = n.image.height || 0, i = n.image.src || n.uuid || "";
|
|
6616
|
-
t += `${e}x${r}_${i.slice(-8)}_`;
|
|
6621
|
+
let e = n.image.width || 0, r = n.image.height || 0, i = n.image.src || n.uuid || "", a = n.flipY === !1 ? "n" : "f";
|
|
6622
|
+
t += `${e}x${r}_${i.slice(-8)}_${a}_`;
|
|
6617
6623
|
}
|
|
6618
6624
|
return t + e.length;
|
|
6619
6625
|
}
|
|
@@ -6729,28 +6735,32 @@ var Xs = 16, Zs = class {
|
|
|
6729
6735
|
}
|
|
6730
6736
|
async prepareTexturesForWorkerDirect(e) {
|
|
6731
6737
|
let t = [];
|
|
6732
|
-
for (let n of e)
|
|
6733
|
-
if (
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6738
|
+
for (let n of e) {
|
|
6739
|
+
if (!n?.image) continue;
|
|
6740
|
+
let e = n.flipY !== !1;
|
|
6741
|
+
try {
|
|
6742
|
+
if (typeof createImageBitmap < "u" && n.image instanceof HTMLImageElement) {
|
|
6743
|
+
let r = await createImageBitmap(n.image, { imageOrientation: e ? "flipY" : "none" });
|
|
6744
|
+
t.push({
|
|
6745
|
+
bitmap: r,
|
|
6746
|
+
width: n.image.width,
|
|
6747
|
+
height: n.image.height,
|
|
6748
|
+
isDirect: !0
|
|
6749
|
+
});
|
|
6750
|
+
} else {
|
|
6751
|
+
let r = n.image.width, i = n.image.height, a = await createImageBitmap(n.image, { imageOrientation: e ? "flipY" : "none" }), o = this.canvasPool.getCanvasWithContext(r, i);
|
|
6752
|
+
o.context.drawImage(a, 0, 0), a.close();
|
|
6753
|
+
let s = o.context.getImageData(0, 0, r, i);
|
|
6754
|
+
t.push({
|
|
6755
|
+
data: s.data.buffer,
|
|
6756
|
+
width: r,
|
|
6757
|
+
height: i,
|
|
6758
|
+
isImageData: !0
|
|
6759
|
+
}), this.canvasPool.releaseCanvasWithContext(o);
|
|
6760
|
+
}
|
|
6761
|
+
} catch (e) {
|
|
6762
|
+
console.warn("Failed to prepare texture for worker:", e);
|
|
6751
6763
|
}
|
|
6752
|
-
} catch (e) {
|
|
6753
|
-
console.warn("Failed to prepare texture for worker:", e);
|
|
6754
6764
|
}
|
|
6755
6765
|
return t;
|
|
6756
6766
|
}
|
|
@@ -6769,12 +6779,13 @@ var Xs = 16, Zs = class {
|
|
|
6769
6779
|
for (let e = 0; e < n.length; e += t) {
|
|
6770
6780
|
let a = Math.min(e + t, n.length), s = [];
|
|
6771
6781
|
for (let t = e; t < a; t++) {
|
|
6772
|
-
let e = n[t], a = createImageBitmap(e.image, {
|
|
6782
|
+
let e = n[t], a = e.flipY !== !1, o = createImageBitmap(e.image, {
|
|
6773
6783
|
resizeWidth: r,
|
|
6774
6784
|
resizeHeight: i,
|
|
6775
|
-
resizeQuality: "high"
|
|
6785
|
+
resizeQuality: "high",
|
|
6786
|
+
imageOrientation: a ? "flipY" : "none"
|
|
6776
6787
|
});
|
|
6777
|
-
s.push(
|
|
6788
|
+
s.push(o.then((e) => ({
|
|
6778
6789
|
bitmap: e,
|
|
6779
6790
|
index: t
|
|
6780
6791
|
})));
|
|
@@ -6796,10 +6807,15 @@ var Xs = 16, Zs = class {
|
|
|
6796
6807
|
let { maxWidth: n, maxHeight: r } = this.calculateOptimalDimensions(t), i = t.length, a = this.bufferPool.getBuffer(n * r * i * 4, Uint8Array), o = this.canvasPool.getCanvasWithContext(n, r);
|
|
6797
6808
|
o.context.imageSmoothingEnabled = !0, o.context.imageSmoothingQuality = "high";
|
|
6798
6809
|
for (let e = 0; e < t.length; e++) {
|
|
6799
|
-
let i = t[e]
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6810
|
+
let i = t[e], s = await createImageBitmap(i.image, {
|
|
6811
|
+
resizeWidth: n,
|
|
6812
|
+
resizeHeight: r,
|
|
6813
|
+
resizeQuality: "high",
|
|
6814
|
+
imageOrientation: i.flipY === !1 ? "none" : "flipY"
|
|
6815
|
+
});
|
|
6816
|
+
o.context.clearRect(0, 0, n, r), o.context.drawImage(s, 0, 0), s.close();
|
|
6817
|
+
let c = o.context.getImageData(0, 0, n, r), l = n * r * 4 * e;
|
|
6818
|
+
a.set(c.data, l), e % $n.STREAM_BATCH_SIZE === 0 && await new Promise((e) => setTimeout(e, 0));
|
|
6803
6819
|
}
|
|
6804
6820
|
return this.canvasPool.releaseCanvasWithContext(o), this.createDataArrayTextureFromBuffer(a, n, r, i);
|
|
6805
6821
|
}
|
|
@@ -6809,10 +6825,15 @@ var Xs = 16, Zs = class {
|
|
|
6809
6825
|
let { maxWidth: n, maxHeight: r } = this.calculateOptimalDimensions(t), i = t.length, a = this.bufferPool.getBuffer(n * r * i * 4, Uint8Array), o = this.canvasPool.getCanvasWithContext(n, r);
|
|
6810
6826
|
o.context.imageSmoothingEnabled = !0, o.context.imageSmoothingQuality = "high";
|
|
6811
6827
|
for (let e = 0; e < t.length; e++) {
|
|
6812
|
-
let i = t[e]
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6828
|
+
let i = t[e], s = await createImageBitmap(i.image, {
|
|
6829
|
+
resizeWidth: n,
|
|
6830
|
+
resizeHeight: r,
|
|
6831
|
+
resizeQuality: "high",
|
|
6832
|
+
imageOrientation: i.flipY === !1 ? "none" : "flipY"
|
|
6833
|
+
});
|
|
6834
|
+
o.context.clearRect(0, 0, n, r), o.context.drawImage(s, 0, 0), s.close();
|
|
6835
|
+
let c = o.context.getImageData(0, 0, n, r), l = n * r * 4 * e;
|
|
6836
|
+
a.set(c.data, l);
|
|
6816
6837
|
}
|
|
6817
6838
|
return this.canvasPool.releaseCanvasWithContext(o), this.createDataArrayTextureFromBuffer(a, n, r, i);
|
|
6818
6839
|
}
|
|
@@ -7054,7 +7075,7 @@ var Xs = 16, Zs = class {
|
|
|
7054
7075
|
}
|
|
7055
7076
|
createDataArrayTextureFromBuffer(e, t, n, r) {
|
|
7056
7077
|
let i = new ze(e, t, n, r);
|
|
7057
|
-
i.minFilter =
|
|
7078
|
+
i.minFilter = Xe, i.magFilter = Xe, i.format = yt, i.type = Mt, i.needsUpdate = !0, i.generateMipmaps = !1, i.userData = {
|
|
7058
7079
|
buffer: e,
|
|
7059
7080
|
bufferType: Uint8Array
|
|
7060
7081
|
};
|
|
@@ -7070,6 +7091,7 @@ var Xs = 16, Zs = class {
|
|
|
7070
7091
|
let e = n.mipmaps[0], i = t.length;
|
|
7071
7092
|
t.push(null), r.push({
|
|
7072
7093
|
index: i,
|
|
7094
|
+
flipY: n.flipY,
|
|
7073
7095
|
promise: ac(e.data, e.width, e.height)
|
|
7074
7096
|
});
|
|
7075
7097
|
continue;
|
|
@@ -7082,6 +7104,7 @@ var Xs = 16, Zs = class {
|
|
|
7082
7104
|
let e = t.length;
|
|
7083
7105
|
t.push(null), r.push({
|
|
7084
7106
|
index: e,
|
|
7107
|
+
flipY: n.flipY,
|
|
7085
7108
|
promise: ac(n.image.data, n.image.width, n.image.height)
|
|
7086
7109
|
});
|
|
7087
7110
|
continue;
|
|
@@ -7091,11 +7114,14 @@ var Xs = 16, Zs = class {
|
|
|
7091
7114
|
if (r.length > 0) {
|
|
7092
7115
|
let e = await Promise.allSettled(r.map((e) => e.promise));
|
|
7093
7116
|
for (let i = 0; i < r.length; i++) {
|
|
7094
|
-
let { index: a } = r[i],
|
|
7095
|
-
if (
|
|
7096
|
-
let e =
|
|
7097
|
-
n.push(e), t[a] = {
|
|
7098
|
-
|
|
7117
|
+
let { index: a, flipY: o } = r[i], s = e[i];
|
|
7118
|
+
if (s.status === "fulfilled") {
|
|
7119
|
+
let e = s.value;
|
|
7120
|
+
n.push(e), t[a] = {
|
|
7121
|
+
image: e,
|
|
7122
|
+
flipY: o
|
|
7123
|
+
};
|
|
7124
|
+
} else console.warn("[TextureCreator] Failed to create ImageBitmap:", s.reason);
|
|
7099
7125
|
}
|
|
7100
7126
|
}
|
|
7101
7127
|
for (let e = 0; e < t.length; e++) if (t[e] === null) {
|
|
@@ -7105,7 +7131,10 @@ var Xs = 16, Zs = class {
|
|
|
7105
7131
|
255,
|
|
7106
7132
|
255
|
|
7107
7133
|
]), i = await createImageBitmap(new ImageData(r, 1, 1));
|
|
7108
|
-
n.push(i), t[e] = {
|
|
7134
|
+
n.push(i), t[e] = {
|
|
7135
|
+
image: i,
|
|
7136
|
+
flipY: !1
|
|
7137
|
+
};
|
|
7109
7138
|
}
|
|
7110
7139
|
return {
|
|
7111
7140
|
normalized: t,
|
|
@@ -7119,7 +7148,7 @@ var Xs = 16, Zs = class {
|
|
|
7119
7148
|
255,
|
|
7120
7149
|
255
|
|
7121
7150
|
]), 1, 1, 1);
|
|
7122
|
-
return e.minFilter =
|
|
7151
|
+
return e.minFilter = Xe, e.magFilter = Xe, e.format = yt, e.type = Mt, e.needsUpdate = !0, e.generateMipmaps = !1, e;
|
|
7123
7152
|
}
|
|
7124
7153
|
combineTextureResults(e) {
|
|
7125
7154
|
return e[0];
|
|
@@ -7147,8 +7176,8 @@ var oc = 128, sc = class {
|
|
|
7147
7176
|
,
|
|
7148
7177
|
].fill().map(() => new Nt())
|
|
7149
7178
|
}, this._matrixPool = {
|
|
7150
|
-
mat3: new
|
|
7151
|
-
mat4: new
|
|
7179
|
+
mat3: new rt(),
|
|
7180
|
+
mat4: new it()
|
|
7152
7181
|
}, this.resetArrays(), this.triangleCount = 0, this.currentTriangleIndex = 0;
|
|
7153
7182
|
}
|
|
7154
7183
|
_getVec3(e = 0) {
|
|
@@ -7332,7 +7361,7 @@ var oc = 128, sc = class {
|
|
|
7332
7361
|
};
|
|
7333
7362
|
}
|
|
7334
7363
|
getTextureMatrix(e) {
|
|
7335
|
-
return e ? (e.updateMatrix(), e.matrix.elements) : new
|
|
7364
|
+
return e ? (e.updateMatrix(), e.matrix.elements) : new rt().elements;
|
|
7336
7365
|
}
|
|
7337
7366
|
getMaterialSide(e) {
|
|
7338
7367
|
if (e.transmission > 0) return 2;
|
|
@@ -7587,7 +7616,7 @@ var oc = 128, sc = class {
|
|
|
7587
7616
|
let t = Math.ceil(Math.sqrt(this.emissiveCount)), n = Math.ceil(this.emissiveCount / t), r = t * n * 4, i = new Float32Array(r);
|
|
7588
7617
|
i.set(e);
|
|
7589
7618
|
let a = new Be(i, t, n, yt, qe);
|
|
7590
|
-
return a.needsUpdate = !0, a.generateMipmaps = !1, a.minFilter =
|
|
7619
|
+
return a.needsUpdate = !0, a.generateMipmaps = !1, a.minFilter = q, a.magFilter = q, console.log(`[EmissiveTriangleBuilder] Created ${t}x${n} emissive texture (${this.emissiveCount} emissives)`), a;
|
|
7591
7620
|
}
|
|
7592
7621
|
createEmissiveRawData() {
|
|
7593
7622
|
if (this.emissiveCount === 0) return new Float32Array(8);
|
|
@@ -8442,7 +8471,7 @@ var oc = 128, sc = class {
|
|
|
8442
8471
|
count: this.triangleCount
|
|
8443
8472
|
}), this.materialData.callbacks.onTriangleDataChanged = () => {
|
|
8444
8473
|
this.triangleStorageAttr && (this.triangleStorageAttr.needsUpdate = !0);
|
|
8445
|
-
}, this.environment = new Rr(this.scene, this.uniforms), this.environment.callbacks.onReset = () => this.reset(), this.environment.callbacks.getSceneTextureNodes = () => this.shaderBuilder.getSceneTextureNodes(), this.shaderBuilder = new Ds(), this._initRenderingState(), this.setupBlueNoise(), this.tempVector2 = new Nt(), this.lastCameraMatrix = new
|
|
8474
|
+
}, this.environment = new Rr(this.scene, this.uniforms), this.environment.callbacks.onReset = () => this.reset(), this.environment.callbacks.getSceneTextureNodes = () => this.shaderBuilder.getSceneTextureNodes(), this.shaderBuilder = new Ds(), this._initRenderingState(), this.setupBlueNoise(), this.tempVector2 = new Nt(), this.lastCameraMatrix = new it(), this.lastProjectionMatrix = new it(), this.lastRenderMode = -1, this.tileCompletionFrame = 0, this.renderModeChangeTimeout = null, this.renderModeChangeDelay = 50, this.pendingRenderMode = null, this.adaptiveSamplingFrameToggle = !1, this.lastInteractionModeState = !1, this.cameraChanged = !1, this.tileChanged = !1, this.updateCompletionThreshold();
|
|
8446
8475
|
}
|
|
8447
8476
|
_initDataTextures() {
|
|
8448
8477
|
this.triangleStorageAttr = null, this.triangleStorageNode = null, this.triangleCount = 0, this.bvhStorageAttr = null, this.bvhStorageNode = null, this.bvhNodeCount = 0, this.directionalLightsData = null, this.pointLightsData = null, this.spotLightsData = null, this.areaLightsData = null, this.stbnScalarTexture = null, this.stbnVec2Texture = null, this.lightStorageAttr = new o(new Float32Array(16), 4), this.lightStorageNode = ve(this.lightStorageAttr, "vec4", 1).toReadOnly(), this._lbvhDataCache = null, this._emissiveDataCache = null, this._instanceTable = null, this.adaptiveSamplingTexture = null, this.spheres = [];
|
|
@@ -8539,7 +8568,7 @@ var oc = 128, sc = class {
|
|
|
8539
8568
|
setupBlueNoise() {
|
|
8540
8569
|
let e = new kt();
|
|
8541
8570
|
e.setCrossOrigin("anonymous");
|
|
8542
|
-
let t = (e) => (e.minFilter =
|
|
8571
|
+
let t = (e) => (e.minFilter = q, e.magFilter = q, e.wrapS = Ct, e.wrapT = Ct, e.generateMipmaps = !1, e);
|
|
8543
8572
|
e.load(pc, (e) => {
|
|
8544
8573
|
this.stbnScalarTexture = t(e), on.value = e, console.log(`PathTracer: STBN scalar atlas loaded ${e.image.width}x${e.image.height}`);
|
|
8545
8574
|
}), e.load(mc, (e) => {
|
|
@@ -8829,13 +8858,13 @@ var oc = 128, sc = class {
|
|
|
8829
8858
|
super("NormalDepth", {
|
|
8830
8859
|
...t,
|
|
8831
8860
|
executionMode: Cn.ALWAYS
|
|
8832
|
-
}), this.renderer = e, this.pathTracer = t.pathTracer, this._dirty = !0, this.cameraWorldMatrix = H(new
|
|
8861
|
+
}), this.renderer = e, this.pathTracer = t.pathTracer, this._dirty = !0, this.cameraWorldMatrix = H(new it(), "mat4"), this.cameraProjectionMatrixInverse = H(new it(), "mat4"), this.resolutionWidth = H(t.width || 1), this.resolutionHeight = H(t.height || 1);
|
|
8833
8862
|
let n = t.width || 1, r = t.height || 1;
|
|
8834
|
-
this._outputStorageTex = new s(n, r), this._outputStorageTex.type = Ye, this._outputStorageTex.format = yt, this._outputStorageTex.minFilter =
|
|
8863
|
+
this._outputStorageTex = new s(n, r), this._outputStorageTex.type = Ye, this._outputStorageTex.format = yt, this._outputStorageTex.minFilter = q, this._outputStorageTex.magFilter = q, this.renderTarget = new i(n, r, {
|
|
8835
8864
|
type: Ye,
|
|
8836
8865
|
format: yt,
|
|
8837
|
-
minFilter:
|
|
8838
|
-
magFilter:
|
|
8866
|
+
minFilter: q,
|
|
8867
|
+
magFilter: q,
|
|
8839
8868
|
depthBuffer: !1,
|
|
8840
8869
|
stencilBuffer: !1
|
|
8841
8870
|
}), this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._triStorageNode = null, this._bvhStorageNode = null, this._matStorageNode = null, this._lastTriAttr = null, this._lastBvhAttr = null, this._lastMatAttr = null, this._computeNode = null, this._computeBuilt = !1;
|
|
@@ -8909,12 +8938,12 @@ var oc = 128, sc = class {
|
|
|
8909
8938
|
executionMode: Cn.ALWAYS
|
|
8910
8939
|
}), this.renderer = e, this.camera = t, this.pathTracer = n.pathTracer || null;
|
|
8911
8940
|
let r = n.width || 1, a = n.height || 1;
|
|
8912
|
-
this.prevViewProjectionMatrix = new
|
|
8941
|
+
this.prevViewProjectionMatrix = new it(), this.currentViewProjectionMatrix = new it(), this.matricesInitialized = !1, this.isFirstFrame = !0, this.frameCount = 0, this.cameraWorldMatrix = H(new it(), "mat4"), this.cameraProjectionMatrixInverse = H(new it(), "mat4"), this.prevVP = H(new it(), "mat4"), this.isFirstFrameU = H(1), this.deltaTime = H(1 / 60), this.velocityScale = H(1), this.resolutionWidth = H(r), this.resolutionHeight = H(a), this._normalDepthTexNode = new c(), this._screenSpaceStorageTex = new s(r, a), this._screenSpaceStorageTex.type = Ye, this._screenSpaceStorageTex.format = yt, this._screenSpaceStorageTex.minFilter = q, this._screenSpaceStorageTex.magFilter = q, this._worldSpaceStorageTex = new s(r, a), this._worldSpaceStorageTex.type = Ye, this._worldSpaceStorageTex.format = yt, this._worldSpaceStorageTex.minFilter = q, this._worldSpaceStorageTex.magFilter = q;
|
|
8913
8942
|
let o = {
|
|
8914
8943
|
type: Ye,
|
|
8915
8944
|
format: yt,
|
|
8916
|
-
minFilter:
|
|
8917
|
-
magFilter:
|
|
8945
|
+
minFilter: q,
|
|
8946
|
+
magFilter: q,
|
|
8918
8947
|
depthBuffer: !1,
|
|
8919
8948
|
stencilBuffer: !1
|
|
8920
8949
|
};
|
|
@@ -9179,11 +9208,11 @@ var bc = class extends wn {
|
|
|
9179
9208
|
executionMode: Cn.PER_CYCLE
|
|
9180
9209
|
}), this.renderer = e, this.debugContainer = t.debugContainer || null, this.temporalAlpha = H(t.temporalAlpha ?? .1), this.phiColor = H(t.phiColor ?? 10), this.maxAccumFrames = H(t.maxAccumFrames ?? 32), this.varianceClip = H(t.varianceClip ?? 1), this.resW = H(t.width || 1), this.resH = H(t.height || 1), this.temporalEnabled = !0, this.temporalEnabledU = H(1), this._colorTexNode = new c(), this._motionTexNode = new c(), this._readTemporalTexNode = new c();
|
|
9181
9210
|
let n = t.width || 1, r = t.height || 1;
|
|
9182
|
-
this._temporalTexA = new s(n, r), this._temporalTexA.type = Ye, this._temporalTexA.format = yt, this._temporalTexA.minFilter =
|
|
9211
|
+
this._temporalTexA = new s(n, r), this._temporalTexA.type = Ye, this._temporalTexA.format = yt, this._temporalTexA.minFilter = Xe, this._temporalTexA.magFilter = Xe, this._temporalTexB = new s(n, r), this._temporalTexB.type = Ye, this._temporalTexB.format = yt, this._temporalTexB.minFilter = Xe, this._temporalTexB.magFilter = Xe, this._gradientStorageTex = new s(n, r), this._gradientStorageTex.type = Ye, this._gradientStorageTex.format = yt, this._gradientStorageTex.minFilter = Xe, this._gradientStorageTex.magFilter = Xe, this.currentMoments = 0, this._compiled = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildGradientCompute(), this._buildTemporalCompute(), this.showHeatmap = !1, this.debugMode = H(0, "int"), this._heatmapStorageTex = new s(n, r), this._heatmapStorageTex.type = qe, this._heatmapStorageTex.format = yt, this._heatmapStorageTex.minFilter = q, this._heatmapStorageTex.magFilter = q, this.heatmapTarget = new i(n, r, {
|
|
9183
9212
|
type: qe,
|
|
9184
9213
|
format: yt,
|
|
9185
|
-
minFilter:
|
|
9186
|
-
magFilter:
|
|
9214
|
+
minFilter: q,
|
|
9215
|
+
magFilter: q,
|
|
9187
9216
|
depthBuffer: !1,
|
|
9188
9217
|
stencilBuffer: !1
|
|
9189
9218
|
}), this._heatmapRawColorTexNode = new c(), this._heatmapColorTexNode = new c(), this._heatmapTemporalTexNode = new c(), this._heatmapNDTexNode = new c(), this._heatmapMotionTexNode = new c(), this._heatmapGradientTexNode = new c(), this._buildHeatmapCompute(), this.heatmapHelper = yc(this.renderer, this.heatmapTarget, {
|
|
@@ -9360,7 +9389,7 @@ var bc = class extends wn {
|
|
|
9360
9389
|
executionMode: Cn.ALWAYS
|
|
9361
9390
|
}), this.renderer = e, this.inputTextureName = t.inputTextureName || "pathtracer:color", this.varianceBoost = H(t.varianceBoost ?? 1), this.temporalAlpha = H(t.temporalAlpha ?? .1), this.resW = H(t.width || 1), this.resH = H(t.height || 1), this._colorTexNode = new c();
|
|
9362
9391
|
let n = t.width || 1, r = t.height || 1;
|
|
9363
|
-
this._storageTexA = new s(n, r), this._storageTexA.type = qe, this._storageTexA.format = yt, this._storageTexA.minFilter =
|
|
9392
|
+
this._storageTexA = new s(n, r), this._storageTexA.type = qe, this._storageTexA.format = yt, this._storageTexA.minFilter = Xe, this._storageTexA.magFilter = Xe, this._storageTexB = new s(n, r), this._storageTexB.type = qe, this._storageTexB.format = yt, this._storageTexB.minFilter = Xe, this._storageTexB.magFilter = Xe, this.currentMoments = 0, this._compiled = !1, this._needsWarmReset = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildCompute();
|
|
9364
9393
|
}
|
|
9365
9394
|
setupEventListeners() {
|
|
9366
9395
|
this.on("pathtracer:viewpointChanged", () => this.reset());
|
|
@@ -9435,7 +9464,7 @@ var bc = class extends wn {
|
|
|
9435
9464
|
executionMode: Cn.ALWAYS
|
|
9436
9465
|
}), this.renderer = e, this.inputTextureName = t.inputTextureName || "asvgf:output", this.normalDepthTextureName = t.normalDepthTextureName || "pathtracer:normalDepth", this.iterations = t.iterations ?? 4, this.phiColor = H(t.phiColor ?? 10), this.phiNormal = H(t.phiNormal ?? 128), this.phiDepth = H(t.phiDepth ?? 1), this.phiLuminance = H(t.phiLuminance ?? 4), this.stepSizeU = H(1, "int"), this.resW = H(t.width || 1), this.resH = H(t.height || 1), this._readTexNode = new c(), this._normalDepthTexNode = new c();
|
|
9437
9466
|
let n = t.width || 1, r = t.height || 1;
|
|
9438
|
-
this._storageTexA = new s(n, r), this._storageTexA.type = Ye, this._storageTexA.format = yt, this._storageTexA.minFilter =
|
|
9467
|
+
this._storageTexA = new s(n, r), this._storageTexA.type = Ye, this._storageTexA.format = yt, this._storageTexA.minFilter = Xe, this._storageTexA.magFilter = Xe, this._storageTexB = new s(n, r), this._storageTexB.type = Ye, this._storageTexB.format = yt, this._storageTexB.minFilter = Xe, this._storageTexB.magFilter = Xe, this._compiled = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildCompute();
|
|
9439
9468
|
}
|
|
9440
9469
|
_buildCompute() {
|
|
9441
9470
|
this._computeNodeA = this._buildComputeForDirection(this._storageTexA), this._computeNodeB = this._buildComputeForDirection(this._storageTexB);
|
|
@@ -9525,11 +9554,11 @@ var bc = class extends wn {
|
|
|
9525
9554
|
executionMode: Cn.PER_CYCLE
|
|
9526
9555
|
}), this.renderer = e, this.debugContainer = t.debugContainer || null, this.frameNumber = 0, this.delayByFrames = t.delayByFrames ?? 2, this.showAdaptiveSamplingHelper = !1, this.adaptiveSamplingMax = H(t.adaptiveSamplingMax ?? X.adaptiveSamplingMax ?? 32, "int"), this.varianceThreshold = H(t.varianceThreshold ?? X.adaptiveSamplingVarianceThreshold ?? .01), this.materialBias = H(t.materialBias ?? X.adaptiveSamplingMaterialBias ?? 1.2), this.edgeBias = H(t.edgeBias ?? X.adaptiveSamplingEdgeBias ?? 1.5), this.convergenceSpeed = H(t.convergenceSpeed ?? X.adaptiveSamplingConvergenceSpeed ?? 2), this.frameNumberUniform = H(0, "int"), this.resolutionWidth = H(t.width || 1024), this.resolutionHeight = H(t.height || 1024), this.minConvergenceFrames = H(10), this.convergenceThreshold = H(.01);
|
|
9527
9556
|
let n = t.width || 1, r = t.height || 1;
|
|
9528
|
-
this._outputStorageTex = new s(n, r), this._outputStorageTex.type = Ye, this._outputStorageTex.format = yt, this._outputStorageTex.minFilter =
|
|
9557
|
+
this._outputStorageTex = new s(n, r), this._outputStorageTex.type = Ye, this._outputStorageTex.format = yt, this._outputStorageTex.minFilter = Xe, this._outputStorageTex.magFilter = Xe, this._heatmapStorageTex = new s(n, r), this._heatmapStorageTex.type = qe, this._heatmapStorageTex.format = yt, this._heatmapStorageTex.minFilter = q, this._heatmapStorageTex.magFilter = q, this.heatmapTarget = new i(n, r, {
|
|
9529
9558
|
format: yt,
|
|
9530
9559
|
type: qe,
|
|
9531
|
-
minFilter:
|
|
9532
|
-
magFilter:
|
|
9560
|
+
minFilter: q,
|
|
9561
|
+
magFilter: q,
|
|
9533
9562
|
depthBuffer: !1,
|
|
9534
9563
|
stencilBuffer: !1
|
|
9535
9564
|
}), this._dispatchX = Math.ceil(n / 16), this._dispatchY = Math.ceil(r / 16), this._varianceTexNode = new c(), this._buildCompute(), this._buildHeatmapCompute(), this.helper = yc(this.renderer, this.heatmapTarget, {
|
|
@@ -9633,11 +9662,11 @@ var bc = class extends wn {
|
|
|
9633
9662
|
executionMode: Cn.PER_CYCLE
|
|
9634
9663
|
}), this.renderer = e, this.filterStrength = H(t.filterStrength ?? .75), this.strengthDecaySpeed = H(t.strengthDecaySpeed ?? .05), this.edgeThreshold = H(t.edgeThreshold ?? 1), this.phiNormal = H(t.phiNormal ?? 128), this.phiDepth = H(t.phiDepth ?? 1), this.iterationCount = H(0), this.resW = H(t.width || 1), this.resH = H(t.height || 1), this._iterations = 0, this._inputTexNode = new c(), this._ndTexNode = new c();
|
|
9635
9664
|
let n = 2048, r = t.width || 1, a = t.height || 1;
|
|
9636
|
-
this._outputStorageTex = new s(n, n), this._outputStorageTex.type = Ye, this._outputStorageTex.format = yt, this._outputStorageTex.minFilter =
|
|
9665
|
+
this._outputStorageTex = new s(n, n), this._outputStorageTex.type = Ye, this._outputStorageTex.format = yt, this._outputStorageTex.minFilter = q, this._outputStorageTex.magFilter = q, this._srcRegion = new Ne(new Nt(0, 0), new Nt(0, 0)), this.outputTarget = new i(r, a, {
|
|
9637
9666
|
type: Ye,
|
|
9638
9667
|
format: yt,
|
|
9639
|
-
minFilter:
|
|
9640
|
-
magFilter:
|
|
9668
|
+
minFilter: q,
|
|
9669
|
+
magFilter: q,
|
|
9641
9670
|
depthBuffer: !1,
|
|
9642
9671
|
stencilBuffer: !1
|
|
9643
9672
|
}), this._dispatchX = Math.ceil(r / 16), this._dispatchY = Math.ceil(a / 16), this._buildCompute();
|
|
@@ -9720,12 +9749,12 @@ var bc = class extends wn {
|
|
|
9720
9749
|
let e = {
|
|
9721
9750
|
type: qe,
|
|
9722
9751
|
format: yt,
|
|
9723
|
-
minFilter:
|
|
9724
|
-
magFilter:
|
|
9752
|
+
minFilter: q,
|
|
9753
|
+
magFilter: q,
|
|
9725
9754
|
depthBuffer: !1,
|
|
9726
9755
|
stencilBuffer: !1
|
|
9727
9756
|
};
|
|
9728
|
-
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = qe, this._downsampleStorageTex.format = yt, this._downsampleStorageTex.minFilter =
|
|
9757
|
+
this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = qe, this._downsampleStorageTex.format = yt, this._downsampleStorageTex.minFilter = q, this._downsampleStorageTex.magFilter = q, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = qe, this._reductionStorageTex.format = yt, this._reductionStorageTex.minFilter = q, this._reductionStorageTex.magFilter = q, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(kc, "uint").toAtomic();
|
|
9729
9758
|
}
|
|
9730
9759
|
_buildCompute() {
|
|
9731
9760
|
this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
|
|
@@ -9919,7 +9948,7 @@ var Rc = class extends wn {
|
|
|
9919
9948
|
super("SSRC", {
|
|
9920
9949
|
...t,
|
|
9921
9950
|
executionMode: Cn.PER_CYCLE
|
|
9922
|
-
}), this.renderer = e, this.resW = H(1), this.resH = H(1), this.temporalAlpha = H(t.temporalAlpha ?? .1), this.phiNormal = H(t.phiNormal ?? 128), this.phiDepth = H(t.phiDepth ?? .5), this.maxHistory = H(t.maxHistory ?? 128), this.spatialRadius = H(t.spatialRadius ?? 4, "int"), this.spatialWeight = H(t.spatialWeight ?? .4), this._framesSinceReset = H(0, "int"), this._colorTexNode = new c(), this._ndTexNode = new c(), this._motionTexNode = new c(), this._readCacheTexNode = new c(), this._readPrevNDTexNode = new c(), this._readPass1CacheTexNode = new c(), this._cacheTexA = this._createStorageTex(1, 1,
|
|
9951
|
+
}), this.renderer = e, this.resW = H(1), this.resH = H(1), this.temporalAlpha = H(t.temporalAlpha ?? .1), this.phiNormal = H(t.phiNormal ?? 128), this.phiDepth = H(t.phiDepth ?? .5), this.maxHistory = H(t.maxHistory ?? 128), this.spatialRadius = H(t.spatialRadius ?? 4, "int"), this.spatialWeight = H(t.spatialWeight ?? .4), this._framesSinceReset = H(0, "int"), this._colorTexNode = new c(), this._ndTexNode = new c(), this._motionTexNode = new c(), this._readCacheTexNode = new c(), this._readPrevNDTexNode = new c(), this._readPass1CacheTexNode = new c(), this._cacheTexA = this._createStorageTex(1, 1, q), this._cacheTexB = this._createStorageTex(1, 1, q), this._prevNDTexA = this._createStorageTex(1, 1, q), this._prevNDTexB = this._createStorageTex(1, 1, q), this._outputTex = this._createStorageTex(1, 1, Xe), this._currentPingPong = 0, this._dispatchX = 1, this._dispatchY = 1, this._buildComputeNodes();
|
|
9923
9952
|
}
|
|
9924
9953
|
setupEventListeners() {
|
|
9925
9954
|
this.on("pipeline:reset", () => this._resetCache()), this.on("camera:moved", () => this._resetCache());
|
|
@@ -10407,7 +10436,7 @@ var Rc = class extends wn {
|
|
|
10407
10436
|
}
|
|
10408
10437
|
}
|
|
10409
10438
|
showFocusPoint(e) {
|
|
10410
|
-
this.focusPointIndicator && this.scene.remove(this.focusPointIndicator), this.focusPointIndicator = new
|
|
10439
|
+
this.focusPointIndicator && this.scene.remove(this.focusPointIndicator), this.focusPointIndicator = new at(new Et(this.assetLoader.getSceneScale() * .02, 16, 16), new ot({
|
|
10411
10440
|
color: 65280,
|
|
10412
10441
|
transparent: !0,
|
|
10413
10442
|
opacity: .8,
|
|
@@ -10787,7 +10816,7 @@ var Rc = class extends wn {
|
|
|
10787
10816
|
}
|
|
10788
10817
|
async loadEnvironmentByExtension(e, t) {
|
|
10789
10818
|
let n;
|
|
10790
|
-
return t === "hdr" || t === "exr" ? n = await (t === "hdr" ? this.loaderCache.hdr || (this.loaderCache.hdr = new zt().setDataType(qe)) : this.loaderCache.exr || (this.loaderCache.exr = new Ht().setDataType(qe))).loadAsync(e) : (this.loaderCache.texture || (this.loaderCache.texture = new kt()), n = await this.loaderCache.texture.loadAsync(e)), n.mapping = Ge, n.minFilter =
|
|
10819
|
+
return t === "hdr" || t === "exr" ? n = await (t === "hdr" ? this.loaderCache.hdr || (this.loaderCache.hdr = new zt().setDataType(qe)) : this.loaderCache.exr || (this.loaderCache.exr = new Ht().setDataType(qe))).loadAsync(e) : (this.loaderCache.texture || (this.loaderCache.texture = new kt()), n = await this.loaderCache.texture.loadAsync(e)), n.mapping = Ge, n.minFilter = Xe, n.magFilter = Xe, n;
|
|
10791
10820
|
}
|
|
10792
10821
|
applyEnvironmentToScene(e) {
|
|
10793
10822
|
this.scene.background = e, this.scene.environment = e;
|
|
@@ -10912,7 +10941,7 @@ var Rc = class extends wn {
|
|
|
10912
10941
|
}
|
|
10913
10942
|
async handleGltfFromZip(e, t, n, r) {
|
|
10914
10943
|
if (e === "gltf") {
|
|
10915
|
-
let e = Gt(t), i = new
|
|
10944
|
+
let e = Gt(t), i = new $e(), a = n.split("/").slice(0, -1).join("/");
|
|
10916
10945
|
i.setURLModifier((e) => this.resolveZipResource(e, a, r));
|
|
10917
10946
|
let o = await this.createGLTFLoader();
|
|
10918
10947
|
o.manager = i;
|
|
@@ -10942,7 +10971,7 @@ var Rc = class extends wn {
|
|
|
10942
10971
|
e.split("/").pop()
|
|
10943
10972
|
];
|
|
10944
10973
|
for (let e of i) if (n[e]) {
|
|
10945
|
-
let { MTLLoader: t } = await import("three/examples/jsm/loaders/MTLLoader.js"), i = Gt(n[e]), a = new
|
|
10974
|
+
let { MTLLoader: t } = await import("three/examples/jsm/loaders/MTLLoader.js"), i = Gt(n[e]), a = new $e();
|
|
10946
10975
|
a.setURLModifier((e) => this.resolveZipResource(e, r, n));
|
|
10947
10976
|
let o = new t(a).parse(i, r);
|
|
10948
10977
|
return o.preload(), o;
|
|
@@ -10962,7 +10991,7 @@ var Rc = class extends wn {
|
|
|
10962
10991
|
return console.warn(`Resource not found in ZIP: ${e}`), e;
|
|
10963
10992
|
}
|
|
10964
10993
|
async loadOBJMTLPairFromZip(e, t, n, r) {
|
|
10965
|
-
let { MTLLoader: i } = await import("three/examples/jsm/loaders/MTLLoader.js"), { OBJLoader: a } = await import("three/examples/jsm/loaders/OBJLoader.js"), o = [], s = new
|
|
10994
|
+
let { MTLLoader: i } = await import("three/examples/jsm/loaders/MTLLoader.js"), { OBJLoader: a } = await import("three/examples/jsm/loaders/OBJLoader.js"), o = [], s = new $e(), c = e.path.split("/").slice(0, -1).join("/"), l = t.path.split("/").slice(0, -1).join("/");
|
|
10966
10995
|
s.setURLModifier((e) => this.resolveTextureInZip(e, c, l, t, n, o));
|
|
10967
10996
|
let u = this.prepareFixedMtlContent(t), d = new i(s).parse(u, l);
|
|
10968
10997
|
d.preload();
|
|
@@ -11154,7 +11183,7 @@ var Rc = class extends wn {
|
|
|
11154
11183
|
let { STLLoader: e } = await import("three/examples/jsm/loaders/STLLoader.js");
|
|
11155
11184
|
this.loaderCache.stl = new e();
|
|
11156
11185
|
}
|
|
11157
|
-
let n = new
|
|
11186
|
+
let n = new at(this.loaderCache.stl.parse(e), new ct());
|
|
11158
11187
|
return n.name = t, this.releaseTargetModel(), this.targetModel = n, An({
|
|
11159
11188
|
isLoading: !0,
|
|
11160
11189
|
status: "Processing Data...",
|
|
@@ -11183,7 +11212,7 @@ var Rc = class extends wn {
|
|
|
11183
11212
|
this.loaderCache.ply = new e();
|
|
11184
11213
|
}
|
|
11185
11214
|
let n = this.loaderCache.ply.parse(e), r;
|
|
11186
|
-
if (n.index !== null) r = new
|
|
11215
|
+
if (n.index !== null) r = new at(n, new ct());
|
|
11187
11216
|
else {
|
|
11188
11217
|
let e = new _t({ size: .01 });
|
|
11189
11218
|
e.vertexColors = n.hasAttribute("color"), r = new gt(n, e);
|
|
@@ -11359,7 +11388,7 @@ var Rc = class extends wn {
|
|
|
11359
11388
|
this.sceneScale = t;
|
|
11360
11389
|
}
|
|
11361
11390
|
createFloorPlane() {
|
|
11362
|
-
this.floorPlane = new
|
|
11391
|
+
this.floorPlane = new at(new Ie(), new st({
|
|
11363
11392
|
transparent: !1,
|
|
11364
11393
|
color: 3158064,
|
|
11365
11394
|
roughness: 1,
|
|
@@ -11762,7 +11791,7 @@ var Rc = class extends wn {
|
|
|
11762
11791
|
if (e === "DirectionalLight") n = new He(t.color, t.intensity), n.position.fromArray(t.position);
|
|
11763
11792
|
else if (e === "PointLight") n = new mt(t.color, t.intensity), n.position.fromArray(t.position);
|
|
11764
11793
|
else if (e === "SpotLight") {
|
|
11765
|
-
n = new Dt(t.color, t.intensity), n.position.fromArray(t.position), n.angle =
|
|
11794
|
+
n = new Dt(t.color, t.intensity), n.position.fromArray(t.position), n.angle = nt.degToRad(t.angle);
|
|
11766
11795
|
let e = new ft();
|
|
11767
11796
|
this.scene.add(e), n.target = e;
|
|
11768
11797
|
} else e === "RectAreaLight" && (n = new xt(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0));
|
|
@@ -11835,7 +11864,7 @@ var Rc = class extends wn {
|
|
|
11835
11864
|
}
|
|
11836
11865
|
_buildDescriptor(e) {
|
|
11837
11866
|
let t = 0;
|
|
11838
|
-
e.type === "SpotLight" && e.angle !== void 0 && (t =
|
|
11867
|
+
e.type === "SpotLight" && e.angle !== void 0 && (t = nt.radToDeg(e.angle));
|
|
11839
11868
|
let n = {
|
|
11840
11869
|
uuid: e.uuid,
|
|
11841
11870
|
name: e.name,
|
|
@@ -11913,7 +11942,7 @@ function al(e, t, n, r, i) {
|
|
|
11913
11942
|
}
|
|
11914
11943
|
var ol = new Map([
|
|
11915
11944
|
[dt, $c],
|
|
11916
|
-
[
|
|
11945
|
+
[Qe, el],
|
|
11917
11946
|
[St, tl],
|
|
11918
11947
|
[Fe, nl],
|
|
11919
11948
|
[Oe, rl],
|
|
@@ -12894,6 +12923,9 @@ var _l = new Float32Array(3), vl = {
|
|
|
12894
12923
|
getHUDCanvas() {
|
|
12895
12924
|
return this._hudCanvas;
|
|
12896
12925
|
}
|
|
12926
|
+
mount(e) {
|
|
12927
|
+
!e || this._hudCanvas.parentElement === e || e.appendChild(this._hudCanvas);
|
|
12928
|
+
}
|
|
12897
12929
|
setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
|
|
12898
12930
|
this.setHelperScene(e);
|
|
12899
12931
|
let s = new Tl();
|
|
@@ -13017,7 +13049,7 @@ var _l = new Float32Array(3), vl = {
|
|
|
13017
13049
|
this._savedTimeScale = e, this.mixer && this.isPlaying && (this.mixer.timeScale = e);
|
|
13018
13050
|
}
|
|
13019
13051
|
setLoop(e) {
|
|
13020
|
-
let t = e ?
|
|
13052
|
+
let t = e ? tt : et;
|
|
13021
13053
|
for (let n of this.actions) n.setLoop(t), n.clampWhenFinished = !e;
|
|
13022
13054
|
}
|
|
13023
13055
|
seekTo(e, t = 0) {
|
|
@@ -13071,7 +13103,7 @@ var _l = new Float32Array(3), vl = {
|
|
|
13071
13103
|
}
|
|
13072
13104
|
}, kl = class {
|
|
13073
13105
|
constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
|
|
13074
|
-
this._app = r, this._orbitControls = n, this._camera = e, this._controls = new Yt(e, t), this._gizmoScene = new Tt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new Pt(), this._normalMatrix = new
|
|
13106
|
+
this._app = r, this._orbitControls = n, this._camera = e, this._controls = new Yt(e, t), this._gizmoScene = new Tt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new Pt(), this._normalMatrix = new rt(), 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);
|
|
13075
13107
|
}
|
|
13076
13108
|
setMeshData(e, t) {
|
|
13077
13109
|
this._meshes = e, this._meshTriRanges = [], this._skinnedCache = [], this._normalCache = [];
|
|
@@ -13188,7 +13220,7 @@ var _l = new Float32Array(3), vl = {
|
|
|
13188
13220
|
} catch (e) {
|
|
13189
13221
|
console.warn("PathTracerApp: prior canvas owner dispose failed", e);
|
|
13190
13222
|
}
|
|
13191
|
-
Al.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._showStats = t.showStats !== !1, this._statsContainer = t.statsContainer || null, this.settings = new Yc(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Ol(), 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 Uc(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1;
|
|
13223
|
+
Al.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._showStats = t.showStats !== !1, this._container = t.container || null, this._statsContainer = t.statsContainer || null, this.settings = new Yc(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Ol(), 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 Uc(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1;
|
|
13192
13224
|
}
|
|
13193
13225
|
_addTrackedListener(e, t, n) {
|
|
13194
13226
|
e && (e.addEventListener(t, n), this._trackedListeners.push({
|
|
@@ -13607,7 +13639,7 @@ var _l = new Float32Array(3), vl = {
|
|
|
13607
13639
|
}
|
|
13608
13640
|
}
|
|
13609
13641
|
_initStats() {
|
|
13610
|
-
let e = this._statsContainer || this.canvas.parentElement || document.body;
|
|
13642
|
+
let e = this._statsContainer || this._container || this.canvas.parentElement || document.body;
|
|
13611
13643
|
this._stats = en(this.renderer, e);
|
|
13612
13644
|
}
|
|
13613
13645
|
_setupAutoExposureListener() {
|
|
@@ -13631,7 +13663,7 @@ var _l = new Float32Array(3), vl = {
|
|
|
13631
13663
|
app: this,
|
|
13632
13664
|
renderWidth: this.denoisingManager?._lastRenderWidth || this.canvas.clientWidth || 1,
|
|
13633
13665
|
renderHeight: this.denoisingManager?._lastRenderHeight || this.canvas.clientHeight || 1
|
|
13634
|
-
});
|
|
13666
|
+
}), this._container = this._container || this.canvas.parentNode || null, this.overlayManager.mount(this._container);
|
|
13635
13667
|
}
|
|
13636
13668
|
_syncControlsAfterLoad() {
|
|
13637
13669
|
this.cameraManager.controls.saveState(), this.cameraManager.controls.update();
|