@takram/three-clouds 0.3.0 → 0.4.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 +19 -0
- package/README.md +16 -17
- package/build/index.cjs +9 -9
- package/build/index.cjs.map +1 -1
- package/build/index.js +70 -77
- package/build/index.js.map +1 -1
- package/build/r3f.cjs +1 -1
- package/build/r3f.cjs.map +1 -1
- package/build/r3f.js +122 -127
- package/build/r3f.js.map +1 -1
- package/build/shared.cjs +70 -55
- package/build/shared.cjs.map +1 -1
- package/build/shared.js +352 -303
- package/build/shared.js.map +1 -1
- package/package.json +3 -3
- package/src/CloudLayers.ts +2 -2
- package/src/CloudsEffect.ts +49 -28
- package/src/CloudsMaterial.ts +38 -21
- package/src/CloudsPass.ts +5 -6
- package/src/PassBase.ts +1 -1
- package/src/Procedural3DTexture.ts +2 -4
- package/src/ProceduralTexture.ts +1 -3
- package/src/ShaderArrayPass.ts +5 -5
- package/src/ShadowMaterial.ts +4 -4
- package/src/ShadowPass.ts +5 -6
- package/src/constants.ts +1 -0
- package/src/helpers/setArrayRenderTargetLayers.ts +3 -6
- package/src/qualityPresets.ts +5 -5
- package/src/r3f/CloudLayer.tsx +1 -1
- package/src/r3f/Clouds.tsx +71 -85
- package/src/shaders/clouds.frag +36 -34
- package/src/shaders/clouds.vert +18 -5
- package/src/shaders/parameters.glsl +1 -1
- package/src/shaders/shadowResolve.frag +2 -2
- package/src/shaders/types.glsl +1 -1
- package/src/shaders/varianceClipping.glsl +2 -2
- package/src/uniforms.ts +3 -3
- package/types/CloudsEffect.d.ts +18 -8
- package/types/CloudsMaterial.d.ts +7 -3
- package/types/qualityPresets.d.ts +1 -1
package/build/shared.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import { Pass as
|
2
|
-
import { Vector3 as f, Vector2 as m, Matrix4 as v, Object3D as se, Box3 as
|
3
|
-
import { AtmosphereMaterialBase as
|
4
|
-
import { lerp as
|
5
|
-
import {
|
6
|
-
import { vogelDisk as
|
7
|
-
class
|
1
|
+
import { Pass as ze, ShaderPass as Z, Resolution as K, Effect as Fe, EffectAttribute as We } from "postprocessing";
|
2
|
+
import { Vector3 as f, Vector2 as m, Matrix4 as v, Object3D as se, Box3 as Be, Uniform as r, GLSL3 as W, Vector4 as x, RawShaderMaterial as X, Camera as we, WebGLRenderTarget as Ge, HalfFloatType as Ce, LinearFilter as F, RedFormat as Ve, WebGLArrayRenderTarget as ke, EventDispatcher as je, Texture as ce, Data3DTexture as le } from "three";
|
3
|
+
import { AtmosphereMaterialBase as Ye, AtmosphereParameters as Te, getAltitudeCorrectionOffset as Ze } from "@takram/three-atmosphere";
|
4
|
+
import { lerp as De, defineInt as P, defineExpression as Ee, define as C, defineFloat as J, unrollLoops as B, resolveIncludes as U, assertType as Ke, Geodetic as qe, definePropertyShorthand as ue, defineUniformShorthand as he } from "@takram/three-geospatial";
|
5
|
+
import { runtime as de, definitions as pe, common as fe } from "@takram/three-atmosphere/shaders/bruneton";
|
6
|
+
import { vogelDisk as $e, interleavedGradientNoise as Xe, cascadedShadowMaps as Je, raySphereIntersection as Ae, generators as Qe, turbo as _e, math as Oe, depth as et } from "@takram/three-geospatial/shaders";
|
7
|
+
class G {
|
8
8
|
constructor(e = 0, t = 0, n = 0, a = 0) {
|
9
9
|
this.expTerm = e, this.exponent = t, this.linearTerm = n, this.constantTerm = a;
|
10
10
|
}
|
@@ -12,7 +12,7 @@ class B {
|
|
12
12
|
return this.expTerm = e, this.exponent = t, this.linearTerm = n, this.constantTerm = a, this;
|
13
13
|
}
|
14
14
|
clone() {
|
15
|
-
return new
|
15
|
+
return new G(
|
16
16
|
this.expTerm,
|
17
17
|
this.exponent,
|
18
18
|
this.linearTerm,
|
@@ -23,7 +23,7 @@ class B {
|
|
23
23
|
return this.expTerm = e.expTerm, this.exponent = e.exponent, this.linearTerm = e.linearTerm, this.constantTerm = e.constantTerm, this;
|
24
24
|
}
|
25
25
|
}
|
26
|
-
const
|
26
|
+
const tt = [
|
27
27
|
"channel",
|
28
28
|
"altitude",
|
29
29
|
"height",
|
@@ -36,19 +36,19 @@ const et = [
|
|
36
36
|
"shadow",
|
37
37
|
"densityProfile"
|
38
38
|
];
|
39
|
-
function
|
39
|
+
function nt(o, e) {
|
40
40
|
if (e != null)
|
41
|
-
for (const t of
|
41
|
+
for (const t of tt) {
|
42
42
|
const n = e[t];
|
43
|
-
n != null && (o[t] instanceof
|
43
|
+
n != null && (o[t] instanceof G ? o[t].copy(n) : o[t] = n);
|
44
44
|
}
|
45
45
|
}
|
46
46
|
const N = class N {
|
47
47
|
constructor(e) {
|
48
|
-
this.channel = "r", this.altitude = 0, this.height = 0, this.densityScale = 0.2, this.shapeAmount = 1, this.shapeDetailAmount = 1, this.weatherExponent = 1, this.shapeAlteringBias = 0.35, this.coverageFilterWidth = 0.6, this.densityProfile = new
|
48
|
+
this.channel = "r", this.altitude = 0, this.height = 0, this.densityScale = 0.2, this.shapeAmount = 1, this.shapeDetailAmount = 1, this.weatherExponent = 1, this.shapeAlteringBias = 0.35, this.coverageFilterWidth = 0.6, this.densityProfile = new G(0, 0, 0.75, 0.25), this.shadow = !1, this.set(e);
|
49
49
|
}
|
50
50
|
set(e) {
|
51
|
-
return
|
51
|
+
return nt(this, e), this;
|
52
52
|
}
|
53
53
|
clone() {
|
54
54
|
return new N(this);
|
@@ -59,17 +59,17 @@ const N = class N {
|
|
59
59
|
};
|
60
60
|
N.DEFAULT = /* @__PURE__ */ new N();
|
61
61
|
let T = N;
|
62
|
-
const
|
62
|
+
const O = /* @__PURE__ */ Array.from(
|
63
63
|
{ length: 8 },
|
64
64
|
() => ({ value: 0, flag: 0 })
|
65
65
|
), L = /* @__PURE__ */ Array.from(
|
66
66
|
{ length: 3 },
|
67
67
|
() => ({ min: 0, max: 0 })
|
68
68
|
);
|
69
|
-
function
|
69
|
+
function at(o, e) {
|
70
70
|
return o.value !== e.value ? o.value - e.value : o.flag - e.flag;
|
71
71
|
}
|
72
|
-
const
|
72
|
+
const M = class M extends Array {
|
73
73
|
constructor(e) {
|
74
74
|
super(
|
75
75
|
new T(e == null ? void 0 : e[0]),
|
@@ -85,7 +85,7 @@ const b = class b extends Array {
|
|
85
85
|
return this[0].copy(T.DEFAULT), this[1].copy(T.DEFAULT), this[2].copy(T.DEFAULT), this[3].copy(T.DEFAULT), this;
|
86
86
|
}
|
87
87
|
clone() {
|
88
|
-
return new
|
88
|
+
return new M(this);
|
89
89
|
}
|
90
90
|
copy(e) {
|
91
91
|
return this[0].copy(e[0]), this[1].copy(e[1]), this[2].copy(e[2]), this[3].copy(e[3]), this;
|
@@ -116,18 +116,18 @@ const b = class b extends Array {
|
|
116
116
|
packIntervalHeights(e, t) {
|
117
117
|
for (let s = 0; s < 4; ++s) {
|
118
118
|
const l = this[s];
|
119
|
-
let
|
120
|
-
|
119
|
+
let u = O[s];
|
120
|
+
u.value = l.altitude, u.flag = 0, u = O[s + 4], u.value = l.altitude + l.height, u.flag = 1;
|
121
121
|
}
|
122
|
-
|
122
|
+
O.sort(at);
|
123
123
|
let n = 0, a = 0;
|
124
|
-
for (let s = 0; s <
|
125
|
-
const { value: l, flag:
|
124
|
+
for (let s = 0; s < O.length; ++s) {
|
125
|
+
const { value: l, flag: u } = O[s];
|
126
126
|
if (a === 0 && s > 0) {
|
127
|
-
const
|
128
|
-
|
127
|
+
const h = L[n++];
|
128
|
+
h.min = O[s - 1].value, h.max = l;
|
129
129
|
}
|
130
|
-
a +=
|
130
|
+
a += u === 0 ? 1 : -1;
|
131
131
|
}
|
132
132
|
for (; n < 3; ++n) {
|
133
133
|
const s = L[n];
|
@@ -137,7 +137,7 @@ const b = class b extends Array {
|
|
137
137
|
e.x = i.min, t.x = i.max, i = L[1], e.y = i.min, t.y = i.max, i = L[2], e.z = i.min, t.z = i.max;
|
138
138
|
}
|
139
139
|
};
|
140
|
-
|
140
|
+
M.DEFAULT = /* @__PURE__ */ new M([
|
141
141
|
{
|
142
142
|
channel: "r",
|
143
143
|
altitude: 750,
|
@@ -175,22 +175,22 @@ b.DEFAULT = /* @__PURE__ */ new b([
|
|
175
175
|
},
|
176
176
|
{ channel: "a" }
|
177
177
|
]);
|
178
|
-
let
|
179
|
-
var
|
178
|
+
let q = M;
|
179
|
+
var it = "production" === "production", me = "Invariant failed";
|
180
180
|
function A(o, e) {
|
181
181
|
if (!o) {
|
182
|
-
if (
|
183
|
-
throw new Error(
|
184
|
-
var t =
|
182
|
+
if (it)
|
183
|
+
throw new Error(me);
|
184
|
+
var t = me;
|
185
185
|
throw new Error(t);
|
186
186
|
}
|
187
187
|
}
|
188
|
-
class
|
188
|
+
class b {
|
189
189
|
constructor(e, t) {
|
190
190
|
this.near = [new f(), new f(), new f(), new f()], this.far = [new f(), new f(), new f(), new f()], e != null && t != null && this.setFromCamera(e, t);
|
191
191
|
}
|
192
192
|
clone() {
|
193
|
-
return new
|
193
|
+
return new b().copy(this);
|
194
194
|
}
|
195
195
|
copy(e) {
|
196
196
|
for (let t = 0; t < 4; ++t)
|
@@ -213,7 +213,7 @@ class U {
|
|
213
213
|
}
|
214
214
|
split(e, t = []) {
|
215
215
|
for (let n = 0; n < e.length; ++n) {
|
216
|
-
const a = t[n] ?? (t[n] = new
|
216
|
+
const a = t[n] ?? (t[n] = new b());
|
217
217
|
if (n === 0)
|
218
218
|
for (let i = 0; i < 4; ++i)
|
219
219
|
a.near[i].copy(this.near[i]);
|
@@ -243,7 +243,7 @@ class U {
|
|
243
243
|
return this;
|
244
244
|
}
|
245
245
|
}
|
246
|
-
const
|
246
|
+
const rt = {
|
247
247
|
uniform: (o, e, t, n, a = []) => {
|
248
248
|
for (let i = 0; i < o; ++i)
|
249
249
|
a[i] = (e + (t - e) * (i + 1) / o) / t;
|
@@ -257,15 +257,15 @@ const it = {
|
|
257
257
|
practical: (o, e, t, n = 0.5, a = []) => {
|
258
258
|
for (let i = 0; i < o; ++i) {
|
259
259
|
const s = (e + (t - e) * (i + 1) / o) / t, l = e * (t / e) ** ((i + 1) / o) / t;
|
260
|
-
a[i] =
|
260
|
+
a[i] = De(s, l, n);
|
261
261
|
}
|
262
262
|
return a.length = o, a;
|
263
263
|
}
|
264
264
|
};
|
265
|
-
function
|
266
|
-
return
|
265
|
+
function ot(o, e, t, n, a, i = []) {
|
266
|
+
return rt[o](e, t, n, a, i);
|
267
267
|
}
|
268
|
-
const
|
268
|
+
const ve = /* @__PURE__ */ new f(), ge = /* @__PURE__ */ new f(), st = /* @__PURE__ */ new v(), Se = /* @__PURE__ */ new v(), ct = /* @__PURE__ */ new b(), lt = /* @__PURE__ */ new Be(), ut = {
|
269
269
|
maxFar: null,
|
270
270
|
farScale: 1,
|
271
271
|
splitMode: "practical",
|
@@ -275,7 +275,7 @@ const me = /* @__PURE__ */ new f(), ve = /* @__PURE__ */ new f(), ot = /* @__PUR
|
|
275
275
|
};
|
276
276
|
class ht {
|
277
277
|
constructor(e) {
|
278
|
-
this.cascades = [], this.mapSize = new m(), this.cameraFrustum = new
|
278
|
+
this.cascades = [], this.mapSize = new m(), this.cameraFrustum = new b(), this.frusta = [], this.splits = [], this._far = 0;
|
279
279
|
const {
|
280
280
|
cascadeCount: t,
|
281
281
|
mapSize: n,
|
@@ -283,13 +283,13 @@ class ht {
|
|
283
283
|
farScale: i,
|
284
284
|
splitMode: s,
|
285
285
|
splitLambda: l,
|
286
|
-
margin:
|
287
|
-
fade:
|
286
|
+
margin: u,
|
287
|
+
fade: h
|
288
288
|
} = {
|
289
|
-
...
|
289
|
+
...ut,
|
290
290
|
...e
|
291
291
|
};
|
292
|
-
this.cascadeCount = t, this.mapSize.copy(n), this.maxFar = a, this.farScale = i, this.splitMode = s, this.splitLambda = l, this.margin =
|
292
|
+
this.cascadeCount = t, this.mapSize.copy(n), this.maxFar = a, this.farScale = i, this.splitMode = s, this.splitLambda = l, this.margin = u, this.fade = h;
|
293
293
|
}
|
294
294
|
get cascadeCount() {
|
295
295
|
return this.cascades.length;
|
@@ -315,7 +315,7 @@ class ht {
|
|
315
315
|
}
|
316
316
|
updateIntervals(e) {
|
317
317
|
const t = this.cascadeCount, n = this.splits, a = this.far;
|
318
|
-
|
318
|
+
ot(
|
319
319
|
this.splitMode,
|
320
320
|
t,
|
321
321
|
e.near,
|
@@ -334,22 +334,22 @@ class ht {
|
|
334
334
|
a[0].distanceTo(n[2])
|
335
335
|
);
|
336
336
|
if (this.fade) {
|
337
|
-
const s = e.near, l = this.far,
|
338
|
-
i += 0.25 *
|
337
|
+
const s = e.near, l = this.far, u = a[0].z / (l - s);
|
338
|
+
i += 0.25 * u ** 2 * (l - s);
|
339
339
|
}
|
340
340
|
return i * 0.5;
|
341
341
|
}
|
342
342
|
updateMatrices(e, t, n = 1) {
|
343
|
-
const a =
|
344
|
-
|
345
|
-
|
343
|
+
const a = st.lookAt(
|
344
|
+
ve.setScalar(0),
|
345
|
+
ge.copy(t).multiplyScalar(-1),
|
346
346
|
se.DEFAULT_UP
|
347
|
-
), i =
|
348
|
-
|
347
|
+
), i = Se.multiplyMatrices(
|
348
|
+
Se.copy(a).invert(),
|
349
349
|
e.matrixWorld
|
350
350
|
), s = this.frusta, l = this.cascades;
|
351
351
|
A(s.length === l.length);
|
352
|
-
const
|
352
|
+
const u = this.margin, h = this.mapSize;
|
353
353
|
for (let d = 0; d < s.length; ++d) {
|
354
354
|
const p = s[d], g = l[d], S = this.getFrustumRadius(e, s[d]), ee = -S, te = S, ne = S, ae = -S;
|
355
355
|
g.projectionMatrix.makeOrthographic(
|
@@ -362,14 +362,14 @@ class ht {
|
|
362
362
|
S * 2 + this.margin
|
363
363
|
// far
|
364
364
|
);
|
365
|
-
const { near:
|
366
|
-
for (let
|
367
|
-
H.expandByPoint(
|
368
|
-
const E = H.getCenter(
|
369
|
-
E.z = H.max.z +
|
370
|
-
const ie = (te - ee) /
|
365
|
+
const { near: be, far: He } = ct.copy(p).applyMatrix4(i), H = lt.makeEmpty();
|
366
|
+
for (let z = 0; z < 4; z++)
|
367
|
+
H.expandByPoint(be[z]), H.expandByPoint(He[z]);
|
368
|
+
const E = H.getCenter(ve);
|
369
|
+
E.z = H.max.z + u;
|
370
|
+
const ie = (te - ee) / h.width, re = (ne - ae) / h.height;
|
371
371
|
E.x = Math.round(E.x / ie) * ie, E.y = Math.round(E.y / re) * re, E.applyMatrix4(a);
|
372
|
-
const oe =
|
372
|
+
const oe = ge.copy(t).multiplyScalar(n).add(E);
|
373
373
|
g.inverseViewMatrix.lookAt(E, oe, se.DEFAULT_UP).setPosition(oe);
|
374
374
|
}
|
375
375
|
}
|
@@ -379,17 +379,17 @@ class ht {
|
|
379
379
|
for (let s = 0; s < i; ++s) {
|
380
380
|
const {
|
381
381
|
matrix: l,
|
382
|
-
inverseMatrix:
|
383
|
-
projectionMatrix:
|
382
|
+
inverseMatrix: u,
|
383
|
+
projectionMatrix: h,
|
384
384
|
inverseProjectionMatrix: d,
|
385
385
|
viewMatrix: p,
|
386
386
|
inverseViewMatrix: g
|
387
387
|
} = a[s];
|
388
|
-
d.copy(
|
388
|
+
d.copy(h).invert(), p.copy(g).invert(), l.copy(h).multiply(p), u.copy(g).multiply(d);
|
389
389
|
}
|
390
390
|
}
|
391
391
|
}
|
392
|
-
const
|
392
|
+
const ye = [
|
393
393
|
0,
|
394
394
|
8,
|
395
395
|
2,
|
@@ -406,18 +406,18 @@ const Se = [
|
|
406
406
|
7,
|
407
407
|
13,
|
408
408
|
5
|
409
|
-
], Pe = /* @__PURE__ */
|
409
|
+
], Pe = /* @__PURE__ */ ye.reduce(
|
410
410
|
(o, e, t) => {
|
411
411
|
const n = new m();
|
412
412
|
for (let a = 0; a < 16; ++a)
|
413
|
-
if (
|
413
|
+
if (ye[a] === t) {
|
414
414
|
n.set((a % 4 + 0.5) / 4, (Math.floor(a / 4) + 0.5) / 4);
|
415
415
|
break;
|
416
416
|
}
|
417
417
|
return [...o, n];
|
418
418
|
},
|
419
419
|
[]
|
420
|
-
),
|
420
|
+
), dt = {
|
421
421
|
resolutionScale: 1,
|
422
422
|
lightShafts: !0,
|
423
423
|
shapeDetail: !0,
|
@@ -425,7 +425,7 @@ const Se = [
|
|
425
425
|
haze: !0,
|
426
426
|
clouds: {
|
427
427
|
multiScatteringOctaves: 8,
|
428
|
-
|
428
|
+
accurateSunSkyLight: !0,
|
429
429
|
accuratePhaseFunction: !1,
|
430
430
|
// Primary raymarch
|
431
431
|
maxIterationCount: 500,
|
@@ -457,7 +457,7 @@ const Se = [
|
|
457
457
|
minExtinction: 1e-5,
|
458
458
|
minTransmittance: 1e-4
|
459
459
|
}
|
460
|
-
}, c =
|
460
|
+
}, c = dt, pt = {
|
461
461
|
// TODO: We cloud decrease multi-scattering octaves for lower quality presets,
|
462
462
|
// but it leads to a loss of higher frequency scattering, making it darker
|
463
463
|
// overall, which suggests the need for a fudge factor to scale the radiance.
|
@@ -471,7 +471,7 @@ const Se = [
|
|
471
471
|
// Expensive
|
472
472
|
clouds: {
|
473
473
|
...c.clouds,
|
474
|
-
|
474
|
+
accurateSunSkyLight: !1,
|
475
475
|
// Greatly reduces texel reads.
|
476
476
|
maxIterationCount: 200,
|
477
477
|
minStepSize: 100,
|
@@ -508,7 +508,7 @@ const Se = [
|
|
508
508
|
...c.clouds,
|
509
509
|
minDensity: 1e-4,
|
510
510
|
minExtinction: 1e-4,
|
511
|
-
|
511
|
+
accurateSunSkyLight: !1,
|
512
512
|
maxIterationCountToSun: 2,
|
513
513
|
maxIterationCountToGround: 1
|
514
514
|
},
|
@@ -532,7 +532,7 @@ const Se = [
|
|
532
532
|
mapSize: /* @__PURE__ */ new m(1024, 1024)
|
533
533
|
}
|
534
534
|
}
|
535
|
-
},
|
535
|
+
}, ft = `precision highp float;
|
536
536
|
precision highp sampler3D;
|
537
537
|
precision highp sampler2DArray;
|
538
538
|
|
@@ -547,14 +547,28 @@ precision highp sampler2DArray;
|
|
547
547
|
#include "core/cascadedShadowMaps"
|
548
548
|
#include "core/interleavedGradientNoise"
|
549
549
|
#include "core/vogelDisk"
|
550
|
-
|
551
|
-
#include "atmosphere/
|
550
|
+
|
551
|
+
#include "atmosphere/bruneton/definitions"
|
552
|
+
|
553
|
+
uniform AtmosphereParameters ATMOSPHERE;
|
554
|
+
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
|
555
|
+
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
|
556
|
+
|
557
|
+
uniform sampler2D transmittance_texture;
|
558
|
+
uniform sampler3D scattering_texture;
|
559
|
+
uniform sampler2D irradiance_texture;
|
560
|
+
uniform sampler3D single_mie_scattering_texture;
|
561
|
+
uniform sampler3D higher_order_scattering_texture;
|
562
|
+
|
563
|
+
#include "atmosphere/bruneton/common"
|
564
|
+
#include "atmosphere/bruneton/runtime"
|
565
|
+
|
552
566
|
#include "types"
|
553
567
|
#include "parameters"
|
554
568
|
#include "clouds"
|
555
569
|
|
556
570
|
#if !defined(RECIPROCAL_PI4)
|
557
|
-
#define RECIPROCAL_PI4
|
571
|
+
#define RECIPROCAL_PI4 0.07957747154594767
|
558
572
|
#endif // !defined(RECIPROCAL_PI4)
|
559
573
|
|
560
574
|
uniform sampler2D depthBuffer;
|
@@ -570,8 +584,8 @@ uniform float mipLevelScale;
|
|
570
584
|
// Scattering
|
571
585
|
const vec2 scatterAnisotropy = vec2(SCATTER_ANISOTROPY_1, SCATTER_ANISOTROPY_2);
|
572
586
|
const float scatterAnisotropyMix = SCATTER_ANISOTROPY_MIX;
|
573
|
-
uniform float
|
574
|
-
uniform float
|
587
|
+
uniform float skyLightScale;
|
588
|
+
uniform float groundBounceScale;
|
575
589
|
uniform float powderScale;
|
576
590
|
uniform float powderExponent;
|
577
591
|
|
@@ -800,7 +814,7 @@ vec4 getCascadedShadowMaps(vec2 uv) {
|
|
800
814
|
}
|
801
815
|
|
802
816
|
#if !defined(DEBUG_SHOW_SHADOW_MAP_TYPE)
|
803
|
-
#define DEBUG_SHOW_SHADOW_MAP_TYPE
|
817
|
+
#define DEBUG_SHOW_SHADOW_MAP_TYPE 0
|
804
818
|
#endif // !defined(DEBUG_SHOW_SHADOW_MAP_TYPE
|
805
819
|
|
806
820
|
const float frontDepthScale = 1e-5;
|
@@ -949,35 +963,31 @@ vec3 getGroundSunSkyIrradiance(
|
|
949
963
|
const float height,
|
950
964
|
out vec3 skyIrradiance
|
951
965
|
) {
|
952
|
-
#ifdef
|
966
|
+
#ifdef ACCURATE_SUN_SKY_LIGHT
|
953
967
|
return GetSunAndSkyIrradiance(
|
954
968
|
(position - surfaceNormal * height) * METER_TO_LENGTH_UNIT,
|
955
969
|
surfaceNormal,
|
956
970
|
sunDirection,
|
957
971
|
skyIrradiance
|
958
972
|
);
|
959
|
-
#else //
|
973
|
+
#else // ACCURATE_SUN_SKY_LIGHT
|
960
974
|
skyIrradiance = vGroundIrradiance.sky;
|
961
975
|
return vGroundIrradiance.sun;
|
962
|
-
#endif //
|
976
|
+
#endif // ACCURATE_SUN_SKY_LIGHT
|
963
977
|
}
|
964
978
|
|
965
979
|
vec3 getCloudsSunSkyIrradiance(const vec3 position, const float height, out vec3 skyIrradiance) {
|
966
|
-
#ifdef
|
967
|
-
return
|
968
|
-
|
969
|
-
sunDirection,
|
970
|
-
skyIrradiance
|
971
|
-
);
|
972
|
-
#else // ACCURATE_SUN_SKY_IRRADIANCE
|
980
|
+
#ifdef ACCURATE_SUN_SKY_LIGHT
|
981
|
+
return GetSunAndSkyScalarIrradiance(position * METER_TO_LENGTH_UNIT, sunDirection, skyIrradiance);
|
982
|
+
#else // ACCURATE_SUN_SKY_LIGHT
|
973
983
|
float alpha = remapClamped(height, minHeight, maxHeight);
|
974
984
|
skyIrradiance = mix(vCloudsIrradiance.minSky, vCloudsIrradiance.maxSky, alpha);
|
975
985
|
return mix(vCloudsIrradiance.minSun, vCloudsIrradiance.maxSun, alpha);
|
976
|
-
#endif //
|
986
|
+
#endif // ACCURATE_SUN_SKY_LIGHT
|
977
987
|
}
|
978
988
|
|
979
|
-
#ifdef
|
980
|
-
vec3
|
989
|
+
#ifdef GROUND_BOUNCE
|
990
|
+
vec3 approximateRadianceFromGround(
|
981
991
|
const vec3 position,
|
982
992
|
const vec3 surfaceNormal,
|
983
993
|
const float height,
|
@@ -998,7 +1008,7 @@ vec3 approximateIrradianceFromGround(
|
|
998
1008
|
vec3 bouncedRadiance = groundAlbedo * RECIPROCAL_PI * groundIrradiance;
|
999
1009
|
return bouncedRadiance * exp(-opticalDepthToGround);
|
1000
1010
|
}
|
1001
|
-
#endif //
|
1011
|
+
#endif // GROUND_BOUNCE
|
1002
1012
|
|
1003
1013
|
vec4 marchClouds(
|
1004
1014
|
const vec3 rayOrigin,
|
@@ -1088,23 +1098,23 @@ vec4 marchClouds(
|
|
1088
1098
|
|
1089
1099
|
vec3 radiance = sunIrradiance * approximateMultipleScattering(opticalDepth, cosTheta);
|
1090
1100
|
|
1091
|
-
#ifdef
|
1101
|
+
#ifdef GROUND_BOUNCE
|
1092
1102
|
// Fudge factor for the irradiance from ground.
|
1093
1103
|
if (height < shadowTopHeight && mipLevel < 0.5) {
|
1094
|
-
vec3
|
1104
|
+
vec3 groundRadiance = approximateRadianceFromGround(
|
1095
1105
|
position,
|
1096
1106
|
surfaceNormal,
|
1097
1107
|
height,
|
1098
1108
|
mipLevel,
|
1099
1109
|
jitter
|
1100
1110
|
);
|
1101
|
-
radiance +=
|
1111
|
+
radiance += groundRadiance * RECIPROCAL_PI4 * groundBounceScale;
|
1102
1112
|
}
|
1103
|
-
#endif //
|
1113
|
+
#endif // GROUND_BOUNCE
|
1104
1114
|
|
1105
1115
|
// Crude approximation of sky gradient. Better than none in the shadows.
|
1106
1116
|
float skyGradient = dot(weather.heightFraction * 0.5 + 0.5, media.weight);
|
1107
|
-
radiance += skyIrradiance * RECIPROCAL_PI4 * skyGradient *
|
1117
|
+
radiance += skyIrradiance * RECIPROCAL_PI4 * skyGradient * skyLightScale;
|
1108
1118
|
|
1109
1119
|
// Finally multiply by scattering.
|
1110
1120
|
radiance *= media.scattering;
|
@@ -1172,14 +1182,6 @@ float marchShadowLength(
|
|
1172
1182
|
vec3 position = rayDistance * rayDirection + rayOrigin;
|
1173
1183
|
float opticalDepth = sampleShadowOpticalDepth(position, 0.0, 0.0, jitter);
|
1174
1184
|
shadowLength += (1.0 - exp(-opticalDepth)) * stepSize * attenuation;
|
1175
|
-
|
1176
|
-
// Hack to prevent over-integration of shadow length. The shadow should be
|
1177
|
-
// attenuated by the inscatter as the ray travels further.
|
1178
|
-
attenuation *= attenuationFactor;
|
1179
|
-
if (attenuation < 1e-5) {
|
1180
|
-
break;
|
1181
|
-
}
|
1182
|
-
|
1183
1185
|
stepSize *= perspectiveStepScale;
|
1184
1186
|
rayDistance += stepSize;
|
1185
1187
|
}
|
@@ -1230,7 +1232,7 @@ vec4 approximateHaze(
|
|
1230
1232
|
vec3 skyIrradiance = vGroundIrradiance.sky;
|
1231
1233
|
vec3 sunIrradiance = vGroundIrradiance.sun;
|
1232
1234
|
vec3 inscatter = sunIrradiance * phaseFunction(cosTheta) * shadowTransmittance;
|
1233
|
-
inscatter += skyIrradiance * RECIPROCAL_PI4 *
|
1235
|
+
inscatter += skyIrradiance * RECIPROCAL_PI4 * skyLightScale * transmittance;
|
1234
1236
|
inscatter *= hazeScatteringCoefficient / (hazeAbsorptionCoefficient + hazeScatteringCoefficient);
|
1235
1237
|
return vec4(inscatter, transmittance);
|
1236
1238
|
}
|
@@ -1540,7 +1542,7 @@ void main() {
|
|
1540
1542
|
outputShadowLength = shadowLength * METER_TO_LENGTH_UNIT;
|
1541
1543
|
#endif // SHADOW_LENGTH
|
1542
1544
|
}
|
1543
|
-
`,
|
1545
|
+
`, Re = `float getSTBN() {
|
1544
1546
|
ivec3 size = textureSize(stbnTexture, 0);
|
1545
1547
|
vec3 scale = 1.0 / vec3(size);
|
1546
1548
|
return texture(stbnTexture, vec3(gl_FragCoord.xy, float(frame % size.z)) * scale).r;
|
@@ -1730,11 +1732,24 @@ MediaSample sampleMedia(
|
|
1730
1732
|
ivec3 sampleCount;
|
1731
1733
|
return sampleMedia(weather, position, uv, mipLevel, jitter, sampleCount);
|
1732
1734
|
}
|
1733
|
-
`,
|
1735
|
+
`, mt = `precision highp float;
|
1734
1736
|
precision highp sampler3D;
|
1735
1737
|
|
1736
|
-
#include "atmosphere/
|
1737
|
-
|
1738
|
+
#include "atmosphere/bruneton/definitions"
|
1739
|
+
|
1740
|
+
uniform AtmosphereParameters ATMOSPHERE;
|
1741
|
+
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
|
1742
|
+
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
|
1743
|
+
|
1744
|
+
uniform sampler2D transmittance_texture;
|
1745
|
+
uniform sampler3D scattering_texture;
|
1746
|
+
uniform sampler2D irradiance_texture;
|
1747
|
+
uniform sampler3D single_mie_scattering_texture;
|
1748
|
+
uniform sampler3D higher_order_scattering_texture;
|
1749
|
+
|
1750
|
+
#include "atmosphere/bruneton/common"
|
1751
|
+
#include "atmosphere/bruneton/runtime"
|
1752
|
+
|
1738
1753
|
#include "types"
|
1739
1754
|
|
1740
1755
|
uniform mat4 inverseProjectionMatrix;
|
@@ -1764,7 +1779,7 @@ out GroundIrradiance vGroundIrradiance;
|
|
1764
1779
|
out CloudsIrradiance vCloudsIrradiance;
|
1765
1780
|
|
1766
1781
|
void sampleSunSkyIrradiance(const vec3 positionECEF) {
|
1767
|
-
vGroundIrradiance.sun =
|
1782
|
+
vGroundIrradiance.sun = GetSunAndSkyScalarIrradiance(
|
1768
1783
|
positionECEF * METER_TO_LENGTH_UNIT,
|
1769
1784
|
sunDirection,
|
1770
1785
|
vGroundIrradiance.sky
|
@@ -1772,12 +1787,12 @@ void sampleSunSkyIrradiance(const vec3 positionECEF) {
|
|
1772
1787
|
|
1773
1788
|
vec3 surfaceNormal = normalize(positionECEF);
|
1774
1789
|
vec2 radii = (bottomRadius + vec2(minHeight, maxHeight)) * METER_TO_LENGTH_UNIT;
|
1775
|
-
vCloudsIrradiance.minSun =
|
1790
|
+
vCloudsIrradiance.minSun = GetSunAndSkyScalarIrradiance(
|
1776
1791
|
surfaceNormal * radii.x,
|
1777
1792
|
sunDirection,
|
1778
1793
|
vCloudsIrradiance.minSky
|
1779
1794
|
);
|
1780
|
-
vCloudsIrradiance.maxSun =
|
1795
|
+
vCloudsIrradiance.maxSun = GetSunAndSkyScalarIrradiance(
|
1781
1796
|
surfaceNormal * radii.y,
|
1782
1797
|
sunDirection,
|
1783
1798
|
vCloudsIrradiance.maxSky
|
@@ -1799,7 +1814,7 @@ void main() {
|
|
1799
1814
|
|
1800
1815
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
1801
1816
|
}
|
1802
|
-
`,
|
1817
|
+
`, Le = `uniform vec2 resolution;
|
1803
1818
|
uniform int frame;
|
1804
1819
|
uniform sampler3D stbnTexture;
|
1805
1820
|
|
@@ -1863,7 +1878,7 @@ uniform float maxHeight;
|
|
1863
1878
|
uniform float shadowTopHeight;
|
1864
1879
|
uniform float shadowBottomHeight;
|
1865
1880
|
uniform vec4 shadowLayerMask;
|
1866
|
-
uniform
|
1881
|
+
uniform CloudDensityProfile densityProfile;
|
1867
1882
|
`, $ = `struct GroundIrradiance {
|
1868
1883
|
vec3 sun;
|
1869
1884
|
vec3 sky;
|
@@ -1876,55 +1891,61 @@ struct CloudsIrradiance {
|
|
1876
1891
|
vec3 maxSky;
|
1877
1892
|
};
|
1878
1893
|
|
1879
|
-
struct
|
1894
|
+
struct CloudDensityProfile {
|
1880
1895
|
vec4 expTerms;
|
1881
1896
|
vec4 exponents;
|
1882
1897
|
vec4 linearTerms;
|
1883
1898
|
vec4 constantTerms;
|
1884
1899
|
};
|
1885
1900
|
`;
|
1886
|
-
var
|
1901
|
+
var vt = Object.defineProperty, w = (o, e, t, n) => {
|
1887
1902
|
for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
|
1888
1903
|
(s = o[i]) && (a = s(e, t, a) || a);
|
1889
|
-
return a &&
|
1904
|
+
return a && vt(e, t, a), a;
|
1890
1905
|
};
|
1891
|
-
const
|
1892
|
-
class y extends
|
1906
|
+
const gt = /* @__PURE__ */ new f(), St = /* @__PURE__ */ new qe();
|
1907
|
+
class y extends Ye {
|
1893
1908
|
constructor({
|
1894
1909
|
parameterUniforms: e,
|
1895
1910
|
layerUniforms: t,
|
1896
1911
|
atmosphereUniforms: n
|
1897
|
-
}, a =
|
1912
|
+
}, a = Te.DEFAULT) {
|
1898
1913
|
super(
|
1899
1914
|
{
|
1900
1915
|
name: "CloudsMaterial",
|
1901
1916
|
glslVersion: W,
|
1902
|
-
vertexShader:
|
1917
|
+
vertexShader: U(mt, {
|
1903
1918
|
atmosphere: {
|
1904
|
-
|
1905
|
-
|
1919
|
+
bruneton: {
|
1920
|
+
common: fe,
|
1921
|
+
definitions: pe,
|
1922
|
+
runtime: de
|
1923
|
+
}
|
1906
1924
|
},
|
1907
1925
|
types: $
|
1908
1926
|
}),
|
1909
|
-
fragmentShader:
|
1910
|
-
|
1927
|
+
fragmentShader: B(
|
1928
|
+
U(ft, {
|
1911
1929
|
core: {
|
1912
|
-
depth:
|
1913
|
-
math:
|
1914
|
-
turbo:
|
1915
|
-
generators:
|
1916
|
-
raySphereIntersection:
|
1917
|
-
cascadedShadowMaps:
|
1918
|
-
interleavedGradientNoise:
|
1919
|
-
vogelDisk:
|
1930
|
+
depth: et,
|
1931
|
+
math: Oe,
|
1932
|
+
turbo: _e,
|
1933
|
+
generators: Qe,
|
1934
|
+
raySphereIntersection: Ae,
|
1935
|
+
cascadedShadowMaps: Je,
|
1936
|
+
interleavedGradientNoise: Xe,
|
1937
|
+
vogelDisk: $e
|
1920
1938
|
},
|
1921
1939
|
atmosphere: {
|
1922
|
-
|
1923
|
-
|
1940
|
+
bruneton: {
|
1941
|
+
common: fe,
|
1942
|
+
definitions: pe,
|
1943
|
+
runtime: de
|
1944
|
+
}
|
1924
1945
|
},
|
1925
1946
|
types: $,
|
1926
|
-
parameters:
|
1927
|
-
clouds:
|
1947
|
+
parameters: Le,
|
1948
|
+
clouds: Re
|
1928
1949
|
})
|
1929
1950
|
),
|
1930
1951
|
// prettier-ignore
|
@@ -1947,8 +1968,8 @@ class y extends je {
|
|
1947
1968
|
mipLevelScale: new r(1),
|
1948
1969
|
stbnTexture: new r(null),
|
1949
1970
|
// Scattering
|
1950
|
-
|
1951
|
-
|
1971
|
+
skyLightScale: new r(1),
|
1972
|
+
groundBounceScale: new r(1),
|
1952
1973
|
powderScale: new r(0.8),
|
1953
1974
|
powderExponent: new r(150),
|
1954
1975
|
// Primary raymarch
|
@@ -1992,15 +2013,15 @@ class y extends je {
|
|
1992
2013
|
}
|
1993
2014
|
},
|
1994
2015
|
a
|
1995
|
-
), this.temporalUpscale = !0, this.depthPacking = 0, this.localWeatherChannels = "rgba", this.shapeDetail = c.shapeDetail, this.turbulence = c.turbulence, this.shadowLength = c.lightShafts, this.haze = c.haze, this.multiScatteringOctaves = c.clouds.multiScatteringOctaves, this.
|
2016
|
+
), this.temporalUpscale = !0, this.depthPacking = 0, this.localWeatherChannels = "rgba", this.shapeDetail = c.shapeDetail, this.turbulence = c.turbulence, this.shadowLength = c.lightShafts, this.haze = c.haze, this.multiScatteringOctaves = c.clouds.multiScatteringOctaves, this.accurateSunSkyLight = c.clouds.accurateSunSkyLight, this.accuratePhaseFunction = c.clouds.accuratePhaseFunction, this.shadowCascadeCount = c.shadow.cascadeCount, this.shadowSampleCount = 8, this.scatterAnisotropy1 = 0.7, this.scatterAnisotropy2 = -0.2, this.scatterAnisotropyMix = 0.5;
|
1996
2017
|
}
|
1997
2018
|
onBeforeRender(e, t, n, a, i, s) {
|
1998
|
-
const l = this.defines.USE_LOGDEPTHBUF != null,
|
1999
|
-
|
2000
|
-
const
|
2001
|
-
d !==
|
2002
|
-
const p = this.defines.
|
2003
|
-
(this.uniforms.
|
2019
|
+
const l = this.defines.USE_LOGDEPTHBUF != null, u = e.capabilities.logarithmicDepthBuffer;
|
2020
|
+
u !== l && (u ? this.defines.USE_LOGDEPTHBUF = "1" : delete this.defines.USE_LOGDEPTHBUF);
|
2021
|
+
const h = this.defines.POWDER != null, d = this.uniforms.powderScale.value > 0;
|
2022
|
+
d !== h && (d ? this.defines.POWDER = "1" : delete this.defines.POWDER, this.needsUpdate = !0);
|
2023
|
+
const p = this.defines.GROUND_BOUNCE != null;
|
2024
|
+
(this.uniforms.groundBounceScale.value > 0 && this.uniforms.maxIterationCountToGround.value > 0) !== p && (d ? this.defines.GROUND_BOUNCE = "1" : delete this.defines.GROUND_BOUNCE, this.needsUpdate = !0);
|
2004
2025
|
}
|
2005
2026
|
copyCameraSettings(e) {
|
2006
2027
|
e.isPerspectiveCamera === !0 ? this.defines.PERSPECTIVE_CAMERA !== "1" && (this.defines.PERSPECTIVE_CAMERA = "1", this.needsUpdate = !0) : this.defines.PERSPECTIVE_CAMERA != null && (delete this.defines.PERSPECTIVE_CAMERA, this.needsUpdate = !0);
|
@@ -2008,16 +2029,16 @@ class y extends je {
|
|
2008
2029
|
t.viewMatrix.value.copy(e.matrixWorldInverse), t.inverseViewMatrix.value.copy(e.matrixWorld);
|
2009
2030
|
const n = this.previousProjectionMatrix ?? e.projectionMatrix, a = this.previousViewMatrix ?? e.matrixWorldInverse, i = t.inverseProjectionMatrix.value, s = t.reprojectionMatrix.value;
|
2010
2031
|
if (this.temporalUpscale) {
|
2011
|
-
const
|
2032
|
+
const h = t.frame.value % 16, d = t.resolution.value, p = Pe[h], g = (p.x - 0.5) / d.x * 4, S = (p.y - 0.5) / d.y * 4;
|
2012
2033
|
t.temporalJitter.value.set(g, S), t.mipLevelScale.value = 0.25, i.copy(e.projectionMatrix), i.elements[8] += g * 2, i.elements[9] += S * 2, i.invert(), s.copy(n), s.elements[8] += g * 2, s.elements[9] += S * 2, s.multiply(a);
|
2013
2034
|
} else
|
2014
2035
|
t.temporalJitter.value.setScalar(0), t.mipLevelScale.value = 1, i.copy(e.projectionMatrixInverse), s.copy(n).multiply(a);
|
2015
|
-
|
2036
|
+
Ke(e), t.cameraNear.value = e.near, t.cameraFar.value = e.far;
|
2016
2037
|
const l = e.getWorldPosition(
|
2017
2038
|
t.cameraPosition.value
|
2018
|
-
),
|
2039
|
+
), u = gt.copy(l).applyMatrix4(t.inverseEllipsoidMatrix.value).sub(t.ellipsoidCenter.value);
|
2019
2040
|
try {
|
2020
|
-
t.cameraHeight.value =
|
2041
|
+
t.cameraHeight.value = St.setFromECEF(u).height;
|
2021
2042
|
} catch {
|
2022
2043
|
}
|
2023
2044
|
}
|
@@ -2041,12 +2062,20 @@ class y extends je {
|
|
2041
2062
|
set depthBuffer(e) {
|
2042
2063
|
this.uniforms.depthBuffer.value = e;
|
2043
2064
|
}
|
2065
|
+
/** @deprecated Use accurateSunSkyLight instead. */
|
2066
|
+
get accurateSunSkyIrradiance() {
|
2067
|
+
return this.accurateSunSkyLight;
|
2068
|
+
}
|
2069
|
+
/** @deprecated Use accurateSunSkyLight instead. */
|
2070
|
+
set accurateSunSkyIrradiance(e) {
|
2071
|
+
this.accurateSunSkyLight = e;
|
2072
|
+
}
|
2044
2073
|
}
|
2045
2074
|
w([
|
2046
|
-
|
2075
|
+
P("DEPTH_PACKING")
|
2047
2076
|
], y.prototype, "depthPacking");
|
2048
2077
|
w([
|
2049
|
-
|
2078
|
+
Ee("LOCAL_WEATHER_CHANNELS", {
|
2050
2079
|
validate: (o) => /^[rgba]{4}$/.test(o)
|
2051
2080
|
})
|
2052
2081
|
], y.prototype, "localWeatherChannels");
|
@@ -2063,19 +2092,19 @@ w([
|
|
2063
2092
|
C("HAZE")
|
2064
2093
|
], y.prototype, "haze");
|
2065
2094
|
w([
|
2066
|
-
|
2095
|
+
P("MULTI_SCATTERING_OCTAVES", { min: 1, max: 12 })
|
2067
2096
|
], y.prototype, "multiScatteringOctaves");
|
2068
2097
|
w([
|
2069
|
-
C("
|
2070
|
-
], y.prototype, "
|
2098
|
+
C("ACCURATE_SUN_SKY_LIGHT")
|
2099
|
+
], y.prototype, "accurateSunSkyLight");
|
2071
2100
|
w([
|
2072
2101
|
C("ACCURATE_PHASE_FUNCTION")
|
2073
2102
|
], y.prototype, "accuratePhaseFunction");
|
2074
2103
|
w([
|
2075
|
-
|
2104
|
+
P("SHADOW_CASCADE_COUNT", { min: 1, max: 4 })
|
2076
2105
|
], y.prototype, "shadowCascadeCount");
|
2077
2106
|
w([
|
2078
|
-
|
2107
|
+
P("SHADOW_SAMPLE_COUNT", { min: 1, max: 16 })
|
2079
2108
|
], y.prototype, "shadowSampleCount");
|
2080
2109
|
w([
|
2081
2110
|
J("SCATTER_ANISOTROPY_1")
|
@@ -2086,7 +2115,7 @@ w([
|
|
2086
2115
|
w([
|
2087
2116
|
J("SCATTER_ANISOTROPY_MIX")
|
2088
2117
|
], y.prototype, "scatterAnisotropyMix");
|
2089
|
-
const
|
2118
|
+
const yt = `// Taken from https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1
|
2090
2119
|
// TODO: Use 5-taps version: https://www.shadertoy.com/view/MtVGWz
|
2091
2120
|
// Or even 4 taps (requires preprocessing in the input buffer):
|
2092
2121
|
// https://www.shadertoy.com/view/4tyGDD
|
@@ -2199,7 +2228,7 @@ vec4 textureCatmullRom(sampler2DArray tex, vec3 uv) {
|
|
2199
2228
|
result += texture(tex, vec3(texPos3.x, texPos3.y, uv.z)) * w3.x * w3.y;
|
2200
2229
|
return result;
|
2201
2230
|
}
|
2202
|
-
`,
|
2231
|
+
`, xt = `precision highp float;
|
2203
2232
|
precision highp sampler2DArray;
|
2204
2233
|
|
2205
2234
|
#include "core/turbo"
|
@@ -2401,7 +2430,7 @@ void main() {
|
|
2401
2430
|
outputColor = vec4(turbo(outputShadowLength * 0.05), 1.0);
|
2402
2431
|
#endif // defined(SHADOW_LENGTH) && defined(DEBUG_SHOW_SHADOW_LENGTH)
|
2403
2432
|
}
|
2404
|
-
`,
|
2433
|
+
`, wt = `precision highp float;
|
2405
2434
|
|
2406
2435
|
layout(location = 0) in vec3 position;
|
2407
2436
|
|
@@ -2411,8 +2440,8 @@ void main() {
|
|
2411
2440
|
vUv = position.xy * 0.5 + 0.5;
|
2412
2441
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
2413
2442
|
}
|
2414
|
-
`,
|
2415
|
-
#define VARIANCE_OFFSET_COUNT
|
2443
|
+
`, Ie = `#ifdef VARIANCE_9_SAMPLES
|
2444
|
+
#define VARIANCE_OFFSET_COUNT 8
|
2416
2445
|
const ivec2 varianceOffsets[8] = ivec2[8](
|
2417
2446
|
ivec2(-1, -1),
|
2418
2447
|
ivec2(-1, 1),
|
@@ -2424,7 +2453,7 @@ const ivec2 varianceOffsets[8] = ivec2[8](
|
|
2424
2453
|
ivec2(-1, 0)
|
2425
2454
|
);
|
2426
2455
|
#else // VARIANCE_9_SAMPLES
|
2427
|
-
#define VARIANCE_OFFSET_COUNT
|
2456
|
+
#define VARIANCE_OFFSET_COUNT 4
|
2428
2457
|
const ivec2 varianceOffsets[4] = ivec2[4](ivec2(1, 0), ivec2(0, -1), ivec2(0, 1), ivec2(-1, 0));
|
2429
2458
|
#endif // VARIANCE_9_SAMPLES
|
2430
2459
|
|
@@ -2526,10 +2555,10 @@ vec4 varianceClipping(
|
|
2526
2555
|
return varianceClipping(inputBuffer, coord, current, history, 1.0);
|
2527
2556
|
}
|
2528
2557
|
`;
|
2529
|
-
var
|
2558
|
+
var Ct = Object.defineProperty, Ne = (o, e, t, n) => {
|
2530
2559
|
for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
|
2531
2560
|
(s = o[i]) && (a = s(e, t, a) || a);
|
2532
|
-
return a &&
|
2561
|
+
return a && Ct(e, t, a), a;
|
2533
2562
|
};
|
2534
2563
|
class Q extends X {
|
2535
2564
|
constructor({
|
@@ -2542,12 +2571,12 @@ class Q extends X {
|
|
2542
2571
|
super({
|
2543
2572
|
name: "CloudsResolveMaterial",
|
2544
2573
|
glslVersion: W,
|
2545
|
-
vertexShader:
|
2546
|
-
fragmentShader:
|
2547
|
-
|
2548
|
-
core: { turbo:
|
2549
|
-
catmullRomSampling:
|
2550
|
-
varianceClipping:
|
2574
|
+
vertexShader: wt,
|
2575
|
+
fragmentShader: B(
|
2576
|
+
U(xt, {
|
2577
|
+
core: { turbo: _e },
|
2578
|
+
catmullRomSampling: yt,
|
2579
|
+
varianceClipping: Ie
|
2551
2580
|
})
|
2552
2581
|
),
|
2553
2582
|
uniforms: {
|
@@ -2568,19 +2597,19 @@ class Q extends X {
|
|
2568
2597
|
this.uniforms.texelSize.value.set(1 / e, 1 / t);
|
2569
2598
|
}
|
2570
2599
|
onBeforeRender(e, t, n, a, i, s) {
|
2571
|
-
const
|
2600
|
+
const u = this.uniforms.frame.value % 16, h = Pe[u], d = (h.x - 0.5) * 4, p = (h.y - 0.5) * 4;
|
2572
2601
|
this.uniforms.jitterOffset.value.set(d, p);
|
2573
2602
|
}
|
2574
2603
|
}
|
2575
|
-
|
2604
|
+
Ne([
|
2576
2605
|
C("TEMPORAL_UPSCALE")
|
2577
2606
|
], Q.prototype, "temporalUpscale");
|
2578
|
-
|
2607
|
+
Ne([
|
2579
2608
|
C("SHADOW_LENGTH")
|
2580
2609
|
], Q.prototype, "shadowLength");
|
2581
|
-
class
|
2610
|
+
class Me extends ze {
|
2582
2611
|
constructor(e, t) {
|
2583
|
-
super(e), this._mainCamera = new
|
2612
|
+
super(e), this._mainCamera = new we();
|
2584
2613
|
const { shadow: n } = t;
|
2585
2614
|
this.shadow = n;
|
2586
2615
|
}
|
@@ -2594,19 +2623,18 @@ class Ne extends He {
|
|
2594
2623
|
function k(o, { depthVelocity: e, shadowLength: t }) {
|
2595
2624
|
const n = new Ge(1, 1, {
|
2596
2625
|
depthBuffer: !1,
|
2597
|
-
|
2598
|
-
type: we
|
2626
|
+
type: Ce
|
2599
2627
|
});
|
2600
|
-
n.texture.minFilter =
|
2628
|
+
n.texture.minFilter = F, n.texture.magFilter = F, n.texture.name = o;
|
2601
2629
|
let a;
|
2602
2630
|
e && (a = n.texture.clone(), a.isRenderTargetTexture = !0, n.depthVelocity = a, n.textures.push(a));
|
2603
2631
|
let i;
|
2604
|
-
return t && (i = n.texture.clone(), i.isRenderTargetTexture = !0, i.format =
|
2632
|
+
return t && (i = n.texture.clone(), i.isRenderTargetTexture = !0, i.format = Ve, n.shadowLength = i, n.textures.push(i)), Object.assign(n, {
|
2605
2633
|
depthVelocity: a ?? null,
|
2606
2634
|
shadowLength: i ?? null
|
2607
2635
|
});
|
2608
2636
|
}
|
2609
|
-
class
|
2637
|
+
class Tt extends Me {
|
2610
2638
|
constructor({
|
2611
2639
|
parameterUniforms: e,
|
2612
2640
|
layerUniforms: t,
|
@@ -2632,8 +2660,8 @@ class Ct extends Ne {
|
|
2632
2660
|
this.currentPass.initialize(e, t, n), this.resolvePass.initialize(e, t, n);
|
2633
2661
|
}
|
2634
2662
|
initRenderTargets(e) {
|
2635
|
-
var s, l,
|
2636
|
-
(s = this.currentRenderTarget) == null || s.dispose(), (l = this.resolveRenderTarget) == null || l.dispose(), (
|
2663
|
+
var s, l, u;
|
2664
|
+
(s = this.currentRenderTarget) == null || s.dispose(), (l = this.resolveRenderTarget) == null || l.dispose(), (u = this.historyRenderTarget) == null || u.dispose();
|
2637
2665
|
const t = k("Clouds", e), n = k("Clouds.A", {
|
2638
2666
|
...e,
|
2639
2667
|
depthVelocity: !1
|
@@ -2712,28 +2740,28 @@ class Ct extends Ne {
|
|
2712
2740
|
}), this.setSize(this.width, this.height));
|
2713
2741
|
}
|
2714
2742
|
}
|
2715
|
-
function
|
2716
|
-
const
|
2717
|
-
A(
|
2718
|
-
const
|
2719
|
-
if (
|
2720
|
-
for (let
|
2721
|
-
|
2722
|
-
|
2723
|
-
|
2724
|
-
|
2743
|
+
function Dt(o, e) {
|
2744
|
+
const n = o.properties.get(e.texture).__webglTexture, a = o.getContext();
|
2745
|
+
A(a instanceof WebGL2RenderingContext), o.setRenderTarget(e);
|
2746
|
+
const i = [];
|
2747
|
+
if (n != null)
|
2748
|
+
for (let s = 0; s < e.depth; ++s)
|
2749
|
+
a.framebufferTextureLayer(
|
2750
|
+
a.FRAMEBUFFER,
|
2751
|
+
a.COLOR_ATTACHMENT0 + s,
|
2752
|
+
n,
|
2725
2753
|
0,
|
2726
|
-
|
2727
|
-
),
|
2728
|
-
|
2754
|
+
s
|
2755
|
+
), i.push(a.COLOR_ATTACHMENT0 + s);
|
2756
|
+
a.drawBuffers(i);
|
2729
2757
|
}
|
2730
|
-
class
|
2758
|
+
class xe extends Z {
|
2731
2759
|
render(e, t, n, a, i) {
|
2732
2760
|
const s = this.fullscreenMaterial.uniforms;
|
2733
|
-
t !== null && (s == null ? void 0 : s[this.input]) != null && (s[this.input].value = t.texture),
|
2761
|
+
t !== null && (s == null ? void 0 : s[this.input]) != null && (s[this.input].value = t.texture), Dt(e, n), e.render(this.scene, this.camera);
|
2734
2762
|
}
|
2735
2763
|
}
|
2736
|
-
const
|
2764
|
+
const Et = `precision highp float;
|
2737
2765
|
precision highp sampler3D;
|
2738
2766
|
|
2739
2767
|
#include <common>
|
@@ -2930,7 +2958,7 @@ void main() {
|
|
2930
2958
|
}
|
2931
2959
|
#pragma unroll_loop_end
|
2932
2960
|
}
|
2933
|
-
`,
|
2961
|
+
`, At = `precision highp float;
|
2934
2962
|
|
2935
2963
|
uniform vec3 ellipsoidCenter;
|
2936
2964
|
uniform vec3 altitudeCorrection;
|
@@ -2946,7 +2974,7 @@ void main() {
|
|
2946
2974
|
|
2947
2975
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
2948
2976
|
}
|
2949
|
-
`,
|
2977
|
+
`, _t = `// Implements Structured Volume Sampling in fragment shader:
|
2950
2978
|
// https://github.com/huwb/volsample
|
2951
2979
|
// Implementation reference:
|
2952
2980
|
// https://www.shadertoy.com/view/ttVfDc
|
@@ -3048,10 +3076,10 @@ void intersectStructuredPlanes(
|
|
3048
3076
|
}
|
3049
3077
|
}
|
3050
3078
|
`;
|
3051
|
-
var
|
3079
|
+
var Ot = Object.defineProperty, R = (o, e, t, n) => {
|
3052
3080
|
for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
|
3053
3081
|
(s = o[i]) && (a = s(e, t, a) || a);
|
3054
|
-
return a &&
|
3082
|
+
return a && Ot(e, t, a), a;
|
3055
3083
|
};
|
3056
3084
|
class _ extends X {
|
3057
3085
|
constructor({
|
@@ -3062,17 +3090,17 @@ class _ extends X {
|
|
3062
3090
|
super({
|
3063
3091
|
name: "ShadowMaterial",
|
3064
3092
|
glslVersion: W,
|
3065
|
-
vertexShader:
|
3066
|
-
fragmentShader:
|
3067
|
-
|
3093
|
+
vertexShader: At,
|
3094
|
+
fragmentShader: B(
|
3095
|
+
U(Et, {
|
3068
3096
|
core: {
|
3069
|
-
math:
|
3070
|
-
raySphereIntersection:
|
3097
|
+
math: Oe,
|
3098
|
+
raySphereIntersection: Ae
|
3071
3099
|
},
|
3072
3100
|
types: $,
|
3073
|
-
parameters:
|
3074
|
-
structuredSampling:
|
3075
|
-
clouds:
|
3101
|
+
parameters: Le,
|
3102
|
+
structuredSampling: _t,
|
3103
|
+
clouds: Re
|
3076
3104
|
})
|
3077
3105
|
),
|
3078
3106
|
uniforms: {
|
@@ -3111,12 +3139,12 @@ class _ extends X {
|
|
3111
3139
|
}
|
3112
3140
|
}
|
3113
3141
|
R([
|
3114
|
-
|
3142
|
+
Ee("LOCAL_WEATHER_CHANNELS", {
|
3115
3143
|
validate: (o) => /^[rgba]{4}$/.test(o)
|
3116
3144
|
})
|
3117
3145
|
], _.prototype, "localWeatherChannels");
|
3118
3146
|
R([
|
3119
|
-
|
3147
|
+
P("CASCADE_COUNT", { min: 1, max: 4 })
|
3120
3148
|
], _.prototype, "cascadeCount");
|
3121
3149
|
R([
|
3122
3150
|
C("TEMPORAL_PASS")
|
@@ -3133,8 +3161,8 @@ R([
|
|
3133
3161
|
const Pt = `precision highp float;
|
3134
3162
|
precision highp sampler2DArray;
|
3135
3163
|
|
3136
|
-
#define VARIANCE_9_SAMPLES
|
3137
|
-
#define VARIANCE_SAMPLER_ARRAY
|
3164
|
+
#define VARIANCE_9_SAMPLES 1
|
3165
|
+
#define VARIANCE_SAMPLER_ARRAY 1
|
3138
3166
|
|
3139
3167
|
#include "varianceClipping"
|
3140
3168
|
|
@@ -3206,7 +3234,7 @@ void main() {
|
|
3206
3234
|
}
|
3207
3235
|
#pragma unroll_loop_end
|
3208
3236
|
}
|
3209
|
-
`,
|
3237
|
+
`, Rt = `precision highp float;
|
3210
3238
|
|
3211
3239
|
layout(location = 0) in vec3 position;
|
3212
3240
|
|
@@ -3217,12 +3245,12 @@ void main() {
|
|
3217
3245
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
3218
3246
|
}
|
3219
3247
|
`;
|
3220
|
-
var
|
3248
|
+
var Lt = Object.defineProperty, It = (o, e, t, n) => {
|
3221
3249
|
for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
|
3222
3250
|
(s = o[i]) && (a = s(e, t, a) || a);
|
3223
|
-
return a &&
|
3251
|
+
return a && Lt(e, t, a), a;
|
3224
3252
|
};
|
3225
|
-
class
|
3253
|
+
class Ue extends X {
|
3226
3254
|
constructor({
|
3227
3255
|
inputBuffer: e = null,
|
3228
3256
|
historyBuffer: t = null
|
@@ -3230,10 +3258,10 @@ class be extends X {
|
|
3230
3258
|
super({
|
3231
3259
|
name: "ShadowResolveMaterial",
|
3232
3260
|
glslVersion: W,
|
3233
|
-
vertexShader:
|
3234
|
-
fragmentShader:
|
3235
|
-
|
3236
|
-
varianceClipping:
|
3261
|
+
vertexShader: Rt,
|
3262
|
+
fragmentShader: B(
|
3263
|
+
U(Pt, {
|
3264
|
+
varianceClipping: Ie
|
3237
3265
|
})
|
3238
3266
|
),
|
3239
3267
|
uniforms: {
|
@@ -3254,17 +3282,16 @@ class be extends X {
|
|
3254
3282
|
this.uniforms.texelSize.value.set(1 / e, 1 / t);
|
3255
3283
|
}
|
3256
3284
|
}
|
3257
|
-
|
3258
|
-
|
3259
|
-
],
|
3285
|
+
It([
|
3286
|
+
P("CASCADE_COUNT", { min: 1, max: 4 })
|
3287
|
+
], Ue.prototype, "cascadeCount");
|
3260
3288
|
function j(o) {
|
3261
|
-
const e = new
|
3262
|
-
depthBuffer: !1
|
3263
|
-
stencilBuffer: !1
|
3289
|
+
const e = new ke(1, 1, 1, {
|
3290
|
+
depthBuffer: !1
|
3264
3291
|
});
|
3265
|
-
return e.texture.type =
|
3292
|
+
return e.texture.type = Ce, e.texture.minFilter = F, e.texture.magFilter = F, e.texture.name = o, e;
|
3266
3293
|
}
|
3267
|
-
class
|
3294
|
+
class Nt extends Me {
|
3268
3295
|
constructor({
|
3269
3296
|
parameterUniforms: e,
|
3270
3297
|
layerUniforms: t,
|
@@ -3275,7 +3302,7 @@ class It extends Ne {
|
|
3275
3302
|
parameterUniforms: e,
|
3276
3303
|
layerUniforms: t,
|
3277
3304
|
atmosphereUniforms: n
|
3278
|
-
}), this.currentPass = new
|
3305
|
+
}), this.currentPass = new xe(this.currentMaterial), this.resolveMaterial = new Ue(), this.resolvePass = new xe(this.resolveMaterial), this.initRenderTargets();
|
3279
3306
|
}
|
3280
3307
|
initialize(e, t, n) {
|
3281
3308
|
this.currentPass.initialize(e, t, n), this.resolvePass.initialize(e, t, n);
|
@@ -3329,7 +3356,7 @@ class It extends Ne {
|
|
3329
3356
|
e !== this.temporalPass && (this.currentMaterial.temporalPass = e, this.initRenderTargets(), this.setSize(this.width, this.height));
|
3330
3357
|
}
|
3331
3358
|
}
|
3332
|
-
function
|
3359
|
+
function Mt(o) {
|
3333
3360
|
return {
|
3334
3361
|
// Participating medium
|
3335
3362
|
scatteringCoefficient: new r(1),
|
@@ -3350,7 +3377,7 @@ function Nt(o) {
|
|
3350
3377
|
turbulenceDisplacement: new r(350)
|
3351
3378
|
};
|
3352
3379
|
}
|
3353
|
-
function
|
3380
|
+
function Ut() {
|
3354
3381
|
return {
|
3355
3382
|
minLayerHeights: new r(new x()),
|
3356
3383
|
maxLayerHeights: new r(new x()),
|
@@ -3376,7 +3403,7 @@ function bt() {
|
|
3376
3403
|
};
|
3377
3404
|
}
|
3378
3405
|
const Y = [0, 0, 0, 0];
|
3379
|
-
function
|
3406
|
+
function bt(o, e) {
|
3380
3407
|
e.packValues("altitude", o.minLayerHeights.value), e.packSums("altitude", "height", o.maxLayerHeights.value), e.packIntervalHeights(
|
3381
3408
|
o.minIntervalHeights.value,
|
3382
3409
|
o.maxIntervalHeights.value
|
@@ -3386,12 +3413,12 @@ function Mt(o, e) {
|
|
3386
3413
|
let n = 1 / 0, a = 0, i = 1 / 0, s = 0;
|
3387
3414
|
Y.fill(0);
|
3388
3415
|
for (let l = 0; l < e.length; ++l) {
|
3389
|
-
const { altitude:
|
3390
|
-
|
3416
|
+
const { altitude: u, height: h, shadow: d } = e[l], p = u + h;
|
3417
|
+
h > 0 && (u < n && (n = u), d && u < i && (i = u), p > a && (a = p), d && p > s && (s = p)), Y[l] = d ? 1 : 0;
|
3391
3418
|
}
|
3392
3419
|
n !== 1 / 0 ? (o.minHeight.value = n, o.maxHeight.value = a) : (A(a === 0), o.minHeight.value = 0), i !== 1 / 0 ? (o.shadowBottomHeight.value = i, o.shadowTopHeight.value = s) : (A(s === 0), o.shadowBottomHeight.value = 0), o.shadowLayerMask.value.fromArray(Y);
|
3393
3420
|
}
|
3394
|
-
function
|
3421
|
+
function Ht(o, e) {
|
3395
3422
|
return {
|
3396
3423
|
bottomRadius: new r(o.bottomRadius),
|
3397
3424
|
topRadius: new r(o.topRadius),
|
@@ -3402,7 +3429,7 @@ function Ut(o, e) {
|
|
3402
3429
|
sunDirection: new r(e.sunDirection)
|
3403
3430
|
};
|
3404
3431
|
}
|
3405
|
-
const
|
3432
|
+
const zt = `uniform sampler2D cloudsBuffer;
|
3406
3433
|
|
3407
3434
|
void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
|
3408
3435
|
#ifdef SKIP_RENDERING
|
@@ -3414,12 +3441,12 @@ void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
|
|
3414
3441
|
#endif // SKIP_RENDERING
|
3415
3442
|
}
|
3416
3443
|
`;
|
3417
|
-
var Ft = Object.defineProperty,
|
3444
|
+
var Ft = Object.defineProperty, Wt = (o, e, t, n) => {
|
3418
3445
|
for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
|
3419
3446
|
(s = o[i]) && (a = s(e, t, a) || a);
|
3420
3447
|
return a && Ft(e, t, a), a;
|
3421
3448
|
};
|
3422
|
-
const I = /* @__PURE__ */ new f(),
|
3449
|
+
const I = /* @__PURE__ */ new f(), Bt = /* @__PURE__ */ new m(), Gt = [
|
3423
3450
|
"maxIterationCount",
|
3424
3451
|
"minStepSize",
|
3425
3452
|
"maxStepSize",
|
@@ -3440,11 +3467,11 @@ const I = /* @__PURE__ */ new f(), Wt = /* @__PURE__ */ new m(), Gt = [
|
|
3440
3467
|
"hazeExponent",
|
3441
3468
|
"hazeScatteringCoefficient",
|
3442
3469
|
"hazeAbsorptionCoefficient"
|
3443
|
-
],
|
3470
|
+
], Vt = [
|
3444
3471
|
"multiScatteringOctaves",
|
3445
|
-
"
|
3472
|
+
"accurateSunSkyLight",
|
3446
3473
|
"accuratePhaseFunction"
|
3447
|
-
],
|
3474
|
+
], kt = [
|
3448
3475
|
"maxIterationCount",
|
3449
3476
|
"minStepSize",
|
3450
3477
|
"maxStepSize",
|
@@ -3452,11 +3479,11 @@ const I = /* @__PURE__ */ new f(), Wt = /* @__PURE__ */ new m(), Gt = [
|
|
3452
3479
|
"minExtinction",
|
3453
3480
|
"minTransmittance",
|
3454
3481
|
"opticalDepthTailScale"
|
3455
|
-
], kt = [
|
3456
|
-
"temporalJitter"
|
3457
3482
|
], jt = [
|
3458
|
-
"
|
3483
|
+
"temporalJitter"
|
3459
3484
|
], Yt = [
|
3485
|
+
"temporalPass"
|
3486
|
+
], Zt = [
|
3460
3487
|
"cascadeCount",
|
3461
3488
|
"mapSize",
|
3462
3489
|
"maxFar",
|
@@ -3465,18 +3492,18 @@ const I = /* @__PURE__ */ new f(), Wt = /* @__PURE__ */ new m(), Gt = [
|
|
3465
3492
|
"splitLambda"
|
3466
3493
|
], D = {
|
3467
3494
|
type: "change"
|
3468
|
-
},
|
3495
|
+
}, Kt = {
|
3469
3496
|
resolutionScale: c.resolutionScale,
|
3470
|
-
width:
|
3471
|
-
height:
|
3497
|
+
width: K.AUTO_SIZE,
|
3498
|
+
height: K.AUTO_SIZE
|
3472
3499
|
};
|
3473
3500
|
class qt extends Fe {
|
3474
|
-
constructor(e = new
|
3501
|
+
constructor(e = new we(), t, n = Te.DEFAULT) {
|
3475
3502
|
var d, p, g, S;
|
3476
|
-
super("CloudsEffect",
|
3477
|
-
attributes:
|
3503
|
+
super("CloudsEffect", zt, {
|
3504
|
+
attributes: We.DEPTH,
|
3478
3505
|
uniforms: /* @__PURE__ */ new Map([["cloudsBuffer", new r(null)]])
|
3479
|
-
}), this.camera = e, this.atmosphere = n, this.cloudLayers =
|
3506
|
+
}), this.camera = e, this.atmosphere = n, this.cloudLayers = q.DEFAULT.clone(), this.correctAltitude = !0, this.localWeatherRepeat = new m().setScalar(100), this.localWeatherOffset = new m(), this.shapeRepeat = new f().setScalar(3e-4), this.shapeOffset = new f(), this.shapeDetailRepeat = new f().setScalar(6e-3), this.shapeDetailOffset = new f(), this.turbulenceRepeat = new m().setScalar(20), this.ellipsoidCenter = new f(), this.ellipsoidMatrix = new v(), this.inverseEllipsoidMatrix = new v(), this.altitudeCorrection = new f(), this.sunDirection = new f(), this.localWeatherVelocity = new m(), this.shapeVelocity = new f(), this.shapeDetailVelocity = new f(), this._atmosphereOverlay = null, this._atmosphereShadow = null, this._atmosphereShadowLength = null, this.events = new je(), this.frame = 0, this.shadowCascadeCount = 0, this.shadowMapSize = new m(), this.onResolutionChange = () => {
|
3480
3507
|
this.setSize(this.resolution.baseWidth, this.resolution.baseHeight);
|
3481
3508
|
}, this.skipRendering = !0;
|
3482
3509
|
const {
|
@@ -3484,16 +3511,16 @@ class qt extends Fe {
|
|
3484
3511
|
width: i,
|
3485
3512
|
height: s,
|
3486
3513
|
resolutionX: l = i,
|
3487
|
-
resolutionY:
|
3514
|
+
resolutionY: u = s
|
3488
3515
|
} = {
|
3489
|
-
...
|
3516
|
+
...Kt,
|
3490
3517
|
...t
|
3491
3518
|
};
|
3492
3519
|
this.shadowMaps = new ht({
|
3493
3520
|
cascadeCount: c.shadow.cascadeCount,
|
3494
3521
|
mapSize: c.shadow.mapSize,
|
3495
3522
|
splitLambda: 0.6
|
3496
|
-
}), this.parameterUniforms =
|
3523
|
+
}), this.parameterUniforms = Mt({
|
3497
3524
|
localWeatherTexture: ((d = this.proceduralLocalWeather) == null ? void 0 : d.texture) ?? null,
|
3498
3525
|
localWeatherRepeat: this.localWeatherRepeat,
|
3499
3526
|
localWeatherOffset: this.localWeatherOffset,
|
@@ -3505,43 +3532,43 @@ class qt extends Fe {
|
|
3505
3532
|
shapeDetailOffset: this.shapeDetailOffset,
|
3506
3533
|
turbulenceTexture: ((S = this.proceduralTurbulence) == null ? void 0 : S.texture) ?? null,
|
3507
3534
|
turbulenceRepeat: this.turbulenceRepeat
|
3508
|
-
}), this.layerUniforms =
|
3535
|
+
}), this.layerUniforms = Ut(), this.atmosphereUniforms = Ht(n, {
|
3509
3536
|
ellipsoidCenter: this.ellipsoidCenter,
|
3510
3537
|
ellipsoidMatrix: this.ellipsoidMatrix,
|
3511
3538
|
inverseEllipsoidMatrix: this.inverseEllipsoidMatrix,
|
3512
3539
|
altitudeCorrection: this.altitudeCorrection,
|
3513
3540
|
sunDirection: this.sunDirection
|
3514
3541
|
});
|
3515
|
-
const
|
3542
|
+
const h = {
|
3516
3543
|
shadow: this.shadowMaps,
|
3517
3544
|
parameterUniforms: this.parameterUniforms,
|
3518
3545
|
layerUniforms: this.layerUniforms,
|
3519
3546
|
atmosphereUniforms: this.atmosphereUniforms
|
3520
3547
|
};
|
3521
|
-
this.shadowPass = new
|
3522
|
-
|
3548
|
+
this.shadowPass = new Nt(h), this.shadowPass.mainCamera = e, this.cloudsPass = new Tt(h, n), this.cloudsPass.mainCamera = e, this.clouds = ue(
|
3549
|
+
he(
|
3523
3550
|
{},
|
3524
3551
|
this.cloudsPass.currentMaterial,
|
3525
3552
|
Gt
|
3526
3553
|
),
|
3527
3554
|
this.cloudsPass.currentMaterial,
|
3528
|
-
|
3529
|
-
), this.shadow =
|
3530
|
-
|
3555
|
+
Vt
|
3556
|
+
), this.shadow = ue(
|
3557
|
+
he(
|
3531
3558
|
{},
|
3532
3559
|
this.shadowPass.currentMaterial,
|
3533
|
-
|
3560
|
+
kt
|
3534
3561
|
),
|
3535
3562
|
this.shadowPass.currentMaterial,
|
3536
|
-
kt,
|
3537
|
-
this.shadowPass,
|
3538
3563
|
jt,
|
3564
|
+
this.shadowPass,
|
3565
|
+
Yt,
|
3539
3566
|
this.shadowMaps,
|
3540
|
-
|
3541
|
-
), this.resolution = new
|
3567
|
+
Zt
|
3568
|
+
), this.resolution = new K(
|
3542
3569
|
this,
|
3543
3570
|
l,
|
3544
|
-
|
3571
|
+
u,
|
3545
3572
|
a
|
3546
3573
|
), this.resolution.addEventListener("change", this.onResolutionChange);
|
3547
3574
|
}
|
@@ -3555,17 +3582,17 @@ class qt extends Fe {
|
|
3555
3582
|
this.shadowPass.initialize(e, t, n), this.cloudsPass.initialize(e, t, n);
|
3556
3583
|
}
|
3557
3584
|
updateSharedUniforms(e) {
|
3558
|
-
|
3585
|
+
bt(this.layerUniforms, this.cloudLayers);
|
3559
3586
|
const { parameterUniforms: t } = this;
|
3560
3587
|
t.localWeatherOffset.value.add(
|
3561
|
-
|
3588
|
+
Bt.copy(this.localWeatherVelocity).multiplyScalar(e)
|
3562
3589
|
), t.shapeOffset.value.add(
|
3563
3590
|
I.copy(this.shapeVelocity).multiplyScalar(e)
|
3564
3591
|
), t.shapeDetailOffset.value.add(
|
3565
3592
|
I.copy(this.shapeDetailVelocity).multiplyScalar(e)
|
3566
3593
|
);
|
3567
3594
|
const n = this.inverseEllipsoidMatrix.copy(this.ellipsoidMatrix).invert(), a = this.camera.getWorldPosition(I).applyMatrix4(n).sub(this.ellipsoidCenter), i = this.altitudeCorrection;
|
3568
|
-
this.correctAltitude ?
|
3595
|
+
this.correctAltitude ? Ze(
|
3569
3596
|
a,
|
3570
3597
|
this.atmosphere.bottomRadius,
|
3571
3598
|
this.ellipsoid,
|
@@ -3575,14 +3602,14 @@ class qt extends Fe {
|
|
3575
3602
|
const s = this.ellipsoid.getSurfaceNormal(
|
3576
3603
|
a,
|
3577
3604
|
I
|
3578
|
-
), l = this.sunDirection.dot(s),
|
3605
|
+
), l = this.sunDirection.dot(s), u = De(1e6, 1e3, l);
|
3579
3606
|
this.shadowMaps.update(
|
3580
3607
|
this.camera,
|
3581
3608
|
// The sun direction must be rotated with the ellipsoid to ensure the
|
3582
3609
|
// frusta are constructed correctly. Note this affects the transformation
|
3583
3610
|
// in the shadow shader.
|
3584
3611
|
I.copy(this.sunDirection).applyMatrix4(this.ellipsoidMatrix),
|
3585
|
-
|
3612
|
+
u
|
3586
3613
|
);
|
3587
3614
|
}
|
3588
3615
|
updateWeatherTextureChannels() {
|
@@ -3594,7 +3621,7 @@ class qt extends Fe {
|
|
3594
3621
|
map: n.outputBuffer
|
3595
3622
|
});
|
3596
3623
|
s !== l && (this._atmosphereOverlay = l, D.target = this, D.property = "atmosphereOverlay", this.events.dispatchEvent(D));
|
3597
|
-
const
|
3624
|
+
const u = this._atmosphereShadow, h = Object.assign(this._atmosphereShadow ?? {}, {
|
3598
3625
|
map: t.outputBuffer,
|
3599
3626
|
mapSize: e.mapSize,
|
3600
3627
|
cascadeCount: e.cascadeCount,
|
@@ -3604,20 +3631,20 @@ class qt extends Fe {
|
|
3604
3631
|
far: e.far,
|
3605
3632
|
topHeight: i.shadowTopHeight.value
|
3606
3633
|
});
|
3607
|
-
|
3634
|
+
u !== h && (this._atmosphereShadow = h, D.target = this, D.property = "atmosphereShadow", this.events.dispatchEvent(D));
|
3608
3635
|
const d = this._atmosphereShadowLength, p = n.shadowLengthBuffer != null ? Object.assign(this._atmosphereShadowLength ?? {}, {
|
3609
3636
|
map: n.shadowLengthBuffer
|
3610
3637
|
}) : null;
|
3611
3638
|
d !== p && (this._atmosphereShadowLength = p, D.target = this, D.property = "atmosphereShadowLength", this.events.dispatchEvent(D));
|
3612
3639
|
}
|
3613
3640
|
update(e, t, n = 0) {
|
3614
|
-
var l,
|
3641
|
+
var l, u, h, d;
|
3615
3642
|
const { shadowMaps: a, shadowPass: i, cloudsPass: s } = this;
|
3616
3643
|
if (a.cascadeCount !== this.shadowCascadeCount || !a.mapSize.equals(this.shadowMapSize)) {
|
3617
3644
|
const { width: p, height: g } = a.mapSize, S = a.cascadeCount;
|
3618
3645
|
this.shadowMapSize.set(p, g), this.shadowCascadeCount = S, i.setSize(p, g, S), s.setShadowSize(p, g, S);
|
3619
3646
|
}
|
3620
|
-
(l = this.proceduralLocalWeather) == null || l.render(e, n), (
|
3647
|
+
(l = this.proceduralLocalWeather) == null || l.render(e, n), (u = this.proceduralShape) == null || u.render(e, n), (h = this.proceduralShapeDetail) == null || h.render(e, n), (d = this.proceduralTurbulence) == null || d.render(e, n), ++this.frame, this.updateSharedUniforms(n), this.updateWeatherTextureChannels(), i.update(e, this.frame, n), s.shadowBuffer = i.outputBuffer, s.update(e, this.frame, n), this.updateAtmosphereComposition(), this.uniforms.get("cloudsBuffer").value = this.cloudsPass.outputBuffer;
|
3621
3648
|
}
|
3622
3649
|
setSize(e, t) {
|
3623
3650
|
const { resolution: n } = this;
|
@@ -3630,7 +3657,7 @@ class qt extends Fe {
|
|
3630
3657
|
}
|
3631
3658
|
// eslint-disable-next-line accessor-pairs
|
3632
3659
|
set qualityPreset(e) {
|
3633
|
-
const { clouds: t, shadow: n, ...a } =
|
3660
|
+
const { clouds: t, shadow: n, ...a } = pt[e];
|
3634
3661
|
Object.assign(this, a), Object.assign(this.clouds, t), Object.assign(this.shadow, n);
|
3635
3662
|
}
|
3636
3663
|
// Textures
|
@@ -3745,17 +3772,33 @@ class qt extends Fe {
|
|
3745
3772
|
set scatterAnisotropyMix(e) {
|
3746
3773
|
this.cloudsPass.currentMaterial.scatterAnisotropyMix = e;
|
3747
3774
|
}
|
3775
|
+
/** @deprecated Use skyLightScale instead. */
|
3748
3776
|
get skyIrradianceScale() {
|
3749
|
-
return this.
|
3777
|
+
return this.skyLightScale;
|
3750
3778
|
}
|
3779
|
+
/** @deprecated Use skyLightScale instead. */
|
3751
3780
|
set skyIrradianceScale(e) {
|
3752
|
-
this.
|
3781
|
+
this.skyLightScale = e;
|
3753
3782
|
}
|
3783
|
+
get skyLightScale() {
|
3784
|
+
return this.cloudsPass.currentMaterial.uniforms.skyLightScale.value;
|
3785
|
+
}
|
3786
|
+
set skyLightScale(e) {
|
3787
|
+
this.cloudsPass.currentMaterial.uniforms.skyLightScale.value = e;
|
3788
|
+
}
|
3789
|
+
/** @deprecated Use groundBounceScale instead. */
|
3754
3790
|
get groundIrradianceScale() {
|
3755
|
-
return this.
|
3791
|
+
return this.groundBounceScale;
|
3756
3792
|
}
|
3793
|
+
/** @deprecated Use groundBounceScale instead. */
|
3757
3794
|
set groundIrradianceScale(e) {
|
3758
|
-
this.
|
3795
|
+
this.groundBounceScale = e;
|
3796
|
+
}
|
3797
|
+
get groundBounceScale() {
|
3798
|
+
return this.cloudsPass.currentMaterial.uniforms.groundBounceScale.value;
|
3799
|
+
}
|
3800
|
+
set groundBounceScale(e) {
|
3801
|
+
this.cloudsPass.currentMaterial.uniforms.groundBounceScale.value = e;
|
3759
3802
|
}
|
3760
3803
|
get powderScale() {
|
3761
3804
|
return this.cloudsPass.currentMaterial.uniforms.powderScale.value;
|
@@ -3798,18 +3841,24 @@ class qt extends Fe {
|
|
3798
3841
|
set transmittanceTexture(e) {
|
3799
3842
|
this.cloudsPass.currentMaterial.transmittanceTexture = e;
|
3800
3843
|
}
|
3844
|
+
get singleMieScatteringTexture() {
|
3845
|
+
return this.cloudsPass.currentMaterial.singleMieScatteringTexture;
|
3846
|
+
}
|
3847
|
+
set singleMieScatteringTexture(e) {
|
3848
|
+
this.cloudsPass.currentMaterial.singleMieScatteringTexture = e;
|
3849
|
+
}
|
3850
|
+
get higherOrderScatteringTexture() {
|
3851
|
+
return this.cloudsPass.currentMaterial.higherOrderScatteringTexture;
|
3852
|
+
}
|
3853
|
+
set higherOrderScatteringTexture(e) {
|
3854
|
+
this.cloudsPass.currentMaterial.higherOrderScatteringTexture = e;
|
3855
|
+
}
|
3801
3856
|
get ellipsoid() {
|
3802
3857
|
return this.cloudsPass.currentMaterial.ellipsoid;
|
3803
3858
|
}
|
3804
3859
|
set ellipsoid(e) {
|
3805
3860
|
this.cloudsPass.currentMaterial.ellipsoid = e;
|
3806
3861
|
}
|
3807
|
-
get photometric() {
|
3808
|
-
return this.cloudsPass.currentMaterial.photometric;
|
3809
|
-
}
|
3810
|
-
set photometric(e) {
|
3811
|
-
this.cloudsPass.currentMaterial.photometric = e;
|
3812
|
-
}
|
3813
3862
|
get sunAngularRadius() {
|
3814
3863
|
return this.cloudsPass.currentMaterial.sunAngularRadius;
|
3815
3864
|
}
|
@@ -3817,21 +3866,21 @@ class qt extends Fe {
|
|
3817
3866
|
this.cloudsPass.currentMaterial.sunAngularRadius = e;
|
3818
3867
|
}
|
3819
3868
|
}
|
3820
|
-
|
3869
|
+
Wt([
|
3821
3870
|
C("SKIP_RENDERING")
|
3822
3871
|
], qt.prototype, "skipRendering");
|
3823
|
-
const
|
3872
|
+
const nn = 128, an = 32, V = "45a1c6c1bb9fd38b3680fd120795ff4c32df68ff", rn = `https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${V}/packages/clouds/assets/local_weather.png`, on = `https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${V}/packages/clouds/assets/shape.bin`, sn = `https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${V}/packages/clouds/assets/shape_detail.bin`, cn = `https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${V}/packages/clouds/assets/turbulence.png`;
|
3824
3873
|
export {
|
3825
|
-
|
3826
|
-
|
3827
|
-
|
3874
|
+
nn as C,
|
3875
|
+
rn as D,
|
3876
|
+
an as a,
|
3828
3877
|
T as b,
|
3829
|
-
|
3830
|
-
|
3878
|
+
q as c,
|
3879
|
+
Kt as d,
|
3831
3880
|
qt as e,
|
3832
|
-
|
3833
|
-
|
3834
|
-
|
3835
|
-
|
3881
|
+
on as f,
|
3882
|
+
sn as g,
|
3883
|
+
cn as h,
|
3884
|
+
G as i
|
3836
3885
|
};
|
3837
3886
|
//# sourceMappingURL=shared.js.map
|