UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LightComponent.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
9#include "EngineDefines.h"
10#include "SceneTypes.h"
11#include "RenderResource.h"
13#include "LightComponent.generated.h"
14
19class ULevel;
21class UPrimitiveComponent;
23enum class ELightUnits : uint8;
24
26
32{
33public:
34
38
40
41 virtual void InitRHI(FRHICommandListBase& RHICmdList);
42};
43
44UCLASS(abstract, HideCategories=(Trigger,Activation,"Components|Activation",Physics), ShowCategories=(Mobility), MinimalAPI)
46{
48
49
53 UPROPERTY(EditAnywhere, BlueprintReadOnly, interp, Category = Light, meta = (UIMin = "1700.0", UIMax = "12000.0", ShouldShowInViewport = true, DisplayAfter ="bUseTemperature"))
54 float Temperature;
55
57 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Performance)
58 float MaxDrawDistance;
59
61 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Performance, meta = (EditCondition = "MaxDrawDistance > 0.0"))
63
65 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, meta=(DisplayName = "Use Temperature", ShouldShowInViewport = true))
67
71 UPROPERTY()
73
75 UPROPERTY(NonPIEDuplicateTransient)
76 int32 PreviewShadowMapChannel;
77
79 UPROPERTY()
81
86 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, AdvancedDisplay, meta=(UIMin = "0", UIMax = "1"))
87 float SpecularScale;
88
92 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, AdvancedDisplay, meta=(UIMin = "0", UIMax = "1"))
93 float DiffuseScale;
94
100 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, AdvancedDisplay, meta=(UIMin = ".125", UIMax = "8"))
101 float ShadowResolutionScale;
102
109 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, AdvancedDisplay, meta=(UIMin = "0", UIMax = "1"))
110 float ShadowBias;
111
119 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Light, AdvancedDisplay, meta = (UIMin = "0", UIMax = "1"))
120 float ShadowSlopeBias;
121
123 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, AdvancedDisplay, meta=(UIMin = "0.0", UIMax = "1.0", DisplayName = "Shadow Filter Sharpen"))
124 float ShadowSharpen;
125
127 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Light, AdvancedDisplay, meta = (UIMin = "0.0", UIMax = "0.1"))
128 float ContactShadowLength;
129
131 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Light, AdvancedDisplay, meta = (DisplayName = "Contact Shadow Length In World Space Units"))
133
135 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Light, AdvancedDisplay, meta = (ClampMin = 0.0, ClampMax = 1.0, UIMin = "0.0", UIMax = "1.0"))
136 float ContactShadowCastingIntensity;
137
139 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Light, AdvancedDisplay, meta = (ClampMin = 0.0, ClampMax = 1.0))
140 float ContactShadowNonCastingIntensity;
141
142 UPROPERTY()
144
146 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, AdvancedDisplay)
148
154 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Light, AdvancedDisplay)
155 uint32 bCastShadowsFromCinematicObjectsOnly:1;
156
160 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Light, AdvancedDisplay)
161 uint32 bForceCachedShadowsForMovablePrimitives : 1;
162
167 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Light, meta = (DisplayName = "Allow MegaLights"), AdvancedDisplay)
168 uint32 bAllowMegaLights : 1;
169
175 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Light, meta = (DisplayName = "MegaLights Shadow Method"), AdvancedDisplay)
176 TEnumAsByte<EMegaLightsShadowMethod::Type> MegaLightsShadowMethod;
177
178 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Light, meta=(InlineEditConditionToggle), AdvancedDisplay)
180
181 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Light, meta = (EditCondition = "bOverrideRayEndBias", ClampMin = "0", UIMax = "100"), AdvancedDisplay)
182 float RayEndBias;
183
189 UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadOnly, Category=Light)
190 FLightingChannels LightingChannels;
191
193 UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadOnly, Category=Light)
194 FViewLightingChannels ViewLightingChannels;
195
201 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightFunction)
202 TObjectPtr<class UMaterialInterface> LightFunctionMaterial;
203
204#if WITH_EDITORONLY_DATA
208#endif
209
211 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightFunction, meta=(AllowPreserveRatio = "true"))
212 FVector LightFunctionScale;
213
215 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightProfiles, meta=(DisplayName = "IES Texture"))
216 TObjectPtr<class UTextureLightProfile> IESTexture;
217
219 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightProfiles, meta=(DisplayName = "Use IES Intensity", EditCondition="IESTexture!=nullptr"))
221
223 UPROPERTY(BlueprintReadOnly, interp, Category=LightProfiles, meta=(UIMin = "0.0", UIMax = "10.0", DisplayName = "IES Intensity Scale"))
224 float IESBrightnessScale;
225
230 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightFunction, meta=(DisplayName = "Fade Distance"))
231 float LightFunctionFadeDistance;
232
237 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightFunction, meta=(UIMin = "0.0", UIMax = "1.0"))
238 float DisabledBrightness;
239
245 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightShafts, meta=(DisplayName = "Light Shaft Bloom"))
246 uint32 bEnableLightShaftBloom:1;
247
249 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightShafts, meta=(UIMin = "0", UIMax = "10"))
250 float BloomScale;
251
253 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightShafts, meta=(UIMin = "0", UIMax = "4"))
254 float BloomThreshold;
255
257 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightShafts, meta=(UIMin = "0", UIMax = "100", SliderExponent = 20.0))
258 float BloomMaxBrightness;
259
261 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightShafts)
262 FColor BloomTint;
263
270 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=DistanceFieldShadows, meta=(DisplayName = "Distance Field Shadows"))
271 bool bUseRayTracedDistanceFieldShadows;
272
277 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=DistanceFieldShadows, meta=(UIMin = "0", UIMax = ".1"), AdvancedDisplay)
278 float RayStartOffsetDepthScale;
279
280public:
282 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
283 ENGINE_API void SetIntensity(float NewIntensity);
284
285 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
287
288 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
290
292 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
293 ENGINE_API void SetLightColor(FLinearColor NewLightColor, bool bSRGB = true);
294
296 UFUNCTION(Category="Rendering|Components|Light")
298
299 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|Light")
300 ENGINE_API void SetTemperature(float NewTemperature);
301
302 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|Light")
303 ENGINE_API void SetUseTemperature(bool bNewValue);
304
305 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
306 ENGINE_API void SetLightFunctionMaterial(UMaterialInterface* NewLightFunctionMaterial);
307
308 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
310
311 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
313
314 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
316
317 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
319
320 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|Light")
322
323 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
325
326 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
327 ENGINE_API void SetBloomScale(float NewValue);
328
329 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
330 ENGINE_API void SetBloomThreshold(float NewValue);
331
332 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
333 ENGINE_API void SetBloomMaxBrightness(float NewValue);
334
335 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
336 ENGINE_API void SetBloomTint(FColor NewValue);
337
338 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light", meta=(DisplayName = "Set IES Texture"))
340
341 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light", meta=(DisplayName = "Set Use IES Intensity"))
343
344 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light", meta=(DisplayName = "Set IES Intensity Scale"))
345 ENGINE_API void SetIESBrightnessScale(float NewValue);
346
347 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
348 ENGINE_API void SetShadowBias(float NewValue);
349
350 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|Light")
351 ENGINE_API void SetShadowSlopeBias(float NewValue);
352
353 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|Light")
354 ENGINE_API void SetSpecularScale(float NewValue);
355
356 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|Light")
357 ENGINE_API void SetDiffuseScale(float NewValue);
358
359 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|Light")
361
362 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|Light")
363 ENGINE_API void SetLightingChannels(bool bChannel0, bool bChannel1, bool bChannel2);
364
365 UFUNCTION(BlueprintCallable, Category="Rendering|Components|Light")
367
368 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|Light")
369 ENGINE_API void SetMaxDrawDistance(float NewValue);
370
371 UFUNCTION(BlueprintCallable, Category = "Rendering|Components|Light")
372 ENGINE_API void SetMaxDistanceFadeRange(float NewValue);
373
374public:
376 FLightSceneProxy* SceneProxy;
377
382
383 FStaticShadowDepthMap StaticShadowDepthMap;
384
386 FRenderCommandFence DestroyFence;
387
390
397 ENGINE_API bool AffectsPrimitive(const UPrimitiveComponent* Primitive) const;
398
404 ENGINE_API virtual bool AffectsBounds(const FBoxSphereBounds& InBounds) const;
405
410
411 virtual FSphere GetBoundingSphere() const
412 {
413 // Directional lights will have a radius of WORLD_MAX
415 }
416
417#if WITH_EDITOR
418 virtual FBox GetStreamingBounds() const override
419 {
420 return GetBoundingBox();
421 }
422#endif // WITH_EDITOR
423
427 virtual FVector4 GetLightPosition() const PURE_VIRTUAL(ULightComponent::GetPosition,return FVector4(););
428
432 virtual ELightComponentType GetLightType() const PURE_VIRTUAL(ULightComponent::GetLightType,return LightType_MAX;);
433
435
437
439
445 ENGINE_API bool IsShadowCast(UPrimitiveComponent* Primitive) const;
446
447 /* Whether to consider light as a sunlight for atmospheric scattering. */
448 virtual bool IsUsedAsAtmosphereSunLight() const
449 {
450 return false;
451 }
452 virtual uint8 GetAtmosphereSunLightIndex() const
453 {
454 return 0;
455 }
456 virtual FLinearColor GetAtmosphereSunDiskColorScale() const
457 {
458 return FLinearColor::White;
459 }
460
462 ENGINE_API virtual float ComputeLightBrightness() const;
463#if WITH_EDITOR
465 ENGINE_API virtual void SetLightBrightness(float InBrightness);
466#endif
467
468 //~ Begin UObject Interface.
469 ENGINE_API virtual void Serialize(FArchive& Ar) override;
470 ENGINE_API virtual void PostLoad() override;
471#if WITH_EDITOR
472 ENGINE_API virtual void PreSave(FObjectPreSaveContext ObjectSaveContext) override;
473 ENGINE_API virtual bool CanEditChange(const FProperty* InProperty) const override;
474 ENGINE_API virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
475 ENGINE_API virtual void UpdateLightSpriteTexture() override;
476 ENGINE_API virtual void CheckForErrors() override;
477#endif // WITH_EDITOR
478 ENGINE_API virtual void BeginDestroy() override;
479 ENGINE_API virtual bool IsReadyForFinishDestroy() override;
480 //~ End UObject Interface.
481
482 ENGINE_API virtual TStructOnScope<FActorComponentInstanceData> GetComponentInstanceData() const override;
483 ENGINE_API void ApplyComponentInstanceData(struct FPrecomputedLightInstanceData* ComponentInstanceData);
484 ENGINE_API virtual void PropagateLightingScenarioChange() override;
485 ENGINE_API virtual bool IsPrecomputedLightingValid() const override;
486
488 ENGINE_API virtual int32 GetNumMaterials() const;
489
491 ENGINE_API virtual UMaterialInterface* GetMaterial(int32 ElementIndex) const;
492
494 ENGINE_API virtual void SetMaterial(int32 ElementIndex, UMaterialInterface* InMaterial);
495
498
499 virtual class FLightSceneProxy* CreateSceneProxy() const
500 {
501 return NULL;
502 }
503
504protected:
505 //~ Begin UActorComponent Interface
506 ENGINE_API virtual void OnRegister() override;
507 ENGINE_API virtual void CreateRenderState_Concurrent(FRegisterComponentContext* Context) override;
508 ENGINE_API virtual void SendRenderTransform_Concurrent() override;
509 ENGINE_API virtual void DestroyRenderState_Concurrent() override;
510 //~ Begin UActorComponent Interface
511
512 //~ Begin USceneComponent Interface
513#if WITH_EDITOR
514 ENGINE_API virtual bool GetMaterialPropertyPath(int32 ElementIndex, UObject*& OutOwner, FString& OutPropertyPath, FProperty*& OutProperty) override;
515#endif // WITH_EDITOR
516 //~ End USceneComponent Interface
517
518 void UpdateProxy(FUpdateLightProxyCallback&& Func);
519
520private:
521
522 bool CanTraceDistanceFieldShadows() const;
523
524public:
525 ENGINE_API virtual void InvalidateLightingCacheDetailed(bool bInvalidateBuildEnqueuedLighting, bool bTranslationOnly) override;
526
528 ENGINE_API FVector GetDirection() const;
529
532
533 ENGINE_API const FLightComponentMapBuildData* GetLightComponentMapBuildData() const;
534
536
538
541
542#if WITH_EDITOR
548#endif
549
551
554};
555
556
558USTRUCT()
560{
562
565 : FSceneComponentInstanceData(SourceComponent)
566 , Transform(SourceComponent->GetComponentTransform())
567 , OriginalLightGuid(SourceComponent->OriginalLightGuid)
568 , LightGuid(SourceComponent->LightGuid)
570 {}
572
573 virtual bool ContainsData() const override
574 {
575 return true;
576 }
577
579 {
580 Super::ApplyToComponent(Component, CacheApplyPhase);
581 CastChecked<ULightComponent>(Component)->ApplyComponentInstanceData(this);
582 }
583
584 UPROPERTY()
586
587 UPROPERTY()
588 FGuid OriginalLightGuid;
589
590 UPROPERTY()
592
593 UPROPERTY()
595};
596
597
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define NULL
Definition oodle2base.h:134
ECacheApplyPhase
Definition ComponentInstanceDataCache.h:18
#define PURE_VIRTUAL(func,...)
Definition CoreMiscDefines.h:103
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
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
#define WORLD_MAX
Definition EngineDefines.h:53
#define HALF_WORLD_MAX
Definition EngineDefines.h:56
return true
Definition ExternalRpcRegistry.cpp:601
#define FVector
Definition IOSSystemIncludes.h:8
UE::Math::TBox< double > FBox
Definition MathFwd.h:55
UE::Math::TSphere< double > FSphere
Definition MathFwd.h:54
#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 USTRUCT(...)
Definition ObjectMacros.h:746
ELightComponentType
Definition SceneTypes.h:96
@ LightType_MAX
Definition SceneTypes.h:101
ELightUnits
Definition Scene.h:75
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition MapBuildDataRegistry.h:151
Definition LightSceneProxy.h:43
int32 PreviewShadowMapChannel
Definition LightSceneProxy.h:387
FGuid LightGuid
Definition LightSceneProxy.h:378
Definition ObjectSaveContext.h:244
Definition UnrealType.h:174
Definition RHICommandList.h:455
Definition ActorComponent.h:47
Definition RenderCommandFence.h:15
Definition MapBuildDataRegistry.h:104
Definition LightComponent.h:32
virtual void InitRHI(FRHICommandListBase &RHICmdList)
Definition LightComponent.cpp:52
const FStaticShadowDepthMapData * Data
Definition LightComponent.h:39
FStaticShadowDepthMap()
Definition LightComponent.h:35
Definition RenderResource.h:354
Definition EnumAsByte.h:22
Definition AndroidPlatformMisc.h:14
Definition StructOnScope.h:142
Definition ActorComponent.h:152
Definition Level.h:423
Definition MaterialInterface.h:296
Definition Object.h:95
Definition TextureLightProfile.h:12
Definition World.h:918
Definition EngineTypes.h:517
Definition FieldSystemNoiseAlgo.cpp:6
Definition MegaLights.cpp:462
Definition Color.h:486
Definition Guid.h:109
Definition EngineTypes.h:562
Definition EngineTypes.h:2116
Definition Color.h:48
static CORE_API const FLinearColor White
Definition Color.h:456
Definition LightComponent.h:560
virtual void ApplyToComponent(UActorComponent *Component, const ECacheApplyPhase CacheApplyPhase) override
Definition LightComponent.h:578
virtual ~FPrecomputedLightInstanceData()=default
virtual bool ContainsData() const override
Definition LightComponent.h:573
Definition UnrealType.h:6865
Definition SceneComponent.h:1743
Definition EngineTypes.h:606
Definition ObjectPtr.h:488
Definition BoxSphereBounds.h:25
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79