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