GPU Lightmass Global Illumination

Learn about our GPU-based system for generating precomputed lighting data.

Windows
MacOS
Linux

GPU Lightmass (GPULM) is a light-baking solution that precomputes complex light interactions from lights which have their mobility set to Stationary or Static, and stores that data in generated lightmap textures that are applied to scene geometry. This system of baking lighting into textures is similar to the CPU-based Lightmass Global Illumination system. However, using the GPU to generate and build lighting data means that we can leverage the latest ray tracing capabilities with DirectX 12 (DX12) and Microsoft's DXR framework.

GPULM significantly reduces the time it takes to calculate, build, and generate lighting data for complex scenes, achieving speeds comparable to those of distributed builds using Swarm with the CPU-based Lightmass. Additionally, GPULM offers new workflows with interactivity that enables you to edit the scene, then recalculate and rebuild lighting on-the-fly. This workflow is not possible with the CPU-based Lightmass system.

Enabling GPU Lightmass

To enable GPU Lightmass in your projects:

  1. Open the Plugins tab from the Editor > Plugins menu. Under the Built-in > Editor category, locate and enable GPU Lightmass.

    GPU Lightmass plugin in the Plugins tab

  2. Open the Project Settings window from the Editor > Project Settings menu:

    1. Under the Engine > Rendering category, enable the following:

      1. Ray Tracing > Ray Tracing

      2. Virtual Textures > Enable Virtual Texture Support

      3. Virtual Textures > Enable Virtual Texture Lightmaps

    2. Under the Platforms > Windows category, set the following:

      1. Targeted RHIs > Default RHI: DirectX 12

  3. Restart the editor for these changes to take effect.

Additional Requirements for Setting Up GPU Lightmass

The following are additional suggestions to best work with GPU Lightmass in your projects.

Disabling Real-Time Ray Tracing Features

Ray Tracing features require a Windows 10 development environment with DirectX 12 and a Ray Tracing-capable NVIDIA GPU. For additional information, see our Ray Tracing features documentation for a full list of requirements.

GPU Lightmass leverages Microsoft's DXR API, which requires DirectX 12 and ray tracing to be enabled to use. This means that core ray tracing features for real-time soft shadowing, ambient occlusion, global illumination, and reflections are all enabled by default. This can interfere with seeing results from a GPU Lightmass bake.

You can disable all real-time ray tracing features in the editor using the console command r.RayTracing.ForceAllRayTracingEffects 0.

To set this in your project so that it automatically disables ray tracing features, open the DefaultEngine.ini configuration file located in your project's Config folder. Under the [/Script/Engine.RendererSettings] add the a line so it matches the following code:

[/Script/Engine.RendererSettings]
r.RayTracing.ForceAllRayTracingEffects=0

Configuring GPU Memory

GPULM requires that there be enough GPU memory available to account for its overhead. With that in mind, the following considerations affect the success of using GPULM to bake complex scenes:

  • There must be enough GPU memory to store the entire scene in memory at the lowest level of detail (LOD) mesh, that is, the highest quality LOD mesh.

    GPULM does not currently take LODs into consideration while baking. See the Limitations of GPU Lightmass section of this page for more details.

  • The Virtual Texture system can require significant memory use during light builds. This largely depends on the complexity of your scene and its size.

  • There must be enough CPU memory to store all generated lightmaps in RAM. The GPU can swap out lightmaps to the CPU's RAM, but lightmaps are not saved to disk until the entire light bake is completed.

  • DX12 generally uses more GPU memory than DX11. If you have a scene that was pushing the limits of your GPU memory in DX11, you may find it difficult to use in DX12 with additional overhead from ray tracing and virtual texture requirements without some sacrifices.

  • GPULM has its own memory usage requirements for optional settings, like Irradiance Cache.

The CPU-based Lightmass system requires a significant amount of memory for large scenes, which could be problematic for light baking. Often using a distributed build with Swarm could mitigate these types of issues. With GPULM, currently the only solution when running out of memory is to optimize the scene by reducing geometric or texture detail, or to upgrade to a GPU with more memory.

Using Virtual Texture Lightmaps for In-Editor Previewing

Enabling the Virtual Texture system with Virtual Texture Lightmaps allows for lightmaps to be generated and stored as virtual textures. This has the added benefit of allowing for light builds to update in the level viewport in real time. It also enables editing as the scene is being built instead of having to cancel or wait for the build to complete.

GPULM does not require the Virtual Texturing system to be enabled to simply build lighting but does require it for the interactive and real-time editing functionality. If you do not intend to use virtual texturing in your project, or require interactive preview, you can forego enabling these and save some overhead while working in the editor.

