@takram/three-geospatial 0.7.1 → 0.9.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/CHANGELOG.md +41 -0
- package/README.md +1 -1
- package/build/index.cjs +1 -1
- package/build/index.cjs.map +1 -1
- package/build/index.js +580 -598
- package/build/index.js.map +1 -1
- package/build/r3f.cjs +1 -1
- package/build/r3f.js +1 -1
- package/build/shared2.cjs +1 -1
- package/build/shared2.cjs.map +1 -1
- package/build/shared2.js +27 -212
- package/build/shared2.js.map +1 -1
- package/build/shared3.cjs +1 -1
- package/build/shared3.cjs.map +1 -1
- package/build/shared3.js +213 -8
- package/build/shared3.js.map +1 -1
- package/build/webgpu.cjs +6 -1
- package/build/webgpu.cjs.map +1 -1
- package/build/webgpu.js +1111 -768
- package/build/webgpu.js.map +1 -1
- package/package.json +1 -1
- package/src/EllipsoidGeometry.ts +1 -1
- package/src/PointOfView.ts +12 -5
- package/src/STBNLoader.ts +41 -19
- package/src/unrollLoops.ts +1 -1
- package/src/webgpu/CascadedShadowMapsNode.ts +48 -0
- package/src/webgpu/DualMipmapFilterNode.ts +8 -4
- package/src/webgpu/FilterNode.ts +5 -3
- package/src/webgpu/FnLayout.ts +17 -16
- package/src/webgpu/HighpVelocityNode.ts +9 -4
- package/src/webgpu/LensFlareNode.ts +12 -16
- package/src/webgpu/LensGlareNode.ts +28 -32
- package/src/webgpu/LensHaloNode.ts +2 -1
- package/src/webgpu/OutputTexture3DNode.ts +10 -0
- package/src/webgpu/OutputTextureNode.ts +10 -0
- package/src/webgpu/STBNTextureNode.ts +58 -0
- package/src/webgpu/ScreenSpaceShadowNode.ts +685 -0
- package/src/webgpu/SeparableFilterNode.ts +8 -5
- package/src/webgpu/SingleFilterNode.ts +5 -2
- package/src/webgpu/StorageTexture3DNode.ts +30 -0
- package/src/webgpu/TemporalAntialiasNode.ts +178 -137
- package/src/webgpu/accessors.ts +75 -36
- package/src/webgpu/debug.ts +38 -47
- package/src/webgpu/events.ts +18 -0
- package/src/webgpu/index.ts +5 -1
- package/src/webgpu/math.ts +116 -15
- package/src/webgpu/sampling.ts +39 -5
- package/src/webgpu/transformations.ts +71 -44
- package/types/PointOfView.d.ts +1 -1
- package/types/STBNLoader.d.ts +3 -4
- package/types/webgpu/CascadedShadowMapsNode.d.ts +13 -0
- package/types/webgpu/DualMipmapFilterNode.d.ts +1 -2
- package/types/webgpu/FnLayout.d.ts +4 -4
- package/types/webgpu/HighpVelocityNode.d.ts +1 -0
- package/types/webgpu/LensFlareNode.d.ts +2 -3
- package/types/webgpu/LensGlareNode.d.ts +1 -1
- package/types/webgpu/STBNTextureNode.d.ts +9 -0
- package/types/webgpu/ScreenSpaceShadowNode.d.ts +33 -0
- package/types/webgpu/SeparableFilterNode.d.ts +2 -3
- package/types/webgpu/SingleFilterNode.d.ts +1 -2
- package/types/webgpu/StorageTexture3DNode.d.ts +9 -0
- package/types/webgpu/TemporalAntialiasNode.d.ts +9 -10
- package/types/webgpu/accessors.d.ts +9 -8
- package/types/webgpu/debug.d.ts +4 -3
- package/types/webgpu/events.d.ts +3 -0
- package/types/webgpu/index.d.ts +5 -1
- package/types/webgpu/math.d.ts +3 -0
- package/types/webgpu/sampling.d.ts +2 -1
- package/types/webgpu/transformations.d.ts +7 -10
- package/src/webgpu/RTTextureNode.ts +0 -130
- package/types/webgpu/RTTextureNode.d.ts +0 -22
package/build/webgpu.js
CHANGED
|
@@ -1,82 +1,181 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { Fn as U, logarithmicDepthToViewZ as ct, perspectiveDepthToViewZ as ut, orthographicDepthToViewZ as Et, viewZToLogarithmicDepth as lt, sub as ie, PI2 as kt, PI as It, cos as Xe, vec3 as M, sin as Ze, viewZToPerspectiveDepth as Lt, int as K, vec4 as z, cameraNear as je, cameraFar as Ee, depth as Wt, cameraPosition as $t, cameraProjectionMatrixInverse as qt, cameraWorldMatrix as Gt, cameraProjectionMatrix as Ht, cameraViewMatrix as Yt, uniform as g, reference as le, positionGeometry as ht, texture as oe, uv as I, vec2 as f, add as B, luminance as Xt, smoothstep as dt, OnBeforeObjectUpdate as Zt, OnObjectUpdate as _t, screenCoordinate as ke, time as Kt, equirectUV as Qt, fwidth as Jt, abs as _, positionLocal as es, positionPrevious as ts, nodeImmutable as pt, instancedArray as _e, storage as ss, uvec2 as re, If as ae, globalId as Ae, Return as os, atomicAdd as ns, instanceIndex as is, mat3 as mt, struct as Ie, min as ft, mul as rs, fract as as, distance as cs, mix as ne, rtt as us, convertToTexture as Oe, overloadingFn as Le, sqrt as be, dot as Ne, bvec2 as xt, bvec3 as gt, uvec3 as pe, bvec4 as vt, uvec4 as me, bool as Me, color as ls, mat4 as hs, mat2 as ds, ivec4 as yt, ivec3 as ps, ivec2 as O, uint as ms, float as G, workgroupArray as fs, greaterThan as xs, invocationLocalIndex as we, workgroupBarrier as gs, textureStore as vs, workgroupId as Ke, and as wt, frameId as ys, screenUV as ws, step as Ts, textureSize as Ns, max as Tt } from "three/tsl";
|
|
2
|
+
import { StructTypeNode as Ss, NodeMaterial as ce, TextureNode as bs, TempNode as Q, NodeUpdateType as H, RendererUtils as ge, QuadMesh as ze, IndirectStorageBufferAttribute as Ms, MeshBasicNodeMaterial as zs, NodeBuilder as Cs, Node as Rs, Texture3DNode as Nt, StorageTexture as Ds, Data3DTexture as Bs, RedFormat as As, NearestFilter as Qe, RepeatWrapping as Ve, StorageTextureNode as Vs } from "three/webgpu";
|
|
3
|
+
import { Vector3 as St, Plane as Ps, Mesh as bt, Scene as Fs, Camera as Os, RenderTarget as Mt, RGBAFormat as zt, HalfFloatType as Ct, LinearFilter as ue, Matrix4 as Se, Vector2 as ve, AdditiveBlending as Us, PlaneGeometry as js, PerspectiveCamera as Es, SRGBColorSpace as ks, CanvasTexture as Is, NoColorSpace as Ls, Vector4 as Ws, DepthTexture as $s } from "three";
|
|
4
|
+
import { CSMShadowNode as qs } from "three/examples/jsm/csm/CSMShadowNode.js";
|
|
5
|
+
import { Q as Gs, D as Hs, S as Ys } from "./shared2.js";
|
|
6
|
+
import { i as y } from "./shared.js";
|
|
7
|
+
import { hash as We, hashString as Xs } from "three/src/nodes/core/NodeUtils.js";
|
|
8
|
+
function Je(s) {
|
|
9
|
+
if (typeof s == "string")
|
|
10
|
+
return s;
|
|
11
|
+
if ("layout" in s && s.layout instanceof Ss) {
|
|
12
|
+
if (s.layout.name == null)
|
|
13
|
+
throw new Error("Struct name is required.");
|
|
14
|
+
return s.layout.name;
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`Unsupported layout type: ${s}`);
|
|
12
17
|
}
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
function V({
|
|
19
|
+
typeOnly: s = !1,
|
|
20
|
+
...e
|
|
21
|
+
}) {
|
|
22
|
+
return s ? (t) => U(t) : (t) => U(t).setLayout({
|
|
23
|
+
...e,
|
|
24
|
+
type: Je(e.type),
|
|
25
|
+
inputs: e.inputs?.map((o) => ({
|
|
26
|
+
...o,
|
|
27
|
+
type: Je(o.type)
|
|
28
|
+
})) ?? []
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function L(s) {
|
|
32
|
+
return U((e, t) => {
|
|
33
|
+
const o = s(...e);
|
|
34
|
+
return typeof o == "function" ? o(t) : o;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const Rt = /* @__PURE__ */ L(
|
|
38
|
+
(s, e, t, o) => (n) => {
|
|
39
|
+
t ??= fe(e), o ??= xe(e);
|
|
40
|
+
const i = e?.isPerspectiveCamera === !0;
|
|
41
|
+
return n.renderer.logarithmicDepthBuffer ? ct(s, t, o) : i ? ut(s, t, o) : Et(s, t, o);
|
|
42
|
+
}
|
|
43
|
+
), Ue = (s, e, t) => {
|
|
44
|
+
e ??= je, t ??= Ee;
|
|
45
|
+
const o = ct(s, e, t);
|
|
46
|
+
return Lt(o, e, t);
|
|
47
|
+
}, un = (s, e, t) => {
|
|
48
|
+
e ??= je, t ??= Ee;
|
|
49
|
+
const o = ut(s, e, t);
|
|
50
|
+
return lt(o, e, t);
|
|
51
|
+
}, ln = (s, e, t, o, n) => {
|
|
52
|
+
const i = o.element(K(2)).element(K(3)), r = o.element(K(3)).element(K(3)), a = z(M(s.flipY(), e).mul(2).sub(1), 1).mul(t.mul(i).add(r));
|
|
53
|
+
return n.mul(a).xyz;
|
|
54
|
+
}, Pe = [
|
|
55
|
+
[58.1375, 2.7747, 26.8183],
|
|
56
|
+
[-150.5666, 4.2109, -88.5066],
|
|
57
|
+
[130.5887, -14.0195, 109.0745],
|
|
58
|
+
[-42.3277, 4.8052, -60.1097],
|
|
59
|
+
[4.5974, 2.1856, 12.5925],
|
|
60
|
+
[0.1357, 0.0914, 0.1067]
|
|
61
|
+
], Zs = /* @__PURE__ */ V({
|
|
62
|
+
name: "turbo",
|
|
63
|
+
type: "vec3",
|
|
64
|
+
inputs: [{ name: "x", type: "float" }]
|
|
65
|
+
})(([s]) => {
|
|
66
|
+
const e = M(...Pe[0]).toVar();
|
|
67
|
+
for (let t = 1; t < Pe.length; ++t)
|
|
68
|
+
e.assign(M(...Pe[t]).add(s.mul(e)));
|
|
69
|
+
return e;
|
|
70
|
+
}), hn = L(
|
|
71
|
+
(s, e, t, o) => {
|
|
72
|
+
t ??= fe(e), o ??= xe(e);
|
|
73
|
+
const n = Rt(s, e, t, o);
|
|
74
|
+
return Zs(lt(n, t, o));
|
|
75
|
+
}
|
|
76
|
+
), dn = /* @__PURE__ */ V({
|
|
77
|
+
name: "equirectToDirectionWorld",
|
|
78
|
+
type: "vec3",
|
|
79
|
+
inputs: [{ name: "uv", type: "vec2" }]
|
|
80
|
+
})(([s]) => {
|
|
81
|
+
const e = ie(0.5, s.x).mul(kt), t = ie(s.y, 0.5).mul(It), o = Xe(t);
|
|
82
|
+
return M(o.mul(Xe(e)), Ze(t), o.mul(Ze(e)));
|
|
83
|
+
});
|
|
84
|
+
let Fe;
|
|
85
|
+
function J(s, e, t) {
|
|
86
|
+
Fe ??= /* @__PURE__ */ new WeakMap();
|
|
87
|
+
let o = Fe.get(s);
|
|
88
|
+
return o == null && (o = {}, Fe.set(s, o)), o[e] ??= t();
|
|
89
|
+
}
|
|
90
|
+
const pn = (s) => s != null ? J(
|
|
91
|
+
s,
|
|
15
92
|
"projectionMatrix",
|
|
16
|
-
() =>
|
|
17
|
-
|
|
18
|
-
|
|
93
|
+
() => le("projectionMatrix", "mat4", s).setName(
|
|
94
|
+
"projectionMatrix"
|
|
95
|
+
)
|
|
96
|
+
) : Ht, mn = (s) => s != null ? J(
|
|
97
|
+
s,
|
|
19
98
|
"viewMatrix",
|
|
20
|
-
() =>
|
|
21
|
-
),
|
|
22
|
-
|
|
99
|
+
() => le("matrixWorldInverse", "mat4", s).setName("viewMatrix")
|
|
100
|
+
) : Yt, fn = (s) => s != null ? J(
|
|
101
|
+
s,
|
|
23
102
|
"inverseProjectionMatrix",
|
|
24
|
-
() =>
|
|
103
|
+
() => le("projectionMatrixInverse", "mat4", s).setName(
|
|
25
104
|
"inverseProjectionMatrix"
|
|
26
105
|
)
|
|
27
|
-
),
|
|
28
|
-
|
|
106
|
+
) : qt, xn = (s) => s != null ? J(
|
|
107
|
+
s,
|
|
29
108
|
"inverseViewMatrix",
|
|
30
|
-
() =>
|
|
31
|
-
),
|
|
32
|
-
|
|
109
|
+
() => le("matrixWorld", "mat4", s).setName("inverseViewMatrix")
|
|
110
|
+
) : Gt, gn = (s) => s != null ? J(
|
|
111
|
+
s,
|
|
33
112
|
"cameraPositionWorld",
|
|
34
|
-
() =>
|
|
35
|
-
t.setFromMatrixPosition(
|
|
113
|
+
() => g("vec3").setName("cameraPositionWorld").onRenderUpdate((e, { value: t }) => {
|
|
114
|
+
t.setFromMatrixPosition(s.matrixWorld);
|
|
36
115
|
})
|
|
37
|
-
),
|
|
38
|
-
|
|
116
|
+
) : $t, fe = (s) => s != null ? J(
|
|
117
|
+
s,
|
|
39
118
|
"cameraNear",
|
|
40
|
-
() =>
|
|
41
|
-
),
|
|
42
|
-
|
|
119
|
+
() => le("near", "float", s).setName("cameraNear")
|
|
120
|
+
) : je, xe = (s) => s != null ? J(
|
|
121
|
+
s,
|
|
43
122
|
"cameraFar",
|
|
44
|
-
() =>
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
|
|
123
|
+
() => le("far", "float", s).setName("cameraFar")
|
|
124
|
+
) : Ee, vn = U(
|
|
125
|
+
({ camera: s }) => Rt(Wt, s)
|
|
126
|
+
).once()().toVar("viewZ"), _s = /* @__PURE__ */ new St(), Ks = /* @__PURE__ */ new Ps();
|
|
127
|
+
class yn extends qs {
|
|
128
|
+
updateBefore(e) {
|
|
129
|
+
super.updateBefore(e);
|
|
130
|
+
const { lights: t } = this;
|
|
131
|
+
if (t.length < 2)
|
|
132
|
+
return;
|
|
133
|
+
const o = t[t.length - 1], n = _s.subVectors(o.target.position, o.position).normalize(), i = Ks.setFromNormalAndCoplanarPoint(
|
|
134
|
+
n,
|
|
135
|
+
o.position
|
|
136
|
+
);
|
|
137
|
+
for (let r = 0; r < t.length - 1; ++r) {
|
|
138
|
+
const c = t[r];
|
|
139
|
+
i.projectPoint(c.position, c.position), c.target.position.copy(c.position).add(n);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
48
142
|
}
|
|
49
|
-
function
|
|
50
|
-
const t = new
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
143
|
+
async function Ce(s, e) {
|
|
144
|
+
const t = new bt(new Gs(), e);
|
|
145
|
+
try {
|
|
146
|
+
return await s.debug.getShaderAsync(new Fs(), new Os(), t);
|
|
147
|
+
} catch (o) {
|
|
148
|
+
return console.error(o), { vertexShader: null, fragmentShader: null };
|
|
149
|
+
} finally {
|
|
54
150
|
t.geometry.dispose();
|
|
55
|
-
}
|
|
151
|
+
}
|
|
56
152
|
}
|
|
57
|
-
function
|
|
58
|
-
const t =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
153
|
+
async function wn(s, e) {
|
|
154
|
+
const { vertexShader: t, fragmentShader: o } = await Ce(s, e);
|
|
155
|
+
return t != null && o != null ? `// Vertex shader
|
|
156
|
+
|
|
157
|
+
${t}
|
|
158
|
+
// Fragment shader
|
|
159
|
+
|
|
160
|
+
${o}` : null;
|
|
64
161
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
162
|
+
async function Tn(s, e) {
|
|
163
|
+
return (await Ce(s, e)).vertexShader;
|
|
164
|
+
}
|
|
165
|
+
async function Nn(s, e) {
|
|
166
|
+
return (await Ce(s, e)).fragmentShader;
|
|
167
|
+
}
|
|
168
|
+
async function Sn(s, e) {
|
|
169
|
+
const t = new ce();
|
|
170
|
+
t.vertexNode = z(ht.xy, 0, 1), t.fragmentNode = e.toConst("debugNode");
|
|
171
|
+
const o = await Ce(s, t);
|
|
172
|
+
return t.dispose(), o.fragmentShader;
|
|
74
173
|
}
|
|
75
|
-
function
|
|
76
|
-
const
|
|
77
|
-
return
|
|
174
|
+
function bn(s, e, t) {
|
|
175
|
+
const o = s[e];
|
|
176
|
+
return s[e] = ((...n) => (t(...n), o.apply(s, n))), s;
|
|
78
177
|
}
|
|
79
|
-
class
|
|
178
|
+
class Qs extends bs {
|
|
80
179
|
static get type() {
|
|
81
180
|
return "OutputTextureNode";
|
|
82
181
|
}
|
|
@@ -90,26 +189,26 @@ class qt extends se {
|
|
|
90
189
|
return new this.constructor(this.owner, this.value);
|
|
91
190
|
}
|
|
92
191
|
}
|
|
93
|
-
const
|
|
94
|
-
class
|
|
192
|
+
const $e = (...s) => new Qs(...s);
|
|
193
|
+
class Re extends Q {
|
|
95
194
|
constructor(e) {
|
|
96
|
-
super("vec4"), this.resolutionScale = 1, this.renderTargets = [], this.
|
|
195
|
+
super("vec4"), this.resolutionScale = 1, this.renderTargets = [], this.updateBeforeType = H.FRAME, this.inputNode = e;
|
|
97
196
|
}
|
|
98
197
|
static get type() {
|
|
99
198
|
return "FilterNode";
|
|
100
199
|
}
|
|
101
200
|
createRenderTarget(e) {
|
|
102
|
-
const t = new
|
|
201
|
+
const t = new Mt(1, 1, {
|
|
103
202
|
depthBuffer: !1,
|
|
104
|
-
type:
|
|
105
|
-
format:
|
|
106
|
-
}),
|
|
107
|
-
|
|
203
|
+
type: Ct,
|
|
204
|
+
format: zt
|
|
205
|
+
}), o = t.texture;
|
|
206
|
+
o.minFilter = ue, o.magFilter = ue, o.generateMipmaps = !1;
|
|
108
207
|
const n = this.constructor.type;
|
|
109
|
-
return
|
|
208
|
+
return o.name = e != null ? `${n}_${e}` : n, this.renderTargets.push(t), t;
|
|
110
209
|
}
|
|
111
210
|
getTextureNode() {
|
|
112
|
-
return
|
|
211
|
+
return y(
|
|
113
212
|
this.textureNode != null,
|
|
114
213
|
"outputTexture must be specified before getTextureNode() is called."
|
|
115
214
|
), this.textureNode;
|
|
@@ -118,17 +217,17 @@ class _ extends E {
|
|
|
118
217
|
return this.textureNode?.value ?? null;
|
|
119
218
|
}
|
|
120
219
|
set outputTexture(e) {
|
|
121
|
-
this.textureNode = e != null ?
|
|
220
|
+
this.textureNode = e != null ? $e(this, e) : void 0;
|
|
122
221
|
}
|
|
123
222
|
setup(e) {
|
|
124
|
-
const { inputNode: t, textureNode:
|
|
125
|
-
return
|
|
223
|
+
const { inputNode: t, textureNode: o } = this;
|
|
224
|
+
return y(
|
|
126
225
|
t != null,
|
|
127
226
|
"inputNode must be specified before being setup."
|
|
128
|
-
),
|
|
129
|
-
|
|
227
|
+
), y(
|
|
228
|
+
o != null,
|
|
130
229
|
"outputTexture must be specified before being setup."
|
|
131
|
-
),
|
|
230
|
+
), o.uvNode = t.uvNode, o;
|
|
132
231
|
}
|
|
133
232
|
dispose() {
|
|
134
233
|
for (const e of this.renderTargets)
|
|
@@ -136,20 +235,22 @@ class _ extends E {
|
|
|
136
235
|
super.dispose();
|
|
137
236
|
}
|
|
138
237
|
}
|
|
139
|
-
const { resetRendererState:
|
|
140
|
-
class
|
|
238
|
+
const { resetRendererState: Js, restoreRendererState: eo } = ge;
|
|
239
|
+
class qe extends Re {
|
|
141
240
|
constructor(e, t) {
|
|
142
|
-
super(e), this.downsampleRTs = [], this.upsampleRTs = [], this.downsampleMaterial = new
|
|
143
|
-
|
|
144
|
-
|
|
241
|
+
super(e), this.downsampleRTs = [], this.upsampleRTs = [], this.downsampleMaterial = new ce(), this.upsampleMaterial = new ce(), this.mesh = new ze(), this.inputTexelSize = g("vec2"), this.downsampleNode = oe();
|
|
242
|
+
const o = this.constructor.type.replace(/Node$/, "");
|
|
243
|
+
this.downsampleMaterial.name = `${o}_downsample`, this.upsampleMaterial.name = `${o}_upsample`, this.mesh.name = o;
|
|
244
|
+
for (let n = 0; n < t; ++n)
|
|
245
|
+
this.downsampleRTs[n] = this.createRenderTarget(`downsample${n}`), n < t - 1 && (this.upsampleRTs[n] = this.createRenderTarget(`upsample${n}`));
|
|
145
246
|
this.outputTexture = this.upsampleRTs[0].texture;
|
|
146
247
|
}
|
|
147
248
|
setSize(e, t) {
|
|
148
|
-
const { resolutionScale:
|
|
149
|
-
let n = Math.max(Math.round(e *
|
|
150
|
-
const { downsampleRTs:
|
|
151
|
-
for (let a = 0; a <
|
|
152
|
-
n = Math.max(Math.round(n / 2), 1),
|
|
249
|
+
const { resolutionScale: o } = this;
|
|
250
|
+
let n = Math.max(Math.round(e * o), 1), i = Math.max(Math.round(t * o), 1);
|
|
251
|
+
const { downsampleRTs: r, upsampleRTs: c } = this;
|
|
252
|
+
for (let a = 0; a < r.length; ++a)
|
|
253
|
+
n = Math.max(Math.round(n / 2), 1), i = Math.max(Math.round(i / 2), 1), r[a].setSize(n, i), a < c.length && c[a].setSize(n, i);
|
|
153
254
|
return this;
|
|
154
255
|
}
|
|
155
256
|
updateBefore({ renderer: e }) {
|
|
@@ -157,33 +258,33 @@ class ae extends _ {
|
|
|
157
258
|
return;
|
|
158
259
|
const {
|
|
159
260
|
downsampleRTs: t,
|
|
160
|
-
upsampleRTs:
|
|
261
|
+
upsampleRTs: o,
|
|
161
262
|
mesh: n,
|
|
162
|
-
inputNode:
|
|
163
|
-
inputTexelSize:
|
|
164
|
-
downsampleNode:
|
|
263
|
+
inputNode: i,
|
|
264
|
+
inputTexelSize: r,
|
|
265
|
+
downsampleNode: c
|
|
165
266
|
} = this;
|
|
166
|
-
|
|
167
|
-
const { width: a, height: h } =
|
|
267
|
+
y(i != null);
|
|
268
|
+
const { width: a, height: h } = i.value;
|
|
168
269
|
this.setSize(a, h);
|
|
169
|
-
const
|
|
170
|
-
this.rendererState =
|
|
171
|
-
for (const
|
|
172
|
-
const { width:
|
|
173
|
-
|
|
270
|
+
const l = i.value;
|
|
271
|
+
this.rendererState = Js(e, this.rendererState), n.material = this.downsampleMaterial;
|
|
272
|
+
for (const u of t) {
|
|
273
|
+
const { width: p, height: d } = i.value;
|
|
274
|
+
r.value.set(1 / p, 1 / d), e.setRenderTarget(u), n.render(e), i.value = u.texture;
|
|
174
275
|
}
|
|
175
276
|
n.material = this.upsampleMaterial;
|
|
176
|
-
for (let
|
|
177
|
-
const
|
|
178
|
-
|
|
277
|
+
for (let u = o.length - 1; u >= 0; --u) {
|
|
278
|
+
const p = o[u], { width: d, height: m } = i.value;
|
|
279
|
+
r.value.set(1 / d, 1 / m), c.value = t[u].texture, e.setRenderTarget(p), n.render(e), i.value = p.texture;
|
|
179
280
|
}
|
|
180
|
-
|
|
281
|
+
eo(e, this.rendererState), i.value = l;
|
|
181
282
|
}
|
|
182
283
|
setup(e) {
|
|
183
284
|
const { inputNode: t } = this;
|
|
184
|
-
|
|
185
|
-
const { downsampleMaterial:
|
|
186
|
-
return
|
|
285
|
+
y(t != null);
|
|
286
|
+
const { downsampleMaterial: o, upsampleMaterial: n } = this;
|
|
287
|
+
return o.fragmentNode = this.setupDownsampleNode(e), n.fragmentNode = this.setupUpsampleNode(e), o.needsUpdate = !0, n.needsUpdate = !0, super.setup(e);
|
|
187
288
|
}
|
|
188
289
|
dispose() {
|
|
189
290
|
for (const e of this.downsampleRTs)
|
|
@@ -193,48 +294,48 @@ class ae extends _ {
|
|
|
193
294
|
this.downsampleMaterial.dispose(), this.upsampleMaterial.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
194
295
|
}
|
|
195
296
|
}
|
|
196
|
-
const
|
|
197
|
-
const t =
|
|
198
|
-
return
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
297
|
+
const Dt = (s, e) => {
|
|
298
|
+
const t = I(), o = z(1, 1, -1, -1).mul(e.xyxy).add(t.xyxy).toVertexStage(), n = z(2, 2, -2, -2).mul(e.xyxy).add(t.xyxy).toVertexStage(), i = o.zy, r = o.xy, c = o.zw, a = o.xw, h = f(t.x, n.y), l = f(n.z, t.y), u = f(n.x, t.y), p = f(t.x, n.w), d = n.zy, m = n.xy, x = n.zw, w = n.xw;
|
|
299
|
+
return B(
|
|
300
|
+
B(
|
|
301
|
+
s.sample(t),
|
|
302
|
+
s.sample(i),
|
|
303
|
+
s.sample(r),
|
|
304
|
+
s.sample(c),
|
|
305
|
+
s.sample(a)
|
|
205
306
|
).mul(1 / 8),
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
307
|
+
B(
|
|
308
|
+
s.sample(h),
|
|
309
|
+
s.sample(l),
|
|
310
|
+
s.sample(u),
|
|
311
|
+
s.sample(p)
|
|
211
312
|
).mul(1 / 16),
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
313
|
+
B(
|
|
314
|
+
s.sample(d),
|
|
315
|
+
s.sample(m),
|
|
316
|
+
s.sample(x),
|
|
317
|
+
s.sample(w)
|
|
217
318
|
).mul(1 / 32)
|
|
218
319
|
);
|
|
219
|
-
},
|
|
220
|
-
const t =
|
|
221
|
-
return
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
320
|
+
}, to = (s, e) => {
|
|
321
|
+
const t = I(), o = z(1, 1, -1, -1).mul(e.xyxy).add(t.xyxy).toVertexStage(), n = f(t.x, o.y), i = f(o.z, t.y), r = f(o.x, t.y), c = f(t.x, o.w), a = o.zy, h = o.xy, l = o.zw, u = o.xw;
|
|
322
|
+
return B(
|
|
323
|
+
s.sample(t).mul(0.25),
|
|
324
|
+
B(
|
|
325
|
+
s.sample(n),
|
|
326
|
+
s.sample(i),
|
|
327
|
+
s.sample(r),
|
|
328
|
+
s.sample(c)
|
|
228
329
|
).mul(0.125),
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
330
|
+
B(
|
|
331
|
+
s.sample(a),
|
|
332
|
+
s.sample(h),
|
|
333
|
+
s.sample(l),
|
|
334
|
+
s.sample(u)
|
|
234
335
|
).mul(0.0625)
|
|
235
336
|
);
|
|
236
337
|
};
|
|
237
|
-
class
|
|
338
|
+
class so extends qe {
|
|
238
339
|
static get type() {
|
|
239
340
|
return "MipmapBlurNode";
|
|
240
341
|
}
|
|
@@ -242,149 +343,132 @@ class Jt extends ae {
|
|
|
242
343
|
super(e, t), this.resolutionScale = 0.5;
|
|
243
344
|
}
|
|
244
345
|
setupDownsampleNode(e) {
|
|
245
|
-
return
|
|
346
|
+
return y(this.inputNode != null), Dt(this.inputNode, this.inputTexelSize);
|
|
246
347
|
}
|
|
247
348
|
setupUpsampleNode(e) {
|
|
248
|
-
return
|
|
349
|
+
return y(this.inputNode != null), to(this.inputNode, this.inputTexelSize);
|
|
249
350
|
}
|
|
250
351
|
}
|
|
251
|
-
const
|
|
252
|
-
class
|
|
352
|
+
const Mn = (...s) => new so(...s), { resetRendererState: oo, restoreRendererState: no } = ge;
|
|
353
|
+
class io extends Re {
|
|
253
354
|
constructor(e) {
|
|
254
|
-
super(e), this.material = new
|
|
355
|
+
super(e), this.material = new ce(), this.mesh = new ze(this.material), this.inputTexelSize = g("vec2");
|
|
356
|
+
const t = this.constructor.type.replace(/Node$/, "");
|
|
357
|
+
this.material.name = t, this.mesh.name = t, this.renderTarget = this.createRenderTarget(), this.outputTexture = this.renderTarget.texture;
|
|
255
358
|
}
|
|
256
359
|
setSize(e, t) {
|
|
257
|
-
const { resolutionScale:
|
|
258
|
-
return this.renderTarget.setSize(n,
|
|
360
|
+
const { resolutionScale: o } = this, n = Math.max(Math.round(e * o), 1), i = Math.max(Math.round(t * o), 1);
|
|
361
|
+
return this.renderTarget.setSize(n, i), this;
|
|
259
362
|
}
|
|
260
363
|
updateBefore({ renderer: e }) {
|
|
261
364
|
if (e == null)
|
|
262
365
|
return;
|
|
263
366
|
const { inputNode: t } = this;
|
|
264
|
-
|
|
265
|
-
const { width:
|
|
266
|
-
this.setSize(
|
|
367
|
+
y(t != null);
|
|
368
|
+
const { width: o, height: n } = t.value;
|
|
369
|
+
this.setSize(o, n), this.inputTexelSize.value.set(1 / o, 1 / n), this.rendererState = oo(e, this.rendererState), e.setRenderTarget(this.renderTarget), this.mesh.render(e), no(e, this.rendererState);
|
|
267
370
|
}
|
|
268
371
|
setup(e) {
|
|
269
372
|
const { inputNode: t } = this;
|
|
270
|
-
|
|
271
|
-
const { material:
|
|
272
|
-
return
|
|
373
|
+
y(t != null);
|
|
374
|
+
const { material: o } = this;
|
|
375
|
+
return o.fragmentNode = this.setupOutputNode(e), o.needsUpdate = !0, super.setup(e);
|
|
273
376
|
}
|
|
274
377
|
dispose() {
|
|
275
378
|
this.renderTarget.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
276
379
|
}
|
|
277
380
|
}
|
|
278
|
-
class
|
|
381
|
+
class Bt extends io {
|
|
279
382
|
constructor(e) {
|
|
280
|
-
super(e), this.thresholdLevel =
|
|
383
|
+
super(e), this.thresholdLevel = g(5), this.thresholdRange = g(1), this.resolutionScale = 0.5;
|
|
281
384
|
}
|
|
282
385
|
static get type() {
|
|
283
386
|
return "DownsampleThresholdNode";
|
|
284
387
|
}
|
|
285
388
|
setupOutputNode() {
|
|
286
|
-
const { inputNode: e, thresholdLevel: t, thresholdRange:
|
|
287
|
-
|
|
288
|
-
const
|
|
389
|
+
const { inputNode: e, thresholdLevel: t, thresholdRange: o, inputTexelSize: n } = this;
|
|
390
|
+
y(e != null);
|
|
391
|
+
const i = Dt(e, n), r = Xt(i.rgb), c = dt(
|
|
289
392
|
t,
|
|
290
|
-
t.add(
|
|
291
|
-
|
|
393
|
+
t.add(o),
|
|
394
|
+
r
|
|
292
395
|
);
|
|
293
|
-
return
|
|
396
|
+
return z(i.rgb, r).mul(c);
|
|
294
397
|
}
|
|
295
398
|
}
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
function K({
|
|
305
|
-
typeOnly: o = !1,
|
|
306
|
-
...e
|
|
307
|
-
}) {
|
|
308
|
-
return o ? (t) => C(t) : (t) => C(t).setLayout({
|
|
309
|
-
...e,
|
|
310
|
-
type: me(e.type),
|
|
311
|
-
inputs: e.inputs?.map((s) => ({
|
|
312
|
-
...s,
|
|
313
|
-
type: me(s.type)
|
|
314
|
-
})) ?? []
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
function G(o) {
|
|
318
|
-
return C((e, t) => {
|
|
319
|
-
const s = o(...e);
|
|
320
|
-
return typeof s == "function" ? s(t) : s;
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
const { resetRendererState: es, restoreRendererState: ts } = O;
|
|
324
|
-
class ss extends _ {
|
|
399
|
+
const zn = (...s) => new Bt(...s), Cn = (s) => {
|
|
400
|
+
const e = _t(s);
|
|
401
|
+
return e.updateType = H.NONE, e;
|
|
402
|
+
}, Rn = (s) => {
|
|
403
|
+
const e = Zt(s);
|
|
404
|
+
return e.updateBeforeType = H.FRAME, e;
|
|
405
|
+
}, { resetRendererState: ro, restoreRendererState: ao } = ge;
|
|
406
|
+
class co extends Re {
|
|
325
407
|
constructor(e) {
|
|
326
|
-
super(e), this.iterations = 1, this.material = new
|
|
408
|
+
super(e), this.iterations = 1, this.material = new ce(), this.mesh = new ze(this.material), this.inputTexelSize = g("vec2"), this.direction = g("vec2");
|
|
409
|
+
const t = this.constructor.type.replace(/Node$/, "");
|
|
410
|
+
this.material.name = t, this.mesh.name = t, this.horizontalRT = this.createRenderTarget("horizontal"), this.verticalRT = this.createRenderTarget("vertical"), this.outputTexture = this.verticalRT.texture;
|
|
327
411
|
}
|
|
328
412
|
setSize(e, t) {
|
|
329
|
-
const { resolutionScale:
|
|
330
|
-
return this.horizontalRT.setSize(n,
|
|
413
|
+
const { resolutionScale: o } = this, n = Math.max(Math.round(e * o), 1), i = Math.max(Math.round(t * o), 1);
|
|
414
|
+
return this.horizontalRT.setSize(n, i), this.verticalRT.setSize(n, i), this;
|
|
331
415
|
}
|
|
332
416
|
updateBefore({ renderer: e }) {
|
|
333
417
|
if (e == null)
|
|
334
418
|
return;
|
|
335
|
-
const { horizontalRT: t, verticalRT:
|
|
336
|
-
|
|
337
|
-
const { width:
|
|
338
|
-
this.setSize(
|
|
339
|
-
const h =
|
|
340
|
-
this.rendererState =
|
|
341
|
-
for (let
|
|
342
|
-
|
|
343
|
-
|
|
419
|
+
const { horizontalRT: t, verticalRT: o, mesh: n, inputNode: i, direction: r } = this;
|
|
420
|
+
y(i != null);
|
|
421
|
+
const { width: c, height: a } = i.value;
|
|
422
|
+
this.setSize(c, a), this.inputTexelSize.value.set(1 / c, 1 / a);
|
|
423
|
+
const h = i.value;
|
|
424
|
+
this.rendererState = ro(e, this.rendererState);
|
|
425
|
+
for (let l = 0; l < this.iterations; ++l)
|
|
426
|
+
r.value.set(1, 0), e.setRenderTarget(t), n.render(e), i.value = t.texture, r.value.set(0, 1), e.setRenderTarget(o), n.render(e), i.value = o.texture;
|
|
427
|
+
ao(e, this.rendererState), i.value = h;
|
|
344
428
|
}
|
|
345
429
|
setup(e) {
|
|
346
430
|
const { inputNode: t } = this;
|
|
347
|
-
|
|
348
|
-
const { material:
|
|
349
|
-
return
|
|
431
|
+
y(t != null);
|
|
432
|
+
const { material: o } = this;
|
|
433
|
+
return o.fragmentNode = this.setupOutputNode(e), o.needsUpdate = !0, super.setup(e);
|
|
350
434
|
}
|
|
351
435
|
dispose() {
|
|
352
436
|
this.horizontalRT.dispose(), this.verticalRT.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
353
437
|
}
|
|
354
438
|
}
|
|
355
|
-
function
|
|
356
|
-
if (
|
|
439
|
+
function et(s) {
|
|
440
|
+
if (y(s >= 0), s === 0)
|
|
357
441
|
return new Float64Array(0);
|
|
358
|
-
if (
|
|
442
|
+
if (s === 1)
|
|
359
443
|
return new Float64Array([1]);
|
|
360
|
-
let e = new Float64Array(
|
|
361
|
-
for (let n = 1; n <=
|
|
362
|
-
for (let
|
|
363
|
-
t[
|
|
364
|
-
|
|
444
|
+
let e = new Float64Array(s), t = new Float64Array(s), o = t;
|
|
445
|
+
for (let n = 1; n <= s; ++n) {
|
|
446
|
+
for (let i = 0; i < n; ++i)
|
|
447
|
+
t[i] = i === 0 || i === n - 1 ? 1 : e[i - 1] + e[i];
|
|
448
|
+
o = t, t = e, e = o;
|
|
365
449
|
}
|
|
366
|
-
return
|
|
450
|
+
return o;
|
|
367
451
|
}
|
|
368
|
-
function
|
|
369
|
-
|
|
370
|
-
const t =
|
|
371
|
-
a[0] =
|
|
372
|
-
for (let
|
|
373
|
-
const
|
|
374
|
-
a[
|
|
375
|
-
}
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
378
|
-
const
|
|
379
|
-
for (let
|
|
380
|
-
a[
|
|
452
|
+
function uo(s, e = 2) {
|
|
453
|
+
y(s >= 3);
|
|
454
|
+
const t = s + e * 2, o = e > 0 ? et(t).slice(e, -e) : et(t), n = Math.floor((o.length - 1) / 2), i = o.reduce((u, p) => u + p, 0), r = o.slice(n), c = [...Array(n + 1).keys()], a = new Float64Array(Math.floor(c.length / 2)), h = new Float64Array(a.length);
|
|
455
|
+
a[0] = r[0] / i;
|
|
456
|
+
for (let u = 1, p = 1; u < c.length - 1; u += 2, ++p) {
|
|
457
|
+
const d = c[u], m = c[u + 1], x = r[u], w = r[u + 1], T = x + w, C = (d * x + m * w) / T;
|
|
458
|
+
a[p] = T / i, h[p] = C;
|
|
459
|
+
}
|
|
460
|
+
const l = (a.reduce((u, p) => u + p, 0) - a[0] * 0.5) * 2;
|
|
461
|
+
if (l !== 0) {
|
|
462
|
+
const u = 1 / l;
|
|
463
|
+
for (let p = 0; p < a.length; ++p)
|
|
464
|
+
a[p] *= u;
|
|
381
465
|
}
|
|
382
466
|
return {
|
|
383
467
|
offsets: h,
|
|
384
468
|
weights: a
|
|
385
469
|
};
|
|
386
470
|
}
|
|
387
|
-
class
|
|
471
|
+
class At extends co {
|
|
388
472
|
static get type() {
|
|
389
473
|
return "GaussianBlurNode";
|
|
390
474
|
}
|
|
@@ -392,61 +476,64 @@ class Oe extends ss {
|
|
|
392
476
|
super(e), this.kernelSize = t;
|
|
393
477
|
}
|
|
394
478
|
setupOutputNode(e) {
|
|
395
|
-
const { inputNode: t, inputTexelSize:
|
|
396
|
-
|
|
397
|
-
const { offsets:
|
|
398
|
-
return
|
|
399
|
-
const
|
|
400
|
-
for (let
|
|
401
|
-
const
|
|
479
|
+
const { inputNode: t, inputTexelSize: o, direction: n } = this;
|
|
480
|
+
y(t != null);
|
|
481
|
+
const { offsets: i, weights: r } = uo(this.kernelSize);
|
|
482
|
+
return U(() => {
|
|
483
|
+
const c = I(), a = n.mul(o).toVertexStage(), h = t.sample(c).mul(r[0]);
|
|
484
|
+
for (let l = 1; l < i.length; ++l) {
|
|
485
|
+
const u = a.mul(i[l]);
|
|
402
486
|
h.addAssign(
|
|
403
|
-
|
|
404
|
-
t.sample(
|
|
405
|
-
t.sample(
|
|
406
|
-
).mul(
|
|
487
|
+
B(
|
|
488
|
+
t.sample(c.add(u)),
|
|
489
|
+
t.sample(c.sub(u))
|
|
490
|
+
).mul(r[l])
|
|
407
491
|
);
|
|
408
492
|
}
|
|
409
493
|
return h;
|
|
410
494
|
})();
|
|
411
495
|
}
|
|
412
496
|
}
|
|
413
|
-
const
|
|
414
|
-
const
|
|
415
|
-
return
|
|
416
|
-
}).once()(),
|
|
417
|
-
const
|
|
418
|
-
return
|
|
497
|
+
const Dn = (...s) => new At(...s), lo = (s) => s.dot(f(0.06711056, 583715e-8)).fract().mul(52.9829189).fract(), Bn = /* @__PURE__ */ U(() => {
|
|
498
|
+
const s = f(ke.xy).add(Kt.fract().mul(1337)), e = lo(s);
|
|
499
|
+
return M(e, e.oneMinus(), e).sub(0.5).div(255);
|
|
500
|
+
}).once()(), An = (s, e, t = f(90, 45)) => {
|
|
501
|
+
const o = Qt(s), n = Jt(o), i = e.mul(n).mul(0.5), r = _(o.mul(t).fract().sub(0.5)).div(t), c = dt(i, i.add(n), r).oneMinus();
|
|
502
|
+
return c.x.add(c.y).clamp(0, 1);
|
|
419
503
|
};
|
|
420
|
-
class
|
|
504
|
+
class ho extends Q {
|
|
421
505
|
constructor() {
|
|
422
|
-
super("vec3"), this.currentProjectionMatrix =
|
|
506
|
+
super("vec3"), this.currentProjectionMatrix = g("mat4"), this.previousProjectionMatrix = g("mat4"), this.currentModelViewMatrix = g("mat4"), this.previousModelViewMatrix = g("mat4"), this.objectModelViewMatrices = /* @__PURE__ */ new WeakMap(), this.updateType = H.FRAME, this.updateBeforeType = H.OBJECT, this.updateAfterType = H.OBJECT;
|
|
423
507
|
}
|
|
424
508
|
static get type() {
|
|
425
509
|
return "HighpVelocityNode";
|
|
426
510
|
}
|
|
511
|
+
setProjectionMatrix(e) {
|
|
512
|
+
return this.projectionMatrix = e, this;
|
|
513
|
+
}
|
|
427
514
|
// Executed once per frame:
|
|
428
515
|
update({ camera: e }) {
|
|
429
516
|
if (e == null)
|
|
430
517
|
return;
|
|
431
518
|
const {
|
|
432
519
|
currentProjectionMatrix: t,
|
|
433
|
-
previousProjectionMatrix:
|
|
520
|
+
previousProjectionMatrix: o
|
|
434
521
|
} = this, n = this.projectionMatrix ?? e.projectionMatrix;
|
|
435
|
-
|
|
522
|
+
o.value == null ? o.value = new Se().copy(n) : o.value.copy(t.value), t.value.copy(n);
|
|
436
523
|
}
|
|
437
524
|
// Executed once per object before rendering:
|
|
438
525
|
updateBefore({ object: e, camera: t }) {
|
|
439
526
|
if (e == null || t == null)
|
|
440
527
|
return;
|
|
441
528
|
const {
|
|
442
|
-
currentModelViewMatrix:
|
|
529
|
+
currentModelViewMatrix: o,
|
|
443
530
|
previousModelViewMatrix: n,
|
|
444
|
-
objectModelViewMatrices:
|
|
531
|
+
objectModelViewMatrices: i
|
|
445
532
|
} = this;
|
|
446
|
-
|
|
533
|
+
o.value.multiplyMatrices(
|
|
447
534
|
t.matrixWorldInverse,
|
|
448
535
|
e.matrixWorld
|
|
449
|
-
), n.value =
|
|
536
|
+
), n.value = i.get(e) ?? o.value;
|
|
450
537
|
}
|
|
451
538
|
// Executed once per object after rendering:
|
|
452
539
|
updateAfter({ object: e }) {
|
|
@@ -454,18 +541,18 @@ class rs extends E {
|
|
|
454
541
|
return;
|
|
455
542
|
const {
|
|
456
543
|
currentModelViewMatrix: t,
|
|
457
|
-
objectModelViewMatrices:
|
|
544
|
+
objectModelViewMatrices: o
|
|
458
545
|
} = this;
|
|
459
|
-
let n =
|
|
460
|
-
n == null && (n = new
|
|
546
|
+
let n = o.get(e);
|
|
547
|
+
n == null && (n = new Se(), o.set(e, n)), n.copy(t.value);
|
|
461
548
|
}
|
|
462
549
|
setup(e) {
|
|
463
|
-
const t = this.currentProjectionMatrix.mul(this.currentModelViewMatrix).mul(
|
|
464
|
-
return
|
|
550
|
+
const t = this.currentProjectionMatrix.mul(this.currentModelViewMatrix).mul(es).toVertexStage(), o = this.previousProjectionMatrix.mul(this.previousModelViewMatrix).mul(ts).toVertexStage(), n = t.xyz.div(t.w), i = o.xyz.div(o.w);
|
|
551
|
+
return ie(n, i);
|
|
465
552
|
}
|
|
466
553
|
}
|
|
467
|
-
const
|
|
468
|
-
class
|
|
554
|
+
const tt = /* @__PURE__ */ pt(ho);
|
|
555
|
+
class po extends qe {
|
|
469
556
|
static get type() {
|
|
470
557
|
return "KawaseBlurNode";
|
|
471
558
|
}
|
|
@@ -473,49 +560,49 @@ class is extends ae {
|
|
|
473
560
|
super(e, t), this.resolutionScale = 0.5;
|
|
474
561
|
}
|
|
475
562
|
setupDownsampleNode(e) {
|
|
476
|
-
const { inputNode: t, inputTexelSize:
|
|
477
|
-
|
|
478
|
-
const n =
|
|
479
|
-
return
|
|
563
|
+
const { inputNode: t, inputTexelSize: o } = this;
|
|
564
|
+
y(t != null);
|
|
565
|
+
const n = I(), i = z(1, 1, -1, -1).mul(o.xyxy.mul(0.5)).add(n.xyxy).toVertexStage(), r = i.zy, c = i.xy, a = i.xw, h = i.zw;
|
|
566
|
+
return B(
|
|
480
567
|
t.sample(n).mul(4),
|
|
481
|
-
t.sample(
|
|
482
|
-
t.sample(
|
|
568
|
+
t.sample(r),
|
|
569
|
+
t.sample(c),
|
|
483
570
|
t.sample(a),
|
|
484
571
|
t.sample(h)
|
|
485
572
|
).mul(1 / 8);
|
|
486
573
|
}
|
|
487
574
|
setupUpsampleNode(e) {
|
|
488
|
-
const { inputNode: t, inputTexelSize:
|
|
489
|
-
|
|
490
|
-
const n =
|
|
491
|
-
return
|
|
492
|
-
|
|
493
|
-
t.sample(
|
|
494
|
-
t.sample(
|
|
575
|
+
const { inputNode: t, inputTexelSize: o } = this;
|
|
576
|
+
y(t != null);
|
|
577
|
+
const n = I(), i = z(1, 1, -1, -1).mul(o.xyxy.mul(0.5)).add(n.xyxy).toVertexStage(), r = i.zy, c = i.xy, a = i.xw, h = i.zw, l = f(i.z, n.y), u = f(i.x, n.y), p = f(n.x, i.y), d = f(n.x, i.w);
|
|
578
|
+
return B(
|
|
579
|
+
B(
|
|
580
|
+
t.sample(r),
|
|
581
|
+
t.sample(c),
|
|
495
582
|
t.sample(a),
|
|
496
583
|
t.sample(h)
|
|
497
584
|
).mul(1 / 12),
|
|
498
|
-
|
|
499
|
-
t.sample(c),
|
|
585
|
+
B(
|
|
500
586
|
t.sample(l),
|
|
501
|
-
t.sample(
|
|
502
|
-
t.sample(
|
|
587
|
+
t.sample(u),
|
|
588
|
+
t.sample(p),
|
|
589
|
+
t.sample(d)
|
|
503
590
|
).mul(1 / 6)
|
|
504
591
|
);
|
|
505
592
|
}
|
|
506
593
|
}
|
|
507
|
-
const
|
|
508
|
-
class
|
|
594
|
+
const Vn = (...s) => new po(...s);
|
|
595
|
+
class mo extends Q {
|
|
509
596
|
constructor(e) {
|
|
510
|
-
super("vec3"), this.intensity =
|
|
597
|
+
super("vec3"), this.intensity = g(1e-5), this.inputNode = e;
|
|
511
598
|
}
|
|
512
599
|
static get type() {
|
|
513
600
|
return "LensGhostNode";
|
|
514
601
|
}
|
|
515
602
|
setup(e) {
|
|
516
|
-
const { inputNode: t, intensity:
|
|
517
|
-
|
|
518
|
-
const n =
|
|
603
|
+
const { inputNode: t, intensity: o } = this;
|
|
604
|
+
y(t != null);
|
|
605
|
+
const n = V({
|
|
519
606
|
name: "sampleGhost",
|
|
520
607
|
type: "vec3",
|
|
521
608
|
inputs: [
|
|
@@ -524,77 +611,33 @@ class as extends E {
|
|
|
524
611
|
{ name: "color", type: "vec3" },
|
|
525
612
|
{ name: "offset", type: "float" }
|
|
526
613
|
]
|
|
527
|
-
})(([a, h,
|
|
528
|
-
const
|
|
529
|
-
return
|
|
530
|
-
}),
|
|
531
|
-
return
|
|
532
|
-
n(
|
|
533
|
-
n(
|
|
534
|
-
n(
|
|
535
|
-
n(
|
|
536
|
-
n(
|
|
537
|
-
n(
|
|
538
|
-
n(
|
|
539
|
-
n(
|
|
540
|
-
n(
|
|
541
|
-
).mul(
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
const { resetRendererState: us, restoreRendererState: ls } = O;
|
|
545
|
-
function cs() {
|
|
546
|
-
const o = new kt(1, 1, {
|
|
547
|
-
depthBuffer: !1,
|
|
548
|
-
type: Et,
|
|
549
|
-
format: $t
|
|
550
|
-
}), e = o.texture;
|
|
551
|
-
return e.minFilter = he, e.magFilter = he, e.generateMipmaps = !1, o;
|
|
552
|
-
}
|
|
553
|
-
const hs = /* @__PURE__ */ new It();
|
|
554
|
-
class Ge extends se {
|
|
555
|
-
constructor(e, t) {
|
|
556
|
-
const s = cs();
|
|
557
|
-
super(s.texture, t ?? V()), this.resolutionScale = 1, this.material = new P(), this.mesh = new q(this.material), this.node = e, this.renderTarget = s, this.updateBeforeType = A.FRAME;
|
|
558
|
-
}
|
|
559
|
-
static get type() {
|
|
560
|
-
return "RTTextureNode";
|
|
561
|
-
}
|
|
562
|
-
setSize(e, t) {
|
|
563
|
-
const { resolutionScale: s } = this, n = Math.max(Math.round(e * s), 1), r = Math.max(Math.round(t * s), 1);
|
|
564
|
-
return this.renderTarget.setSize(n, r), this;
|
|
565
|
-
}
|
|
566
|
-
updateBefore({ renderer: e }) {
|
|
567
|
-
if (e == null)
|
|
568
|
-
return;
|
|
569
|
-
const t = e.getDrawingBufferSize(hs);
|
|
570
|
-
this.setSize(t.x, t.y), this.rendererState = us(e, this.rendererState), e.setRenderTarget(this.renderTarget), this.mesh.render(e), ls(e, this.rendererState);
|
|
571
|
-
}
|
|
572
|
-
setup(e) {
|
|
573
|
-
const { material: t } = this;
|
|
574
|
-
return t.fragmentNode = this.node.context(e.getContext()), t.needsUpdate = !0, super.setup(e);
|
|
575
|
-
}
|
|
576
|
-
dispose() {
|
|
577
|
-
this.renderTarget.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
578
|
-
}
|
|
579
|
-
// @ts-expect-error Ignore
|
|
580
|
-
clone() {
|
|
581
|
-
const e = new se(this.value, this.uvNode, this.levelNode);
|
|
582
|
-
return e.sampler = this.sampler, e.referenceNode = this, e;
|
|
614
|
+
})(([a, h, l, u]) => {
|
|
615
|
+
const p = h.mul(u).add(a.oneMinus()).saturate(), d = t.sample(p).rgb.mul(l), m = ie(0.5, p).length().mul(1 / (Math.SQRT2 / 4)).saturate();
|
|
616
|
+
return d.mulAssign(m.oneMinus().pow(3)), d;
|
|
617
|
+
}), i = I(), r = i.sub(0.5);
|
|
618
|
+
return B(
|
|
619
|
+
n(i, r, M(0.8, 0.8, 1), -5),
|
|
620
|
+
n(i, r, M(1, 0.8, 0.4), -1.5),
|
|
621
|
+
n(i, r, M(0.9, 1, 0.8), -0.4),
|
|
622
|
+
n(i, r, M(1, 0.8, 0.4), -0.2),
|
|
623
|
+
n(i, r, M(0.9, 0.7, 0.7), -0.1),
|
|
624
|
+
n(i, r, M(0.5, 1, 0.4), 0.7),
|
|
625
|
+
n(i, r, M(0.5, 0.5, 0.5), 1),
|
|
626
|
+
n(i, r, M(1, 1, 0.6), 2.5),
|
|
627
|
+
n(i, r, M(0.5, 0.8, 1), 10)
|
|
628
|
+
).mul(o);
|
|
583
629
|
}
|
|
584
630
|
}
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
x(n != null), n.beginPath(), n.moveTo(0, 32 / 2), n.lineTo(256 / 2, 5), n.lineTo(256, 32 / 2), n.lineTo(256 / 2, 27), n.closePath();
|
|
594
|
-
const r = n.createLinearGradient(0, 0, 256, 0);
|
|
595
|
-
return r.addColorStop(0, "#000000"), r.addColorStop(0.5, "#ffffff"), r.addColorStop(1, "#000000"), n.fillStyle = r, n.fill(), new Xe(s);
|
|
631
|
+
const { resetRendererState: fo, restoreRendererState: xo } = ge;
|
|
632
|
+
function go() {
|
|
633
|
+
const o = document.createElement("canvas");
|
|
634
|
+
o.width = 256, o.height = 32;
|
|
635
|
+
const n = o.getContext("2d");
|
|
636
|
+
y(n != null), n.beginPath(), n.moveTo(0, 32 / 2), n.lineTo(256 / 2, 5), n.lineTo(256, 32 / 2), n.lineTo(256 / 2, 27), n.closePath();
|
|
637
|
+
const i = n.createLinearGradient(0, 0, 256, 0);
|
|
638
|
+
return i.addColorStop(0, "#000000"), i.addColorStop(0.5, "#ffffff"), i.addColorStop(1, "#000000"), n.fillStyle = i, n.fill(), new Is(o);
|
|
596
639
|
}
|
|
597
|
-
const
|
|
640
|
+
const st = /* @__PURE__ */ Ie({
|
|
598
641
|
color: "vec3",
|
|
599
642
|
luminance: "float",
|
|
600
643
|
position: "vec2",
|
|
@@ -602,69 +645,71 @@ const ge = /* @__PURE__ */ oe({
|
|
|
602
645
|
sin: "float",
|
|
603
646
|
cos: "float"
|
|
604
647
|
});
|
|
605
|
-
class
|
|
648
|
+
class vo extends Re {
|
|
606
649
|
constructor(e) {
|
|
607
|
-
super(e), this.spikePairCount = 6, this.wireframe = !1, this.intensity =
|
|
650
|
+
super(e), this.spikePairCount = 6, this.wireframe = !1, this.intensity = g(1e-5), this.sizeScale = g(new ve(1.5, 0.01)), this.luminanceThreshold = g(100), this.indirectBuffer = new Ms(
|
|
651
|
+
new Uint32Array([6, 0, 0, 0, 0]),
|
|
652
|
+
1
|
|
653
|
+
), this.instanceBuffer = _e(1, st), this.renderTarget = this.createRenderTarget(), this.material = new zs({
|
|
608
654
|
depthTest: !1,
|
|
609
655
|
depthWrite: !1,
|
|
610
656
|
transparent: !0,
|
|
611
|
-
blending:
|
|
612
|
-
}), this.mesh = new
|
|
657
|
+
blending: Us
|
|
658
|
+
}), this.mesh = new bt(new js(1, 1), this.material), this.camera = new Es(), this.inputTexelSize = g("vec2"), this.outputTexelSize = g("vec2"), this.geometryRatio = g("vec2"), this.material.name = "LensGlare", this.inputNode = e, this.resolutionScale = 0.5, this.outputTexture = this.renderTarget.texture, this.mesh.geometry.indirect = this.indirectBuffer;
|
|
613
659
|
}
|
|
614
660
|
customCacheKey() {
|
|
615
|
-
return
|
|
661
|
+
return We(this.spikePairCount, +this.wireframe);
|
|
616
662
|
}
|
|
617
663
|
setSize(e, t) {
|
|
618
|
-
const { resolutionScale:
|
|
619
|
-
this.renderTarget.setSize(n,
|
|
620
|
-
const
|
|
621
|
-
return this.instanceBuffer.bufferCount < a && (this.instanceBuffer.dispose(), this.instanceBuffer =
|
|
664
|
+
const { resolutionScale: o } = this, n = Math.max(Math.round(e * o), 1), i = Math.max(Math.round(t * o), 1);
|
|
665
|
+
this.renderTarget.setSize(n, i);
|
|
666
|
+
const r = Math.floor(n / 2), c = Math.floor(i / 2), a = r * c;
|
|
667
|
+
return this.instanceBuffer.bufferCount < a && (this.instanceBuffer.dispose(), this.instanceBuffer = _e(a, st), this.setupCompute(r, c), this.setupMaterial()), this;
|
|
622
668
|
}
|
|
623
669
|
updateBefore({ renderer: e }) {
|
|
624
670
|
if (e == null)
|
|
625
671
|
return;
|
|
626
672
|
const { inputNode: t } = this;
|
|
627
|
-
|
|
628
|
-
const { width:
|
|
629
|
-
this.setSize(
|
|
630
|
-
const { computeNode:
|
|
631
|
-
|
|
632
|
-
const a =
|
|
673
|
+
y(t != null);
|
|
674
|
+
const { width: o, height: n } = t.value;
|
|
675
|
+
this.setSize(o, n);
|
|
676
|
+
const { computeNode: i, indirectBuffer: r, renderTarget: c } = this;
|
|
677
|
+
y(i != null), this.inputTexelSize.value.set(1 / o, 1 / n);
|
|
678
|
+
const a = o / n;
|
|
633
679
|
a > 1 ? this.geometryRatio.value.set(1 / a, 1) : this.geometryRatio.value.set(1, a);
|
|
634
|
-
const { width: h, height:
|
|
635
|
-
this.outputTexelSize.value.set(1 / h, 1 /
|
|
636
|
-
this.mesh.count = new Uint32Array(l)[0];
|
|
637
|
-
}).catch((l) => {
|
|
638
|
-
console.error(l);
|
|
639
|
-
}), this.rendererState = ps(e, this.rendererState), e.setRenderTarget(u), e.render(this.mesh, this.camera), ms(e, this.rendererState);
|
|
680
|
+
const { width: h, height: l } = c;
|
|
681
|
+
this.outputTexelSize.value.set(1 / h, 1 / l), r.array[1] = 0, r.needsUpdate = !0, e.compute(i), this.rendererState = fo(e, this.rendererState), e.setRenderTarget(c), e.render(this.mesh, this.camera), xo(e, this.rendererState);
|
|
640
682
|
}
|
|
641
683
|
setupCompute(e, t) {
|
|
642
684
|
const {
|
|
643
|
-
spikePairCount:
|
|
685
|
+
spikePairCount: o,
|
|
644
686
|
inputNode: n,
|
|
645
|
-
|
|
646
|
-
instanceBuffer:
|
|
647
|
-
outputTexelSize:
|
|
687
|
+
indirectBuffer: i,
|
|
688
|
+
instanceBuffer: r,
|
|
689
|
+
outputTexelSize: c
|
|
648
690
|
} = this;
|
|
649
|
-
|
|
650
|
-
const a =
|
|
651
|
-
|
|
691
|
+
y(n != null);
|
|
692
|
+
const a = ss(
|
|
693
|
+
i,
|
|
652
694
|
"uint",
|
|
653
|
-
|
|
695
|
+
i.count
|
|
654
696
|
).toAtomic();
|
|
655
|
-
this.computeNode =
|
|
656
|
-
const h =
|
|
657
|
-
|
|
658
|
-
|
|
697
|
+
this.computeNode = U(() => {
|
|
698
|
+
const h = re(e, t);
|
|
699
|
+
ae(Ae.xy.greaterThanEqual(h).any(), () => {
|
|
700
|
+
os();
|
|
659
701
|
});
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
const
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
702
|
+
const l = f(Ae.xy).mul(c).mul(2), u = n.sample(l), p = u.a;
|
|
703
|
+
ae(p.greaterThan(0.1), () => {
|
|
704
|
+
const d = ns(
|
|
705
|
+
a.element(1),
|
|
706
|
+
o
|
|
707
|
+
);
|
|
708
|
+
for (let m = 0; m < o; ++m) {
|
|
709
|
+
const x = r.element(d.add(m));
|
|
710
|
+
x.get("color").assign(u.rgb), x.get("luminance").assign(p), x.get("position").assign(Ae.xy), x.get("scale").assign(m % 2 === 0 ? 1 : 0.5);
|
|
711
|
+
const w = Math.PI * (3 - Math.sqrt(5)), T = Math.PI / o * m + w;
|
|
712
|
+
x.get("sin").assign(Math.sin(T)), x.get("cos").assign(Math.cos(T));
|
|
668
713
|
}
|
|
669
714
|
});
|
|
670
715
|
})().compute(
|
|
@@ -677,29 +722,29 @@ class gs extends _ {
|
|
|
677
722
|
const {
|
|
678
723
|
inputNode: e,
|
|
679
724
|
spikeNode: t,
|
|
680
|
-
instanceBuffer:
|
|
725
|
+
instanceBuffer: o,
|
|
681
726
|
luminanceThreshold: n,
|
|
682
|
-
intensity:
|
|
683
|
-
sizeScale:
|
|
684
|
-
outputTexelSize:
|
|
727
|
+
intensity: i,
|
|
728
|
+
sizeScale: r,
|
|
729
|
+
outputTexelSize: c,
|
|
685
730
|
geometryRatio: a
|
|
686
731
|
} = this;
|
|
687
|
-
|
|
688
|
-
const h =
|
|
689
|
-
this.material.colorNode = this.wireframe ?
|
|
690
|
-
const
|
|
732
|
+
y(e != null), y(t != null);
|
|
733
|
+
const h = o.element(is);
|
|
734
|
+
this.material.colorNode = this.wireframe ? z(1) : t.mul(h.get("color").mul(i)), this.material.vertexNode = U(() => {
|
|
735
|
+
const l = h.get("sin"), u = h.get("cos"), p = mt(u, l, 0, l.negate(), u, 0, 0, 0, 1), m = h.get("position").mul(c).mul(2), x = m.flipY().mul(2).sub(1), T = h.get("luminance").div(n).saturate(), C = f(T, 1).mul(
|
|
691
736
|
h.get("scale"),
|
|
692
|
-
|
|
737
|
+
r,
|
|
693
738
|
// Make the spike to shrink at screen borders:
|
|
694
|
-
|
|
695
|
-
),
|
|
696
|
-
return
|
|
739
|
+
m.sub(0.5).length().mul(2).oneMinus().mul(0.5).add(0.5)
|
|
740
|
+
), j = p.mul(ht.mul(z(C, 1, 1))).mul(a).add(M(x, 0));
|
|
741
|
+
return z(j, 1);
|
|
697
742
|
})(), this.material.wireframe = this.wireframe, this.material.needsUpdate = !0;
|
|
698
743
|
}
|
|
699
744
|
setup(e) {
|
|
700
745
|
if (this.spikeNode == null) {
|
|
701
|
-
const t =
|
|
702
|
-
t.colorSpace =
|
|
746
|
+
const t = go();
|
|
747
|
+
t.colorSpace = ks, this.spikeNode = oe(t);
|
|
703
748
|
}
|
|
704
749
|
return this.setupMaterial(), super.setup(e);
|
|
705
750
|
}
|
|
@@ -707,10 +752,10 @@ class gs extends _ {
|
|
|
707
752
|
this.renderTarget.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
708
753
|
}
|
|
709
754
|
}
|
|
710
|
-
const
|
|
711
|
-
class
|
|
755
|
+
const yo = /* @__PURE__ */ new ve();
|
|
756
|
+
class wo extends Q {
|
|
712
757
|
constructor(e) {
|
|
713
|
-
super("vec3"), this.intensity =
|
|
758
|
+
super("vec3"), this.intensity = g(1e-5), this.chromaticAberration = g(5e-3), this.aspectRatio = g(0), this.updateBeforeType = H.FRAME, this.inputNode = e;
|
|
714
759
|
}
|
|
715
760
|
static get type() {
|
|
716
761
|
return "LensHaloNode";
|
|
@@ -718,13 +763,13 @@ class vs extends E {
|
|
|
718
763
|
updateBefore({ renderer: e }) {
|
|
719
764
|
if (e == null)
|
|
720
765
|
return;
|
|
721
|
-
const { width: t, height:
|
|
722
|
-
this.aspectRatio.value = t /
|
|
766
|
+
const { width: t, height: o } = e.getDrawingBufferSize(yo);
|
|
767
|
+
this.aspectRatio.value = t / o;
|
|
723
768
|
}
|
|
724
769
|
setup(e) {
|
|
725
|
-
const { inputNode: t, intensity:
|
|
726
|
-
|
|
727
|
-
const
|
|
770
|
+
const { inputNode: t, intensity: o, chromaticAberration: n, aspectRatio: i } = this;
|
|
771
|
+
y(t != null);
|
|
772
|
+
const r = V({
|
|
728
773
|
name: "cubicRingMask",
|
|
729
774
|
type: "float",
|
|
730
775
|
inputs: [
|
|
@@ -732,101 +777,101 @@ class vs extends E {
|
|
|
732
777
|
{ name: "radius", type: "float" },
|
|
733
778
|
{ name: "thickness", type: "float" }
|
|
734
779
|
]
|
|
735
|
-
})(([
|
|
736
|
-
const
|
|
737
|
-
return
|
|
738
|
-
}),
|
|
780
|
+
})(([l, u, p]) => {
|
|
781
|
+
const d = ft(_(l.sub(u)).div(p), 1);
|
|
782
|
+
return rs(d, d, ie(3, d.mul(2))).oneMinus();
|
|
783
|
+
}), c = V({
|
|
739
784
|
name: "sampleHalo",
|
|
740
785
|
type: "vec3",
|
|
741
786
|
inputs: [
|
|
742
787
|
{ name: "uv", type: "vec2" },
|
|
743
788
|
{ name: "radius", type: "float" }
|
|
744
789
|
]
|
|
745
|
-
})(([
|
|
746
|
-
const
|
|
747
|
-
t.sample(
|
|
748
|
-
t.sample(
|
|
749
|
-
t.sample(
|
|
750
|
-
),
|
|
751
|
-
return
|
|
752
|
-
}), a =
|
|
753
|
-
return
|
|
790
|
+
})(([l, u]) => {
|
|
791
|
+
const p = f(i, 1), d = l.sub(0.5).mul(p).normalize().div(p), m = M(n).mul(M(-1, 0, 1)), x = as(d.mul(u).add(l.oneMinus())), w = M(
|
|
792
|
+
t.sample(d.mul(m.r).add(x)).r,
|
|
793
|
+
t.sample(d.mul(m.g).add(x)).g,
|
|
794
|
+
t.sample(d.mul(m.b).add(x)).b
|
|
795
|
+
), T = l.sub(f(0.5, 0)).mul(p).add(f(0.5, 0)), C = cs(T, f(0.5)).saturate();
|
|
796
|
+
return w.mulAssign(r(C, 0.45, 0.25)), w;
|
|
797
|
+
}), a = I();
|
|
798
|
+
return c(a, 0.3).mul(o);
|
|
754
799
|
}
|
|
755
800
|
}
|
|
756
|
-
const
|
|
757
|
-
class
|
|
801
|
+
const E = (s) => s.greaterThanEqual(0).all().and(s.lessThanEqual(1).all()).toFloat();
|
|
802
|
+
class Vt extends qe {
|
|
758
803
|
constructor(e, t = 4) {
|
|
759
|
-
super(e, t), this.blendAmount =
|
|
804
|
+
super(e, t), this.blendAmount = g(0.85), this.resolutionScale = 0.5;
|
|
760
805
|
}
|
|
761
806
|
static get type() {
|
|
762
807
|
return "MipmapSurfaceBlurNode";
|
|
763
808
|
}
|
|
764
809
|
setupDownsampleNode(e) {
|
|
765
|
-
const { inputNode: t, inputTexelSize:
|
|
766
|
-
return
|
|
767
|
-
const n =
|
|
768
|
-
let
|
|
769
|
-
return
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
).mul(
|
|
775
|
-
t.sample(
|
|
776
|
-
t.sample(a).mul(
|
|
777
|
-
t.sample(h).mul(
|
|
778
|
-
t.sample(
|
|
779
|
-
),
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
).mul(
|
|
785
|
-
t.sample(
|
|
786
|
-
t.sample(
|
|
787
|
-
t.sample(
|
|
788
|
-
t.sample(
|
|
789
|
-
),
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
).mul(
|
|
795
|
-
t.sample(
|
|
796
|
-
t.sample(
|
|
797
|
-
t.sample(
|
|
798
|
-
t.sample(
|
|
799
|
-
),
|
|
810
|
+
const { inputNode: t, inputTexelSize: o } = this;
|
|
811
|
+
return y(t != null), U(() => {
|
|
812
|
+
const n = I(), i = z(1, 1, -1, -1).mul(o.xyxy).add(n.xyxy).toVertexStage(), r = z(2, 2, -2, -2).mul(o.xyxy).add(n.xyxy).toVertexStage(), c = i.zy, a = i.xy, h = i.zw, l = i.xw, u = r.zy, p = r.xy, d = r.zw, m = r.xw, x = f(n.x, r.y), w = f(r.z, n.y), T = f(r.x, n.y), C = f(n.x, r.w), j = 1 / 4 / 2, R = 1 / 9 / 2, F = t.sample(n).mul(R);
|
|
813
|
+
let b;
|
|
814
|
+
return b = z(
|
|
815
|
+
E(c),
|
|
816
|
+
E(a),
|
|
817
|
+
E(h),
|
|
818
|
+
E(l)
|
|
819
|
+
).mul(j), F.addAssign(
|
|
820
|
+
t.sample(c).mul(b.x),
|
|
821
|
+
t.sample(a).mul(b.y),
|
|
822
|
+
t.sample(h).mul(b.z),
|
|
823
|
+
t.sample(l).mul(b.w)
|
|
824
|
+
), b = z(
|
|
825
|
+
E(u),
|
|
826
|
+
E(p),
|
|
827
|
+
E(d),
|
|
828
|
+
E(m)
|
|
829
|
+
).mul(R), F.addAssign(
|
|
830
|
+
t.sample(u).mul(b.x),
|
|
831
|
+
t.sample(p).mul(b.y),
|
|
832
|
+
t.sample(d).mul(b.z),
|
|
833
|
+
t.sample(m).mul(b.w)
|
|
834
|
+
), b = z(
|
|
835
|
+
E(x),
|
|
836
|
+
E(w),
|
|
837
|
+
E(T),
|
|
838
|
+
E(C)
|
|
839
|
+
).mul(R), F.addAssign(
|
|
840
|
+
t.sample(x).mul(b.x),
|
|
841
|
+
t.sample(w).mul(b.y),
|
|
842
|
+
t.sample(T).mul(b.z),
|
|
843
|
+
t.sample(C).mul(b.w)
|
|
844
|
+
), F;
|
|
800
845
|
})();
|
|
801
846
|
}
|
|
802
847
|
setupUpsampleNode(e) {
|
|
803
|
-
const { inputNode: t, inputTexelSize:
|
|
804
|
-
|
|
805
|
-
const
|
|
806
|
-
t.sample(
|
|
807
|
-
|
|
808
|
-
t.sample(
|
|
848
|
+
const { inputNode: t, inputTexelSize: o, downsampleNode: n } = this;
|
|
849
|
+
y(t != null);
|
|
850
|
+
const i = I(), r = z(1, 1, -1, -1).mul(o.xyxy).add(i.xyxy).toVertexStage(), c = f(i.x, r.y), a = f(r.z, i.y), h = f(r.x, i.y), l = f(i.x, r.w), u = r.zy, p = r.xy, d = r.zw, m = r.xw, x = B(
|
|
851
|
+
t.sample(i).mul(1 / 4),
|
|
852
|
+
B(
|
|
853
|
+
t.sample(c),
|
|
809
854
|
t.sample(a),
|
|
810
855
|
t.sample(h),
|
|
811
|
-
t.sample(
|
|
856
|
+
t.sample(l)
|
|
812
857
|
).mul(1 / 8),
|
|
813
|
-
|
|
814
|
-
t.sample(
|
|
858
|
+
B(
|
|
859
|
+
t.sample(u),
|
|
860
|
+
t.sample(p),
|
|
815
861
|
t.sample(d),
|
|
816
|
-
t.sample(m)
|
|
817
|
-
t.sample(f)
|
|
862
|
+
t.sample(m)
|
|
818
863
|
).mul(1 / 16)
|
|
819
864
|
);
|
|
820
|
-
return
|
|
865
|
+
return ne(n.sample(i), x, this.blendAmount);
|
|
821
866
|
}
|
|
822
867
|
}
|
|
823
|
-
const
|
|
824
|
-
function
|
|
825
|
-
return (
|
|
868
|
+
const Pn = (...s) => new Vt(...s);
|
|
869
|
+
function Pt(s) {
|
|
870
|
+
return (s instanceof Cs ? s.renderer.backend : "backend" in s ? s.backend : s).isWebGPUBackend === !0;
|
|
826
871
|
}
|
|
827
|
-
class
|
|
872
|
+
class To extends Q {
|
|
828
873
|
constructor(e) {
|
|
829
|
-
super("vec4"), this.bloomIntensity =
|
|
874
|
+
super("vec4"), this.bloomIntensity = g(0.05), this.inputNode = e, this.thresholdNode = new Bt(), this.blurNode = new At(), this.ghostNode = new mo(), this.haloNode = new wo(), this.bloomNode = new Vt(null, 8), this.glareNode = new vo(), this.featuresNode = us(B(this.ghostNode, this.haloNode)), this.featuresNode.value.name = "LensFlare_features", this.featuresNode.pixelRatio = 0.5, this.blurNode.resolutionScale = 1, this.bloomNode.resolutionScale = 1, this.glareNode.resolutionScale = 1;
|
|
830
875
|
}
|
|
831
876
|
static get type() {
|
|
832
877
|
return "LensFlareNode";
|
|
@@ -834,82 +879,139 @@ class ys extends E {
|
|
|
834
879
|
setup(e) {
|
|
835
880
|
const {
|
|
836
881
|
inputNode: t,
|
|
837
|
-
thresholdNode:
|
|
882
|
+
thresholdNode: o,
|
|
838
883
|
blurNode: n,
|
|
839
|
-
ghostNode:
|
|
840
|
-
haloNode:
|
|
841
|
-
bloomNode:
|
|
884
|
+
ghostNode: i,
|
|
885
|
+
haloNode: r,
|
|
886
|
+
bloomNode: c,
|
|
842
887
|
featuresNode: a,
|
|
843
888
|
glareNode: h
|
|
844
889
|
} = this;
|
|
845
|
-
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
const
|
|
849
|
-
return
|
|
850
|
-
const
|
|
851
|
-
return
|
|
890
|
+
y(t != null);
|
|
891
|
+
const l = o.getTextureNode(), u = n.getTextureNode();
|
|
892
|
+
o.inputNode = t, n.inputNode = l, i.inputNode = u, r.inputNode = u, c.inputNode = l, h.inputNode = l;
|
|
893
|
+
const p = c.getTextureNode().mul(this.bloomIntensity), d = h.getTextureNode();
|
|
894
|
+
return U(() => {
|
|
895
|
+
const m = t;
|
|
896
|
+
return m.addAssign(p), Pt(e) && m.addAssign(d), m.add(a);
|
|
852
897
|
})();
|
|
853
898
|
}
|
|
854
899
|
dispose() {
|
|
855
900
|
this.thresholdNode.dispose(), this.blurNode.dispose(), this.ghostNode.dispose(), this.haloNode.dispose(), this.bloomNode.dispose(), this.glareNode.dispose(), this.featuresNode.dispose(), super.dispose();
|
|
856
901
|
}
|
|
857
902
|
}
|
|
858
|
-
const
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
903
|
+
const Fn = (s) => new To(s != null ? Oe(s) : null), No = /* @__PURE__ */ V({
|
|
904
|
+
name: "bvec2Not",
|
|
905
|
+
type: "bvec2",
|
|
906
|
+
inputs: [{ name: "x", type: "bvec2" }]
|
|
907
|
+
})(([s]) => s.notEqual(Me(!0))), So = /* @__PURE__ */ V({
|
|
908
|
+
name: "bvec3Not",
|
|
909
|
+
type: "bvec3",
|
|
910
|
+
inputs: [{ name: "x", type: "bvec3" }]
|
|
911
|
+
})(([s]) => s.notEqual(Me(!0))), bo = /* @__PURE__ */ V({
|
|
912
|
+
name: "bvec4Not",
|
|
913
|
+
type: "bvec4",
|
|
914
|
+
inputs: [{ name: "x", type: "bvec4" }]
|
|
915
|
+
})(([s]) => s.notEqual(Me(!0))), On = /* @__PURE__ */ Le([
|
|
916
|
+
No,
|
|
917
|
+
So,
|
|
918
|
+
bo
|
|
919
|
+
]), Mo = /* @__PURE__ */ V({
|
|
920
|
+
name: "bvec2And",
|
|
921
|
+
type: "bvec2",
|
|
922
|
+
inputs: [
|
|
923
|
+
{ name: "x", type: "bvec2" },
|
|
924
|
+
{ name: "y", type: "bvec2" }
|
|
925
|
+
]
|
|
926
|
+
})(([s, e]) => xt(re(s).mul(re(e)))), zo = /* @__PURE__ */ V({
|
|
927
|
+
name: "bvec3And",
|
|
928
|
+
type: "bvec3",
|
|
929
|
+
inputs: [
|
|
930
|
+
{ name: "x", type: "bvec3" },
|
|
931
|
+
{ name: "y", type: "bvec3" }
|
|
932
|
+
]
|
|
933
|
+
})(([s, e]) => gt(pe(s).mul(pe(e)))), Co = /* @__PURE__ */ V({
|
|
934
|
+
name: "bvec4And",
|
|
935
|
+
type: "bvec4",
|
|
936
|
+
inputs: [
|
|
937
|
+
{ name: "x", type: "bvec4" },
|
|
938
|
+
{ name: "y", type: "bvec4" }
|
|
939
|
+
]
|
|
940
|
+
})(([s, e]) => vt(me(s).mul(me(e)))), Un = /* @__PURE__ */ Le([
|
|
941
|
+
Mo,
|
|
942
|
+
zo,
|
|
943
|
+
Co
|
|
944
|
+
]), Ro = /* @__PURE__ */ V({
|
|
945
|
+
name: "bvec2Or",
|
|
946
|
+
type: "bvec2",
|
|
947
|
+
inputs: [
|
|
948
|
+
{ name: "x", type: "bvec2" },
|
|
949
|
+
{ name: "y", type: "bvec2" }
|
|
950
|
+
]
|
|
951
|
+
})(([s, e]) => re(s).add(re(e)).notEqual(0)), Do = /* @__PURE__ */ V({
|
|
952
|
+
name: "bvec3Or",
|
|
953
|
+
type: "bvec3",
|
|
954
|
+
inputs: [
|
|
955
|
+
{ name: "x", type: "bvec3" },
|
|
956
|
+
{ name: "y", type: "bvec3" }
|
|
957
|
+
]
|
|
958
|
+
})(([s, e]) => pe(s).add(pe(e)).notEqual(0)), Bo = /* @__PURE__ */ V({
|
|
959
|
+
name: "bvec4Or",
|
|
960
|
+
type: "bvec4",
|
|
961
|
+
inputs: [
|
|
962
|
+
{ name: "x", type: "bvec4" },
|
|
963
|
+
{ name: "y", type: "bvec4" }
|
|
964
|
+
]
|
|
965
|
+
})(([s, e]) => me(s).add(me(e)).notEqual(0)), jn = /* @__PURE__ */ Le([Ro, Do, Bo]), En = /* @__PURE__ */ L(
|
|
966
|
+
(s, e, t, o) => {
|
|
967
|
+
const n = s.sub(t), i = Ne(e, n), r = Ne(n, n).sub(o.pow2()), c = i.pow2().sub(r).toConst(), a = f(-1);
|
|
968
|
+
return ae(c.greaterThanEqual(0), () => {
|
|
969
|
+
const h = be(c);
|
|
970
|
+
a.assign(f(i.negate().sub(h), i.negate().add(h)));
|
|
866
971
|
}), a;
|
|
867
972
|
}
|
|
868
|
-
),
|
|
869
|
-
|
|
870
|
-
"
|
|
871
|
-
),
|
|
872
|
-
(
|
|
873
|
-
const n =
|
|
874
|
-
return
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
),
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
return F(a.greaterThanEqual(0), () => {
|
|
883
|
-
const c = Y(a);
|
|
884
|
-
h.assign(p(i.negate().sub(c), i.negate().add(c)).div(r));
|
|
973
|
+
), Ao = /* @__PURE__ */ Ie({
|
|
974
|
+
near: "vec4",
|
|
975
|
+
far: "vec4"
|
|
976
|
+
}), kn = /* @__PURE__ */ L(
|
|
977
|
+
(s, e, t, o) => {
|
|
978
|
+
const n = s.sub(t), i = Ne(e, n), r = Ne(n, n).sub(o.pow2()), c = i.pow2().sub(r).toConst(), a = f(c.greaterThanEqual(0)).toConst(), h = a.oneMinus().toConst(), l = be(c.max(0)).toConst(), u = a.mul(i.negate().sub(l)).sub(h), p = a.mul(i.negate().add(l)).sub(h);
|
|
979
|
+
return Ao(u, p);
|
|
980
|
+
}
|
|
981
|
+
), In = /* @__PURE__ */ L(
|
|
982
|
+
(s, e, t) => {
|
|
983
|
+
const o = s.div(t), n = e.div(t), i = n.dot(n), r = o.dot(n), c = o.dot(o), a = r.pow2().sub(i.mul(c.sub(1))).toConst(), h = f(-1);
|
|
984
|
+
return ae(a.greaterThanEqual(0), () => {
|
|
985
|
+
const l = be(a);
|
|
986
|
+
h.assign(f(r.negate().sub(l), r.negate().add(l)).div(i));
|
|
885
987
|
}), h;
|
|
886
988
|
}
|
|
887
|
-
),
|
|
888
|
-
float:
|
|
889
|
-
int:
|
|
890
|
-
uint:
|
|
891
|
-
bool:
|
|
892
|
-
vec2:
|
|
893
|
-
ivec2:
|
|
894
|
-
uvec2:
|
|
895
|
-
bvec2:
|
|
896
|
-
vec3:
|
|
897
|
-
ivec3:
|
|
898
|
-
uvec3:
|
|
899
|
-
bvec3:
|
|
900
|
-
vec4:
|
|
901
|
-
ivec4:
|
|
902
|
-
uvec4:
|
|
903
|
-
bvec4:
|
|
904
|
-
mat2:
|
|
905
|
-
mat3:
|
|
906
|
-
mat4:
|
|
907
|
-
color:
|
|
908
|
-
},
|
|
909
|
-
function
|
|
910
|
-
return
|
|
989
|
+
), Vo = {
|
|
990
|
+
float: G,
|
|
991
|
+
int: K,
|
|
992
|
+
uint: ms,
|
|
993
|
+
bool: Me,
|
|
994
|
+
vec2: f,
|
|
995
|
+
ivec2: O,
|
|
996
|
+
uvec2: re,
|
|
997
|
+
bvec2: xt,
|
|
998
|
+
vec3: M,
|
|
999
|
+
ivec3: ps,
|
|
1000
|
+
uvec3: pe,
|
|
1001
|
+
bvec3: gt,
|
|
1002
|
+
vec4: z,
|
|
1003
|
+
ivec4: yt,
|
|
1004
|
+
uvec4: me,
|
|
1005
|
+
bvec4: vt,
|
|
1006
|
+
mat2: ds,
|
|
1007
|
+
mat3: mt,
|
|
1008
|
+
mat4: hs,
|
|
1009
|
+
color: ls
|
|
1010
|
+
}, Ln = Rs;
|
|
1011
|
+
function Wn(s) {
|
|
1012
|
+
return Vo[s];
|
|
911
1013
|
}
|
|
912
|
-
class
|
|
1014
|
+
class Po extends Nt {
|
|
913
1015
|
static get type() {
|
|
914
1016
|
return "OutputTexture3DNode";
|
|
915
1017
|
}
|
|
@@ -923,58 +1025,276 @@ class Ns extends Ht {
|
|
|
923
1025
|
return new this.constructor(this.owner, this.value);
|
|
924
1026
|
}
|
|
925
1027
|
}
|
|
926
|
-
const
|
|
927
|
-
(
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
o
|
|
931
|
-
|
|
932
|
-
o
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
1028
|
+
const $n = (...s) => new Po(...s), Fo = ["x", "y", "z", "w"], qn = /* @__PURE__ */ L(
|
|
1029
|
+
(s, e, t = 0) => {
|
|
1030
|
+
let o;
|
|
1031
|
+
if (typeof t == "number")
|
|
1032
|
+
o = t;
|
|
1033
|
+
else if (t?.isConstNode === !0)
|
|
1034
|
+
o = t.value;
|
|
1035
|
+
else
|
|
1036
|
+
throw new Error("Component must be a constant.");
|
|
1037
|
+
const n = s.size(), i = O(e.mul(n).sub(0.5).floor()).toConst(), r = yt(i, i.add(1)).toConst(), c = Fo[o];
|
|
1038
|
+
return z(
|
|
1039
|
+
s.load(r.xw)[c],
|
|
1040
|
+
// min, max
|
|
1041
|
+
s.load(r.zw)[c],
|
|
1042
|
+
// max, max
|
|
1043
|
+
s.load(r.zy)[c],
|
|
1044
|
+
// max, min
|
|
1045
|
+
s.load(r.xy)[c]
|
|
1046
|
+
// min, min
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
), Gn = /* @__PURE__ */ L(
|
|
1050
|
+
(s, e = I()) => {
|
|
1051
|
+
const t = f(s.size()), o = t.reciprocal(), n = e.mul(t), i = n.sub(0.5).floor().add(0.5), r = n.sub(i), c = r.mul(r.mul(r.mul(0.5).oneMinus()).sub(0.5)), a = r.mul(r).mul(r.mul(1.5).sub(2.5)).add(1), h = r.mul(r.mul(ie(2, r.mul(1.5))).add(0.5)), l = r.mul(r).mul(r.mul(0.5).sub(0.5)), u = a.add(h), p = h.div(a.add(h)), d = i.sub(1).mul(o), m = i.add(2).mul(o), x = i.add(p).mul(o);
|
|
1052
|
+
return B(
|
|
1053
|
+
s.sample(f(d.x, d.y)).mul(c.x).mul(c.y),
|
|
1054
|
+
s.sample(f(x.x, d.y)).mul(u.x).mul(c.y),
|
|
1055
|
+
s.sample(f(m.x, d.y)).mul(l.x).mul(c.y),
|
|
1056
|
+
s.sample(f(d.x, x.y)).mul(c.x).mul(u.y),
|
|
1057
|
+
s.sample(f(x.x, x.y)).mul(u.x).mul(u.y),
|
|
1058
|
+
s.sample(f(m.x, x.y)).mul(l.x).mul(u.y),
|
|
1059
|
+
s.sample(f(d.x, m.y)).mul(c.x).mul(l.y),
|
|
1060
|
+
s.sample(f(x.x, m.y)).mul(u.x).mul(l.y),
|
|
1061
|
+
s.sample(f(m.x, m.y)).mul(l.x).mul(l.y)
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
), D = 64;
|
|
1065
|
+
function Te(s) {
|
|
1066
|
+
return Math.floor(Math.max(0, s) / D);
|
|
1067
|
+
}
|
|
1068
|
+
class Oo {
|
|
1069
|
+
constructor() {
|
|
1070
|
+
this.size = [0, 0, 0], this.offset = { x: 0, y: 0 };
|
|
1071
|
+
}
|
|
1072
|
+
copy(e) {
|
|
1073
|
+
return [this.size[0], this.size[1], this.size[2]] = e.size, this.offset.x = e.offset.x, this.offset.y = e.offset.y, this;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
const Uo = /* @__PURE__ */ new St(), jo = /* @__PURE__ */ new Ws(), Eo = /* @__PURE__ */ new ve(), ko = /* @__PURE__ */ new Se();
|
|
1077
|
+
class Io extends Q {
|
|
1078
|
+
constructor(e, t, o) {
|
|
1079
|
+
super("float"), this.sampleCount = 60, this.hardShadowSamples = 4, this.fadeOutSamples = 8, this.thickness = g(5e-3), this.shadowContrast = g(4), this.shadowIntensity = g(1), this.bilinearThreshold = g(0.02), this.lightCoordinate = g("vec4"), this.dispatchOffset = g("ivec2"), this.dispatchIndex = g(0), this.dispatches = Array.from(
|
|
1080
|
+
// Populate the max number of dispatches
|
|
1081
|
+
{ length: 8 },
|
|
1082
|
+
() => new Oo()
|
|
1083
|
+
), this.dispatchCount = 0, this.updateBeforeType = H.FRAME, this.depthNode = e, this.camera = t, this.mainLight = o;
|
|
1084
|
+
const n = new Ds(1, 1);
|
|
1085
|
+
n.colorSpace = Ls, n.minFilter = ue, n.magFilter = ue, n.generateMipmaps = !1, n.name = "ScreenSpaceShadow", this.outputTexture = n, this.textureNode = $e(this, n), this.computeNode = this.createComputeNode();
|
|
1086
|
+
}
|
|
1087
|
+
get type() {
|
|
1088
|
+
return "ScreenSpaceShadowNode";
|
|
1089
|
+
}
|
|
1090
|
+
customCacheKey() {
|
|
1091
|
+
return We(
|
|
1092
|
+
this.camera?.id ?? -1,
|
|
1093
|
+
this.mainLight?.id ?? -1,
|
|
1094
|
+
this.sampleCount,
|
|
1095
|
+
this.hardShadowSamples,
|
|
1096
|
+
this.fadeOutSamples
|
|
939
1097
|
);
|
|
940
1098
|
}
|
|
941
|
-
)
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1099
|
+
getTextureNode() {
|
|
1100
|
+
return this.textureNode;
|
|
1101
|
+
}
|
|
1102
|
+
setSize(e, t) {
|
|
1103
|
+
const { outputTexture: o } = this;
|
|
1104
|
+
return (e !== o.width || t !== o.height) && (o.setSize(e, t, 0), o.needsUpdate = !0), this;
|
|
1105
|
+
}
|
|
1106
|
+
updateBefore(e) {
|
|
1107
|
+
const { renderer: t } = e;
|
|
1108
|
+
if (t == null)
|
|
1109
|
+
return;
|
|
1110
|
+
const o = t.getDrawingBufferSize(Eo);
|
|
1111
|
+
this.setSize(o.width, o.height);
|
|
1112
|
+
const { camera: n, mainLight: i } = this, r = ko.multiplyMatrices(
|
|
1113
|
+
n.projectionMatrix,
|
|
1114
|
+
n.matrixWorldInverse
|
|
1115
|
+
), c = Uo.copy(i.position).sub(i.target.position).normalize(), a = jo.set(c.x, c.y, c.z, 0).applyMatrix4(r);
|
|
1116
|
+
this.updateDispatchList(a, o);
|
|
1117
|
+
for (let h = 0; h < this.dispatchCount; ++h) {
|
|
1118
|
+
const l = this.dispatches[h];
|
|
1119
|
+
this.dispatchOffset.value.set(l.offset.x, l.offset.y), this.dispatchIndex.value = h, t.compute(this.computeNode, l.size);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
// See bend_sss_cpu.h
|
|
1123
|
+
updateDispatchList(e, { width: t, height: o }) {
|
|
1124
|
+
let n = e.w;
|
|
1125
|
+
const i = 2e-6 * D;
|
|
1126
|
+
n >= 0 && n < i ? n = i : n < 0 && n > -i && (n = -i), this.lightCoordinate.value.set(
|
|
1127
|
+
(e.x / n * 0.5 + 0.5) * t,
|
|
1128
|
+
(e.y / n * -0.5 + 0.5) * o,
|
|
1129
|
+
e.w === 0 ? 0 : e.z / e.w,
|
|
1130
|
+
e.w > 0 ? 1 : -1
|
|
1131
|
+
);
|
|
1132
|
+
const r = Math.round(this.lightCoordinate.value.x), c = Math.round(this.lightCoordinate.value.y), a = -r, h = -(o - c), l = t - r, u = c;
|
|
1133
|
+
let p = 0;
|
|
1134
|
+
for (let d = 0; d < 4; ++d) {
|
|
1135
|
+
const m = d === 0 || d === 3, x = (d & 1) > 0, w = (d & 2) > 0, T = Te(x ? a : -l), C = Te(w ? h : -u), j = D * (m ? 1 : 2) - 1, R = D * (m ? 2 : 1) - 1, F = Te((x ? l : -a) + j), b = Te((w ? u : -h) + R);
|
|
1136
|
+
if (F - T > 0 && b - C > 0) {
|
|
1137
|
+
const k = d === 2 || d === 3 ? 1 : 0, W = d === 1 || d === 3 ? 1 : 0, v = this.dispatches[p++];
|
|
1138
|
+
v.size[0] = D, v.size[1] = F - T, v.size[2] = b - C, v.offset.x = (x ? T : -F) + k, v.offset.y = (w ? -b : C) + W;
|
|
1139
|
+
let A;
|
|
1140
|
+
if (d === 0 ? A = a - h : d === 1 ? A = l + h : d === 2 ? A = -a - u : A = -l + u, A = (A + D - 1) / D | 0, A > 0) {
|
|
1141
|
+
const N = this.dispatches[p++].copy(v);
|
|
1142
|
+
d === 0 ? (N.size[2] = Math.min(v.size[2], A), v.size[2] -= N.size[2], N.offset.y = v.offset.y + v.size[2], N.offset.x -= 1, N.size[1] += 1) : d === 1 ? (N.size[1] = Math.min(v.size[1], A), v.size[1] -= N.size[1], N.offset.x = v.offset.x + v.size[1], N.size[2] += 1) : d === 2 ? (N.size[1] = Math.min(v.size[1], A), v.size[1] -= N.size[1], v.offset.x += N.size[1], N.size[2] += 1, N.offset.y -= 1) : d === 3 && (N.size[2] = Math.min(v.size[2], A), v.size[2] -= N.size[2], v.offset.y += N.size[2], ++N.size[1]), (N.size[1] <= 0 || N.size[2] <= 0) && N.copy(this.dispatches[--p]), (v.size[1] <= 0 || v.size[2] <= 0) && v.copy(this.dispatches[--p]);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
for (let d = 0; d < p; ++d) {
|
|
1147
|
+
const m = this.dispatches[d];
|
|
1148
|
+
m.offset.x *= D, m.offset.y *= D;
|
|
1149
|
+
}
|
|
1150
|
+
this.dispatchCount = p;
|
|
1151
|
+
}
|
|
1152
|
+
// See bend_sss_gpu.h
|
|
1153
|
+
createComputeNode() {
|
|
1154
|
+
const {
|
|
1155
|
+
depthNode: e,
|
|
1156
|
+
camera: t,
|
|
1157
|
+
sampleCount: o,
|
|
1158
|
+
hardShadowSamples: n,
|
|
1159
|
+
fadeOutSamples: i,
|
|
1160
|
+
outputTexture: r,
|
|
1161
|
+
thickness: c,
|
|
1162
|
+
shadowContrast: a,
|
|
1163
|
+
shadowIntensity: h,
|
|
1164
|
+
bilinearThreshold: l,
|
|
1165
|
+
lightCoordinate: u,
|
|
1166
|
+
dispatchOffset: p
|
|
1167
|
+
} = this, d = Math.floor(o / D) + 2, m = fs("float", d * D), x = () => {
|
|
1168
|
+
const w = O(Ke.yz).mul(D).add(p).toConst(), T = u.xy.floor().add(0.5).toConst(), C = u.xy.sub(T).toConst(), j = u.w.greaterThan(0), R = O(w.sign()).toConst(), F = _(w.x.add(R.y)).lessThan(_(w.y.sub(R.x))).toConst(), b = O(
|
|
1169
|
+
F.select(R.y, 0),
|
|
1170
|
+
F.select(0, R.x.negate())
|
|
1171
|
+
), k = f(b.mul(Ke.x).add(w)).toConst(), W = _(k.x).greaterThan(_(k.y)).toConst(), v = W.select(k.x, k.y).toConst(), A = v.abs().toConst(), N = A.sub(D), $ = W.select(C.x, C.y).toVar();
|
|
1172
|
+
$.assign(
|
|
1173
|
+
v.greaterThan(0).select($.negate(), $)
|
|
1174
|
+
);
|
|
1175
|
+
const Y = k.add(T).toConst(), X = ne(
|
|
1176
|
+
u.xy,
|
|
1177
|
+
Y,
|
|
1178
|
+
N.add($).div(A.add($))
|
|
1179
|
+
).toConst(), ee = Y.sub(X).toConst(), te = G(
|
|
1180
|
+
j.select(
|
|
1181
|
+
we,
|
|
1182
|
+
we.bitXor(D - 1)
|
|
1183
|
+
)
|
|
1184
|
+
).toConst(), Z = ne(Y, X, te.div(D)).toVar(), q = A.sub(te).add($).toConst();
|
|
1185
|
+
return { pixelXY: Z, pixelDistance: q, xyDelta: ee, xAxisMajor: W };
|
|
1186
|
+
};
|
|
1187
|
+
return U((w) => {
|
|
1188
|
+
const [T, C] = w.renderer.reversedDepthBuffer ? [G(1), G(0)] : [G(0), G(1)], j = (S) => {
|
|
1189
|
+
let P = e.load(S);
|
|
1190
|
+
return w.renderer.logarithmicDepthBuffer && (P = Ue(
|
|
1191
|
+
P,
|
|
1192
|
+
fe(t),
|
|
1193
|
+
xe(t)
|
|
1194
|
+
)), P = P.toConst(), wt(
|
|
1195
|
+
S.greaterThanEqual(0).all(),
|
|
1196
|
+
S.lessThan(e.size()).all()
|
|
1197
|
+
).select(P, C);
|
|
1198
|
+
}, { pixelXY: R, xyDelta: F, pixelDistance: b, xAxisMajor: k } = x(), W = u.w.negate(), v = T.greaterThan(C).select(-1, 1).toConst(), A = O(R.floor()).toConst();
|
|
1199
|
+
let N, $, Y;
|
|
1200
|
+
for (let S = 0; S < d; ++S) {
|
|
1201
|
+
const P = O(R.floor()).toConst(), de = k.select(R.y, R.x).fract().sub(0.5).greaterThan(0).select(1, -1).toConst(), Ft = O(
|
|
1202
|
+
k.select(0, de),
|
|
1203
|
+
k.select(de, 0)
|
|
1204
|
+
), se = j(P).toConst(), He = j(P.add(Ft)).toConst(), Ye = C.sub(se).abs().toConst(), Ot = xs(
|
|
1205
|
+
se.sub(He).abs(),
|
|
1206
|
+
Ye.mul(l)
|
|
1207
|
+
), Ut = se.add(
|
|
1208
|
+
_(se.sub(He)).mul(v)
|
|
1209
|
+
), jt = Ot.select(se, Ut), De = S === 0 ? b : W.mul(D * S).add(b).toConst();
|
|
1210
|
+
let Be = jt.sub(u.z).div(De).toConst();
|
|
1211
|
+
S > 0 && (Be = De.greaterThan(0).select(Be, 1e10).toConst()), m.element(we.add(D * S)).assign(Be), S === 0 && (N = se, $ = Ye, Y = De), R.addAssign(F.mul(W));
|
|
1212
|
+
}
|
|
1213
|
+
gs();
|
|
1214
|
+
const X = N.sub(u.z).div(Y).toVar(), ee = Y.add(W).min(c.reciprocal()).mul(Y).div($).toConst();
|
|
1215
|
+
X.assign(X.mul(ee).sub(v));
|
|
1216
|
+
const te = we.add(1).toConst(), Z = G(1).toVar();
|
|
1217
|
+
for (let S = 0; S < n; ++S) {
|
|
1218
|
+
const P = X.sub(m.element(te.add(S)).mul(ee)).abs();
|
|
1219
|
+
Z.assign(Z.min(P));
|
|
1220
|
+
}
|
|
1221
|
+
const q = z(1).toVar();
|
|
1222
|
+
for (let S = n; S < o - i; ++S) {
|
|
1223
|
+
const P = X.sub(m.element(te.add(S)).mul(ee)).abs(), he = K(S & 3).toConst();
|
|
1224
|
+
q.element(he).assign(q.element(he).min(P));
|
|
1225
|
+
}
|
|
1226
|
+
for (let S = o - i; S < o; ++S) {
|
|
1227
|
+
const P = X.sub(m.element(te.add(S)).mul(ee)).abs(), he = (S + 1 - (o - i)) / (i + 1) * 0.75, de = K(S & 3).toConst();
|
|
1228
|
+
q.element(de).assign(q.element(de).min(P.add(he)));
|
|
1229
|
+
}
|
|
1230
|
+
const Ge = a.oneMinus().toConst();
|
|
1231
|
+
Z.assign(
|
|
1232
|
+
Z.mul(a).add(Ge).saturate()
|
|
1233
|
+
), q.assign(
|
|
1234
|
+
q.mul(a).add(Ge).saturate()
|
|
1235
|
+
);
|
|
1236
|
+
const ye = G(0).toVar();
|
|
1237
|
+
ye.assign(q.dot(z(0.25))), ye.assign(ft(Z, ye)), vs(r, A, ne(1, ye, h));
|
|
1238
|
+
})().computeKernel([D, 1, 1]);
|
|
1239
|
+
}
|
|
1240
|
+
setup(e) {
|
|
1241
|
+
return this.textureNode;
|
|
1242
|
+
}
|
|
1243
|
+
dispose() {
|
|
1244
|
+
this.outputTexture.dispose();
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
const Hn = (...s) => new Io(...s), Lo = /* @__PURE__ */ (() => {
|
|
1248
|
+
const s = new Bs(new Uint8Array(1));
|
|
1249
|
+
return s.format = As, s.minFilter = Qe, s.magFilter = Qe, s.wrapS = Ve, s.wrapT = Ve, s.wrapR = Ve, s.needsUpdate = !0, s;
|
|
1250
|
+
})();
|
|
1251
|
+
class Wo extends Nt {
|
|
1252
|
+
constructor() {
|
|
1253
|
+
super(Lo), this.url = Hs;
|
|
1254
|
+
}
|
|
1255
|
+
customCacheKey() {
|
|
1256
|
+
return Xs(this.url);
|
|
1257
|
+
}
|
|
1258
|
+
setup(e) {
|
|
1259
|
+
return new Ys().loadAsync(this.url).then((t) => {
|
|
1260
|
+
this.value = t;
|
|
1261
|
+
}).catch((t) => {
|
|
1262
|
+
console.error(t);
|
|
1263
|
+
}), super.setup(e);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
const $o = /* @__PURE__ */ pt(Wo), Yn = /* @__PURE__ */ U(() => $o.sample(M(ke.xy, ys.mod(64)).div(M(128, 128, 64))).r.toConst("stbn")).once()();
|
|
1267
|
+
class qo extends Vs {
|
|
1268
|
+
static get type() {
|
|
1269
|
+
return "StorageTexture3DNode";
|
|
1270
|
+
}
|
|
1271
|
+
getDefaultUV() {
|
|
1272
|
+
return M(0.5, 0.5, 0.5);
|
|
1273
|
+
}
|
|
1274
|
+
setUpdateMatrix(e) {
|
|
1275
|
+
}
|
|
1276
|
+
generateUV(e, t) {
|
|
1277
|
+
return t.build(e, this.sampler ? "vec3" : "ivec3");
|
|
1278
|
+
}
|
|
1279
|
+
generateOffset(e, t) {
|
|
1280
|
+
return t.build(e, "ivec3");
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
const Xn = (...s) => new qo(...s);
|
|
1284
|
+
function ot(s, e) {
|
|
1285
|
+
let t = 1, o = 0;
|
|
1286
|
+
for (; s > 0; )
|
|
1287
|
+
t /= e, o += t * (s % e), s = Math.floor(s / e);
|
|
1288
|
+
return o;
|
|
947
1289
|
}
|
|
948
|
-
const
|
|
1290
|
+
const nt = /* @__PURE__ */ Array.from(
|
|
949
1291
|
{ length: 16 },
|
|
950
|
-
(
|
|
951
|
-
),
|
|
952
|
-
|
|
953
|
-
return
|
|
954
|
-
}, po = (o, e, t) => {
|
|
955
|
-
const s = je(o, e, t);
|
|
956
|
-
return Fe(s, e, t);
|
|
957
|
-
}, mo = (o, e, t, s, n) => {
|
|
958
|
-
const r = s.element(H(2)).element(H(3)), i = s.element(H(3)).element(H(3)), a = w(y(o.flipY(), e).mul(2).sub(1), 1).mul(t.mul(r).add(i));
|
|
959
|
-
return n.mul(a).xyz;
|
|
960
|
-
}, we = [
|
|
961
|
-
/* @__PURE__ */ y(58.1375, 2.7747, 26.8183),
|
|
962
|
-
/* @__PURE__ */ y(-150.5666, 4.2109, -88.5066),
|
|
963
|
-
/* @__PURE__ */ y(130.5887, -14.0195, 109.0745),
|
|
964
|
-
/* @__PURE__ */ y(-42.3277, 4.8052, -60.1097),
|
|
965
|
-
/* @__PURE__ */ y(4.5974, 2.1856, 12.5925),
|
|
966
|
-
/* @__PURE__ */ y(0.1357, 0.0914, 0.1067)
|
|
967
|
-
], Ms = (o) => we.slice(1).reduce((e, t) => t.add(o.mul(e)), we[0]), fo = (o, e, t, s) => {
|
|
968
|
-
const n = Ss(o, e, t, s);
|
|
969
|
-
return Ms(Fe(n, e, t));
|
|
970
|
-
}, go = (o) => {
|
|
971
|
-
const e = k(0.5, o.x).mul(Vt), t = k(o.y, 0.5).mul(Ct), s = le(t);
|
|
972
|
-
return y(s.mul(le(e)), ce(t), s.mul(ce(e)));
|
|
973
|
-
}, { resetRendererState: Rs, restoreRendererState: bs } = O;
|
|
974
|
-
function zs(o) {
|
|
975
|
-
return o.isPerspectiveCamera === !0 || o.isOrthographicCamera === !0 || "updateProjectionMatrix" in o && "setViewOffset" in o && "clearViewOffset" in o;
|
|
1292
|
+
(s, e) => new ve(ot(e + 1, 2), ot(e + 1, 3))
|
|
1293
|
+
), { resetRendererState: Go, restoreRendererState: Ho } = ge;
|
|
1294
|
+
function Yo(s) {
|
|
1295
|
+
return s.isPerspectiveCamera === !0 || s.isOrthographicCamera === !0 || "updateProjectionMatrix" in s && "setViewOffset" in s && "clearViewOffset" in s;
|
|
976
1296
|
}
|
|
977
|
-
const
|
|
1297
|
+
const Xo = /* @__PURE__ */ V({
|
|
978
1298
|
name: "clipAABB",
|
|
979
1299
|
type: "vec4",
|
|
980
1300
|
inputs: [
|
|
@@ -983,105 +1303,103 @@ const Bs = /* @__PURE__ */ K({
|
|
|
983
1303
|
{ name: "minColor", type: "vec4" },
|
|
984
1304
|
{ name: "maxColor", type: "vec4" }
|
|
985
1305
|
]
|
|
986
|
-
})(([
|
|
987
|
-
const n =
|
|
988
|
-
return
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
const r = t.toVar(), i = t.pow2().toVar();
|
|
1005
|
-
for (const d of Te) {
|
|
1006
|
-
const m = o.load(e.add(d));
|
|
1007
|
-
r.addAssign(m), i.addAssign(m.pow2());
|
|
1306
|
+
})(([s, e, t, o]) => {
|
|
1307
|
+
const n = o.rgb.add(t.rgb).mul(0.5).toConst(), i = o.rgb.sub(t.rgb).mul(0.5).add(1e-7), r = e.sub(z(n, s.a)).toConst(), a = r.xyz.div(i).abs().toConst(), h = Tt(a.x, a.y, a.z).toConst();
|
|
1308
|
+
return h.greaterThan(1).select(z(n, s.a).add(r.div(h)), e);
|
|
1309
|
+
}), it = [
|
|
1310
|
+
[-1, -1],
|
|
1311
|
+
[-1, 1],
|
|
1312
|
+
[1, -1],
|
|
1313
|
+
[1, 1],
|
|
1314
|
+
[1, 0],
|
|
1315
|
+
[0, -1],
|
|
1316
|
+
[0, 1],
|
|
1317
|
+
[-1, 0]
|
|
1318
|
+
], Zo = /* @__PURE__ */ L(
|
|
1319
|
+
(s, e, t, o, n) => {
|
|
1320
|
+
const i = t.toVar(), r = t.pow2().toVar();
|
|
1321
|
+
for (const [p, d] of it) {
|
|
1322
|
+
const m = s.load(e.add(O(p, d))).toConst();
|
|
1323
|
+
i.addAssign(m), r.addAssign(m.pow2());
|
|
1008
1324
|
}
|
|
1009
|
-
const
|
|
1010
|
-
return
|
|
1011
|
-
}
|
|
1012
|
-
),
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
],
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
}),
|
|
1026
|
-
(
|
|
1027
|
-
const
|
|
1028
|
-
for (const
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1031
|
-
|
|
1325
|
+
const c = it.length + 1, a = i.div(c).toConst(), h = be(r.div(c).sub(a.pow2()).max(0)).mul(n).toConst(), l = a.sub(h).toConst(), u = a.add(h).toConst();
|
|
1326
|
+
return Xo(a.clamp(l, u), o, l, u);
|
|
1327
|
+
}
|
|
1328
|
+
), _o = [
|
|
1329
|
+
[-1, -1],
|
|
1330
|
+
[-1, 0],
|
|
1331
|
+
[-1, 1],
|
|
1332
|
+
[0, -1],
|
|
1333
|
+
[0, 0],
|
|
1334
|
+
[0, 1],
|
|
1335
|
+
[1, -1],
|
|
1336
|
+
[1, 0],
|
|
1337
|
+
[1, 1]
|
|
1338
|
+
], Ko = /* @__PURE__ */ Ie({
|
|
1339
|
+
closestCoord: "ivec2",
|
|
1340
|
+
closestDepth: "float"
|
|
1341
|
+
}), Qo = /* @__PURE__ */ L(
|
|
1342
|
+
(s, e) => (t) => {
|
|
1343
|
+
const o = O(0).toVar(), n = G(1).toVar();
|
|
1344
|
+
for (const [i, r] of _o) {
|
|
1345
|
+
const c = e.add(O(i, r)).toConst();
|
|
1346
|
+
let a = s.load(c).r;
|
|
1347
|
+
t.renderer.reversedDepthBuffer && (a = a.oneMinus()), a = a.toConst(), ae(a.lessThan(n), () => {
|
|
1348
|
+
o.assign(c), n.assign(a);
|
|
1032
1349
|
});
|
|
1033
1350
|
}
|
|
1034
|
-
return
|
|
1351
|
+
return Ko(o, n);
|
|
1352
|
+
}
|
|
1353
|
+
), Jo = /* @__PURE__ */ L(
|
|
1354
|
+
(s, e) => {
|
|
1355
|
+
const o = s.mul(e).fract().abs(), n = Tt(o, o.oneMinus());
|
|
1356
|
+
return n.x.mul(n.y).oneMinus().div(0.75);
|
|
1035
1357
|
}
|
|
1036
|
-
),
|
|
1037
|
-
class
|
|
1038
|
-
constructor(e, t,
|
|
1039
|
-
if (super("vec4"), this.temporalAlpha =
|
|
1358
|
+
), rt = /* @__PURE__ */ new ve(), en = /* @__PURE__ */ new $s(1, 1);
|
|
1359
|
+
class at extends Q {
|
|
1360
|
+
constructor(e, t, o, n) {
|
|
1361
|
+
if (super("vec4"), this.temporalAlpha = g(0.05), this.varianceGamma = g(1), this.velocityThreshold = g(0.1), this.depthError = g(1e-3), this.debugShowRejection = !1, this.resolveRT = this.createRenderTarget("resolve"), this.historyRT = this.createRenderTarget("history"), this.resolveMaterial = new ce(), this.mesh = new ze(), this.needsSyncRenderPipeline = !1, this.needsClearHistory = !1, this.resolveNode = oe(this.resolveRT.texture), this.historyNode = oe(this.historyRT.texture), this.previousDepthNode = oe(en), this.originalProjectionMatrix = new Se(), this.jitterIndex = 0, this.updateBeforeType = H.FRAME, this.resolveMaterial.name = "TemporalAntialias_resolve", this.mesh.name = "TemporalAntialias", this.inputNode = e, this.depthNode = t, this.velocityNode = o, !Yo(n))
|
|
1040
1362
|
throw new Error("The provided camera is not supported.");
|
|
1041
|
-
this.camera =
|
|
1363
|
+
this.camera = n, this.textureNode = $e(this, this.resolveRT.texture);
|
|
1042
1364
|
}
|
|
1043
1365
|
static get type() {
|
|
1044
1366
|
return "TemporalAntialiasNode";
|
|
1045
1367
|
}
|
|
1046
1368
|
customCacheKey() {
|
|
1047
|
-
return
|
|
1369
|
+
return We(this.camera.id, +this.debugShowRejection);
|
|
1048
1370
|
}
|
|
1049
1371
|
createRenderTarget(e) {
|
|
1050
|
-
const t = new
|
|
1372
|
+
const t = new Mt(1, 1, {
|
|
1051
1373
|
depthBuffer: !1,
|
|
1052
|
-
type:
|
|
1053
|
-
format:
|
|
1054
|
-
}),
|
|
1055
|
-
|
|
1374
|
+
type: Ct,
|
|
1375
|
+
format: zt
|
|
1376
|
+
}), o = t.texture;
|
|
1377
|
+
o.minFilter = ue, o.magFilter = ue, o.generateMipmaps = !1;
|
|
1056
1378
|
const n = this.constructor.type;
|
|
1057
|
-
return
|
|
1379
|
+
return o.name = e != null ? `${n}_${e}` : n, t;
|
|
1058
1380
|
}
|
|
1059
1381
|
getTextureNode() {
|
|
1060
1382
|
return this.textureNode;
|
|
1061
1383
|
}
|
|
1062
|
-
setProjectionMatrix(e) {
|
|
1063
|
-
const { velocityNodeImmutable: t } = this;
|
|
1064
|
-
t != null && (t.projectionMatrix = e);
|
|
1065
|
-
}
|
|
1066
1384
|
setSize(e, t) {
|
|
1067
|
-
const { resolveRT:
|
|
1068
|
-
return (e !== n.width || t !== n.height) && (
|
|
1385
|
+
const { resolveRT: o, historyRT: n } = this;
|
|
1386
|
+
return (e !== n.width || t !== n.height) && (o.setSize(e, t), n.setSize(e, t), this.needsClearHistory = !0), this;
|
|
1069
1387
|
}
|
|
1070
1388
|
clearHistory(e) {
|
|
1071
|
-
e.setRenderTarget(this.resolveRT), e.clear(), e.setRenderTarget(this.historyRT), e.clear(),
|
|
1389
|
+
e.setRenderTarget(this.resolveRT), e.clear(), e.setRenderTarget(this.historyRT), e.clear(), this.needsClearHistory = !1;
|
|
1072
1390
|
}
|
|
1073
1391
|
setViewOffset(e, t) {
|
|
1074
|
-
const { camera:
|
|
1075
|
-
|
|
1076
|
-
const n =
|
|
1077
|
-
|
|
1392
|
+
const { camera: o } = this;
|
|
1393
|
+
o.updateProjectionMatrix(), this.originalProjectionMatrix.copy(o.projectionMatrix), tt.setProjectionMatrix(this.originalProjectionMatrix);
|
|
1394
|
+
const n = nt[this.jitterIndex], i = n.x - 0.5, r = n.y - 0.5;
|
|
1395
|
+
o.setViewOffset(e, t, i, r, e, t);
|
|
1078
1396
|
}
|
|
1079
1397
|
clearViewOffset() {
|
|
1080
|
-
this.camera.clearViewOffset(),
|
|
1398
|
+
this.camera.clearViewOffset(), tt.setProjectionMatrix(null), this.jitterIndex = (this.jitterIndex + 1) % nt.length;
|
|
1081
1399
|
}
|
|
1082
1400
|
copyDepthTexture(e) {
|
|
1083
|
-
const t = this.depthNode.value,
|
|
1084
|
-
(
|
|
1401
|
+
const t = this.depthNode.value, o = this.previousDepthTexture ??= t.clone();
|
|
1402
|
+
(o.image.width !== t.width || o.image.height !== t.height) && (o.image.width = t.width, o.image.height = t.height, o.needsUpdate = !0), e.copyTextureToTexture(t, o), this.previousDepthNode.value = o;
|
|
1085
1403
|
}
|
|
1086
1404
|
swapBuffers() {
|
|
1087
1405
|
const { resolveRT: e, historyRT: t } = this;
|
|
@@ -1090,128 +1408,153 @@ class Ds extends E {
|
|
|
1090
1408
|
updateBefore({ renderer: e }) {
|
|
1091
1409
|
if (e == null)
|
|
1092
1410
|
return;
|
|
1093
|
-
const t = e.getDrawingBufferSize(
|
|
1094
|
-
this.setSize(t.x, t.y), this.rendererState =
|
|
1411
|
+
const t = e.getDrawingBufferSize(rt);
|
|
1412
|
+
this.setSize(t.x, t.y), this.rendererState = Go(e, this.rendererState), this.needsClearHistory && this.clearHistory(e), e.setRenderTarget(this.resolveRT), this.mesh.material = this.resolveMaterial, this.mesh.render(e), Ho(e, this.rendererState), Pt(e) && this.copyDepthTexture(e), this.swapBuffers(), this.needsSyncRenderPipeline && this.clearViewOffset();
|
|
1095
1413
|
}
|
|
1096
1414
|
setupResolveNode({ renderer: e }) {
|
|
1097
|
-
const t = (
|
|
1098
|
-
const { previousDepthNode: n } = this,
|
|
1099
|
-
return e.logarithmicDepthBuffer ?
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
) :
|
|
1415
|
+
const t = (o) => {
|
|
1416
|
+
const { previousDepthNode: n } = this, i = n.load(O(o.mul(n.size()).sub(0.5))).toConst();
|
|
1417
|
+
return e.logarithmicDepthBuffer ? Ue(
|
|
1418
|
+
i,
|
|
1419
|
+
fe(this.camera),
|
|
1420
|
+
xe(this.camera)
|
|
1421
|
+
) : e.reversedDepthBuffer ? i.oneMinus() : i;
|
|
1104
1422
|
};
|
|
1105
|
-
return
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
) :
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
),
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
).toFloat(),
|
|
1117
|
-
return
|
|
1118
|
-
const
|
|
1423
|
+
return U(() => {
|
|
1424
|
+
const o = O(ke), n = ws, i = Qo(this.depthNode, o).toConst(), r = i.get("closestCoord"), c = i.get("closestDepth"), a = this.velocityNode.load(r).xyz.mul(M(0.5, -0.5, 0.5)).toConst(), h = a.xy.length().div(this.velocityThreshold).oneMinus().saturate(), l = n.sub(a.xy).toConst(), u = t(l), p = e.logarithmicDepthBuffer ? Ue(
|
|
1425
|
+
c,
|
|
1426
|
+
fe(this.camera),
|
|
1427
|
+
xe(this.camera)
|
|
1428
|
+
) : c, d = Ts(
|
|
1429
|
+
p.add(a.z),
|
|
1430
|
+
u.add(this.depthError)
|
|
1431
|
+
), m = h.mul(d), x = wt(
|
|
1432
|
+
l.greaterThanEqual(0).all(),
|
|
1433
|
+
l.lessThanEqual(1).all()
|
|
1434
|
+
).toFloat(), w = c.notEqual(1).toFloat(), T = this.inputNode.load(o).toVar();
|
|
1435
|
+
return ae(x.mul(w).mul(m).greaterThan(0), () => {
|
|
1436
|
+
const C = oe(this.historyNode, l), j = Zo(
|
|
1119
1437
|
this.inputNode,
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1438
|
+
o,
|
|
1439
|
+
T,
|
|
1440
|
+
C,
|
|
1123
1441
|
this.varianceGamma
|
|
1124
|
-
),
|
|
1442
|
+
), R = ne(
|
|
1125
1443
|
this.temporalAlpha,
|
|
1126
|
-
0.
|
|
1127
|
-
|
|
1444
|
+
0.4,
|
|
1445
|
+
Jo(a.xy, Ns(this.inputNode))
|
|
1128
1446
|
).saturate();
|
|
1129
|
-
|
|
1447
|
+
T.assign(ne(j, T, R));
|
|
1130
1448
|
}).Else(() => {
|
|
1131
|
-
|
|
1132
|
-
}),
|
|
1449
|
+
this.debugShowRejection && T.assign(M(1, 0, 0));
|
|
1450
|
+
}), T;
|
|
1133
1451
|
})();
|
|
1134
1452
|
}
|
|
1135
1453
|
setup(e) {
|
|
1136
|
-
const
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
}, this.needsSyncPostProcessing = !0;
|
|
1454
|
+
const t = () => {
|
|
1455
|
+
const n = e.renderer.getDrawingBufferSize(rt);
|
|
1456
|
+
this.setViewOffset(n.width, n.height);
|
|
1457
|
+
};
|
|
1458
|
+
if (e.context.renderPipeline != null) {
|
|
1459
|
+
const { context: n } = e.context.renderPipeline;
|
|
1460
|
+
n.onBeforeRenderPipeline = t, this.needsSyncRenderPipeline = !0;
|
|
1144
1461
|
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1462
|
+
if (e.context.postProcessing != null) {
|
|
1463
|
+
const { context: n } = e.context.postProcessing;
|
|
1464
|
+
n.onBeforePostProcessing = t, this.needsSyncRenderPipeline = !0;
|
|
1465
|
+
}
|
|
1466
|
+
const { resolveMaterial: o } = this;
|
|
1467
|
+
return o.fragmentNode = this.setupResolveNode(e), o.needsUpdate = !0, this.textureNode.uvNode = this.inputNode.uvNode, this.textureNode;
|
|
1147
1468
|
}
|
|
1148
1469
|
dispose() {
|
|
1149
|
-
this.resolveRT.dispose(), this.historyRT.dispose(), this.previousDepthTexture?.dispose(), this.resolveMaterial.dispose(), this.
|
|
1470
|
+
this.resolveRT.dispose(), this.historyRT.dispose(), this.previousDepthTexture?.dispose(), this.resolveMaterial.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
1150
1471
|
}
|
|
1151
1472
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1473
|
+
function Zn(...s) {
|
|
1474
|
+
if (s.length === 1)
|
|
1475
|
+
return (i, r, c, a) => new at(
|
|
1476
|
+
Oe(i),
|
|
1477
|
+
r,
|
|
1478
|
+
c,
|
|
1479
|
+
a
|
|
1480
|
+
);
|
|
1481
|
+
const [e, t, o, n] = s;
|
|
1482
|
+
return new at(
|
|
1483
|
+
Oe(e),
|
|
1484
|
+
t,
|
|
1485
|
+
o,
|
|
1486
|
+
n
|
|
1487
|
+
);
|
|
1488
|
+
}
|
|
1159
1489
|
export {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1490
|
+
yn as CascadedShadowMapsNode,
|
|
1491
|
+
Bt as DownsampleThresholdNode,
|
|
1492
|
+
V as FnLayout,
|
|
1493
|
+
L as FnVar,
|
|
1494
|
+
At as GaussianBlurNode,
|
|
1495
|
+
ho as HighpVelocityNode,
|
|
1496
|
+
po as KawaseBlurNode,
|
|
1497
|
+
To as LensFlareNode,
|
|
1498
|
+
so as MipmapBlurNode,
|
|
1499
|
+
Vt as MipmapSurfaceBlurNode,
|
|
1500
|
+
Ln as Node,
|
|
1501
|
+
Rn as OnBeforeFrameUpdate,
|
|
1502
|
+
Cn as OnFrameUpdate,
|
|
1503
|
+
Po as OutputTexture3DNode,
|
|
1504
|
+
Qs as OutputTextureNode,
|
|
1505
|
+
Wo as STBNTextureNode,
|
|
1506
|
+
Io as ScreenSpaceShadowNode,
|
|
1507
|
+
qo as StorageTexture3DNode,
|
|
1508
|
+
at as TemporalAntialiasNode,
|
|
1509
|
+
Un as bvecAnd,
|
|
1510
|
+
On as bvecNot,
|
|
1511
|
+
jn as bvecOr,
|
|
1512
|
+
xe as cameraFar,
|
|
1513
|
+
fe as cameraNear,
|
|
1514
|
+
gn as cameraPositionWorld,
|
|
1515
|
+
Nn as debugFragmentNode,
|
|
1516
|
+
wn as debugMaterial,
|
|
1517
|
+
Sn as debugNode,
|
|
1518
|
+
Tn as debugVertexNode,
|
|
1519
|
+
hn as depthToColor,
|
|
1520
|
+
Rt as depthToViewZ,
|
|
1521
|
+
Bn as dithering,
|
|
1522
|
+
zn as downsampleThreshold,
|
|
1523
|
+
An as equirectGrid,
|
|
1524
|
+
dn as equirectToDirectionWorld,
|
|
1525
|
+
Dn as gaussianBlur,
|
|
1526
|
+
tt as highpVelocity,
|
|
1527
|
+
bn as hookFunction,
|
|
1528
|
+
lo as interleavedGradientNoise,
|
|
1529
|
+
fn as inverseProjectionMatrix,
|
|
1530
|
+
xn as inverseViewMatrix,
|
|
1531
|
+
Pt as isWebGPU,
|
|
1532
|
+
Vn as kawaseBlur,
|
|
1533
|
+
Fn as lensFlare,
|
|
1534
|
+
Ue as logarithmicToPerspectiveDepth,
|
|
1535
|
+
Mn as mipmapBlur,
|
|
1536
|
+
Dt as mipmapBlurDownsample,
|
|
1537
|
+
to as mipmapBlurUpsample,
|
|
1538
|
+
Pn as mipmapSurfaceBlur,
|
|
1539
|
+
Wn as node,
|
|
1540
|
+
$e as outputTexture,
|
|
1541
|
+
$n as outputTexture3D,
|
|
1542
|
+
un as perspectiveToLogarithmicDepth,
|
|
1543
|
+
pn as projectionMatrix,
|
|
1544
|
+
In as rayEllipsoidIntersection,
|
|
1545
|
+
En as raySphereIntersection,
|
|
1546
|
+
kn as raySpheresIntersections,
|
|
1547
|
+
Ao as raySpheresIntersectionsStruct,
|
|
1548
|
+
Hn as screenSpaceShadow,
|
|
1549
|
+
ln as screenToPositionView,
|
|
1550
|
+
Yn as stbn,
|
|
1551
|
+
$o as stbnTexture,
|
|
1552
|
+
Xn as storageTexture3D,
|
|
1553
|
+
Zn as temporalAntialias,
|
|
1554
|
+
Gn as textureCatmullRom,
|
|
1555
|
+
qn as textureGather,
|
|
1556
|
+
Zs as turbo,
|
|
1557
|
+
mn as viewMatrix,
|
|
1558
|
+
vn as viewZ
|
|
1216
1559
|
};
|
|
1217
1560
|
//# sourceMappingURL=webgpu.js.map
|