Setting up Bounced Indirect Lighting in HDRP

Tutorial

·

intermediate

·

+0XP

·

15 mins

·

(55)

Unity Technologies

Setting up Bounced Indirect Lighting in HDRP

Bounced Indirect Lighting is also known as Global Illumination (GI). This system captures any light that bounces off at least two surfaces and then reaches the camera. GI enables effects that make the virtual world seem more realistic. A classic example of indirect lighting is the color bleed that occurs when sunlight hits a bright orange bin, causing orange light to be bounced onto the wall behind it.

Languages available:

1. Setting Up Bounced Indirect Lighting in HDRP

This tutorial has been verified using Unity 2019 LTS


Bounced Indirect Lighting is also known as Global Illumination (GI). This system captures any light that bounces off at least two surfaces and then reaches the camera. GI enables effects that make the virtual world seem more realistic. A classic example of indirect lighting is the color bleed that occurs when sunlight hits a bright orange bin, causing orange light to be bounced onto the wall behind it.


In the image below (Figure 01), you’ll see an example of indirect lighting in a Scene. In the left image, the Scene is illuminated by indirect lighting that’s allowed to bounce up to three times. The Directional Light hitting the wall bounces onto the train car, then to the railway below it. On the right, indirect lighting is not being calculated in the lightmap, causing all surfaces to receive only direct lighting.


Figure 01:  The same Scene with (left) and without (right) Global Illumination.

Figure 01: The same Scene with (left) and without (right) Global Illumination.


In this tutorial, we’ll set up a project to use Global Illumination.


2. Setting up the Back End

Global Illumination is on by default. To adjust how GI works:


1. Navigate to the Window drop-down menu.


2. Click Rendering > Lighting Settings. This will open the Lighting window (Figure 02).


Figure 02: Lighting window with all available settings

Figure 02: Lighting window with all available settings


The Lighting window includes all the GI settings you’ll need including which lighting mode the Mixed Lighting will use.


  • Mixed Lighting: This controls whether Baked and Mixed Lights will use baked Global Illumination. If enabled, the Mixed Lights are baked using the specified Lighting Mode. Baked Lights will be completely baked and will not be adjustable at runtime.

Unity allows both the Baked and Realtime GI systems to be active simultaneously, which gives you access to all of the lighting features. Enabling both systems will significantly increase baking time and memory usage at runtime because these systems do not rely on the same data sets. Having both enabled will strain your CPU and cause discrepancies between the indirect lighting provided by the Baked and Realtime GI systems, since they rely on different techniques to simulate indirect lighting. They also often operate at significantly different resolutions.


You should restrict the usage of both GI systems to high-end platforms or projects that have tightly controlled Scenes. Having both systems active adds further complexity to the project, as you have to manage two systems instead of one. For most projects, you should choose one system; it’s rare that a project will require you to use both.


3. CPU versus GPU

In addition to choosing the GI system you wish to use, you’ll also have to decide between using the CPU or GPU for your lightmapper.


  • Progressive CPU: This is a fast path-tracing-based system that provides baked lightmaps and Light Probes with progressive updates in the Editor. This mode requires non-overlapping UVs with a small area and angle errors and sufficient padding between the charts.

  • Progressive GPU: This mode provides you with an interactive workflow when you’re setting up and tweaking the lighting in your Scene. Because this lightmapper uses your computer’s GPU to generate baked lightmaps and Light Probes, it’s a faster alternative to the CPU. The sampling algorithm used by the GPU produces slightly different noise patterns. To use this mode, you must have a Windows operating system, a GPU with OpenCL 1.2 support, at least 2GB of dedicated GPU memory, and a CPU that supports SSE4.1 instructions.

Despite being a faster alternative, this mode has limitations. The Progressive GPU does not support Baked LODs, A-Trous filtering (it only uses Gaussian), or custom bake API. With sub-meshes, the lightmapper uses material properties on the first sub-mesh only.


The CPU has more support for all lightmapping features but takes a much longer time than the GPU lightmapper. If the GPU lightmapper’s limitations aren’t detrimental to your project and you have the hardware to support it, you can take advantage of its faster bake times. The more powerful your GPU, the faster the baking times.


4. Setting Lighting Mode

If you enable the Mixed Lighting in your Light Settings, there are three modes to choose from (Figure 04).


Figure 04: Lighting modes for Mixed Lighting

Figure 04: Lighting modes for Mixed Lighting


  • Baked Indirect: This mode has real-time lighting and shadowing with baked indirect lighting. It allows real-time direct lighting and shadowing for static and dynamic objects. This mode does incur high costs for real-time Shadow Maps for static and dynamic objects. Another drawback is that there are no shadows drawn beyond the Shadow Distance for both static and dynamic objects. A typical use for this lighting mode are Scenes with view distances under the Shadow Distance with mainly fixed lights and many dynamic objects requiring real-time shadows.

  • Subtractive: This lighting mode is almost always baked, with directional light shadowing for dynamic objects. It features cheap baked light and shadows for static objects, and real-time shadows for dynamic objects with Light Probes providing ultra-low-resolution shadowing from static objects onto dynamic ones. With this mode, there is no specular lighting for static objects and it requires high texel density to get decent baked light and shadows for static objects. The typical use for this lighting mode is for simple outdoor Scenes with a fixed sun, few dynamic objects, lower-end hardware, and lower visual fidelity.

  • Shadowmask: This lighting mode features real-time lighting and baked shadows for static objects. This mode is relatively cheap in performance and allows for real-time shadows for dynamic objects. Light Probes can provide ultra-low-resolution shadowing from static objects onto dynamic ones. This mode comes with some drawbacks: baked shadows allow a maximum of only four lights per object and no shadows will be drawn beyond the Shadow Distance for dynamic objects. Typical uses for this lighting mode are Scenes with fixed lights and few dynamic objects, such as large, mainly static, outdoor Scenes with a fixed time of day.

Furthermore, the lighting mode of each Light, as set in the Inspector window, defines how the light interacts with your Global Illumination. These lighting modes are only relevant if the Baked Global Illumination system is enabled.


There are three modes available in the Light Inspector (Figure 05).


Figure 05: Available light modes

Figure 05: Available light modes


  • Realtime: The direct lighting and shadows from these lights are real-time and therefore not baked into lightmaps. Depending on a Scene’s complexity, this mode can come with a high performance cost. If you enable Realtime Global Illumination, you’ll notice a performance loss when the engine updates the indirect lighting at runtime.

  • Mixed: This lighting mode is a hybrid that offers a mix of baked and real-time features. Baked indirect lighting and real-time direct lighting are two examples of what it allows. The performance cost depends on the chosen global mixed lighting mode.

  • Baked: The direct and indirect lighting from these lights are baked into lightmaps. This can be a time-consuming process when building the lighting, but it has no runtime costs. Applying the lightmaps to the Scene does incur a minor cost, but is often a favorable approach to optimizing the lighting in a Scene.

5. Conclusion

Now that you know how to set up your Global Illumination model and how to use the lights within it, you’ll be able to boost the fidelity of your Scenes.


Complete this tutorial