Baked GI uses a path tracer to simulate indirect lighting ahead of time. The information is then stored in lightmaps, which are used at run-time to light up the scene. The result is realistic and high quality lighting. Performance-wise, it is fairly inexpensive at run-time (but takes a long time to bake).
Since lighting is baked ahead of time, this requires both the meshes and the light sources to be static. Therefore baked GI will not work for scenes relying heavily on dynamic lighting, or scenes featuring procedural geometry and/or dynamic level design.
Precomputed Realtime GI
Precomputed Realtime GI tackles one of these issues. It is able to simulate indirect lighting for dynamic light sources, by precomputing how light can bounce throughout the scene.
To test it out I loaded up the Crytek Sponza, and added a dynamic directional light.
Here are the settings that I used:
Note that I have disabled ambient lighting completely. There is only 1 directional light source, and there are no reflection probes. All visible indirect lighting is a result of the precomputed realtime GI. There are some minor lighting artifacts, but overall I am rather pleased with both the quality and the performance. I’m probably going to make extensive use of this feature in future projects that use dynamic lighting.
The quality of the indirect light is directly related to the “Realtime Resolution” parameter, and so is the time required for baking. In a production environment you probably want to set the realtime resolution higher than I have. During development you can lower the resolution to improve bake times.
There are a few caveats with precomputed realtime GI though:
- Realtime indirect bounce light shadowing is only supported for directional lights. You will get a warning in Unity if you try to do this with another type of light source. In the following example you can see that indirect bounce light from the point light spheres bleeds through the curtains.
- If you make changes to the lighting within your scene at runtime, you may need to update some of your reflection probes to reflect these changes (which can be very expensive). This problem is not directly related to realtime GI, but rather to dynamic lighting in general. Unity offers some ways to deal with this through scripting, and I’ll probably make another blog post about using reflection probes in dynamic environments.
You can use both Baked GI and Precomputed Realtime GI simultaneously. Static geometry will use baked GI for static lights and realtime GI for dynamic lights. In most situations you’ll probably achieve the best result by using both.