Using GPU Lightmass

GPULM has its own panel which can accessed through the Level Editor's toolbar under the Build dropdown menu by selecting GPU Lightmass.

Toolbar Build dropdown showing GPU Lightmass option

The GPULM panel can be docked within the editor, similarly to other panels.

GPU Lightmass panel docked

Once you've configured your settings, press Build Lighting to start a bake.

GPU Lightmass panel build button

GPU Lightmass Baking Modes

GPULM includes two modes with which to bake lighting: Full Bake and Bake What You See (BWYS).

GPU Lightmass bake mode dropdown

  • Full Bake mode renders the full lightmap resolution for every object in the scene as lighting is being calculated and built. The results aren't visible until the build completes.

  • Bake What You See mode offers greater flexibility in that you only build lighting for what is visible within the viewport instead of the entire scene. It also enables interactivity during the light building process to recalculate lighting as changes are being made, when the viewport's real-time mode is enabled.

Both of these baking modes are view-dependent, meaning that they first prioritize objects within the view before moving onto other objects in the scene.

In Full Bake mode, GPULM uses the following flow:

  • Every object within the scene is considered, and objects within the current view are prioritized.

  • Lighting is baked in texture space at an object's full lightmap resolution, and completed lightmap tiles are sent to the Virtual Texture system to update the display.

  • Once all objects have been calculated and a lightmap rendered, encoding takes place and saves the data automatically.

Bake What You See mode offers a non-destructive way of interactively working within a scene with lighting results being calculated (and recalculated) in real-time. It encourages on-the-fly adjustments in areas of your scene where lighting is actively being worked on. Because of this interactivity, the BWYS workflow for light builds differs from that of Full Bake as follows:

  • The Runtime Virtual Texture system determines visible tiles at the mipmap level necessary to resolve on screen.

  • Lighting is baked in texture space at the resolved mipmap resolution of each tile within the camera view.

  • Once all on-screen tiles have completed, BWYS waits indefinitely for the scene or viewport camera to update.

  • Pressing the Save button starts encoding the final lightmaps. A completed lighting build is not produced for the scene if you choose to save the results; only parts of the scene which were visible on screen have their lighting data ready to be stored and saved.

  • Pressing Save does not end the light bake, it only saves any encoded lightmap data that has been generated up to this point. Instead, press Cancel to stop the process.

Interactive Baking

Interactive baking is readily available for both Full Bake and BWYS modes, prioritizing visible virtual texture tiles that have been mapped to the current camera view; moving the camera will re-prioritize tiles for the current view. While interactive baking is used for both light baking modes, it is most useful used in conjunction with BWYS mode.

Starting BWYS mode kicks off a lighting build that only completes when it is manually stopped. This mode only considers and builds lighting for objects within the camera view. Moving the camera around the scene, changing position or adding/removing objects from the scene, or changing properties of scene Actors cause lighting to be recalculated in real-time. Because this mode requires the lighting results to be manually saved, it is a non-destructive way to work if lighting has previously been built for the scene.

Using GPU Lightmass Speed Modes

One benefit of GPULM is that it leverages virtual texturing during light bakes. This enables lighting to be built and displayed in real-time in the editor viewport. It also works progressively if the scene is being edited at the same time and updates the scene lighting accordingly. The drawback to using in-editor previewing in real time is that there is additional overhead of re-rendering frames in the scenes to update the visible result. Disabling this overhead frees up the GPU to work more efficiently and quicker.

The Level Viewport Realtime toggle controls the two speeds at which GPULM operates: On uses the Slow mode with additional overhead of rendering frames in real-time, and Off renders lighting significantly faster without the real-time overhead.

Toggle Realtime mode off and on using the dropdown menu found in the top-left of the Level Viewport, or simply use the keyboard shortcut Ctrl + R to toggle it on and off.

level viewport real time toggle

In addition to the Realtime mode toggle for the viewport, GPULM also includes settings of its own to increase the Fast and Slow mode builds.

GPU Lightmass build speed settings

  • Slow Mode Speed is a multiplier that can improve the speed of a lighting build when Realtime mode is toggled On in the viewport. Using too high a value can cause the editor to become unresponsive in scenes with lots of geometry.

  • Full Speed is a multiplier that can improve speed of lighting builds when Realtime mode is toggled Off.

The Speed options are not a guarantee that your builds will instantly become faster and should be used with caution. The multipliers determine the size of the chunks of work sent to the GPU, and the effectiveness of this size is one of many factors that determines the final speed on the GPU. For example, increasing Full Speed can make a fast bake go slower in some projects. There is no hard and fast rule for settings that will work in every situation.

