@takram/three-clouds 0.2.2 → 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 +37 -0
- package/README.md +25 -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 +180 -186
- package/build/r3f.js.map +1 -1
- package/build/shared.cjs +102 -74
- package/build/shared.cjs.map +1 -1
- package/build/shared.js +443 -380
- package/build/shared.js.map +1 -1
- package/package.json +3 -3
- package/src/CloudLayers.ts +2 -2
- package/src/CloudsEffect.ts +52 -29
- package/src/CloudsMaterial.ts +53 -30
- 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 +65 -63
- package/src/r3f/Clouds.tsx +170 -188
- package/src/shaders/clouds.frag +64 -50
- package/src/shaders/clouds.glsl +1 -1
- package/src/shaders/clouds.vert +18 -5
- package/src/shaders/parameters.glsl +3 -2
- 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 +19 -9
- package/types/CloudsMaterial.d.ts +10 -5
- package/types/qualityPresets.d.ts +1 -1
- package/types/r3f/CloudLayer.d.ts +3 -1
- package/types/r3f/Clouds.d.ts +2 -1
package/build/shared.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";const C=require("postprocessing"),n=require("three"),H=require("@takram/three-atmosphere"),u=require("@takram/three-geospatial"),
|
1
|
+
"use strict";const C=require("postprocessing"),n=require("three"),H=require("@takram/three-atmosphere"),u=require("@takram/three-geospatial"),A=require("@takram/three-atmosphere/shaders/bruneton"),y=require("@takram/three-geospatial/shaders");class M{constructor(e=0,t=0,a=0,i=0){this.expTerm=e,this.exponent=t,this.linearTerm=a,this.constantTerm=i}set(e=0,t=0,a=0,i=0){return this.expTerm=e,this.exponent=t,this.linearTerm=a,this.constantTerm=i,this}clone(){return new M(this.expTerm,this.exponent,this.linearTerm,this.constantTerm)}copy(e){return this.expTerm=e.expTerm,this.exponent=e.exponent,this.linearTerm=e.linearTerm,this.constantTerm=e.constantTerm,this}}const me=["channel","altitude","height","densityScale","shapeAmount","shapeDetailAmount","weatherExponent","shapeAlteringBias","coverageFilterWidth","shadow","densityProfile"];function ve(o,e){if(e!=null)for(const t of me){const a=e[t];a!=null&&(o[t]instanceof M?o[t].copy(a):o[t]=a)}}const U=class U{constructor(e){this.channel="r",this.altitude=0,this.height=0,this.densityScale=.2,this.shapeAmount=1,this.shapeDetailAmount=1,this.weatherExponent=1,this.shapeAlteringBias=.35,this.coverageFilterWidth=.6,this.densityProfile=new M(0,0,.75,.25),this.shadow=!1,this.set(e)}set(e){return ve(this,e),this}clone(){return new U(this)}copy(e){return this.channel=e.channel,this.altitude=e.altitude,this.height=e.height,this.densityScale=e.densityScale,this.shapeAmount=e.shapeAmount,this.shapeDetailAmount=e.shapeDetailAmount,this.weatherExponent=e.weatherExponent,this.shapeAlteringBias=e.shapeAlteringBias,this.coverageFilterWidth=e.coverageFilterWidth,this.densityProfile.copy(e.densityProfile),this.shadow=e.shadow,this}};U.DEFAULT=new U;let x=U;const _=Array.from({length:8},()=>({value:0,flag:0})),P=Array.from({length:3},()=>({min:0,max:0}));function ge(o,e){return o.value!==e.value?o.value-e.value:o.flag-e.flag}const R=class R extends Array{constructor(e){super(new x(e==null?void 0:e[0]),new x(e==null?void 0:e[1]),new x(e==null?void 0:e[2]),new x(e==null?void 0:e[3]))}set(e){return this[0].set(e==null?void 0:e[0]),this[1].set(e==null?void 0:e[1]),this[2].set(e==null?void 0:e[2]),this[3].set(e==null?void 0:e[3]),this}reset(){return this[0].copy(x.DEFAULT),this[1].copy(x.DEFAULT),this[2].copy(x.DEFAULT),this[3].copy(x.DEFAULT),this}clone(){return new R(this)}copy(e){return this[0].copy(e[0]),this[1].copy(e[1]),this[2].copy(e[2]),this[3].copy(e[3]),this}get localWeatherChannels(){return this[0].channel+this[1].channel+this[2].channel+this[3].channel}packValues(e,t){return t.set(this[0][e],this[1][e],this[2][e],this[3][e])}packSums(e,t,a){return a.set(this[0][e]+this[0][t],this[1][e]+this[1][t],this[2][e]+this[2][t],this[3][e]+this[3][t])}packDensityProfiles(e,t){return t.set(this[0].densityProfile[e],this[1].densityProfile[e],this[2].densityProfile[e],this[3].densityProfile[e])}packIntervalHeights(e,t){for(let s=0;s<4;++s){const l=this[s];let h=_[s];h.value=l.altitude,h.flag=0,h=_[s+4],h.value=l.altitude+l.height,h.flag=1}_.sort(ge);let a=0,i=0;for(let s=0;s<_.length;++s){const{value:l,flag:h}=_[s];if(i===0&&s>0){const d=P[a++];d.min=_[s-1].value,d.max=l}i+=h===0?1:-1}for(;a<3;++a){const s=P[a];s.min=0,s.max=0}let r=P[0];e.x=r.min,t.x=r.max,r=P[1],e.y=r.min,t.y=r.max,r=P[2],e.z=r.min,t.z=r.max}};R.DEFAULT=new R([{channel:"r",altitude:750,height:650,densityScale:.2,shapeAmount:1,shapeDetailAmount:1,weatherExponent:1,shapeAlteringBias:.35,coverageFilterWidth:.6,shadow:!0},{channel:"g",altitude:1e3,height:1200,densityScale:.2,shapeAmount:1,shapeDetailAmount:1,weatherExponent:1,shapeAlteringBias:.35,coverageFilterWidth:.6,shadow:!0},{channel:"b",altitude:7500,height:500,densityScale:.003,shapeAmount:.4,shapeDetailAmount:0,weatherExponent:1,shapeAlteringBias:.35,coverageFilterWidth:.5},{channel:"a"}]);let F=R;var Se=process.env.NODE_ENV==="production",J="Invariant failed";function D(o,e){if(!o){if(Se)throw new Error(J);var t=J;throw new Error(t)}}class I{constructor(e,t){this.near=[new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3],this.far=[new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3],e!=null&&t!=null&&this.setFromCamera(e,t)}clone(){return new I().copy(this)}copy(e){for(let t=0;t<4;++t)this.near[t].copy(e.near[t]),this.far[t].copy(e.far[t]);return this}setFromCamera(e,t){const a=e.isOrthographicCamera===!0,i=e.projectionMatrixInverse;this.near[0].set(1,1,-1),this.near[1].set(1,-1,-1),this.near[2].set(-1,-1,-1),this.near[3].set(-1,1,-1);for(let r=0;r<4;++r)this.near[r].applyMatrix4(i);this.far[0].set(1,1,1),this.far[1].set(1,-1,1),this.far[2].set(-1,-1,1),this.far[3].set(-1,1,1);for(let r=0;r<4;++r){const s=this.far[r];s.applyMatrix4(i);const l=Math.abs(s.z);a?s.z*=Math.min(t/l,1):s.multiplyScalar(Math.min(t/l,1))}return this}split(e,t=[]){for(let a=0;a<e.length;++a){const i=t[a]??(t[a]=new I);if(a===0)for(let r=0;r<4;++r)i.near[r].copy(this.near[r]);else for(let r=0;r<4;++r)i.near[r].lerpVectors(this.near[r],this.far[r],e[a-1]);if(a===e.length-1)for(let r=0;r<4;++r)i.far[r].copy(this.far[r]);else for(let r=0;r<4;++r)i.far[r].lerpVectors(this.near[r],this.far[r],e[a])}return t.length=e.length,t}applyMatrix4(e){for(let t=0;t<4;++t)this.near[t].applyMatrix4(e),this.far[t].applyMatrix4(e);return this}}const ye={uniform:(o,e,t,a,i=[])=>{for(let r=0;r<o;++r)i[r]=(e+(t-e)*(r+1)/o)/t;return i.length=o,i},logarithmic:(o,e,t,a,i=[])=>{for(let r=0;r<o;++r)i[r]=e*(t/e)**((r+1)/o)/t;return i.length=o,i},practical:(o,e,t,a=.5,i=[])=>{for(let r=0;r<o;++r){const s=(e+(t-e)*(r+1)/o)/t,l=e*(t/e)**((r+1)/o)/t;i[r]=u.lerp(s,l,a)}return i.length=o,i}};function xe(o,e,t,a,i,r=[]){return ye[o](e,t,a,i,r)}const Q=new n.Vector3,ee=new n.Vector3,we=new n.Matrix4,te=new n.Matrix4,Ce=new I,Te=new n.Box3,De={maxFar:null,farScale:1,splitMode:"practical",splitLambda:.5,margin:0,fade:!0};class Ee{constructor(e){this.cascades=[],this.mapSize=new n.Vector2,this.cameraFrustum=new I,this.frusta=[],this.splits=[],this._far=0;const{cascadeCount:t,mapSize:a,maxFar:i,farScale:r,splitMode:s,splitLambda:l,margin:h,fade:d}={...De,...e};this.cascadeCount=t,this.mapSize.copy(a),this.maxFar=i,this.farScale=r,this.splitMode=s,this.splitLambda=l,this.margin=h,this.fade=d}get cascadeCount(){return this.cascades.length}set cascadeCount(e){var t;if(e!==this.cascadeCount){for(let a=0;a<e;++a)(t=this.cascades)[a]??(t[a]={interval:new n.Vector2,matrix:new n.Matrix4,inverseMatrix:new n.Matrix4,projectionMatrix:new n.Matrix4,inverseProjectionMatrix:new n.Matrix4,viewMatrix:new n.Matrix4,inverseViewMatrix:new n.Matrix4});this.cascades.length=e}}get far(){return this._far}updateIntervals(e){const t=this.cascadeCount,a=this.splits,i=this.far;xe(this.splitMode,t,e.near,i,this.splitLambda,a),this.cameraFrustum.setFromCamera(e,i),this.cameraFrustum.split(a,this.frusta);const r=this.cascades;for(let s=0;s<t;++s)r[s].interval.set(a[s-1]??0,a[s]??0)}getFrustumRadius(e,t){const a=t.near,i=t.far;let r=Math.max(i[0].distanceTo(i[2]),i[0].distanceTo(a[2]));if(this.fade){const s=e.near,l=this.far,h=i[0].z/(l-s);r+=.25*h**2*(l-s)}return r*.5}updateMatrices(e,t,a=1){const i=we.lookAt(Q.setScalar(0),ee.copy(t).multiplyScalar(-1),n.Object3D.DEFAULT_UP),r=te.multiplyMatrices(te.copy(i).invert(),e.matrixWorld),s=this.frusta,l=this.cascades;D(s.length===l.length);const h=this.margin,d=this.mapSize;for(let p=0;p<s.length;++p){const f=s[p],m=l[p],v=this.getFrustumRadius(e,s[p]),j=-v,Y=v,q=v,Z=-v;m.projectionMatrix.makeOrthographic(j,Y,q,Z,-this.margin,v*2+this.margin);const{near:pe,far:fe}=Ce.copy(f).applyMatrix4(r),N=Te.makeEmpty();for(let b=0;b<4;b++)N.expandByPoint(pe[b]),N.expandByPoint(fe[b]);const T=N.getCenter(Q);T.z=N.max.z+h;const K=(Y-j)/d.width,X=(q-Z)/d.height;T.x=Math.round(T.x/K)*K,T.y=Math.round(T.y/X)*X,T.applyMatrix4(i);const $=ee.copy(t).multiplyScalar(a).add(T);m.inverseViewMatrix.lookAt(T,$,n.Object3D.DEFAULT_UP).setPosition($)}}update(e,t,a){this._far=this.maxFar!=null?Math.min(this.maxFar,e.far*this.farScale):e.far*this.farScale,this.updateIntervals(e),this.updateMatrices(e,t,a);const i=this.cascades,r=this.cascadeCount;for(let s=0;s<r;++s){const{matrix:l,inverseMatrix:h,projectionMatrix:d,inverseProjectionMatrix:p,viewMatrix:f,inverseViewMatrix:m}=i[s];p.copy(d).invert(),f.copy(m).invert(),l.copy(d).multiply(f),h.copy(m).multiply(p)}}}const ne=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5],ie=ne.reduce((o,e,t)=>{const a=new n.Vector2;for(let i=0;i<16;++i)if(ne[i]===t){a.set((i%4+.5)/4,(Math.floor(i/4)+.5)/4);break}return[...o,a]},[]),Ae={resolutionScale:1,lightShafts:!0,shapeDetail:!0,turbulence:!0,haze:!0,clouds:{multiScatteringOctaves:8,accurateSunSkyLight:!0,accuratePhaseFunction:!1,maxIterationCount:500,minStepSize:50,maxStepSize:1e3,maxRayDistance:2e5,perspectiveStepScale:1.01,minDensity:1e-5,minExtinction:1e-5,minTransmittance:.01,maxIterationCountToGround:3,maxIterationCountToSun:2,minSecondaryStepSize:100,secondaryStepScale:2,maxShadowLengthIterationCount:500,minShadowLengthStepSize:50,maxShadowLengthRayDistance:2e5},shadow:{cascadeCount:3,mapSize:new n.Vector2(512,512),maxIterationCount:50,minStepSize:100,maxStepSize:1e3,minDensity:1e-5,minExtinction:1e-5,minTransmittance:1e-4}},c=Ae,_e={low:{...c,lightShafts:!1,shapeDetail:!1,turbulence:!1,clouds:{...c.clouds,accurateSunSkyLight:!1,maxIterationCount:200,minStepSize:100,maxRayDistance:1e5,minDensity:1e-4,minExtinction:1e-4,minTransmittance:.1,maxIterationCountToGround:0,maxIterationCountToSun:1},shadow:{...c.shadow,maxIterationCount:25,minDensity:1e-4,minExtinction:1e-4,minTransmittance:.01,cascadeCount:2,mapSize:new n.Vector2(256,256)}},medium:{...c,lightShafts:!1,turbulence:!1,clouds:{...c.clouds,minDensity:1e-4,minExtinction:1e-4,accurateSunSkyLight:!1,maxIterationCountToSun:2,maxIterationCountToGround:1},shadow:{...c.shadow,minDensity:1e-4,minExtinction:1e-4,mapSize:new n.Vector2(256,256)}},high:c,ultra:{...c,clouds:{...c.clouds,minStepSize:10},shadow:{...c.shadow,mapSize:new n.Vector2(1024,1024)}}},Oe=`precision highp float;
|
2
2
|
precision highp sampler3D;
|
3
3
|
precision highp sampler2DArray;
|
4
4
|
|
@@ -13,14 +13,28 @@ precision highp sampler2DArray;
|
|
13
13
|
#include "core/cascadedShadowMaps"
|
14
14
|
#include "core/interleavedGradientNoise"
|
15
15
|
#include "core/vogelDisk"
|
16
|
-
|
17
|
-
#include "atmosphere/
|
16
|
+
|
17
|
+
#include "atmosphere/bruneton/definitions"
|
18
|
+
|
19
|
+
uniform AtmosphereParameters ATMOSPHERE;
|
20
|
+
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
|
21
|
+
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
|
22
|
+
|
23
|
+
uniform sampler2D transmittance_texture;
|
24
|
+
uniform sampler3D scattering_texture;
|
25
|
+
uniform sampler2D irradiance_texture;
|
26
|
+
uniform sampler3D single_mie_scattering_texture;
|
27
|
+
uniform sampler3D higher_order_scattering_texture;
|
28
|
+
|
29
|
+
#include "atmosphere/bruneton/common"
|
30
|
+
#include "atmosphere/bruneton/runtime"
|
31
|
+
|
18
32
|
#include "types"
|
19
33
|
#include "parameters"
|
20
34
|
#include "clouds"
|
21
35
|
|
22
36
|
#if !defined(RECIPROCAL_PI4)
|
23
|
-
#define RECIPROCAL_PI4
|
37
|
+
#define RECIPROCAL_PI4 0.07957747154594767
|
24
38
|
#endif // !defined(RECIPROCAL_PI4)
|
25
39
|
|
26
40
|
uniform sampler2D depthBuffer;
|
@@ -36,8 +50,8 @@ uniform float mipLevelScale;
|
|
36
50
|
// Scattering
|
37
51
|
const vec2 scatterAnisotropy = vec2(SCATTER_ANISOTROPY_1, SCATTER_ANISOTROPY_2);
|
38
52
|
const float scatterAnisotropyMix = SCATTER_ANISOTROPY_MIX;
|
39
|
-
uniform float
|
40
|
-
uniform float
|
53
|
+
uniform float skyLightScale;
|
54
|
+
uniform float groundBounceScale;
|
41
55
|
uniform float powderScale;
|
42
56
|
uniform float powderExponent;
|
43
57
|
|
@@ -266,7 +280,7 @@ vec4 getCascadedShadowMaps(vec2 uv) {
|
|
266
280
|
}
|
267
281
|
|
268
282
|
#if !defined(DEBUG_SHOW_SHADOW_MAP_TYPE)
|
269
|
-
#define DEBUG_SHOW_SHADOW_MAP_TYPE
|
283
|
+
#define DEBUG_SHOW_SHADOW_MAP_TYPE 0
|
270
284
|
#endif // !defined(DEBUG_SHOW_SHADOW_MAP_TYPE
|
271
285
|
|
272
286
|
const float frontDepthScale = 1e-5;
|
@@ -415,30 +429,31 @@ vec3 getGroundSunSkyIrradiance(
|
|
415
429
|
const float height,
|
416
430
|
out vec3 skyIrradiance
|
417
431
|
) {
|
418
|
-
#ifdef
|
432
|
+
#ifdef ACCURATE_SUN_SKY_LIGHT
|
419
433
|
return GetSunAndSkyIrradiance(
|
420
434
|
(position - surfaceNormal * height) * METER_TO_LENGTH_UNIT,
|
435
|
+
surfaceNormal,
|
421
436
|
sunDirection,
|
422
437
|
skyIrradiance
|
423
438
|
);
|
424
|
-
#else //
|
439
|
+
#else // ACCURATE_SUN_SKY_LIGHT
|
425
440
|
skyIrradiance = vGroundIrradiance.sky;
|
426
441
|
return vGroundIrradiance.sun;
|
427
|
-
#endif //
|
442
|
+
#endif // ACCURATE_SUN_SKY_LIGHT
|
428
443
|
}
|
429
444
|
|
430
445
|
vec3 getCloudsSunSkyIrradiance(const vec3 position, const float height, out vec3 skyIrradiance) {
|
431
|
-
#ifdef
|
432
|
-
return
|
433
|
-
#else //
|
446
|
+
#ifdef ACCURATE_SUN_SKY_LIGHT
|
447
|
+
return GetSunAndSkyScalarIrradiance(position * METER_TO_LENGTH_UNIT, sunDirection, skyIrradiance);
|
448
|
+
#else // ACCURATE_SUN_SKY_LIGHT
|
434
449
|
float alpha = remapClamped(height, minHeight, maxHeight);
|
435
450
|
skyIrradiance = mix(vCloudsIrradiance.minSky, vCloudsIrradiance.maxSky, alpha);
|
436
451
|
return mix(vCloudsIrradiance.minSun, vCloudsIrradiance.maxSun, alpha);
|
437
|
-
#endif //
|
452
|
+
#endif // ACCURATE_SUN_SKY_LIGHT
|
438
453
|
}
|
439
454
|
|
440
|
-
#ifdef
|
441
|
-
vec3
|
455
|
+
#ifdef GROUND_BOUNCE
|
456
|
+
vec3 approximateRadianceFromGround(
|
442
457
|
const vec3 position,
|
443
458
|
const vec3 surfaceNormal,
|
444
459
|
const float height,
|
@@ -455,12 +470,11 @@ vec3 approximateIrradianceFromGround(
|
|
455
470
|
vec3 skyIrradiance;
|
456
471
|
vec3 sunIrradiance = getGroundSunSkyIrradiance(position, surfaceNormal, height, skyIrradiance);
|
457
472
|
const float groundAlbedo = 0.3;
|
458
|
-
vec3 groundIrradiance = skyIrradiance + (1.0 - coverage) * sunIrradiance
|
459
|
-
vec3
|
460
|
-
|
461
|
-
return albedo * bouncedIrradiance * RECIPROCAL_PI4 * groundIrradianceScale;
|
473
|
+
vec3 groundIrradiance = skyIrradiance + (1.0 - coverage) * sunIrradiance;
|
474
|
+
vec3 bouncedRadiance = groundAlbedo * RECIPROCAL_PI * groundIrradiance;
|
475
|
+
return bouncedRadiance * exp(-opticalDepthToGround);
|
462
476
|
}
|
463
|
-
#endif //
|
477
|
+
#endif // GROUND_BOUNCE
|
464
478
|
|
465
479
|
vec4 marchClouds(
|
466
480
|
const vec3 rayOrigin,
|
@@ -548,28 +562,28 @@ vec4 marchClouds(
|
|
548
562
|
);
|
549
563
|
}
|
550
564
|
|
551
|
-
|
552
|
-
vec3 radiance = albedo * sunIrradiance * scattering;
|
565
|
+
vec3 radiance = sunIrradiance * approximateMultipleScattering(opticalDepth, cosTheta);
|
553
566
|
|
554
|
-
#ifdef
|
567
|
+
#ifdef GROUND_BOUNCE
|
555
568
|
// Fudge factor for the irradiance from ground.
|
556
569
|
if (height < shadowTopHeight && mipLevel < 0.5) {
|
557
|
-
|
570
|
+
vec3 groundRadiance = approximateRadianceFromGround(
|
558
571
|
position,
|
559
572
|
surfaceNormal,
|
560
573
|
height,
|
561
574
|
mipLevel,
|
562
575
|
jitter
|
563
576
|
);
|
577
|
+
radiance += groundRadiance * RECIPROCAL_PI4 * groundBounceScale;
|
564
578
|
}
|
565
|
-
#endif //
|
579
|
+
#endif // GROUND_BOUNCE
|
566
580
|
|
567
581
|
// Crude approximation of sky gradient. Better than none in the shadows.
|
568
|
-
float skyGradient = dot(0.5 +
|
569
|
-
radiance +=
|
582
|
+
float skyGradient = dot(weather.heightFraction * 0.5 + 0.5, media.weight);
|
583
|
+
radiance += skyIrradiance * RECIPROCAL_PI4 * skyGradient * skyLightScale;
|
570
584
|
|
571
|
-
// Finally multiply by
|
572
|
-
radiance *= media.
|
585
|
+
// Finally multiply by scattering.
|
586
|
+
radiance *= media.scattering;
|
573
587
|
|
574
588
|
#ifdef POWDER
|
575
589
|
radiance *= 1.0 - powderScale * exp(-media.extinction * powderExponent);
|
@@ -622,7 +636,7 @@ float marchShadowLength(
|
|
622
636
|
float maxRayDistance = rayNearFar.y - rayNearFar.x;
|
623
637
|
float stepSize = minShadowLengthStepSize;
|
624
638
|
float rayDistance = stepSize * jitter;
|
625
|
-
const float attenuationFactor = 1.0 -
|
639
|
+
const float attenuationFactor = 1.0 - 5e-4;
|
626
640
|
float attenuation = 1.0;
|
627
641
|
|
628
642
|
// TODO: This march is closed, and sample resolution can be much lower.
|
@@ -634,14 +648,6 @@ float marchShadowLength(
|
|
634
648
|
vec3 position = rayDistance * rayDirection + rayOrigin;
|
635
649
|
float opticalDepth = sampleShadowOpticalDepth(position, 0.0, 0.0, jitter);
|
636
650
|
shadowLength += (1.0 - exp(-opticalDepth)) * stepSize * attenuation;
|
637
|
-
|
638
|
-
// Hack to prevent over-integration of shadow length. The shadow should be
|
639
|
-
// attenuated by the inscatter as the ray travels further.
|
640
|
-
attenuation *= attenuationFactor;
|
641
|
-
if (attenuation < 1e-5) {
|
642
|
-
break;
|
643
|
-
}
|
644
|
-
|
645
651
|
stepSize *= perspectiveStepScale;
|
646
652
|
rayDistance += stepSize;
|
647
653
|
}
|
@@ -668,25 +674,33 @@ vec4 approximateHaze(
|
|
668
674
|
return vec4(0.0); // Prevent artifact in views from space
|
669
675
|
}
|
670
676
|
|
677
|
+
// Blend two normals by the difference in angle so that normal near the
|
678
|
+
// ground becomes that of the origin, and in the sky that of the horizon.
|
679
|
+
vec3 normalAtOrigin = normalize(rayOrigin);
|
680
|
+
vec3 normalAtHorizon = (rayOrigin - dot(rayOrigin, rayDirection) * rayDirection) / bottomRadius;
|
681
|
+
float alpha = remapClamped(dot(normalAtOrigin, normalAtHorizon), 0.9, 1.0);
|
682
|
+
vec3 normal = mix(normalAtOrigin, normalAtHorizon, alpha);
|
683
|
+
|
671
684
|
// Analytical optical depth where density exponentially decreases with height.
|
672
685
|
// Based on: https://iquilezles.org/articles/fog/
|
673
|
-
float angle = max(dot(
|
686
|
+
float angle = max(dot(normal, rayDirection), 1e-5);
|
674
687
|
float exponent = angle * hazeExponent;
|
688
|
+
float linearTerm = density / hazeExponent / angle;
|
689
|
+
|
675
690
|
// Derive the optical depths separately for with and without shadow length.
|
676
691
|
float expTerm = 1.0 - exp(-maxRayDistance * exponent);
|
677
692
|
float shadowExpTerm = 1.0 - exp(-min(maxRayDistance, shadowLength) * exponent);
|
678
|
-
float linearTerm = density / hazeExponent / angle;
|
679
693
|
float opticalDepth = expTerm * linearTerm;
|
680
|
-
float
|
694
|
+
float shadowOpticalDepth = max((expTerm - shadowExpTerm) * linearTerm, 0.0);
|
695
|
+
float transmittance = saturate(1.0 - exp(-opticalDepth));
|
696
|
+
float shadowTransmittance = saturate(1.0 - exp(-shadowOpticalDepth));
|
681
697
|
|
682
698
|
vec3 skyIrradiance = vGroundIrradiance.sky;
|
683
699
|
vec3 sunIrradiance = vGroundIrradiance.sun;
|
684
|
-
vec3
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
// Inscatter is attenuated by shadow length, but transmittance is not.
|
689
|
-
return vec4(inscatter, saturate(1.0 - exp(-opticalDepth)));
|
700
|
+
vec3 inscatter = sunIrradiance * phaseFunction(cosTheta) * shadowTransmittance;
|
701
|
+
inscatter += skyIrradiance * RECIPROCAL_PI4 * skyLightScale * transmittance;
|
702
|
+
inscatter *= hazeScatteringCoefficient / (hazeAbsorptionCoefficient + hazeScatteringCoefficient);
|
703
|
+
return vec4(inscatter, transmittance);
|
690
704
|
}
|
691
705
|
|
692
706
|
#endif // HAZE
|
@@ -705,8 +719,7 @@ void applyAerialPerspective(
|
|
705
719
|
sunDirection,
|
706
720
|
transmittance
|
707
721
|
);
|
708
|
-
|
709
|
-
color.rgb = mix(vec3(0.0), color.rgb * transmittance / clampedAlpha + inscatter, color.a);
|
722
|
+
color.rgb = color.rgb * transmittance + inscatter * color.a;
|
710
723
|
}
|
711
724
|
|
712
725
|
bool rayIntersectsGround(const vec3 cameraPosition, const vec3 rayDirection) {
|
@@ -985,7 +998,8 @@ void main() {
|
|
985
998
|
cosTheta,
|
986
999
|
shadowLength
|
987
1000
|
);
|
988
|
-
color = color
|
1001
|
+
color.rgb = mix(color.rgb, haze.rgb, haze.a);
|
1002
|
+
color.a = color.a * (1.0 - haze.a) + haze.a;
|
989
1003
|
#endif // HAZE
|
990
1004
|
|
991
1005
|
outputColor = color;
|
@@ -1163,7 +1177,7 @@ MediaSample sampleMedia(
|
|
1163
1177
|
}
|
1164
1178
|
#endif // SHAPE_DETAIL
|
1165
1179
|
|
1166
|
-
//
|
1180
|
+
// Apply the density profiles.
|
1167
1181
|
density = saturate(density * densityScales * getLayerDensity(weather.heightFraction));
|
1168
1182
|
|
1169
1183
|
MediaSample media;
|
@@ -1184,11 +1198,24 @@ MediaSample sampleMedia(
|
|
1184
1198
|
ivec3 sampleCount;
|
1185
1199
|
return sampleMedia(weather, position, uv, mipLevel, jitter, sampleCount);
|
1186
1200
|
}
|
1187
|
-
`,
|
1201
|
+
`,Pe=`precision highp float;
|
1188
1202
|
precision highp sampler3D;
|
1189
1203
|
|
1190
|
-
#include "atmosphere/
|
1191
|
-
|
1204
|
+
#include "atmosphere/bruneton/definitions"
|
1205
|
+
|
1206
|
+
uniform AtmosphereParameters ATMOSPHERE;
|
1207
|
+
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
|
1208
|
+
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
|
1209
|
+
|
1210
|
+
uniform sampler2D transmittance_texture;
|
1211
|
+
uniform sampler3D scattering_texture;
|
1212
|
+
uniform sampler2D irradiance_texture;
|
1213
|
+
uniform sampler3D single_mie_scattering_texture;
|
1214
|
+
uniform sampler3D higher_order_scattering_texture;
|
1215
|
+
|
1216
|
+
#include "atmosphere/bruneton/common"
|
1217
|
+
#include "atmosphere/bruneton/runtime"
|
1218
|
+
|
1192
1219
|
#include "types"
|
1193
1220
|
|
1194
1221
|
uniform mat4 inverseProjectionMatrix;
|
@@ -1218,7 +1245,7 @@ out GroundIrradiance vGroundIrradiance;
|
|
1218
1245
|
out CloudsIrradiance vCloudsIrradiance;
|
1219
1246
|
|
1220
1247
|
void sampleSunSkyIrradiance(const vec3 positionECEF) {
|
1221
|
-
vGroundIrradiance.sun =
|
1248
|
+
vGroundIrradiance.sun = GetSunAndSkyScalarIrradiance(
|
1222
1249
|
positionECEF * METER_TO_LENGTH_UNIT,
|
1223
1250
|
sunDirection,
|
1224
1251
|
vGroundIrradiance.sky
|
@@ -1226,12 +1253,12 @@ void sampleSunSkyIrradiance(const vec3 positionECEF) {
|
|
1226
1253
|
|
1227
1254
|
vec3 surfaceNormal = normalize(positionECEF);
|
1228
1255
|
vec2 radii = (bottomRadius + vec2(minHeight, maxHeight)) * METER_TO_LENGTH_UNIT;
|
1229
|
-
vCloudsIrradiance.minSun =
|
1256
|
+
vCloudsIrradiance.minSun = GetSunAndSkyScalarIrradiance(
|
1230
1257
|
surfaceNormal * radii.x,
|
1231
1258
|
sunDirection,
|
1232
1259
|
vCloudsIrradiance.minSky
|
1233
1260
|
);
|
1234
|
-
vCloudsIrradiance.maxSun =
|
1261
|
+
vCloudsIrradiance.maxSun = GetSunAndSkyScalarIrradiance(
|
1235
1262
|
surfaceNormal * radii.y,
|
1236
1263
|
sunDirection,
|
1237
1264
|
vCloudsIrradiance.maxSky
|
@@ -1266,7 +1293,6 @@ uniform vec3 sunDirection;
|
|
1266
1293
|
// Participating medium
|
1267
1294
|
uniform float scatteringCoefficient;
|
1268
1295
|
uniform float absorptionCoefficient;
|
1269
|
-
uniform vec3 albedo;
|
1270
1296
|
|
1271
1297
|
// Primary raymarch
|
1272
1298
|
uniform float minDensity;
|
@@ -1298,6 +1324,8 @@ uniform float turbulenceDisplacement;
|
|
1298
1324
|
#ifdef HAZE
|
1299
1325
|
uniform float hazeDensityScale;
|
1300
1326
|
uniform float hazeExponent;
|
1327
|
+
uniform float hazeScatteringCoefficient;
|
1328
|
+
uniform float hazeAbsorptionCoefficient;
|
1301
1329
|
#endif // HAZE
|
1302
1330
|
|
1303
1331
|
// Cloud layers
|
@@ -1316,8 +1344,8 @@ uniform float maxHeight;
|
|
1316
1344
|
uniform float shadowTopHeight;
|
1317
1345
|
uniform float shadowBottomHeight;
|
1318
1346
|
uniform vec4 shadowLayerMask;
|
1319
|
-
uniform
|
1320
|
-
`,
|
1347
|
+
uniform CloudDensityProfile densityProfile;
|
1348
|
+
`,V=`struct GroundIrradiance {
|
1321
1349
|
vec3 sun;
|
1322
1350
|
vec3 sky;
|
1323
1351
|
};
|
@@ -1329,13 +1357,13 @@ struct CloudsIrradiance {
|
|
1329
1357
|
vec3 maxSky;
|
1330
1358
|
};
|
1331
1359
|
|
1332
|
-
struct
|
1360
|
+
struct CloudDensityProfile {
|
1333
1361
|
vec4 expTerms;
|
1334
1362
|
vec4 exponents;
|
1335
1363
|
vec4 linearTerms;
|
1336
1364
|
vec4 constantTerms;
|
1337
1365
|
};
|
1338
|
-
`;var
|
1366
|
+
`;var Le=Object.defineProperty,S=(o,e,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(e,t,i)||i);return i&&Le(e,t,i),i};const Ue=new n.Vector3,Re=new u.Geodetic;class g extends H.AtmosphereMaterialBase{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:a},i=H.AtmosphereParameters.DEFAULT){super({name:"CloudsMaterial",glslVersion:n.GLSL3,vertexShader:u.resolveIncludes(Pe,{atmosphere:{bruneton:{common:A.common,definitions:A.definitions,runtime:A.runtime}},types:V}),fragmentShader:u.unrollLoops(u.resolveIncludes(Oe,{core:{depth:y.depth,math:y.math,turbo:y.turbo,generators:y.generators,raySphereIntersection:y.raySphereIntersection,cascadedShadowMaps:y.cascadedShadowMaps,interleavedGradientNoise:y.interleavedGradientNoise,vogelDisk:y.vogelDisk},atmosphere:{bruneton:{common:A.common,definitions:A.definitions,runtime:A.runtime}},types:V,parameters:oe,clouds:re})),uniforms:{...e,...t,...a,depthBuffer:new n.Uniform(null),viewMatrix:new n.Uniform(new n.Matrix4),inverseProjectionMatrix:new n.Uniform(new n.Matrix4),inverseViewMatrix:new n.Uniform(new n.Matrix4),reprojectionMatrix:new n.Uniform(new n.Matrix4),resolution:new n.Uniform(new n.Vector2),cameraNear:new n.Uniform(0),cameraFar:new n.Uniform(0),cameraHeight:new n.Uniform(0),frame:new n.Uniform(0),temporalJitter:new n.Uniform(new n.Vector2),targetUvScale:new n.Uniform(new n.Vector2),mipLevelScale:new n.Uniform(1),stbnTexture:new n.Uniform(null),skyLightScale:new n.Uniform(1),groundBounceScale:new n.Uniform(1),powderScale:new n.Uniform(.8),powderExponent:new n.Uniform(150),maxIterationCount:new n.Uniform(c.clouds.maxIterationCount),minStepSize:new n.Uniform(c.clouds.minStepSize),maxStepSize:new n.Uniform(c.clouds.maxStepSize),maxRayDistance:new n.Uniform(c.clouds.maxRayDistance),perspectiveStepScale:new n.Uniform(c.clouds.perspectiveStepScale),minDensity:new n.Uniform(c.clouds.minDensity),minExtinction:new n.Uniform(c.clouds.minExtinction),minTransmittance:new n.Uniform(c.clouds.minTransmittance),maxIterationCountToSun:new n.Uniform(c.clouds.maxIterationCountToSun),maxIterationCountToGround:new n.Uniform(c.clouds.maxIterationCountToGround),minSecondaryStepSize:new n.Uniform(c.clouds.minSecondaryStepSize),secondaryStepScale:new n.Uniform(c.clouds.secondaryStepScale),shadowBuffer:new n.Uniform(null),shadowTexelSize:new n.Uniform(new n.Vector2),shadowIntervals:new n.Uniform(Array.from({length:4},()=>new n.Vector2)),shadowMatrices:new n.Uniform(Array.from({length:4},()=>new n.Matrix4)),shadowFar:new n.Uniform(0),maxShadowFilterRadius:new n.Uniform(6),shadowLayerMask:new n.Uniform(new n.Vector4().setScalar(1)),maxShadowLengthIterationCount:new n.Uniform(c.clouds.maxShadowLengthIterationCount),minShadowLengthStepSize:new n.Uniform(c.clouds.minShadowLengthStepSize),maxShadowLengthRayDistance:new n.Uniform(c.clouds.maxShadowLengthRayDistance),hazeDensityScale:new n.Uniform(3e-5),hazeExponent:new n.Uniform(.001),hazeScatteringCoefficient:new n.Uniform(.9),hazeAbsorptionCoefficient:new n.Uniform(.5)}},i),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=.7,this.scatterAnisotropy2=-.2,this.scatterAnisotropyMix=.5}onBeforeRender(e,t,a,i,r,s){const l=this.defines.USE_LOGDEPTHBUF!=null,h=e.capabilities.logarithmicDepthBuffer;h!==l&&(h?this.defines.USE_LOGDEPTHBUF="1":delete this.defines.USE_LOGDEPTHBUF);const d=this.defines.POWDER!=null,p=this.uniforms.powderScale.value>0;p!==d&&(p?this.defines.POWDER="1":delete this.defines.POWDER,this.needsUpdate=!0);const f=this.defines.GROUND_BOUNCE!=null;(this.uniforms.groundBounceScale.value>0&&this.uniforms.maxIterationCountToGround.value>0)!==f&&(p?this.defines.GROUND_BOUNCE="1":delete this.defines.GROUND_BOUNCE,this.needsUpdate=!0)}copyCameraSettings(e){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);const t=this.uniforms;t.viewMatrix.value.copy(e.matrixWorldInverse),t.inverseViewMatrix.value.copy(e.matrixWorld);const a=this.previousProjectionMatrix??e.projectionMatrix,i=this.previousViewMatrix??e.matrixWorldInverse,r=t.inverseProjectionMatrix.value,s=t.reprojectionMatrix.value;if(this.temporalUpscale){const d=t.frame.value%16,p=t.resolution.value,f=ie[d],m=(f.x-.5)/p.x*4,v=(f.y-.5)/p.y*4;t.temporalJitter.value.set(m,v),t.mipLevelScale.value=.25,r.copy(e.projectionMatrix),r.elements[8]+=m*2,r.elements[9]+=v*2,r.invert(),s.copy(a),s.elements[8]+=m*2,s.elements[9]+=v*2,s.multiply(i)}else t.temporalJitter.value.setScalar(0),t.mipLevelScale.value=1,r.copy(e.projectionMatrixInverse),s.copy(a).multiply(i);u.assertType(e),t.cameraNear.value=e.near,t.cameraFar.value=e.far;const l=e.getWorldPosition(t.cameraPosition.value),h=Ue.copy(l).applyMatrix4(t.inverseEllipsoidMatrix.value).sub(t.ellipsoidCenter.value);try{t.cameraHeight.value=Re.setFromECEF(h).height}catch{}}copyReprojectionMatrix(e){this.previousProjectionMatrix??(this.previousProjectionMatrix=new n.Matrix4),this.previousViewMatrix??(this.previousViewMatrix=new n.Matrix4),this.previousProjectionMatrix.copy(e.projectionMatrix),this.previousViewMatrix.copy(e.matrixWorldInverse)}setSize(e,t,a,i){this.uniforms.resolution.value.set(e,t),a!=null&&i!=null?this.uniforms.targetUvScale.value.set(e/a,t/i):this.uniforms.targetUvScale.value.setScalar(1),this.previousProjectionMatrix=void 0,this.previousViewMatrix=void 0}setShadowSize(e,t){this.uniforms.shadowTexelSize.value.set(1/e,1/t)}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}get accurateSunSkyIrradiance(){return this.accurateSunSkyLight}set accurateSunSkyIrradiance(e){this.accurateSunSkyLight=e}}S([u.defineInt("DEPTH_PACKING")],g.prototype,"depthPacking");S([u.defineExpression("LOCAL_WEATHER_CHANNELS",{validate:o=>/^[rgba]{4}$/.test(o)})],g.prototype,"localWeatherChannels");S([u.define("SHAPE_DETAIL")],g.prototype,"shapeDetail");S([u.define("TURBULENCE")],g.prototype,"turbulence");S([u.define("SHADOW_LENGTH")],g.prototype,"shadowLength");S([u.define("HAZE")],g.prototype,"haze");S([u.defineInt("MULTI_SCATTERING_OCTAVES",{min:1,max:12})],g.prototype,"multiScatteringOctaves");S([u.define("ACCURATE_SUN_SKY_LIGHT")],g.prototype,"accurateSunSkyLight");S([u.define("ACCURATE_PHASE_FUNCTION")],g.prototype,"accuratePhaseFunction");S([u.defineInt("SHADOW_CASCADE_COUNT",{min:1,max:4})],g.prototype,"shadowCascadeCount");S([u.defineInt("SHADOW_SAMPLE_COUNT",{min:1,max:16})],g.prototype,"shadowSampleCount");S([u.defineFloat("SCATTER_ANISOTROPY_1")],g.prototype,"scatterAnisotropy1");S([u.defineFloat("SCATTER_ANISOTROPY_2")],g.prototype,"scatterAnisotropy2");S([u.defineFloat("SCATTER_ANISOTROPY_MIX")],g.prototype,"scatterAnisotropyMix");const Ie=`// Taken from https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1
|
1339
1367
|
// TODO: Use 5-taps version: https://www.shadertoy.com/view/MtVGWz
|
1340
1368
|
// Or even 4 taps (requires preprocessing in the input buffer):
|
1341
1369
|
// https://www.shadertoy.com/view/4tyGDD
|
@@ -1448,7 +1476,7 @@ vec4 textureCatmullRom(sampler2DArray tex, vec3 uv) {
|
|
1448
1476
|
result += texture(tex, vec3(texPos3.x, texPos3.y, uv.z)) * w3.x * w3.y;
|
1449
1477
|
return result;
|
1450
1478
|
}
|
1451
|
-
`,
|
1479
|
+
`,Me=`precision highp float;
|
1452
1480
|
precision highp sampler2DArray;
|
1453
1481
|
|
1454
1482
|
#include "core/turbo"
|
@@ -1650,7 +1678,7 @@ void main() {
|
|
1650
1678
|
outputColor = vec4(turbo(outputShadowLength * 0.05), 1.0);
|
1651
1679
|
#endif // defined(SHADOW_LENGTH) && defined(DEBUG_SHOW_SHADOW_LENGTH)
|
1652
1680
|
}
|
1653
|
-
`,
|
1681
|
+
`,Ne=`precision highp float;
|
1654
1682
|
|
1655
1683
|
layout(location = 0) in vec3 position;
|
1656
1684
|
|
@@ -1661,7 +1689,7 @@ void main() {
|
|
1661
1689
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
1662
1690
|
}
|
1663
1691
|
`,se=`#ifdef VARIANCE_9_SAMPLES
|
1664
|
-
#define VARIANCE_OFFSET_COUNT
|
1692
|
+
#define VARIANCE_OFFSET_COUNT 8
|
1665
1693
|
const ivec2 varianceOffsets[8] = ivec2[8](
|
1666
1694
|
ivec2(-1, -1),
|
1667
1695
|
ivec2(-1, 1),
|
@@ -1673,7 +1701,7 @@ const ivec2 varianceOffsets[8] = ivec2[8](
|
|
1673
1701
|
ivec2(-1, 0)
|
1674
1702
|
);
|
1675
1703
|
#else // VARIANCE_9_SAMPLES
|
1676
|
-
#define VARIANCE_OFFSET_COUNT
|
1704
|
+
#define VARIANCE_OFFSET_COUNT 4
|
1677
1705
|
const ivec2 varianceOffsets[4] = ivec2[4](ivec2(1, 0), ivec2(0, -1), ivec2(0, 1), ivec2(-1, 0));
|
1678
1706
|
#endif // VARIANCE_9_SAMPLES
|
1679
1707
|
|
@@ -1774,7 +1802,7 @@ vec4 varianceClipping(
|
|
1774
1802
|
) {
|
1775
1803
|
return varianceClipping(inputBuffer, coord, current, history, 1.0);
|
1776
1804
|
}
|
1777
|
-
`;var be=Object.defineProperty,ce=(o,e,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(e,t,i)||i);return i&&be(e,t,i),i};class k extends n.RawShaderMaterial{constructor({colorBuffer:e=null,depthVelocityBuffer:t=null,shadowLengthBuffer:a=null,colorHistoryBuffer:i=null,shadowLengthHistoryBuffer:r=null}={}){super({name:"CloudsResolveMaterial",glslVersion:n.GLSL3,vertexShader:
|
1805
|
+
`;var be=Object.defineProperty,ce=(o,e,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(e,t,i)||i);return i&&be(e,t,i),i};class k extends n.RawShaderMaterial{constructor({colorBuffer:e=null,depthVelocityBuffer:t=null,shadowLengthBuffer:a=null,colorHistoryBuffer:i=null,shadowLengthHistoryBuffer:r=null}={}){super({name:"CloudsResolveMaterial",glslVersion:n.GLSL3,vertexShader:Ne,fragmentShader:u.unrollLoops(u.resolveIncludes(Me,{core:{turbo:y.turbo},catmullRomSampling:Ie,varianceClipping:se})),uniforms:{colorBuffer:new n.Uniform(e),depthVelocityBuffer:new n.Uniform(t),shadowLengthBuffer:new n.Uniform(a),colorHistoryBuffer:new n.Uniform(i),shadowLengthHistoryBuffer:new n.Uniform(r),texelSize:new n.Uniform(new n.Vector2),frame:new n.Uniform(0),jitterOffset:new n.Uniform(new n.Vector2),varianceGamma:new n.Uniform(2),temporalAlpha:new n.Uniform(.1)}}),this.temporalUpscale=!0,this.shadowLength=!0}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}onBeforeRender(e,t,a,i,r,s){const h=this.uniforms.frame.value%16,d=ie[h],p=(d.x-.5)*4,f=(d.y-.5)*4;this.uniforms.jitterOffset.value.set(p,f)}}ce([u.define("TEMPORAL_UPSCALE")],k.prototype,"temporalUpscale");ce([u.define("SHADOW_LENGTH")],k.prototype,"shadowLength");class le extends C.Pass{constructor(e,t){super(e),this._mainCamera=new n.Camera;const{shadow:a}=t;this.shadow=a}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e}}function W(o,{depthVelocity:e,shadowLength:t}){const a=new n.WebGLRenderTarget(1,1,{depthBuffer:!1,type:n.HalfFloatType});a.texture.minFilter=n.LinearFilter,a.texture.magFilter=n.LinearFilter,a.texture.name=o;let i;e&&(i=a.texture.clone(),i.isRenderTargetTexture=!0,a.depthVelocity=i,a.textures.push(i));let r;return t&&(r=a.texture.clone(),r.isRenderTargetTexture=!0,r.format=n.RedFormat,a.shadowLength=r,a.textures.push(r)),Object.assign(a,{depthVelocity:i??null,shadowLength:r??null})}class He extends le{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:a,...i},r){super("CloudsPass",i),this.atmosphere=r,this.width=0,this.height=0,this.currentMaterial=new g({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:a},r),this.currentPass=new C.ShaderPass(this.currentMaterial),this.resolveMaterial=new k,this.resolvePass=new C.ShaderPass(this.resolveMaterial),this.initRenderTargets({depthVelocity:!0,shadowLength:c.lightShafts})}copyCameraSettings(e){this.currentMaterial.copyCameraSettings(e)}initialize(e,t,a){this.currentPass.initialize(e,t,a),this.resolvePass.initialize(e,t,a)}initRenderTargets(e){var s,l,h;(s=this.currentRenderTarget)==null||s.dispose(),(l=this.resolveRenderTarget)==null||l.dispose(),(h=this.historyRenderTarget)==null||h.dispose();const t=W("Clouds",e),a=W("Clouds.A",{...e,depthVelocity:!1}),i=W("Clouds.B",{...e,depthVelocity:!1});this.currentRenderTarget=t,this.resolveRenderTarget=a,this.historyRenderTarget=i;const r=this.resolveMaterial.uniforms;r.colorBuffer.value=t.texture,r.depthVelocityBuffer.value=t.depthVelocity,r.shadowLengthBuffer.value=t.shadowLength,r.colorHistoryBuffer.value=i.texture,r.shadowLengthHistoryBuffer.value=i.shadowLength}copyShadow(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let a=0;a<e.cascadeCount;++a){const i=e.cascades[a];t.shadowIntervals.value[a].copy(i.interval),t.shadowMatrices.value[a].copy(i.matrix)}t.shadowFar.value=e.far}copyReprojection(){this.currentMaterial.copyReprojectionMatrix(this.mainCamera)}swapBuffers(){const e=this.historyRenderTarget,t=this.resolveRenderTarget;this.resolveRenderTarget=e,this.historyRenderTarget=t;const a=this.resolveMaterial.uniforms;a.colorHistoryBuffer.value=t.texture,a.shadowLengthHistoryBuffer.value=t.shadowLength}update(e,t,a){this.currentMaterial.uniforms.frame.value=t,this.resolveMaterial.uniforms.frame.value=t,this.copyCameraSettings(this.mainCamera),this.copyShadow(),this.currentPass.render(e,null,this.currentRenderTarget),this.resolvePass.render(e,null,this.resolveRenderTarget),this.copyReprojection(),this.swapBuffers()}setSize(e,t){if(this.width=e,this.height=t,this.temporalUpscale){const a=Math.ceil(e/4),i=Math.ceil(t/4);this.currentRenderTarget.setSize(a,i),this.currentMaterial.setSize(a*4,i*4,e,t)}else this.currentRenderTarget.setSize(e,t),this.currentMaterial.setSize(e,t);this.resolveRenderTarget.setSize(e,t),this.resolveMaterial.setSize(e,t),this.historyRenderTarget.setSize(e,t)}setShadowSize(e,t,a){this.currentMaterial.shadowCascadeCount=a,this.currentMaterial.setShadowSize(e,t)}setDepthTexture(e,t){this.currentMaterial.depthBuffer=e,this.currentMaterial.depthPacking=t??0}get outputBuffer(){return this.historyRenderTarget.texture}get shadowBuffer(){return this.currentMaterial.uniforms.shadowBuffer.value}set shadowBuffer(e){this.currentMaterial.uniforms.shadowBuffer.value=e}get shadowLengthBuffer(){return this.historyRenderTarget.shadowLength}get temporalUpscale(){return this.currentMaterial.temporalUpscale}set temporalUpscale(e){e!==this.temporalUpscale&&(this.currentMaterial.temporalUpscale=e,this.resolveMaterial.temporalUpscale=e,this.setSize(this.width,this.height))}get lightShafts(){return this.currentMaterial.shadowLength}set lightShafts(e){e!==this.lightShafts&&(this.currentMaterial.shadowLength=e,this.resolveMaterial.shadowLength=e,this.initRenderTargets({depthVelocity:!0,shadowLength:e}),this.setSize(this.width,this.height))}}function Fe(o,e){const a=o.properties.get(e.texture).__webglTexture,i=o.getContext();D(i instanceof WebGL2RenderingContext),o.setRenderTarget(e);const r=[];if(a!=null)for(let s=0;s<e.depth;++s)i.framebufferTextureLayer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+s,a,0,s),r.push(i.COLOR_ATTACHMENT0+s);i.drawBuffers(r)}class ae extends C.ShaderPass{render(e,t,a,i,r){const s=this.fullscreenMaterial.uniforms;t!==null&&(s==null?void 0:s[this.input])!=null&&(s[this.input].value=t.texture),Fe(e,a),e.render(this.scene,this.camera)}}const ze=`precision highp float;
|
1778
1806
|
precision highp sampler3D;
|
1779
1807
|
|
1780
1808
|
#include <common>
|
@@ -1987,7 +2015,7 @@ void main() {
|
|
1987
2015
|
|
1988
2016
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
1989
2017
|
}
|
1990
|
-
`,
|
2018
|
+
`,Be=`// Implements Structured Volume Sampling in fragment shader:
|
1991
2019
|
// https://github.com/huwb/volsample
|
1992
2020
|
// Implementation reference:
|
1993
2021
|
// https://www.shadertoy.com/view/ttVfDc
|
@@ -2088,11 +2116,11 @@ void intersectStructuredPlanes(
|
|
2088
2116
|
stepOffset += stepSize;
|
2089
2117
|
}
|
2090
2118
|
}
|
2091
|
-
`;var
|
2119
|
+
`;var Ge=Object.defineProperty,O=(o,e,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(e,t,i)||i);return i&&Ge(e,t,i),i};class E extends n.RawShaderMaterial{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:a}){super({name:"ShadowMaterial",glslVersion:n.GLSL3,vertexShader:We,fragmentShader:u.unrollLoops(u.resolveIncludes(ze,{core:{math:y.math,raySphereIntersection:y.raySphereIntersection},types:V,parameters:oe,structuredSampling:Be,clouds:re})),uniforms:{...e,...t,...a,inverseShadowMatrices:new n.Uniform(Array.from({length:4},()=>new n.Matrix4)),reprojectionMatrices:new n.Uniform(Array.from({length:4},()=>new n.Matrix4)),resolution:new n.Uniform(new n.Vector2),frame:new n.Uniform(0),stbnTexture:new n.Uniform(null),maxIterationCount:new n.Uniform(c.shadow.maxIterationCount),minStepSize:new n.Uniform(c.shadow.minStepSize),maxStepSize:new n.Uniform(c.shadow.maxStepSize),minDensity:new n.Uniform(c.shadow.minDensity),minExtinction:new n.Uniform(c.shadow.minExtinction),minTransmittance:new n.Uniform(c.shadow.minTransmittance),opticalDepthTailScale:new n.Uniform(2)},defines:{SHADOW:"1",TEMPORAL_PASS:"1",TEMPORAL_JITTER:"1"}}),this.localWeatherChannels="rgba",this.cascadeCount=c.shadow.cascadeCount,this.temporalPass=!0,this.temporalJitter=!0,this.shapeDetail=c.shapeDetail,this.turbulence=c.turbulence,this.cascadeCount=c.shadow.cascadeCount}setSize(e,t){this.uniforms.resolution.value.set(e,t)}}O([u.defineExpression("LOCAL_WEATHER_CHANNELS",{validate:o=>/^[rgba]{4}$/.test(o)})],E.prototype,"localWeatherChannels");O([u.defineInt("CASCADE_COUNT",{min:1,max:4})],E.prototype,"cascadeCount");O([u.define("TEMPORAL_PASS")],E.prototype,"temporalPass");O([u.define("TEMPORAL_JITTER")],E.prototype,"temporalJitter");O([u.define("SHAPE_DETAIL")],E.prototype,"shapeDetail");O([u.define("TURBULENCE")],E.prototype,"turbulence");const Ve=`precision highp float;
|
2092
2120
|
precision highp sampler2DArray;
|
2093
2121
|
|
2094
|
-
#define VARIANCE_9_SAMPLES
|
2095
|
-
#define VARIANCE_SAMPLER_ARRAY
|
2122
|
+
#define VARIANCE_9_SAMPLES 1
|
2123
|
+
#define VARIANCE_SAMPLER_ARRAY 1
|
2096
2124
|
|
2097
2125
|
#include "varianceClipping"
|
2098
2126
|
|
@@ -2174,7 +2202,7 @@ void main() {
|
|
2174
2202
|
vUv = position.xy * 0.5 + 0.5;
|
2175
2203
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
2176
2204
|
}
|
2177
|
-
`;var je=Object.defineProperty,Ye=(o,e,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(e,t,i)||i);return i&&je(e,t,i),i};class ue extends n.RawShaderMaterial{constructor({inputBuffer:e=null,historyBuffer:t=null}={}){super({name:"ShadowResolveMaterial",glslVersion:n.GLSL3,vertexShader:ke,fragmentShader:u.unrollLoops(u.resolveIncludes(
|
2205
|
+
`;var je=Object.defineProperty,Ye=(o,e,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(e,t,i)||i);return i&&je(e,t,i),i};class ue extends n.RawShaderMaterial{constructor({inputBuffer:e=null,historyBuffer:t=null}={}){super({name:"ShadowResolveMaterial",glslVersion:n.GLSL3,vertexShader:ke,fragmentShader:u.unrollLoops(u.resolveIncludes(Ve,{varianceClipping:se})),uniforms:{inputBuffer:new n.Uniform(e),historyBuffer:new n.Uniform(t),texelSize:new n.Uniform(new n.Vector2),varianceGamma:new n.Uniform(1),temporalAlpha:new n.Uniform(.01)},defines:{}}),this.cascadeCount=c.shadow.cascadeCount}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}}Ye([u.defineInt("CASCADE_COUNT",{min:1,max:4})],ue.prototype,"cascadeCount");function B(o){const e=new n.WebGLArrayRenderTarget(1,1,1,{depthBuffer:!1});return e.texture.type=n.HalfFloatType,e.texture.minFilter=n.LinearFilter,e.texture.magFilter=n.LinearFilter,e.texture.name=o,e}class qe extends le{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:a,...i}){super("ShadowPass",i),this.width=0,this.height=0,this.currentMaterial=new E({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:a}),this.currentPass=new ae(this.currentMaterial),this.resolveMaterial=new ue,this.resolvePass=new ae(this.resolveMaterial),this.initRenderTargets()}initialize(e,t,a){this.currentPass.initialize(e,t,a),this.resolvePass.initialize(e,t,a)}initRenderTargets(){var r,s,l;(r=this.currentRenderTarget)==null||r.dispose(),(s=this.resolveRenderTarget)==null||s.dispose(),(l=this.historyRenderTarget)==null||l.dispose();const e=B("Shadow"),t=this.temporalPass?B("Shadow.A"):null,a=this.temporalPass?B("Shadow.B"):null;this.currentRenderTarget=e,this.resolveRenderTarget=t,this.historyRenderTarget=a;const i=this.resolveMaterial.uniforms;i.inputBuffer.value=e.texture,i.historyBuffer.value=(a==null?void 0:a.texture)??null}copyShadow(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let a=0;a<e.cascadeCount;++a){const i=e.cascades[a];t.inverseShadowMatrices.value[a].copy(i.inverseMatrix)}}copyReprojection(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let a=0;a<e.cascadeCount;++a){const i=e.cascades[a];t.reprojectionMatrices.value[a].copy(i.matrix)}}swapBuffers(){D(this.historyRenderTarget!=null),D(this.resolveRenderTarget!=null);const e=this.historyRenderTarget,t=this.resolveRenderTarget;this.resolveRenderTarget=e,this.historyRenderTarget=t,this.resolveMaterial.uniforms.historyBuffer.value=t.texture}update(e,t,a){this.currentMaterial.uniforms.frame.value=t,this.copyShadow(),this.currentPass.render(e,null,this.currentRenderTarget),this.temporalPass&&(D(this.resolveRenderTarget!=null),this.resolvePass.render(e,null,this.resolveRenderTarget),this.copyReprojection(),this.swapBuffers())}setSize(e,t,a=this.shadow.cascadeCount){var i,r;this.width=e,this.height=t,this.currentMaterial.cascadeCount=a,this.resolveMaterial.cascadeCount=a,this.currentMaterial.setSize(e,t),this.resolveMaterial.setSize(e,t),this.currentRenderTarget.setSize(e,t,this.temporalPass?a*2:a),(i=this.resolveRenderTarget)==null||i.setSize(e,t,a),(r=this.historyRenderTarget)==null||r.setSize(e,t,a)}get outputBuffer(){return this.temporalPass?(D(this.historyRenderTarget!=null),this.historyRenderTarget.texture):this.currentRenderTarget.texture}get temporalPass(){return this.currentMaterial.temporalPass}set temporalPass(e){e!==this.temporalPass&&(this.currentMaterial.temporalPass=e,this.initRenderTargets(),this.setSize(this.width,this.height))}}function Ze(o){return{scatteringCoefficient:new n.Uniform(1),absorptionCoefficient:new n.Uniform(0),coverage:new n.Uniform(.3),localWeatherTexture:new n.Uniform(o.localWeatherTexture),localWeatherRepeat:new n.Uniform(o.localWeatherRepeat),localWeatherOffset:new n.Uniform(o.localWeatherOffset),shapeTexture:new n.Uniform(o.shapeTexture),shapeRepeat:new n.Uniform(o.shapeRepeat),shapeOffset:new n.Uniform(o.shapeOffset),shapeDetailTexture:new n.Uniform(o.shapeDetailTexture),shapeDetailRepeat:new n.Uniform(o.shapeDetailRepeat),shapeDetailOffset:new n.Uniform(o.shapeDetailOffset),turbulenceTexture:new n.Uniform(o.turbulenceTexture),turbulenceRepeat:new n.Uniform(o.turbulenceRepeat),turbulenceDisplacement:new n.Uniform(350)}}function Ke(){return{minLayerHeights:new n.Uniform(new n.Vector4),maxLayerHeights:new n.Uniform(new n.Vector4),minIntervalHeights:new n.Uniform(new n.Vector3),maxIntervalHeights:new n.Uniform(new n.Vector3),densityScales:new n.Uniform(new n.Vector4),shapeAmounts:new n.Uniform(new n.Vector4),shapeDetailAmounts:new n.Uniform(new n.Vector4),weatherExponents:new n.Uniform(new n.Vector4),shapeAlteringBiases:new n.Uniform(new n.Vector4),coverageFilterWidths:new n.Uniform(new n.Vector4),minHeight:new n.Uniform(0),maxHeight:new n.Uniform(0),shadowTopHeight:new n.Uniform(0),shadowBottomHeight:new n.Uniform(0),shadowLayerMask:new n.Uniform(new n.Vector4),densityProfile:new n.Uniform({expTerms:new n.Vector4,exponents:new n.Vector4,linearTerms:new n.Vector4,constantTerms:new n.Vector4})}}const G=[0,0,0,0];function Xe(o,e){e.packValues("altitude",o.minLayerHeights.value),e.packSums("altitude","height",o.maxLayerHeights.value),e.packIntervalHeights(o.minIntervalHeights.value,o.maxIntervalHeights.value),e.packValues("densityScale",o.densityScales.value),e.packValues("shapeAmount",o.shapeAmounts.value),e.packValues("shapeDetailAmount",o.shapeDetailAmounts.value),e.packValues("weatherExponent",o.weatherExponents.value),e.packValues("shapeAlteringBias",o.shapeAlteringBiases.value),e.packValues("coverageFilterWidth",o.coverageFilterWidths.value);const t=o.densityProfile.value;e.packDensityProfiles("expTerm",t.expTerms),e.packDensityProfiles("exponent",t.exponents),e.packDensityProfiles("linearTerm",t.linearTerms),e.packDensityProfiles("constantTerm",t.constantTerms);let a=1/0,i=0,r=1/0,s=0;G.fill(0);for(let l=0;l<e.length;++l){const{altitude:h,height:d,shadow:p}=e[l],f=h+d;d>0&&(h<a&&(a=h),p&&h<r&&(r=h),f>i&&(i=f),p&&f>s&&(s=f)),G[l]=p?1:0}a!==1/0?(o.minHeight.value=a,o.maxHeight.value=i):(D(i===0),o.minHeight.value=0),r!==1/0?(o.shadowBottomHeight.value=r,o.shadowTopHeight.value=s):(D(s===0),o.shadowBottomHeight.value=0),o.shadowLayerMask.value.fromArray(G)}function $e(o,e){return{bottomRadius:new n.Uniform(o.bottomRadius),topRadius:new n.Uniform(o.topRadius),ellipsoidCenter:new n.Uniform(e.ellipsoidCenter),ellipsoidMatrix:new n.Uniform(e.ellipsoidMatrix),inverseEllipsoidMatrix:new n.Uniform(e.inverseEllipsoidMatrix),altitudeCorrection:new n.Uniform(e.altitudeCorrection),sunDirection:new n.Uniform(e.sunDirection)}}const Je=`uniform sampler2D cloudsBuffer;
|
2178
2206
|
|
2179
2207
|
void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
|
2180
2208
|
#ifdef SKIP_RENDERING
|
@@ -2185,5 +2213,5 @@ void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
|
|
2185
2213
|
outputColor.a = inputColor.a * (1.0 - clouds.a) + clouds.a;
|
2186
2214
|
#endif // SKIP_RENDERING
|
2187
2215
|
}
|
2188
|
-
`;var Qe=Object.defineProperty,et=(o,e,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(e,t,i)||i);return i&&Qe(e,t,i),i};const O=new n.Vector3,tt=new n.Vector2,nt=["maxIterationCount","minStepSize","maxStepSize","maxRayDistance","perspectiveStepScale","minDensity","minExtinction","minTransmittance","maxIterationCountToSun","maxIterationCountToGround","minSecondaryStepSize","secondaryStepScale","maxShadowFilterRadius","maxShadowLengthIterationCount","minShadowLengthStepSize","maxShadowLengthRayDistance","hazeDensityScale","hazeExponent"],at=["multiScatteringOctaves","accurateSunSkyIrradiance","accuratePhaseFunction"],it=["maxIterationCount","minStepSize","maxStepSize","minDensity","minExtinction","minTransmittance","opticalDepthTailScale"],rt=["temporalJitter"],ot=["temporalPass"],st=["cascadeCount","mapSize","maxFar","farScale","splitMode","splitLambda"],w={type:"change"},he={resolutionScale:l.resolutionScale,width:C.Resolution.AUTO_SIZE,height:C.Resolution.AUTO_SIZE};class de extends C.Effect{constructor(e=new n.Camera,t,a=H.AtmosphereParameters.DEFAULT){var p,f,m,v;super("CloudsEffect",Je,{attributes:C.EffectAttribute.DEPTH,uniforms:new Map([["cloudsBuffer",new n.Uniform(null)]])}),this.camera=e,this.atmosphere=a,this.cloudLayers=F.DEFAULT.clone(),this.correctAltitude=!0,this.localWeatherRepeat=new n.Vector2().setScalar(100),this.localWeatherOffset=new n.Vector2,this.shapeRepeat=new n.Vector3().setScalar(3e-4),this.shapeOffset=new n.Vector3,this.shapeDetailRepeat=new n.Vector3().setScalar(.006),this.shapeDetailOffset=new n.Vector3,this.turbulenceRepeat=new n.Vector2().setScalar(20),this.ellipsoidCenter=new n.Vector3,this.ellipsoidMatrix=new n.Matrix4,this.inverseEllipsoidMatrix=new n.Matrix4,this.altitudeCorrection=new n.Vector3,this.sunDirection=new n.Vector3,this.localWeatherVelocity=new n.Vector2,this.shapeVelocity=new n.Vector3,this.shapeDetailVelocity=new n.Vector3,this._atmosphereOverlay=null,this._atmosphereShadow=null,this._atmosphereShadowLength=null,this.events=new n.EventDispatcher,this.frame=0,this.shadowCascadeCount=0,this.shadowMapSize=new n.Vector2,this.onResolutionChange=()=>{this.setSize(this.resolution.baseWidth,this.resolution.baseHeight)},this.skipRendering=!0;const{resolutionScale:i,width:r,height:s,resolutionX:c=r,resolutionY:h=s}={...he,...t};this.shadowMaps=new Ee({cascadeCount:l.shadow.cascadeCount,mapSize:l.shadow.mapSize,splitLambda:.6}),this.parameterUniforms=Ze({localWeatherTexture:((p=this.proceduralLocalWeather)==null?void 0:p.texture)??null,localWeatherRepeat:this.localWeatherRepeat,localWeatherOffset:this.localWeatherOffset,shapeTexture:((f=this.proceduralShape)==null?void 0:f.texture)??null,shapeRepeat:this.shapeRepeat,shapeOffset:this.shapeOffset,shapeDetailTexture:((m=this.proceduralShapeDetail)==null?void 0:m.texture)??null,shapeDetailRepeat:this.shapeDetailRepeat,shapeDetailOffset:this.shapeDetailOffset,turbulenceTexture:((v=this.proceduralTurbulence)==null?void 0:v.texture)??null,turbulenceRepeat:this.turbulenceRepeat}),this.layerUniforms=Ke(),this.atmosphereUniforms=$e(a,{ellipsoidCenter:this.ellipsoidCenter,ellipsoidMatrix:this.ellipsoidMatrix,inverseEllipsoidMatrix:this.inverseEllipsoidMatrix,altitudeCorrection:this.altitudeCorrection,sunDirection:this.sunDirection});const d={shadow:this.shadowMaps,parameterUniforms:this.parameterUniforms,layerUniforms:this.layerUniforms,atmosphereUniforms:this.atmosphereUniforms};this.shadowPass=new qe(d),this.shadowPass.mainCamera=e,this.cloudsPass=new He(d,a),this.cloudsPass.mainCamera=e,this.clouds=u.definePropertyShorthand(u.defineUniformShorthand({},this.cloudsPass.currentMaterial,nt),this.cloudsPass.currentMaterial,at),this.shadow=u.definePropertyShorthand(u.defineUniformShorthand({},this.shadowPass.currentMaterial,it),this.shadowPass.currentMaterial,rt,this.shadowPass,ot,this.shadowMaps,st),this.resolution=new C.Resolution(this,c,h,i),this.resolution.addEventListener("change",this.onResolutionChange)}get mainCamera(){return this.camera}set mainCamera(e){this.camera=e,this.shadowPass.mainCamera=e,this.cloudsPass.mainCamera=e}initialize(e,t,a){this.shadowPass.initialize(e,t,a),this.cloudsPass.initialize(e,t,a)}updateSharedUniforms(e){Xe(this.layerUniforms,this.cloudLayers);const{parameterUniforms:t}=this;t.localWeatherOffset.value.add(tt.copy(this.localWeatherVelocity).multiplyScalar(e)),t.shapeOffset.value.add(O.copy(this.shapeVelocity).multiplyScalar(e)),t.shapeDetailOffset.value.add(O.copy(this.shapeDetailVelocity).multiplyScalar(e));const a=this.inverseEllipsoidMatrix.copy(this.ellipsoidMatrix).invert(),i=this.camera.getWorldPosition(O).applyMatrix4(a).sub(this.ellipsoidCenter),r=this.altitudeCorrection;this.correctAltitude?H.getAltitudeCorrectionOffset(i,this.atmosphere.bottomRadius,this.ellipsoid,r,!1):r.setScalar(0);const s=this.ellipsoid.getSurfaceNormal(i,O),c=this.sunDirection.dot(s),h=u.lerp(1e6,1e3,c);this.shadowMaps.update(this.camera,O.copy(this.sunDirection).applyMatrix4(this.ellipsoidMatrix),h)}updateWeatherTextureChannels(){const e=this.cloudLayers.localWeatherChannels;this.cloudsPass.currentMaterial.localWeatherChannels=e,this.shadowPass.currentMaterial.localWeatherChannels=e}updateAtmosphereComposition(){const{shadowMaps:e,shadowPass:t,cloudsPass:a}=this,i=t.currentMaterial.uniforms,r=a.currentMaterial.uniforms,s=this._atmosphereOverlay,c=Object.assign(this._atmosphereOverlay??{},{map:a.outputBuffer});s!==c&&(this._atmosphereOverlay=c,w.target=this,w.property="atmosphereOverlay",this.events.dispatchEvent(w));const h=this._atmosphereShadow,d=Object.assign(this._atmosphereShadow??{},{map:t.outputBuffer,mapSize:e.mapSize,cascadeCount:e.cascadeCount,intervals:r.shadowIntervals.value,matrices:r.shadowMatrices.value,inverseMatrices:i.inverseShadowMatrices.value,far:e.far,topHeight:r.shadowTopHeight.value});h!==d&&(this._atmosphereShadow=d,w.target=this,w.property="atmosphereShadow",this.events.dispatchEvent(w));const p=this._atmosphereShadowLength,f=a.shadowLengthBuffer!=null?Object.assign(this._atmosphereShadowLength??{},{map:a.shadowLengthBuffer}):null;p!==f&&(this._atmosphereShadowLength=f,w.target=this,w.property="atmosphereShadowLength",this.events.dispatchEvent(w))}update(e,t,a=0){var c,h,d,p;const{shadowMaps:i,shadowPass:r,cloudsPass:s}=this;if(i.cascadeCount!==this.shadowCascadeCount||!i.mapSize.equals(this.shadowMapSize)){const{width:f,height:m}=i.mapSize,v=i.cascadeCount;this.shadowMapSize.set(f,m),this.shadowCascadeCount=v,r.setSize(f,m,v),s.setShadowSize(f,m,v)}(c=this.proceduralLocalWeather)==null||c.render(e,a),(h=this.proceduralShape)==null||h.render(e,a),(d=this.proceduralShapeDetail)==null||d.render(e,a),(p=this.proceduralTurbulence)==null||p.render(e,a),++this.frame,this.updateSharedUniforms(a),this.updateWeatherTextureChannels(),r.update(e,this.frame,a),s.shadowBuffer=r.outputBuffer,s.update(e,this.frame,a),this.updateAtmosphereComposition(),this.uniforms.get("cloudsBuffer").value=this.cloudsPass.outputBuffer}setSize(e,t){const{resolution:a}=this;a.setBaseSize(e,t);const{width:i,height:r}=a;this.cloudsPass.setSize(i,r)}setDepthTexture(e,t){this.shadowPass.setDepthTexture(e,t),this.cloudsPass.setDepthTexture(e,t)}set qualityPreset(e){const{clouds:t,shadow:a,...i}=_e[e];Object.assign(this,i),Object.assign(this.clouds,t),Object.assign(this.shadow,a)}get localWeatherTexture(){return this.proceduralLocalWeather??this.parameterUniforms.localWeatherTexture.value}set localWeatherTexture(e){e instanceof n.Texture||e==null?(this.proceduralLocalWeather=void 0,this.parameterUniforms.localWeatherTexture.value=e):(this.proceduralLocalWeather=e,this.parameterUniforms.localWeatherTexture.value=e.texture)}get shapeTexture(){return this.proceduralShape??this.parameterUniforms.shapeTexture.value}set shapeTexture(e){e instanceof n.Data3DTexture||e==null?(this.proceduralShape=void 0,this.parameterUniforms.shapeTexture.value=e):(this.proceduralShape=e,this.parameterUniforms.shapeTexture.value=e.texture)}get shapeDetailTexture(){return this.proceduralShapeDetail??this.parameterUniforms.shapeDetailTexture.value}set shapeDetailTexture(e){e instanceof n.Data3DTexture||e==null?(this.proceduralShapeDetail=void 0,this.parameterUniforms.shapeDetailTexture.value=e):(this.proceduralShapeDetail=e,this.parameterUniforms.shapeDetailTexture.value=e.texture)}get turbulenceTexture(){return this.proceduralTurbulence??this.parameterUniforms.turbulenceTexture.value}set turbulenceTexture(e){e instanceof n.Texture||e==null?(this.proceduralTurbulence=void 0,this.parameterUniforms.turbulenceTexture.value=e):(this.proceduralTurbulence=e,this.parameterUniforms.turbulenceTexture.value=e.texture)}get stbnTexture(){return this.cloudsPass.currentMaterial.uniforms.stbnTexture.value}set stbnTexture(e){this.cloudsPass.currentMaterial.uniforms.stbnTexture.value=e,this.shadowPass.currentMaterial.uniforms.stbnTexture.value=e}get resolutionScale(){return this.resolution.scale}set resolutionScale(e){this.resolution.scale=e}get temporalUpscale(){return this.cloudsPass.temporalUpscale}set temporalUpscale(e){this.cloudsPass.temporalUpscale=e}get lightShafts(){return this.cloudsPass.lightShafts}set lightShafts(e){this.cloudsPass.lightShafts=e}get shapeDetail(){return this.cloudsPass.currentMaterial.shapeDetail}set shapeDetail(e){this.cloudsPass.currentMaterial.shapeDetail=e,this.shadowPass.currentMaterial.shapeDetail=e}get turbulence(){return this.cloudsPass.currentMaterial.turbulence}set turbulence(e){this.cloudsPass.currentMaterial.turbulence=e,this.shadowPass.currentMaterial.turbulence=e}get haze(){return this.cloudsPass.currentMaterial.haze}set haze(e){this.cloudsPass.currentMaterial.haze=e}get scatteringCoefficient(){return this.parameterUniforms.scatteringCoefficient.value}set scatteringCoefficient(e){this.parameterUniforms.scatteringCoefficient.value=e}get absorptionCoefficient(){return this.parameterUniforms.absorptionCoefficient.value}set absorptionCoefficient(e){this.parameterUniforms.absorptionCoefficient.value=e}get coverage(){return this.parameterUniforms.coverage.value}set coverage(e){this.parameterUniforms.coverage.value=e}get turbulenceDisplacement(){return this.parameterUniforms.turbulenceDisplacement.value}set turbulenceDisplacement(e){this.parameterUniforms.turbulenceDisplacement.value=e}get scatterAnisotropy1(){return this.cloudsPass.currentMaterial.scatterAnisotropy1}set scatterAnisotropy1(e){this.cloudsPass.currentMaterial.scatterAnisotropy1=e}get scatterAnisotropy2(){return this.cloudsPass.currentMaterial.scatterAnisotropy2}set scatterAnisotropy2(e){this.cloudsPass.currentMaterial.scatterAnisotropy2=e}get scatterAnisotropyMix(){return this.cloudsPass.currentMaterial.scatterAnisotropyMix}set scatterAnisotropyMix(e){this.cloudsPass.currentMaterial.scatterAnisotropyMix=e}get skyIrradianceScale(){return this.cloudsPass.currentMaterial.uniforms.skyIrradianceScale.value}set skyIrradianceScale(e){this.cloudsPass.currentMaterial.uniforms.skyIrradianceScale.value=e}get groundIrradianceScale(){return this.cloudsPass.currentMaterial.uniforms.groundIrradianceScale.value}set groundIrradianceScale(e){this.cloudsPass.currentMaterial.uniforms.groundIrradianceScale.value=e}get powderScale(){return this.cloudsPass.currentMaterial.uniforms.powderScale.value}set powderScale(e){this.cloudsPass.currentMaterial.uniforms.powderScale.value=e}get powderExponent(){return this.cloudsPass.currentMaterial.uniforms.powderExponent.value}set powderExponent(e){this.cloudsPass.currentMaterial.uniforms.powderExponent.value=e}get atmosphereOverlay(){return this._atmosphereOverlay}get atmosphereShadow(){return this._atmosphereShadow}get atmosphereShadowLength(){return this._atmosphereShadowLength}get irradianceTexture(){return this.cloudsPass.currentMaterial.irradianceTexture}set irradianceTexture(e){this.cloudsPass.currentMaterial.irradianceTexture=e}get scatteringTexture(){return this.cloudsPass.currentMaterial.scatteringTexture}set scatteringTexture(e){this.cloudsPass.currentMaterial.scatteringTexture=e}get transmittanceTexture(){return this.cloudsPass.currentMaterial.transmittanceTexture}set transmittanceTexture(e){this.cloudsPass.currentMaterial.transmittanceTexture=e}get ellipsoid(){return this.cloudsPass.currentMaterial.ellipsoid}set ellipsoid(e){this.cloudsPass.currentMaterial.ellipsoid=e}get photometric(){return this.cloudsPass.currentMaterial.photometric}set photometric(e){this.cloudsPass.currentMaterial.photometric=e}get sunAngularRadius(){return this.cloudsPass.currentMaterial.sunAngularRadius}set sunAngularRadius(e){this.cloudsPass.currentMaterial.sunAngularRadius=e}}et([u.define("SKIP_RENDERING")],de.prototype,"skipRendering");const ct=128,lt=32,z="45a1c6c1bb9fd38b3680fd120795ff4c32df68ff",ut=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${z}/packages/clouds/assets/local_weather.png`,ht=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${z}/packages/clouds/assets/shape.bin`,dt=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${z}/packages/clouds/assets/shape_detail.bin`,pt=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${z}/packages/clouds/assets/turbulence.png`;exports.CLOUD_SHAPE_DETAIL_TEXTURE_SIZE=lt;exports.CLOUD_SHAPE_TEXTURE_SIZE=ct;exports.CloudLayer=x;exports.CloudLayers=F;exports.CloudsEffect=de;exports.DEFAULT_LOCAL_WEATHER_URL=ut;exports.DEFAULT_SHAPE_DETAIL_URL=dt;exports.DEFAULT_SHAPE_URL=ht;exports.DEFAULT_TURBULENCE_URL=pt;exports.DensityProfile=I;exports.cloudsPassOptionsDefaults=he;
|
2216
|
+
`;var Qe=Object.defineProperty,et=(o,e,t,a)=>{for(var i=void 0,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=s(e,t,i)||i);return i&&Qe(e,t,i),i};const L=new n.Vector3,tt=new n.Vector2,nt=["maxIterationCount","minStepSize","maxStepSize","maxRayDistance","perspectiveStepScale","minDensity","minExtinction","minTransmittance","maxIterationCountToSun","maxIterationCountToGround","minSecondaryStepSize","secondaryStepScale","maxShadowFilterRadius","maxShadowLengthIterationCount","minShadowLengthStepSize","maxShadowLengthRayDistance","hazeDensityScale","hazeExponent","hazeScatteringCoefficient","hazeAbsorptionCoefficient"],at=["multiScatteringOctaves","accurateSunSkyLight","accuratePhaseFunction"],it=["maxIterationCount","minStepSize","maxStepSize","minDensity","minExtinction","minTransmittance","opticalDepthTailScale"],rt=["temporalJitter"],ot=["temporalPass"],st=["cascadeCount","mapSize","maxFar","farScale","splitMode","splitLambda"],w={type:"change"},he={resolutionScale:c.resolutionScale,width:C.Resolution.AUTO_SIZE,height:C.Resolution.AUTO_SIZE};class de extends C.Effect{constructor(e=new n.Camera,t,a=H.AtmosphereParameters.DEFAULT){var p,f,m,v;super("CloudsEffect",Je,{attributes:C.EffectAttribute.DEPTH,uniforms:new Map([["cloudsBuffer",new n.Uniform(null)]])}),this.camera=e,this.atmosphere=a,this.cloudLayers=F.DEFAULT.clone(),this.correctAltitude=!0,this.localWeatherRepeat=new n.Vector2().setScalar(100),this.localWeatherOffset=new n.Vector2,this.shapeRepeat=new n.Vector3().setScalar(3e-4),this.shapeOffset=new n.Vector3,this.shapeDetailRepeat=new n.Vector3().setScalar(.006),this.shapeDetailOffset=new n.Vector3,this.turbulenceRepeat=new n.Vector2().setScalar(20),this.ellipsoidCenter=new n.Vector3,this.ellipsoidMatrix=new n.Matrix4,this.inverseEllipsoidMatrix=new n.Matrix4,this.altitudeCorrection=new n.Vector3,this.sunDirection=new n.Vector3,this.localWeatherVelocity=new n.Vector2,this.shapeVelocity=new n.Vector3,this.shapeDetailVelocity=new n.Vector3,this._atmosphereOverlay=null,this._atmosphereShadow=null,this._atmosphereShadowLength=null,this.events=new n.EventDispatcher,this.frame=0,this.shadowCascadeCount=0,this.shadowMapSize=new n.Vector2,this.onResolutionChange=()=>{this.setSize(this.resolution.baseWidth,this.resolution.baseHeight)},this.skipRendering=!0;const{resolutionScale:i,width:r,height:s,resolutionX:l=r,resolutionY:h=s}={...he,...t};this.shadowMaps=new Ee({cascadeCount:c.shadow.cascadeCount,mapSize:c.shadow.mapSize,splitLambda:.6}),this.parameterUniforms=Ze({localWeatherTexture:((p=this.proceduralLocalWeather)==null?void 0:p.texture)??null,localWeatherRepeat:this.localWeatherRepeat,localWeatherOffset:this.localWeatherOffset,shapeTexture:((f=this.proceduralShape)==null?void 0:f.texture)??null,shapeRepeat:this.shapeRepeat,shapeOffset:this.shapeOffset,shapeDetailTexture:((m=this.proceduralShapeDetail)==null?void 0:m.texture)??null,shapeDetailRepeat:this.shapeDetailRepeat,shapeDetailOffset:this.shapeDetailOffset,turbulenceTexture:((v=this.proceduralTurbulence)==null?void 0:v.texture)??null,turbulenceRepeat:this.turbulenceRepeat}),this.layerUniforms=Ke(),this.atmosphereUniforms=$e(a,{ellipsoidCenter:this.ellipsoidCenter,ellipsoidMatrix:this.ellipsoidMatrix,inverseEllipsoidMatrix:this.inverseEllipsoidMatrix,altitudeCorrection:this.altitudeCorrection,sunDirection:this.sunDirection});const d={shadow:this.shadowMaps,parameterUniforms:this.parameterUniforms,layerUniforms:this.layerUniforms,atmosphereUniforms:this.atmosphereUniforms};this.shadowPass=new qe(d),this.shadowPass.mainCamera=e,this.cloudsPass=new He(d,a),this.cloudsPass.mainCamera=e,this.clouds=u.definePropertyShorthand(u.defineUniformShorthand({},this.cloudsPass.currentMaterial,nt),this.cloudsPass.currentMaterial,at),this.shadow=u.definePropertyShorthand(u.defineUniformShorthand({},this.shadowPass.currentMaterial,it),this.shadowPass.currentMaterial,rt,this.shadowPass,ot,this.shadowMaps,st),this.resolution=new C.Resolution(this,l,h,i),this.resolution.addEventListener("change",this.onResolutionChange)}get mainCamera(){return this.camera}set mainCamera(e){this.camera=e,this.shadowPass.mainCamera=e,this.cloudsPass.mainCamera=e}initialize(e,t,a){this.shadowPass.initialize(e,t,a),this.cloudsPass.initialize(e,t,a)}updateSharedUniforms(e){Xe(this.layerUniforms,this.cloudLayers);const{parameterUniforms:t}=this;t.localWeatherOffset.value.add(tt.copy(this.localWeatherVelocity).multiplyScalar(e)),t.shapeOffset.value.add(L.copy(this.shapeVelocity).multiplyScalar(e)),t.shapeDetailOffset.value.add(L.copy(this.shapeDetailVelocity).multiplyScalar(e));const a=this.inverseEllipsoidMatrix.copy(this.ellipsoidMatrix).invert(),i=this.camera.getWorldPosition(L).applyMatrix4(a).sub(this.ellipsoidCenter),r=this.altitudeCorrection;this.correctAltitude?H.getAltitudeCorrectionOffset(i,this.atmosphere.bottomRadius,this.ellipsoid,r,!1):r.setScalar(0);const s=this.ellipsoid.getSurfaceNormal(i,L),l=this.sunDirection.dot(s),h=u.lerp(1e6,1e3,l);this.shadowMaps.update(this.camera,L.copy(this.sunDirection).applyMatrix4(this.ellipsoidMatrix),h)}updateWeatherTextureChannels(){const e=this.cloudLayers.localWeatherChannels;this.cloudsPass.currentMaterial.localWeatherChannels=e,this.shadowPass.currentMaterial.localWeatherChannels=e}updateAtmosphereComposition(){const{shadowMaps:e,shadowPass:t,cloudsPass:a}=this,i=t.currentMaterial.uniforms,r=a.currentMaterial.uniforms,s=this._atmosphereOverlay,l=Object.assign(this._atmosphereOverlay??{},{map:a.outputBuffer});s!==l&&(this._atmosphereOverlay=l,w.target=this,w.property="atmosphereOverlay",this.events.dispatchEvent(w));const h=this._atmosphereShadow,d=Object.assign(this._atmosphereShadow??{},{map:t.outputBuffer,mapSize:e.mapSize,cascadeCount:e.cascadeCount,intervals:r.shadowIntervals.value,matrices:r.shadowMatrices.value,inverseMatrices:i.inverseShadowMatrices.value,far:e.far,topHeight:r.shadowTopHeight.value});h!==d&&(this._atmosphereShadow=d,w.target=this,w.property="atmosphereShadow",this.events.dispatchEvent(w));const p=this._atmosphereShadowLength,f=a.shadowLengthBuffer!=null?Object.assign(this._atmosphereShadowLength??{},{map:a.shadowLengthBuffer}):null;p!==f&&(this._atmosphereShadowLength=f,w.target=this,w.property="atmosphereShadowLength",this.events.dispatchEvent(w))}update(e,t,a=0){var l,h,d,p;const{shadowMaps:i,shadowPass:r,cloudsPass:s}=this;if(i.cascadeCount!==this.shadowCascadeCount||!i.mapSize.equals(this.shadowMapSize)){const{width:f,height:m}=i.mapSize,v=i.cascadeCount;this.shadowMapSize.set(f,m),this.shadowCascadeCount=v,r.setSize(f,m,v),s.setShadowSize(f,m,v)}(l=this.proceduralLocalWeather)==null||l.render(e,a),(h=this.proceduralShape)==null||h.render(e,a),(d=this.proceduralShapeDetail)==null||d.render(e,a),(p=this.proceduralTurbulence)==null||p.render(e,a),++this.frame,this.updateSharedUniforms(a),this.updateWeatherTextureChannels(),r.update(e,this.frame,a),s.shadowBuffer=r.outputBuffer,s.update(e,this.frame,a),this.updateAtmosphereComposition(),this.uniforms.get("cloudsBuffer").value=this.cloudsPass.outputBuffer}setSize(e,t){const{resolution:a}=this;a.setBaseSize(e,t);const{width:i,height:r}=a;this.cloudsPass.setSize(i,r)}setDepthTexture(e,t){this.shadowPass.setDepthTexture(e,t),this.cloudsPass.setDepthTexture(e,t)}set qualityPreset(e){const{clouds:t,shadow:a,...i}=_e[e];Object.assign(this,i),Object.assign(this.clouds,t),Object.assign(this.shadow,a)}get localWeatherTexture(){return this.proceduralLocalWeather??this.parameterUniforms.localWeatherTexture.value}set localWeatherTexture(e){e instanceof n.Texture||e==null?(this.proceduralLocalWeather=void 0,this.parameterUniforms.localWeatherTexture.value=e):(this.proceduralLocalWeather=e,this.parameterUniforms.localWeatherTexture.value=e.texture)}get shapeTexture(){return this.proceduralShape??this.parameterUniforms.shapeTexture.value}set shapeTexture(e){e instanceof n.Data3DTexture||e==null?(this.proceduralShape=void 0,this.parameterUniforms.shapeTexture.value=e):(this.proceduralShape=e,this.parameterUniforms.shapeTexture.value=e.texture)}get shapeDetailTexture(){return this.proceduralShapeDetail??this.parameterUniforms.shapeDetailTexture.value}set shapeDetailTexture(e){e instanceof n.Data3DTexture||e==null?(this.proceduralShapeDetail=void 0,this.parameterUniforms.shapeDetailTexture.value=e):(this.proceduralShapeDetail=e,this.parameterUniforms.shapeDetailTexture.value=e.texture)}get turbulenceTexture(){return this.proceduralTurbulence??this.parameterUniforms.turbulenceTexture.value}set turbulenceTexture(e){e instanceof n.Texture||e==null?(this.proceduralTurbulence=void 0,this.parameterUniforms.turbulenceTexture.value=e):(this.proceduralTurbulence=e,this.parameterUniforms.turbulenceTexture.value=e.texture)}get stbnTexture(){return this.cloudsPass.currentMaterial.uniforms.stbnTexture.value}set stbnTexture(e){this.cloudsPass.currentMaterial.uniforms.stbnTexture.value=e,this.shadowPass.currentMaterial.uniforms.stbnTexture.value=e}get resolutionScale(){return this.resolution.scale}set resolutionScale(e){this.resolution.scale=e}get temporalUpscale(){return this.cloudsPass.temporalUpscale}set temporalUpscale(e){this.cloudsPass.temporalUpscale=e}get lightShafts(){return this.cloudsPass.lightShafts}set lightShafts(e){this.cloudsPass.lightShafts=e}get shapeDetail(){return this.cloudsPass.currentMaterial.shapeDetail}set shapeDetail(e){this.cloudsPass.currentMaterial.shapeDetail=e,this.shadowPass.currentMaterial.shapeDetail=e}get turbulence(){return this.cloudsPass.currentMaterial.turbulence}set turbulence(e){this.cloudsPass.currentMaterial.turbulence=e,this.shadowPass.currentMaterial.turbulence=e}get haze(){return this.cloudsPass.currentMaterial.haze}set haze(e){this.cloudsPass.currentMaterial.haze=e}get scatteringCoefficient(){return this.parameterUniforms.scatteringCoefficient.value}set scatteringCoefficient(e){this.parameterUniforms.scatteringCoefficient.value=e}get absorptionCoefficient(){return this.parameterUniforms.absorptionCoefficient.value}set absorptionCoefficient(e){this.parameterUniforms.absorptionCoefficient.value=e}get coverage(){return this.parameterUniforms.coverage.value}set coverage(e){this.parameterUniforms.coverage.value=e}get turbulenceDisplacement(){return this.parameterUniforms.turbulenceDisplacement.value}set turbulenceDisplacement(e){this.parameterUniforms.turbulenceDisplacement.value=e}get scatterAnisotropy1(){return this.cloudsPass.currentMaterial.scatterAnisotropy1}set scatterAnisotropy1(e){this.cloudsPass.currentMaterial.scatterAnisotropy1=e}get scatterAnisotropy2(){return this.cloudsPass.currentMaterial.scatterAnisotropy2}set scatterAnisotropy2(e){this.cloudsPass.currentMaterial.scatterAnisotropy2=e}get scatterAnisotropyMix(){return this.cloudsPass.currentMaterial.scatterAnisotropyMix}set scatterAnisotropyMix(e){this.cloudsPass.currentMaterial.scatterAnisotropyMix=e}get skyIrradianceScale(){return this.skyLightScale}set skyIrradianceScale(e){this.skyLightScale=e}get skyLightScale(){return this.cloudsPass.currentMaterial.uniforms.skyLightScale.value}set skyLightScale(e){this.cloudsPass.currentMaterial.uniforms.skyLightScale.value=e}get groundIrradianceScale(){return this.groundBounceScale}set groundIrradianceScale(e){this.groundBounceScale=e}get groundBounceScale(){return this.cloudsPass.currentMaterial.uniforms.groundBounceScale.value}set groundBounceScale(e){this.cloudsPass.currentMaterial.uniforms.groundBounceScale.value=e}get powderScale(){return this.cloudsPass.currentMaterial.uniforms.powderScale.value}set powderScale(e){this.cloudsPass.currentMaterial.uniforms.powderScale.value=e}get powderExponent(){return this.cloudsPass.currentMaterial.uniforms.powderExponent.value}set powderExponent(e){this.cloudsPass.currentMaterial.uniforms.powderExponent.value=e}get atmosphereOverlay(){return this._atmosphereOverlay}get atmosphereShadow(){return this._atmosphereShadow}get atmosphereShadowLength(){return this._atmosphereShadowLength}get irradianceTexture(){return this.cloudsPass.currentMaterial.irradianceTexture}set irradianceTexture(e){this.cloudsPass.currentMaterial.irradianceTexture=e}get scatteringTexture(){return this.cloudsPass.currentMaterial.scatteringTexture}set scatteringTexture(e){this.cloudsPass.currentMaterial.scatteringTexture=e}get transmittanceTexture(){return this.cloudsPass.currentMaterial.transmittanceTexture}set transmittanceTexture(e){this.cloudsPass.currentMaterial.transmittanceTexture=e}get singleMieScatteringTexture(){return this.cloudsPass.currentMaterial.singleMieScatteringTexture}set singleMieScatteringTexture(e){this.cloudsPass.currentMaterial.singleMieScatteringTexture=e}get higherOrderScatteringTexture(){return this.cloudsPass.currentMaterial.higherOrderScatteringTexture}set higherOrderScatteringTexture(e){this.cloudsPass.currentMaterial.higherOrderScatteringTexture=e}get ellipsoid(){return this.cloudsPass.currentMaterial.ellipsoid}set ellipsoid(e){this.cloudsPass.currentMaterial.ellipsoid=e}get sunAngularRadius(){return this.cloudsPass.currentMaterial.sunAngularRadius}set sunAngularRadius(e){this.cloudsPass.currentMaterial.sunAngularRadius=e}}et([u.define("SKIP_RENDERING")],de.prototype,"skipRendering");const ct=128,lt=32,z="45a1c6c1bb9fd38b3680fd120795ff4c32df68ff",ut=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${z}/packages/clouds/assets/local_weather.png`,ht=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${z}/packages/clouds/assets/shape.bin`,dt=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${z}/packages/clouds/assets/shape_detail.bin`,pt=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${z}/packages/clouds/assets/turbulence.png`;exports.CLOUD_SHAPE_DETAIL_TEXTURE_SIZE=lt;exports.CLOUD_SHAPE_TEXTURE_SIZE=ct;exports.CloudLayer=x;exports.CloudLayers=F;exports.CloudsEffect=de;exports.DEFAULT_LOCAL_WEATHER_URL=ut;exports.DEFAULT_SHAPE_DETAIL_URL=dt;exports.DEFAULT_SHAPE_URL=ht;exports.DEFAULT_TURBULENCE_URL=pt;exports.DensityProfile=M;exports.cloudsPassOptionsDefaults=he;
|
2189
2217
|
//# sourceMappingURL=shared.cjs.map
|