UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SkyLightComponent.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4#pragma once
5
6#include "CoreMinimal.h"
9#include "RenderResource.h"
10#include "RenderingThread.h"
12#include "Math/SHMath.h"
15#include "SkyLightComponent.generated.h"
16
18class UTextureCube;
19
24{
25 // @todo - support compression
26
27public:
28
30 Size(0),
31 NumMips(0),
32 Format(PF_Unknown),
33 TextureCubeRHI(NULL),
34 NumRefs(0)
35 {}
36
37 virtual ~FSkyTextureCubeResource() { check(NumRefs == 0); }
38
40 {
41 Size = InSize;
42 NumMips = InNumMips;
43 Format = InFormat;
44 }
45
46 ENGINE_API virtual void InitRHI(FRHICommandListBase& RHICmdList) override;
47
48 virtual void ReleaseRHI() override
49 {
50 TextureCubeRHI.SafeRelease();
52 }
53
54 virtual uint32 GetSizeX() const override
55 {
56 return Size;
57 }
58
59 // PVS-Studio notices that the implementation of GetSizeX is identical to this one
60 // and warns us. In this case, it is intentional, so we disable the warning:
61 virtual uint32 GetSizeY() const override //-V524
62 {
63 return Size;
64 }
65
66 // Reference counting.
67 void AddRef()
68 {
70 NumRefs++;
71 }
72
73 ENGINE_API void Release();
74private:
75
76 int32 Size;
77 int32 NumMips;
78 EPixelFormat Format;
79 FTextureRHIRef TextureCubeRHI;
80 int32 NumRefs;
81};
82
83UENUM()
92
99
100UCLASS(Blueprintable, ClassGroup=Lights, HideCategories=(Trigger,Activation,"Components|Activation",Physics), meta=(BlueprintSpawnableComponent), MinimalAPI)
102{
104
105
107 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Light)
108 bool bRealTimeCapture;
109
111 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light)
113
115 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light)
116 TObjectPtr<class UTextureCube> Cubemap;
117
119 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, meta=(UIMin = "0", UIMax = "360"))
120 float SourceCubemapAngle;
121
123 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Light)
125
130 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light)
131 float SkyDistanceThreshold;
132
134 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Light, AdvancedDisplay)
136
142 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, AdvancedDisplay, meta=(DisplayName = "Lower Hemisphere Is Solid Color"))
144
145 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, AdvancedDisplay)
146 FLinearColor LowerHemisphereColor;
147
152 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=DistanceFieldAmbientOcclusion, meta=(UIMin = "200", UIMax = "1500"))
153 float OcclusionMaxDistance;
154
158 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=DistanceFieldAmbientOcclusion, meta=(UIMin = "0", UIMax = "1", DisplayName = "Occlusion Contrast"))
159 float Contrast;
160
164 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=DistanceFieldAmbientOcclusion, meta=(UIMin = ".6", UIMax = "1.6"))
165 float OcclusionExponent;
166
170 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=DistanceFieldAmbientOcclusion, meta=(UIMin = "0", UIMax = "1"))
171 float MinOcclusion;
172
174 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=DistanceFieldAmbientOcclusion)
175 FColor OcclusionTint;
176
180 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = AtmosphereAndCloud)
181 uint32 bCloudAmbientOcclusion : 1;
185 UPROPERTY(EditAnywhere, BlueprintReadOnly, interp, Category = AtmosphereAndCloud, meta = (UIMin = "0", UIMax = "1", ClampMin = "0", SliderExponent = 1.0))
186 float CloudAmbientOcclusionStrength;
190 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = AtmosphereAndCloud, meta = (UIMin = "1", ClampMin = "1"))
191 float CloudAmbientOcclusionExtent;
195 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = AtmosphereAndCloud, meta = (UIMin = "0.25", UIMax = "8", ClampMin = "0.25", SliderExponent = 1.0))
196 float CloudAmbientOcclusionMapResolutionScale;
200 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = AtmosphereAndCloud, meta = (UIMin = "0.0", UIMax = "0.1", ClampMin = "0.0", ClampMax = "1.0", SliderExponent = 2.0))
201 float CloudAmbientOcclusionApertureScale;
202
203
205 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=DistanceFieldAmbientOcclusion)
206 TEnumAsByte<enum EOcclusionCombineMode> OcclusionCombineMode;
207
208 ENGINE_API class FSkyLightSceneProxy* CreateSceneProxy() const;
209
210 //~ Begin UObject Interface
211 ENGINE_API virtual void PostInitProperties() override;
213#if WITH_EDITOR
215 ENGINE_API virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
216 ENGINE_API virtual bool CanEditChange(const FProperty* InProperty) const override;
217 ENGINE_API virtual void CheckForErrors() override;
218#endif // WITH_EDITOR
219 ENGINE_API virtual void BeginDestroy() override;
220 ENGINE_API virtual bool IsReadyForFinishDestroy() override;
221 //~ End UObject Interface
222
223 ENGINE_API virtual TStructOnScope<FActorComponentInstanceData> GetComponentInstanceData() const override;
224 ENGINE_API void ApplyComponentInstanceData(struct FPrecomputedSkyLightInstanceData* ComponentInstanceData);
225
227 static ENGINE_API void UpdateSkyCaptureContents(UWorld* WorldToUpdate);
229
232
233 UFUNCTION(BlueprintCallable, Category="Rendering|Components|SkyLight")
234 ENGINE_API void SetIntensity(float NewIntensity);
235
236 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
238
239 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
241
243 UFUNCTION(BlueprintCallable, Category="Rendering|Components|SkyLight")
244 ENGINE_API void SetLightColor(FLinearColor NewLightColor);
245
247 UFUNCTION(BlueprintCallable, Category="SkyLight")
249
251 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|SkyLight")
252 ENGINE_API void SetSourceCubemapAngle(float NewValue);
253
260 UFUNCTION(BlueprintCallable, Category="SkyLight")
262
263 UFUNCTION(BlueprintCallable, Category="Rendering|Components|SkyLight")
265
266 UFUNCTION(BlueprintCallable, Category="Rendering|Components|SkyLight")
268
269 UFUNCTION(BlueprintCallable, Category="Rendering|Components|SkyLight")
271
272 UFUNCTION(BlueprintCallable, Category="Rendering|Components|SkyLight")
274
275 UFUNCTION(BlueprintCallable, Category="Rendering|Components|SkyLight")
277
278 UFUNCTION(BlueprintCallable, Category="Rendering|Components|SkyLight")
280
282 ENGINE_API virtual void OnVisibilityChanged() override;
283
284public:
285
290
292 ENGINE_API bool IsOcclusionSupported() const;
293
296
302 UFUNCTION(BlueprintCallable, Category="Rendering|Components|SkyLight")
304
306
307 const FTexture* GetProcessedSkyTexture() const { return ProcessedSkyTexture; }
308 FSHVectorRGB3 GetIrradianceEnvironmentMap() { return IrradianceEnvironmentMap; }
309protected:
310
311#if WITH_EDITOR
314#endif
315
318
319 bool bHasEverCaptured;
320
321#if WITH_EDITOR
322 // In an attempt to get valid lighting data as soon as possible in a level, we will always trigger a skylight capture at creation.
323 // And then, a soon as the world is finally loaded, the final capture will be taken.
326#endif
327
328 TRefCountPtr<FSkyTextureCubeResource> ProcessedSkyTexture;
329 FSHVectorRGB3 IrradianceEnvironmentMap;
330 float AverageBrightness=0.0f;
331
333 float BlendFraction;
334
340
341 FLinearColor SpecifiedCubemapColorScale;
342
345
347 FRenderCommandFence ReleaseResourcesFence;
348
349 FSkyLightSceneProxy* SceneProxy;
350
359
360 //~ Begin UActorComponent Interface
361 ENGINE_API virtual void CreateRenderState_Concurrent(FRegisterComponentContext* Context) override;
362 ENGINE_API virtual void DestroyRenderState_Concurrent() override;
363 ENGINE_API virtual void SendRenderTransform_Concurrent() override;
364 //~ Begin UActorComponent Interface
365
368
369 friend class FSkyLightSceneProxy;
370};
371
372
374USTRUCT()
376{
378public:
381 : FSceneComponentInstanceData(SourceComponent)
382 {}
384
385 virtual bool ContainsData() const override
386 {
387 return true;
388 }
389
391 {
392 Super::ApplyToComponent(Component, CacheApplyPhase);
393 CastChecked<USkyLightComponent>(Component)->ApplyComponentInstanceData(this);
394 }
395
396 UPROPERTY()
397 FGuid OriginalLightGuid;
398
399 UPROPERTY()
400 FGuid LightGuid;
401
402 UPROPERTY()
403 float AverageBrightness = 1.0f;
404
405 // This has to be refcounted to keep it alive during the handoff without doing a deep copy
407
409};
410
#define NULL
Definition oodle2base.h:134
#define check(expr)
Definition AssertionMacros.h:314
ECacheApplyPhase
Definition ComponentInstanceDataCache.h:18
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EOcclusionCombineMode
Definition EngineTypes.h:226
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
EPixelFormat
Definition PixelFormat.h:16
@ PF_Unknown
Definition PixelFormat.h:17
ESkyLightCaptureStatus
Definition SkyLightComponent.h:94
ESkyLightSourceType
Definition SkyLightComponent.h:85
@ SLS_SpecifiedCubemap
Definition SkyLightComponent.h:89
@ SLS_CapturedScene
Definition SkyLightComponent.h:87
@ SLS_MAX
Definition SkyLightComponent.h:90
CORE_API bool IsInGameThread()
Definition ThreadingBase.cpp:185
::FCriticalSection FTransactionallySafeCriticalSection
Definition TransactionallySafeCriticalSection.h:16
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition RenderDeferredCleanup.h:11
Definition UnrealType.h:174
Definition RHICommandList.h:455
Definition ActorComponent.h:47
Definition RenderCommandFence.h:15
Definition SkyLightSceneProxy.h:17
FSHVectorRGB3 IrradianceEnvironmentMap
Definition SkyLightSceneProxy.h:48
float AverageBrightness
Definition SkyLightSceneProxy.h:45
Definition SkyLightComponent.h:24
virtual ENGINE_API void InitRHI(FRHICommandListBase &RHICmdList) override
Definition SkyLightComponent.cpp:134
virtual void ReleaseRHI() override
Definition SkyLightComponent.h:48
virtual ~FSkyTextureCubeResource()
Definition SkyLightComponent.h:37
ENGINE_API void Release()
Definition SkyLightComponent.cpp:159
virtual uint32 GetSizeX() const override
Definition SkyLightComponent.h:54
virtual uint32 GetSizeY() const override
Definition SkyLightComponent.h:61
void AddRef()
Definition SkyLightComponent.h:67
void SetupParameters(int32 InSize, int32 InNumMips, EPixelFormat InFormat)
Definition SkyLightComponent.h:39
FSkyTextureCubeResource()
Definition SkyLightComponent.h:29
Definition RenderResource.h:354
virtual RENDERCORE_API void ReleaseRHI() override
Definition RenderResource.cpp:440
Definition Array.h:670
Definition EnumAsByte.h:22
UE_FORCEINLINE_HINT void SafeRelease()
Definition RefCounting.h:599
Definition StructOnScope.h:142
Definition ActorComponent.h:152
Definition TextureCube.h:15
Definition World.h:918
Definition Color.h:486
Definition Guid.h:109
Definition Color.h:48
Definition SkyLightComponent.h:376
virtual void ApplyToComponent(UActorComponent *Component, const ECacheApplyPhase CacheApplyPhase) override
Definition SkyLightComponent.h:390
FPrecomputedSkyLightInstanceData(const USkyLightComponent *SourceComponent)
Definition SkyLightComponent.h:380
virtual ~FPrecomputedSkyLightInstanceData()=default
virtual bool ContainsData() const override
Definition SkyLightComponent.h:385
Definition UnrealType.h:6865
Definition SceneComponent.h:1743
Definition ObjectPtr.h:488