4#include <util/ue-header-guard-begin.h>
5#include "Components/PostProcessComponent.h"
6#include "Components/ExponentialHeightFogComponent.h"
7#include "Components/DirectionalLightComponent.h"
8#include "Components/DirectionalLightComponent.h"
9#include "Components/SkyLightComponent.h"
10#include "Components/VolumetricCloudComponent.h"
11#include "Components/SkyAtmosphereComponent.h"
12#include <util/ue-header-guard-end.h>
18#include <util/ue-header-guard-begin.h>
19#include "Kismet/GameplayStatics.h"
20#include <util/ue-header-guard-end.h>
24 AWeather* FindWeatherActor(
const UWorld* World)
26 return World !=
nullptr
27 ? Cast<AWeather>(UGameplayStatics::GetActorOfClass(World, AWeather::StaticClass()))
39 return Weather->GetCurrentWeather();
52 Weather->ApplyWeather(NewWeather);
61 for (TFieldIterator<FProperty> It(SkyActor->GetClass()); It; ++It)
63 FStructProperty* StructProperty = CastField<FStructProperty>(*It);
64 if (StructProperty !=
nullptr && StructProperty->Struct == FWeatherParameters::StaticStruct())
71 const FObjectInitializer& ObjectInitializer) :
72 Super(ObjectInitializer)
102 SkyLightComponent = CreateDefaultSubobject<USkyLightComponent>(
"SkyLightComponent");
162 if (!bTimeOk && !bConditionOk)
202 RerunConstructionScripts();
252 ApplyWeatherTo(
this, *SkyParameters);
257 const UWorld* World = GetWorld();
258 if (World ==
nullptr)
260 FString MapName = World->GetMapName();
261 MapName.RemoveFromStart(World->StreamingLevelsPrefix);
267 ApplyWeatherTo(
this, MapDefault);
269 RerunConstructionScripts();
297 Settings.bOverride_LocalExposureHighlightContrastScale =
true;
299 Settings.bOverride_LocalExposureShadowContrastScale =
true;
302 Settings.bOverride_CameraShutterSpeed =
true;
304 Settings.bOverride_AutoExposureMethod =
true;
306 Settings.bOverride_CameraISO =
true;
308 Settings.bOverride_DepthOfFieldFstop =
true;
311 Settings.bOverride_DepthOfFieldSensorWidth =
true;
313 Settings.bOverride_DepthOfFieldFocalDistance =
true;
316 Settings.bOverride_WhiteTemp =
true;
318 Settings.bOverride_WhiteTint =
true;
320 Settings.bOverride_SceneColorTint =
true;
322 Settings.bOverride_ColorSaturation =
true;
325 Settings.bOverride_ColorContrast =
true;
328 Settings.bOverride_ColorGamma =
true;
331 Settings.bOverride_VignetteIntensity =
true;
362void ASkyBase::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
364 Super::PostEditChangeProperty(PropertyChangedEvent);
366 const FName PropertyName = PropertyChangedEvent.GetPropertyName();
367 if (PropertyName == GET_MEMBER_NAME_CHECKED(
ASkyBase, TimePresetName)
368 || PropertyName == GET_MEMBER_NAME_CHECKED(
ASkyBase, ConditionPresetName))
377 Super::OnConstruction(Transform);
387 if (GetWorld() !=
nullptr && GetWorld()->IsGameWorld())
409 UWorld* World = GetWorld();
420 UE_LOG(LogCarla, Log, TEXT(
"ASkyBase: %s loaded camera profile '%s'"), *GetName(), *Profile);
424 UE_LOG(LogCarla, Warning, TEXT(
"ASkyBase: %s could not load camera profile '%s'"), *GetName(), *Profile);
432 TArray<AActor*> Fallbacks;
433 UGameplayStatics::GetAllActorsWithTag(World,
FallbackSkyTag, Fallbacks);
434 if (Fallbacks.IsEmpty())
436 for (
AActor* Fallback : Fallbacks)
440 TArray<AActor*> Attached;
441 Fallback->GetAttachedActors(Attached,
true,
true);
442 for (
AActor* Child : Attached)
446 UE_LOG(LogCarla, Log, TEXT(
"ASkyBase: %s streamed in, removed %d fallback sky rig(s)"),
447 *GetName(), Fallbacks.Num());
450 if (
AWeather*
Weather = Cast<AWeather>(UGameplayStatics::GetActorOfClass(World, AWeather::StaticClass())))
456 const UWorld* World = GetWorld();
457 if (World ==
nullptr)
459 FString MapName = World->GetMapName();
460 MapName.RemoveFromStart(World->StreamingLevelsPrefix);
466 const UWorld* World = GetWorld();
467 if (World ==
nullptr)
469 FString MapName = World->GetMapName();
470 MapName.RemoveFromStart(World->StreamingLevelsPrefix);
static TArray< FString > GetAvailableConditionPresetNamesForPicker()
UPostProcessComponent * PostProcessComponent
FString NewTimePresetName
static FWeatherParameters * FindWeatherParameters(AActor *SkyActor)
USkyLightComponent * SkyLightComponent
USkyAtmosphereComponent * SkyAtmosphereComponent
UVolumetricCloudComponent * VolumetricCloudComponent
void D_SaveCurrentWeatherAsMapDefault()
void C_SaveConditionPreset()
void G_CreateConditionPreset()
UDirectionalLightComponent * DirectionalLightComponentMoon
bool bBloomFromWeatherFallback
ASkyBase(const FObjectInitializer &ObjectInitializer)
void ApplyTimeAndConditionPresets()
virtual void OnConstruction(const FTransform &Transform) override
static TArray< FString > GetAvailableTimePresetNamesForPicker()
static TArray< FString > GetAvailablePostProcessProfileNamesForPicker()
virtual void BeginPlay() override
void F_CreateTimePreset()
static const FName FallbackSkyTag
UExponentialHeightFogComponent * ExponentialHeightFogComponent
FString NewConditionPresetName
void SyncCameraParametersFromPostProcess()
UDirectionalLightComponent * DirectionalLightComponentSun
FCameraParameters CameraParameters
void PushCameraParameters()
static void ApplyWeatherToSkyActor(AActor *SkyActor, const FWeatherParameters &Weather)
Pushes Weather into a single ASkyBase rig (sun/fog/clouds/atmosphere/ exposure) and runs its blueprin...
static void FillSkyPostProcessFallback(class UPostProcessComponent *PostProcessComponent)
Exposure / bloom defaults for the fields the sky's loaded camera profile does not set (see the commen...
static bool LoadAllPostProcessFromJsonToPostProcessComponent(UPostProcessComponent *Volume, const FString &FileName)
static bool SaveAllPostProcessComponentToJson(UPostProcessComponent *Volume, const FString &FileName)
static TArray< FString > GetAvailablePostProcessProfileNames()
static FString GetViewportProfileName()
static FWeatherParameters MergeWeatherPresets(const FWeatherParameters &Base, const FWeatherTimePreset &TimePreset, const FWeatherConditionPreset &ConditionPreset)
static bool SaveConditionPreset(const FWeatherConditionPreset &Preset, const FString &Name)
static bool GetMapDefaultWeather(const FString &MapName, const FWeatherParameters &Base, UPARAM(ref) FWeatherParameters &OutWeather)
static TArray< FString > GetAvailableConditionPresetNames()
static bool LoadConditionPreset(UPARAM(ref) FWeatherConditionPreset &OutPreset, const FString &Name)
static bool SaveTimePreset(const FWeatherTimePreset &Preset, const FString &Name)
static bool SetMapDefaultWeather(const FString &MapName, const FWeatherParameters &Weather)
static TArray< FString > GetAvailableTimePresetNames()
static bool LoadTimePreset(UPARAM(ref) FWeatherTimePreset &OutPreset, const FString &Name)
static bool SetMapDefaultPresetNames(const FString &MapName, const FString &TimeName, const FString &ConditionName)
TEnumAsByte< EAutoExposureMethod > ExposureMode
FLinearColor SceneColorTint
float RayleighScatteringScale
float PrecipitationDeposits
float ScatteringIntensity
float RayleighScatteringScale
float PrecipitationDeposits
float ScatteringIntensity