Introduction to global illumination
Compare the ways Unity calculates indirect lighting, and choose the approach that suits your project.
阅读时间4 分钟最后更新于 6 天前
Global illumination (GI) is a group of techniques that model both direct and indirect lighting to provide realistic lighting results.
Unity has the following GI systems:
- Baked GI
- Enlighten Realtime GI (deprecated)
- Surface Cache GI, in the Universal Render Pipeline (URP) only
The main difference between them is when Unity calculates the lighting. Baked GI calculates it before runtime, so it costs little while your application runs but can't respond to changes. Enlighten Realtime GI and Surface Cache GI calculate lighting while your application runs, so indirect light follows your changes at a per-frame cost.
With baked GI and Enlighten Realtime GI, you need to make sure you set up texture UVs correctly, and control Light Probe placement to avoid increasing baking time.
If you're experimenting with lighting, you can disable the GI systems so lighting updates more quickly. To compensate for the lack of indirect lighting, enable screen space ambient occlusion (SSAO).
For more information about support for GI across render pipelines, refer to Render pipeline feature comparison.
Baked GI
Baked GI uses a light baking backend to store lighting data in your build, in Light Probes, Reflection Probes, and textures called lightmaps. You can bake with the Unity Compute Light Baker, or with the Progressive Light Baker using either its Progressive GPU or Progressive CPU backend.
Baked GI usually produces better lighting quality than Enlighten Realtime GI.
For more information, refer to Baking lightmaps before runtime.
Enlighten Realtime GI
Enlighten Realtime GI stores some lighting data in your build, but Unity uses the data to create lightmaps at runtime. As a result, you can adjust lights and see the effects on indirect lighting in real time, in the Editor or at runtime.
Enlighten Realtime GI doesn't support GI from real-time shadows.
For more information, refer to Update lightmaps at runtime with Enlighten Realtime Global Illumination.
Surface Cache GI
Surface Cache GI calculates indirect diffuse lighting entirely at runtime. It needs no baking. Indirect light responds to lights and geometry that move, both in the Editor and at runtime.
Surface Cache GI is available in URP only and needs a device that supports compute shaders. It lights opaque surfaces only and isn't compatible with baked GI.
For more information, refer to Real-time global illumination with Surface Cache.
Compare the GI systems
The following table compares the three systems:
System | When Unity calculates lighting | Responds to runtime changes | What it lights |
|---|---|---|---|
| Baked GI | Before runtime, during a bake | No | Static geometry through lightmaps, and moving GameObjects through probes |
| Enlighten Realtime GI | Visibility before runtime, lighting at runtime | Yes, for lights | Static geometry through lightmaps updated at runtime |
| Surface Cache GI | Entirely at runtime | Yes, for lights and geometry | Opaque surfaces inside the Surface Cache volume |
Choose Surface Cache GI if you want scene changes to affect your indirect lighting at runtime, and you can afford the per-frame cost. Choose baked GI if your scene is static, or if indirect lighting doesn't need to follow the scene changes at runtime.
Use Enlighten Realtime GI and baked GI together
The Unity Editor and Player allow you to use both Enlighten Realtime GI and baked GI at the same time.
However, simultaneously enabling these features greatly increases baking time and memory usage at runtime, because they don't use the same data sets. You can expect visual differences between indirect light you have baked and indirect light provided by Enlighten Realtime GI, regardless of the lightmapper you use for baking. This is because Enlighten Realtime GI often operates at a significantly different resolution than Unity's baking backends, and relies on different techniques to simulate indirect lighting.
If you want to use both Enlighten Realtime GI and baked GI at the same time, limit your simultaneous use of both GI systems to high-end platforms or to projects that have tightly controlled scenes with predictable costs. Only expert users who have a very good understanding of all lighting settings can effectively use this approach. Consequently, picking one of the two GI systems is usually a safer strategy for most projects. Using both systems is rarely recommended.