@takram/three-geospatial 0.5.1 → 0.7.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 +14 -0
- package/README.md +2 -0
- package/build/index.cjs +1 -1
- package/build/index.cjs.map +1 -1
- package/build/index.js +318 -312
- package/build/index.js.map +1 -1
- package/build/r3f.cjs.map +1 -1
- package/build/r3f.js.map +1 -1
- package/build/shaders.cjs.map +1 -1
- package/build/shaders.js.map +1 -1
- package/build/shared.cjs.map +1 -1
- package/build/shared.js.map +1 -1
- package/build/shared2.cjs.map +1 -1
- package/build/shared2.js.map +1 -1
- package/build/shared3.cjs.map +1 -1
- package/build/shared3.js.map +1 -1
- package/build/webgpu.cjs +1 -1
- package/build/webgpu.cjs.map +1 -1
- package/build/webgpu.js +445 -463
- package/build/webgpu.js.map +1 -1
- package/package.json +2 -2
- package/src/decorators.ts +30 -10
- package/src/r3f/EastNorthUpFrame.tsx +2 -1
- package/src/r3f/EllipsoidMesh.tsx +4 -2
- package/src/webgpu/DownsampleThresholdNode.ts +3 -4
- package/src/webgpu/DualMipmapFilterNode.ts +1 -1
- package/src/webgpu/FnLayout.ts +5 -5
- package/src/webgpu/GaussianBlurNode.ts +3 -3
- package/src/webgpu/HighpVelocityNode.ts +8 -4
- package/src/webgpu/KawaseBlurNode.ts +3 -3
- package/src/webgpu/LensFlareNode.ts +10 -19
- package/src/webgpu/LensGlareNode.ts +8 -11
- package/src/webgpu/MipmapBlurNode.ts +7 -7
- package/src/webgpu/MipmapSurfaceBlurNode.ts +5 -6
- package/src/webgpu/OutputTexture3DNode.ts +1 -5
- package/src/webgpu/OutputTextureNode.ts +1 -4
- package/src/webgpu/RTTextureNode.ts +6 -8
- package/src/webgpu/TemporalAntialiasNode.ts +20 -23
- package/src/webgpu/accessors.ts +8 -10
- package/src/webgpu/generators.ts +7 -9
- package/src/webgpu/math.ts +13 -13
- package/src/webgpu/node.ts +3 -6
- package/src/webgpu/sampling.ts +3 -51
- package/src/webgpu/transformations.ts +30 -35
- package/src/webgpu/utils.ts +9 -9
- package/types/decorators.d.ts +2 -2
- package/types/webgpu/DownsampleThresholdNode.d.ts +4 -4
- package/types/webgpu/DualMipmapFilterNode.d.ts +2 -2
- package/types/webgpu/FnLayout.d.ts +3 -3
- package/types/webgpu/GaussianBlurNode.d.ts +2 -2
- package/types/webgpu/HighpVelocityNode.d.ts +2 -3
- package/types/webgpu/KawaseBlurNode.d.ts +2 -2
- package/types/webgpu/LensFlareNode.d.ts +4 -4
- package/types/webgpu/LensGhostNode.d.ts +1 -1
- package/types/webgpu/LensGlareNode.d.ts +5 -5
- package/types/webgpu/LensHaloNode.d.ts +2 -2
- package/types/webgpu/MipmapBlurNode.d.ts +4 -4
- package/types/webgpu/MipmapSurfaceBlurNode.d.ts +3 -3
- package/types/webgpu/OutputTexture3DNode.d.ts +1 -2
- package/types/webgpu/OutputTextureNode.d.ts +1 -2
- package/types/webgpu/RTTextureNode.d.ts +2 -3
- package/types/webgpu/SeparableFilterNode.d.ts +2 -2
- package/types/webgpu/SingleFilterNode.d.ts +1 -1
- package/types/webgpu/TemporalAntialiasNode.d.ts +6 -6
- package/types/webgpu/accessors.d.ts +8 -8
- package/types/webgpu/generators.d.ts +4 -4
- package/types/webgpu/node.d.ts +4 -5
- package/types/webgpu/sampling.d.ts +0 -1
- package/types/webgpu/transformations.d.ts +8 -8
- package/types/webgpu/utils.d.ts +1 -2
package/build/webgpu.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { Vector3 as
|
|
2
|
-
import { reference as $, uniform as v, vec4 as
|
|
3
|
-
import { NodeMaterial as
|
|
4
|
-
import { Q as
|
|
5
|
-
import { i as
|
|
6
|
-
import { hash as
|
|
7
|
-
let
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
let s =
|
|
11
|
-
return s == null && (s = {},
|
|
1
|
+
import { Vector3 as qe, Mesh as J, Scene as Ze, Camera as Qe, RenderTarget as Ne, RGBAFormat as Me, HalfFloatType as Re, LinearFilter as Z, Vector2 as V, Matrix4 as W, AdditiveBlending as Ke, PlaneGeometry as Je, PerspectiveCamera as Ye, SRGBColorSpace as _e, CanvasTexture as Xe, DepthTexture as et } from "three";
|
|
2
|
+
import { reference as $, uniform as v, vec4 as w, positionGeometry as be, texture as I, uv as B, vec2 as p, add as S, luminance as tt, smoothstep as Ve, Fn as C, screenCoordinate as ze, time as st, vec3 as y, equirectUV as ot, fwidth as rt, abs as Be, positionLocal as nt, positionPrevious as it, sub as k, nodeImmutable as at, instancedArray as ue, storage as ut, uvec2 as Ce, If as F, globalId as X, Return as lt, atomicAdd as ct, instanceIndex as ht, mat3 as Pe, struct as oe, min as dt, mul as pt, fract as mt, distance as gt, mix as te, sqrt as Y, dot as Q, color as xt, mat4 as ft, mat2 as vt, bvec4 as yt, uvec4 as wt, ivec4 as Tt, bvec3 as St, uvec3 as Nt, ivec3 as Mt, bvec2 as Rt, ivec2 as T, bool as bt, uint as Vt, int as H, float as re, textureSize as Ae, viewZToLogarithmicDepth as Fe, logarithmicDepthToViewZ as De, perspectiveDepthToViewZ as je, orthographicDepthToViewZ as zt, PI2 as Bt, PI as Ct, cos as le, sin as ce, viewZToPerspectiveDepth as Pt, screenUV as At, step as Ft, and as Dt, screenSize as jt, max as Ue, select as Ut } from "three/tsl";
|
|
3
|
+
import { NodeMaterial as P, TextureNode as se, TempNode as E, NodeUpdateType as A, RendererUtils as O, QuadMesh as q, Vector2 as It, RenderTarget as kt, RGBAFormat as $t, HalfFloatType as Et, LinearFilter as he, StorageBufferAttribute as Ot, MeshBasicNodeMaterial as Gt, NodeBuilder as Lt, Node as Wt, Texture3DNode as Ht } from "three/webgpu";
|
|
4
|
+
import { Q as ne } from "./shared3.js";
|
|
5
|
+
import { i as f } from "./shared.js";
|
|
6
|
+
import { hash as Ie } from "three/src/nodes/core/NodeUtils.js";
|
|
7
|
+
let ee;
|
|
8
|
+
function D(o, e, t) {
|
|
9
|
+
ee ??= /* @__PURE__ */ new WeakMap();
|
|
10
|
+
let s = ee.get(o);
|
|
11
|
+
return s == null && (s = {}, ee.set(o, s)), s[e] ??= t();
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const Os = (o) => D(
|
|
14
14
|
o,
|
|
15
15
|
"projectionMatrix",
|
|
16
16
|
() => $("projectionMatrix", "mat4", o).setName("projectionMatrix")
|
|
17
|
-
),
|
|
17
|
+
), Gs = (o) => D(
|
|
18
18
|
o,
|
|
19
19
|
"viewMatrix",
|
|
20
20
|
() => $("matrixWorldInverse", "mat4", o).setName("viewMatrix")
|
|
21
|
-
),
|
|
21
|
+
), Ls = (o) => D(
|
|
22
22
|
o,
|
|
23
23
|
"inverseProjectionMatrix",
|
|
24
24
|
() => $("projectionMatrixInverse", "mat4", o).setName(
|
|
25
25
|
"inverseProjectionMatrix"
|
|
26
26
|
)
|
|
27
|
-
),
|
|
27
|
+
), Ws = (o) => D(
|
|
28
28
|
o,
|
|
29
29
|
"inverseViewMatrix",
|
|
30
30
|
() => $("matrixWorld", "mat4", o).setName("inverseViewMatrix")
|
|
31
|
-
),
|
|
31
|
+
), Hs = (o) => D(
|
|
32
32
|
o,
|
|
33
33
|
"cameraPositionWorld",
|
|
34
|
-
() => v(new
|
|
34
|
+
() => v(new qe()).setName("cameraPositionWorld").onRenderUpdate((e, { value: t }) => {
|
|
35
35
|
t.setFromMatrixPosition(o.matrixWorld);
|
|
36
36
|
})
|
|
37
|
-
),
|
|
37
|
+
), de = (o) => D(
|
|
38
38
|
o,
|
|
39
39
|
"cameraNear",
|
|
40
40
|
() => $("near", "float", o).setName("cameraNear")
|
|
41
|
-
),
|
|
41
|
+
), pe = (o) => D(
|
|
42
42
|
o,
|
|
43
43
|
"cameraFar",
|
|
44
44
|
() => $("far", "float", o).setName("cameraFar")
|
|
45
45
|
);
|
|
46
|
-
async function
|
|
47
|
-
return await o.debug.getShaderAsync(new
|
|
46
|
+
async function ie(o, e) {
|
|
47
|
+
return await o.debug.getShaderAsync(new Ze(), new Qe(), e).then((t) => t).catch((t) => (console.error(t), { fragmentShader: null, vertexShader: null }));
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
const t = new
|
|
51
|
-
|
|
49
|
+
function qs(o, e) {
|
|
50
|
+
const t = new J(new ne(), e);
|
|
51
|
+
ie(o, t).then((s) => {
|
|
52
52
|
console.log(s.fragmentShader);
|
|
53
53
|
}).finally(() => {
|
|
54
54
|
t.geometry.dispose();
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
const t = new
|
|
59
|
-
|
|
57
|
+
function Zs(o, e) {
|
|
58
|
+
const t = new J(new ne(), e);
|
|
59
|
+
ie(o, t).then((s) => {
|
|
60
60
|
console.log(s.vertexShader);
|
|
61
61
|
}).finally(() => {
|
|
62
62
|
t.geometry.dispose();
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
const t = new
|
|
67
|
-
t.vertexNode =
|
|
68
|
-
const s = new
|
|
69
|
-
|
|
65
|
+
function Qs(o, e) {
|
|
66
|
+
const t = new P();
|
|
67
|
+
t.vertexNode = w(be.xy, 0, 1), t.fragmentNode = e;
|
|
68
|
+
const s = new J(new ne(), t);
|
|
69
|
+
ie(o, s).then((r) => {
|
|
70
70
|
console.log(r.fragmentShader);
|
|
71
71
|
}).finally(() => {
|
|
72
72
|
t.dispose(), s.geometry.dispose();
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function Ks(o, e, t) {
|
|
76
76
|
const s = o[e];
|
|
77
77
|
return o[e] = ((...r) => (t(...r), s.apply(o, r))), o;
|
|
78
78
|
}
|
|
79
|
-
class qt extends
|
|
79
|
+
class qt extends se {
|
|
80
80
|
static get type() {
|
|
81
81
|
return "OutputTextureNode";
|
|
82
82
|
}
|
|
@@ -90,26 +90,26 @@ class qt extends oe {
|
|
|
90
90
|
return new this.constructor(this.owner, this.value);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
const ke = (...o) =>
|
|
94
|
-
class
|
|
93
|
+
const ke = (...o) => new qt(...o);
|
|
94
|
+
class _ extends E {
|
|
95
95
|
constructor(e) {
|
|
96
|
-
super("vec4"), this.resolutionScale = 1, this.renderTargets = [], this.inputNode = e, this.updateBeforeType =
|
|
96
|
+
super("vec4"), this.resolutionScale = 1, this.renderTargets = [], this.inputNode = e, this.updateBeforeType = A.FRAME;
|
|
97
97
|
}
|
|
98
98
|
static get type() {
|
|
99
99
|
return "FilterNode";
|
|
100
100
|
}
|
|
101
101
|
createRenderTarget(e) {
|
|
102
|
-
const t = new
|
|
102
|
+
const t = new Ne(1, 1, {
|
|
103
103
|
depthBuffer: !1,
|
|
104
104
|
type: Re,
|
|
105
|
-
format:
|
|
105
|
+
format: Me
|
|
106
106
|
}), s = t.texture;
|
|
107
|
-
s.minFilter =
|
|
107
|
+
s.minFilter = Z, s.magFilter = Z, s.generateMipmaps = !1;
|
|
108
108
|
const r = this.constructor.type;
|
|
109
109
|
return s.name = e != null ? `${r}.${e}` : r, this.renderTargets.push(t), t;
|
|
110
110
|
}
|
|
111
111
|
getTextureNode() {
|
|
112
|
-
return
|
|
112
|
+
return f(
|
|
113
113
|
this.textureNode != null,
|
|
114
114
|
"outputTexture must be specified before getTextureNode() is called."
|
|
115
115
|
), this.textureNode;
|
|
@@ -122,10 +122,10 @@ class X extends G {
|
|
|
122
122
|
}
|
|
123
123
|
setup(e) {
|
|
124
124
|
const { inputNode: t, textureNode: s } = this;
|
|
125
|
-
return
|
|
125
|
+
return f(
|
|
126
126
|
t != null,
|
|
127
127
|
"inputNode must be specified before being setup."
|
|
128
|
-
),
|
|
128
|
+
), f(
|
|
129
129
|
s != null,
|
|
130
130
|
"outputTexture must be specified before being setup."
|
|
131
131
|
), s.uvNode = t.uvNode, s;
|
|
@@ -136,10 +136,10 @@ class X extends G {
|
|
|
136
136
|
super.dispose();
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
const { resetRendererState: Zt, restoreRendererState: Qt } =
|
|
140
|
-
class
|
|
139
|
+
const { resetRendererState: Zt, restoreRendererState: Qt } = O;
|
|
140
|
+
class ae extends _ {
|
|
141
141
|
constructor(e, t) {
|
|
142
|
-
super(e), this.downsampleRTs = [], this.upsampleRTs = [], this.downsampleMaterial = new
|
|
142
|
+
super(e), this.downsampleRTs = [], this.upsampleRTs = [], this.downsampleMaterial = new P(), this.upsampleMaterial = new P(), this.mesh = new q(), this.inputTexelSize = v(new V()), this.downsampleNode = I();
|
|
143
143
|
for (let s = 0; s < t; ++s)
|
|
144
144
|
this.downsampleRTs[s] = this.createRenderTarget(`Downsample${s}`), s < t - 1 && (this.upsampleRTs[s] = this.createRenderTarget(`Upsample${s}`));
|
|
145
145
|
this.outputTexture = this.upsampleRTs[0].texture;
|
|
@@ -163,25 +163,25 @@ class ue extends X {
|
|
|
163
163
|
inputTexelSize: i,
|
|
164
164
|
downsampleNode: u
|
|
165
165
|
} = this;
|
|
166
|
-
|
|
166
|
+
f(n != null);
|
|
167
167
|
const { width: a, height: h } = n.value;
|
|
168
168
|
this.setSize(a, h);
|
|
169
|
-
const
|
|
169
|
+
const c = n.value;
|
|
170
170
|
this.rendererState = Zt(e, this.rendererState), r.material = this.downsampleMaterial;
|
|
171
|
-
for (const
|
|
171
|
+
for (const l of t) {
|
|
172
172
|
const { width: d, height: m } = n.value;
|
|
173
|
-
i.value.set(1 / d, 1 / m), e.setRenderTarget(
|
|
173
|
+
i.value.set(1 / d, 1 / m), e.setRenderTarget(l), r.render(e), n.value = l.texture;
|
|
174
174
|
}
|
|
175
175
|
r.material = this.upsampleMaterial;
|
|
176
|
-
for (let
|
|
177
|
-
const d = s[
|
|
178
|
-
i.value.set(1 / m, 1 / g), u.value = t[
|
|
176
|
+
for (let l = s.length - 1; l >= 0; --l) {
|
|
177
|
+
const d = s[l], { width: m, height: g } = n.value;
|
|
178
|
+
i.value.set(1 / m, 1 / g), u.value = t[l].texture, e.setRenderTarget(d), r.render(e), n.value = d.texture;
|
|
179
179
|
}
|
|
180
|
-
Qt(e, this.rendererState), n.value =
|
|
180
|
+
Qt(e, this.rendererState), n.value = c;
|
|
181
181
|
}
|
|
182
182
|
setup(e) {
|
|
183
183
|
const { inputNode: t } = this;
|
|
184
|
-
|
|
184
|
+
f(t != null);
|
|
185
185
|
const { downsampleMaterial: s, upsampleMaterial: r } = this;
|
|
186
186
|
return s.fragmentNode = this.setupDownsampleNode(e), r.fragmentNode = this.setupUpsampleNode(e), s.needsUpdate = !0, r.needsUpdate = !0, super.setup(e);
|
|
187
187
|
}
|
|
@@ -193,48 +193,48 @@ class ue extends X {
|
|
|
193
193
|
this.downsampleMaterial.dispose(), this.upsampleMaterial.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
const
|
|
197
|
-
const t =
|
|
198
|
-
return
|
|
199
|
-
|
|
196
|
+
const $e = (o, e) => {
|
|
197
|
+
const t = B(), s = w(1, 1, -1, -1).mul(e.xyxy).add(t.xyxy), r = w(2, 2, -2, -2).mul(e.xyxy).add(t.xyxy), n = s.zy.toVertexStage(), i = s.xy.toVertexStage(), u = s.zw.toVertexStage(), a = s.xw.toVertexStage(), h = p(t.x, r.y).toVertexStage(), c = p(r.z, t.y).toVertexStage(), l = p(r.x, t.y).toVertexStage(), d = p(t.x, r.w).toVertexStage(), m = r.zy.toVertexStage(), g = r.xy.toVertexStage(), x = r.zw.toVertexStage(), R = r.xw.toVertexStage();
|
|
198
|
+
return S(
|
|
199
|
+
S(
|
|
200
200
|
o.sample(t),
|
|
201
201
|
o.sample(n),
|
|
202
202
|
o.sample(i),
|
|
203
203
|
o.sample(u),
|
|
204
204
|
o.sample(a)
|
|
205
205
|
).mul(1 / 8),
|
|
206
|
-
|
|
206
|
+
S(
|
|
207
207
|
o.sample(h),
|
|
208
|
-
o.sample(l),
|
|
209
208
|
o.sample(c),
|
|
209
|
+
o.sample(l),
|
|
210
210
|
o.sample(d)
|
|
211
211
|
).mul(1 / 16),
|
|
212
|
-
|
|
212
|
+
S(
|
|
213
213
|
o.sample(m),
|
|
214
214
|
o.sample(g),
|
|
215
215
|
o.sample(x),
|
|
216
|
-
o.sample(
|
|
216
|
+
o.sample(R)
|
|
217
217
|
).mul(1 / 32)
|
|
218
218
|
);
|
|
219
219
|
}, Kt = (o, e) => {
|
|
220
|
-
const t =
|
|
221
|
-
return
|
|
220
|
+
const t = B(), s = w(1, 1, -1, -1).mul(e.xyxy).add(t.xyxy), r = p(t.x, s.y).toVertexStage(), n = p(s.z, t.y).toVertexStage(), i = p(s.x, t.y).toVertexStage(), u = p(t.x, s.w).toVertexStage(), a = s.zy.toVertexStage(), h = s.xy.toVertexStage(), c = s.zw.toVertexStage(), l = s.xw.toVertexStage();
|
|
221
|
+
return S(
|
|
222
222
|
o.sample(t).mul(0.25),
|
|
223
|
-
|
|
223
|
+
S(
|
|
224
224
|
o.sample(r),
|
|
225
225
|
o.sample(n),
|
|
226
226
|
o.sample(i),
|
|
227
227
|
o.sample(u)
|
|
228
228
|
).mul(0.125),
|
|
229
|
-
|
|
229
|
+
S(
|
|
230
230
|
o.sample(a),
|
|
231
231
|
o.sample(h),
|
|
232
|
-
o.sample(
|
|
233
|
-
o.sample(
|
|
232
|
+
o.sample(c),
|
|
233
|
+
o.sample(l)
|
|
234
234
|
).mul(0.0625)
|
|
235
235
|
);
|
|
236
236
|
};
|
|
237
|
-
class Jt extends
|
|
237
|
+
class Jt extends ae {
|
|
238
238
|
static get type() {
|
|
239
239
|
return "MipmapBlurNode";
|
|
240
240
|
}
|
|
@@ -242,16 +242,16 @@ class Jt extends ue {
|
|
|
242
242
|
super(e, t), this.resolutionScale = 0.5;
|
|
243
243
|
}
|
|
244
244
|
setupDownsampleNode(e) {
|
|
245
|
-
return
|
|
245
|
+
return f(this.inputNode != null), $e(this.inputNode, this.inputTexelSize);
|
|
246
246
|
}
|
|
247
247
|
setupUpsampleNode(e) {
|
|
248
|
-
return
|
|
248
|
+
return f(this.inputNode != null), Kt(this.inputNode, this.inputTexelSize);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
const
|
|
252
|
-
class Xt extends
|
|
251
|
+
const Js = (...o) => new Jt(...o), { resetRendererState: Yt, restoreRendererState: _t } = O;
|
|
252
|
+
class Xt extends _ {
|
|
253
253
|
constructor(e) {
|
|
254
|
-
super(e), this.material = new
|
|
254
|
+
super(e), this.material = new P(), this.mesh = new q(this.material), this.inputTexelSize = v(new V()), this.renderTarget = this.createRenderTarget(), this.outputTexture = this.renderTarget.texture;
|
|
255
255
|
}
|
|
256
256
|
setSize(e, t) {
|
|
257
257
|
const { resolutionScale: s } = this, r = Math.max(Math.round(e * s), 1), n = Math.max(Math.round(t * s), 1);
|
|
@@ -261,13 +261,13 @@ class Xt extends X {
|
|
|
261
261
|
if (e == null)
|
|
262
262
|
return;
|
|
263
263
|
const { inputNode: t } = this;
|
|
264
|
-
|
|
264
|
+
f(t != null);
|
|
265
265
|
const { width: s, height: r } = t.value;
|
|
266
266
|
this.setSize(s, r), this.inputTexelSize.value.set(1 / s, 1 / r), this.rendererState = Yt(e, this.rendererState), e.setRenderTarget(this.renderTarget), this.mesh.render(e), _t(e, this.rendererState);
|
|
267
267
|
}
|
|
268
268
|
setup(e) {
|
|
269
269
|
const { inputNode: t } = this;
|
|
270
|
-
|
|
270
|
+
f(t != null);
|
|
271
271
|
const { material: s } = this;
|
|
272
272
|
return s.fragmentNode = this.setupOutputNode(e), s.needsUpdate = !0, super.setup(e);
|
|
273
273
|
}
|
|
@@ -275,7 +275,7 @@ class Xt extends X {
|
|
|
275
275
|
this.renderTarget.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
class
|
|
278
|
+
class Ee extends Xt {
|
|
279
279
|
constructor(e) {
|
|
280
280
|
super(e), this.thresholdLevel = v(5), this.thresholdRange = v(1), this.resolutionScale = 0.5;
|
|
281
281
|
}
|
|
@@ -284,46 +284,46 @@ class $e extends Xt {
|
|
|
284
284
|
}
|
|
285
285
|
setupOutputNode() {
|
|
286
286
|
const { inputNode: e, thresholdLevel: t, thresholdRange: s, inputTexelSize: r } = this;
|
|
287
|
-
|
|
288
|
-
const n =
|
|
287
|
+
f(e != null);
|
|
288
|
+
const n = $e(e, r), i = tt(n.rgb), u = Ve(
|
|
289
289
|
t,
|
|
290
290
|
t.add(s),
|
|
291
291
|
i
|
|
292
292
|
);
|
|
293
|
-
return
|
|
293
|
+
return w(n.rgb, i).mul(u);
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
const
|
|
297
|
-
function
|
|
296
|
+
const Ys = (...o) => new Ee(...o);
|
|
297
|
+
function me(o) {
|
|
298
298
|
if (typeof o == "string")
|
|
299
299
|
return o;
|
|
300
300
|
if (o.layout.name == null)
|
|
301
301
|
throw new Error("Struct name is required.");
|
|
302
302
|
return o.layout.name;
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function K({
|
|
305
305
|
typeOnly: o = !1,
|
|
306
306
|
...e
|
|
307
307
|
}) {
|
|
308
|
-
return o ? (t) =>
|
|
308
|
+
return o ? (t) => C(t) : (t) => C(t).setLayout({
|
|
309
309
|
...e,
|
|
310
|
-
type:
|
|
310
|
+
type: me(e.type),
|
|
311
311
|
inputs: e.inputs?.map((s) => ({
|
|
312
312
|
...s,
|
|
313
|
-
type:
|
|
313
|
+
type: me(s.type)
|
|
314
314
|
})) ?? []
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
|
-
function
|
|
318
|
-
return
|
|
317
|
+
function G(o) {
|
|
318
|
+
return C((e, t) => {
|
|
319
319
|
const s = o(...e);
|
|
320
320
|
return typeof s == "function" ? s(t) : s;
|
|
321
321
|
});
|
|
322
322
|
}
|
|
323
|
-
const { resetRendererState: es, restoreRendererState: ts } =
|
|
324
|
-
class ss extends
|
|
323
|
+
const { resetRendererState: es, restoreRendererState: ts } = O;
|
|
324
|
+
class ss extends _ {
|
|
325
325
|
constructor(e) {
|
|
326
|
-
super(e), this.iterations = 1, this.material = new
|
|
326
|
+
super(e), this.iterations = 1, this.material = new P(), this.mesh = new q(this.material), this.inputTexelSize = v(new V()), this.direction = v(new V()), this.horizontalRT = this.createRenderTarget("Horizontal"), this.verticalRT = this.createRenderTarget("Vertical"), this.outputTexture = this.verticalRT.texture;
|
|
327
327
|
}
|
|
328
328
|
setSize(e, t) {
|
|
329
329
|
const { resolutionScale: s } = this, r = Math.max(Math.round(e * s), 1), n = Math.max(Math.round(t * s), 1);
|
|
@@ -333,18 +333,18 @@ class ss extends X {
|
|
|
333
333
|
if (e == null)
|
|
334
334
|
return;
|
|
335
335
|
const { horizontalRT: t, verticalRT: s, mesh: r, inputNode: n, direction: i } = this;
|
|
336
|
-
|
|
336
|
+
f(n != null);
|
|
337
337
|
const { width: u, height: a } = n.value;
|
|
338
338
|
this.setSize(u, a), this.inputTexelSize.value.set(1 / u, 1 / a);
|
|
339
339
|
const h = n.value;
|
|
340
340
|
this.rendererState = es(e, this.rendererState);
|
|
341
|
-
for (let
|
|
341
|
+
for (let c = 0; c < this.iterations; ++c)
|
|
342
342
|
i.value.set(1, 0), e.setRenderTarget(t), r.render(e), n.value = t.texture, i.value.set(0, 1), e.setRenderTarget(s), r.render(e), n.value = s.texture;
|
|
343
343
|
ts(e, this.rendererState), n.value = h;
|
|
344
344
|
}
|
|
345
345
|
setup(e) {
|
|
346
346
|
const { inputNode: t } = this;
|
|
347
|
-
|
|
347
|
+
f(t != null);
|
|
348
348
|
const { material: s } = this;
|
|
349
349
|
return s.fragmentNode = this.setupOutputNode(e), s.needsUpdate = !0, super.setup(e);
|
|
350
350
|
}
|
|
@@ -352,8 +352,8 @@ class ss extends X {
|
|
|
352
352
|
this.horizontalRT.dispose(), this.verticalRT.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
|
-
function
|
|
356
|
-
if (
|
|
355
|
+
function ge(o) {
|
|
356
|
+
if (f(o >= 0), o === 0)
|
|
357
357
|
return new Float64Array(0);
|
|
358
358
|
if (o === 1)
|
|
359
359
|
return new Float64Array([1]);
|
|
@@ -366,25 +366,25 @@ function xe(o) {
|
|
|
366
366
|
return s;
|
|
367
367
|
}
|
|
368
368
|
function os(o, e = 2) {
|
|
369
|
-
|
|
370
|
-
const t = o + e * 2, s = e > 0 ?
|
|
369
|
+
f(o >= 3);
|
|
370
|
+
const t = o + e * 2, s = e > 0 ? ge(t).slice(e, -e) : ge(t), r = Math.floor((s.length - 1) / 2), n = s.reduce((l, d) => l + d, 0), i = s.slice(r), u = [...Array(r + 1).keys()], a = new Float64Array(Math.floor(u.length / 2)), h = new Float64Array(a.length);
|
|
371
371
|
a[0] = i[0] / n;
|
|
372
|
-
for (let
|
|
373
|
-
const m = u[
|
|
374
|
-
a[d] =
|
|
372
|
+
for (let l = 1, d = 1; l < u.length - 1; l += 2, ++d) {
|
|
373
|
+
const m = u[l], g = u[l + 1], x = i[l], R = i[l + 1], N = x + R, z = (m * x + g * R) / N;
|
|
374
|
+
a[d] = N / n, h[d] = z;
|
|
375
375
|
}
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
378
|
-
const
|
|
376
|
+
const c = (a.reduce((l, d) => l + d, 0) - a[0] * 0.5) * 2;
|
|
377
|
+
if (c !== 0) {
|
|
378
|
+
const l = 1 / c;
|
|
379
379
|
for (let d = 0; d < a.length; ++d)
|
|
380
|
-
a[d] *=
|
|
380
|
+
a[d] *= l;
|
|
381
381
|
}
|
|
382
382
|
return {
|
|
383
383
|
offsets: h,
|
|
384
384
|
weights: a
|
|
385
385
|
};
|
|
386
386
|
}
|
|
387
|
-
class
|
|
387
|
+
class Oe extends ss {
|
|
388
388
|
static get type() {
|
|
389
389
|
return "GaussianBlurNode";
|
|
390
390
|
}
|
|
@@ -393,33 +393,33 @@ class Ge extends ss {
|
|
|
393
393
|
}
|
|
394
394
|
setupOutputNode(e) {
|
|
395
395
|
const { inputNode: t, inputTexelSize: s, direction: r } = this;
|
|
396
|
-
|
|
396
|
+
f(t != null);
|
|
397
397
|
const { offsets: n, weights: i } = os(this.kernelSize);
|
|
398
|
-
return
|
|
399
|
-
const u =
|
|
400
|
-
for (let
|
|
401
|
-
const
|
|
398
|
+
return C(() => {
|
|
399
|
+
const u = B(), a = r.mul(s).toVertexStage(), h = t.sample(u).mul(i[0]);
|
|
400
|
+
for (let c = 1; c < n.length; ++c) {
|
|
401
|
+
const l = a.mul(n[c]);
|
|
402
402
|
h.addAssign(
|
|
403
|
-
|
|
404
|
-
t.sample(u.add(
|
|
405
|
-
t.sample(u.sub(
|
|
406
|
-
).mul(i[
|
|
403
|
+
S(
|
|
404
|
+
t.sample(u.add(l)),
|
|
405
|
+
t.sample(u.sub(l))
|
|
406
|
+
).mul(i[c])
|
|
407
407
|
);
|
|
408
408
|
}
|
|
409
409
|
return h;
|
|
410
410
|
})();
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
const
|
|
414
|
-
const o = p(
|
|
415
|
-
return
|
|
416
|
-
}).once()(),
|
|
417
|
-
const s =
|
|
413
|
+
const _s = (...o) => new Oe(...o), rs = (o) => o.dot(p(0.06711056, 583715e-8)).fract().mul(52.9829189).fract(), Xs = /* @__PURE__ */ C(() => {
|
|
414
|
+
const o = p(ze.xy).add(st.fract().mul(1337)), e = rs(o);
|
|
415
|
+
return y(e, e.oneMinus(), e).sub(0.5).div(255);
|
|
416
|
+
}).once()(), eo = (o, e, t = p(90, 45)) => {
|
|
417
|
+
const s = ot(o), r = rt(s), n = e.mul(r).mul(0.5), i = Be(s.mul(t).fract().sub(0.5)).div(t), u = Ve(n, n.add(r), i).oneMinus();
|
|
418
418
|
return u.x.add(u.y).clamp(0, 1);
|
|
419
419
|
};
|
|
420
|
-
class ns extends
|
|
420
|
+
class ns extends E {
|
|
421
421
|
constructor() {
|
|
422
|
-
super("vec3"), this.currentProjectionMatrix = v(new W()), this.previousProjectionMatrix = v("mat4"), this.currentModelViewMatrix = v(new W()), this.previousModelViewMatrix = v("mat4"), this.objectModelViewMatrices = /* @__PURE__ */ new WeakMap(), this.updateType =
|
|
422
|
+
super("vec3"), this.currentProjectionMatrix = v(new W()), this.previousProjectionMatrix = v("mat4"), this.currentModelViewMatrix = v(new W()), this.previousModelViewMatrix = v("mat4"), this.objectModelViewMatrices = /* @__PURE__ */ new WeakMap(), this.updateType = A.FRAME, this.updateBeforeType = A.OBJECT, this.updateAfterType = A.OBJECT;
|
|
423
423
|
}
|
|
424
424
|
static get type() {
|
|
425
425
|
return "HighpVelocityNode";
|
|
@@ -460,12 +460,12 @@ class ns extends G {
|
|
|
460
460
|
r == null && (r = new W(), s.set(e, r)), r.copy(t.value);
|
|
461
461
|
}
|
|
462
462
|
setup(e) {
|
|
463
|
-
const t = this.currentProjectionMatrix.mul(this.currentModelViewMatrix).mul(
|
|
464
|
-
return
|
|
463
|
+
const t = this.currentProjectionMatrix.mul(this.currentModelViewMatrix).mul(nt).toVertexStage(), s = this.previousProjectionMatrix.mul(this.previousModelViewMatrix).mul(it).toVertexStage(), r = t.xyz.div(t.w), n = s.xyz.div(s.w);
|
|
464
|
+
return k(r, n);
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
const
|
|
468
|
-
class is extends
|
|
467
|
+
const to = /* @__PURE__ */ at(ns);
|
|
468
|
+
class is extends ae {
|
|
469
469
|
static get type() {
|
|
470
470
|
return "KawaseBlurNode";
|
|
471
471
|
}
|
|
@@ -474,9 +474,9 @@ class is extends ue {
|
|
|
474
474
|
}
|
|
475
475
|
setupDownsampleNode(e) {
|
|
476
476
|
const { inputNode: t, inputTexelSize: s } = this;
|
|
477
|
-
|
|
478
|
-
const r =
|
|
479
|
-
return
|
|
477
|
+
f(t != null);
|
|
478
|
+
const r = B(), n = w(1, 1, -1, -1).mul(s.xyxy.mul(0.5)).add(r.xyxy), i = n.zy.toVertexStage(), u = n.xy.toVertexStage(), a = n.xw.toVertexStage(), h = n.zw.toVertexStage();
|
|
479
|
+
return S(
|
|
480
480
|
t.sample(r).mul(4),
|
|
481
481
|
t.sample(i),
|
|
482
482
|
t.sample(u),
|
|
@@ -486,26 +486,26 @@ class is extends ue {
|
|
|
486
486
|
}
|
|
487
487
|
setupUpsampleNode(e) {
|
|
488
488
|
const { inputNode: t, inputTexelSize: s } = this;
|
|
489
|
-
|
|
490
|
-
const r =
|
|
491
|
-
return
|
|
492
|
-
|
|
489
|
+
f(t != null);
|
|
490
|
+
const r = B(), n = w(1, 1, -1, -1).mul(s.xyxy.mul(0.5)).add(r.xyxy), i = n.zy.toVertexStage(), u = n.xy.toVertexStage(), a = n.xw.toVertexStage(), h = n.zw.toVertexStage(), c = p(n.z, r.y).toVertexStage(), l = p(n.x, r.y).toVertexStage(), d = p(r.x, n.y).toVertexStage(), m = p(r.x, n.w).toVertexStage();
|
|
491
|
+
return S(
|
|
492
|
+
S(
|
|
493
493
|
t.sample(i),
|
|
494
494
|
t.sample(u),
|
|
495
495
|
t.sample(a),
|
|
496
496
|
t.sample(h)
|
|
497
497
|
).mul(1 / 12),
|
|
498
|
-
|
|
499
|
-
t.sample(l),
|
|
498
|
+
S(
|
|
500
499
|
t.sample(c),
|
|
500
|
+
t.sample(l),
|
|
501
501
|
t.sample(d),
|
|
502
502
|
t.sample(m)
|
|
503
503
|
).mul(1 / 6)
|
|
504
504
|
);
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
const
|
|
508
|
-
class as extends
|
|
507
|
+
const so = (...o) => new is(...o);
|
|
508
|
+
class as extends E {
|
|
509
509
|
constructor(e) {
|
|
510
510
|
super("vec3"), this.intensity = v(1e-5), this.inputNode = e;
|
|
511
511
|
}
|
|
@@ -514,8 +514,8 @@ class as extends G {
|
|
|
514
514
|
}
|
|
515
515
|
setup(e) {
|
|
516
516
|
const { inputNode: t, intensity: s } = this;
|
|
517
|
-
|
|
518
|
-
const r =
|
|
517
|
+
f(t != null);
|
|
518
|
+
const r = K({
|
|
519
519
|
name: "sampleGhost",
|
|
520
520
|
type: "vec3",
|
|
521
521
|
inputs: [
|
|
@@ -524,37 +524,37 @@ class as extends G {
|
|
|
524
524
|
{ name: "color", type: "vec3" },
|
|
525
525
|
{ name: "offset", type: "float" }
|
|
526
526
|
]
|
|
527
|
-
})(([a, h,
|
|
528
|
-
const d = h.mul(
|
|
527
|
+
})(([a, h, c, l]) => {
|
|
528
|
+
const d = h.mul(l).add(a.oneMinus()).saturate(), m = t.sample(d).rgb.mul(c), g = k(0.5, d).length().mul(1 / (Math.SQRT2 / 4)).saturate();
|
|
529
529
|
return m.mulAssign(g.oneMinus().pow(3)), m;
|
|
530
|
-
}), n =
|
|
531
|
-
return
|
|
532
|
-
r(n, i,
|
|
533
|
-
r(n, i,
|
|
534
|
-
r(n, i,
|
|
535
|
-
r(n, i,
|
|
536
|
-
r(n, i,
|
|
537
|
-
r(n, i,
|
|
538
|
-
r(n, i,
|
|
539
|
-
r(n, i,
|
|
540
|
-
r(n, i,
|
|
530
|
+
}), n = B(), i = n.sub(0.5);
|
|
531
|
+
return S(
|
|
532
|
+
r(n, i, y(0.8, 0.8, 1), -5),
|
|
533
|
+
r(n, i, y(1, 0.8, 0.4), -1.5),
|
|
534
|
+
r(n, i, y(0.9, 1, 0.8), -0.4),
|
|
535
|
+
r(n, i, y(1, 0.8, 0.4), -0.2),
|
|
536
|
+
r(n, i, y(0.9, 0.7, 0.7), -0.1),
|
|
537
|
+
r(n, i, y(0.5, 1, 0.4), 0.7),
|
|
538
|
+
r(n, i, y(0.5, 0.5, 0.5), 1),
|
|
539
|
+
r(n, i, y(1, 1, 0.6), 2.5),
|
|
540
|
+
r(n, i, y(0.5, 0.8, 1), 10)
|
|
541
541
|
).mul(s);
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
|
-
const { resetRendererState: us, restoreRendererState: ls } =
|
|
544
|
+
const { resetRendererState: us, restoreRendererState: ls } = O;
|
|
545
545
|
function cs() {
|
|
546
546
|
const o = new kt(1, 1, {
|
|
547
547
|
depthBuffer: !1,
|
|
548
|
-
type:
|
|
549
|
-
format:
|
|
548
|
+
type: Et,
|
|
549
|
+
format: $t
|
|
550
550
|
}), e = o.texture;
|
|
551
|
-
return e.minFilter =
|
|
551
|
+
return e.minFilter = he, e.magFilter = he, e.generateMipmaps = !1, o;
|
|
552
552
|
}
|
|
553
|
-
const hs = /* @__PURE__ */ new
|
|
554
|
-
class
|
|
553
|
+
const hs = /* @__PURE__ */ new It();
|
|
554
|
+
class Ge extends se {
|
|
555
555
|
constructor(e, t) {
|
|
556
556
|
const s = cs();
|
|
557
|
-
super(s.texture, t
|
|
557
|
+
super(s.texture, t ?? B()), this.resolutionScale = 1, this.material = new P(), this.mesh = new q(this.material), this.node = e, this.renderTarget = s, this.updateBeforeType = A.FRAME;
|
|
558
558
|
}
|
|
559
559
|
static get type() {
|
|
560
560
|
return "RTTextureNode";
|
|
@@ -571,30 +571,30 @@ class Le extends oe {
|
|
|
571
571
|
}
|
|
572
572
|
setup(e) {
|
|
573
573
|
const { material: t } = this;
|
|
574
|
-
return t.fragmentNode =
|
|
574
|
+
return t.fragmentNode = this.node.context(e.getContext()), t.needsUpdate = !0, super.setup(e);
|
|
575
575
|
}
|
|
576
576
|
dispose() {
|
|
577
577
|
this.renderTarget.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
578
578
|
}
|
|
579
579
|
// @ts-expect-error Ignore
|
|
580
580
|
clone() {
|
|
581
|
-
const e = new
|
|
581
|
+
const e = new se(this.value, this.uvNode, this.levelNode);
|
|
582
582
|
return e.sampler = this.sampler, e.referenceNode = this, e;
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
|
-
const ds = (...o) =>
|
|
585
|
+
const ds = (...o) => new Ge(...o), Le = (o, e) => {
|
|
586
586
|
let t;
|
|
587
|
-
return o.isTextureNode === !0 || o.isSampleNode === !0 ? t = o : o.getTextureNode != null ? t = o.getTextureNode() : (t = new
|
|
588
|
-
}, { resetRendererState: ps, restoreRendererState: ms } =
|
|
587
|
+
return o.isTextureNode === !0 || o.isSampleNode === !0 ? t = o : o.getTextureNode != null ? t = o.getTextureNode() : (t = new Ge(o), e != null && (t.value.name = e)), t;
|
|
588
|
+
}, { resetRendererState: ps, restoreRendererState: ms } = O;
|
|
589
589
|
function gs() {
|
|
590
590
|
const s = document.createElement("canvas");
|
|
591
591
|
s.width = 256, s.height = 32;
|
|
592
592
|
const r = s.getContext("2d");
|
|
593
|
-
|
|
593
|
+
f(r != null), r.beginPath(), r.moveTo(0, 32 / 2), r.lineTo(256 / 2, 5), r.lineTo(256, 32 / 2), r.lineTo(256 / 2, 27), r.closePath();
|
|
594
594
|
const n = r.createLinearGradient(0, 0, 256, 0);
|
|
595
|
-
return n.addColorStop(0, "#000000"), n.addColorStop(0.5, "#ffffff"), n.addColorStop(1, "#000000"), r.fillStyle = n, r.fill(), new
|
|
595
|
+
return n.addColorStop(0, "#000000"), n.addColorStop(0.5, "#ffffff"), n.addColorStop(1, "#000000"), r.fillStyle = n, r.fill(), new Xe(s);
|
|
596
596
|
}
|
|
597
|
-
const
|
|
597
|
+
const xe = /* @__PURE__ */ oe({
|
|
598
598
|
color: "vec3",
|
|
599
599
|
luminance: "float",
|
|
600
600
|
position: "vec2",
|
|
@@ -602,40 +602,40 @@ const fe = /* @__PURE__ */ re({
|
|
|
602
602
|
sin: "float",
|
|
603
603
|
cos: "float"
|
|
604
604
|
});
|
|
605
|
-
class xs extends
|
|
605
|
+
class xs extends _ {
|
|
606
606
|
constructor(e) {
|
|
607
|
-
super(e), this.spikePairCount = 6, this.wireframe = !1, this.intensity = v(1e-5), this.sizeScale = v(new
|
|
607
|
+
super(e), this.spikePairCount = 6, this.wireframe = !1, this.intensity = v(1e-5), this.sizeScale = v(new V(1.5, 0.01)), this.luminanceThreshold = v(100), this.counterBuffer = new Ot(1, 1), this.instanceBuffer = ue(1, xe), this.renderTarget = this.createRenderTarget(), this.material = new Gt({
|
|
608
608
|
depthTest: !1,
|
|
609
609
|
depthWrite: !1,
|
|
610
610
|
transparent: !0,
|
|
611
|
-
blending:
|
|
612
|
-
}), this.mesh = new
|
|
611
|
+
blending: Ke
|
|
612
|
+
}), this.mesh = new J(new Je(1, 1), this.material), this.camera = new Ye(), this.inputTexelSize = v(new V()), this.outputTexelSize = v(new V()), this.geometryRatio = v(new V()), this.inputNode = e, this.resolutionScale = 0.5, this.outputTexture = this.renderTarget.texture;
|
|
613
613
|
}
|
|
614
614
|
customCacheKey() {
|
|
615
|
-
return
|
|
615
|
+
return Ie(this.spikePairCount, +this.wireframe);
|
|
616
616
|
}
|
|
617
617
|
setSize(e, t) {
|
|
618
618
|
const { resolutionScale: s } = this, r = Math.max(Math.round(e * s), 1), n = Math.max(Math.round(t * s), 1);
|
|
619
619
|
this.renderTarget.setSize(r, n);
|
|
620
620
|
const i = Math.floor(r / 2), u = Math.floor(n / 2), a = i * u;
|
|
621
|
-
return this.instanceBuffer.bufferCount < a && (this.instanceBuffer.dispose(), this.instanceBuffer =
|
|
621
|
+
return this.instanceBuffer.bufferCount < a && (this.instanceBuffer.dispose(), this.instanceBuffer = ue(a, xe), this.setupCompute(i, u), this.setupMaterial()), this;
|
|
622
622
|
}
|
|
623
623
|
updateBefore({ renderer: e }) {
|
|
624
624
|
if (e == null)
|
|
625
625
|
return;
|
|
626
626
|
const { inputNode: t } = this;
|
|
627
|
-
|
|
627
|
+
f(t != null);
|
|
628
628
|
const { width: s, height: r } = t.value;
|
|
629
629
|
this.setSize(s, r);
|
|
630
630
|
const { computeNode: n, counterBuffer: i, renderTarget: u } = this;
|
|
631
|
-
|
|
631
|
+
f(n != null), this.inputTexelSize.value.set(1 / s, 1 / r);
|
|
632
632
|
const a = s / r;
|
|
633
633
|
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(
|
|
637
|
-
}).catch((
|
|
638
|
-
console.error(
|
|
634
|
+
const { width: h, height: c } = u;
|
|
635
|
+
this.outputTexelSize.value.set(1 / h, 1 / c), i.array[0] = 0, i.needsUpdate = !0, e.compute(n), e.getArrayBufferAsync(i).then((l) => {
|
|
636
|
+
this.mesh.count = new Uint32Array(l)[0];
|
|
637
|
+
}).catch((l) => {
|
|
638
|
+
console.error(l);
|
|
639
639
|
}), this.rendererState = ps(e, this.rendererState), e.setRenderTarget(u), e.render(this.mesh, this.camera), ms(e, this.rendererState);
|
|
640
640
|
}
|
|
641
641
|
setupCompute(e, t) {
|
|
@@ -646,25 +646,25 @@ class xs extends X {
|
|
|
646
646
|
instanceBuffer: i,
|
|
647
647
|
outputTexelSize: u
|
|
648
648
|
} = this;
|
|
649
|
-
|
|
650
|
-
const a =
|
|
649
|
+
f(r != null);
|
|
650
|
+
const a = ut(
|
|
651
651
|
n,
|
|
652
652
|
"uint",
|
|
653
653
|
n.count
|
|
654
654
|
).toAtomic();
|
|
655
|
-
this.computeNode =
|
|
656
|
-
const h =
|
|
657
|
-
|
|
658
|
-
|
|
655
|
+
this.computeNode = C(() => {
|
|
656
|
+
const h = Ce(e, t);
|
|
657
|
+
F(X.xy.greaterThanEqual(h).any(), () => {
|
|
658
|
+
lt();
|
|
659
659
|
});
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
const m =
|
|
660
|
+
const c = p(X.xy).mul(u).mul(2), l = r.sample(c), d = l.a;
|
|
661
|
+
F(d.greaterThan(0.1), () => {
|
|
662
|
+
const m = ct(a.element(0), s);
|
|
663
663
|
for (let g = 0; g < s; ++g) {
|
|
664
664
|
const x = i.element(m.add(g));
|
|
665
|
-
x.get("color").assign(
|
|
666
|
-
const
|
|
667
|
-
x.get("sin").assign(Math.sin(
|
|
665
|
+
x.get("color").assign(l.rgb), x.get("luminance").assign(d), x.get("position").assign(X.xy), x.get("scale").assign(g % 2 === 0 ? 1 : 0.5);
|
|
666
|
+
const R = Math.PI * (3 - Math.sqrt(5)), N = Math.PI / s * g + R;
|
|
667
|
+
x.get("sin").assign(Math.sin(N)), x.get("cos").assign(Math.cos(N));
|
|
668
668
|
}
|
|
669
669
|
});
|
|
670
670
|
})().compute(
|
|
@@ -684,22 +684,22 @@ class xs extends X {
|
|
|
684
684
|
outputTexelSize: u,
|
|
685
685
|
geometryRatio: a
|
|
686
686
|
} = this;
|
|
687
|
-
|
|
688
|
-
const h = s.element(
|
|
689
|
-
this.material.colorNode = this.wireframe ?
|
|
690
|
-
const
|
|
687
|
+
f(e != null), f(t != null);
|
|
688
|
+
const h = s.element(ht);
|
|
689
|
+
this.material.colorNode = this.wireframe ? w(1) : t.mul(h.get("color").mul(n)), this.material.vertexNode = C(() => {
|
|
690
|
+
const c = h.get("sin"), l = h.get("cos"), d = Pe(l, c, 0, c.negate(), l, 0, 0, 0, 1), g = h.get("position").mul(u).mul(2), x = g.flipY().mul(2).sub(1), N = h.get("luminance").div(r).saturate(), z = p(N, 1).mul(
|
|
691
691
|
h.get("scale"),
|
|
692
692
|
i,
|
|
693
693
|
// Make the spike to shrink at screen borders:
|
|
694
694
|
g.sub(0.5).length().mul(2).oneMinus().mul(0.5).add(0.5)
|
|
695
|
-
),
|
|
696
|
-
return
|
|
695
|
+
), L = d.mul(be.mul(w(z, 1, 1))).mul(a).add(y(x, 0));
|
|
696
|
+
return w(L, 1);
|
|
697
697
|
})(), this.material.wireframe = this.wireframe, this.material.needsUpdate = !0;
|
|
698
698
|
}
|
|
699
699
|
setup(e) {
|
|
700
700
|
if (this.spikeNode == null) {
|
|
701
701
|
const t = gs();
|
|
702
|
-
t.colorSpace =
|
|
702
|
+
t.colorSpace = _e, this.spikeNode = I(t);
|
|
703
703
|
}
|
|
704
704
|
return this.setupMaterial(), super.setup(e);
|
|
705
705
|
}
|
|
@@ -707,10 +707,10 @@ class xs extends X {
|
|
|
707
707
|
this.renderTarget.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
|
-
const fs = /* @__PURE__ */ new
|
|
711
|
-
class
|
|
710
|
+
const fs = /* @__PURE__ */ new V();
|
|
711
|
+
class vs extends E {
|
|
712
712
|
constructor(e) {
|
|
713
|
-
super("vec3"), this.intensity = v(1e-5), this.chromaticAberration = v(5e-3), this.aspectRatio = v(0), this.inputNode = e, this.updateBeforeType =
|
|
713
|
+
super("vec3"), this.intensity = v(1e-5), this.chromaticAberration = v(5e-3), this.aspectRatio = v(0), this.inputNode = e, this.updateBeforeType = A.FRAME;
|
|
714
714
|
}
|
|
715
715
|
static get type() {
|
|
716
716
|
return "LensHaloNode";
|
|
@@ -723,8 +723,8 @@ class ys extends G {
|
|
|
723
723
|
}
|
|
724
724
|
setup(e) {
|
|
725
725
|
const { inputNode: t, intensity: s, chromaticAberration: r, aspectRatio: n } = this;
|
|
726
|
-
|
|
727
|
-
const i =
|
|
726
|
+
f(t != null);
|
|
727
|
+
const i = K({
|
|
728
728
|
name: "cubicRingMask",
|
|
729
729
|
type: "float",
|
|
730
730
|
inputs: [
|
|
@@ -732,29 +732,29 @@ class ys extends G {
|
|
|
732
732
|
{ name: "radius", type: "float" },
|
|
733
733
|
{ name: "thickness", type: "float" }
|
|
734
734
|
]
|
|
735
|
-
})(([
|
|
736
|
-
const m =
|
|
737
|
-
return
|
|
738
|
-
}), u =
|
|
735
|
+
})(([c, l, d]) => {
|
|
736
|
+
const m = dt(Be(c.sub(l)).div(d), 1);
|
|
737
|
+
return pt(m, m, k(3, m.mul(2))).oneMinus();
|
|
738
|
+
}), u = K({
|
|
739
739
|
name: "sampleHalo",
|
|
740
740
|
type: "vec3",
|
|
741
741
|
inputs: [
|
|
742
742
|
{ name: "uv", type: "vec2" },
|
|
743
743
|
{ name: "radius", type: "float" }
|
|
744
744
|
]
|
|
745
|
-
})(([
|
|
746
|
-
const d = p(n, 1), m =
|
|
745
|
+
})(([c, l]) => {
|
|
746
|
+
const d = p(n, 1), m = c.sub(0.5).mul(d).normalize().div(d), g = y(r).mul(y(-1, 0, 1)), x = mt(m.mul(l).add(c.oneMinus())), R = y(
|
|
747
747
|
t.sample(m.mul(g.r).add(x)).r,
|
|
748
748
|
t.sample(m.mul(g.g).add(x)).g,
|
|
749
749
|
t.sample(m.mul(g.b).add(x)).b
|
|
750
|
-
),
|
|
751
|
-
return
|
|
752
|
-
}), a =
|
|
750
|
+
), N = c.sub(p(0.5, 0)).mul(d).add(p(0.5, 0)), z = gt(N, p(0.5)).saturate();
|
|
751
|
+
return R.mulAssign(i(z, 0.45, 0.25)), R;
|
|
752
|
+
}), a = B();
|
|
753
753
|
return u(a, 0.3).mul(s);
|
|
754
754
|
}
|
|
755
755
|
}
|
|
756
|
-
const
|
|
757
|
-
class
|
|
756
|
+
const b = (o) => o.greaterThanEqual(0).all().and(o.lessThanEqual(1).all()).toFloat();
|
|
757
|
+
class We extends ae {
|
|
758
758
|
constructor(e, t = 4) {
|
|
759
759
|
super(e, t), this.blendAmount = v(0.85), this.resolutionScale = 0.5;
|
|
760
760
|
}
|
|
@@ -763,71 +763,70 @@ class He extends ue {
|
|
|
763
763
|
}
|
|
764
764
|
setupDownsampleNode(e) {
|
|
765
765
|
const { inputNode: t, inputTexelSize: s } = this;
|
|
766
|
-
return
|
|
767
|
-
const r =
|
|
768
|
-
let
|
|
769
|
-
return
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
).mul(
|
|
775
|
-
t.sample(u).mul(
|
|
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(d).mul(
|
|
787
|
-
t.sample(m).mul(
|
|
788
|
-
t.sample(g).mul(
|
|
789
|
-
),
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
z
|
|
794
|
-
).mul(
|
|
795
|
-
t.sample(x).mul(
|
|
796
|
-
t.sample(
|
|
797
|
-
t.sample(
|
|
798
|
-
t.sample(
|
|
799
|
-
),
|
|
766
|
+
return f(t != null), C(() => {
|
|
767
|
+
const r = B(), n = w(1, 1, -1, -1).mul(s.xyxy).add(r.xyxy), i = w(2, 2, -2, -2).mul(s.xyxy).add(r.xyxy), u = n.zy.toVertexStage(), a = n.xy.toVertexStage(), h = n.zw.toVertexStage(), c = n.xw.toVertexStage(), l = i.zy.toVertexStage(), d = i.xy.toVertexStage(), m = i.zw.toVertexStage(), g = i.xw.toVertexStage(), x = p(r.x, i.y).toVertexStage(), R = p(i.z, r.y).toVertexStage(), N = p(i.x, r.y).toVertexStage(), z = p(r.x, i.w).toVertexStage(), L = 1 / 4 / 2, j = 1 / 9 / 2, U = t.sample(r).mul(j);
|
|
768
|
+
let M;
|
|
769
|
+
return M = w(
|
|
770
|
+
b(u),
|
|
771
|
+
b(a),
|
|
772
|
+
b(h),
|
|
773
|
+
b(c)
|
|
774
|
+
).mul(L), U.addAssign(
|
|
775
|
+
t.sample(u).mul(M.x),
|
|
776
|
+
t.sample(a).mul(M.y),
|
|
777
|
+
t.sample(h).mul(M.z),
|
|
778
|
+
t.sample(c).mul(M.w)
|
|
779
|
+
), M = w(
|
|
780
|
+
b(l),
|
|
781
|
+
b(d),
|
|
782
|
+
b(m),
|
|
783
|
+
b(g)
|
|
784
|
+
).mul(j), U.addAssign(
|
|
785
|
+
t.sample(l).mul(M.x),
|
|
786
|
+
t.sample(d).mul(M.y),
|
|
787
|
+
t.sample(m).mul(M.z),
|
|
788
|
+
t.sample(g).mul(M.w)
|
|
789
|
+
), M = w(
|
|
790
|
+
b(x),
|
|
791
|
+
b(R),
|
|
792
|
+
b(N),
|
|
793
|
+
b(z)
|
|
794
|
+
).mul(j), U.addAssign(
|
|
795
|
+
t.sample(x).mul(M.x),
|
|
796
|
+
t.sample(R).mul(M.y),
|
|
797
|
+
t.sample(N).mul(M.z),
|
|
798
|
+
t.sample(z).mul(M.w)
|
|
799
|
+
), U;
|
|
800
800
|
})();
|
|
801
801
|
}
|
|
802
802
|
setupUpsampleNode(e) {
|
|
803
803
|
const { inputNode: t, inputTexelSize: s, downsampleNode: r } = this;
|
|
804
|
-
|
|
805
|
-
const n =
|
|
804
|
+
f(t != null);
|
|
805
|
+
const n = B(), i = w(1, 1, -1, -1).mul(s.xyxy).add(n.xyxy), u = p(n.x, i.y).toVertexStage(), a = p(i.z, n.y).toVertexStage(), h = p(i.x, n.y).toVertexStage(), c = p(n.x, i.w).toVertexStage(), l = i.zy.toVertexStage(), d = i.xy.toVertexStage(), m = i.zw.toVertexStage(), g = i.xw.toVertexStage(), x = S(
|
|
806
806
|
t.sample(n).mul(1 / 4),
|
|
807
|
-
|
|
807
|
+
S(
|
|
808
808
|
t.sample(u),
|
|
809
809
|
t.sample(a),
|
|
810
810
|
t.sample(h),
|
|
811
|
-
t.sample(
|
|
811
|
+
t.sample(c)
|
|
812
812
|
).mul(1 / 8),
|
|
813
|
-
|
|
814
|
-
t.sample(
|
|
813
|
+
S(
|
|
814
|
+
t.sample(l),
|
|
815
815
|
t.sample(d),
|
|
816
816
|
t.sample(m),
|
|
817
817
|
t.sample(g)
|
|
818
818
|
).mul(1 / 16)
|
|
819
819
|
);
|
|
820
|
-
return
|
|
820
|
+
return te(r.sample(n), x, this.blendAmount);
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
|
-
const
|
|
824
|
-
function
|
|
825
|
-
|
|
826
|
-
return ("backend" in e ? e.backend : o).isWebGPUBackend === !0;
|
|
823
|
+
const oo = (...o) => new We(...o);
|
|
824
|
+
function He(o) {
|
|
825
|
+
return (o instanceof Lt ? o.renderer.backend : "backend" in o ? o.backend : o).isWebGPUBackend === !0;
|
|
827
826
|
}
|
|
828
|
-
class
|
|
827
|
+
class ys extends E {
|
|
829
828
|
constructor(e) {
|
|
830
|
-
super("vec4"), this.bloomIntensity = v(0.05), this.inputNode = e, this.thresholdNode = new
|
|
829
|
+
super("vec4"), this.bloomIntensity = v(0.05), this.inputNode = e, this.thresholdNode = new Ee(), this.blurNode = new Oe(), this.ghostNode = new as(), this.haloNode = new vs(), this.bloomNode = new We(null, 8), this.glareNode = new xs(), this.featuresNode = ds(S(this.ghostNode, this.haloNode)), this.featuresNode.value.name = "LensFlareNode.Features", this.featuresNode.resolutionScale = 0.5, this.blurNode.resolutionScale = 1, this.bloomNode.resolutionScale = 1, this.glareNode.resolutionScale = 1;
|
|
831
830
|
}
|
|
832
831
|
static get type() {
|
|
833
832
|
return "LensFlareNode";
|
|
@@ -843,74 +842,70 @@ class vs extends G {
|
|
|
843
842
|
featuresNode: a,
|
|
844
843
|
glareNode: h
|
|
845
844
|
} = this;
|
|
846
|
-
|
|
847
|
-
const
|
|
848
|
-
s.inputNode = t, r.inputNode =
|
|
849
|
-
const d =
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
const g = b(t);
|
|
854
|
-
return g.addAssign(d), qe(e) && g.addAssign(m), g.add(a);
|
|
845
|
+
f(t != null);
|
|
846
|
+
const c = s.getTextureNode(), l = r.getTextureNode();
|
|
847
|
+
s.inputNode = t, r.inputNode = c, n.inputNode = l, i.inputNode = l, u.inputNode = c, h.inputNode = c;
|
|
848
|
+
const d = u.getTextureNode().mul(this.bloomIntensity), m = h.getTextureNode();
|
|
849
|
+
return C(() => {
|
|
850
|
+
const g = t;
|
|
851
|
+
return g.addAssign(d), He(e) && g.addAssign(m), g.add(a);
|
|
855
852
|
})();
|
|
856
853
|
}
|
|
857
854
|
dispose() {
|
|
858
855
|
this.thresholdNode.dispose(), this.blurNode.dispose(), this.ghostNode.dispose(), this.haloNode.dispose(), this.bloomNode.dispose(), this.glareNode.dispose(), this.featuresNode.dispose(), super.dispose();
|
|
859
856
|
}
|
|
860
857
|
}
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
)
|
|
865
|
-
), io = /* @__PURE__ */ k(
|
|
858
|
+
const ro = (o) => new ys(
|
|
859
|
+
o != null ? Le(o, "LensFlareNode.Input") : null
|
|
860
|
+
), no = /* @__PURE__ */ G(
|
|
866
861
|
(o, e, t, s) => {
|
|
867
|
-
const r = o.sub(t), n =
|
|
868
|
-
return
|
|
869
|
-
const h =
|
|
862
|
+
const r = o.sub(t), n = Q(e, r), i = Q(r, r).sub(s.pow2()), u = n.pow2().sub(i).toVar(), a = p(-1);
|
|
863
|
+
return F(u.greaterThanEqual(0), () => {
|
|
864
|
+
const h = Y(u);
|
|
870
865
|
a.assign(p(n.negate().sub(h), n.negate().add(h)));
|
|
871
866
|
}), a;
|
|
872
867
|
}
|
|
873
|
-
), ws = /* @__PURE__ */
|
|
868
|
+
), ws = /* @__PURE__ */ oe(
|
|
874
869
|
{ near: "vec4", far: "vec4" },
|
|
875
870
|
"raySpheresIntersections"
|
|
876
|
-
),
|
|
871
|
+
), io = /* @__PURE__ */ G(
|
|
877
872
|
(o, e, t, s) => {
|
|
878
|
-
const r = o.sub(t), n =
|
|
879
|
-
return
|
|
880
|
-
const
|
|
881
|
-
a.assign(n.negate().sub(
|
|
873
|
+
const r = o.sub(t), n = Q(e, r), i = Q(r, r).sub(s.pow2()), u = n.pow2().sub(i).toVar(), a = w(-1), h = w(-1);
|
|
874
|
+
return F(u.greaterThanEqual(0), () => {
|
|
875
|
+
const c = Y(u);
|
|
876
|
+
a.assign(n.negate().sub(c)), h.assign(n.negate().add(c));
|
|
882
877
|
}), ws(a, h);
|
|
883
878
|
}
|
|
884
|
-
),
|
|
879
|
+
), ao = /* @__PURE__ */ G(
|
|
885
880
|
(o, e, t) => {
|
|
886
881
|
const s = o.div(t), r = e.div(t), n = r.dot(r), i = s.dot(r), u = s.dot(s), a = i.pow2().sub(n.mul(u.sub(1))).toVar(), h = p(-1);
|
|
887
|
-
return
|
|
888
|
-
const
|
|
889
|
-
h.assign(p(i.negate().sub(
|
|
882
|
+
return F(a.greaterThanEqual(0), () => {
|
|
883
|
+
const c = Y(a);
|
|
884
|
+
h.assign(p(i.negate().sub(c), i.negate().add(c)).div(n));
|
|
890
885
|
}), h;
|
|
891
886
|
}
|
|
892
887
|
), Ts = {
|
|
893
|
-
float:
|
|
888
|
+
float: re,
|
|
894
889
|
int: H,
|
|
895
|
-
uint:
|
|
896
|
-
bool:
|
|
890
|
+
uint: Vt,
|
|
891
|
+
bool: bt,
|
|
897
892
|
vec2: p,
|
|
898
|
-
ivec2:
|
|
899
|
-
uvec2:
|
|
893
|
+
ivec2: T,
|
|
894
|
+
uvec2: Ce,
|
|
900
895
|
bvec2: Rt,
|
|
901
|
-
vec3:
|
|
902
|
-
ivec3:
|
|
903
|
-
uvec3:
|
|
904
|
-
bvec3:
|
|
905
|
-
vec4:
|
|
906
|
-
ivec4:
|
|
907
|
-
uvec4:
|
|
908
|
-
bvec4:
|
|
896
|
+
vec3: y,
|
|
897
|
+
ivec3: Mt,
|
|
898
|
+
uvec3: Nt,
|
|
899
|
+
bvec3: St,
|
|
900
|
+
vec4: w,
|
|
901
|
+
ivec4: Tt,
|
|
902
|
+
uvec4: wt,
|
|
903
|
+
bvec4: yt,
|
|
909
904
|
mat2: vt,
|
|
910
|
-
mat3:
|
|
911
|
-
mat4:
|
|
912
|
-
color:
|
|
913
|
-
};
|
|
905
|
+
mat3: Pe,
|
|
906
|
+
mat4: ft,
|
|
907
|
+
color: xt
|
|
908
|
+
}, uo = Wt;
|
|
914
909
|
function lo(o) {
|
|
915
910
|
return Ts[o];
|
|
916
911
|
}
|
|
@@ -928,34 +923,23 @@ class Ss extends Ht {
|
|
|
928
923
|
return new this.constructor(this.owner, this.value);
|
|
929
924
|
}
|
|
930
925
|
}
|
|
931
|
-
const co = (...o) =>
|
|
932
|
-
(o, e, t = 0.4) => {
|
|
933
|
-
const s = p(Fe(o)), r = s.reciprocal(), n = s.mul(e), i = n.sub(0.5).floor().add(0.5), u = n.sub(i), a = u.mul(u), h = u.mul(a), l = b(t), c = l.mul(u), d = l.negate().mul(h).add(l.mul(2).mul(a).sub(c)), m = C(2, l).mul(h).sub(C(3, l).mul(a)).add(1), g = C(2, l).negate().mul(h).add(C(3, l.mul(2)).mul(a)).add(c), x = l.mul(h).sub(l.mul(a)), T = m.add(g), S = r.mul(i.add(g.div(T))), V = o.sample(S).rgb, D = r.mul(i.sub(1)), F = r.mul(i.add(2));
|
|
934
|
-
return M(
|
|
935
|
-
f(o.sample(p(S.x, D.y)).rgb, 1).mul(T.x.mul(d.y)),
|
|
936
|
-
f(o.sample(p(D.x, S.y)).rgb, 1).mul(d.x.mul(T.y)),
|
|
937
|
-
f(V, 1).mul(T.x.mul(T.y)),
|
|
938
|
-
f(o.sample(p(F.x, S.y)).rgb, 1).mul(x.x.mul(T.y)),
|
|
939
|
-
f(o.sample(p(S.x, F.y)).rgb, 1).mul(T.x.mul(x.y))
|
|
940
|
-
);
|
|
941
|
-
}
|
|
942
|
-
), ho = /* @__PURE__ */ k(
|
|
926
|
+
const co = (...o) => new Ss(...o), ho = /* @__PURE__ */ G(
|
|
943
927
|
(o, e) => {
|
|
944
|
-
const t = p(
|
|
945
|
-
return
|
|
928
|
+
const t = p(Ae(o)), s = t.reciprocal(), r = e.mul(t), n = r.sub(0.5).floor().add(0.5), i = r.sub(n), u = i.mul(i.mul(i.mul(0.5).oneMinus()).sub(0.5)), a = i.mul(i).mul(i.mul(1.5).sub(2.5)).add(1), h = i.mul(i.mul(k(2, i.mul(1.5))).add(0.5)), c = i.mul(i).mul(i.mul(0.5).sub(0.5)), l = a.add(h), d = h.div(a.add(h)), m = n.sub(1).mul(s), g = n.add(2).mul(s), x = n.add(d).mul(s);
|
|
929
|
+
return S(
|
|
946
930
|
o.sample(p(m.x, m.y)).mul(u.x).mul(u.y),
|
|
947
|
-
o.sample(p(x.x, m.y)).mul(
|
|
948
|
-
o.sample(p(g.x, m.y)).mul(
|
|
949
|
-
o.sample(p(m.x, x.y)).mul(u.x).mul(
|
|
950
|
-
o.sample(p(x.x, x.y)).mul(
|
|
951
|
-
o.sample(p(g.x, x.y)).mul(
|
|
952
|
-
o.sample(p(m.x, g.y)).mul(u.x).mul(
|
|
953
|
-
o.sample(p(x.x, g.y)).mul(
|
|
954
|
-
o.sample(p(g.x, g.y)).mul(
|
|
931
|
+
o.sample(p(x.x, m.y)).mul(l.x).mul(u.y),
|
|
932
|
+
o.sample(p(g.x, m.y)).mul(c.x).mul(u.y),
|
|
933
|
+
o.sample(p(m.x, x.y)).mul(u.x).mul(l.y),
|
|
934
|
+
o.sample(p(x.x, x.y)).mul(l.x).mul(l.y),
|
|
935
|
+
o.sample(p(g.x, x.y)).mul(c.x).mul(l.y),
|
|
936
|
+
o.sample(p(m.x, g.y)).mul(u.x).mul(c.y),
|
|
937
|
+
o.sample(p(x.x, g.y)).mul(l.x).mul(c.y),
|
|
938
|
+
o.sample(p(g.x, g.y)).mul(c.x).mul(c.y)
|
|
955
939
|
);
|
|
956
940
|
}
|
|
957
941
|
);
|
|
958
|
-
function
|
|
942
|
+
function fe(o, e) {
|
|
959
943
|
let t = 1, s = 0;
|
|
960
944
|
for (; o > 0; )
|
|
961
945
|
t /= e, s += t * (o % e), o = Math.floor(o / e);
|
|
@@ -963,34 +947,34 @@ function ye(o, e) {
|
|
|
963
947
|
}
|
|
964
948
|
const ve = /* @__PURE__ */ Array.from(
|
|
965
949
|
{ length: 16 },
|
|
966
|
-
(o, e) => new
|
|
967
|
-
),
|
|
950
|
+
(o, e) => new V(fe(e + 1, 2), fe(e + 1, 3))
|
|
951
|
+
), Ns = (o, e, t, { perspective: s = !0, logarithmic: r = !1 } = {}) => r ? De(o, e, t) : s ? je(o, e, t) : zt(o, e, t), ye = (o, e, t) => {
|
|
968
952
|
const s = De(o, e, t);
|
|
969
|
-
return
|
|
953
|
+
return Pt(s, e, t);
|
|
970
954
|
}, po = (o, e, t) => {
|
|
971
|
-
const s =
|
|
972
|
-
return
|
|
955
|
+
const s = je(o, e, t);
|
|
956
|
+
return Fe(s, e, t);
|
|
973
957
|
}, mo = (o, e, t, s, r) => {
|
|
974
|
-
const n = s.element(H(2)).element(H(3)), i = s.element(H(3)).element(H(3)), a =
|
|
958
|
+
const n = 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(n).add(i));
|
|
975
959
|
return r.mul(a).xyz;
|
|
976
|
-
},
|
|
977
|
-
/* @__PURE__ */
|
|
978
|
-
/* @__PURE__ */
|
|
979
|
-
/* @__PURE__ */
|
|
980
|
-
/* @__PURE__ */
|
|
981
|
-
/* @__PURE__ */
|
|
982
|
-
/* @__PURE__ */
|
|
983
|
-
],
|
|
984
|
-
const r =
|
|
985
|
-
return
|
|
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]), go = (o, e, t, s) => {
|
|
968
|
+
const r = Ns(o, e, t, s);
|
|
969
|
+
return Ms(Fe(r, e, t));
|
|
986
970
|
}, xo = (o) => {
|
|
987
|
-
const e =
|
|
988
|
-
return
|
|
989
|
-
}, { resetRendererState: Rs, restoreRendererState:
|
|
990
|
-
function
|
|
971
|
+
const e = k(0.5, o.x).mul(Bt), 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 Vs(o) {
|
|
991
975
|
return o.isPerspectiveCamera === !0 || o.isOrthographicCamera === !0 || "updateProjectionMatrix" in o && "setViewOffset" in o && "clearViewOffset" in o;
|
|
992
976
|
}
|
|
993
|
-
const
|
|
977
|
+
const zs = /* @__PURE__ */ K({
|
|
994
978
|
name: "clipAABB",
|
|
995
979
|
type: "vec4",
|
|
996
980
|
inputs: [
|
|
@@ -1000,75 +984,75 @@ const Bs = /* @__PURE__ */ J({
|
|
|
1000
984
|
{ name: "maxColor", type: "vec4" }
|
|
1001
985
|
]
|
|
1002
986
|
})(([o, e, t, s]) => {
|
|
1003
|
-
const r = s.rgb.add(t.rgb).mul(0.5), n = s.rgb.sub(t.rgb).mul(0.5).add(1e-7), i = e.sub(
|
|
1004
|
-
return
|
|
987
|
+
const r = s.rgb.add(t.rgb).mul(0.5), n = s.rgb.sub(t.rgb).mul(0.5).add(1e-7), i = e.sub(w(r, o.a)), a = i.xyz.div(n).abs(), h = Ue(a.x, a.y, a.z);
|
|
988
|
+
return Ut(
|
|
1005
989
|
h.greaterThan(1),
|
|
1006
|
-
|
|
990
|
+
w(r, o.a).add(i.div(h)),
|
|
1007
991
|
e
|
|
1008
992
|
);
|
|
1009
|
-
}),
|
|
1010
|
-
/* @__PURE__ */
|
|
1011
|
-
/* @__PURE__ */
|
|
1012
|
-
/* @__PURE__ */
|
|
1013
|
-
/* @__PURE__ */
|
|
1014
|
-
/* @__PURE__ */
|
|
1015
|
-
/* @__PURE__ */
|
|
1016
|
-
/* @__PURE__ */
|
|
1017
|
-
/* @__PURE__ */
|
|
1018
|
-
],
|
|
993
|
+
}), Te = [
|
|
994
|
+
/* @__PURE__ */ T(-1, -1),
|
|
995
|
+
/* @__PURE__ */ T(-1, 1),
|
|
996
|
+
/* @__PURE__ */ T(1, -1),
|
|
997
|
+
/* @__PURE__ */ T(1, 1),
|
|
998
|
+
/* @__PURE__ */ T(1, 0),
|
|
999
|
+
/* @__PURE__ */ T(0, -1),
|
|
1000
|
+
/* @__PURE__ */ T(0, 1),
|
|
1001
|
+
/* @__PURE__ */ T(-1, 0)
|
|
1002
|
+
], Bs = /* @__PURE__ */ G(
|
|
1019
1003
|
(o, e, t, s, r) => {
|
|
1020
1004
|
const n = t.toVar(), i = t.pow2().toVar();
|
|
1021
|
-
for (const d of
|
|
1005
|
+
for (const d of Te) {
|
|
1022
1006
|
const m = o.load(e.add(d));
|
|
1023
1007
|
n.addAssign(m), i.addAssign(m.pow2());
|
|
1024
1008
|
}
|
|
1025
|
-
const u =
|
|
1026
|
-
return
|
|
1027
|
-
}
|
|
1028
|
-
),
|
|
1029
|
-
/* @__PURE__ */
|
|
1030
|
-
/* @__PURE__ */
|
|
1031
|
-
/* @__PURE__ */
|
|
1032
|
-
/* @__PURE__ */
|
|
1033
|
-
/* @__PURE__ */
|
|
1034
|
-
/* @__PURE__ */
|
|
1035
|
-
/* @__PURE__ */
|
|
1036
|
-
/* @__PURE__ */
|
|
1037
|
-
/* @__PURE__ */
|
|
1038
|
-
],
|
|
1009
|
+
const u = re(Te.length + 1), a = n.div(u), h = Y(i.div(u).sub(a.pow2()).max(0)).mul(r), c = a.sub(h), l = a.add(h);
|
|
1010
|
+
return zs(a.clamp(c, l), s, c, l);
|
|
1011
|
+
}
|
|
1012
|
+
), Cs = [
|
|
1013
|
+
/* @__PURE__ */ T(-1, -1),
|
|
1014
|
+
/* @__PURE__ */ T(-1, 0),
|
|
1015
|
+
/* @__PURE__ */ T(-1, 1),
|
|
1016
|
+
/* @__PURE__ */ T(0, -1),
|
|
1017
|
+
/* @__PURE__ */ T(0, 0),
|
|
1018
|
+
/* @__PURE__ */ T(0, 1),
|
|
1019
|
+
/* @__PURE__ */ T(1, -1),
|
|
1020
|
+
/* @__PURE__ */ T(1, 0),
|
|
1021
|
+
/* @__PURE__ */ T(1, 1)
|
|
1022
|
+
], Ps = /* @__PURE__ */ oe({
|
|
1039
1023
|
coord: "ivec2",
|
|
1040
1024
|
depth: "float"
|
|
1041
|
-
}),
|
|
1025
|
+
}), As = /* @__PURE__ */ G(
|
|
1042
1026
|
(o, e) => {
|
|
1043
|
-
const t =
|
|
1044
|
-
for (const r of
|
|
1027
|
+
const t = re(1), s = T(0);
|
|
1028
|
+
for (const r of Cs) {
|
|
1045
1029
|
const n = e.add(r).toVar(), i = o.load(n).toVar();
|
|
1046
|
-
|
|
1030
|
+
F(i.r.lessThan(t), () => {
|
|
1047
1031
|
s.assign(n), t.assign(i.r);
|
|
1048
1032
|
});
|
|
1049
1033
|
}
|
|
1050
|
-
return
|
|
1034
|
+
return Ps(s, t);
|
|
1051
1035
|
}
|
|
1052
|
-
),
|
|
1053
|
-
class
|
|
1036
|
+
), Se = /* @__PURE__ */ new V(), Fs = /* @__PURE__ */ new et(1, 1);
|
|
1037
|
+
class Ds extends E {
|
|
1054
1038
|
constructor(e, t, s, r, n) {
|
|
1055
|
-
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
|
|
1039
|
+
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 P(), this.copyMaterial = new P(), this.mesh = new q(), this.needsSyncPostProcessing = !1, this.needsClearHistory = !1, this.resolveNode = I(this.resolveRT.texture), this.historyNode = I(this.historyRT.texture), this.previousDepthNode = I(Fs), this.originalProjectionMatrix = new W(), this.jitterIndex = 0, this.velocityNodeImmutable = e, this.inputNode = t, this.depthNode = s, this.velocityNode = r, !Vs(n))
|
|
1056
1040
|
throw new Error("The provided camera is not supported.");
|
|
1057
|
-
this.camera = n, this.textureNode = ke(this, this.resolveRT.texture), this.updateBeforeType =
|
|
1041
|
+
this.camera = n, this.textureNode = ke(this, this.resolveRT.texture), this.updateBeforeType = A.FRAME;
|
|
1058
1042
|
}
|
|
1059
1043
|
static get type() {
|
|
1060
1044
|
return "TemporalAntialiasNode";
|
|
1061
1045
|
}
|
|
1062
1046
|
customCacheKey() {
|
|
1063
|
-
return
|
|
1047
|
+
return Ie(this.camera.id, +this.debugShowRejection);
|
|
1064
1048
|
}
|
|
1065
1049
|
createRenderTarget(e) {
|
|
1066
|
-
const t = new
|
|
1050
|
+
const t = new Ne(1, 1, {
|
|
1067
1051
|
depthBuffer: !1,
|
|
1068
1052
|
type: Re,
|
|
1069
|
-
format:
|
|
1053
|
+
format: Me
|
|
1070
1054
|
}), s = t.texture;
|
|
1071
|
-
s.minFilter =
|
|
1055
|
+
s.minFilter = Z, s.magFilter = Z, s.generateMipmaps = !1;
|
|
1072
1056
|
const r = this.constructor.type;
|
|
1073
1057
|
return s.name = e != null ? `${r}.${e}` : r, t;
|
|
1074
1058
|
}
|
|
@@ -1106,46 +1090,46 @@ class js extends G {
|
|
|
1106
1090
|
updateBefore({ renderer: e }) {
|
|
1107
1091
|
if (e == null)
|
|
1108
1092
|
return;
|
|
1109
|
-
const t = e.getDrawingBufferSize(
|
|
1110
|
-
this.setSize(t.x, t.y), this.rendererState = Rs(e, this.rendererState), this.needsClearHistory && this.clearHistory(e), e.setRenderTarget(this.resolveRT), this.mesh.material = this.resolveMaterial, this.mesh.render(e),
|
|
1093
|
+
const t = e.getDrawingBufferSize(Se);
|
|
1094
|
+
this.setSize(t.x, t.y), this.rendererState = Rs(e, this.rendererState), this.needsClearHistory && this.clearHistory(e), e.setRenderTarget(this.resolveRT), this.mesh.material = this.resolveMaterial, this.mesh.render(e), bs(e, this.rendererState), He(e) && this.copyDepthTexture(e), this.swapBuffers(), this.needsSyncPostProcessing && this.clearViewOffset();
|
|
1111
1095
|
}
|
|
1112
1096
|
setupResolveNode({ renderer: e }) {
|
|
1113
1097
|
const t = (s) => {
|
|
1114
|
-
const { previousDepthNode: r } = this, n = r.load(
|
|
1115
|
-
return e.logarithmicDepthBuffer ?
|
|
1098
|
+
const { previousDepthNode: r } = this, n = r.load(T(s.mul(Ae(r)).sub(0.5))).toVar();
|
|
1099
|
+
return e.logarithmicDepthBuffer ? ye(
|
|
1116
1100
|
n,
|
|
1117
|
-
|
|
1118
|
-
|
|
1101
|
+
de(this.camera),
|
|
1102
|
+
pe(this.camera)
|
|
1119
1103
|
) : n;
|
|
1120
1104
|
};
|
|
1121
|
-
return
|
|
1122
|
-
const s =
|
|
1105
|
+
return C(() => {
|
|
1106
|
+
const s = T(ze), r = At, n = this.inputNode.load(s), i = As(this.depthNode, s), u = i.get("coord"), a = this.velocityNode.load(u).xyz.mul(y(0.5, -0.5, 0.5)).toVar(), h = a.xy.length().div(this.velocityThreshold).oneMinus().saturate(), c = r.sub(a.xy).toVar(), l = t(c), d = e.logarithmicDepthBuffer ? ye(
|
|
1123
1107
|
i.get("depth"),
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
) : i.get("depth"), m =
|
|
1108
|
+
de(this.camera),
|
|
1109
|
+
pe(this.camera)
|
|
1110
|
+
) : i.get("depth"), m = Ft(
|
|
1127
1111
|
d.add(a.z),
|
|
1128
|
-
|
|
1129
|
-
), g = h.mul(m), x =
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
).toFloat(),
|
|
1133
|
-
return
|
|
1134
|
-
const
|
|
1112
|
+
l.add(this.depthError)
|
|
1113
|
+
), g = h.mul(m), x = Dt(
|
|
1114
|
+
c.greaterThanEqual(0).all(),
|
|
1115
|
+
c.lessThanEqual(1).all()
|
|
1116
|
+
).toFloat(), R = i.get("depth").notEqual(1).toFloat(), N = w(0).toVar();
|
|
1117
|
+
return F(x.mul(R).mul(g).greaterThan(0), () => {
|
|
1118
|
+
const z = I(this.historyNode, c), L = Bs(
|
|
1135
1119
|
this.inputNode,
|
|
1136
1120
|
s,
|
|
1137
1121
|
n,
|
|
1138
|
-
|
|
1122
|
+
z,
|
|
1139
1123
|
this.varianceGamma
|
|
1140
|
-
),
|
|
1124
|
+
), j = a.xy.abs().mul(jt), U = Ue(j.x, j.y).fract().mul(0.5), M = te(
|
|
1141
1125
|
this.temporalAlpha,
|
|
1142
1126
|
0.8,
|
|
1143
|
-
|
|
1127
|
+
U
|
|
1144
1128
|
).saturate();
|
|
1145
|
-
|
|
1129
|
+
N.assign(te(L, n, M));
|
|
1146
1130
|
}).Else(() => {
|
|
1147
|
-
|
|
1148
|
-
}),
|
|
1131
|
+
N.assign(n), this.debugShowRejection && N.assign(y(1, 0, 0));
|
|
1132
|
+
}), N;
|
|
1149
1133
|
})();
|
|
1150
1134
|
}
|
|
1151
1135
|
setup(e) {
|
|
@@ -1154,7 +1138,7 @@ class js extends G {
|
|
|
1154
1138
|
const { onBeforePostProcessing: n } = t;
|
|
1155
1139
|
t.onBeforePostProcessing = () => {
|
|
1156
1140
|
n?.();
|
|
1157
|
-
const i = e.renderer.getDrawingBufferSize(
|
|
1141
|
+
const i = e.renderer.getDrawingBufferSize(Se);
|
|
1158
1142
|
this.setViewOffset(i.width, i.height);
|
|
1159
1143
|
}, this.needsSyncPostProcessing = !0;
|
|
1160
1144
|
}
|
|
@@ -1165,71 +1149,69 @@ class js extends G {
|
|
|
1165
1149
|
this.resolveRT.dispose(), this.historyRT.dispose(), this.previousDepthTexture?.dispose(), this.resolveMaterial.dispose(), this.copyMaterial.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
1166
1150
|
}
|
|
1167
1151
|
}
|
|
1168
|
-
const fo = (o) => (e, t, s, r) =>
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
r
|
|
1175
|
-
)
|
|
1152
|
+
const fo = (o) => (e, t, s, r) => new Ds(
|
|
1153
|
+
o,
|
|
1154
|
+
Le(e, "TemporalAntialiasNode.Input"),
|
|
1155
|
+
t,
|
|
1156
|
+
s,
|
|
1157
|
+
r
|
|
1176
1158
|
);
|
|
1177
1159
|
export {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1160
|
+
Ee as DownsampleThresholdNode,
|
|
1161
|
+
K as FnLayout,
|
|
1162
|
+
G as FnVar,
|
|
1163
|
+
Oe as GaussianBlurNode,
|
|
1182
1164
|
ns as HighpVelocityNode,
|
|
1183
1165
|
is as KawaseBlurNode,
|
|
1184
|
-
|
|
1166
|
+
ys as LensFlareNode,
|
|
1185
1167
|
Jt as MipmapBlurNode,
|
|
1186
|
-
|
|
1168
|
+
We as MipmapSurfaceBlurNode,
|
|
1169
|
+
uo as Node,
|
|
1187
1170
|
Ss as OutputTexture3DNode,
|
|
1188
1171
|
qt as OutputTextureNode,
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1172
|
+
Ge as RTTextureNode,
|
|
1173
|
+
Ds as TemporalAntialiasNode,
|
|
1174
|
+
pe as cameraFar,
|
|
1175
|
+
de as cameraNear,
|
|
1176
|
+
Hs as cameraPositionWorld,
|
|
1177
|
+
Le as convertToTexture,
|
|
1178
|
+
qs as debugFragmentNode,
|
|
1179
|
+
Qs as debugNode,
|
|
1180
|
+
Zs as debugVertexNode,
|
|
1198
1181
|
go as depthToColor,
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1182
|
+
Ns as depthToViewZ,
|
|
1183
|
+
Xs as dithering,
|
|
1184
|
+
Ys as downsampleThreshold,
|
|
1185
|
+
eo as equirectGrid,
|
|
1203
1186
|
xo as equirectToDirectionWorld,
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1187
|
+
_s as gaussianBlur,
|
|
1188
|
+
to as highpVelocity,
|
|
1189
|
+
Ks as hookFunction,
|
|
1207
1190
|
rs as interleavedGradientNoise,
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1191
|
+
Ls as inverseProjectionMatrix,
|
|
1192
|
+
Ws as inverseViewMatrix,
|
|
1193
|
+
He as isWebGPU,
|
|
1194
|
+
so as kawaseBlur,
|
|
1195
|
+
ro as lensFlare,
|
|
1196
|
+
ye as logarithmicToPerspectiveDepth,
|
|
1197
|
+
Js as mipmapBlur,
|
|
1198
|
+
$e as mipmapBlurDownsample,
|
|
1216
1199
|
Kt as mipmapBlurUpsample,
|
|
1217
|
-
|
|
1200
|
+
oo as mipmapSurfaceBlur,
|
|
1218
1201
|
lo as node,
|
|
1219
1202
|
ke as outputTexture,
|
|
1220
1203
|
co as outputTexture3D,
|
|
1221
1204
|
po as perspectiveToLogarithmicDepth,
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1205
|
+
Os as projectionMatrix,
|
|
1206
|
+
ao as rayEllipsoidIntersection,
|
|
1207
|
+
no as raySphereIntersection,
|
|
1208
|
+
io as raySpheresIntersections,
|
|
1226
1209
|
ws as raySpheresIntersectionsStruct,
|
|
1227
1210
|
ds as rtTexture,
|
|
1228
1211
|
mo as screenToPositionView,
|
|
1229
1212
|
fo as temporalAntialias,
|
|
1230
|
-
Ns as textureBicubic,
|
|
1231
1213
|
ho as textureCatmullRom,
|
|
1232
|
-
|
|
1233
|
-
|
|
1214
|
+
Ms as turbo,
|
|
1215
|
+
Gs as viewMatrix
|
|
1234
1216
|
};
|
|
1235
1217
|
//# sourceMappingURL=webgpu.js.map
|