@takram/three-clouds 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +8 -8
- package/build/shared.cjs +8 -8
- package/build/shared.cjs.map +1 -1
- package/build/shared.js +236 -242
- package/build/shared.js.map +1 -1
- package/package.json +8 -8
- package/src/CloudsMaterial.ts +7 -12
- package/src/CloudsResolveMaterial.ts +1 -1
- package/src/PassBase.ts +2 -2
- package/src/ShadowPass.ts +1 -1
- package/src/helpers/FrustumCorners.ts +0 -6
- package/types/CloudsMaterial.d.ts +0 -5
- package/types/helpers/FrustumCorners.d.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.2] - 2025-11-01
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Removed `three-stdlib` from dependencies to fix compatibility with importmaps.
|
|
8
|
+
- Reverted the TS target to `es2017` to fix incorrect code generation.
|
|
9
|
+
|
|
10
|
+
## [0.5.1] - 2025-11-01
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Removed module augmentation from type definitions.
|
|
15
|
+
- Updated dependencies.
|
|
16
|
+
|
|
3
17
|
## [0.5.0] - 2025-08-19
|
|
4
18
|
|
|
5
19
|
### Changed
|
package/README.md
CHANGED
|
@@ -199,7 +199,7 @@ This illustrates that greater total cloud layer height increases computational c
|
|
|
199
199
|
|
|
200
200
|
- A large portion of weather sampling is wasted simply checking whether it is outside the cloud shell. However, since we already know the front depth and sample count at the texel from the reprojected previous frame, using this information to better estimate the ray marching range would make it much more efficient.
|
|
201
201
|
|
|
202
|
-
- Compute light shafts of the scene objects (possibly in the [atmosphere package](../atmosphere)). Implementing this would require an additional depth pass to render the scene as seen from the sun, which is too expensive unless shadow map is already in use. It may provide a partial solution to project the main camera
|
|
202
|
+
- Compute light shafts of the scene objects (possibly in the [atmosphere package](../atmosphere)). Implementing this would require an additional depth pass to render the scene as seen from the sun, which is too expensive unless shadow map is already in use. It may provide a partial solution to project the main camera's depth onto the sun's view.
|
|
203
203
|
|
|
204
204
|
### Planned features
|
|
205
205
|
|
|
@@ -477,7 +477,7 @@ Specifies whether this cloud layer should be included in BSM.
|
|
|
477
477
|
|
|
478
478
|
A post-processing effect that renders volumetric clouds. Although it is an effect and can render as a standalone, it is primarily intended to render clouds into buffers and then composited in `AerialPerspectiveEffect`.
|
|
479
479
|
|
|
480
|
-
This is for use with the [`postprocessing`](https://github.com/pmndrs/postprocessing)
|
|
480
|
+
This is for use with the [`postprocessing`](https://github.com/pmndrs/postprocessing)'s `EffectComposer` and is not compatible with the one in Three.js examples.
|
|
481
481
|
|
|
482
482
|
→ [Source](/packages/clouds/src/CloudsEffect.ts)
|
|
483
483
|
|
|
@@ -489,7 +489,7 @@ Nothing novel here, just a combination of existing techniques. See the [referenc
|
|
|
489
489
|
|
|
490
490
|
- **Shadow**
|
|
491
491
|
|
|
492
|
-
Performs ray marching in the sun
|
|
492
|
+
Performs ray marching in the sun's orthographic projection and outputs the necessary values for computing the optical depth of the clouds (BSM) during the main camera's ray marching.
|
|
493
493
|
|
|
494
494
|
→ [Shader](/packages/clouds/src/shaders/shadow.frag)
|
|
495
495
|
|
|
@@ -521,7 +521,7 @@ Nothing novel here, just a combination of existing techniques. See the [referenc
|
|
|
521
521
|
|
|
522
522
|
### Parameters
|
|
523
523
|
|
|
524
|
-
The number of parameters might seem overwhelming at first, but they provide fine control as needed. To get started, try adjusting [`qualityPreset`](#qualitypreset), [`coverage`](#coverage), cloud layer
|
|
524
|
+
The number of parameters might seem overwhelming at first, but they provide fine control as needed. To get started, try adjusting [`qualityPreset`](#qualitypreset), [`coverage`](#coverage), cloud layer's [`altitude`](#altitude), and [`height`](#height) to suit your needs. You can also experiment with the parameters in the [Basic story](https://takram-design-engineering.github.io/three-geospatial/?path=/story/clouds-clouds--basic).
|
|
525
525
|
|
|
526
526
|
- [Rendering](#rendering)
|
|
527
527
|
- [Cloud layers](#cloud-layers)
|
|
@@ -796,7 +796,7 @@ The resolution of each cascade in the shadow map.
|
|
|
796
796
|
maxFar: number | null = null
|
|
797
797
|
```
|
|
798
798
|
|
|
799
|
-
The maximum far plane distance for rendering shadows within the main camera
|
|
799
|
+
The maximum far plane distance for rendering shadows within the main camera's frustum. This limits the main camera's frustum: shadows beyond this distance are not rendered, and setting a value larger than the main camera's far plane has no effect.
|
|
800
800
|
|
|
801
801
|
#### shadow.farScale
|
|
802
802
|
|
|
@@ -804,7 +804,7 @@ The maximum far plane distance for rendering shadows within the main camera’s
|
|
|
804
804
|
farScale: number = 1
|
|
805
805
|
```
|
|
806
806
|
|
|
807
|
-
A scale factor for the main camera
|
|
807
|
+
A scale factor for the main camera's far plane. This is useful when the far plane extends to a point like the horizon occlusion point, even though shadows do not need to be rendered that far. The resulting value is also limited by `shadow.maxFar`.
|
|
808
808
|
|
|
809
809
|
#### shadow.splitMode, shadow.splitLambda
|
|
810
810
|
|
|
@@ -813,7 +813,7 @@ splitMode: 'uniform' | 'logarithmic' | 'practical' = 'practical'
|
|
|
813
813
|
splitLambda: number = 0.6
|
|
814
814
|
```
|
|
815
815
|
|
|
816
|
-
Controls [how the main camera
|
|
816
|
+
Controls [how the main camera's frustum is split](https://developer.nvidia.com/gpugems/gpugems3/part-ii-light-and-shadows/chapter-10-parallel-split-shadow-maps-programmable-gpus). `splitLambda` is only applicable when `splitMode` is set to `practical`.
|
|
817
817
|
|
|
818
818
|
### Advanced clouds parameters
|
|
819
819
|
|
|
@@ -839,7 +839,7 @@ Whether to sample sun and sky irradiance at every sample point during ray marchi
|
|
|
839
839
|
accuratePhaseFunction: boolean = false
|
|
840
840
|
```
|
|
841
841
|
|
|
842
|
-
Whether to use a [numerically-fitted Mie phase function](https://research.nvidia.com/labs/rtr/approximate-mie/) for large particles (d = 10 μm) instead of the dual-lobe Henyey-Greenstein phase function. However, it won
|
|
842
|
+
Whether to use a [numerically-fitted Mie phase function](https://research.nvidia.com/labs/rtr/approximate-mie/) for large particles (d = 10 μm) instead of the dual-lobe Henyey-Greenstein phase function. However, it won't be plausible without a more precise computation of multiple scattering.
|
|
843
843
|
|
|
844
844
|
#### clouds.maxIterationCount
|
|
845
845
|
|
package/build/shared.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const w=require("postprocessing"),n=require("three"),z=require("@takram/three-atmosphere"),u=require("@takram/three-geospatial"),P=require("@takram/three-atmosphere/shaders/bruneton"),g=require("@takram/three-geospatial/shaders");class b{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 b(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 b?o[t].copy(a):o[t]=a)}}const I=class I{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 b(0,0,.75,.25),this.shadow=!1,this.set(e)}set(e){return ve(this,e),this}clone(){return new I(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}};I.DEFAULT=new I;let S=I;const O=Array.from({length:8},()=>({value:0,flag:0})),L=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 M=class M extends Array{constructor(e){super(new S(e?.[0]),new S(e?.[1]),new S(e?.[2]),new S(e?.[3]))}set(e){return this[0].set(e?.[0]),this[1].set(e?.[1]),this[2].set(e?.[2]),this[3].set(e?.[3]),this}reset(){return this[0].copy(S.DEFAULT),this[1].copy(S.DEFAULT),this[2].copy(S.DEFAULT),this[3].copy(S.DEFAULT),this}clone(){return new M(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=O[s];h.value=l.altitude,h.flag=0,h=O[s+4],h.value=l.altitude+l.height,h.flag=1}O.sort(ge);let a=0,i=0;for(let s=0;s<O.length;++s){const{value:l,flag:h}=O[s];if(i===0&&s>0){const d=L[a++];d.min=O[s-1].value,d.max=l}i+=h===0?1:-1}for(;a<3;++a){const s=L[a];s.min=0,s.max=0}let r=L[0];e.x=r.min,t.x=r.max,r=L[1],e.y=r.min,t.y=r.max,r=L[2],e.z=r.min,t.z=r.max}};M.DEFAULT=new M([{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 W=M;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 N{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 N().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]??=new N;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 N,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 N,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){if(e!==this.cascadeCount){for(let t=0;t<e;++t)this.cascades[t]??={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],y=l[p],C=this.getFrustumRadius(e,s[p]),A=-C,_=C,Z=C,q=-C;y.projectionMatrix.makeOrthographic(A,_,Z,q,-this.margin,C*2+this.margin);const{near:pe,far:fe}=Ce.copy(f).applyMatrix4(r),H=Te.makeEmpty();for(let F=0;F<4;F++)H.expandByPoint(pe[F]),H.expandByPoint(fe[F]);const T=H.getCenter(Q);T.z=H.max.z+h;const K=(_-A)/d.width,X=(Z-q)/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);y.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:y}=i[s];p.copy(d).invert(),f.copy(y).invert(),l.copy(d).multiply(f),h.copy(y).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)}}},Pe=`precision highp float;
|
|
2
2
|
precision highp sampler3D;
|
|
3
3
|
precision highp sampler2DArray;
|
|
4
4
|
|
|
@@ -1009,7 +1009,7 @@ void main() {
|
|
|
1009
1009
|
outputShadowLength = shadowLength * METER_TO_LENGTH_UNIT;
|
|
1010
1010
|
#endif // SHADOW_LENGTH
|
|
1011
1011
|
}
|
|
1012
|
-
`,
|
|
1012
|
+
`,re=`float getSTBN() {
|
|
1013
1013
|
ivec3 size = textureSize(stbnTexture, 0);
|
|
1014
1014
|
vec3 scale = 1.0 / vec3(size);
|
|
1015
1015
|
return texture(stbnTexture, vec3(gl_FragCoord.xy, float(frame % size.z)) * scale).r;
|
|
@@ -1364,7 +1364,7 @@ struct CloudDensityProfile {
|
|
|
1364
1364
|
vec4 linearTerms;
|
|
1365
1365
|
vec4 constantTerms;
|
|
1366
1366
|
};
|
|
1367
|
-
`;var
|
|
1367
|
+
`;var Re=Object.defineProperty,v=(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&&Re(e,t,i),i};const Le=new n.Vector3,Ue=new u.Geodetic;class m extends z.AtmosphereMaterialBase{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:a},i=z.AtmosphereParameters.DEFAULT){super({name:"CloudsMaterial",glslVersion:n.GLSL3,vertexShader:u.resolveIncludes(Oe,{atmosphere:{bruneton:{common:P.common,definitions:P.definitions,runtime:P.runtime}},types:j}),fragmentShader:u.unrollLoops(u.resolveIncludes(Pe,{core:{depth:g.depth,math:g.math,turbo:g.turbo,generators:g.generators,raySphereIntersection:g.raySphereIntersection,cascadedShadowMaps:g.cascadedShadowMaps,interleavedGradientNoise:g.interleavedGradientNoise,vogelDisk:g.vogelDisk},atmosphere:{bruneton:{common:P.common,definitions:P.definitions,runtime:P.runtime}},types:j,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),viewReprojectionMatrix: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_LOGARITHMIC_DEPTH_BUFFER!=null,h=e.capabilities.logarithmicDepthBuffer;h!==l&&(h?this.defines.USE_LOGARITHMIC_DEPTH_BUFFER="1":delete this.defines.USE_LOGARITHMIC_DEPTH_BUFFER);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.inverseViewMatrix.value,l=t.reprojectionMatrix.value,h=t.viewReprojectionMatrix.value;if(this.temporalUpscale){const f=t.frame.value%16,y=t.resolution.value,C=ie[f],A=(C.x-.5)/y.x*4,_=(C.y-.5)/y.y*4;t.temporalJitter.value.set(A,_),t.mipLevelScale.value=.25,r.copy(e.projectionMatrix),r.elements[8]+=A*2,r.elements[9]+=_*2,r.invert(),l.copy(a),l.elements[8]+=A*2,l.elements[9]+=_*2,l.multiply(i),h.copy(l).multiply(s)}else t.temporalJitter.value.setScalar(0),t.mipLevelScale.value=1,r.copy(e.projectionMatrixInverse),l.copy(a).multiply(i),h.copy(l).multiply(s);u.reinterpretType(e),t.cameraNear.value=e.near,t.cameraFar.value=e.far;const d=e.getWorldPosition(t.cameraPosition.value),p=Le.copy(d).applyMatrix4(t.worldToECEFMatrix.value);try{t.cameraHeight.value=Ue.setFromECEF(p).height}catch{}}copyReprojectionMatrix(e){this.previousProjectionMatrix??=new n.Matrix4,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}}v([u.defineInt("DEPTH_PACKING")],m.prototype,"depthPacking");v([u.defineExpression("LOCAL_WEATHER_CHANNELS",{validate:o=>/^[rgba]{4}$/.test(o)})],m.prototype,"localWeatherChannels");v([u.define("SHAPE_DETAIL")],m.prototype,"shapeDetail");v([u.define("TURBULENCE")],m.prototype,"turbulence");v([u.define("SHADOW_LENGTH")],m.prototype,"shadowLength");v([u.define("HAZE")],m.prototype,"haze");v([u.defineInt("MULTI_SCATTERING_OCTAVES",{min:1,max:12})],m.prototype,"multiScatteringOctaves");v([u.define("ACCURATE_SUN_SKY_LIGHT")],m.prototype,"accurateSunSkyLight");v([u.define("ACCURATE_PHASE_FUNCTION")],m.prototype,"accuratePhaseFunction");v([u.defineInt("SHADOW_CASCADE_COUNT",{min:1,max:4})],m.prototype,"shadowCascadeCount");v([u.defineInt("SHADOW_SAMPLE_COUNT",{min:1,max:16})],m.prototype,"shadowSampleCount");v([u.defineFloat("SCATTER_ANISOTROPY_1")],m.prototype,"scatterAnisotropy1");v([u.defineFloat("SCATTER_ANISOTROPY_2")],m.prototype,"scatterAnisotropy2");v([u.defineFloat("SCATTER_ANISOTROPY_MIX")],m.prototype,"scatterAnisotropyMix");const Ie=`// Taken from https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1
|
|
1368
1368
|
// TODO: Use 5-taps version: https://www.shadertoy.com/view/MtVGWz
|
|
1369
1369
|
// Or even 4 taps (requires preprocessing in the input buffer):
|
|
1370
1370
|
// https://www.shadertoy.com/view/4tyGDD
|
|
@@ -1477,7 +1477,7 @@ vec4 textureCatmullRom(sampler2DArray tex, vec3 uv) {
|
|
|
1477
1477
|
result += texture(tex, vec3(texPos3.x, texPos3.y, uv.z)) * w3.x * w3.y;
|
|
1478
1478
|
return result;
|
|
1479
1479
|
}
|
|
1480
|
-
`,
|
|
1480
|
+
`,Me=`precision highp float;
|
|
1481
1481
|
precision highp sampler2DArray;
|
|
1482
1482
|
|
|
1483
1483
|
#include "core/turbo"
|
|
@@ -1778,7 +1778,7 @@ vec4 varianceClipping(
|
|
|
1778
1778
|
) {
|
|
1779
1779
|
return varianceClipping(inputBuffer, coord, current, history, 1.0);
|
|
1780
1780
|
}
|
|
1781
|
-
`;var be=Object.defineProperty,ce=(o,e,t,a)=>{for(var
|
|
1781
|
+
`;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 Y 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:g.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")],Y.prototype,"temporalUpscale");ce([u.define("SHADOW_LENGTH")],Y.prototype,"shadowLength");class le extends w.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 G(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 m({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:a},r),this.currentPass=new w.ShaderPass(this.currentMaterial),this.resolveMaterial=new Y,this.resolvePass=new w.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){this.currentRenderTarget?.dispose(),this.resolveRenderTarget?.dispose(),this.historyRenderTarget?.dispose();const t=G("Clouds",e),a=G("Clouds.A",{...e,depthVelocity:!1}),i=G("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 w.ShaderPass{render(e,t,a,i,r){const s=this.fullscreenMaterial.uniforms;t!==null&&s?.[this.input]!=null&&(s[this.input].value=t.texture),Fe(e,a),e.render(this.scene,this.camera)}}const ze=`precision highp float;
|
|
1782
1782
|
precision highp sampler3D;
|
|
1783
1783
|
|
|
1784
1784
|
#include <common>
|
|
@@ -2082,7 +2082,7 @@ void intersectStructuredPlanes(
|
|
|
2082
2082
|
stepOffset += stepSize;
|
|
2083
2083
|
}
|
|
2084
2084
|
}
|
|
2085
|
-
`;var Ge=Object.defineProperty,
|
|
2085
|
+
`;var Ge=Object.defineProperty,R=(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:g.math,raySphereIntersection:g.raySphereIntersection},types:j,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)}}R([u.defineExpression("LOCAL_WEATHER_CHANNELS",{validate:o=>/^[rgba]{4}$/.test(o)})],E.prototype,"localWeatherChannels");R([u.defineInt("CASCADE_COUNT",{min:1,max:4})],E.prototype,"cascadeCount");R([u.define("TEMPORAL_PASS")],E.prototype,"temporalPass");R([u.define("TEMPORAL_JITTER")],E.prototype,"temporalJitter");R([u.define("SHAPE_DETAIL")],E.prototype,"shapeDetail");R([u.define("TURBULENCE")],E.prototype,"turbulence");const Ve=`precision highp float;
|
|
2086
2086
|
precision highp sampler2DArray;
|
|
2087
2087
|
|
|
2088
2088
|
#define VARIANCE_9_SAMPLES 1
|
|
@@ -2168,7 +2168,7 @@ void main() {
|
|
|
2168
2168
|
vUv = position.xy * 0.5 + 0.5;
|
|
2169
2169
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
2170
2170
|
}
|
|
2171
|
-
`;var je=Object.defineProperty,Ye=(o,e,t,a)=>{for(var
|
|
2171
|
+
`;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 V(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 Ze 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(){this.currentRenderTarget?.dispose(),this.resolveRenderTarget?.dispose(),this.historyRenderTarget?.dispose();const e=V("Shadow"),t=this.temporalPass?V("Shadow.A"):null,a=this.temporalPass?V("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?.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){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),this.resolveRenderTarget?.setSize(e,t,a),this.historyRenderTarget?.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 qe(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 k=[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;k.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)),k[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(k)}function $e(o,e){return{bottomRadius:new n.Uniform(o.bottomRadius),topRadius:new n.Uniform(o.topRadius),worldToECEFMatrix:new n.Uniform(e.worldToECEFMatrix),ecefToWorldMatrix:new n.Uniform(e.ecefToWorldMatrix),altitudeCorrection:new n.Uniform(e.altitudeCorrection),sunDirection:new n.Uniform(e.sunDirection)}}const Je=`uniform sampler2D cloudsBuffer;
|
|
2172
2172
|
|
|
2173
2173
|
void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
|
|
2174
2174
|
#ifdef SKIP_RENDERING
|
|
@@ -2179,5 +2179,5 @@ void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
|
|
|
2179
2179
|
outputColor.a = inputColor.a * (1.0 - clouds.a) + clouds.a;
|
|
2180
2180
|
#endif // SKIP_RENDERING
|
|
2181
2181
|
}
|
|
2182
|
-
`;var Qe=Object.defineProperty,et=(o,e,t,a)=>{for(var r=void 0,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=s(e,t,r)||r);return r&&Qe(e,t,r),r};const U=new n.Vector3,tt=new n.Vector2,nt=new n.Matrix3,at=["maxIterationCount","minStepSize","maxStepSize","maxRayDistance","perspectiveStepScale","minDensity","minExtinction","minTransmittance","maxIterationCountToSun","maxIterationCountToGround","minSecondaryStepSize","secondaryStepScale","maxShadowFilterRadius","maxShadowLengthIterationCount","minShadowLengthStepSize","maxShadowLengthRayDistance","hazeDensityScale","hazeExponent","hazeScatteringCoefficient","hazeAbsorptionCoefficient"],rt=["multiScatteringOctaves","accurateSunSkyLight","accuratePhaseFunction"],it=["maxIterationCount","minStepSize","maxStepSize","minDensity","minExtinction","minTransmittance","opticalDepthTailScale"],ot=["temporalJitter"],st=["temporalPass"],ct=["cascadeCount","mapSize","maxFar","farScale","splitMode","splitLambda"],w={type:"change"},ue={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=z.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=W.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.worldToECEFMatrix=new n.Matrix4,this.ecefToWorldMatrix=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:r,width:i,height:s,resolutionX:c=i,resolutionY:h=s}={...ue,...t};this.shadowMaps=new Ee({cascadeCount:l.shadow.cascadeCount,mapSize:l.shadow.mapSize,splitLambda:.6}),this.parameterUniforms=qe({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,{worldToECEFMatrix:this.worldToECEFMatrix,ecefToWorldMatrix:this.ecefToWorldMatrix,altitudeCorrection:this.altitudeCorrection,sunDirection:this.sunDirection});const d={shadow:this.shadowMaps,parameterUniforms:this.parameterUniforms,layerUniforms:this.layerUniforms,atmosphereUniforms:this.atmosphereUniforms};this.shadowPass=new Ze(d),this.shadowPass.mainCamera=e,this.cloudsPass=new He(d,a),this.cloudsPass.mainCamera=e,this.clouds=u.definePropertyShorthand(u.defineUniformShorthand({},this.cloudsPass.currentMaterial,at),this.cloudsPass.currentMaterial,rt),this.shadow=u.definePropertyShorthand(u.defineUniformShorthand({},this.shadowPass.currentMaterial,it),this.shadowPass.currentMaterial,ot,this.shadowPass,st,this.shadowMaps,ct),this.resolution=new C.Resolution(this,c,h,r),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(U.copy(this.shapeVelocity).multiplyScalar(e)),t.shapeDetailOffset.value.add(U.copy(this.shapeDetailVelocity).multiplyScalar(e));const a=this.worldToECEFMatrix;this.ecefToWorldMatrix.copy(a).invert();const r=this.camera.getWorldPosition(U).applyMatrix4(this.worldToECEFMatrix),i=this.altitudeCorrection;this.correctAltitude?z.getAltitudeCorrectionOffset(r,this.atmosphere.bottomRadius,this.ellipsoid,i):i.setScalar(0);const s=this.ellipsoid.getSurfaceNormal(r,U),c=this.sunDirection.dot(s),h=u.lerp(1e6,1e3,c),d=nt.setFromMatrix4(a).transpose();this.shadowMaps.update(this.camera,U.copy(this.sunDirection).applyMatrix3(d),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,r=t.currentMaterial.uniforms,i=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:i.shadowIntervals.value,matrices:i.shadowMatrices.value,inverseMatrices:r.inverseShadowMatrices.value,far:e.far,topHeight:i.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:r,shadowPass:i,cloudsPass:s}=this;if(r.cascadeCount!==this.shadowCascadeCount||!r.mapSize.equals(this.shadowMapSize)){const{width:f,height:m}=r.mapSize,v=r.cascadeCount;this.shadowMapSize.set(f,m),this.shadowCascadeCount=v,i.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(),i.update(e,this.frame,a),s.shadowBuffer=i.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:r,height:i}=a;this.cloudsPass.setSize(r,i)}setDepthTexture(e,t){this.shadowPass.setDepthTexture(e,t),this.cloudsPass.setDepthTexture(e,t)}set qualityPreset(e){const{clouds:t,shadow:a,...r}=_e[e];Object.assign(this,r),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 lt=128,ht=32,B="45a1c6c1bb9fd38b3680fd120795ff4c32df68ff",ut=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${B}/packages/clouds/assets/local_weather.png`,dt=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${B}/packages/clouds/assets/shape.bin`,pt=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${B}/packages/clouds/assets/shape_detail.bin`,ft=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${B}/packages/clouds/assets/turbulence.png`;exports.CLOUD_SHAPE_DETAIL_TEXTURE_SIZE=ht;exports.CLOUD_SHAPE_TEXTURE_SIZE=lt;exports.CloudLayer=x;exports.CloudLayers=W;exports.CloudsEffect=de;exports.DEFAULT_LOCAL_WEATHER_URL=ut;exports.DEFAULT_SHAPE_DETAIL_URL=pt;exports.DEFAULT_SHAPE_URL=dt;exports.DEFAULT_TURBULENCE_URL=ft;exports.DensityProfile=b;exports.cloudsPassOptionsDefaults=ue;
|
|
2182
|
+
`;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 U=new n.Vector3,tt=new n.Vector2,nt=new n.Matrix3,at=["maxIterationCount","minStepSize","maxStepSize","maxRayDistance","perspectiveStepScale","minDensity","minExtinction","minTransmittance","maxIterationCountToSun","maxIterationCountToGround","minSecondaryStepSize","secondaryStepScale","maxShadowFilterRadius","maxShadowLengthIterationCount","minShadowLengthStepSize","maxShadowLengthRayDistance","hazeDensityScale","hazeExponent","hazeScatteringCoefficient","hazeAbsorptionCoefficient"],it=["multiScatteringOctaves","accurateSunSkyLight","accuratePhaseFunction"],rt=["maxIterationCount","minStepSize","maxStepSize","minDensity","minExtinction","minTransmittance","opticalDepthTailScale"],ot=["temporalJitter"],st=["temporalPass"],ct=["cascadeCount","mapSize","maxFar","farScale","splitMode","splitLambda"],x={type:"change"},he={resolutionScale:c.resolutionScale,width:w.Resolution.AUTO_SIZE,height:w.Resolution.AUTO_SIZE};class de extends w.Effect{constructor(e=new n.Camera,t,a=z.AtmosphereParameters.DEFAULT){super("CloudsEffect",Je,{attributes:w.EffectAttribute.DEPTH,uniforms:new Map([["cloudsBuffer",new n.Uniform(null)]])}),this.camera=e,this.atmosphere=a,this.cloudLayers=W.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.worldToECEFMatrix=new n.Matrix4,this.ecefToWorldMatrix=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=qe({localWeatherTexture:this.proceduralLocalWeather?.texture??null,localWeatherRepeat:this.localWeatherRepeat,localWeatherOffset:this.localWeatherOffset,shapeTexture:this.proceduralShape?.texture??null,shapeRepeat:this.shapeRepeat,shapeOffset:this.shapeOffset,shapeDetailTexture:this.proceduralShapeDetail?.texture??null,shapeDetailRepeat:this.shapeDetailRepeat,shapeDetailOffset:this.shapeDetailOffset,turbulenceTexture:this.proceduralTurbulence?.texture??null,turbulenceRepeat:this.turbulenceRepeat}),this.layerUniforms=Ke(),this.atmosphereUniforms=$e(a,{worldToECEFMatrix:this.worldToECEFMatrix,ecefToWorldMatrix:this.ecefToWorldMatrix,altitudeCorrection:this.altitudeCorrection,sunDirection:this.sunDirection});const d={shadow:this.shadowMaps,parameterUniforms:this.parameterUniforms,layerUniforms:this.layerUniforms,atmosphereUniforms:this.atmosphereUniforms};this.shadowPass=new Ze(d),this.shadowPass.mainCamera=e,this.cloudsPass=new He(d,a),this.cloudsPass.mainCamera=e,this.clouds=u.definePropertyShorthand(u.defineUniformShorthand({},this.cloudsPass.currentMaterial,at),this.cloudsPass.currentMaterial,it),this.shadow=u.definePropertyShorthand(u.defineUniformShorthand({},this.shadowPass.currentMaterial,rt),this.shadowPass.currentMaterial,ot,this.shadowPass,st,this.shadowMaps,ct),this.resolution=new w.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(U.copy(this.shapeVelocity).multiplyScalar(e)),t.shapeDetailOffset.value.add(U.copy(this.shapeDetailVelocity).multiplyScalar(e));const a=this.worldToECEFMatrix;this.ecefToWorldMatrix.copy(a).invert();const i=this.camera.getWorldPosition(U).applyMatrix4(this.worldToECEFMatrix),r=this.altitudeCorrection;this.correctAltitude?z.getAltitudeCorrectionOffset(i,this.atmosphere.bottomRadius,this.ellipsoid,r):r.setScalar(0);const s=this.ellipsoid.getSurfaceNormal(i,U),l=this.sunDirection.dot(s),h=u.lerp(1e6,1e3,l),d=nt.setFromMatrix4(a).transpose();this.shadowMaps.update(this.camera,U.copy(this.sunDirection).applyMatrix3(d),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,x.target=this,x.property="atmosphereOverlay",this.events.dispatchEvent(x));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,x.target=this,x.property="atmosphereShadow",this.events.dispatchEvent(x));const p=this._atmosphereShadowLength,f=a.shadowLengthBuffer!=null?Object.assign(this._atmosphereShadowLength??{},{map:a.shadowLengthBuffer}):null;p!==f&&(this._atmosphereShadowLength=f,x.target=this,x.property="atmosphereShadowLength",this.events.dispatchEvent(x))}update(e,t,a=0){const{shadowMaps:i,shadowPass:r,cloudsPass:s}=this;if(i.cascadeCount!==this.shadowCascadeCount||!i.mapSize.equals(this.shadowMapSize)){const{width:l,height:h}=i.mapSize,d=i.cascadeCount;this.shadowMapSize.set(l,h),this.shadowCascadeCount=d,r.setSize(l,h,d),s.setShadowSize(l,h,d)}this.proceduralLocalWeather?.render(e,a),this.proceduralShape?.render(e,a),this.proceduralShapeDetail?.render(e,a),this.proceduralTurbulence?.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 lt=128,ut=32,B="45a1c6c1bb9fd38b3680fd120795ff4c32df68ff",ht=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${B}/packages/clouds/assets/local_weather.png`,dt=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${B}/packages/clouds/assets/shape.bin`,pt=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${B}/packages/clouds/assets/shape_detail.bin`,ft=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${B}/packages/clouds/assets/turbulence.png`;exports.CLOUD_SHAPE_DETAIL_TEXTURE_SIZE=ut;exports.CLOUD_SHAPE_TEXTURE_SIZE=lt;exports.CloudLayer=S;exports.CloudLayers=W;exports.CloudsEffect=de;exports.DEFAULT_LOCAL_WEATHER_URL=ht;exports.DEFAULT_SHAPE_DETAIL_URL=pt;exports.DEFAULT_SHAPE_URL=dt;exports.DEFAULT_TURBULENCE_URL=ft;exports.DensityProfile=b;exports.cloudsPassOptionsDefaults=he;
|
|
2183
2183
|
//# sourceMappingURL=shared.cjs.map
|