@takram/three-clouds 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +16 -17
- package/build/index.cjs +9 -9
- package/build/index.cjs.map +1 -1
- package/build/index.js +70 -77
- package/build/index.js.map +1 -1
- package/build/r3f.cjs +1 -1
- package/build/r3f.cjs.map +1 -1
- package/build/r3f.js +122 -127
- package/build/r3f.js.map +1 -1
- package/build/shared.cjs +70 -55
- package/build/shared.cjs.map +1 -1
- package/build/shared.js +352 -303
- package/build/shared.js.map +1 -1
- package/package.json +3 -3
- package/src/CloudLayers.ts +2 -2
- package/src/CloudsEffect.ts +49 -28
- package/src/CloudsMaterial.ts +38 -21
- package/src/CloudsPass.ts +5 -6
- package/src/PassBase.ts +1 -1
- package/src/Procedural3DTexture.ts +2 -4
- package/src/ProceduralTexture.ts +1 -3
- package/src/ShaderArrayPass.ts +5 -5
- package/src/ShadowMaterial.ts +4 -4
- package/src/ShadowPass.ts +5 -6
- package/src/constants.ts +1 -0
- package/src/helpers/setArrayRenderTargetLayers.ts +3 -6
- package/src/qualityPresets.ts +5 -5
- package/src/r3f/CloudLayer.tsx +1 -1
- package/src/r3f/Clouds.tsx +71 -85
- package/src/shaders/clouds.frag +36 -34
- package/src/shaders/clouds.vert +18 -5
- package/src/shaders/parameters.glsl +1 -1
- package/src/shaders/shadowResolve.frag +2 -2
- package/src/shaders/types.glsl +1 -1
- package/src/shaders/varianceClipping.glsl +2 -2
- package/src/uniforms.ts +3 -3
- package/types/CloudsEffect.d.ts +18 -8
- package/types/CloudsMaterial.d.ts +7 -3
- package/types/qualityPresets.d.ts +1 -1
package/src/r3f/Clouds.tsx
CHANGED
@@ -1,33 +1,26 @@
|
|
1
1
|
import { useFrame, useThree, type ElementProps } from '@react-three/fiber'
|
2
2
|
import { EffectComposerContext } from '@react-three/postprocessing'
|
3
|
+
import { useCallback, useContext, useEffect, useMemo, type FC } from 'react'
|
3
4
|
import {
|
4
|
-
|
5
|
-
useContext,
|
6
|
-
useEffect,
|
7
|
-
useMemo,
|
8
|
-
useState,
|
9
|
-
type FC
|
10
|
-
} from 'react'
|
11
|
-
import {
|
5
|
+
Data3DTexture,
|
12
6
|
LinearFilter,
|
13
7
|
LinearMipMapLinearFilter,
|
14
8
|
NoColorSpace,
|
15
9
|
RedFormat,
|
16
10
|
RepeatWrapping,
|
17
11
|
TextureLoader,
|
18
|
-
type Data3DTexture,
|
19
12
|
type Texture,
|
20
13
|
type WebGLRenderer
|
21
14
|
} from 'three'
|
22
15
|
|
23
16
|
import { AtmosphereContext, separateProps } from '@takram/three-atmosphere/r3f'
|
24
17
|
import {
|
25
|
-
|
18
|
+
DataTextureLoader,
|
26
19
|
DEFAULT_STBN_URL,
|
27
20
|
parseUint8Array,
|
28
21
|
STBNLoader
|
29
22
|
} from '@takram/three-geospatial'
|
30
|
-
import {
|
23
|
+
import type { ExpandNestedProps } from '@takram/three-geospatial/r3f'
|
31
24
|
|
32
25
|
import {
|
33
26
|
CloudsEffect,
|
@@ -42,94 +35,86 @@ import {
|
|
42
35
|
DEFAULT_SHAPE_URL,
|
43
36
|
DEFAULT_TURBULENCE_URL
|
44
37
|
} from '../constants'
|
45
|
-
import {
|
46
|
-
import {
|
38
|
+
import type { Procedural3DTexture } from '../Procedural3DTexture'
|
39
|
+
import type { ProceduralTexture } from '../ProceduralTexture'
|
47
40
|
import { CloudLayers } from './CloudLayers'
|
48
41
|
|
49
|
-
function
|
42
|
+
function useLoadTexture(
|
50
43
|
input: string | Texture | ProceduralTexture,
|
51
44
|
gl: WebGLRenderer
|
52
45
|
): Texture | ProceduralTexture | null {
|
53
|
-
const
|
46
|
+
const loadedTexture = useMemo(
|
47
|
+
() =>
|
48
|
+
typeof input === 'string'
|
49
|
+
? new TextureLoader().load(input, texture => {
|
50
|
+
texture.minFilter = LinearMipMapLinearFilter
|
51
|
+
texture.magFilter = LinearFilter
|
52
|
+
texture.wrapS = RepeatWrapping
|
53
|
+
texture.wrapT = RepeatWrapping
|
54
|
+
texture.colorSpace = NoColorSpace
|
55
|
+
texture.needsUpdate = true
|
56
|
+
})
|
57
|
+
: undefined,
|
58
|
+
[input]
|
59
|
+
)
|
54
60
|
useEffect(() => {
|
55
|
-
if (
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
texture.minFilter = LinearMipMapLinearFilter
|
60
|
-
texture.magFilter = LinearFilter
|
61
|
-
texture.wrapS = RepeatWrapping
|
62
|
-
texture.wrapT = RepeatWrapping
|
63
|
-
texture.colorSpace = NoColorSpace
|
64
|
-
texture.needsUpdate = true
|
65
|
-
|
66
|
-
// WORKAROUND: The color space resets to sRGB for unknown reason, unless
|
67
|
-
// the texture is initialized here.
|
68
|
-
gl.initTexture(texture)
|
69
|
-
|
70
|
-
setData(texture)
|
71
|
-
})().catch(error => {
|
72
|
-
console.error(error)
|
73
|
-
})
|
74
|
-
} else {
|
75
|
-
setData(input)
|
61
|
+
if (loadedTexture != null) {
|
62
|
+
return () => {
|
63
|
+
loadedTexture.dispose()
|
64
|
+
}
|
76
65
|
}
|
77
|
-
}, [
|
78
|
-
|
79
|
-
return data
|
66
|
+
}, [loadedTexture])
|
67
|
+
return (typeof input === 'string' ? loadedTexture : input) ?? null
|
80
68
|
}
|
81
69
|
|
82
|
-
function
|
70
|
+
function useLoad3DTexture(
|
83
71
|
input: string | Data3DTexture | Procedural3DTexture,
|
84
72
|
size: number
|
85
73
|
): Data3DTexture | Procedural3DTexture | null {
|
86
|
-
const
|
74
|
+
const loadedTexture = useMemo(
|
75
|
+
() =>
|
76
|
+
typeof input === 'string'
|
77
|
+
? new DataTextureLoader(Data3DTexture, parseUint8Array, {
|
78
|
+
width: size,
|
79
|
+
height: size,
|
80
|
+
depth: size,
|
81
|
+
format: RedFormat,
|
82
|
+
minFilter: LinearFilter,
|
83
|
+
magFilter: LinearFilter,
|
84
|
+
wrapS: RepeatWrapping,
|
85
|
+
wrapT: RepeatWrapping,
|
86
|
+
wrapR: RepeatWrapping,
|
87
|
+
colorSpace: NoColorSpace
|
88
|
+
}).load(input)
|
89
|
+
: undefined,
|
90
|
+
[input, size]
|
91
|
+
)
|
87
92
|
useEffect(() => {
|
88
|
-
if (
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
depth: size,
|
93
|
-
format: RedFormat,
|
94
|
-
minFilter: LinearFilter,
|
95
|
-
magFilter: LinearFilter,
|
96
|
-
wrapS: RepeatWrapping,
|
97
|
-
wrapT: RepeatWrapping,
|
98
|
-
wrapR: RepeatWrapping,
|
99
|
-
colorSpace: NoColorSpace
|
100
|
-
})
|
101
|
-
const loader = new Loader()
|
102
|
-
;(async () => {
|
103
|
-
setData(await loader.loadAsync(input))
|
104
|
-
})().catch(error => {
|
105
|
-
console.error(error)
|
106
|
-
})
|
107
|
-
} else {
|
108
|
-
setData(input)
|
93
|
+
if (loadedTexture != null) {
|
94
|
+
return () => {
|
95
|
+
loadedTexture.dispose()
|
96
|
+
}
|
109
97
|
}
|
110
|
-
}, [
|
111
|
-
|
112
|
-
return data
|
98
|
+
}, [loadedTexture])
|
99
|
+
return (typeof input === 'string' ? loadedTexture : input) ?? null
|
113
100
|
}
|
114
101
|
|
115
|
-
function
|
102
|
+
function useLoadSTBNTexture(
|
116
103
|
input: string | Data3DTexture
|
117
104
|
): Data3DTexture | null {
|
118
|
-
const
|
105
|
+
const loadedTexture = useMemo(
|
106
|
+
() =>
|
107
|
+
typeof input === 'string' ? new STBNLoader().load(input) : undefined,
|
108
|
+
[input]
|
109
|
+
)
|
119
110
|
useEffect(() => {
|
120
|
-
if (
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
})().catch(error => {
|
125
|
-
console.error(error)
|
126
|
-
})
|
127
|
-
} else {
|
128
|
-
setData(input)
|
111
|
+
if (loadedTexture != null) {
|
112
|
+
return () => {
|
113
|
+
loadedTexture.dispose()
|
114
|
+
}
|
129
115
|
}
|
130
|
-
}, [
|
131
|
-
|
132
|
-
return data
|
116
|
+
}, [loadedTexture])
|
117
|
+
return (typeof input === 'string' ? loadedTexture : input) ?? null
|
133
118
|
}
|
134
119
|
|
135
120
|
export interface CloudsProps
|
@@ -218,6 +203,7 @@ export const Clouds: FC<CloudsProps> = ({
|
|
218
203
|
case 'atmosphereShadowLength':
|
219
204
|
transientStates.shadowLength = effect.atmosphereShadowLength
|
220
205
|
break
|
206
|
+
default:
|
221
207
|
}
|
222
208
|
},
|
223
209
|
[effect, transientStates]
|
@@ -229,18 +215,18 @@ export const Clouds: FC<CloudsProps> = ({
|
|
229
215
|
}
|
230
216
|
}, [effect, handleChange])
|
231
217
|
|
232
|
-
const
|
233
|
-
const localWeatherTexture =
|
234
|
-
const shapeTexture =
|
218
|
+
const renderer = useThree(({ gl }) => gl)
|
219
|
+
const localWeatherTexture = useLoadTexture(localWeatherTextureProp, renderer)
|
220
|
+
const shapeTexture = useLoad3DTexture(
|
235
221
|
shapeTextureProp,
|
236
222
|
CLOUD_SHAPE_TEXTURE_SIZE
|
237
223
|
)
|
238
|
-
const shapeDetailTexture =
|
224
|
+
const shapeDetailTexture = useLoad3DTexture(
|
239
225
|
shapeDetailTextureProp,
|
240
226
|
CLOUD_SHAPE_DETAIL_TEXTURE_SIZE
|
241
227
|
)
|
242
|
-
const turbulenceTexture =
|
243
|
-
const stbnTexture =
|
228
|
+
const turbulenceTexture = useLoadTexture(turbulenceTextureProp, renderer)
|
229
|
+
const stbnTexture = useLoadSTBNTexture(stbnTextureProp)
|
244
230
|
|
245
231
|
const { camera } = useContext(EffectComposerContext)
|
246
232
|
return (
|
package/src/shaders/clouds.frag
CHANGED
@@ -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,35 +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,
|
421
435
|
surfaceNormal,
|
422
436
|
sunDirection,
|
423
437
|
skyIrradiance
|
424
438
|
);
|
425
|
-
#else //
|
439
|
+
#else // ACCURATE_SUN_SKY_LIGHT
|
426
440
|
skyIrradiance = vGroundIrradiance.sky;
|
427
441
|
return vGroundIrradiance.sun;
|
428
|
-
#endif //
|
442
|
+
#endif // ACCURATE_SUN_SKY_LIGHT
|
429
443
|
}
|
430
444
|
|
431
445
|
vec3 getCloudsSunSkyIrradiance(const vec3 position, const float height, out vec3 skyIrradiance) {
|
432
|
-
#ifdef
|
433
|
-
return
|
434
|
-
|
435
|
-
sunDirection,
|
436
|
-
skyIrradiance
|
437
|
-
);
|
438
|
-
#else // ACCURATE_SUN_SKY_IRRADIANCE
|
446
|
+
#ifdef ACCURATE_SUN_SKY_LIGHT
|
447
|
+
return GetSunAndSkyScalarIrradiance(position * METER_TO_LENGTH_UNIT, sunDirection, skyIrradiance);
|
448
|
+
#else // ACCURATE_SUN_SKY_LIGHT
|
439
449
|
float alpha = remapClamped(height, minHeight, maxHeight);
|
440
450
|
skyIrradiance = mix(vCloudsIrradiance.minSky, vCloudsIrradiance.maxSky, alpha);
|
441
451
|
return mix(vCloudsIrradiance.minSun, vCloudsIrradiance.maxSun, alpha);
|
442
|
-
#endif //
|
452
|
+
#endif // ACCURATE_SUN_SKY_LIGHT
|
443
453
|
}
|
444
454
|
|
445
|
-
#ifdef
|
446
|
-
vec3
|
455
|
+
#ifdef GROUND_BOUNCE
|
456
|
+
vec3 approximateRadianceFromGround(
|
447
457
|
const vec3 position,
|
448
458
|
const vec3 surfaceNormal,
|
449
459
|
const float height,
|
@@ -464,7 +474,7 @@ vec3 approximateIrradianceFromGround(
|
|
464
474
|
vec3 bouncedRadiance = groundAlbedo * RECIPROCAL_PI * groundIrradiance;
|
465
475
|
return bouncedRadiance * exp(-opticalDepthToGround);
|
466
476
|
}
|
467
|
-
#endif //
|
477
|
+
#endif // GROUND_BOUNCE
|
468
478
|
|
469
479
|
vec4 marchClouds(
|
470
480
|
const vec3 rayOrigin,
|
@@ -554,23 +564,23 @@ vec4 marchClouds(
|
|
554
564
|
|
555
565
|
vec3 radiance = sunIrradiance * approximateMultipleScattering(opticalDepth, cosTheta);
|
556
566
|
|
557
|
-
#ifdef
|
567
|
+
#ifdef GROUND_BOUNCE
|
558
568
|
// Fudge factor for the irradiance from ground.
|
559
569
|
if (height < shadowTopHeight && mipLevel < 0.5) {
|
560
|
-
vec3
|
570
|
+
vec3 groundRadiance = approximateRadianceFromGround(
|
561
571
|
position,
|
562
572
|
surfaceNormal,
|
563
573
|
height,
|
564
574
|
mipLevel,
|
565
575
|
jitter
|
566
576
|
);
|
567
|
-
radiance +=
|
577
|
+
radiance += groundRadiance * RECIPROCAL_PI4 * groundBounceScale;
|
568
578
|
}
|
569
|
-
#endif //
|
579
|
+
#endif // GROUND_BOUNCE
|
570
580
|
|
571
581
|
// Crude approximation of sky gradient. Better than none in the shadows.
|
572
582
|
float skyGradient = dot(weather.heightFraction * 0.5 + 0.5, media.weight);
|
573
|
-
radiance += skyIrradiance * RECIPROCAL_PI4 * skyGradient *
|
583
|
+
radiance += skyIrradiance * RECIPROCAL_PI4 * skyGradient * skyLightScale;
|
574
584
|
|
575
585
|
// Finally multiply by scattering.
|
576
586
|
radiance *= media.scattering;
|
@@ -638,14 +648,6 @@ float marchShadowLength(
|
|
638
648
|
vec3 position = rayDistance * rayDirection + rayOrigin;
|
639
649
|
float opticalDepth = sampleShadowOpticalDepth(position, 0.0, 0.0, jitter);
|
640
650
|
shadowLength += (1.0 - exp(-opticalDepth)) * stepSize * attenuation;
|
641
|
-
|
642
|
-
// Hack to prevent over-integration of shadow length. The shadow should be
|
643
|
-
// attenuated by the inscatter as the ray travels further.
|
644
|
-
attenuation *= attenuationFactor;
|
645
|
-
if (attenuation < 1e-5) {
|
646
|
-
break;
|
647
|
-
}
|
648
|
-
|
649
651
|
stepSize *= perspectiveStepScale;
|
650
652
|
rayDistance += stepSize;
|
651
653
|
}
|
@@ -696,7 +698,7 @@ vec4 approximateHaze(
|
|
696
698
|
vec3 skyIrradiance = vGroundIrradiance.sky;
|
697
699
|
vec3 sunIrradiance = vGroundIrradiance.sun;
|
698
700
|
vec3 inscatter = sunIrradiance * phaseFunction(cosTheta) * shadowTransmittance;
|
699
|
-
inscatter += skyIrradiance * RECIPROCAL_PI4 *
|
701
|
+
inscatter += skyIrradiance * RECIPROCAL_PI4 * skyLightScale * transmittance;
|
700
702
|
inscatter *= hazeScatteringCoefficient / (hazeAbsorptionCoefficient + hazeScatteringCoefficient);
|
701
703
|
return vec4(inscatter, transmittance);
|
702
704
|
}
|
package/src/shaders/clouds.vert
CHANGED
@@ -1,8 +1,21 @@
|
|
1
1
|
precision highp float;
|
2
2
|
precision highp sampler3D;
|
3
3
|
|
4
|
-
#include "atmosphere/
|
5
|
-
|
4
|
+
#include "atmosphere/bruneton/definitions"
|
5
|
+
|
6
|
+
uniform AtmosphereParameters ATMOSPHERE;
|
7
|
+
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
|
8
|
+
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
|
9
|
+
|
10
|
+
uniform sampler2D transmittance_texture;
|
11
|
+
uniform sampler3D scattering_texture;
|
12
|
+
uniform sampler2D irradiance_texture;
|
13
|
+
uniform sampler3D single_mie_scattering_texture;
|
14
|
+
uniform sampler3D higher_order_scattering_texture;
|
15
|
+
|
16
|
+
#include "atmosphere/bruneton/common"
|
17
|
+
#include "atmosphere/bruneton/runtime"
|
18
|
+
|
6
19
|
#include "types"
|
7
20
|
|
8
21
|
uniform mat4 inverseProjectionMatrix;
|
@@ -32,7 +45,7 @@ out GroundIrradiance vGroundIrradiance;
|
|
32
45
|
out CloudsIrradiance vCloudsIrradiance;
|
33
46
|
|
34
47
|
void sampleSunSkyIrradiance(const vec3 positionECEF) {
|
35
|
-
vGroundIrradiance.sun =
|
48
|
+
vGroundIrradiance.sun = GetSunAndSkyScalarIrradiance(
|
36
49
|
positionECEF * METER_TO_LENGTH_UNIT,
|
37
50
|
sunDirection,
|
38
51
|
vGroundIrradiance.sky
|
@@ -40,12 +53,12 @@ void sampleSunSkyIrradiance(const vec3 positionECEF) {
|
|
40
53
|
|
41
54
|
vec3 surfaceNormal = normalize(positionECEF);
|
42
55
|
vec2 radii = (bottomRadius + vec2(minHeight, maxHeight)) * METER_TO_LENGTH_UNIT;
|
43
|
-
vCloudsIrradiance.minSun =
|
56
|
+
vCloudsIrradiance.minSun = GetSunAndSkyScalarIrradiance(
|
44
57
|
surfaceNormal * radii.x,
|
45
58
|
sunDirection,
|
46
59
|
vCloudsIrradiance.minSky
|
47
60
|
);
|
48
|
-
vCloudsIrradiance.maxSun =
|
61
|
+
vCloudsIrradiance.maxSun = GetSunAndSkyScalarIrradiance(
|
49
62
|
surfaceNormal * radii.y,
|
50
63
|
sunDirection,
|
51
64
|
vCloudsIrradiance.maxSky
|
package/src/shaders/types.glsl
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#ifdef VARIANCE_9_SAMPLES
|
2
|
-
#define VARIANCE_OFFSET_COUNT
|
2
|
+
#define VARIANCE_OFFSET_COUNT 8
|
3
3
|
const ivec2 varianceOffsets[8] = ivec2[8](
|
4
4
|
ivec2(-1, -1),
|
5
5
|
ivec2(-1, 1),
|
@@ -11,7 +11,7 @@ const ivec2 varianceOffsets[8] = ivec2[8](
|
|
11
11
|
ivec2(-1, 0)
|
12
12
|
);
|
13
13
|
#else // VARIANCE_9_SAMPLES
|
14
|
-
#define VARIANCE_OFFSET_COUNT
|
14
|
+
#define VARIANCE_OFFSET_COUNT 4
|
15
15
|
const ivec2 varianceOffsets[4] = ivec2[4](ivec2(1, 0), ivec2(0, -1), ivec2(0, 1), ivec2(-1, 0));
|
16
16
|
#endif // VARIANCE_9_SAMPLES
|
17
17
|
|
package/src/uniforms.ts
CHANGED
@@ -8,11 +8,11 @@ import {
|
|
8
8
|
type Vector2
|
9
9
|
} from 'three'
|
10
10
|
import invariant from 'tiny-invariant'
|
11
|
-
import {
|
11
|
+
import type { Primitive } from 'type-fest'
|
12
12
|
|
13
|
-
import {
|
13
|
+
import type { AtmosphereParameters } from '@takram/three-atmosphere'
|
14
14
|
|
15
|
-
import {
|
15
|
+
import type { CloudLayers } from './CloudLayers'
|
16
16
|
|
17
17
|
export interface CloudParameterUniforms {
|
18
18
|
// Participating medium
|
package/types/CloudsEffect.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Effect, Resolution } from 'postprocessing';
|
2
|
-
import { Camera, Data3DTexture, EventDispatcher, Matrix4, Texture, Uniform, Vector2, Vector3,
|
2
|
+
import { Camera, Data3DTexture, EventDispatcher, Matrix4, Texture, Uniform, Vector2, Vector3, DepthPackingStrategies, TextureDataType, WebGLRenderer, WebGLRenderTarget } from 'three';
|
3
3
|
import { AtmosphereParameters, AtmosphereOverlay, AtmosphereShadow, AtmosphereShadowLength } from '@takram/three-atmosphere';
|
4
4
|
import { UniformMap, Ellipsoid, PropertyShorthand, UniformShorthand } from '@takram/three-geospatial';
|
5
5
|
import { CascadedShadowMaps } from './CascadedShadowMaps';
|
@@ -12,7 +12,7 @@ import { QualityPreset } from './qualityPresets';
|
|
12
12
|
import { ShadowMaterial } from './ShadowMaterial';
|
13
13
|
import { ShadowPass } from './ShadowPass';
|
14
14
|
declare const cloudsUniformKeys: ["maxIterationCount", "minStepSize", "maxStepSize", "maxRayDistance", "perspectiveStepScale", "minDensity", "minExtinction", "minTransmittance", "maxIterationCountToSun", "maxIterationCountToGround", "minSecondaryStepSize", "secondaryStepScale", "maxShadowFilterRadius", "maxShadowLengthIterationCount", "minShadowLengthStepSize", "maxShadowLengthRayDistance", "hazeDensityScale", "hazeExponent", "hazeScatteringCoefficient", "hazeAbsorptionCoefficient"];
|
15
|
-
declare const cloudsMaterialParameterKeys: ["multiScatteringOctaves", "
|
15
|
+
declare const cloudsMaterialParameterKeys: ["multiScatteringOctaves", "accurateSunSkyLight", "accuratePhaseFunction"];
|
16
16
|
declare const shadowUniformKeys: ["maxIterationCount", "minStepSize", "maxStepSize", "minDensity", "minExtinction", "minTransmittance", "opticalDepthTailScale"];
|
17
17
|
declare const shadowMaterialParameterKeys: ["temporalJitter"];
|
18
18
|
declare const shadowPassParameterKeys: ["temporalPass"];
|
@@ -140,10 +140,18 @@ export declare class CloudsEffect extends Effect {
|
|
140
140
|
set scatterAnisotropy2(value: number);
|
141
141
|
get scatterAnisotropyMix(): number;
|
142
142
|
set scatterAnisotropyMix(value: number);
|
143
|
+
/** @deprecated Use skyLightScale instead. */
|
143
144
|
get skyIrradianceScale(): number;
|
145
|
+
/** @deprecated Use skyLightScale instead. */
|
144
146
|
set skyIrradianceScale(value: number);
|
147
|
+
get skyLightScale(): number;
|
148
|
+
set skyLightScale(value: number);
|
149
|
+
/** @deprecated Use groundBounceScale instead. */
|
145
150
|
get groundIrradianceScale(): number;
|
151
|
+
/** @deprecated Use groundBounceScale instead. */
|
146
152
|
set groundIrradianceScale(value: number);
|
153
|
+
get groundBounceScale(): number;
|
154
|
+
set groundBounceScale(value: number);
|
147
155
|
get powderScale(): number;
|
148
156
|
set powderScale(value: number);
|
149
157
|
get powderExponent(): number;
|
@@ -151,16 +159,18 @@ export declare class CloudsEffect extends Effect {
|
|
151
159
|
get atmosphereOverlay(): AtmosphereOverlay | null;
|
152
160
|
get atmosphereShadow(): AtmosphereShadow | null;
|
153
161
|
get atmosphereShadowLength(): AtmosphereShadowLength | null;
|
154
|
-
get irradianceTexture():
|
155
|
-
set irradianceTexture(value:
|
162
|
+
get irradianceTexture(): Texture | null;
|
163
|
+
set irradianceTexture(value: Texture | null);
|
156
164
|
get scatteringTexture(): Data3DTexture | null;
|
157
165
|
set scatteringTexture(value: Data3DTexture | null);
|
158
|
-
get transmittanceTexture():
|
159
|
-
set transmittanceTexture(value:
|
166
|
+
get transmittanceTexture(): Texture | null;
|
167
|
+
set transmittanceTexture(value: Texture | null);
|
168
|
+
get singleMieScatteringTexture(): Data3DTexture | null;
|
169
|
+
set singleMieScatteringTexture(value: Data3DTexture | null);
|
170
|
+
get higherOrderScatteringTexture(): Data3DTexture | null;
|
171
|
+
set higherOrderScatteringTexture(value: Data3DTexture | null);
|
160
172
|
get ellipsoid(): Ellipsoid;
|
161
173
|
set ellipsoid(value: Ellipsoid);
|
162
|
-
get photometric(): boolean;
|
163
|
-
set photometric(value: boolean);
|
164
174
|
get sunAngularRadius(): number;
|
165
175
|
set sunAngularRadius(value: number);
|
166
176
|
}
|
@@ -26,8 +26,8 @@ export interface CloudsMaterialUniforms extends CloudParameterUniforms, CloudLay
|
|
26
26
|
targetUvScale: Uniform<Vector2>;
|
27
27
|
mipLevelScale: Uniform<number>;
|
28
28
|
stbnTexture: Uniform<Data3DTexture | null>;
|
29
|
-
|
30
|
-
|
29
|
+
skyLightScale: Uniform<number>;
|
30
|
+
groundBounceScale: Uniform<number>;
|
31
31
|
powderScale: Uniform<number>;
|
32
32
|
powderExponent: Uniform<number>;
|
33
33
|
maxIterationCount: Uniform<number>;
|
@@ -76,7 +76,11 @@ export declare class CloudsMaterial extends AtmosphereMaterialBase {
|
|
76
76
|
shadowLength: boolean;
|
77
77
|
haze: boolean;
|
78
78
|
multiScatteringOctaves: number;
|
79
|
-
|
79
|
+
/** @deprecated Use accurateSunSkyLight instead. */
|
80
|
+
get accurateSunSkyIrradiance(): boolean;
|
81
|
+
/** @deprecated Use accurateSunSkyLight instead. */
|
82
|
+
set accurateSunSkyIrradiance(value: boolean);
|
83
|
+
accurateSunSkyLight: boolean;
|
80
84
|
accuratePhaseFunction: boolean;
|
81
85
|
shadowCascadeCount: number;
|
82
86
|
shadowSampleCount: number;
|