How Unreal Engine Renders a Frame
Unreal Engine · HDR Rendering Pipeline · WebGL1 · Cesium
Contents
The goal is to understand the major Unreal Engine rendering passes, use them as a reference for an HDR rendering pipeline, and reproduce the pipeline on the web.
Scene
Create a scene with the Cesium for Unreal plugin containing:
- A CesiumSkyLight containing:
- A Directional Light component
- A SkyLight component
- A SkyAtmosphere component
- CesiumTerrain
- Two character models that ship with Unreal Engine, one using the Clear Coat shading model and one using Default Lit
- A translucent sphere
- A set of spheres with different metallic and roughness values
- A cube using Default Lit
Here is the result in the Unreal Editor:

Overview
Capture a frame with the RenderDoc plugin:

- SkyAtmosphereLUTs: Computes the atmospheric lookup tables.
- CaptureConvolveSkyEnvMap: Captures the sky environment map for the SkyLight and fits its low-frequency diffuse lighting to spherical harmonics.
- BasePass: Writes the opaque objects' data to the GBuffer.
- ShadowDepths: Renders opaque depth into a shadow map atlas for each light that casts shadows.
- LightCompositionTasks_PreLighting: Computes screen-space ambient occlusion (SSAO) for the Lights pass.
- Lights: Computes direct lighting from the GBuffer, shadow map atlas, and SSAO. Pixels in shadow should be black at this stage.
- ReflectionIndirect: Adds indirect lighting, including screen-space reflections, planar reflections, and sky image-based lighting (IBL). Shadows can now contain nonzero values.
- SkyAtmosphere: Draws the atmosphere where there is no geometry and applies aerial perspective to opaque surfaces.
- Translucency: Renders translucent objects to a separate texture.
- PostProcessing: Performs temporal super resolution (TSR), auto exposure, bloom, and tone mapping.
SkyAtmosphereLUTs
First compute the atmospheric lookup tables used later to render the sky and aerial perspective.

The lookup tables look like this:






Their roles are:
- Transmittance, Multi-Scattering, and Sky View are used to render the atmosphere.
- Distant Sky Light is a 1-by-1 texture holding the average atmospheric color at 6 km, used to render volumetric clouds.
- Real Time Capture Sky View is used to generate the sky-light cubemap quickly.
- Camera Volume is a 3D texture used for aerial perspective on opaque objects. APIs without 3D texture support render it into a 2D texture.
A paper summarizes Unreal Engine's atmospheric rendering [1] . The corresponding engine source shows the implementation.
CaptureConvolveSkyEnvMap
This pass captures the sky, including the atmosphere and volumetric clouds, as an environment map for scene lighting. The sky changes relatively little between frames, so the engine spreads the rendering work over several frames using time slicing.
Time slicing is on by default and can be turned off with r.SkyLight.RealTimeReflectionCapture.TimeSlice 0. With time slicing enabled, a full update takes 12 frames and each frame performs one step. With time slicing disabled, all steps run in a single frame.
These are the graphics API calls with time slicing disabled:

The 12 steps are:
- Render the atmosphere to
CapturedSkyRenderTarget, corresponding to six Draw(3) calls. - Render any volumetric clouds to
CapturedSkyRenderTarget, corresponding to another six Draw(3) calls. - Generate all mipmaps of
CapturedSkyRenderTarget, corresponding to the MipGen calls. The default 128-by-128 cubemap has seven levels beyond level 0. - Convolve faces 0 and 1 of mip level 0 of
CapturedSkyRenderTargetand render into the corresponding faces and mip level ofConvolvedSkyRenderTarget. This is part of the first Convolve entry. - Repeat for faces 2 and 3 of mip level 0, also in the first Convolve entry.
- Repeat for faces 4 and 5 of mip level 0, also in the first Convolve entry.
- Convolve all faces of mip level 1, corresponding to the second Convolve entry.
- Convolve all faces of mip level 2, corresponding to the third Convolve entry.
- Convolve all faces of mip level 3, corresponding to the fourth Convolve entry.
- Convolve all faces of mip levels 4 and 5, corresponding to the fifth and sixth Convolve entries.
- Convolve all faces of mip levels 6 and above, corresponding to the seventh and eighth Convolve entries.
- Use the filtered
ConvolvedSkyRenderTargetto compute the spherical harmonic coefficients, stored as sevenfloat4values. This is ComputeSkyEnvMapDiffuseIrradianceCS.
Convolution here filters the cubemap. Generating spherical harmonic (SH) coefficients directly from a high-frequency cubemap can produce ringing in the reconstructed diffuse cubemap [2] .
The pass produces two outputs. The first is ConvolvedSkyRenderTarget for IBL specular reflections.

The second is a set of SH coefficients stored in seven float4 values for IBL diffuse lighting. See ReflectionEnvironmentRealTimeCapture.cpp.
BasePass
This pass writes the scene's opaque geometry to the GBuffer and depth buffer.

