How sebh/unrealengineskyatmosphere works
Purpose and Entry Points
Windows/D3D11 research renderer accompanying the EGSR 2020 Unreal Sky Atmosphere technique. It compares the paper’s LUT-based ray-marched atmosphere against Bruneton 2017 precomputed scattering and a volumetric path tracer. Process startup and main loop begin in Application/WinMain.cpp, which drives Application/Game.cpp; Sky.sln builds the Application executable plus the DX11 platform layer.
Platform, Window, and GPU Device Boundary
DX11Base/Dx11Device.cpp and DX11Base/Dx11Device.h encapsulate Direct3D 11 device, context, swap chain, resource, and shader-facing setup. DX11Base/WindowHelper.cpp owns Win32 window lifecycle, while DX11Base/WindowInput.h exposes interaction state. This boundary isolates Windows/D3D11 infrastructure from atmosphere and scene rendering.
Application Orchestration and State
Application/Game.cpp is the frame-level coordinator: it manages camera/sun interaction, rendering mode selection, GPU passes, screenshots, and saved/loaded runtime state. Application/DataRecord.cpp supports persistence of application state. Application/SkyAtmosphereCommon.cpp / Application/SkyAtmosphereCommon.h define CPU-side atmospheric parameters and shared logic corresponding to GPU atmosphere inputs.
Atmosphere LUT Pipeline
The primary scalable technique precomputes and samples atmospheric lookup tables. Application/RenderWithLuts.cpp dispatches and uses these LUT-driven passes; shader stages are split by physical quantity:
• Resources/SkyAtmosphereTransmittanceLut.hlsl
• Resources/SkyAtmosphereDirectIrradianceLut.hlsl
• Resources/SkyAtmosphereSingleScatteringLut.hlsl
• Resources/SkyAtmosphereMultipleScattering.hlsl
• Resources/SkyAtmosphereScatteringDensity.hlsl
• Resources/SkyAtmosphereIndirectIrradiance.hlsl
Shared atmospheric equations, coordinate conventions, and constants reside in Resources/SkyAtmosphereCommon.hlsl and Resources/SkyAtmosphereBruneton.hlsl.
Sky Rendering Modes
Application/RenderSky.cpp selects sky rendering behavior and binds the appropriate shaders. The ray-marching implementation in Resources/RenderSkyRayMarching.hlsl builds the new method’s LUTs and evaluates the atmosphere. Resources/RenderSkyPathTracing.hlsl provides an alternate real-time volumetric path tracer for comparison; runtime mode toggling switches between ray marching and path tracing and disables the multiple-scattering approximation for path tracing. Resources/RenderSkyCommon.hlsl holds shared sky shading code.
Scene, Composition, and Diagnostics
Terrain establishes the visible ground/planet context through Application/RenderTerrain.cpp and Resources/Terrain.hlsl, using repository heightmap assets such as Resources/heightmap0.exr. Final fullscreen/post-processing work is in Resources/PostProcess.hlsl. GPU-side debug visualization is driven by Application/GpuDebugRenderer.cpp and Resources/GpuDebugPrimitives.hlsl.
Comparative and External Assets
The Bruneton reference implementation is represented by Resources/Bruneton17/definitions.glsl and Resources/Bruneton17/functions.glsl, with integration-facing atmospheric shader code in Resources/SkyAtmosphereBruneton.hlsl. External dependencies are Git submodules imgui (runtime UI) and tinyexr (EXR asset/image support). The project targets Windows, Visual Studio, a Windows SDK, and Direct3D 11; it has no indicated server, network, or cloud dependency.
Main entry points: Game.cpp Game frame coordinator · RenderWithLuts.cpp LUT renderer · RenderSky.cpp Sky mode renderer · RenderTerrain.cpp Terrain rendering
Components 23
Application
- WinMain
Application/WinMain.cpp - Game frame coordinator · Coordinates input, modes, GPU passes, screenshots, and runtime state.
Application/Game.cpp - State persistence
Application/DataRecord.cpp - Atmosphere parameters · Shared CPU-side parameters supplied to atmosphere shaders.
Application/SkyAtmosphereCommon.cpp
Windows / D3D11
- Win32 window
DX11Base/WindowHelper.cpp - Window input
DX11Base/WindowInput.h - D3D11 device layer · Owns device, context, swap chain, resources, and shader setup.
DX11Base/Dx11Device.cpp
Atmosphere LUT Pipeline
- LUT renderer
Application/RenderWithLuts.cpp - Transmittance LUT
Resources/SkyAtmosphereTransmittanceLut.hlsl - Direct irradiance LUT
Resources/SkyAtmosphereDirectIrradianceLut.hlsl - Single scattering LUT
Resources/SkyAtmosphereSingleScatteringLut.hlsl - Multiple scattering LUT
Resources/SkyAtmosphereMultipleScattering.hlsl - Scattering density
Resources/SkyAtmosphereScatteringDensity.hlsl - Indirect irradiance LUT
Resources/SkyAtmosphereIndirectIrradiance.hlsl
Scene & Rendering
- Sky mode renderer · Selects LUT ray marching or volumetric path tracing.
Application/RenderSky.cpp - LUT ray-marched sky
Resources/RenderSkyRayMarching.hlsl - Volumetric path-traced sky · Alternate mode without the multiple-scattering approximation.
Resources/RenderSkyPathTracing.hlsl - Terrain rendering · Renders ground context from heightmap assets.
Application/RenderTerrain.cpp - Post-processing
Resources/PostProcess.hlsl - GPU diagnostics
Application/GpuDebugRenderer.cpp
Comparison & Dependencies
- Bruneton 2017 reference · Comparative precomputed-scattering implementation.
Resources/Bruneton17/functions.glsl - imgui · Runtime UI dependency.
imgui - tinyexr · EXR image and asset support.
tinyexr
Connections 26
- WinMain → Game frame coordinator: starts
- Game frame coordinator → Win32 window: drives
- Win32 window → Window input: provides events
- Game frame coordinator → D3D11 device layer: submits frames
- Game frame coordinator → State persistence: saves / loads
- Game frame coordinator → Atmosphere parameters: updates
- Game frame coordinator → LUT renderer: runs LUT mode
- Game frame coordinator → Sky mode renderer: selects mode
- Game frame coordinator → Terrain rendering: renders scene
- Game frame coordinator → GPU diagnostics: renders diagnostics
- Game frame coordinator → imgui: uses UI
- LUT renderer → Transmittance LUT: generates
- LUT renderer → Direct irradiance LUT: generates
- LUT renderer → Single scattering LUT: generates
- LUT renderer → Scattering density: iterates
- Scattering density → Multiple scattering LUT: feeds
- Multiple scattering LUT → Indirect irradiance LUT: feeds
- Atmosphere parameters → LUT renderer: atmosphere inputs
- LUT renderer → LUT ray-marched sky: supplies LUTs
- Sky mode renderer → LUT ray-marched sky: LUT mode
- Sky mode renderer → Volumetric path-traced sky: path-tracing mode
- Sky mode renderer → Bruneton 2017 reference: reference mode
- Sky mode renderer → Post-processing: composites through
- Terrain rendering → Post-processing: scene color
- Post-processing → D3D11 device layer: presents
- tinyexr → Terrain rendering: supports EXR assets