UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LightSceneInfo.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 LightSceneInfo.h: Light scene info definitions.
5=============================================================================*/
6
7#pragma once
8
9#include "CoreTypes.h"
10#include "Math/Color.h"
11#include "Math/GenericOctree.h"
13#include "Math/UnrealMath.h"
14#include "PrimitiveSceneProxy.h"
15#include "SceneTypes.h"
16#include "SceneView.h"
17
19class FLightSceneInfo;
23class FScene;
24class FViewInfo;
26
28{
29 enum Type : int;
30}
31
78
81{
82 union
83 {
84 struct
85 {
86 // Note: the order of these members controls the light sort order!
87 // Currently bHandledByMegaLights is the MSB and LightType is LSB
112 static_assert(sizeof(Packed) >= sizeof(Fields), "SortKey Packed representation must include all bits in Fields");
114
118
124 {
125 SortKey.Packed = 0;
126 SortKey.Fields.bIsNotSimpleLight = 1;
127 }
128
130 : LightSceneInfo(nullptr),
133 {
134 SortKey.Packed = 0;
135 SortKey.Fields.bIsNotSimpleLight = 0;
136 }
137};
138
146{
147 // One past last simple light excluding those handled by Mega Lights
150
153
154 // First light handled by Mega Lights
156 // One past last simple light handled by Mega Lights
158
159 bool bHasRectLights = false;
160 bool bHasLightFunctions = false;
161 bool bHasLightChannels = false;
163
166};
167
168template <>
170{
171 enum { Value = false };
172};
173
176
183
185{
186 return HashCombine(HashCombine((uint32)Key.AtlasIndex, (uint32)Key.ProjectionId), (uint32)Key.SubjectPrimitiveComponentIndex);
187}
188
190{
191 return A.AtlasIndex == B.AtlasIndex && A.ProjectionId == B.ProjectionId && A.SubjectPrimitiveComponentIndex == B.SubjectPrimitiveComponentIndex;
192}
193
195{
196public:
198
200 TRefCountPtr<IPooledRenderTarget> HZB; // Direct HZB. nullptr for Atlas rendering.
201};
202
208{
210
211 bool bRecordInteractionShadowPrimitives;
212 TArray<FLightPrimitiveInteraction*> InteractionShadowPrimitives;
213
215 FLightPrimitiveInteraction* DynamicInteractionOftenMovingPrimitiveList;
216
217 FLightPrimitiveInteraction* DynamicInteractionStaticPrimitiveList;
218
219public:
221
224
226
230
233
237
238protected:
239
245
248
249public:
250
256
263
266
269
272
275
278
281
284
287
289 void AddToScene();
290
297
304
306 void RemoveFromScene();
307
309 void Detach();
310
313
314 bool ShouldRenderLight(const FViewInfo& View, bool bOffscreen = false) const;
315
318
321
322 bool IsPrecomputedLightingValid() const;
323
325
327
329
331
333
335 friend uint32 GetTypeHash(const FLightSceneInfo* LightSceneInfo)
336 {
337 return (uint32)LightSceneInfo->Id;
338 }
339
341
343
344 // Extra data such as shadow channel masks, light type and flags packed into a uint32.
345 // Unpacked in shader using helper functions defined in LightData.ush
346 uint32 PackExtraData(bool bAllowStaticLighting, bool bLightFunction, bool bMegaLight, bool bClusteredDeferredSupported) const;
347};
348
351{
352 enum { MaxElementsPerLeaf = 16 };
354 enum { MaxNodeDepth = 12 };
355
357
359 {
360 return Element.LightSceneInfo->GetBoundingBox();
361 }
362
364 {
365 return A.LightSceneInfo == B.LightSceneInfo;
366 }
367
369 {
370 Element.LightSceneInfo->OctreeId = Id;
371 }
372
374 {
376 Element.BoundingSphereVector = VectorAdd(Element.BoundingSphereVector, OffsetReg);
377 }
378};
#define NULL
Definition oodle2base.h:134
#define FORCEINLINE
Definition AndroidPlatform.h:140
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
TOctree2< FLightSceneInfoCompact, struct FLightOctreeSemantics > FSceneLightOctree
Definition LightSceneInfo.h:175
uint32 GetTypeHash(const FPersistentShadowStateKey &Key)
Definition LightSceneInfo.h:184
bool operator==(const FPersistentShadowStateKey &A, const FPersistentShadowStateKey &B)
Definition LightSceneInfo.h:189
void Init()
Definition LockFreeList.h:4
ELightComponentType
Definition SceneTypes.h:96
@ LightType_NumBits
Definition SceneTypes.h:102
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
FORCEINLINE VectorRegister4Float VectorAdd(const VectorRegister4Float &Vec1, const VectorRegister4Float &Vec2)
Definition UnrealMathFPU.h:704
FORCEINLINE VectorRegister4Float VectorLoadFloat3_W0(const float *Ptr)
VectorLoadFloat3_W0.
Definition UnrealMathVectorCommon.h.inl:129
uint32 Offset
Definition VulkanMemory.cpp:4033
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition GenericOctree.h:42
Definition SceneCore.h:23
Definition LightSceneInfo.h:36
uint32 bStaticLighting
Definition LightSceneInfo.h:47
FLightSceneInfoCompact()
Definition LightSceneInfo.h:59
FLightSceneInfoCompact(FLightSceneInfo *InLightSceneInfo)
Definition LightSceneInfo.h:64
FLinearColor Color
Definition LightSceneInfo.h:40
uint32 bCastDynamicShadow
Definition LightSceneInfo.h:45
uint32 bIsMovable
Definition LightSceneInfo.h:50
VectorRegister BoundingSphereVector
Definition LightSceneInfo.h:39
TEnumAsByte< EMegaLightsShadowMethod::Type > MegaLightsShadowMethod
Definition LightSceneInfo.h:52
uint32 bAffectGlobalIllumination
Definition LightSceneInfo.h:49
FLightSceneInfo * LightSceneInfo
Definition LightSceneInfo.h:42
TEnumAsByte< ECastRayTracedShadow::Type > CastRaytracedShadow
Definition LightSceneInfo.h:53
uint32 bCastStaticShadow
Definition LightSceneInfo.h:46
uint32 LightType
Definition LightSceneInfo.h:44
uint32 bAffectReflection
Definition LightSceneInfo.h:48
uint32 bAllowMegaLights
Definition LightSceneInfo.h:51
bool AffectsPrimitive(const FBoxSphereBounds &PrimitiveBounds, const FPrimitiveSceneProxy *PrimitiveSceneProxy) const
Definition LightSceneInfo.cpp:463
Definition LightSceneInfo.h:208
FBoxCenterAndExtent GetBoundingBox() const
Definition LightSceneInfo.cpp:184
int32 NumUnbuiltInteractions
Definition LightSceneInfo.h:277
uint32 bEnableLightShaftBloom
Definition LightSceneInfo.h:262
FPersistentId Id
Definition LightSceneInfo.h:228
void Detach()
Definition LightSceneInfo.cpp:166
const TArray< FLightPrimitiveInteraction * > * GetInteractionShadowPrimitives() const
Definition LightSceneInfo.cpp:302
bool ShouldRecordShadowSubjectsForMobile() const
Definition LightSceneInfo.cpp:360
float BloomMaxBrightness
Definition LightSceneInfo.h:271
int32 DynamicShadowMapChannel
Definition LightSceneInfo.h:244
FColor BloomTint
Definition LightSceneInfo.h:274
bool ShouldRenderLight(const FViewInfo &View, bool bOffscreen=false) const
Definition LightSceneInfo.cpp:207
FOctreeElementId2 OctreeId
Definition LightSceneInfo.h:232
uint32 bPrecomputedLightingIsValid
Definition LightSceneInfo.h:247
FLightPrimitiveInteraction * GetDynamicInteractionOftenMovingPrimitiveList() const
Definition LightSceneInfo.cpp:307
FORCEINLINE FPersistentId GetPersistentIndex() const
Definition LightSceneInfo.h:229
int32 GetDynamicShadowMapChannel() const
Definition LightSceneInfo.cpp:290
int32 FPersistentId
Definition LightSceneInfo.h:220
FScene * Scene
Definition LightSceneInfo.h:283
bool ShouldRenderViewIndependentWholeSceneShadows() const
Definition LightSceneInfo.cpp:257
void SetDynamicShadowMapChannel(int32 NewChannel)
Definition LightSceneInfo.cpp:277
bool SetupMobileMovableLocalLightShadowParameters(const FViewInfo &View, TConstArrayView< FVisibleLightInfo > VisibleLightInfos, FMobileMovableLocalLightShadowParameters &MobileMovableLocalLightShadowParameters) const
Definition LightSceneInfo.cpp:317
ELightComponentType Type
Definition LightSceneInfo.h:225
uint32 bVisible
Definition LightSceneInfo.h:255
friend uint32 GetTypeHash(const FLightSceneInfo *LightSceneInfo)
Definition LightSceneInfo.h:335
float BloomThreshold
Definition LightSceneInfo.h:268
uint32 PackExtraData(bool bAllowStaticLighting, bool bLightFunction, bool bMegaLight, bool bClusteredDeferredSupported) const
Definition LightSceneInfo.cpp:386
FLightSceneProxy * Proxy
Definition LightSceneInfo.h:223
float BloomScale
Definition LightSceneInfo.h:265
void CreateLightPrimitiveInteraction(const FLightSceneInfoCompact &LightSceneInfoCompact, const FPrimitiveSceneInfoCompact &PrimitiveSceneInfoCompact)
Definition LightSceneInfo.cpp:138
TMap< FPersistentShadowStateKey, FPersistentShadowState > PrevPersistentShadows
Definition LightSceneInfo.h:235
bool bCreatePerObjectShadowsForDynamicObjects
Definition LightSceneInfo.h:280
bool IsPrecomputedLightingValid() const
Definition LightSceneInfo.cpp:272
FLightPrimitiveInteraction * GetDynamicInteractionStaticPrimitiveList() const
Definition LightSceneInfo.cpp:312
void RemoveFromScene()
Definition LightSceneInfo.cpp:147
bool ShouldCreateLightPrimitiveInteraction(const FLightSceneInfoCompact &LightSceneInfoCompact, const FPrimitiveSceneInfoCompact &PrimitiveSceneInfoCompact)
Definition LightSceneInfo.cpp:128
bool ShouldRenderLightViewIndependent() const
Definition LightSceneInfo.cpp:250
void AddToScene()
Definition LightSceneInfo.cpp:83
TMap< FPersistentShadowStateKey, FPersistentShadowState > PersistentShadows
Definition LightSceneInfo.h:236
Definition LightSceneProxy.h:43
Definition GenericOctreePublic.h:15
Definition LightSceneInfo.h:195
TRefCountPtr< IPooledRenderTarget > HZB
Definition LightSceneInfo.h:200
FIntRect HZBTestViewRect
Definition LightSceneInfo.h:199
FViewMatrices ViewMatrices
Definition LightSceneInfo.h:197
Definition PrimitiveSceneInfo.h:201
Definition PrimitiveSceneProxy.h:296
Definition ScenePrivate.h:2875
Definition PrimitiveSceneProxy.h:172
Definition SceneRendering.h:1132
Definition SceneRendering.h:211
Definition ContainerAllocationPolicies.h:447
Definition Array.h:670
Definition EnumAsByte.h:22
Definition UnrealString.h.inl:34
Definition GenericOctree.h:378
Definition RefCounting.h:454
Definition ContainerAllocationPolicies.h:894
Definition EngineTypes.h:501
Type
Definition EngineTypes.h:503
int
Definition TestServer.py:515
@ false
Definition radaudio_common.h:23
Definition Color.h:486
Definition LightSceneInfo.h:351
static FORCEINLINE void ApplyOffset(FLightSceneInfoCompact &Element, FVector Offset)
Definition LightSceneInfo.h:373
@ MinInclusiveElementsPerNode
Definition LightSceneInfo.h:353
static FORCEINLINE void SetElementId(const FLightSceneInfoCompact &Element, FOctreeElementId2 Id)
Definition LightSceneInfo.h:368
static FORCEINLINE bool AreElementsEqual(const FLightSceneInfoCompact &A, const FLightSceneInfoCompact &B)
Definition LightSceneInfo.h:363
static FORCEINLINE FBoxCenterAndExtent GetBoundingBox(const FLightSceneInfoCompact &Element)
Definition LightSceneInfo.h:358
@ MaxNodeDepth
Definition LightSceneInfo.h:354
@ MaxElementsPerLeaf
Definition LightSceneInfo.h:352
Definition Color.h:48
Definition LightSceneInfo.h:178
int32 SubjectPrimitiveComponentIndex
Definition LightSceneInfo.h:181
int32 ProjectionId
Definition LightSceneInfo.h:180
int32 AtlasIndex
Definition LightSceneInfo.h:179
Definition LightSceneInfo.h:81
uint32 Packed
Definition LightSceneInfo.h:111
uint32 LightSceneId
Definition LightSceneInfo.h:106
uint32 bShadowed
Definition LightSceneInfo.h:97
uint32 bLightFunction
Definition LightSceneInfo.h:93
int32 SimpleLightIndex
Definition LightSceneInfo.h:116
uint32 bIsNotSimpleLight
Definition LightSceneInfo.h:99
FSortedLightSceneInfo(int32 InSimpleLightIndex)
Definition LightSceneInfo.h:129
uint32 LightType
Definition LightSceneInfo.h:89
const FLightSceneInfo * LightSceneInfo
Definition LightSceneInfo.h:115
uint32 bHandledByMegaLights
Definition LightSceneInfo.h:108
bool bIsCompatibleWithLightFunctionAtlas
Definition LightSceneInfo.h:117
uint32 bIESProfile
Definition LightSceneInfo.h:91
union FSortedLightSceneInfo::@1755 SortKey
FSortedLightSceneInfo(const FLightSceneInfo *InLightSceneInfo)
Definition LightSceneInfo.h:120
uint32 bClusteredDeferredNotSupported
Definition LightSceneInfo.h:104
struct FSortedLightSceneInfo::@1755::@1756 Fields
uint32 bUsesLightingChannels
Definition LightSceneInfo.h:95
Definition LightSceneInfo.h:146
bool bHasRectLights
Definition LightSceneInfo.h:159
bool bHasLightChannels
Definition LightSceneInfo.h:161
bool bHasLightFunctions
Definition LightSceneInfo.h:160
FSimpleLightArray SimpleLights
Definition LightSceneInfo.h:164
TArray< FSortedLightSceneInfo, SceneRenderingAllocator > SortedLights
Definition LightSceneInfo.h:165
int32 SimpleLightsEnd
Definition LightSceneInfo.h:148
int32 MegaLightsSimpleLightsEnd
Definition LightSceneInfo.h:157
int32 MegaLightsLightStart
Definition LightSceneInfo.h:155
int32 ClusteredSupportedEnd
Definition LightSceneInfo.h:149
int32 UnbatchedLightStart
Definition LightSceneInfo.h:152
bool bHasFirstPersonSelfShadowLights
Definition LightSceneInfo.h:162
Definition SceneView.h:317
Definition UseBitwiseSwap.h:13
@ Value
Definition UseBitwiseSwap.h:15
Definition BoxSphereBounds.h:25
Definition UnrealMathFPU.h:42