GPU Lightmass Settings

GPU Lightmass contains most of its settings within its own panel.

GPU Lightmess panel

Properties

Description

General

Show Progress Bars

If true, a green progress bar is drawn within each tile as it renders. A red bar indicates the First Bounce Ray Guiding is in progress. Bars may appear black in very bright scenes that have their exposure turned down.

Mode

Choose the baking mode that best fits your development needs:

  • Full Bake: This mode renders the full lightmap resolution for every object in the scene.

  • Bake What You See: This mode renders only the virtual texture tiles for objects in view, at the mip level determined by the Virtual Texture system. The camera can be moved to render more tiles. This mode only saves its results if you press the Save button.

Denoise

When enabled, denoising will take place on the CPU after rendering. When deciding when denoising of the lightmap bake should happen, choose between the following options:

  • None: Lightmaps will not have any denoising applied to them.

  • On Completion: The entire lightmap will have denoising applied when the bake is finished.

  • During Interactive Preview: Each tile is denoised as it finishes, which is useful for previewing parts of a scene but is less efficient.

Global Illumination

GI Samples

The total number of ray paths executed per texel across all bounces against surfaces. This should be set to the lowest value that gives artifact-free results with the denoiser.

Stationary Light Shadow Samples

The number of samples used for lights that have their mobility set to Stationary. The shadows are calculated and stored separately from global illumination.

Use Irradiance Caching

Enable this for interior scenes, to achieve more physically correct global illumination intensities (with some biasing). If not enabled, results may appear darker than expected. Disable for exterior scenes.

Use First Bounce Ray Guiding

When Use Irradiance Caching is enabled, this option searches the hemisphere over each first bounce sample to find the brightest directions to weigh the rest of the samples towards. It improves results for interior scenes with specific sources of light, such as a window. The quality of this pass is controlled with the Trial Samples setting.

Irradiance Caching

Quality

The number of samples per Irradiance Cache cell.

Size

The size of each Irradiance Cache cell. Smaller sizes will be slower but more accurate.

Corner Rejection

Provides better control over rejection of Irradiance Cache entries around corners, helping reduce light leaking and artifacts that can happen.

Debug: Visualize

When enabled, the Irradiance Cache cells are visible. It's useful for setting the Irradiance Cache cell size and its quality. The visualization may appear black in very bright scenes that have their exposure turned down.

First Bounce Ray Guiding

Trial Samples

The number of samples used for First Bounce Ray Guiding, which are thrown away before sampling for lighting.

System

Slow Mode Speed

Control the baking speed with this multiplier when the viewport has Realtime mode enabled.

Full Speed

Control the baking speed with this multiplier when the viewport has Realtime mode disabled.

Lightmap Tile Pool Size

The pool of visible tiles which GPU Lightmass manages for calculations. The pool size should be set based on the size of the viewport and how many tiles will be visible on screen at once. Increasing the pool size increases GPU memory usage.

GPU lightmass panel world setting

Under the World Settings panel, the only Lightmass setting that carries over from the CPU-based Lightmass system is the Volumetric Lightmap Detail Cell Size. It sets the size of a Volumetric Lightmap voxel at the highest density around geometry in the scene. Decreasing the size of the voxel increases the time it takes to build lighting and the amount of memory that gets used. In some cases, it can increase memory by up to a factor of eight.

Setting Up Lightmap UVs and their Resolutions

Baking lighting requires that each Static Mesh have its own Lightmap UV and that the UV charts (also called UV islands) are all contained within the 0-1 texture space and have no overlapping or wrapping pieces. This ensures that when lighting is calculated that no artefacts occur due to a bad lightmap UV.

You can learn more about setting up lightmap UVs and generating them within Unreal Engine by taking a look at these pages:

Setting up a good Lightmap UV is the first step to getting a quality light bake for your object's geometry. Next, it's important to make sure that the lightmap texture applied to your geometry has enough resolution to capture all the necessary light and shadow detail. This means changing the lightmap resolution per object, as needed. You can do this in one of two ways:

  • Set the Light Map Resolution of the object using the Static Mesh Editor.

    static mesh editor light map resolution setting

  • Select a Static Mesh Actor in the scene and, in the Details panel under the Lighting category, set a new lightmap resolution for this individual Actor using its Overridden Light Map Res property.

    Overriden light map res property in details panel

Controlling the Number of Light Bounces

