17#include <util/ue-header-guard-begin.h>
18#include "Camera/PlayerCameraManager.h"
19#include "Particles/ParticleSystem.h"
20#include "Particles/ParticleSystemComponent.h"
21#include "EngineUtils.h"
22#include "Components/ExponentialHeightFogComponent.h"
23#include "Components/ChildActorComponent.h"
24#include "Components/MeshComponent.h"
25#include "Components/DirectionalLightComponent.h"
26#include "Components/SkyAtmosphereComponent.h"
27#include "Components/LightComponent.h"
28#include "Components/PostProcessComponent.h"
29#include "Components/SceneCaptureComponent2D.h"
30#include "Components/SkyLightComponent.h"
31#include "Components/StaticMeshComponent.h"
32#include "Components/VolumetricCloudComponent.h"
33#include "Curves/CurveFloat.h"
34#include "Engine/StaticMesh.h"
35#include "Engine/TextureCube.h"
36#include "Engine/World.h"
37#include "HAL/IConsoleManager.h"
38#include "Kismet/GameplayStatics.h"
39#include "Kismet/KismetMaterialLibrary.h"
40#include "Materials/MaterialInstanceDynamic.h"
41#include "Materials/MaterialParameterCollection.h"
42#include "Rendering/SkyAtmosphereCommonData.h"
43#include "UObject/ConstructorHelpers.h"
44#include "UObject/UnrealType.h"
45#include <util/ue-header-guard-end.h>
50 TEXT(
"carla.Weather.SunAltitudeFalloff"),
52 TEXT(
"How much of the physical sin(elevation) falloff to apply to the sun intensity ")
53 TEXT(
"curve. 1 is fully physical, 0 leaves the rig's curve alone."),
59 TEXT(
"carla.Weather.SunFalloffExponent"),
61 TEXT(
"Power the sin(elevation) sun falloff is raised to. 1 is the plain sine, lower ")
62 TEXT(
"keeps a low sun brighter, 0 disables the falloff."),
66 TEXT(
"carla.Weather.SunHorizonFloor"),
68 TEXT(
"Lower bound on the sin(elevation) falloff factor, as a fraction of the zenith ")
69 TEXT(
"value. 0.004 is a real horizon sun's ~400 lux against ~100000 overhead."),
73 TEXT(
"carla.Weather.TransmittanceReleaseDeg"),
75 TEXT(
"Sun altitude, in degrees, by which the transmittance clamp has fully released ")
76 TEXT(
"back to the engine's -90. Between 0 and this it eases off."),
83 TEXT(
"carla.Weather.BloomIntensity"),
85 TEXT(
"Bloom intensity filled into the sky rig's post-process when the loaded profile ")
86 TEXT(
"does not set one, so the sun glows in the viewport. Negative leaves it alone."),
93 TEXT(
"carla.Weather.ExposureBias"),
95 TEXT(
"Auto exposure compensation, in EV, forced on the sky rig's post process. ")
96 TEXT(
"Negative leaves the rig's authored value."),
100 TEXT(
"carla.Weather.ExposureMaxEV"),
102 TEXT(
"Upper EV100 bound of the auto exposure range. Negative leaves the rig's value. ")
103 TEXT(
"Above 13 nothing measurably changes."),
110 TEXT(
"carla.Weather.SunIndirectIntensity"),
112 TEXT(
"IndirectLightingIntensity forced on the sky rig's sun. Negative leaves the rig's value."),
116 TEXT(
"carla.Weather.SkyLightIndirectIntensity"),
118 TEXT(
"IndirectLightingIntensity forced on the sky rig's sky light. Negative leaves the rig's value."),
122 TEXT(
"carla.Weather.TransmittanceMinElevationDeg"),
124 TEXT(
"Minimum sun elevation, in degrees, used to evaluate the atmospheric tint applied ")
125 TEXT(
"to lit surfaces. The engine default of -90 makes a sunset tint the whole city red. ")
126 TEXT(
"Values above ~5 light the city as if it were day under a night sky."),
130 TEXT(
"carla.Weather.DayNightBlendDeg"),
132 TEXT(
"Half-width, in degrees of sun altitude, of the band the sun/moon handover is ")
133 TEXT(
"spread over. 0 gives a hard switch at the horizon."),
139 TEXT(
"carla.Weather.MoonMinAltitudeDeg"),
141 TEXT(
"Lowest altitude, in degrees, the moon is aimed from. Keeps it lighting the city ")
142 TEXT(
"across dusk instead of from below the horizon. 0 is the plain anti-solar point."),
148 TEXT(
"carla.Weather.MoonFadeStartDeg"),
150 TEXT(
"Sun altitude, in degrees, at which the moon starts to fade in."),
154 TEXT(
"carla.Weather.MoonFullAltitudeDeg"),
156 TEXT(
"Sun altitude, in degrees, at which the moon reaches full MoonIntensity. ")
157 TEXT(
"Must be below MoonFadeStartDeg; otherwise the moon switches on hard there."),
163 TEXT(
"carla.Weather.MoonAtmosphereDisk"),
165 TEXT(
"Let SkyAtmosphere paint its flat disc for the moon. False hides it; the ")
166 TEXT(
"textured moon disc (carla.Weather.MoonDisc) replaces it."),
173 TEXT(
"carla.Weather.MoonDisc"),
175 TEXT(
"Draw the textured moon disc along the moon light's direction."),
181 TEXT(
"carla.Weather.MoonDiscAdditive"),
183 TEXT(
"Draw the moon disc additively over the sky (M_Moon_Additive) instead of as an ")
184 TEXT(
"opaque disc (M_Moon). Additive blends with the day sky; opaque is covered by ")
185 TEXT(
"clouds more exactly."),
189 TEXT(
"carla.Weather.MoonDiscContrast"),
191 TEXT(
"Contrast of the moon texture: 1 as authored, 0 flat grey."),
195 TEXT(
"carla.Weather.MoonDiscAngleDeg"),
197 TEXT(
"Apparent diameter of the moon disc in degrees. The real moon is 0.52; ")
198 TEXT(
"larger reads better on screen."),
202 TEXT(
"carla.Weather.MoonDiscDistanceKm"),
204 TEXT(
"Distance of the moon disc from the sky sphere's centre, in km. Must be beyond ")
205 TEXT(
"the clouds so they cover it. Clamped to MoonDiscSphereFraction of the sphere."),
209 TEXT(
"carla.Weather.MoonDiscSphereFraction"),
211 TEXT(
"Largest distance of the moon disc as a fraction of the sky sphere's radius, ")
212 TEXT(
"so the sphere never draws in front of it."),
218 TEXT(
"carla.Weather.MoonDiscBrightnessStartDeg"),
220 TEXT(
"Sun altitude at which the moon disc starts dimming from its dusk brightness."),
224 TEXT(
"carla.Weather.MoonDiscBrightnessEndDeg"),
226 TEXT(
"Sun altitude at which the moon disc reaches its night brightness."),
230 TEXT(
"carla.Weather.MoonDiscNightBrightness"),
232 TEXT(
"Emissive brightness of the moon disc at full night. Lower also means less bloom ")
233 TEXT(
"around it, the only per-object bloom control there is."),
237 TEXT(
"carla.Weather.MoonDiscDuskBrightness"),
239 TEXT(
"Emissive brightness of the moon disc while the sun is still up, blended to the ")
240 TEXT(
"night value between MoonDiscBrightnessStartDeg and MoonDiscBrightnessEndDeg."),
248 TEXT(
"carla.Weather.MoonHaloMieScale"),
250 TEXT(
"Factor on the atmosphere's Mie scattering at night, dimming the moon's halo. ")
251 TEXT(
"1 leaves it as the rig sets it."),
255 TEXT(
"carla.Weather.MoonHaloMieAnisotropy"),
257 TEXT(
"Mie anisotropy at night: closer to 1 makes the moon's halo smaller. Negative ")
258 TEXT(
"leaves it as the rig sets it."),
262 TEXT(
"carla.Weather.MoonHaloStartDeg"),
264 TEXT(
"Sun altitude at which the night Mie settings (MoonHaloMieScale, ")
265 TEXT(
"MoonHaloMieAnisotropy) start blending in."),
269 TEXT(
"carla.Weather.MoonHaloEndDeg"),
271 TEXT(
"Sun altitude at which the night Mie settings are fully applied."),
277 TEXT(
"carla.Weather.MoonIntensity"),
279 TEXT(
"Minimum DirectionalLightComponentMoon intensity (lux) enforced on the sky rig, ")
280 TEXT(
"faded in between MoonFadeStartDeg and MoonFullAltitudeDeg of sun altitude. Set 0 to ")
281 TEXT(
"leave the rig's authored/curve-driven moon intensity untouched."),
285 TEXT(
"carla.Weather.NightSkylightIntensity"),
287 TEXT(
"Minimum SkyLightComponent intensity enforced on the sky rig whenever ")
288 TEXT(
"SunAltitudeAngle < 0 (same units as the rig's SkyIntensity_Curve). Set 0 to ")
289 TEXT(
"leave the rig's curve-driven skylight intensity untouched."),
302 TEXT(
"carla.Weather.SunTwilightEndDeg"),
304 TEXT(
"Sun altitude at which the sun light has faded out below the horizon. ")
305 TEXT(
"0 or above leaves the rig's hard cut at the horizon."),
309 TEXT(
"carla.Weather.SunTwilightStartDeg"),
311 TEXT(
"Sun altitude at which the twilight fade starts, from the sun's value there."),
315 TEXT(
"carla.Weather.SunTwilightEndFraction"),
317 TEXT(
"Fraction of the sun's intensity at SunTwilightStartDeg left at SunTwilightEndDeg; ")
318 TEXT(
"the fade is log-linear in between."),
324 TEXT(
"carla.Weather.SkySphereShowDeg"),
326 TEXT(
"Sun altitude below which the night sky sphere (stars) is shown in front of the ")
335 TEXT(
"carla.Weather.SkySphereScale"),
337 TEXT(
"Factor on the night sky sphere's size, so it draws behind the volumetric clouds. ")
338 TEXT(
"1 leaves it as authored."),
342 TEXT(
"carla.Weather.SkySphereCloudOpacity"),
344 TEXT(
"\"Cloud opacity\" of the night sky sphere's painted clouds. Negative leaves the ")
345 TEXT(
"asset's value."),
353 TEXT(
"carla.Weather.SkySphereNightColor"),
354 TEXT(
"0.002 0.002 0.0025"),
355 TEXT(
"Horizon, zenith and cloud colour of the night sky sphere, \"R G B\". Anything ")
356 TEXT(
"else (e.g. \"off\") leaves the sphere's sun-driven colours."),
360 TEXT(
"carla.Weather.StreetLightsOnDeg"),
362 TEXT(
"Sun altitude at or below which street lights are switched on."),
412 TEXT(
"carla.Weather.CityGlow"),
414 TEXT(
"Night emission of the clouds from city lights (0 off)."),
418 TEXT(
"carla.Weather.CityGlowColor"),
419 TEXT(
"1.0 0.85 0.7"),
420 TEXT(
"Colour of the city glow on the clouds, \"R G B\"."),
424 TEXT(
"carla.Weather.StarsBrightness"),
426 TEXT(
"Value forced into the night sky sphere's \"Stars Brightness\" variable ")
427 TEXT(
"(BP_Sky_Sphere, engine content) whenever SunAltitudeAngle < 0. Set 0 to leave the ")
428 TEXT(
"sphere's authored value alone; any other value replaces it on every push, which is ")
429 TEXT(
"the only way to make the stars FAINTER than the 100 the asset ships."),
442 TEXT(
"carla.Weather.OvercastThreshold"),
444 TEXT(
"Cloudiness value at/above which the sky rig's VolumetricCloudComponent switches ")
445 TEXT(
"from the plain cloud master material to the Billowy overcast one."),
453 TEXT(
"carla.Weather.EnableOvercastClouds"),
455 TEXT(
"Whether Cloudiness at/above OvercastThreshold switches the cloud material to the ")
456 TEXT(
"Billowy overcast one. Set false to always use the plain master instead."),
461 TEXT(
"carla.Weather.OvercastSunIntensity"),
463 TEXT(
"Sun intensity at Cloudiness 100, blended in from SunIntensity_Curve by Cloudiness ")
464 TEXT(
"and clamped so it can only darken. Negative disables."),
468 TEXT(
"carla.Weather.OvercastSkyLightIntensity"),
470 TEXT(
"Sky light intensity at Cloudiness 100, blended in from SkyIntensity_Curve by ")
471 TEXT(
"Cloudiness and clamped so it can only brighten. Negative disables."),
479 TEXT(
"carla.Weather.OvercastAmbientNeutralize"),
481 TEXT(
"How much of the sun's atmospheric tint to cancel from the sky light at ")
482 TEXT(
"Cloudiness 100 (scaled by Cloudiness). 0 leaves the sky light white."),
487 TEXT(
"carla.Weather.OvercastSunNeutralize"),
489 TEXT(
"How much of the sun's atmospheric tint to cancel from the sun light itself at ")
490 TEXT(
"Cloudiness 100 (scaled by Cloudiness), taking the red out of an overcast deck ")
491 TEXT(
"at sunset. 0 leaves the sun white."),
495 TEXT(
"carla.Weather.OvercastAmbientMaxGain"),
497 TEXT(
"Largest per-channel gain the sky light neutralisation may apply, so a sun on ")
498 TEXT(
"the horizon cannot turn the ambient blue."),
513 TEXT(
"carla.Weather.DeckStartCloudiness"),
515 TEXT(
"Cloudiness at which the clouds start closing into the overcast deck (full at 100)."),
522 TEXT(
"carla.Weather.DeckLightFullCloudiness"),
524 TEXT(
"Cloudiness at which the deck's emission and sky light reach their full value."),
532 TEXT(
"carla.Weather.DeckWarpSwitch"),
534 TEXT(
"-1: blend the warp count with the deck factor. 0-1: flip it to DeckWarpCount at that deck factor."),
541 TEXT(
"carla.Weather.DeckCoverageExponent"),
543 TEXT(
"Power applied to the deck factor for the cloud coverage (BaseNoiseExp) blend."),
547 TEXT(
"carla.Weather.DeckNoiseExp"),
549 TEXT(
"Cloud material BaseNoiseExp at Cloudiness 100 (lower = more coverage)."),
553 TEXT(
"carla.Weather.DeckExtinctionScale"),
555 TEXT(
"Cloud material ExtinctionScale at Cloudiness 100 (softer deck base). Negative leaves the material's."),
559 TEXT(
"carla.Weather.DeckWarpCount"),
561 TEXT(
"Cloud material domain warp count at Cloudiness 100. Negative leaves the material's."),
565 TEXT(
"carla.Weather.DeckGlow"),
567 TEXT(
"Cloud emission at Cloudiness 100 with the sun at its peak (0 off)."),
571 TEXT(
"carla.Weather.DeckGlowColor"),
573 TEXT(
"Colour of the overcast deck emission, \"R G B\"."),
577 TEXT(
"carla.Weather.DeckSkyLightIntensity"),
579 TEXT(
"Replaces OvercastSkyLightIntensity at Cloudiness 100 (blended by the deck factor)."),
587 TEXT(
"carla.Weather.RainDeckGlowScale"),
589 TEXT(
"DeckGlow multiplier at Precipitation 100 (1 = rain does not change the deck)."),
593 TEXT(
"carla.Weather.RainDeckSkyLightScale"),
595 TEXT(
"DeckSkyLightIntensity multiplier at Precipitation 100 (1 = rain does not change it)."),
598static float RainDeckScale(
const TAutoConsoleVariable<float>& CVar,
float Precipitation)
600 return FMath::Lerp(1.0f, FMath::Max(CVar.GetValueOnGameThread(), 0.0f),
601 FMath::Clamp(Precipitation / 100.0f, 0.0f, 1.0f));
608 const float T = FMath::Clamp((Cloudiness - Start) / (100.0f - Start), 0.0f, 1.0f);
609 return T * T * (3.0f - 2.0f * T);
617 const float T = FMath::Clamp((Cloudiness - Start) / (Full - Start), 0.0f, 1.0f);
618 return T * T * (3.0f - 2.0f * T);
627 if (Overcast < 0.0f || DeckRaw < 0.0f)
633static FLinearColor
ParseColorCVar(
const TAutoConsoleVariable<FString>& CVar,
const FLinearColor& Fallback)
635 TArray<FString> Channels;
636 CVar.GetValueOnGameThread().ParseIntoArrayWS(Channels);
637 if (Channels.Num() != 3)
639 return FLinearColor(FCString::Atof(*Channels[0]), FCString::Atof(*Channels[1]), FCString::Atof(*Channels[2]));
649 TEXT(
"carla.Weather.TwilightCloudScale"),
650 TEXT(
"0.4 0.55 0.8"),
651 TEXT(
"Sun CloudScatteredLuminanceScale at the horizon, \"R G B\" (\"1 1 1\" off)."),
655 TEXT(
"carla.Weather.TwilightCloudFullDeg"),
657 TEXT(
"Sun altitude at or below which carla.Weather.TwilightCloudScale applies in full."),
661 TEXT(
"carla.Weather.TwilightCloudOffDeg"),
663 TEXT(
"Sun altitude at or above which the clouds get the sun's full scattering again."),
670 const float T = FMath::SmoothStep(0.0f, 1.0f, FMath::Clamp((SunAltitudeAngle - Full) / (Off - Full), 0.0f, 1.0f));
672 FLinearColor::White, T);
683 return SunAltitudeAngle < 0.0f ? 1.0f : 0.0f;
684 const float T = FMath::Clamp(0.5f - SunAltitudeAngle / (2.0f * Band), 0.0f, 1.0f);
685 return T * T * (3.0f - 2.0f * T);
694 return SunAltitudeAngle < Full ? 1.0f : 0.0f;
695 const float T = FMath::Clamp((Start - SunAltitudeAngle) / (Start - Full), 0.0f, 1.0f);
696 return T * T * (3.0f - 2.0f * T);
705 return SunAltitudeAngle < End ? 1.0f : 0.0f;
706 const float T = FMath::Clamp((Start - SunAltitudeAngle) / (Start - End), 0.0f, 1.0f);
707 return T * T * (3.0f - 2.0f * T);
721 TEXT(
"carla.Weather.VSMInvalidateWhileSunMoves"),
723 TEXT(
"Hold r.Shadow.Virtual.Cache.ForceInvalidateDirectional on while the sun direction ")
724 TEXT(
"changes. 0 leaves it alone."),
728 TEXT(
"carla.Weather.VSMSunStillSeconds"),
730 TEXT(
"World seconds without a sun direction change before the directional VSM cache is ")
731 TEXT(
"used again. World time, not engine frames: in synchronous mode the editor keeps ")
732 TEXT(
"rendering between client ticks, and a frame count released the cvar between two ")
733 TEXT(
"pushes of a moving sun, which brought the flicker back."),
744 if (IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(
745 TEXT(
"r.Shadow.Virtual.Cache.ForceInvalidateDirectional")))
747 CVar->Set(bOn ? 1 : 0, ECVF_SetByCode);
749 UE_LOG(LogCarla, Log, TEXT(
"AWeather: directional VSM force-invalidate %s"), bOn ? TEXT(
"on") : TEXT(
"off"));
785 TEXT(
"carla.Weather.LightingJumpSunDeg"),
787 TEXT(
"Sun altitude change, in degrees, between two weather pushes that counts as a lighting ")
788 TEXT(
"jump and forces Lumen and the sky light capture to update in full. 0 disables it."),
792 TEXT(
"carla.Weather.LightingJumpCloudiness"),
794 TEXT(
"Cloudiness change between two weather pushes that counts as a lighting jump. 0 disables it."),
798 TEXT(
"carla.Weather.LightingJumpSettleSeconds"),
800 TEXT(
"World seconds the full Lumen / sky light updates are held after a lighting jump."),
804 TEXT(
"r.Lumen.RadianceCache.ForceFullUpdate"),
805 TEXT(
"r.LumenScene.Lighting.ForceLightingUpdate"),
806 TEXT(
"r.SkyLight.RealTimeReflectionCapture.TimeSlice")};
820 IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(
GLightingJumpCVars[i]);
828 UE_LOG(LogCarla, Log, TEXT(
"AWeather: full Lumen / sky light update %s"), bOn ? TEXT(
"on") : TEXT(
"off"));
836 const bool bJump = !bFirst && (
862 if (End >= 0.0f || Start <= End)
864 if (SunAltitudeAngle >= Start)
866 if (SunAltitudeAngle <= End)
868 const float T = (Start - SunAltitudeAngle) / (Start - End);
869 const float EndFraction = FMath::Clamp(
872 const float Tail = FMath::SmoothStep(0.0f, 1.0f, FMath::Clamp((SunAltitudeAngle - End) / 3.0f, 0.0f, 1.0f));
873 return FMath::Pow(EndFraction, T) * Tail;
880 FObjectProperty* AtmosphereProperty = CastField<FObjectProperty>(
881 SkyActor->GetClass()->FindPropertyByName(TEXT(
"SkyAtmosphereComponent")));
882 USkyAtmosphereComponent* Atmosphere = AtmosphereProperty !=
nullptr
883 ? Cast<USkyAtmosphereComponent>(AtmosphereProperty->GetObjectPropertyValue_InContainer(SkyActor))
885 if (Atmosphere ==
nullptr)
888 static TWeakObjectPtr<USkyAtmosphereComponent> Tracked;
889 static float BaseScale = 0.0f, WrittenScale = -1.0f;
890 static float BaseAnisotropy = 0.0f, WrittenAnisotropy = -2.0f;
891 if (Tracked.Get() != Atmosphere)
893 Tracked = Atmosphere;
894 WrittenScale = -1.0f;
895 WrittenAnisotropy = -2.0f;
897 if (Atmosphere->MieScatteringScale != WrittenScale)
898 BaseScale = Atmosphere->MieScatteringScale;
899 if (Atmosphere->MieAnisotropy != WrittenAnisotropy)
900 BaseAnisotropy = Atmosphere->MieAnisotropy;
902 const float ScaleFactor = FMath::Lerp(1.0f,
905 const float Anisotropy = NightAnisotropy >= 0.0f
906 ? FMath::Lerp(BaseAnisotropy, FMath::Min(NightAnisotropy, 0.999f), HaloBlend)
909 WrittenScale = BaseScale * ScaleFactor;
910 WrittenAnisotropy = Anisotropy;
911 if (Atmosphere->MieScatteringScale != WrittenScale)
912 Atmosphere->SetMieScatteringScale(WrittenScale);
913 if (Atmosphere->MieAnisotropy != WrittenAnisotropy)
914 Atmosphere->SetMieAnisotropy(WrittenAnisotropy);
920 float MoonBlend,
float SunAltitudeAngle)
922 static const FName DiscName(TEXT(
"CarlaMoonDisc"));
923 UStaticMeshComponent* Disc = FindObjectFast<UStaticMeshComponent>(SkyActor, DiscName);
926 if (Disc !=
nullptr && Disc->IsVisible())
927 Disc->SetVisibility(
false);
932 ? TEXT(
"/Game/Carla/Blueprints/Weather/Materials/M_Moon_Additive.M_Moon_Additive")
933 : TEXT(
"/Game/Carla/Blueprints/Weather/Materials/M_Moon.M_Moon");
934 UMaterialInterface* Material = LoadObject<UMaterialInterface>(
nullptr, MaterialPath);
935 if (Material ==
nullptr)
937 static bool bWarned =
false;
939 UE_LOG(LogCarla, Warning, TEXT(
"AWeather: moon disc disabled, missing %s"), MaterialPath);
941 if (Disc !=
nullptr && Disc->IsVisible())
942 Disc->SetVisibility(
false);
948 UStaticMesh* Plane = LoadObject<UStaticMesh>(
nullptr, TEXT(
"/Engine/BasicShapes/Plane.Plane"));
949 if (Plane ==
nullptr)
951 static bool bWarned =
false;
953 UE_LOG(LogCarla, Warning, TEXT(
"AWeather: moon disc disabled, missing /Engine/BasicShapes/Plane"));
957 Disc = NewObject<UStaticMeshComponent>(SkyActor, DiscName, RF_Transient);
958 Disc->SetStaticMesh(Plane);
959 Disc->SetMobility(EComponentMobility::Movable);
960 Disc->SetUsingAbsoluteLocation(
true);
961 Disc->SetUsingAbsoluteRotation(
true);
962 Disc->SetUsingAbsoluteScale(
true);
963 Disc->SetCollisionEnabled(ECollisionEnabled::NoCollision);
964 Disc->SetCastShadow(
false);
965 Disc->bAffectDistanceFieldLighting =
false;
966 Disc->bVisibleInReflectionCaptures =
false;
967 Disc->bVisibleInRealTimeSkyCaptures =
false;
968 Disc->bVisibleInRayTracing =
false;
969 Disc->SetupAttachment(SkyActor->GetRootComponent());
970 Disc->RegisterComponent();
972 else if (!Disc->IsRegistered())
974 Disc->RegisterComponent();
978 const FVector ToMoon = -MoonLight->GetForwardVector();
981 FVector Centre = FVector::ZeroVector;
982 float SphereRadius = 0.0f;
983 TInlineComponentArray<UChildActorComponent*> RigChildActors;
984 SkyActor->GetComponents(RigChildActors);
985 for (UChildActorComponent* RigChild : RigChildActors)
987 if (RigChild ==
nullptr || RigChild->GetChildActor() ==
nullptr)
989 TInlineComponentArray<UMeshComponent*> ChildMeshes;
990 RigChild->GetChildActor()->GetComponents(ChildMeshes);
991 for (UMeshComponent* ChildMesh : ChildMeshes)
993 if (ChildMesh !=
nullptr && ChildMesh->Bounds.SphereRadius > SphereRadius)
995 SphereRadius = ChildMesh->Bounds.SphereRadius;
996 Centre = ChildMesh->Bounds.Origin;
1001 if (SphereRadius > 0.0f)
1002 Distance = FMath::Min(Distance,
1004 static float LastLoggedDistance = -1.0f;
1005 if (Distance != LastLoggedDistance)
1007 UE_LOG(LogCarla, Log, TEXT(
"AWeather moon disc: sky sphere radius %.0f cm, disc distance %.0f cm"),
1008 SphereRadius, Distance);
1009 LastLoggedDistance = Distance;
1013 const float Scale = 2.0f * Distance * FMath::Tan(FMath::DegreesToRadians(Angle) * 0.5f) / 100.0f;
1014 Disc->SetWorldLocationAndRotation(
1015 Centre + ToMoon * Distance, FRotationMatrix::MakeFromZX(-ToMoon, FVector::UpVector).Rotator());
1016 Disc->SetWorldScale3D(FVector(Scale));
1019 UMaterialInstanceDynamic* MoonMaterial = Cast<UMaterialInstanceDynamic>(Disc->GetMaterial(0));
1020 if (MoonMaterial ==
nullptr || MoonMaterial->Parent != Material)
1022 MoonMaterial = UMaterialInstanceDynamic::Create(Material, Disc);
1023 Disc->SetMaterial(0, MoonMaterial);
1025 if (MoonMaterial !=
nullptr)
1027 MoonMaterial->SetScalarParameterValue(TEXT(
"Contrast"),
1031 const float T = Start > End
1032 ? FMath::SmoothStep(0.0f, 1.0f, FMath::Clamp((Start - SunAltitudeAngle) / (Start - End), 0.0f, 1.0f))
1033 : (SunAltitudeAngle < End ? 1.0f : 0.0f);
1034 MoonMaterial->SetScalarParameterValue(TEXT(
"Brightness"), FMath::Lerp(
1039 if (!Disc->IsVisible())
1040 Disc->SetVisibility(
true);
1046 const float Strength = FMath::Clamp(
1048 if (Strength <= 0.0f || CurvePeak <= UE_KINDA_SMALL_NUMBER)
1052 const float SinElevation =
1053 FMath::Sin(FMath::DegreesToRadians(FMath::Max(SunAltitudeAngle, 0.0f)));
1055 const float Physical = CurvePeak * FMath::Max(
1059 return FMath::Min(CurveValue, FMath::Lerp(CurveValue, Physical, Strength));
1066 if (Curve !=
nullptr)
1067 for (
float Altitude = 0.0f; Altitude <= 90.0f; Altitude += 5.0f)
1068 Peak = FMath::Max(Peak, Curve->GetFloatValue(Altitude));
1074 float Cloudiness,
bool bOnlyDarken,
float CurvePeak)
1076 if (OvercastValue < 0.0f)
1078 const float Overcast = FMath::Clamp(Cloudiness / 100.0f, 0.0f, 1.0f);
1079 const float Blended = CurvePeak > UE_KINDA_SMALL_NUMBER
1080 ? CurveValue * FMath::Lerp(1.0f, OvercastValue / CurvePeak, Overcast)
1081 : FMath::Lerp(CurveValue, OvercastValue, Overcast);
1082 return bOnlyDarken ? FMath::Min(CurveValue, Blended) : FMath::Max(CurveValue, Blended);
1089 float SunAltitudeAngle,
float Cloudiness,
1090 float NeutralizeAmount,
float& OutIntensityScale)
1092 OutIntensityScale = 1.0f;
1094 const float DayFade = Release < 0.0f
1095 ? 1.0f - FMath::SmoothStep(0.0f, 1.0f, FMath::Clamp(SunAltitudeAngle / Release, 0.0f, 1.0f))
1096 : (SunAltitudeAngle >= 0.0f ? 1.0f : 0.0f);
1097 const float Strength = FMath::Clamp(NeutralizeAmount, 0.0f, 1.0f)
1098 * FMath::Clamp(Cloudiness / 100.0f, 0.0f, 1.0f) * DayFade;
1099 if (Atmosphere ==
nullptr || Strength <= 0.0f)
1100 return FLinearColor::White;
1103 FAtmosphereSetup Setup(*Atmosphere);
1104 Setup.TransmittanceMinLightElevationAngle = 0.0f;
1105 const float Elevation = FMath::DegreesToRadians(FMath::Max(SunAltitudeAngle, 0.0f));
1106 const FLinearColor TSun = Setup.GetTransmittanceAtGroundLevel(
1107 FVector(FMath::Cos(Elevation), 0.0f, FMath::Sin(Elevation)));
1109 const FLinearColor TZenith = Setup.GetTransmittanceAtGroundLevel(FVector::UpVector);
1110 const FLinearColor T(
1111 TSun.R / FMath::Max(TZenith.R, UE_KINDA_SMALL_NUMBER),
1112 TSun.G / FMath::Max(TZenith.G, UE_KINDA_SMALL_NUMBER),
1113 TSun.B / FMath::Max(TZenith.B, UE_KINDA_SMALL_NUMBER));
1114 const float Luminance = T.GetLuminance();
1115 if (Luminance <= UE_KINDA_SMALL_NUMBER)
1116 return FLinearColor::White;
1120 FMath::Min(Luminance / FMath::Max(T.R, UE_KINDA_SMALL_NUMBER), MaxGain),
1121 FMath::Min(Luminance / FMath::Max(T.G, UE_KINDA_SMALL_NUMBER), MaxGain),
1122 FMath::Min(Luminance / FMath::Max(T.B, UE_KINDA_SMALL_NUMBER), MaxGain),
1124 const float GainLuminance = Gain.GetLuminance();
1125 if (GainLuminance > UE_KINDA_SMALL_NUMBER)
1126 Gain = Gain * (1.0f / GainLuminance);
1128 FLinearColor Tint = FMath::Lerp(FLinearColor::White, Gain, Strength);
1129 const float Peak = FMath::Max3(Tint.R, Tint.G, Tint.B);
1132 Tint = Tint * (1.0f / Peak);
1133 OutIntensityScale = Peak;
1140 TEXT(
"carla.Weather.FogDensityScale"),
1142 TEXT(
"Multiplier taking CARLA's 0-100 FogDensity to the height fog component's density. ")
1143 TEXT(
"The shipped 0.001 caps the engine at 0.1, too thin for a heavy-rain veil."),
1147 TEXT(
"carla.Weather.CloudShadowExtentKm"),
1149 TEXT(
"Radius in km covered by the volumetric cloud shadow map, set on the sky rig's sun ")
1150 TEXT(
"light. Smaller means finer shadow map texels and less stepping as the sun rotates, ")
1151 TEXT(
"at the cost of clouds no longer shadowing anything further away. 0 or less leaves ")
1152 TEXT(
"whatever the rig authored."),
1156 : Super(ObjectInitializer)
1159 TEXT(
"Material'/Game/Carla/Static/GenericMaterials/FX/ScreenDust/M_LensRain.M_LensRain'")).Object;
1162 TEXT(
"Material'/Game/Carla/Static/GenericMaterials/FX/ScreenDust/M_screenDust_wind.M_screenDust_wind'")).Object;
1164 RainParameters = ConstructorHelpers::FObjectFinder<UMaterialParameterCollection>(
1165 TEXT(
"/Game/Carla/Blueprints/Weather/Materials/WeatherMaterialParameters.WeatherMaterialParameters")).Object;
1166 RainTemplate = ConstructorHelpers::FObjectFinder<UParticleSystem>(
1167 TEXT(
"/Game/Carla/Static/FX/Particles/Rain/PS_Rain.PS_Rain")).Object;
1168 PrimaryActorTick.bCanEverTick =
true;
1169 PrimaryActorTick.TickGroup = TG_PostPhysics;
1170 RootComponent = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(
this, TEXT(
"RootComponent"));
1174 float& BlendWeight, FPostProcessSettings& Settings)
1187 UParticleSystemComponent* Emitter =
nullptr;
1192 TInlineComponentArray<UParticleSystemComponent*> Components(Owner);
1193 for (
auto* Component : Components)
1196 Emitter = Component;
1200 const bool bNewComponent = Emitter ==
nullptr;
1202 Emitter = NewObject<UParticleSystemComponent>(Owner);
1203 Emitter->DetachFromComponent(FDetachmentTransformRules::KeepWorldTransform);
1204 Emitter->bAutoActivate =
false;
1205 Emitter->bAutoDestroy =
false;
1209 Emitter->SetOnlyOwnerSee(bSensor);
1210 Emitter->SetVisibleInSceneCaptureOnly(bSensor);
1211 Emitter->SetHiddenInSceneCapture(!bSensor);
1212 Emitter->SetCastShadow(
false);
1215 Owner->AddInstanceComponent(Emitter);
1216 Emitter->RegisterComponent();
1218 Emitter->SetWorldScale3D(FVector(2.0f));
1219 if (
auto* Material = Emitter->CreateDynamicMaterialInstance(0))
1221 Material->SetScalarParameterValue(TEXT(
"StreakBrightness"), 1.2f);
1222 Material->SetScalarParameterValue(TEXT(
"StreakOpacity"), 0.65f);
1229 if (!GetWorld() || !GetWorld()->IsGameWorld())
1235 UKismetMaterialLibrary::SetScalarParameterValue(GetWorld(),
RainParameters, TEXT(
"Precipitation"), Rain);
1237 auto UpdateEmitter = [
this, Rain](UParticleSystemComponent* Emitter,
const FVector& Location,
float Yaw)
1239 if (!Emitter)
return;
1244 const FRotator Heading(0.0f, Yaw, 0.0f);
1245 const FVector Origin = Location + FVector(0.0f, 0.0f, 400.0f);
1246 Emitter->SetWorldRotation(Heading);
1247 if (FVector::DistSquared(Emitter->GetComponentLocation(), Origin) > FMath::Square(2000.0f))
1248 Emitter->DeactivateImmediate();
1249 Emitter->SetWorldLocation(Origin);
1250 Emitter->SetFloatParameter(TEXT(
"RainDensity"), Rain * (4000.0f / 0.85f));
1252 Emitter->SetVectorParameter(TEXT(
"RainVelocity"),
1255 Emitter->DeactivateImmediate();
1256 else if (!Emitter->IsActive())
1257 Emitter->ActivateSystem(
true);
1260 if (
auto* Camera = UGameplayStatics::GetPlayerCameraManager(GetWorld(), 0))
1265 if (
auto* PreviousCamera = Cast<APlayerCameraManager>(
RainCameraModifier->GetOuter()))
1268 Camera->AddNewCameraModifier(UCarlaRainCameraModifier::StaticClass()));
1277 UpdateEmitter(
ViewportRain, Camera->GetCameraLocation(), Camera->GetCameraRotation().Yaw);
1282 for (
auto It =
SensorRain.CreateIterator(); It; ++It)
1283 if (!It.Key().IsValid() || !It.Value().IsValid())
1285 if (It.Value().IsValid()) It.Value()->DestroyComponent();
1288 for (TActorIterator<ASceneCaptureCamera> It(GetWorld()); It; ++It)
1291 auto* Emitter =
SensorRain.FindRef(Sensor).Get();
1292 if (!Emitter && Rain > 0.0f)
1297 UpdateEmitter(Emitter, Sensor->GetCaptureComponent2D()->GetComponentLocation(),
1298 Sensor->GetCaptureComponent2D()->GetComponentRotation().Yaw);
1304 Super::Tick(DeltaSeconds);
1315 SetActorTickEnabled(
true);
1325 if (Entry.Value.IsValid()) Entry.Value->DestroyComponent();
1331 Super::EndPlay(EndPlayReason);
1346 TArray<AActor*> SensorActors;
1347 UGameplayStatics::GetAllActorsOfClass(GetWorld(), ASceneCaptureCamera::StaticClass(), SensorActors);
1348 for (
AActor* SensorActor : SensorActors)
1359 Sensor->
GetCaptureComponent2D()->PostProcessSettings.AddBlendable(ActiveBlendable.Key, ActiveBlendable.Value);
1372 struct FSkyLightMapOverride
1374 UTextureCube* Cubemap =
nullptr;
1375 float Intensity = 1.0f;
1376 TWeakObjectPtr<UWorld> World;
1378 FSkyLightMapOverride GSkyLightMapOverride;
1379 FDelegateHandle GSkyLightMapWorldCleanupHandle;
1381 bool SkyLightMapAppliesTo(
const UWorld* World)
1383 return GSkyLightMapOverride.Cubemap !=
nullptr && World !=
nullptr &&
1384 GSkyLightMapOverride.World.Get() == World;
1391 struct FSkyLightSavedState
1393 TEnumAsByte<ESkyLightSourceType> SourceType;
1394 bool bLowerHemisphereIsBlack;
1396 TMap<TWeakObjectPtr<USkyLightComponent>, FSkyLightSavedState> GSkyLightSavedStates;
1398 void ApplySkyLightMapToComponent(USkyLightComponent* SkyLightComponent)
1400 if (!GSkyLightSavedStates.Contains(SkyLightComponent))
1402 GSkyLightSavedStates.Add(SkyLightComponent,
1403 {SkyLightComponent->SourceType, SkyLightComponent->bLowerHemisphereIsBlack});
1405 if (SkyLightComponent->bRealTimeCapture)
1406 SkyLightComponent->SetRealTimeCaptureEnabled(
false);
1407 if (SkyLightComponent->SourceType != SLS_SpecifiedCubemap)
1409 SkyLightComponent->SourceType = SLS_SpecifiedCubemap;
1410 SkyLightComponent->MarkRenderStateDirty();
1411 SkyLightComponent->SetCaptureIsDirty();
1413 if (SkyLightComponent->bLowerHemisphereIsBlack)
1415 SkyLightComponent->bLowerHemisphereIsBlack =
false;
1416 SkyLightComponent->MarkRenderStateDirty();
1418 SkyLightComponent->SetSourceCubemapAngle(0.0f);
1419 SkyLightComponent->SetCubemap(GSkyLightMapOverride.Cubemap);
1420 if (SkyLightComponent->Cubemap != GSkyLightMapOverride.Cubemap)
1424 SkyLightComponent->Cubemap = GSkyLightMapOverride.Cubemap;
1428 SkyLightComponent->MarkRenderStateDirty();
1429 SkyLightComponent->SetCaptureIsDirty();
1430 SkyLightComponent->SetLightColor(FLinearColor::White);
1431 SkyLightComponent->SetIntensity(GSkyLightMapOverride.Intensity);
1432 if (!SkyLightComponent->IsActive())
1433 SkyLightComponent->SetActive(
true);
1439 void DropSkyLightMapOverride()
1441 if (GSkyLightMapOverride.Cubemap !=
nullptr)
1442 GSkyLightMapOverride.Cubemap->RemoveFromRoot();
1443 GSkyLightMapOverride = FSkyLightMapOverride{};
1444 GSkyLightSavedStates.Empty();
1445 if (GSkyLightMapWorldCleanupHandle.IsValid())
1447 FWorldDelegates::OnWorldCleanup.Remove(GSkyLightMapWorldCleanupHandle);
1448 GSkyLightMapWorldCleanupHandle.Reset();
1456 void OnSkyLightMapWorldCleanup(UWorld* World,
bool ,
bool )
1458 if (World ==
nullptr || GSkyLightMapOverride.World.Get() != World)
1460 DropSkyLightMapOverride();
1461 UE_LOG(LogCarla, Log, TEXT(
"AWeather: sky light map dropped with world %s"), *World->GetName());
1467 if (Cubemap ==
nullptr || World ==
nullptr)
1469 if (GSkyLightMapOverride.Cubemap !=
nullptr && GSkyLightMapOverride.Cubemap != Cubemap)
1470 GSkyLightMapOverride.Cubemap->RemoveFromRoot();
1471 Cubemap->AddToRoot();
1472 if (GSkyLightMapOverride.World.Get() != World)
1476 GSkyLightSavedStates.Empty();
1478 GSkyLightMapOverride.Cubemap = Cubemap;
1479 GSkyLightMapOverride.Intensity = Intensity;
1480 GSkyLightMapOverride.World = World;
1481 if (!GSkyLightMapWorldCleanupHandle.IsValid())
1482 GSkyLightMapWorldCleanupHandle = FWorldDelegates::OnWorldCleanup.AddStatic(&OnSkyLightMapWorldCleanup);
1485 TArray<AActor*> SkyActors;
1486 UGameplayStatics::GetAllActorsOfClass(World, ASkyBase::StaticClass(), SkyActors);
1487 for (
AActor* SkyActor : SkyActors)
1489 ASkyBase* Sky = Cast<ASkyBase>(SkyActor);
1490 if (USkyLightComponent* SkyLightComponent = Sky !=
nullptr ? Sky->GetSkyLightComponent() :
nullptr)
1492 ApplySkyLightMapToComponent(SkyLightComponent);
1496 UE_LOG(LogCarla, Log, TEXT(
"AWeather: sky light map set (intensity %.3f) on %d sky rig(s)"), Intensity, Applied);
1503 TArray<AActor*> SkyActors;
1504 UGameplayStatics::GetAllActorsOfClass(World, ASkyBase::StaticClass(), SkyActors);
1505 for (
AActor* SkyActor : SkyActors)
1507 ASkyBase* Sky = Cast<ASkyBase>(SkyActor);
1508 if (USkyLightComponent* SkyLightComponent = Sky !=
nullptr ? Sky->GetSkyLightComponent() :
nullptr)
1510 SkyLightComponent->SetCubemap(
nullptr);
1511 if (
const FSkyLightSavedState* Saved = GSkyLightSavedStates.Find(SkyLightComponent))
1513 SkyLightComponent->SourceType = Saved->SourceType;
1514 SkyLightComponent->bLowerHemisphereIsBlack = Saved->bLowerHemisphereIsBlack;
1515 SkyLightComponent->MarkRenderStateDirty();
1516 SkyLightComponent->SetCaptureIsDirty();
1518 SkyLightComponent->SetRealTimeCaptureEnabled(
true);
1521 DropSkyLightMapOverride();
1527 UE_LOG(LogCarla, Log, TEXT(
"AWeather: sky light map cleared"));
1532 return GSkyLightMapOverride.Cubemap !=
nullptr;
1537 TArray<AActor*> SkyActors;
1538 UGameplayStatics::GetAllActorsOfClass(GetWorld(), ASkyBase::StaticClass(), SkyActors);
1539 for (
AActor* SkyActor : SkyActors)
1545 if (SkyActor ==
nullptr)
1554 const auto FindPropertyByAuthoredName =
1555 [](
const UClass* Class,
const TCHAR* AuthoredName) -> FProperty*
1557 for (TFieldIterator<FProperty> It(Class); It; ++It)
1559 if ((*It)->GetAuthoredName() == AuthoredName || (*It)->GetName() == AuthoredName)
1581 UE_LOG(LogCarla, Warning, TEXT(
"AWeather: no WeatherParameters property on %s"),
1582 *SkyActor->GetName());
1596 static const TCHAR* UpdateFunctionNames[] = {
1597 TEXT(
"SetSunActorReference"),
1598 TEXT(
"SetSkySphere"),
1600 TEXT(
"UpdateClouds"),
1603 TEXT(
"UpdateAtmosphereAndPrecipitation"),
1604 TEXT(
"UpdateSkySphere"),
1605 TEXT(
"UpdateSkySphereColor")};
1606 for (
const TCHAR* FunctionName : UpdateFunctionNames)
1608 UFunction* Function = SkyActor->FindFunction(FunctionName);
1609 if (Function !=
nullptr && Function->ParmsSize == 0)
1610 SkyActor->ProcessEvent(Function,
nullptr);
1612 UE_LOG(LogCarla, Warning, TEXT(
"AWeather: skipping '%s' on %s (missing or has parameters)"),
1613 FunctionName, *SkyActor->GetName());
1628 FObjectProperty* SphereProperty = CastField<FObjectProperty>(
1629 FindPropertyByAuthoredName(SkyActor->GetClass(), TEXT(
"SkySphere")));
1630 if (SphereProperty ==
nullptr)
1631 SphereProperty = CastField<FObjectProperty>(
1632 FindPropertyByAuthoredName(SkyActor->GetClass(), TEXT(
"Sky Sphere")));
1633 AActor* SphereActor = SphereProperty !=
nullptr
1634 ? Cast<AActor>(SphereProperty->GetObjectPropertyValue_InContainer(SkyActor))
1636 USceneComponent* SphereRoot = SphereActor !=
nullptr ? SphereActor->GetRootComponent() :
nullptr;
1637 if (SphereRoot !=
nullptr && SphereRoot->GetAttachParent() ==
nullptr)
1639 if (SphereRoot->Mobility == EComponentMobility::Static)
1640 SphereRoot->SetMobility(EComponentMobility::Movable);
1641 SphereActor->AttachToActor(SkyActor, FAttachmentTransformRules::KeepWorldTransform);
1648 const FVector SunDirection =
1651 TArray<AActor*> SkyCandidates;
1652 if (SphereActor !=
nullptr)
1653 SkyCandidates.Add(SphereActor);
1654 TInlineComponentArray<UChildActorComponent*> RigChildActors;
1655 SkyActor->GetComponents(RigChildActors);
1656 for (UChildActorComponent* RigChild : RigChildActors)
1657 if (RigChild !=
nullptr && RigChild->GetChildActor() !=
nullptr)
1658 SkyCandidates.AddUnique(RigChild->GetChildActor());
1660 for (
AActor* Candidate : SkyCandidates)
1664 if (FNumericProperty* SunHeightProperty = CastField<FNumericProperty>(
1665 FindPropertyByAuthoredName(Candidate->GetClass(), TEXT(
"Sun Height"))))
1667 SunHeightProperty->SetFloatingPointPropertyValue(
1668 SunHeightProperty->ContainerPtrToValuePtr<
void>(Candidate),
1672 TInlineComponentArray<UMeshComponent*> SphereMeshes;
1673 Candidate->GetComponents(SphereMeshes);
1674 for (UMeshComponent* SphereMesh : SphereMeshes)
1676 if (SphereMesh ==
nullptr)
1680 const float ShowBelow = FMath::Min(
1683 if (SphereMesh->IsVisible() != bShouldBeVisible)
1684 SphereMesh->SetVisibility(bShouldBeVisible);
1688 static const FName ScaledTag(TEXT(
"CarlaSkySphereScaled"));
1690 if (SphereScale > 0.0f && SphereScale != 1.0f && !SphereMesh->ComponentHasTag(ScaledTag))
1692 SphereMesh->SetRelativeScale3D(SphereMesh->GetRelativeScale3D() * SphereScale);
1693 SphereMesh->ComponentTags.Add(ScaledTag);
1697 if (UMaterialInstanceDynamic* SphereMID =
1698 SphereMesh->CreateAndSetMaterialInstanceDynamic(0))
1700 SphereMID->SetVectorParameterValue(
1701 TEXT(
"Light direction"), FLinearColor(SunDirection));
1702 SphereMID->SetScalarParameterValue(TEXT(
"Sun height"), SunDirection.Z);
1704 if (CloudOpacity >= 0.0f)
1705 SphereMID->SetScalarParameterValue(TEXT(
"Cloud opacity"), CloudOpacity);
1723 TMap<UClass*, TArray<AActor*>> AttachedByClass;
1724 TArray<AActor*> AttachedToSky;
1725 SkyActor->GetAttachedActors(AttachedToSky);
1726 for (
AActor* AttachedActor : AttachedToSky)
1727 if (AttachedActor !=
nullptr)
1728 AttachedByClass.FindOrAdd(AttachedActor->GetClass()).Add(AttachedActor);
1730 for (
const TPair<UClass*, TArray<AActor*>>& Pair : AttachedByClass)
1732 const TArray<AActor*>& Instances = Pair.Value;
1736 AActor* ToKeep = (SphereActor !=
nullptr && Instances.Contains(SphereActor))
1737 ? SphereActor : Instances.Last();
1738 for (
AActor* Instance : Instances)
1740 if (Instance != ToKeep)
1742 TArray<AActor*> OrphanChildren;
1743 Instance->GetAttachedActors(OrphanChildren);
1744 for (
AActor* OrphanChild : OrphanChildren)
1745 if (OrphanChild !=
nullptr)
1746 OrphanChild->Destroy();
1747 Instance->Destroy();
1767 if (UDirectionalLightComponent* StrayLight =
1768 ToKeep !=
nullptr ? ToKeep->FindComponentByClass<UDirectionalLightComponent>() :
nullptr)
1770 if (StrayLight->ForwardShadingPriority != -1)
1771 StrayLight->SetForwardShadingPriority(-1);
1772 if (StrayLight->IsUsedAsAtmosphereSunLight())
1773 StrayLight->SetAtmosphereSunLight(
false);
1781 TInlineComponentArray<UChildActorComponent*> ChildActorComponents;
1782 SkyActor->GetComponents(ChildActorComponents);
1783 TMap<UClass*, TArray<UChildActorComponent*>> ComponentsByChildClass;
1784 for (UChildActorComponent* ChildComponent : ChildActorComponents)
1785 if (ChildComponent !=
nullptr && ChildComponent->GetChildActorClass() !=
nullptr)
1786 ComponentsByChildClass.FindOrAdd(ChildComponent->GetChildActorClass()).Add(ChildComponent);
1788 for (
const TPair<UClass*, TArray<UChildActorComponent*>>& Pair : ComponentsByChildClass)
1790 const TArray<UChildActorComponent*>& Components = Pair.Value;
1791 if (Components.Num() < 2)
1793 UChildActorComponent* ComponentToKeep = Components.Last();
1794 for (UChildActorComponent* ChildComponent : Components)
1796 if (ChildComponent->GetChildActor() !=
nullptr
1797 && ChildComponent->GetChildActor() == SphereActor)
1799 ComponentToKeep = ChildComponent;
1803 for (UChildActorComponent* ChildComponent : Components)
1804 if (ChildComponent != ComponentToKeep)
1805 ChildComponent->DestroyComponent();
1820 FObjectProperty* FogProperty = CastField<FObjectProperty>(
1821 SkyActor->GetClass()->FindPropertyByName(TEXT(
"ExponentialHeightFogComponent")));
1822 UExponentialHeightFogComponent* FogComponent = FogProperty !=
nullptr
1823 ? Cast<UExponentialHeightFogComponent>(FogProperty->GetObjectPropertyValue_InContainer(SkyActor))
1825 if (FogComponent !=
nullptr)
1827 FogComponent->SetFogDensity(
1830 FogComponent->SetFogCutoffDistance(0.0f);
1850 auto FindCurve = [](
const TCHAR* PropertyName) -> UCurveFloat*
1852 if (FCString::Strcmp(PropertyName, TEXT(
"SunIntensity_Curve")) == 0)
1853 return LoadObject<UCurveFloat>(
nullptr,
1854 TEXT(
"/Game/Carla/Blueprints/Weather/Weather2_Curves/SunIntensity_2.SunIntensity_2"));
1855 if (FCString::Strcmp(PropertyName, TEXT(
"SkyIntensity_Curve")) == 0)
1856 return LoadObject<UCurveFloat>(
nullptr,
1857 TEXT(
"/Game/Carla/Blueprints/Weather/Weather2_Curves/SkylightIntensity_2.SkylightIntensity_2"));
1860 auto FindComponent = [SkyActor](
const TCHAR* PropertyName) -> ULightComponent*
1862 FObjectProperty* ComponentProperty =
1863 CastField<FObjectProperty>(SkyActor->GetClass()->FindPropertyByName(PropertyName));
1864 return ComponentProperty !=
nullptr
1865 ? Cast<ULightComponent>(ComponentProperty->GetObjectPropertyValue_InContainer(SkyActor))
1874 auto FindSkyLightComponent = [SkyActor](
const TCHAR* PropertyName) -> USkyLightComponent*
1876 FObjectProperty* ComponentProperty =
1877 CastField<FObjectProperty>(SkyActor->GetClass()->FindPropertyByName(PropertyName));
1878 return ComponentProperty !=
nullptr
1879 ? Cast<USkyLightComponent>(ComponentProperty->GetObjectPropertyValue_InContainer(SkyActor))
1885 ULightComponent* Sun = FindComponent(TEXT(
"DirectionalLightComponentSun"));
1886 if (Sun !=
nullptr && SunIndirect >= 0.0f && Sun->IndirectLightingIntensity != SunIndirect)
1887 Sun->SetIndirectLightingIntensity(SunIndirect);
1889 USkyLightComponent* SkyLight = FindSkyLightComponent(TEXT(
"SkyLightComponent"));
1890 if (SkyLight !=
nullptr && SkyIndirect >= 0.0f && SkyLight->IndirectLightingIntensity != SkyIndirect)
1891 SkyLight->SetIndirectLightingIntensity(SkyIndirect);
1894 if (UCurveFloat* SunIntensityCurve = FindCurve(TEXT(
"SunIntensity_Curve")))
1896 if (ULightComponent* SunLightComponent = FindComponent(TEXT(
"DirectionalLightComponentSun")))
1908 if (Twilight >= 0.0f && Twilight < 1.0f)
1913 SunIntensityCurve->GetFloatValue(StartAltitude),
1919 SunLightComponent->SetIntensity(FMath::Max(SunLightComponent->Intensity, AtStart * Twilight));
1921 if (Twilight > 0.0f && !SunLightComponent->IsVisible())
1922 SunLightComponent->SetVisibility(
true);
1927 FObjectProperty* SunAtmosphereProperty = CastField<FObjectProperty>(
1928 SkyActor->GetClass()->FindPropertyByName(TEXT(
"SkyAtmosphereComponent")));
1929 const USkyAtmosphereComponent* SunAtmosphere = SunAtmosphereProperty !=
nullptr
1930 ? Cast<USkyAtmosphereComponent>(SunAtmosphereProperty->GetObjectPropertyValue_InContainer(SkyActor))
1932 float SunIntensityScale = 1.0f;
1936 if (SunIntensityScale != 1.0f)
1937 SunLightComponent->SetIntensity(SunLightComponent->Intensity * SunIntensityScale);
1942 if (ULightComponent* SunLightComponent = FindComponent(TEXT(
"DirectionalLightComponentSun")))
1945 SunLightComponent->SetWorldRotation(SunRotation);
1946 if (UDirectionalLightComponent* SunDirectional = Cast<UDirectionalLightComponent>(SunLightComponent))
1949 if (!SunDirectional->CloudScatteredLuminanceScale.Equals(CloudScale))
1951 SunDirectional->CloudScatteredLuminanceScale = CloudScale;
1952 SunDirectional->MarkRenderStateDirty();
1955 if (SkyActor->GetWorld() !=
nullptr && SkyActor->GetWorld()->IsGameWorld())
1964 if (ULightComponent* MoonLightComponent = FindComponent(TEXT(
"DirectionalLightComponentMoon")))
1966 const float MoonMinAltitude = FMath::Max(
1969 MoonLightComponent->SetWorldRotation(
1974 if (UDirectionalLightComponent* MoonAtmosphereLight =
1975 Cast<UDirectionalLightComponent>(FindComponent(TEXT(
"DirectionalLightComponentMoon"))))
1979 if (MoonAtmosphereLight->AtmosphereSunLightIndex != 1)
1980 MoonAtmosphereLight->SetAtmosphereSunLightIndex(1);
1981 if (MoonAtmosphereLight->bAtmosphereSunLight != (bWanted ? 1u : 0u))
1982 MoonAtmosphereLight->SetAtmosphereSunLight(bWanted);
1984 ? FLinearColor::White : FLinearColor::Black;
1985 if (MoonAtmosphereLight->AtmosphereSunDiskColorScale != DiskScale)
1986 MoonAtmosphereLight->SetAtmosphereSunDiskColorScale(DiskScale);
1991 if (UDirectionalLightComponent* SunDirectionalLight =
1992 Cast<UDirectionalLightComponent>(FindComponent(TEXT(
"DirectionalLightComponentSun"))))
1994 bool bSunLightRenderStateDirty =
false;
1996 if (CloudShadowExtentKm > 0.0f && SunDirectionalLight->CloudShadowExtent != CloudShadowExtentKm)
1998 SunDirectionalLight->CloudShadowExtent = CloudShadowExtentKm;
1999 bSunLightRenderStateDirty =
true;
2001 if (bSunLightRenderStateDirty)
2003 SunDirectionalLight->MarkRenderStateDirty();
2013 if (ULightComponent* MoonLightComponentAffects = FindComponent(TEXT(
"DirectionalLightComponentMoon")))
2015 if (!MoonLightComponentAffects->bAffectsWorld)
2017 MoonLightComponentAffects->bAffectsWorld =
true;
2018 MoonLightComponentAffects->MarkRenderStateDirty();
2043 FObjectProperty* AtmosphereProperty = CastField<FObjectProperty>(
2044 SkyActor->GetClass()->FindPropertyByName(TEXT(
"SkyAtmosphereComponent")));
2045 UActorComponent* AtmosphereComponent = AtmosphereProperty !=
nullptr
2046 ? Cast<UActorComponent>(AtmosphereProperty->GetObjectPropertyValue_InContainer(SkyActor))
2048 if (AtmosphereComponent !=
nullptr && !AtmosphereComponent->IsActive())
2049 AtmosphereComponent->SetActive(
true);
2052 if (USkyAtmosphereComponent* Atmosphere = Cast<USkyAtmosphereComponent>(AtmosphereComponent))
2057 float MinElevation = Clamped;
2061 const float Eased = T * T * (3.0f - 2.0f * T);
2062 MinElevation = FMath::Lerp(Clamped, -90.0f, Eased);
2064 if (!FMath::IsNearlyEqual(Atmosphere->TransmittanceMinLightElevationAngle, MinElevation))
2065 Atmosphere->SetTransmittanceMinLightElevationAngle(MinElevation);
2073 if (USkyLightComponent* SkyLightComponent = FindSkyLightComponent(TEXT(
"SkyLightComponent")))
2075 if (SkyLightMapAppliesTo(SkyActor->GetWorld()))
2084 ApplySkyLightMapToComponent(SkyLightComponent);
2088 if (!SkyLightComponent->bRealTimeCapture)
2089 SkyLightComponent->SetRealTimeCaptureEnabled(
true);
2090 if (!SkyLightComponent->IsActive())
2091 SkyLightComponent->SetActive(
true);
2092 if (UCurveFloat* SkyIntensityCurve = FindCurve(TEXT(
"SkyIntensity_Curve")))
2097 FObjectProperty* AtmosphereProperty = CastField<FObjectProperty>(
2098 SkyActor->GetClass()->FindPropertyByName(TEXT(
"SkyAtmosphereComponent")));
2099 const USkyAtmosphereComponent* Atmosphere = AtmosphereProperty !=
nullptr
2100 ? Cast<USkyAtmosphereComponent>(AtmosphereProperty->GetObjectPropertyValue_InContainer(SkyActor))
2102 float AmbientIntensityScale = 1.0f;
2106 if (AmbientIntensityScale != 1.0f)
2107 SkyLightComponent->SetIntensity(SkyLightComponent->Intensity * AmbientIntensityScale);
2109 UE_LOG(LogCarla, Verbose, TEXT(
2110 "AWeather sky light: active=%d intensity=%.3f realtimecapture=%d mobility=%d visible=%d"),
2111 SkyLightComponent->IsActive() ? 1 : 0,
2112 SkyLightComponent->Intensity,
2113 SkyLightComponent->IsRealTimeCaptureEnabled() ? 1 : 0,
2114 int(SkyLightComponent->Mobility.GetValue()),
2115 SkyLightComponent->IsVisible() ? 1 : 0);
2119 UE_LOG(LogCarla, Warning, TEXT(
"AWeather: no SkyLightComponent found on %s"), *SkyActor->GetName());
2137 if (MoonBlend > 0.0f)
2140 if (ULightComponent* MoonLightComponent = FindComponent(TEXT(
"DirectionalLightComponentMoon")))
2142 if (!MoonLightComponent->IsActive())
2143 MoonLightComponent->SetActive(
true);
2145 if (!MoonLightComponent->IsVisible())
2146 MoonLightComponent->SetVisibility(
true);
2149 MoonLightComponent->SetIntensity(MoonFloor);
2150 else if (MoonFloor > 0.0f && MoonLightComponent->Intensity < MoonFloor)
2151 MoonLightComponent->SetIntensity(MoonFloor);
2154 UpdateMoonDisc(SkyActor, FindComponent(TEXT(
"DirectionalLightComponentMoon")),
2164 if (USkyLightComponent* SkyLightComponent = GSkyLightMapOverride.Cubemap ==
nullptr
2165 ? FindSkyLightComponent(TEXT(
"SkyLightComponent")) :
nullptr)
2167 if (!SkyLightComponent->IsActive())
2168 SkyLightComponent->SetActive(
true);
2171 float Floor = SkylightFloor;
2173 if (TwilightEnd < 0.0f && Weather.SunAltitudeAngle > TwilightEnd && SkylightFloor > 0.0f)
2180 Floor = FMath::Pow(DayValue, 1.0f - U) * FMath::Pow(SkylightFloor, U);
2182 if (Floor > 0.0f && SkyLightComponent->Intensity < Floor)
2183 SkyLightComponent->SetIntensity(Floor);
2192 FObjectProperty* SphereProperty = CastField<FObjectProperty>(
2193 FindPropertyByAuthoredName(SkyActor->GetClass(), TEXT(
"SkySphere")));
2194 if (SphereProperty ==
nullptr)
2195 SphereProperty = CastField<FObjectProperty>(
2196 FindPropertyByAuthoredName(SkyActor->GetClass(), TEXT(
"Sky Sphere")));
2197 AActor* SphereActor = SphereProperty !=
nullptr
2198 ? Cast<AActor>(SphereProperty->GetObjectPropertyValue_InContainer(SkyActor))
2203 if (SphereActor ==
nullptr)
2205 TInlineComponentArray<UChildActorComponent*> RigChildActors;
2206 SkyActor->GetComponents(RigChildActors);
2207 for (UChildActorComponent* RigChild : RigChildActors)
2209 AActor* Candidate = RigChild !=
nullptr ? RigChild->GetChildActor() :
nullptr;
2210 if (Candidate !=
nullptr &&
2211 FindPropertyByAuthoredName(Candidate->GetClass(), TEXT(
"Stars Brightness")) !=
nullptr)
2213 SphereActor = Candidate;
2218 UE_LOG(LogCarla, Verbose, TEXT(
"AWeather night sky: sphere property %s, actor %s"),
2219 SphereProperty ? TEXT(
"found") : TEXT(
"MISSING"),
2220 SphereActor ? *SphereActor->GetName() : TEXT(
"null"));
2221 if (SphereActor !=
nullptr)
2223 if (FBoolProperty* ColorsBySunProperty = CastField<FBoolProperty>(
2224 FindPropertyByAuthoredName(SphereActor->GetClass(), TEXT(
"Colors Determined By Sun Position"))))
2225 ColorsBySunProperty->SetPropertyValue_InContainer(SphereActor,
true);
2227 UE_LOG(LogCarla, Verbose, TEXT(
"AWeather night sky: 'Colors Determined By Sun Position' MISSING on %s"),
2228 *SphereActor->GetClass()->GetName());
2233 if (FNumericProperty* StarsBrightnessProperty = CastField<FNumericProperty>(
2234 FindPropertyByAuthoredName(SphereActor->GetClass(), TEXT(
"Stars Brightness"))))
2236 void* ValuePtr = StarsBrightnessProperty->ContainerPtrToValuePtr<
void>(SphereActor);
2238 if (StarsFloor > 0.0f)
2239 StarsBrightnessProperty->SetFloatingPointPropertyValue(ValuePtr, StarsFloor);
2242 UE_LOG(LogCarla, Verbose, TEXT(
"AWeather night sky: 'Stars Brightness' MISSING on %s"),
2243 *SphereActor->GetClass()->GetName());
2251 UFunction* RefreshMaterialFunction = SphereActor->FindFunction(TEXT(
"RefreshMaterial"));
2252 if (RefreshMaterialFunction !=
nullptr && RefreshMaterialFunction->ParmsSize == 0)
2253 SphereActor->ProcessEvent(RefreshMaterialFunction,
nullptr);
2259 TInlineComponentArray<UMeshComponent*> SphereMeshes;
2260 SphereActor->GetComponents(SphereMeshes);
2261 for (UMeshComponent* SphereMesh : SphereMeshes)
2263 UMaterialInstanceDynamic* SphereMID = SphereMesh !=
nullptr
2264 ? Cast<UMaterialInstanceDynamic>(SphereMesh->GetMaterial(0)) :
nullptr;
2265 if (SphereMID ==
nullptr)
2267 if (NightColor.R >= 0.0f)
2269 SphereMID->SetVectorParameterValue(TEXT(
"Horizon color"), NightColor);
2270 SphereMID->SetVectorParameterValue(TEXT(
"Zenith Color"), NightColor);
2271 SphereMID->SetVectorParameterValue(TEXT(
"Cloud color"), NightColor);
2273 if (CloudOpacity >= 0.0f)
2274 SphereMID->SetScalarParameterValue(TEXT(
"Cloud opacity"), CloudOpacity);
2295 ULightComponent* MoonLightComponent = MoonBlend <= 0.0f
2296 ? FindComponent(TEXT(
"DirectionalLightComponentMoon")) :
nullptr;
2297 if (MoonLightComponent !=
nullptr)
2299 if (MoonLightComponent->Intensity != 0.0f)
2300 MoonLightComponent->SetIntensity(0.0f);
2311 FObjectProperty* CloudComponentProperty = CastField<FObjectProperty>(
2312 SkyActor->GetClass()->FindPropertyByName(TEXT(
"VolumetricCloudComponent")));
2313 UVolumetricCloudComponent* CloudComponent = CloudComponentProperty !=
nullptr
2314 ? Cast<UVolumetricCloudComponent>(CloudComponentProperty->GetObjectPropertyValue_InContainer(SkyActor))
2316 if (CloudComponent !=
nullptr)
2319 UCurveFloat*
const DensityCurve = LoadObject<UCurveFloat>(
nullptr,
2320 TEXT(
"/Game/Carla/Blueprints/Weather/CloudsBillowy/C_BillowyDensity.C_BillowyDensity"));
2321 UMaterialInterface*
const NormalCloudMaterial = LoadObject<UMaterialInterface>(
nullptr,
2322 TEXT(
"/Game/Carla/Static/FX/VolumetricClouds/MI_Clouds.MI_Clouds"));
2323 UMaterialInterface*
const BillowyCloudMaterial = LoadObject<UMaterialInterface>(
nullptr,
2324 TEXT(
"/Game/Carla/Static/GenericMaterials/VolumetricClouds/Masters/M_VolumetricCloud_03_Profiles_Billowy_Inst.M_VolumetricCloud_03_Profiles_Billowy_Inst"));
2329 UMaterialInterface* BaseMaterial = bOvercast ? BillowyCloudMaterial : NormalCloudMaterial;
2330 if (BaseMaterial !=
nullptr)
2345 static TMap<TWeakObjectPtr<UVolumetricCloudComponent>, TWeakObjectPtr<UMaterialInstanceDynamic>> CloudMIDCache;
2346 TWeakObjectPtr<UMaterialInstanceDynamic>* CachedMID = CloudMIDCache.Find(CloudComponent);
2347 UMaterialInstanceDynamic* CloudMID = (CachedMID !=
nullptr && CachedMID->IsValid()
2348 && CachedMID->Get()->Parent == BaseMaterial)
2351 if (CloudMID ==
nullptr)
2353 CloudMID = UMaterialInstanceDynamic::Create(BaseMaterial, CloudComponent);
2354 CloudMIDCache.Add(CloudComponent, CloudMID);
2368 if (DensityCurve !=
nullptr)
2369 CloudMID->SetScalarParameterValue(TEXT(
"Cloud Density"), DensityCurve->GetFloatValue(
Weather.
Cloudiness));
2382 if (DeckNoiseExp > 0.0f && BaseNoiseExp > 0.0f)
2383 BaseNoiseExp = FMath::Exp(FMath::Lerp(FMath::Loge(BaseNoiseExp), FMath::Loge(DeckNoiseExp),
2385 CloudMID->SetScalarParameterValue(TEXT(
"BaseNoiseExp"), BaseNoiseExp);
2388 auto BlendToDeck = [CloudMID, BaseMaterial](
const TCHAR* Name,
float DeckValue,
float Alpha)
2390 float Authored = 0.0f;
2391 if (BaseMaterial->GetScalarParameterValue(Name, Authored))
2392 CloudMID->SetScalarParameterValue(Name, DeckValue >= 0.0f ? FMath::Lerp(Authored, DeckValue, Alpha) : Authored);
2400 WarpSwitch < 0.0f ? Deck : (Deck >= WarpSwitch && Deck > 0.0f ? 1.0f : 0.0f));
2402 CloudComponent->SetMaterial(CloudMID);
2406 UE_LOG(LogCarla, Warning, TEXT(
"AWeather: cloud master material missing for %s"), *SkyActor->GetName());
2419 if (UWorld* World = SkyActor->GetWorld())
2422 CarlaLightSubsystem->NotifyDayTimeChange(
2447 UMaterialParameterCollection*
const WeatherMPC = LoadObject<UMaterialParameterCollection>(
nullptr,
2448 TEXT(
"/Game/Carla/Blueprints/Weather/Materials/WeatherMaterialParameters.WeatherMaterialParameters"));
2449 if (WeatherMPC !=
nullptr && SkyActor->GetWorld() !=
nullptr)
2451 UKismetMaterialLibrary::SetScalarParameterValue(
2453 UKismetMaterialLibrary::SetScalarParameterValue(
2454 SkyActor->GetWorld(), WeatherMPC, TEXT(
"Wetness"),
Weather.
Wetness);
2457 UKismetMaterialLibrary::SetScalarParameterValue(
2458 SkyActor->GetWorld(), WeatherMPC, TEXT(
"NightFactor"), NightFactor);
2465 float SunFraction = 0.0f;
2466 if (UCurveFloat* SunCurve = LoadObject<UCurveFloat>(
nullptr,
2467 TEXT(
"/Game/Carla/Blueprints/Weather/Weather2_Curves/SunIntensity_2.SunIntensity_2")))
2470 if (Peak > UE_KINDA_SMALL_NUMBER)
2478 UKismetMaterialLibrary::SetVectorParameterValue(
2479 SkyActor->GetWorld(), WeatherMPC, TEXT(
"CityGlow"), CityGlow + DeckGlow);
2499 FObjectProperty* PostProcessProperty = CastField<FObjectProperty>(
2500 SkyActor->GetClass()->FindPropertyByName(TEXT(
"PostProcessComponent")));
2501 UPostProcessComponent* PostProcessComponent = PostProcessProperty !=
nullptr
2502 ? Cast<UPostProcessComponent>(PostProcessProperty->GetObjectPropertyValue_InContainer(SkyActor))
2504 if (PostProcessComponent !=
nullptr)
2513 if (PostProcessComponent ==
nullptr)
2515 FPostProcessSettings& Settings = PostProcessComponent->Settings;
2516 if (!Settings.bOverride_AutoExposureMethod)
2518 Settings.bOverride_AutoExposureMethod =
true;
2519 Settings.AutoExposureMethod = AEM_Histogram;
2521 if (!Settings.bOverride_AutoExposureBias)
2523 Settings.bOverride_AutoExposureBias =
true;
2524 Settings.AutoExposureBias = 0.0f;
2526 if (!Settings.bOverride_AutoExposureMinBrightness)
2528 Settings.bOverride_AutoExposureMinBrightness =
true;
2529 Settings.AutoExposureMinBrightness = 10.0f;
2531 if (!Settings.bOverride_AutoExposureMaxBrightness)
2533 Settings.bOverride_AutoExposureMaxBrightness =
true;
2534 Settings.AutoExposureMaxBrightness = 12.0f;
2536 if (!Settings.bOverride_AutoExposureSpeedUp)
2538 Settings.bOverride_AutoExposureSpeedUp =
true;
2539 Settings.AutoExposureSpeedUp = 3.0f;
2541 if (!Settings.bOverride_AutoExposureSpeedDown)
2543 Settings.bOverride_AutoExposureSpeedDown =
true;
2544 Settings.AutoExposureSpeedDown = 1.0f;
2548 if (ExposureBias >= 0.0f)
2550 Settings.bOverride_AutoExposureBias =
true;
2551 Settings.AutoExposureBias = ExposureBias;
2555 ASkyBase* Sky = Cast<ASkyBase>(PostProcessComponent->GetOwner());
2556 const bool bBloomIsOurs = Sky !=
nullptr && Sky->bBloomFromWeatherFallback;
2558 if (BloomIntensity >= 0.0f && (!Settings.bOverride_BloomIntensity || bBloomIsOurs))
2560 Settings.bOverride_BloomIntensity =
true;
2561 Settings.BloomIntensity = BloomIntensity;
2563 Sky->bBloomFromWeatherFallback =
true;
2565 else if (BloomIntensity < 0.0f && bBloomIsOurs)
2568 Settings.bOverride_BloomIntensity =
false;
2569 Sky->bBloomFromWeatherFallback =
false;
2572 if (ExposureMaxEV >= 0.0f)
2574 Settings.bOverride_AutoExposureMaxBrightness =
true;
2575 Settings.AutoExposureMaxBrightness = ExposureMaxEV;
2577 PostProcessComponent->bUnbound =
true;
2586 if (CarlaLightSubsystem ==
nullptr)
2592 UE_LOG(LogCarla, Verbose, TEXT(
"AWeather: day/night state (bIsDay=%d) for %d registered CarlaLights"),
2593 bIsDay ? 1 : 0, CarlaLightSubsystem->
NumLights());
2603#ifdef CARLA_WEATHER_EXTRA_LOG
2604 UE_LOG(LogCarla, Log, TEXT(
"Changing weather:"));
2614 UE_LOG(LogCarla, Log, TEXT(
" - Wetness = %.2f"),
Weather.
Wetness);
2672void AWeather::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
2674 Super::PostEditChangeProperty(PropertyChangedEvent);
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonHaloMieScale(TEXT("carla.Weather.MoonHaloMieScale"), 0.1f, TEXT("1 leaves it as the rig sets it."), ECVF_Default)
static float ComputeCloudDeckFactor(float Cloudiness)
static TAutoConsoleVariable< float > CVarCarlaWeatherDayNightBlendDeg(TEXT("carla.Weather.DayNightBlendDeg"), 8.0f, TEXT("spread over. 0 gives a hard switch at the horizon."), ECVF_Default)
static float ApplySunAltitudeFalloff(float CurveValue, float CurvePeak, float SunAltitudeAngle)
static double GLightingJumpWorldSeconds
static FRotator GLastSunRotation(ForceInitToZero)
static int32 GLightingJumpRestore[UE_ARRAY_COUNT(GLightingJumpCVars)]
static TAutoConsoleVariable< float > CVarCarlaWeatherTransmittanceMinElevationDeg(TEXT("carla.Weather.TransmittanceMinElevationDeg"), 0.0f, TEXT("Values above ~5 light the city as if it were day under a night sky."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherSkySphereShowDeg(TEXT("carla.Weather.SkySphereShowDeg"), -12.0f, TEXT("atmosphere."), ECVF_Default)
static void ReleaseLightingUpdateIfSettled(const UWorld *World)
static TAutoConsoleVariable< float > CVarCarlaWeatherSunAltitudeFalloff(TEXT("carla.Weather.SunAltitudeFalloff"), 1.0f, TEXT("curve. 1 is fully physical, 0 leaves the rig's curve alone."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherDeckGlow(TEXT("carla.Weather.DeckGlow"), 2.0f, TEXT("Cloud emission at Cloudiness 100 with the sun at its peak (0 off)."), ECVF_Default)
static float ComputeNightBlend(float SunAltitudeAngle)
static TAutoConsoleVariable< float > CVarCarlaWeatherLightingJumpSettleSeconds(TEXT("carla.Weather.LightingJumpSettleSeconds"), 8.0f, TEXT("World seconds the full Lumen / sky light updates are held after a lighting jump."), ECVF_Default)
static FLinearColor ComputeTwilightCloudScale(float SunAltitudeAngle)
static TAutoConsoleVariable< float > CVarCarlaWeatherBloomIntensity(TEXT("carla.Weather.BloomIntensity"), 1.0f, TEXT("does not set one, so the sun glows in the viewport. Negative leaves it alone."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonDiscAngleDeg(TEXT("carla.Weather.MoonDiscAngleDeg"), 2.0f, TEXT("larger reads better on screen."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonFullAltitudeDeg(TEXT("carla.Weather.MoonFullAltitudeDeg"), 0.0f, TEXT("Must be below MoonFadeStartDeg; otherwise the moon switches on hard there."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherDeckWarpCount(TEXT("carla.Weather.DeckWarpCount"), 1.0f, TEXT("Cloud material domain warp count at Cloudiness 100. Negative leaves the material's."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherSunIndirectIntensity(TEXT("carla.Weather.SunIndirectIntensity"), 1.0f, TEXT("IndirectLightingIntensity forced on the sky rig's sun. Negative leaves the rig's value."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherSkySphereScale(TEXT("carla.Weather.SkySphereScale"), 10.0f, TEXT("1 leaves it as authored."), ECVF_Default)
static float ApplyOvercastBlend(float CurveValue, float OvercastValue, float Cloudiness, bool bOnlyDarken, float CurvePeak)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonHaloMieAnisotropy(TEXT("carla.Weather.MoonHaloMieAnisotropy"), -1.0f, TEXT("leaves it as the rig sets it."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonIntensity(TEXT("carla.Weather.MoonIntensity"), 0.5f, TEXT("leave the rig's authored/curve-driven moon intensity untouched."), ECVF_Default)
static void NoteLightingChange(const UWorld *World, float SunAltitude, float Cloudiness)
static double GLastSunMoveWorldSeconds
static TAutoConsoleVariable< float > CVarCarlaWeatherOvercastSunNeutralize(TEXT("carla.Weather.OvercastSunNeutralize"), 0.6f, TEXT("at sunset. 0 leaves the sun white."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherStarsBrightness(TEXT("carla.Weather.StarsBrightness"), 4.0f, TEXT("the only way to make the stars FAINTER than the 100 the asset ships."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonHaloStartDeg(TEXT("carla.Weather.MoonHaloStartDeg"), 3.0f, TEXT("MoonHaloMieAnisotropy) start blending in."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonDiscSphereFraction(TEXT("carla.Weather.MoonDiscSphereFraction"), 0.9f, TEXT("so the sphere never draws in front of it."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherSunTwilightEndFraction(TEXT("carla.Weather.SunTwilightEndFraction"), 0.0001f, TEXT("the fade is log-linear in between."), ECVF_Default)
static FLinearColor ParseColorCVar(const TAutoConsoleVariable< FString > &CVar, const FLinearColor &Fallback)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonDiscDuskBrightness(TEXT("carla.Weather.MoonDiscDuskBrightness"), 3000.0f, TEXT("night value between MoonDiscBrightnessStartDeg and MoonDiscBrightnessEndDeg."), ECVF_Default)
static TAutoConsoleVariable< bool > CVarCarlaWeatherMoonDiscAdditive(TEXT("carla.Weather.MoonDiscAdditive"), true, TEXT("clouds more exactly."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonHaloEndDeg(TEXT("carla.Weather.MoonHaloEndDeg"), 0.0f, TEXT("Sun altitude at which the night Mie settings are fully applied."), ECVF_Default)
static FLinearColor ComputeOvercastNeutralTint(const USkyAtmosphereComponent *Atmosphere, float SunAltitudeAngle, float Cloudiness, float NeutralizeAmount, float &OutIntensityScale)
static TAutoConsoleVariable< float > CVarCarlaWeatherStreetLightsOnDeg(TEXT("carla.Weather.StreetLightsOnDeg"), 0.8f, TEXT("Sun altitude at or below which street lights are switched on."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherOvercastAmbientMaxGain(TEXT("carla.Weather.OvercastAmbientMaxGain"), 3.0f, TEXT("the horizon cannot turn the ambient blue."), ECVF_Default)
static TAutoConsoleVariable< bool > CVarCarlaWeatherEnableOvercastClouds(TEXT("carla.Weather.EnableOvercastClouds"), false, TEXT("Billowy overcast one. Set false to always use the plain master instead."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonFadeStartDeg(TEXT("carla.Weather.MoonFadeStartDeg"), 10.0f, TEXT("Sun altitude, in degrees, at which the moon starts to fade in."), ECVF_Default)
static TAutoConsoleVariable< FString > CVarCarlaWeatherCityGlowColor(TEXT("carla.Weather.CityGlowColor"), TEXT("1.0 0.85 0.7"), TEXT("Colour of the city glow on the clouds, \"R G B\"."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherOvercastAmbientNeutralize(TEXT("carla.Weather.OvercastAmbientNeutralize"), 0.4f, TEXT("Cloudiness 100 (scaled by Cloudiness). 0 leaves the sky light white."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherRainDeckSkyLightScale(TEXT("carla.Weather.RainDeckSkyLightScale"), 3.0f, TEXT("DeckSkyLightIntensity multiplier at Precipitation 100 (1 = rain does not change it)."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherDeckLightFullCloudiness(TEXT("carla.Weather.DeckLightFullCloudiness"), 84.0f, TEXT("Cloudiness at which the deck's emission and sky light reach their full value."), ECVF_Default)
static void SetForceLightingUpdate(bool bOn)
static float ComputeMoonHaloBlend(float SunAltitudeAngle)
static TAutoConsoleVariable< float > CVarCarlaWeatherDeckSkyLightIntensity(TEXT("carla.Weather.DeckSkyLightIntensity"), 1.0f, TEXT("Replaces OvercastSkyLightIntensity at Cloudiness 100 (blended by the deck factor)."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherSunTwilightStartDeg(TEXT("carla.Weather.SunTwilightStartDeg"), 1.0f, TEXT("Sun altitude at which the twilight fade starts, from the sun's value there."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherSunFalloffExponent(TEXT("carla.Weather.SunFalloffExponent"), 0.01f, TEXT("keeps a low sun brighter, 0 disables the falloff."), ECVF_Default)
static float RainDeckScale(const TAutoConsoleVariable< float > &CVar, float Precipitation)
static TAutoConsoleVariable< float > CVarCarlaWeatherDeckNoiseExp(TEXT("carla.Weather.DeckNoiseExp"), 1.0f, TEXT("Cloud material BaseNoiseExp at Cloudiness 100 (lower = more coverage)."), ECVF_Default)
static float GLastPushedCloudiness
static void UpdateMoonDisc(AActor *SkyActor, const USceneComponent *MoonLight, float MoonBlend, float SunAltitudeAngle)
static float GetOvercastSkyLightTarget(float Cloudiness, float Precipitation)
static TAutoConsoleVariable< float > CVarCarlaWeatherTwilightCloudOffDeg(TEXT("carla.Weather.TwilightCloudOffDeg"), 12.0f, TEXT("Sun altitude at or above which the clouds get the sun's full scattering again."), ECVF_Default)
static bool GForcingLightingUpdate
static TAutoConsoleVariable< float > CVarCarlaWeatherRainDeckGlowScale(TEXT("carla.Weather.RainDeckGlowScale"), 0.25f, TEXT("DeckGlow multiplier at Precipitation 100 (1 = rain does not change the deck)."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherDeckWarpSwitch(TEXT("carla.Weather.DeckWarpSwitch"), -1.0f, TEXT("-1: blend the warp count with the deck factor. 0-1: flip it to DeckWarpCount at that deck factor."), ECVF_Default)
static void NoteSunRotation(const UWorld *World, const FRotator &Rotation)
static TAutoConsoleVariable< bool > CVarCarlaWeatherVSMInvalidateWhileSunMoves(TEXT("carla.Weather.VSMInvalidateWhileSunMoves"), true, TEXT("changes. 0 leaves it alone."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonDiscDistanceKm(TEXT("carla.Weather.MoonDiscDistanceKm"), 100.0f, TEXT("the clouds so they cover it. Clamped to MoonDiscSphereFraction of the sphere."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherDeckCoverageExponent(TEXT("carla.Weather.DeckCoverageExponent"), 2.0f, TEXT("Power applied to the deck factor for the cloud coverage (BaseNoiseExp) blend."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherSkySphereCloudOpacity(TEXT("carla.Weather.SkySphereCloudOpacity"), 0.0f, TEXT("asset's value."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonDiscContrast(TEXT("carla.Weather.MoonDiscContrast"), 0.7f, TEXT("Contrast of the moon texture: 1 as authored, 0 flat grey."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonDiscBrightnessStartDeg(TEXT("carla.Weather.MoonDiscBrightnessStartDeg"), 2.0f, TEXT("Sun altitude at which the moon disc starts dimming from its dusk brightness."), ECVF_Default)
static const int32 GLightingJumpValues[]
static TAutoConsoleVariable< float > CVarCarlaWeatherCityGlow(TEXT("carla.Weather.CityGlow"), 0.000002f, TEXT("Night emission of the clouds from city lights (0 off)."), ECVF_Default)
static void UpdateMoonHalo(AActor *SkyActor, float HaloBlend)
static TAutoConsoleVariable< float > CVarCarlaWeatherCloudShadowExtentKm(TEXT("carla.Weather.CloudShadowExtentKm"), 10.0f, TEXT("whatever the rig authored."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherSunTwilightEndDeg(TEXT("carla.Weather.SunTwilightEndDeg"), -10.0f, TEXT("0 or above leaves the rig's hard cut at the horizon."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonDiscBrightnessEndDeg(TEXT("carla.Weather.MoonDiscBrightnessEndDeg"), -4.0f, TEXT("Sun altitude at which the moon disc reaches its night brightness."), ECVF_Default)
static float ComputeMoonBlend(float SunAltitudeAngle)
static TAutoConsoleVariable< FString > CVarCarlaWeatherTwilightCloudScale(TEXT("carla.Weather.TwilightCloudScale"), TEXT("0.4 0.55 0.8"), TEXT("Sun CloudScatteredLuminanceScale at the horizon, \"R G B\" (\"1 1 1\" off)."), ECVF_Default)
static float SampleCurvePeakAboveHorizon(UCurveFloat *Curve)
static TAutoConsoleVariable< float > CVarCarlaWeatherLightingJumpSunDeg(TEXT("carla.Weather.LightingJumpSunDeg"), 5.0f, TEXT("jump and forces Lumen and the sky light capture to update in full. 0 disables it."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonDiscNightBrightness(TEXT("carla.Weather.MoonDiscNightBrightness"), 40.0f, TEXT("around it, the only per-object bloom control there is."), ECVF_Default)
static TAutoConsoleVariable< FString > CVarCarlaWeatherDeckGlowColor(TEXT("carla.Weather.DeckGlowColor"), TEXT("1.0 1.0 1.0"), TEXT("Colour of the overcast deck emission, \"R G B\"."), ECVF_Default)
static float ComputeSunTwilightFactor(float SunAltitudeAngle)
static void SetForceInvalidateDirectionalVSM(bool bOn)
static TAutoConsoleVariable< float > CVarCarlaWeatherLightingJumpCloudiness(TEXT("carla.Weather.LightingJumpCloudiness"), 30.0f, TEXT("Cloudiness change between two weather pushes that counts as a lighting jump. 0 disables it."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherDeckExtinctionScale(TEXT("carla.Weather.DeckExtinctionScale"), 0.005f, TEXT("Cloud material ExtinctionScale at Cloudiness 100 (softer deck base). Negative leaves the material's."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherTwilightCloudFullDeg(TEXT("carla.Weather.TwilightCloudFullDeg"), 2.0f, TEXT("Sun altitude at or below which carla.Weather.TwilightCloudScale applies in full."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherNightSkylightIntensity(TEXT("carla.Weather.NightSkylightIntensity"), 10.0f, TEXT("leave the rig's curve-driven skylight intensity untouched."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherSunHorizonFloor(TEXT("carla.Weather.SunHorizonFloor"), 0.05f, TEXT("value. 0.004 is a real horizon sun's ~400 lux against ~100000 overhead."), ECVF_Default)
static bool GForcingDirectionalVSMInvalidate
static TAutoConsoleVariable< float > CVarCarlaWeatherSkyLightIndirectIntensity(TEXT("carla.Weather.SkyLightIndirectIntensity"), 1.0f, TEXT("IndirectLightingIntensity forced on the sky rig's sky light. Negative leaves the rig's value."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherMoonMinAltitudeDeg(TEXT("carla.Weather.MoonMinAltitudeDeg"), 20.0f, TEXT("across dusk instead of from below the horizon. 0 is the plain anti-solar point."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherExposureBias(TEXT("carla.Weather.ExposureBias"), -1.0f, TEXT("Negative leaves the rig's authored value."), ECVF_Default)
static TAutoConsoleVariable< bool > CVarCarlaWeatherMoonDisc(TEXT("carla.Weather.MoonDisc"), true, TEXT("Draw the textured moon disc along the moon light's direction."), ECVF_Default)
static TAutoConsoleVariable< bool > CVarCarlaWeatherMoonAtmosphereDisk(TEXT("carla.Weather.MoonAtmosphereDisk"), false, TEXT("textured moon disc (carla.Weather.MoonDisc) replaces it."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherTransmittanceReleaseDeg(TEXT("carla.Weather.TransmittanceReleaseDeg"), -6.0f, TEXT("back to the engine's -90. Between 0 and this it eases off."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherDeckStartCloudiness(TEXT("carla.Weather.DeckStartCloudiness"), 80.0f, TEXT("Cloudiness at which the clouds start closing into the overcast deck (full at 100)."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherVSMSunStillSeconds(TEXT("carla.Weather.VSMSunStillSeconds"), 1.0f, TEXT("pushes of a moving sun, which brought the flicker back."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherOvercastSunIntensity(TEXT("carla.Weather.OvercastSunIntensity"), 1200.0f, TEXT("and clamped so it can only darken. Negative disables."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherOvercastThreshold(TEXT("carla.Weather.OvercastThreshold"), 90.0f, TEXT("from the plain cloud master material to the Billowy overcast one."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherFogDensityScale(TEXT("carla.Weather.FogDensityScale"), 0.001f, TEXT("The shipped 0.001 caps the engine at 0.1, too thin for a heavy-rain veil."), ECVF_Default)
static TAutoConsoleVariable< float > CVarCarlaWeatherOvercastSkyLightIntensity(TEXT("carla.Weather.OvercastSkyLightIntensity"), 10.0f, TEXT("Cloudiness and clamped so it can only brighten. Negative disables."), ECVF_Default)
static void ReleaseDirectionalVSMInvalidateIfSunStill(const UWorld *World)
static float GLastPushedSunAltitude
static float ComputeCloudDeckLightFactor(float Cloudiness)
static TAutoConsoleVariable< float > CVarCarlaWeatherExposureMaxEV(TEXT("carla.Weather.ExposureMaxEV"), -1.0f, TEXT("Above 13 nothing measurably changes."), ECVF_Default)
static const TCHAR * GLightingJumpCVars[]
static TAutoConsoleVariable< FString > CVarCarlaWeatherSkySphereNightColor(TEXT("carla.Weather.SkySphereNightColor"), TEXT("0.002 0.002 0.0025"), TEXT("else (e.g. \"off\") leaves the sphere's sun-driven colours."), ECVF_Default)
Recorder for the simulation.
void AddWeather(const CarlaRecorderWeather &Weather)
A sensor that captures images from the scene.
USceneCaptureComponent2D * GetCaptureComponent2D()
static FWeatherParameters * FindWeatherParameters(AActor *SkyActor)
static bool SetSkyLightMap(UWorld *World, class UTextureCube *Cubemap, float Intensity)
Environment-map override for the sky light (set_sky_light_map RPC): every ASkyBase rig in World switc...
UCarlaRainCameraModifier * RainCameraModifier
void SetWeather(const FWeatherParameters &WeatherParameters)
Update the weather parameters without notifing it to the blueprint's event.
FWeatherParameters Weather
void SetDayNightCycle(const bool &active)
Update the day night cycle.
TMap< TWeakObjectPtr< ASceneCaptureCamera >, TWeakObjectPtr< UParticleSystemComponent > > SensorRain
static void ApplyWeatherToSkyActor(AActor *SkyActor, const FWeatherParameters &Weather)
Pushes Weather into a single ASkyBase rig (sun/fog/clouds/atmosphere/ exposure) and runs its blueprin...
void ApplyWeather(const FWeatherParameters &WeatherParameters)
Update the weather parameters and notifies it to the blueprint's event.
void UpdateStreetLightsForDayNight()
Broadcast the current day/night state (derived from SunAltitudeAngle) to UCarlaLightSubsystem so regi...
UMaterial * PrecipitationPostProcessMaterial
UParticleSystemComponent * ViewportRain
static void FillSkyPostProcessFallback(class UPostProcessComponent *PostProcessComponent)
Exposure / bloom defaults for the fields the sky's loaded camera profile does not set (see the commen...
void CheckWeatherPostProcessEffects()
UParticleSystem * RainTemplate
UParticleSystemComponent * CreateRainEmitter(AActor *Owner, bool bSensor)
static bool HasSkyLightMap()
AWeather(const FObjectInitializer &ObjectInitializer)
void NotifyWeather(ASensor *Sensor=nullptr)
Notifing the weather to the blueprint's event.
UMaterial * DustStormPostProcessMaterial
void RefreshWeather(const FWeatherParameters &WeatherParameters)
void PushWeatherToSky()
Push the current weather into the ASkyBase rig (BP_Carla_Sky) and run its blueprint Update.
class UMaterialParameterCollection * RainParameters
TMap< UMaterial *, float > ActiveBlendables
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
virtual void BeginPlay() override
virtual void Tick(float DeltaSeconds) override
static void ClearSkyLightMap(UWorld *World)
Drops the override and restores the real-time atmosphere capture with the curve-driven intensity.
void NotifyDayTimeChange(bool bIsDay)
Broadcast a day/night change and then re-apply the UE4->UE5 component intensity conversion on every r...
virtual void ModifyPostProcess(float DeltaTime, float &BlendWeight, FPostProcessSettings &Settings) override
static UCarlaEpisode * GetCurrentEpisode(const UObject *WorldContextObject)
static ACarlaRecorder * GetRecorder(const UObject *WorldContextObject)
float RayleighScatteringScale
float ScatteringIntensity
float PrecipitationDeposits
float RayleighScatteringScale
float PrecipitationDeposits
float ScatteringIntensity