@takram/three-clouds 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/build/shared.cjs +8 -16
- package/build/shared.cjs.map +1 -1
- package/build/shared.js +38 -46
- package/build/shared.js.map +1 -1
- package/package.json +4 -4
- package/src/shaders/clouds.frag +2 -10
package/build/shared.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Pass as Fe, ShaderPass as
|
|
1
|
+
import { Pass as Fe, ShaderPass as K, Resolution as $, Effect as ze, EffectAttribute as We } from "postprocessing";
|
|
2
2
|
import { Vector3 as p, Vector2 as f, Matrix4 as m, Object3D as se, Box3 as Be, Uniform as r, GLSL3 as G, Vector4 as S, RawShaderMaterial as Q, Camera as we, WebGLRenderTarget as Ge, HalfFloatType as Ce, LinearFilter as B, RedFormat as Ve, WebGLArrayRenderTarget as ke, EventDispatcher as je, Matrix3 as Ye, Texture as ce, Data3DTexture as le } from "three";
|
|
3
|
-
import { AtmosphereMaterialBase as Ze, AtmosphereParameters as Te, getAltitudeCorrectionOffset as
|
|
4
|
-
import { lerp as De, defineInt as L, defineExpression as Ee, define as x, defineFloat as ee, unrollLoops as V, resolveIncludes as H, reinterpretType as
|
|
3
|
+
import { AtmosphereMaterialBase as Ze, AtmosphereParameters as Te, getAltitudeCorrectionOffset as qe } from "@takram/three-atmosphere";
|
|
4
|
+
import { lerp as De, defineInt as L, defineExpression as Ee, define as x, defineFloat as ee, unrollLoops as V, resolveIncludes as H, reinterpretType as Ke, Geodetic as $e, definePropertyShorthand as he, defineUniformShorthand as ue } from "@takram/three-geospatial";
|
|
5
5
|
import { runtime as de, definitions as pe, common as fe } from "@takram/three-atmosphere/shaders/bruneton";
|
|
6
6
|
import { vogelDisk as Xe, interleavedGradientNoise as Je, cascadedShadowMaps as Qe, raySphereIntersection as Ae, generators as et, turbo as _e, math as Pe, depth as tt } from "@takram/three-geospatial/shaders";
|
|
7
7
|
class k {
|
|
@@ -62,7 +62,7 @@ let w = b;
|
|
|
62
62
|
const R = /* @__PURE__ */ Array.from(
|
|
63
63
|
{ length: 8 },
|
|
64
64
|
() => ({ value: 0, flag: 0 })
|
|
65
|
-
),
|
|
65
|
+
), I = /* @__PURE__ */ Array.from(
|
|
66
66
|
{ length: 3 },
|
|
67
67
|
() => ({ min: 0, max: 0 })
|
|
68
68
|
);
|
|
@@ -124,17 +124,17 @@ const U = class U extends Array {
|
|
|
124
124
|
for (let s = 0; s < R.length; ++s) {
|
|
125
125
|
const { value: l, flag: h } = R[s];
|
|
126
126
|
if (a === 0 && s > 0) {
|
|
127
|
-
const u =
|
|
127
|
+
const u = I[n++];
|
|
128
128
|
u.min = R[s - 1].value, u.max = l;
|
|
129
129
|
}
|
|
130
130
|
a += h === 0 ? 1 : -1;
|
|
131
131
|
}
|
|
132
132
|
for (; n < 3; ++n) {
|
|
133
|
-
const s =
|
|
133
|
+
const s = I[n];
|
|
134
134
|
s.min = 0, s.max = 0;
|
|
135
135
|
}
|
|
136
|
-
let i =
|
|
137
|
-
e.x = i.min, t.x = i.max, i =
|
|
136
|
+
let i = I[0];
|
|
137
|
+
e.x = i.min, t.x = i.max, i = I[1], e.y = i.min, t.y = i.max, i = I[2], e.z = i.min, t.z = i.max;
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
140
|
U.DEFAULT = /* @__PURE__ */ new U([
|
|
@@ -628,14 +628,6 @@ layout(location = 1) out vec3 outputDepthVelocity;
|
|
|
628
628
|
layout(location = 2) out float outputShadowLength;
|
|
629
629
|
#endif // SHADOW_LENGTH
|
|
630
630
|
|
|
631
|
-
float readDepth(const vec2 uv) {
|
|
632
|
-
#if DEPTH_PACKING == 3201
|
|
633
|
-
return unpackRGBAToDepth(texture(depthBuffer, uv));
|
|
634
|
-
#else // DEPTH_PACKING == 3201
|
|
635
|
-
return texture(depthBuffer, uv).r;
|
|
636
|
-
#endif // DEPTH_PACKING == 3201
|
|
637
|
-
}
|
|
638
|
-
|
|
639
631
|
float getViewZ(const float depth) {
|
|
640
632
|
#ifdef PERSPECTIVE_CAMERA
|
|
641
633
|
return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
|
|
@@ -1348,9 +1340,9 @@ vec2 getHazeRayNearFar(const IntersectionResult intersections) {
|
|
|
1348
1340
|
#endif // HAZE
|
|
1349
1341
|
|
|
1350
1342
|
float getRayDistanceToScene(const vec3 rayDirection, out float viewZ) {
|
|
1351
|
-
float depth =
|
|
1352
|
-
depth = reverseLogDepth(depth, cameraNear, cameraFar);
|
|
1343
|
+
float depth = readDepthValue(depthBuffer, vUv * targetUvScale + temporalJitter);
|
|
1353
1344
|
if (depth < 1.0 - 1e-7) {
|
|
1345
|
+
depth = reverseLogDepth(depth, cameraNear, cameraFar);
|
|
1354
1346
|
viewZ = getViewZ(depth);
|
|
1355
1347
|
return -viewZ / dot(rayDirection, vCameraDirection);
|
|
1356
1348
|
}
|
|
@@ -2031,7 +2023,7 @@ class g extends Ze {
|
|
|
2031
2023
|
t.temporalJitter.value.set(P, O), t.mipLevelScale.value = 0.25, i.copy(e.projectionMatrix), i.elements[8] += P * 2, i.elements[9] += O * 2, i.invert(), l.copy(n), l.elements[8] += P * 2, l.elements[9] += O * 2, l.multiply(a), h.copy(l).multiply(s);
|
|
2032
2024
|
} else
|
|
2033
2025
|
t.temporalJitter.value.setScalar(0), t.mipLevelScale.value = 1, i.copy(e.projectionMatrixInverse), l.copy(n).multiply(a), h.copy(l).multiply(s);
|
|
2034
|
-
|
|
2026
|
+
Ke(e), t.cameraNear.value = e.near, t.cameraFar.value = e.far;
|
|
2035
2027
|
const u = e.getWorldPosition(
|
|
2036
2028
|
t.cameraPosition.value
|
|
2037
2029
|
), d = St.copy(u).applyMatrix4(t.worldToECEFMatrix.value);
|
|
@@ -2405,7 +2397,7 @@ void main() {
|
|
|
2405
2397
|
vUv = position.xy * 0.5 + 0.5;
|
|
2406
2398
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
2407
2399
|
}
|
|
2408
|
-
`,
|
|
2400
|
+
`, Me = `#ifdef VARIANCE_9_SAMPLES
|
|
2409
2401
|
#define VARIANCE_OFFSET_COUNT 8
|
|
2410
2402
|
const ivec2 varianceOffsets[8] = ivec2[8](
|
|
2411
2403
|
ivec2(-1, -1),
|
|
@@ -2520,7 +2512,7 @@ vec4 varianceClipping(
|
|
|
2520
2512
|
return varianceClipping(inputBuffer, coord, current, history, 1.0);
|
|
2521
2513
|
}
|
|
2522
2514
|
`;
|
|
2523
|
-
var Tt = Object.defineProperty,
|
|
2515
|
+
var Tt = Object.defineProperty, Ie = (o, e, t, n) => {
|
|
2524
2516
|
for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
|
|
2525
2517
|
(s = o[i]) && (a = s(e, t, a) || a);
|
|
2526
2518
|
return a && Tt(e, t, a), a;
|
|
@@ -2541,7 +2533,7 @@ class te extends Q {
|
|
|
2541
2533
|
H(wt, {
|
|
2542
2534
|
core: { turbo: _e },
|
|
2543
2535
|
catmullRomSampling: xt,
|
|
2544
|
-
varianceClipping:
|
|
2536
|
+
varianceClipping: Me
|
|
2545
2537
|
})
|
|
2546
2538
|
),
|
|
2547
2539
|
uniforms: {
|
|
@@ -2566,10 +2558,10 @@ class te extends Q {
|
|
|
2566
2558
|
this.uniforms.jitterOffset.value.set(d, v);
|
|
2567
2559
|
}
|
|
2568
2560
|
}
|
|
2569
|
-
|
|
2561
|
+
Ie([
|
|
2570
2562
|
x("TEMPORAL_UPSCALE")
|
|
2571
2563
|
], te.prototype, "temporalUpscale");
|
|
2572
|
-
|
|
2564
|
+
Ie([
|
|
2573
2565
|
x("SHADOW_LENGTH")
|
|
2574
2566
|
], te.prototype, "shadowLength");
|
|
2575
2567
|
class Ne extends Fe {
|
|
@@ -2613,7 +2605,7 @@ class Dt extends Ne {
|
|
|
2613
2605
|
atmosphereUniforms: n
|
|
2614
2606
|
},
|
|
2615
2607
|
i
|
|
2616
|
-
), this.currentPass = new
|
|
2608
|
+
), this.currentPass = new K(this.currentMaterial), this.resolveMaterial = new te(), this.resolvePass = new K(this.resolveMaterial), this.initRenderTargets({
|
|
2617
2609
|
depthVelocity: !0,
|
|
2618
2610
|
shadowLength: c.lightShafts
|
|
2619
2611
|
});
|
|
@@ -2719,7 +2711,7 @@ function Et(o, e) {
|
|
|
2719
2711
|
), i.push(a.COLOR_ATTACHMENT0 + s);
|
|
2720
2712
|
a.drawBuffers(i);
|
|
2721
2713
|
}
|
|
2722
|
-
class xe extends
|
|
2714
|
+
class xe extends K {
|
|
2723
2715
|
render(e, t, n, a, i) {
|
|
2724
2716
|
const s = this.fullscreenMaterial.uniforms;
|
|
2725
2717
|
t !== null && s?.[this.input] != null && (s[this.input].value = t.texture), Et(e, n), e.render(this.scene, this.camera);
|
|
@@ -3030,7 +3022,7 @@ void intersectStructuredPlanes(
|
|
|
3030
3022
|
}
|
|
3031
3023
|
}
|
|
3032
3024
|
`;
|
|
3033
|
-
var Ot = Object.defineProperty,
|
|
3025
|
+
var Ot = Object.defineProperty, M = (o, e, t, n) => {
|
|
3034
3026
|
for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
|
|
3035
3027
|
(s = o[i]) && (a = s(e, t, a) || a);
|
|
3036
3028
|
return a && Ot(e, t, a), a;
|
|
@@ -3092,24 +3084,24 @@ class _ extends Q {
|
|
|
3092
3084
|
this.uniforms.resolution.value.set(e, t);
|
|
3093
3085
|
}
|
|
3094
3086
|
}
|
|
3095
|
-
|
|
3087
|
+
M([
|
|
3096
3088
|
Ee("LOCAL_WEATHER_CHANNELS", {
|
|
3097
3089
|
validate: (o) => /^[rgba]{4}$/.test(o)
|
|
3098
3090
|
})
|
|
3099
3091
|
], _.prototype, "localWeatherChannels");
|
|
3100
|
-
|
|
3092
|
+
M([
|
|
3101
3093
|
L("CASCADE_COUNT", { min: 1, max: 4 })
|
|
3102
3094
|
], _.prototype, "cascadeCount");
|
|
3103
|
-
|
|
3095
|
+
M([
|
|
3104
3096
|
x("TEMPORAL_PASS")
|
|
3105
3097
|
], _.prototype, "temporalPass");
|
|
3106
|
-
|
|
3098
|
+
M([
|
|
3107
3099
|
x("TEMPORAL_JITTER")
|
|
3108
3100
|
], _.prototype, "temporalJitter");
|
|
3109
|
-
|
|
3101
|
+
M([
|
|
3110
3102
|
x("SHAPE_DETAIL")
|
|
3111
3103
|
], _.prototype, "shapeDetail");
|
|
3112
|
-
|
|
3104
|
+
M([
|
|
3113
3105
|
x("TURBULENCE")
|
|
3114
3106
|
], _.prototype, "turbulence");
|
|
3115
3107
|
const Rt = `precision highp float;
|
|
@@ -3199,10 +3191,10 @@ void main() {
|
|
|
3199
3191
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
3200
3192
|
}
|
|
3201
3193
|
`;
|
|
3202
|
-
var
|
|
3194
|
+
var Mt = Object.defineProperty, It = (o, e, t, n) => {
|
|
3203
3195
|
for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
|
|
3204
3196
|
(s = o[i]) && (a = s(e, t, a) || a);
|
|
3205
|
-
return a &&
|
|
3197
|
+
return a && Mt(e, t, a), a;
|
|
3206
3198
|
};
|
|
3207
3199
|
class be extends Q {
|
|
3208
3200
|
constructor({
|
|
@@ -3215,7 +3207,7 @@ class be extends Q {
|
|
|
3215
3207
|
vertexShader: Lt,
|
|
3216
3208
|
fragmentShader: V(
|
|
3217
3209
|
H(Rt, {
|
|
3218
|
-
varianceClipping:
|
|
3210
|
+
varianceClipping: Me
|
|
3219
3211
|
})
|
|
3220
3212
|
),
|
|
3221
3213
|
uniforms: {
|
|
@@ -3236,7 +3228,7 @@ class be extends Q {
|
|
|
3236
3228
|
this.uniforms.texelSize.value.set(1 / e, 1 / t);
|
|
3237
3229
|
}
|
|
3238
3230
|
}
|
|
3239
|
-
|
|
3231
|
+
It([
|
|
3240
3232
|
L("CASCADE_COUNT", { min: 1, max: 4 })
|
|
3241
3233
|
], be.prototype, "cascadeCount");
|
|
3242
3234
|
function Z(o) {
|
|
@@ -3354,7 +3346,7 @@ function Ut() {
|
|
|
3354
3346
|
})
|
|
3355
3347
|
};
|
|
3356
3348
|
}
|
|
3357
|
-
const
|
|
3349
|
+
const q = [0, 0, 0, 0];
|
|
3358
3350
|
function Ht(o, e) {
|
|
3359
3351
|
e.packValues("altitude", o.minLayerHeights.value), e.packSums("altitude", "height", o.maxLayerHeights.value), e.packIntervalHeights(
|
|
3360
3352
|
o.minIntervalHeights.value,
|
|
@@ -3363,12 +3355,12 @@ function Ht(o, e) {
|
|
|
3363
3355
|
const t = o.densityProfile.value;
|
|
3364
3356
|
e.packDensityProfiles("expTerm", t.expTerms), e.packDensityProfiles("exponent", t.exponents), e.packDensityProfiles("linearTerm", t.linearTerms), e.packDensityProfiles("constantTerm", t.constantTerms);
|
|
3365
3357
|
let n = 1 / 0, a = 0, i = 1 / 0, s = 0;
|
|
3366
|
-
|
|
3358
|
+
q.fill(0);
|
|
3367
3359
|
for (let l = 0; l < e.length; ++l) {
|
|
3368
3360
|
const { altitude: h, height: u, shadow: d } = e[l], v = h + u;
|
|
3369
|
-
u > 0 && (h < n && (n = h), d && h < i && (i = h), v > a && (a = v), d && v > s && (s = v)),
|
|
3361
|
+
u > 0 && (h < n && (n = h), d && h < i && (i = h), v > a && (a = v), d && v > s && (s = v)), q[l] = d ? 1 : 0;
|
|
3370
3362
|
}
|
|
3371
|
-
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(
|
|
3363
|
+
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(q);
|
|
3372
3364
|
}
|
|
3373
3365
|
function Ft(o, e) {
|
|
3374
3366
|
return {
|
|
@@ -3432,9 +3424,9 @@ const N = /* @__PURE__ */ new p(), Gt = /* @__PURE__ */ new f(), Vt = /* @__PURE
|
|
|
3432
3424
|
"opticalDepthTailScale"
|
|
3433
3425
|
], Zt = [
|
|
3434
3426
|
"temporalJitter"
|
|
3435
|
-
], Kt = [
|
|
3436
|
-
"temporalPass"
|
|
3437
3427
|
], qt = [
|
|
3428
|
+
"temporalPass"
|
|
3429
|
+
], Kt = [
|
|
3438
3430
|
"cascadeCount",
|
|
3439
3431
|
"mapSize",
|
|
3440
3432
|
"maxFar",
|
|
@@ -3511,9 +3503,9 @@ class Xt extends ze {
|
|
|
3511
3503
|
this.shadowPass.currentMaterial,
|
|
3512
3504
|
Zt,
|
|
3513
3505
|
this.shadowPass,
|
|
3514
|
-
|
|
3506
|
+
qt,
|
|
3515
3507
|
this.shadowMaps,
|
|
3516
|
-
|
|
3508
|
+
Kt
|
|
3517
3509
|
), this.resolution = new $(
|
|
3518
3510
|
this,
|
|
3519
3511
|
l,
|
|
@@ -3543,7 +3535,7 @@ class Xt extends ze {
|
|
|
3543
3535
|
const n = this.worldToECEFMatrix;
|
|
3544
3536
|
this.ecefToWorldMatrix.copy(n).invert();
|
|
3545
3537
|
const a = this.camera.getWorldPosition(N).applyMatrix4(this.worldToECEFMatrix), i = this.altitudeCorrection;
|
|
3546
|
-
this.correctAltitude ?
|
|
3538
|
+
this.correctAltitude ? qe(
|
|
3547
3539
|
a,
|
|
3548
3540
|
this.atmosphere.bottomRadius,
|
|
3549
3541
|
this.ellipsoid,
|