UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SkyAtmosphereRendering.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 SkyAtmosphereRendering.h
5=============================================================================*/
6
7#pragma once
8
9#include "EngineDefines.h"
10#include "RenderGraph.h"
11#include "RenderResource.h"
14#include "SceneView.h"
16
17
18class FScene;
19class FViewInfo;
20class FLightSceneInfo;
25
29
31struct FEngineShowFlags;
32
33DECLARE_UNIFORM_BUFFER_STRUCT(FSceneUniformParameters, RENDERER_API)
34
35
36// Use as a global shader parameter struct and also the CPU structure representing the atmosphere it self.
37// This is static for a version of a component. When a component is changed/tweaked, it is recreated.
39 SHADER_PARAMETER(float, MultiScatteringFactor)
40 SHADER_PARAMETER(float, BottomRadiusKm)
41 SHADER_PARAMETER(float, TopRadiusKm)
42 SHADER_PARAMETER(float, RayleighDensityExpScale)
43 SHADER_PARAMETER(FLinearColor, RayleighScattering)
44 SHADER_PARAMETER(FLinearColor, MieScattering)
45 SHADER_PARAMETER(float, MieDensityExpScale)
46 SHADER_PARAMETER(FLinearColor, MieExtinction)
47 SHADER_PARAMETER(float, MiePhaseG)
48 SHADER_PARAMETER(FLinearColor, MieAbsorption)
49 SHADER_PARAMETER(float, AbsorptionDensity0LayerWidth)
50 SHADER_PARAMETER(float, AbsorptionDensity0ConstantTerm)
51 SHADER_PARAMETER(float, AbsorptionDensity0LinearTerm)
52 SHADER_PARAMETER(float, AbsorptionDensity1ConstantTerm)
53 SHADER_PARAMETER(float, AbsorptionDensity1LinearTerm)
54 SHADER_PARAMETER(FLinearColor, AbsorptionExtinction)
55 SHADER_PARAMETER(FLinearColor, GroundAlbedo)
57
58// These parameters are shared on the view global uniform buffer and are dynamically changed with cvars.
69
70// Structure with data necessary to specify a sky render.
72{
74 // Per scene parameters
75
78 bool bDepthReadDisabled;// Do not apply scene depth texture. As such, only far Z will be considered
79 bool bDisableBlending; // Do not do any blending. The sky will clear the target when rendering a sky reflection capture for instance.
85
92
94 // Per view parameters
95
96 FViewMatrices* ViewMatrices; // The actual view matrices we use to render the sky
100
102
104
110
113
116
119
122
126
129
131
132private:
133};
134
135
136
138{
139public:
140
142 explicit FSkyAtmosphereRenderSceneInfo(FSkyAtmosphereSceneProxy& SkyAtmosphereSceneProxy);
144
147 TRefCountPtr<IPooledRenderTarget>& GetMultiScatteredLuminanceLutTexture() { return MultiScatteredLuminanceLutTexture; }
148
154
155 FRDGTextureRef GetTransmittanceLutTexture(FRDGBuilder& GraphBuilder) const { return GraphBuilder.RegisterExternalTexture(TransmittanceLutTexture); }
156
157 const FAtmosphereUniformShaderParameters* GetAtmosphereShaderParameters() const { return &AtmosphereUniformShaderParameters; }
158 const FSkyAtmosphereSceneProxy& GetSkyAtmosphereSceneProxy() const { return SkyAtmosphereSceneProxy; }
159
161
162private:
163
164 FSkyAtmosphereSceneProxy& SkyAtmosphereSceneProxy;
165
166 FAtmosphereUniformShaderParameters AtmosphereUniformShaderParameters;
167
169
170 TUniformBufferRef<FSkyAtmosphereInternalCommonParameters> InternalCommonParametersUniformBuffer;
171
172 TRefCountPtr<IPooledRenderTarget> TransmittanceLutTexture;
173 TRefCountPtr<IPooledRenderTarget> MultiScatteredLuminanceLutTexture;
174 TRefCountPtr<FRDGPooledBuffer> DistantSkyLightLutBuffer;
175 FRHIShaderResourceView* DistantSkyLightLutBufferSRV = nullptr;
176 TRefCountPtr<FRDGPooledBuffer> MobileDistantSkyLightLutBuffer;
177 FRHIShaderResourceView* MobileDistantSkyLightLutBufferSRV = nullptr;
178};
179
182{
183public:
184 // Sky env map capture uses the view UB, which contains the LUTs computed above. We need to transition them to readable now.
186
187private:
188 struct FViewRDGResources
189 {
190 FRDGTextureRef SkyAtmosphereViewLutTexture = nullptr;
191 FRDGTextureRef SkyAtmosphereCameraAerialPerspectiveVolume = nullptr;
192 };
193
194 FSceneRenderer* SceneRenderer = nullptr;
196
197 FRDGBufferRef DistantSkyLightLutBuffer = nullptr;
198 FRDGBufferRef MobileDistantSkyLightLutBuffer = nullptr;
199 FRDGTextureRef RealTimeReflectionCaptureSkyAtmosphereViewLutTexture = nullptr;
200 FRDGTextureRef RealTimeReflectionCaptureCamera360APLutTexture = nullptr;
201
202 FRDGTextureRef TransmittanceLut = nullptr;
203
204 friend class FSceneRenderer;
205};
206
208{
209 // Renders just before the BasePass.
211
212 // Renders just before the PrePass but can overlap on async compute with it too.
214};
215
216// Returns the location in the frame where SkyAtmosphere is rendered.
218
219
220bool ShouldRenderSkyAtmosphere(const FScene* Scene, const FEngineShowFlags& EngineShowFlags);
221
224
226
227// Prepare the sun light data as a function of the atmosphere state.
229
230bool IsLightAtmospherePerPixelTransmittanceEnabled(const FScene* Scene, const FViewInfo& View, const FLightSceneInfo* const LightSceneInfo);
231
233
245 FRDGBuilder& GraphBuilder,
249 const FViewInfo& ViewInfo,
250 const bool bShouldSampleOpaqueShadow,
251 const EUniformBufferUsage UniformBufferUsage);
252
253
254bool ShouldRenderSkyAtmosphereDebugPasses(const FScene* Scene, const FEngineShowFlags& EngineShowFlags);
256
@ INDEX_NONE
Definition CoreMiscDefines.h:150
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EUniformBufferUsage
Definition RHIDefinitions.h:536
#define END_GLOBAL_SHADER_PARAMETER_STRUCT
Definition ShaderParameterMacros.h:1669
#define BEGIN_GLOBAL_SHADER_PARAMETER_STRUCT
Definition ShaderParameterMacros.h:1663
#define SHADER_PARAMETER(MemberType, MemberName)
Definition ShaderParameterMacros.h:1684
#define DECLARE_UNIFORM_BUFFER_STRUCT(StructTypeName, PrefixKeywords)
Definition ShaderParameterStructDeclaration.h:10
void PrepareSunLightProxy(const FSkyAtmosphereRenderSceneInfo &SkyAtmosphere, uint32 AtmosphereLightIndex, FLightSceneInfo &AtmosphereLight)
Definition SkyAtmosphereRendering.cpp:487
void InitSkyAtmosphereForScene(FRHICommandListImmediate &RHICmdList, FRDGBuilder &GraphBuilder, FScene *Scene)
Definition SkyAtmosphereRendering.cpp:1207
void SetupSkyAtmosphereViewSharedUniformShaderParameters(const class FViewInfo &View, const FSkyAtmosphereSceneProxy &SkyAtmosphereProxy, FSkyAtmosphereViewSharedUniformShaderParameters &OutParameters)
float GetValidAerialPerspectiveStartDepthInCm(const FViewInfo &View, const FSkyAtmosphereSceneProxy &SkyAtmosphereProxy)
Definition SkyAtmosphereRendering.cpp:322
void GetSkyAtmosphereLightsUniformBuffers(FRDGBuilder &GraphBuilder, TRDGUniformBufferRef< FVolumeShadowingShaderParametersGlobal0 > &OutLightShadowShaderParams0UniformBuffer, TRDGUniformBufferRef< FVolumeShadowingShaderParametersGlobal1 > &OutLightShadowShaderParams1UniformBuffer, const SkyAtmosphereLightShadowData &LightShadowData, const FViewInfo &ViewInfo, const bool bShouldSampleOpaqueShadow, const EUniformBufferUsage UniformBufferUsage)
Definition SkyAtmosphereRendering.cpp:375
bool ShouldSkySampleAtmosphereLightsOpaqueShadow(const FScene &Scene, const TArray< FVisibleLightInfo, SceneRenderingAllocator > &VisibleLightInfos, SkyAtmosphereLightShadowData &LightShadowData)
Definition SkyAtmosphereRendering.cpp:337
void InitSkyAtmosphereForView(FRHICommandListImmediate &RHICmdList, const FScene *Scene, FViewInfo &View)
Definition SkyAtmosphereRendering.cpp:1259
ESkyAtmospherePassLocation GetSkyAtmospherePassLocation()
Definition SkyAtmosphereRendering.cpp:312
bool ShouldRenderSkyAtmosphereDebugPasses(const FScene *Scene, const FEngineShowFlags &EngineShowFlags)
Definition SkyAtmosphereRendering.cpp:2204
ESkyAtmospherePassLocation
Definition SkyAtmosphereRendering.h:208
FScreenPassTexture AddSkyAtmosphereDebugPasses(FRDGBuilder &GraphBuilder, FScene *Scene, const FSceneViewFamily &ViewFamily, const FViewInfo &View, FScreenPassTexture &ScreenPassSceneColor)
Definition SkyAtmosphereRendering.cpp:2209
bool ShouldRenderSkyAtmosphere(const FScene *Scene, const FEngineShowFlags &EngineShowFlags)
Definition SkyAtmosphereRendering.cpp:409
bool IsLightAtmospherePerPixelTransmittanceEnabled(const FScene *Scene, const FViewInfo &View, const FLightSceneInfo *const LightSceneInfo)
Definition SkyAtmosphereRendering.cpp:499
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition LightSceneInfo.h:208
Definition ShadowRendering.h:279
Definition RenderGraphResources.h:1321
Definition RenderGraphBuilder.h:49
RENDERCORE_API FRDGTextureRef RegisterExternalTexture(const TRefCountPtr< IPooledRenderTarget > &ExternalPooledTexture, ERDGTextureFlags Flags=ERDGTextureFlags::None)
Definition RenderGraphBuilder.cpp:1070
Definition RenderGraphUtils.h:1272
Definition RenderGraphResources.h:571
Definition RHICommandList.h:4626
Definition RHIResources.h:3304
Definition SceneRendering.h:2080
Definition SceneView.h:2212
Definition ScenePrivate.h:2875
Definition SkyAtmosphereRendering.h:182
void CommitToSceneAndViewUniformBuffers(FRDGBuilder &GraphBuilder, FRDGExternalAccessQueue &ExternalAccessQueue) const
Definition SkyAtmosphereRendering.cpp:1806
Definition SkyAtmosphereRendering.h:138
FRDGTextureRef GetTransmittanceLutTexture(FRDGBuilder &GraphBuilder) const
Definition SkyAtmosphereRendering.h:155
const FSkyAtmosphereSceneProxy & GetSkyAtmosphereSceneProxy() const
Definition SkyAtmosphereRendering.h:158
~FSkyAtmosphereRenderSceneInfo()
Definition SkyAtmosphereRendering.cpp:537
TRefCountPtr< IPooledRenderTarget > & GetMultiScatteredLuminanceLutTexture()
Definition SkyAtmosphereRendering.h:147
const FAtmosphereUniformShaderParameters * GetAtmosphereShaderParameters() const
Definition SkyAtmosphereRendering.h:157
TUniformBufferRef< FSkyAtmosphereInternalCommonParameters > & GetInternalCommonParametersUniformBuffer()
Definition SkyAtmosphereRendering.h:160
TRefCountPtr< FRDGPooledBuffer > & GetMobileDistantSkyLightLutBuffer()
Definition SkyAtmosphereRendering.cpp:556
TRefCountPtr< FRDGPooledBuffer > & GetDistantSkyLightLutBuffer()
Definition SkyAtmosphereRendering.cpp:550
TRefCountPtr< IPooledRenderTarget > & GetTransmittanceLutTexture()
Definition SkyAtmosphereRendering.h:146
FRHIShaderResourceView * GetDistantSkyLightLutBufferSRV()
Definition SkyAtmosphereRendering.cpp:562
const TUniformBufferRef< FAtmosphereUniformShaderParameters > & GetAtmosphereUniformBuffer()
Definition SkyAtmosphereRendering.h:145
FRHIShaderResourceView * GetMobileDistantSkyLightLutBufferSRV()
Definition SkyAtmosphereRendering.cpp:571
void CreateDistantSkyLightLutBufferAndSRV(FRDGBuilder &GraphBuilder)
Definition SkyAtmosphereRendering.cpp:541
Definition SkyAtmosphereSceneProxy.h:16
Definition SceneRendering.h:1132
Definition SceneRendering.h:211
Definition Array.h:670
Definition RenderGraphResources.h:251
Definition RefCounting.h:454
Definition ShaderParameterMacros.h:136
Type
Definition RHIFeatureLevel.h:20
Definition ShowFlags.h:56
Definition Color.h:48
Definition ShaderParameterMacros.h:770
Definition ScreenPass.h:41
Definition SkyAtmosphereRendering.h:72
bool bDisableBlending
Definition SkyAtmosphereRendering.h:79
FRDGTextureRef MultiScatteredLuminanceLut
Definition SkyAtmosphereRendering.h:87
bool bFastAerialPerspective
Definition SkyAtmosphereRendering.h:81
FRDGTextureRef InputCloudLuminanceTransmittanceTexture
Definition SkyAtmosphereRendering.h:125
bool bShouldSampleCloudSkyAO
Definition SkyAtmosphereRendering.h:120
FRDGTextureRef VolumetricCloudSkyAO
Definition SkyAtmosphereRendering.h:121
FSkyAtmosphereRenderContext()
Definition SkyAtmosphereRendering.cpp:1851
FRDGTextureRef MSAADepthTexture
Definition SkyAtmosphereRendering.h:128
uint8 MSAASampleCount
Definition SkyAtmosphereRendering.h:127
bool bDepthReadDisabled
Definition SkyAtmosphereRendering.h:78
TRDGUniformBufferRef< FVolumeShadowingShaderParametersGlobal1 > LightShadowShaderParams1UniformBuffer
Definition SkyAtmosphereRendering.h:112
FRDGTextureRef SkyAtmosphereCameraAerialPerspectiveVolumeRayOnly
Definition SkyAtmosphereRendering.h:91
FRenderTargetBindingSlots RenderTargets
Definition SkyAtmosphereRendering.h:101
TRDGUniformBufferRef< FSceneUniformParameters > SceneUniformBuffer
Definition SkyAtmosphereRendering.h:98
FRDGTextureRef VolumetricCloudDepthTexture
Definition SkyAtmosphereRendering.h:124
bool bSecondAtmosphereLightEnabled
Definition SkyAtmosphereRendering.h:83
bool bShouldSampleCloudShadow
Definition SkyAtmosphereRendering.h:117
FRDGTextureRef VolumetricCloudShadowMap[2]
Definition SkyAtmosphereRendering.h:118
float NearClippingDistance
Definition SkyAtmosphereRendering.h:108
bool bSceneHasSkyMaterial
Definition SkyAtmosphereRendering.h:99
bool bUseDepthBoundTestIfPossible
Definition SkyAtmosphereRendering.h:76
FRDGTextureRef SkyAtmosphereCameraAerialPerspectiveVolume
Definition SkyAtmosphereRendering.h:89
ERHIFeatureLevel::Type FeatureLevel
Definition SkyAtmosphereRendering.h:109
FRDGTextureRef TransmittanceLut
Definition SkyAtmosphereRendering.h:86
FRDGTextureRef SkyAtmosphereViewLutTexture
Definition SkyAtmosphereRendering.h:88
bool bShouldSampleOpaqueShadow
Definition SkyAtmosphereRendering.h:84
int VirtualShadowMapId1
Definition SkyAtmosphereRendering.h:115
bool bFastAerialPerspectiveDepthTest
Definition SkyAtmosphereRendering.h:82
FRDGTextureRef SkyAtmosphereCameraAerialPerspectiveVolumeMieOnly
Definition SkyAtmosphereRendering.h:90
bool bRenderSkyPixel
Definition SkyAtmosphereRendering.h:106
bool bAPOnCloudMode
Definition SkyAtmosphereRendering.h:123
TUniformBufferRef< FViewUniformShaderParameters > ViewUniformBuffer
Definition SkyAtmosphereRendering.h:97
int VirtualShadowMapId0
Definition SkyAtmosphereRendering.h:114
bool bFastSky
Definition SkyAtmosphereRendering.h:80
TRDGUniformBufferRef< FVolumeShadowingShaderParametersGlobal0 > LightShadowShaderParams0UniformBuffer
Definition SkyAtmosphereRendering.h:111
FViewMatrices * ViewMatrices
Definition SkyAtmosphereRendering.h:96
FIntRect Viewport
Definition SkyAtmosphereRendering.h:103
bool bForceRayMarching
Definition SkyAtmosphereRendering.h:77
float AerialPerspectiveStartDepthInCm
Definition SkyAtmosphereRendering.h:107
bool bIsReflectionCapture
Definition SkyAtmosphereRendering.h:105
Definition SkyAtmosphereRendering.h:60
float CameraAerialPerspectiveVolumeDepthSliceLengthKmInv
Definition SkyAtmosphereRendering.h:66
float AerialPerspectiveStartDepthKm
Definition SkyAtmosphereRendering.h:62
float ApplyCameraAerialPerspectiveVolume
Definition SkyAtmosphereRendering.h:67
float CameraAerialPerspectiveVolumeDepthResolutionInv
Definition SkyAtmosphereRendering.h:64
float CameraAerialPerspectiveVolumeDepthSliceLengthKm
Definition SkyAtmosphereRendering.h:65
float CameraAerialPerspectiveVolumeDepthResolution
Definition SkyAtmosphereRendering.h:63
FVector4f CameraAerialPerspectiveVolumeSizeAndInvSize
Definition SkyAtmosphereRendering.h:61
Definition SceneView.h:317
Definition SkyAtmosphereRendering.h:235
const FLightSceneInfo * LightVolumetricShadowSceneinfo1
Definition SkyAtmosphereRendering.h:237
const FProjectedShadowInfo * ProjectedShadowInfo0
Definition SkyAtmosphereRendering.h:238
int VirtualShadowMapId0
Definition SkyAtmosphereRendering.h:240
const FLightSceneInfo * LightVolumetricShadowSceneinfo0
Definition SkyAtmosphereRendering.h:236
const FProjectedShadowInfo * ProjectedShadowInfo1
Definition SkyAtmosphereRendering.h:239
int VirtualShadowMapId1
Definition SkyAtmosphereRendering.h:241