-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathCloudsEffect.ts
802 lines (673 loc) · 23.3 KB
/
CloudsEffect.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
import { Effect, EffectAttribute, Resolution } from 'postprocessing'
import {
Camera,
Data3DTexture,
EventDispatcher,
Matrix4,
Texture,
Uniform,
Vector2,
Vector3,
type DataTexture,
type DepthPackingStrategies,
type PerspectiveCamera,
type TextureDataType,
type WebGLRenderer,
type WebGLRenderTarget
} from 'three'
import {
AtmosphereParameters,
getAltitudeCorrectionOffset,
type AtmosphereOverlay,
type AtmosphereShadow,
type AtmosphereShadowLength
} from '@takram/three-atmosphere'
import {
define,
definePropertyShorthand,
defineUniformShorthand,
lerp,
UniformMap,
type Ellipsoid,
type PropertyShorthand,
type UniformShorthand
} from '@takram/three-geospatial'
import { CascadedShadowMaps } from './CascadedShadowMaps'
import { CloudLayers } from './CloudLayers'
import {
type CloudsMaterial,
type CloudsMaterialUniforms
} from './CloudsMaterial'
import { CloudsPass } from './CloudsPass'
import { type Procedural3DTexture } from './Procedural3DTexture'
import { type ProceduralTexture } from './ProceduralTexture'
import { defaults, qualityPresets, type QualityPreset } from './qualityPresets'
import {
type ShadowMaterial,
type ShadowMaterialUniforms
} from './ShadowMaterial'
import { ShadowPass } from './ShadowPass'
import {
createAtmosphereUniforms,
createCloudLayerUniforms,
createCloudParameterUniforms,
updateCloudLayerUniforms,
type AtmosphereUniforms,
type CloudLayerUniforms,
type CloudParameterUniforms
} from './uniforms'
import fragmentShader from './shaders/cloudsEffect.frag?raw'
const vector3Scratch = /*#__PURE__*/ new Vector3()
const vector2Scratch = /*#__PURE__*/ new Vector2()
const cloudsUniformKeys = [
'maxIterationCount',
'minStepSize',
'maxStepSize',
'maxRayDistance',
'perspectiveStepScale',
'minDensity',
'minExtinction',
'minTransmittance',
'maxIterationCountToSun',
'maxIterationCountToGround',
'minSecondaryStepSize',
'secondaryStepScale',
'maxShadowFilterRadius',
'maxShadowLengthIterationCount',
'minShadowLengthStepSize',
'maxShadowLengthRayDistance',
'hazeDensityScale',
'hazeExponent'
] as const satisfies Array<keyof CloudsMaterialUniforms>
// prettier-ignore
const cloudsMaterialParameterKeys = [
'multiScatteringOctaves',
'accurateSunSkyIrradiance',
'accuratePhaseFunction',
] as const satisfies Array<keyof CloudsMaterial>
const shadowUniformKeys = [
'maxIterationCount',
'minStepSize',
'maxStepSize',
'minDensity',
'minExtinction',
'minTransmittance',
'opticalDepthTailScale'
] as const satisfies Array<keyof ShadowMaterialUniforms>
// prettier-ignore
const shadowMaterialParameterKeys = [
'temporalJitter'
] as const satisfies Array<keyof ShadowMaterial>
// prettier-ignore
const shadowPassParameterKeys = [
'temporalPass'
] as const satisfies Array<keyof ShadowPass>
const shadowMapsParameterKeys = [
'cascadeCount',
'mapSize',
'maxFar',
'farScale',
'splitMode',
'splitLambda'
] as const satisfies Array<keyof CascadedShadowMaps>
interface CloudsShorthand
extends UniformShorthand<CloudsMaterial, (typeof cloudsUniformKeys)[number]>,
PropertyShorthand<[CloudsMaterial, typeof cloudsMaterialParameterKeys]> {}
interface ShadowShorthand
extends UniformShorthand<ShadowMaterial, (typeof shadowUniformKeys)[number]>,
PropertyShorthand<
[
ShadowMaterial,
typeof shadowMaterialParameterKeys,
ShadowPass,
typeof shadowPassParameterKeys,
CascadedShadowMaps,
typeof shadowMapsParameterKeys
]
> {}
export interface CloudsEffectChangeEvent {
type: 'change'
target?: CloudsEffect
property?: 'atmosphereOverlay' | 'atmosphereShadow' | 'atmosphereShadowLength'
}
const changeEvent: CloudsEffectChangeEvent = {
type: 'change'
}
export interface CloudsEffectUniforms {
cloudsBuffer: Uniform<Texture | null>
}
export interface CloudsEffectOptions {
resolutionScale?: number
width?: number
height?: number
resolutionX?: number
resolutionY?: number
}
export const cloudsPassOptionsDefaults = {
resolutionScale: defaults.resolutionScale,
width: Resolution.AUTO_SIZE,
height: Resolution.AUTO_SIZE
} satisfies CloudsEffectOptions
// We explicitly use Effect instead of Pass, even though this only renders to
// render buffers. Pass, at least when used with R3F, tends to be unstable
// during hot reloading. This should not impact performance since this effect
// can be merged.
export class CloudsEffect extends Effect {
declare uniforms: UniformMap<CloudsEffectUniforms>
readonly cloudLayers = CloudLayers.DEFAULT.clone()
correctAltitude = true
// Mutable instances of cloud parameter uniforms
readonly localWeatherRepeat = new Vector2().setScalar(100)
readonly localWeatherOffset = new Vector2()
readonly shapeRepeat = new Vector3().setScalar(0.0003)
readonly shapeOffset = new Vector3()
readonly shapeDetailRepeat = new Vector3().setScalar(0.006)
readonly shapeDetailOffset = new Vector3()
readonly turbulenceRepeat = new Vector2().setScalar(20)
// Mutable instances of atmosphere parameter uniforms
readonly ellipsoidCenter = new Vector3()
readonly ellipsoidMatrix = new Matrix4()
private readonly inverseEllipsoidMatrix = new Matrix4()
private readonly altitudeCorrection = new Vector3()
readonly sunDirection = new Vector3()
// Uniforms shared by both cloud and shadow materials
private readonly parameterUniforms: CloudParameterUniforms
private readonly layerUniforms: CloudLayerUniforms
private readonly atmosphereUniforms: AtmosphereUniforms
readonly localWeatherVelocity = new Vector2()
readonly shapeVelocity = new Vector3()
readonly shapeDetailVelocity = new Vector3()
// Weather and shape procedural textures
private proceduralLocalWeather?: ProceduralTexture
private proceduralShape?: Procedural3DTexture
private proceduralShapeDetail?: Procedural3DTexture
private proceduralTurbulence?: ProceduralTexture
readonly shadowMaps: CascadedShadowMaps
readonly shadowPass: ShadowPass
readonly cloudsPass: CloudsPass
readonly clouds: CloudsShorthand
readonly shadow: ShadowShorthand
private _atmosphereOverlay: AtmosphereOverlay | null = null
private _atmosphereShadow: AtmosphereShadow | null = null
private _atmosphereShadowLength: AtmosphereShadowLength | null = null
readonly resolution: Resolution
readonly events = new EventDispatcher<{
change: CloudsEffectChangeEvent
}>()
private frame = 0
private shadowCascadeCount = 0
private readonly shadowMapSize = new Vector2()
constructor(
private camera: Camera = new Camera(),
options?: CloudsEffectOptions,
private readonly atmosphere = AtmosphereParameters.DEFAULT
) {
super('CloudsEffect', fragmentShader, {
attributes: EffectAttribute.DEPTH,
uniforms: new Map<string, Uniform>([['cloudsBuffer', new Uniform(null)]])
})
const {
resolutionScale,
width,
height,
resolutionX = width,
resolutionY = height
} = {
...cloudsPassOptionsDefaults,
...options
}
this.shadowMaps = new CascadedShadowMaps({
cascadeCount: defaults.shadow.cascadeCount,
mapSize: defaults.shadow.mapSize,
splitLambda: 0.6
})
this.parameterUniforms = createCloudParameterUniforms({
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 = createCloudLayerUniforms()
this.atmosphereUniforms = createAtmosphereUniforms(atmosphere, {
ellipsoidCenter: this.ellipsoidCenter,
ellipsoidMatrix: this.ellipsoidMatrix,
inverseEllipsoidMatrix: this.inverseEllipsoidMatrix,
altitudeCorrection: this.altitudeCorrection,
sunDirection: this.sunDirection
})
const passOptions = {
shadow: this.shadowMaps,
parameterUniforms: this.parameterUniforms,
layerUniforms: this.layerUniforms,
atmosphereUniforms: this.atmosphereUniforms
}
this.shadowPass = new ShadowPass(passOptions)
this.cloudsPass = new CloudsPass(passOptions, atmosphere)
this.clouds = definePropertyShorthand(
defineUniformShorthand(
{},
this.cloudsPass.currentMaterial,
cloudsUniformKeys
),
this.cloudsPass.currentMaterial,
cloudsMaterialParameterKeys
)
this.shadow = definePropertyShorthand(
defineUniformShorthand(
{},
this.shadowPass.currentMaterial,
shadowUniformKeys
),
this.shadowPass.currentMaterial,
shadowMaterialParameterKeys,
this.shadowPass,
shadowPassParameterKeys,
this.shadowMaps,
shadowMapsParameterKeys
)
this.resolution = new Resolution(
this,
resolutionX,
resolutionY,
resolutionScale
)
this.resolution.addEventListener('change', this.onResolutionChange)
}
private readonly onResolutionChange = (): void => {
this.setSize(this.resolution.baseWidth, this.resolution.baseHeight)
}
override get mainCamera(): Camera {
return this.camera
}
override set mainCamera(value: Camera) {
this.camera = value
this.shadowPass.mainCamera = value
this.cloudsPass.mainCamera = value
}
override initialize(
renderer: WebGLRenderer,
alpha: boolean,
frameBufferType: TextureDataType
): void {
this.shadowPass.initialize(renderer, alpha, frameBufferType)
this.cloudsPass.initialize(renderer, alpha, frameBufferType)
}
private updateSharedUniforms(deltaTime: number): void {
updateCloudLayerUniforms(this.layerUniforms, this.cloudLayers)
// Apply velocity to offset uniforms.
const { parameterUniforms } = this
parameterUniforms.localWeatherOffset.value.add(
vector2Scratch.copy(this.localWeatherVelocity).multiplyScalar(deltaTime)
)
parameterUniforms.shapeOffset.value.add(
vector3Scratch.copy(this.shapeVelocity).multiplyScalar(deltaTime)
)
parameterUniforms.shapeDetailOffset.value.add(
vector3Scratch.copy(this.shapeDetailVelocity).multiplyScalar(deltaTime)
)
// Update atmosphere uniforms.
const inverseEllipsoidMatrix = this.inverseEllipsoidMatrix
.copy(this.ellipsoidMatrix)
.invert()
const cameraPositionECEF = this.camera
.getWorldPosition(vector3Scratch)
.applyMatrix4(inverseEllipsoidMatrix)
.sub(this.ellipsoidCenter)
const altitudeCorrection = this.altitudeCorrection
if (this.correctAltitude) {
getAltitudeCorrectionOffset(
cameraPositionECEF,
this.atmosphere.bottomRadius,
this.ellipsoid,
altitudeCorrection,
false
)
} else {
altitudeCorrection.setScalar(0)
}
// TODO: Position the sun on the top atmosphere sphere.
// Increase light's distance to the target when the sun is at the horizon.
const surfaceNormal = this.ellipsoid.getSurfaceNormal(
cameraPositionECEF,
vector3Scratch
)
const zenithAngle = this.sunDirection.dot(surfaceNormal)
const distance = lerp(1e6, 1e3, zenithAngle)
this.shadowMaps.update(
this.camera as PerspectiveCamera,
// The sun direction must be rotated with the ellipsoid to ensure the
// frusta are constructed correctly. Note this affects the transformation
// in the shadow shader.
vector3Scratch.copy(this.sunDirection).applyMatrix4(this.ellipsoidMatrix),
distance
)
}
private updateWeatherTextureChannels(): void {
const value = this.cloudLayers.localWeatherChannels
this.cloudsPass.currentMaterial.localWeatherChannels = value
this.shadowPass.currentMaterial.localWeatherChannels = value
}
private updateAtmosphereComposition(): void {
const { shadowMaps, shadowPass, cloudsPass } = this
const shadowUniforms = shadowPass.currentMaterial.uniforms
const cloudsUniforms = cloudsPass.currentMaterial.uniforms
const prevOverlay = this._atmosphereOverlay
const nextOverlay = Object.assign(this._atmosphereOverlay ?? {}, {
map: cloudsPass.outputBuffer
} satisfies AtmosphereOverlay)
if (prevOverlay !== nextOverlay) {
this._atmosphereOverlay = nextOverlay
changeEvent.target = this
changeEvent.property = 'atmosphereOverlay'
this.events.dispatchEvent(changeEvent)
}
const prevShadow = this._atmosphereShadow
const nextShadow = Object.assign(this._atmosphereShadow ?? {}, {
map: shadowPass.outputBuffer,
mapSize: shadowMaps.mapSize,
cascadeCount: shadowMaps.cascadeCount,
intervals: cloudsUniforms.shadowIntervals.value,
matrices: cloudsUniforms.shadowMatrices.value,
inverseMatrices: shadowUniforms.inverseShadowMatrices.value,
far: shadowMaps.far,
topHeight: cloudsUniforms.shadowTopHeight.value
} satisfies AtmosphereShadow)
if (prevShadow !== nextShadow) {
this._atmosphereShadow = nextShadow
changeEvent.target = this
changeEvent.property = 'atmosphereShadow'
this.events.dispatchEvent(changeEvent)
}
const prevShadowLength = this._atmosphereShadowLength
const nextShadowLength =
cloudsPass.shadowLengthBuffer != null
? Object.assign(this._atmosphereShadowLength ?? {}, {
map: cloudsPass.shadowLengthBuffer
} satisfies AtmosphereShadowLength)
: null
if (prevShadowLength !== nextShadowLength) {
this._atmosphereShadowLength = nextShadowLength
changeEvent.target = this
changeEvent.property = 'atmosphereShadowLength'
this.events.dispatchEvent(changeEvent)
}
}
override update(
renderer: WebGLRenderer,
inputBuffer: WebGLRenderTarget,
deltaTime = 0
): void {
const { shadowMaps, shadowPass, cloudsPass } = this
if (
shadowMaps.cascadeCount !== this.shadowCascadeCount ||
!shadowMaps.mapSize.equals(this.shadowMapSize)
) {
const { width, height } = shadowMaps.mapSize
const depth = shadowMaps.cascadeCount
this.shadowMapSize.set(width, height)
this.shadowCascadeCount = depth
shadowPass.setSize(width, height, depth)
cloudsPass.setShadowSize(width, height, depth)
}
this.proceduralLocalWeather?.render(renderer, deltaTime)
this.proceduralShape?.render(renderer, deltaTime)
this.proceduralShapeDetail?.render(renderer, deltaTime)
this.proceduralTurbulence?.render(renderer, deltaTime)
++this.frame
this.updateSharedUniforms(deltaTime)
this.updateWeatherTextureChannels()
shadowPass.update(renderer, this.frame, deltaTime)
cloudsPass.shadowBuffer = shadowPass.outputBuffer
cloudsPass.update(renderer, this.frame, deltaTime)
this.updateAtmosphereComposition()
this.uniforms.get('cloudsBuffer').value = this.cloudsPass.outputBuffer
}
override setSize(baseWidth: number, baseHeight: number): void {
const { resolution } = this
resolution.setBaseSize(baseWidth, baseHeight)
const { width, height } = resolution
this.cloudsPass.setSize(width, height)
}
override setDepthTexture(
depthTexture: Texture,
depthPacking?: DepthPackingStrategies
): void {
this.shadowPass.setDepthTexture(depthTexture, depthPacking)
this.cloudsPass.setDepthTexture(depthTexture, depthPacking)
}
@define('SKIP_RENDERING')
skipRendering = true
// eslint-disable-next-line accessor-pairs
set qualityPreset(value: QualityPreset) {
const { clouds, shadow, ...props } = qualityPresets[value]
Object.assign(this, props)
Object.assign(this.clouds, clouds)
Object.assign(this.shadow, shadow)
}
// Textures
get localWeatherTexture(): Texture | ProceduralTexture | null {
return (
this.proceduralLocalWeather ??
this.parameterUniforms.localWeatherTexture.value
)
}
set localWeatherTexture(value: Texture | ProceduralTexture | null) {
if (value instanceof Texture || value == null) {
this.proceduralLocalWeather = undefined
this.parameterUniforms.localWeatherTexture.value = value
} else {
this.proceduralLocalWeather = value
this.parameterUniforms.localWeatherTexture.value = value.texture
}
}
get shapeTexture(): Data3DTexture | Procedural3DTexture | null {
return this.proceduralShape ?? this.parameterUniforms.shapeTexture.value
}
set shapeTexture(value: Data3DTexture | Procedural3DTexture | null) {
if (value instanceof Data3DTexture || value == null) {
this.proceduralShape = undefined
this.parameterUniforms.shapeTexture.value = value
} else {
this.proceduralShape = value
this.parameterUniforms.shapeTexture.value = value.texture
}
}
get shapeDetailTexture(): Data3DTexture | Procedural3DTexture | null {
return (
this.proceduralShapeDetail ??
this.parameterUniforms.shapeDetailTexture.value
)
}
set shapeDetailTexture(value: Data3DTexture | Procedural3DTexture | null) {
if (value instanceof Data3DTexture || value == null) {
this.proceduralShapeDetail = undefined
this.parameterUniforms.shapeDetailTexture.value = value
} else {
this.proceduralShapeDetail = value
this.parameterUniforms.shapeDetailTexture.value = value.texture
}
}
get turbulenceTexture(): Texture | ProceduralTexture | null {
return (
this.proceduralTurbulence ??
this.parameterUniforms.turbulenceTexture.value
)
}
set turbulenceTexture(value: Texture | ProceduralTexture | null) {
if (value instanceof Texture || value == null) {
this.proceduralTurbulence = undefined
this.parameterUniforms.turbulenceTexture.value = value
} else {
this.proceduralTurbulence = value
this.parameterUniforms.turbulenceTexture.value = value.texture
}
}
get stbnTexture(): Data3DTexture | null {
return this.cloudsPass.currentMaterial.uniforms.stbnTexture.value
}
set stbnTexture(value: Data3DTexture | null) {
this.cloudsPass.currentMaterial.uniforms.stbnTexture.value = value
this.shadowPass.currentMaterial.uniforms.stbnTexture.value = value
}
// Rendering controls
get resolutionScale(): number {
return this.resolution.scale
}
set resolutionScale(value: number) {
this.resolution.scale = value
}
get temporalUpscale(): boolean {
return this.cloudsPass.temporalUpscale
}
set temporalUpscale(value: boolean) {
this.cloudsPass.temporalUpscale = value
}
get lightShafts(): boolean {
return this.cloudsPass.lightShafts
}
set lightShafts(value: boolean) {
this.cloudsPass.lightShafts = value
}
get shapeDetail(): boolean {
return this.cloudsPass.currentMaterial.shapeDetail
}
set shapeDetail(value: boolean) {
this.cloudsPass.currentMaterial.shapeDetail = value
this.shadowPass.currentMaterial.shapeDetail = value
}
get turbulence(): boolean {
return this.cloudsPass.currentMaterial.turbulence
}
set turbulence(value: boolean) {
this.cloudsPass.currentMaterial.turbulence = value
this.shadowPass.currentMaterial.turbulence = value
}
get haze(): boolean {
return this.cloudsPass.currentMaterial.haze
}
set haze(value: boolean) {
this.cloudsPass.currentMaterial.haze = value
}
// Cloud parameter primitives
get scatteringCoefficient(): number {
return this.parameterUniforms.scatteringCoefficient.value
}
set scatteringCoefficient(value: number) {
this.parameterUniforms.scatteringCoefficient.value = value
}
get absorptionCoefficient(): number {
return this.parameterUniforms.absorptionCoefficient.value
}
set absorptionCoefficient(value: number) {
this.parameterUniforms.absorptionCoefficient.value = value
}
get coverage(): number {
return this.parameterUniforms.coverage.value
}
set coverage(value: number) {
this.parameterUniforms.coverage.value = value
}
get turbulenceDisplacement(): number {
return this.parameterUniforms.turbulenceDisplacement.value
}
set turbulenceDisplacement(value: number) {
this.parameterUniforms.turbulenceDisplacement.value = value
}
// Scattering parameters
get scatterAnisotropy1(): number {
return this.cloudsPass.currentMaterial.scatterAnisotropy1
}
set scatterAnisotropy1(value: number) {
this.cloudsPass.currentMaterial.scatterAnisotropy1 = value
}
get scatterAnisotropy2(): number {
return this.cloudsPass.currentMaterial.scatterAnisotropy2
}
set scatterAnisotropy2(value: number) {
this.cloudsPass.currentMaterial.scatterAnisotropy2 = value
}
get scatterAnisotropyMix(): number {
return this.cloudsPass.currentMaterial.scatterAnisotropyMix
}
set scatterAnisotropyMix(value: number) {
this.cloudsPass.currentMaterial.scatterAnisotropyMix = value
}
get skyIrradianceScale(): number {
return this.cloudsPass.currentMaterial.uniforms.skyIrradianceScale.value
}
set skyIrradianceScale(value: number) {
this.cloudsPass.currentMaterial.uniforms.skyIrradianceScale.value = value
}
get groundIrradianceScale(): number {
return this.cloudsPass.currentMaterial.uniforms.groundIrradianceScale.value
}
set groundIrradianceScale(value: number) {
this.cloudsPass.currentMaterial.uniforms.groundIrradianceScale.value = value
}
get powderScale(): number {
return this.cloudsPass.currentMaterial.uniforms.powderScale.value
}
set powderScale(value: number) {
this.cloudsPass.currentMaterial.uniforms.powderScale.value = value
}
get powderExponent(): number {
return this.cloudsPass.currentMaterial.uniforms.powderExponent.value
}
set powderExponent(value: number) {
this.cloudsPass.currentMaterial.uniforms.powderExponent.value = value
}
// Atmosphere composition
get atmosphereOverlay(): AtmosphereOverlay | null {
return this._atmosphereOverlay
}
get atmosphereShadow(): AtmosphereShadow | null {
return this._atmosphereShadow
}
get atmosphereShadowLength(): AtmosphereShadowLength | null {
return this._atmosphereShadowLength
}
// Atmosphere parameters
get irradianceTexture(): DataTexture | null {
return this.cloudsPass.currentMaterial.irradianceTexture
}
set irradianceTexture(value: DataTexture | null) {
this.cloudsPass.currentMaterial.irradianceTexture = value
}
get scatteringTexture(): Data3DTexture | null {
return this.cloudsPass.currentMaterial.scatteringTexture
}
set scatteringTexture(value: Data3DTexture | null) {
this.cloudsPass.currentMaterial.scatteringTexture = value
}
get transmittanceTexture(): DataTexture | null {
return this.cloudsPass.currentMaterial.transmittanceTexture
}
set transmittanceTexture(value: DataTexture | null) {
this.cloudsPass.currentMaterial.transmittanceTexture = value
}
get ellipsoid(): Ellipsoid {
return this.cloudsPass.currentMaterial.ellipsoid
}
set ellipsoid(value: Ellipsoid) {
this.cloudsPass.currentMaterial.ellipsoid = value
}
get photometric(): boolean {
return this.cloudsPass.currentMaterial.photometric
}
set photometric(value: boolean) {
this.cloudsPass.currentMaterial.photometric = value
}
get sunAngularRadius(): number {
return this.cloudsPass.currentMaterial.sunAngularRadius
}
set sunAngularRadius(value: number) {
this.cloudsPass.currentMaterial.sunAngularRadius = value
}
}