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