The number of light bounces within any given scene is not controllable. Instead, GPULM uses a Russian Roulette algorithm, which takes into account various probabilities and weighting calculations to determine how many bounces any given ray being cast will take. This also means that light bounces unlikely to contribute to indirect lighting and illumination of the scene are more likely to be terminated.

The GI Samples property of GPULM controls the maximum number of path-traced segments for each texel (or pixel within a texture map), including spatial samples and bounce segments. Increasing the number of GI Samples increases the number of both the spatial samples and (potentially) the depth samples.

Choosing a Denoising Option

GPULM relies on denoising methods provided by Intel's Open Image Denoise library to remove noise and smooth the results of the final lightmap renders.

There are three options to choose from when considering how you want your light bakes to be denoised. Use the Denoising dropdown to make your selection:

GPU Lightmass denoise setting options dropdown

  • None: No denoising is applied to the lighting render. This can be useful to determine a number of GI Samples to use for a given scene. For example, if you noticed artefacts being introduced by the denoiser, increasing the samples and possibly other settings, such as Irradiance Cache and First Bounce Ray Guiding, provide the denoiser with higher quality input.

  • On Completion: Denoises the results of the light build on the CPU after rendering. The entirety of the scene's lightmaps are denoised when the light build is finished.

  • During Interactive Preview: Denoises each virtual texture tile as it completes. This can be useful for seeing final results more quickly but is less efficient because it requires transferring each tile off the GPU to denoise on the CPU, and then back to the GPU to display.

The comparison below shows a completed light build with and without denoising applied.

Denoising Disabled

Denoising Applied to Final Result

Limitations of GPU Lightmass

Below are some of the known limitations of the current implementation of GPULM. This is not an exhaustive list and is intended to give you a rough idea of the support of core features. Keep in mind that some features in this list may never be supported while many will be resolved in future releases of the engine.

Feature

Supported (Yes/No/Partially)

Description

Distributed Baking

N

There are currently no plans to support distributed builds by Swarm Agent for GPULM. The current strategy is to focus on support for multiple GPUs and rely on their power and memory capacity.

Translucent Shadows

N

At the moment, translucent shadowing is a general limitation of the ray tracing feature set. This will be addressed in a future release of the engine.

World Position Offset

N

Pixel Depth Offset

N

GPULM does not take into account PDO, which could lead to lighting discontinuities.

Stationary Sky Light

N

Support is planned in a future release of the engine.

Number of Scene Lights

There is a hard limit of 256 lights. This is a limitation of the ray tracing capabilities leveraged by GPULM. The "Many Lights" initiative for ray tracing features should remove this limitation.

Lighting Channels

N

Custom Settings and Properties of Lights

N

The following lights settings are not yet supported with GPULM:

  • Non-inverse Square Falloff

  • IES Profiles

  • Light Functions

  • Indirect Lighting Intensity

  • Source Texture (on Rect Lights)

  • Barn Door Angle and Length (on Rect Lights)

Some of these settings can be used partially with Stationary lights. The baked GI will not honor the feature, but the dynamic direct lighting from the light will.

Precomputed Ambient Occlusion

N

Lightmass Portals

N

This is partially handled by the First Bounce Ray Guiding property of GPULM.

Lightmass Importance Volume

Partially

These volumes are not used to make distinction between areas of the scene to control quality. Instead, they are used for determining placement of Volumetric Lightmaps.

Volumetric Lightmaps

Y

These are honored by GPULM. Their placement can be done by using Lightmass Importance Volumes around the level, but it is not required. Settings in World Settings > Lightmass for Volumetric Lightmap Detail Cell Size are used with GPULM. The Volumetric Lightmap is always rendered in full, even when using Bake What You See mode.

Level of Detail Meshes

Partially

There is limited support for LODs, only supporting those created using the engine's auto-generated LODs. This is because they all share the same lightmap UVs, which is a requirement of GPULM. This can only be enforced if the LODs have been generated in the engine.

Lightmass World Settings and Per-Object Settings

N

There are many settings to tweak the results of lightmass for the CPU-based workflow. Most of these settings are not used with GPULM and do not have equivalent features or settings.

Additional Notes

Reducing GPU Timeout Detection and Recovery Crashes

Complex scenes or occasions when the GPU is under heavy load can cause the GPU to timeout and crash, often causing software that's using it to close, such as Unreal Engine. You will often see a message similar to this:

GPU driver crash error message

It's possible to prevent these types of crashes by extending the GPU's timeout delay, giving it time to potentially recover without causing the engine to close.

For details on adjusting the timeout delay and recovery (TDR) within Windows 10, see the Movie Render Queue's step for setting up your system configuration in matters such as this.

Select Skin
Light
Dark
Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback