文档

Unity Engine

Download Unity

Unity Engine

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.
重要
The Progressive CPU Lightmapper is deprecated and will be removed in a future release.
Use the Unity Compute Light Baker or the Progressive GPU Lightmapper instead. Baked lighting might look different after you change the backend, so you might need to adjust your lighting setup.
For more information, refer to Choose a light baking backend and Unity Compute Light Baker.
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 Global Illumination (GI) is deprecated and will be removed in a future release.
Use Surface Cache GI instead, which is available in the Universal Render Pipeline (URP).
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.

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 GIBefore runtime, during a bakeNoStatic geometry through lightmaps, and moving GameObjects through probes
Enlighten Realtime GIVisibility before runtime, lighting at runtimeYes, for lightsStatic geometry through lightmaps updated at runtime
Surface Cache GIEntirely at runtimeYes, for lights and geometryOpaque 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.
注意
You can't combine Surface Cache GI with baked GI in this way. When Surface Cache GI is active, Unity stops applying indirect light from lightmaps and Adaptive Probe Volumes to opaque surfaces.

Additional resources