The rendering process looks like this:
The render targets contain:
- RT0 (SceneColor,
R16G16B16A16_FLOAT): RGB storesemission color * preExposure. - RT1 (SelectionOutlineColor,
R10G10B10A2_UNORM): RGB stores the world-space normal, and alpha stores GBuffer.PerObjectGBufferData. - RT2 (GBufferB,
R8G8B8A8_UNORM): RGB stores Metallic, Specular, and Roughness, respectively. Alpha storesGBuffer.ShadingModelID | GBuffer.SelectiveOutputMask. - RT3 (GBufferC,
R8G8B8A8_SRGB): RGB stores base color, and alpha storesGBuffer.IndirectIrradiance * GBuffer.GBufferAO. - RT4 (GBufferD,
R8G8B8A8_UNORM): StoresGBuffer.CustomData. - RT5 (GBufferE,
R8G8B8A8_UNORM): StoresGBuffer.PrecomputedShadowFactor. - RT6 (GBufferF): RGB stores
GBuffer.WorldTangent, and alpha storesGBuffer.Anisotropy. - Depth (D32S8): Stores depth and stencil values.
ShadowDepths
This pass renders the shadow maps.

For a directional light, three distance cascades are rendered into a shadow map atlas. Here is the approximate rendering sequence when a Directional Light acts as the sun:
LightCompositionTasks_PreLighting
This pass computes screen-space ambient occlusion from the normals.

- AmbientOcclusionSetup 618 × 319: Compute normals at half resolution in each dimension.
- AmbientOcclusionPS 618 × 319: Compute ambient occlusion at half resolution.

- AmbientOcclusionPS 1236 × 638: Upsample ambient occlusion to full resolution. The values here are all 1, possibly because the surfaces are too far away for SSAO.

Lights
This pass computes direct lighting.

It uses each light's parameters, the GBuffer, the SSAO result, and the shadow map atlas.

The shader computes per-pixel direct lighting according to the shading model. See DeferredLightPixelShaders.usf. For Default Lit, the basic formula is:
$$ (L \cdot \cos{(\theta)} \cdot \text{BRDF}) * \text{shadow} $$
Unlike glTF, Unreal Engine's Default Lit uses a Specular parameter in the BRDF in addition to metallic and roughness.
Multiplying by the shadow term makes the shadowed pixels black. Here is the result with direct lighting:

ReflectionIndirect
This pass first computes screen-space reflections (SSR), also called screen-space ray tracing. It then combines SSR, planar reflections, and the convolved sky-light cubemap for specular reflections, and uses the irradiance cubemap reconstructed from the SH coefficients for diffuse lighting.

SSR uses the previous frame's rendering result. Here is the resulting SSR texture:

Next, add SSR and image-based lighting from the sky environment map generated by CaptureConvolveSkyEnvMap to the direct lighting from the Lights pass:

Shadowed pixels can now receive indirect light. See ReflectionEnvironmentPixelShader.usf for the shader implementation.
SkyAtmosphere
This pass draws the atmosphere at pixels without opaque geometry, where the depth has its farthest value, such as 1.0. It applies aerial perspective to pixels covered by geometry, where depth is closer.

The pass uses the lookup tables produced by SkyAtmosphereLUTs. Here is the result:

Translucency
This pass renders translucent objects into a separate texture.

The result:

PostProcessing
The scene is now rendered in HDR. The remaining step is post-processing. See PostProcessing.cpp.

TemporalSuperResolution
This pass composites the translucency texture and applies Temporal Super Resolution (TSR) to produce the complete render.
Downsample
This pass downsamples the preceding result to $\frac{1}{2}$ of the width and height for post-processing.
SceneDownsample
The pass takes the $\frac{1}{2}$-scale render and produces versions with widths and heights scaled by $\frac{1}{4}$, $\frac{1}{8}$, $\frac{1}{16}$, $\frac{1}{32}$, and $\frac{1}{64}$.
BasicEyeAdaptation
Unreal Engine offers two auto-exposure modes, Histogram and Basic. Histogram requires a compute shader, so the WebGL implementation uses Basic.
Basic samples the texels of the last downsampled texture, whose width and height are each scaled by $\frac{1}{64}$. It computes average luminance and exposure from these samples and stores the information in four channels of a 1-by-1 texture.
Bloom
This pass produces the bloom texture using six levels of Gaussian filtering.
The resulting bloom texture:

CombineLUTS
This pass computes a 32-by-32-by-32 tone-mapping lookup table from the post-processing settings, including film tone mapping and custom color grading. The table looks like this:

Tonemap
Tone mapping is the final pass. It takes the 1-by-1 exposure texture from BasicEyeAdaptation, the TSR result, the bloom texture, and the lookup table from CombineLUTS. The output is the final rendered scene.

The editor then draws elements such as yellow outlines for selected models and the transform gizmo.
Reproducing the Pipeline on the Web
Here is a Cesium.js and WebGL 1 reproduction of the rendering pipeline:



The result is close to Unreal Engine's. Some features are still missing:
- TSR anti-aliasing
- SSR
- SSAO
- Shadows
- Volumetric clouds