Version: 2019.2
Enlighten
LOD and Realtime GI

Using precomputed lighting

In Unity, precomputed lighting is calculated in the background either as an automatic process or when manually initiated. In either case, it is possible to continue working in the editor while these processes run behind the scenes.

When the precompute process is running, a blue progress bar will appear in the bottom right of the Editor. There are different stages which need to be completed depending on whether Baked GI or Precomputed Realtime GI is enabled. Information on the current process is shown on-top of the progress bar.

Progress bar showing the current state of Unity’s precompute.

In the example above, we can see that we are at task 5 of 11 which is, ‘Clustering’ and there are 6 jobs remaining before that task is complete and the precompute moves on to task 6. The various stages are listed below:

Precomputed Realtime GI

  1. Create Geometry
  2. Layout Systems
  3. Create Systems
  4. Create Atlas
  5. Clustering
  6. Visibility
  7. Light Transport
  8. Tetrahedralize Probes
  9. Create ProbeSet

Probes

  1. Ambient Probes
  2. Baked/Realtime Ref. Probes

Baked GI

  1. Create Geometry
  2. Atlassing
  3. Create Baked Systems
  4. Baked Resources
  5. Bake AO
  6. Export Baked Texture
  7. Bake Visibility
  8. Bake Direct
  9. Ambient and Emissive
  10. Create Bake Systems
  11. Bake Runtime
  12. Upsampling Visibility
  13. Bake Indirect
  14. Final Gather
  15. Bake ProbesSet
  16. Compositing

Starting a precompute

Only static geometry is considered by Unity’s precomputed lighting solutions. To begin the lighting precompute process, you need at least one GameObject marked as ‘static’ in our Scene. This can either be done individually, or by shift-selecting multiple GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
from the hierarchy panel.

To mark a GameObject a static, go to its Inspector and select the Static checkbox (Inspector > Static). This sets all of the GameObject’s ‘static options’, or ‘flags’ to be static, including navigation and batching, which may not be desirable. For Precomputed Realtime GI, you only need to check ‘Contribute Global Illumination’.

For more fine-grained control, individual static options can be set from the drop-down list accessible to the right of the Static checkbox in the InspectorA Unity window that displays information about the currently selected GameObject, Asset or Project Settings, alowing you to inspect and edit the values. More info
See in Glossary
panel. Additionally, objects can also be set to Static in the Object area of the lighting window.

If you set your Scene to Auto Generate (menu: Window > RenderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info
See in Glossary
> Lighting Settings > SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary
> Auto Generate), Unity’s lighting precompute begins automatically, and updates automatically when any static geometry in your Scene changes. If you do not enable Auto Generate, you must start the lighting precompute manually.

Auto/manual precompute

If you have checked Auto Generate in the bottom of Unity’s Lighting panel (menu: Window > Rendering > Lighting Settings > Scene > Auto Generate), this precompute begins automatically as a background process whenever the static geometry within your Scene changes.

However, if you have not enabled Auto Generate, you must manually start the lighting precompute process by clicking the ‘Build’ button next to it. This begins the precompute in much the same way, and gives you control over when this process starts.

Auto Generate can be useful when working on smaller or less complex Scenes, because it quickly produces accurate lighting results while you move or editing static GameObjects in your Scene. However, when working on large or complex Scenes, you might prefer to switch to the manual option, so that your computer is not running a high CPU usage and repeatedly re-starting the lighting precompute each time you modify your Scene.

When you manually initiate a precompute, all aspects of your Scene lighting are evaluated and computed. To recalculate and bake just the Reflection ProbesA rendering component that captures a spherical view of its surroundings in all directions, rather like a camera. The captured image is then stored as a Cubemap that can be used by objects with reflective materials. More info
See in Glossary
by themselves, click the drop-down menu attached to the Generate Lighting button (menu: Window > Lighting Settings > Scene > Generate Lighting) and select Bake Reflection Probes.

NOTE: When using Auto Generate mode, Unity stores your lighting data in a temporary cache with a limited size. This means that when you exceed the cache’s size, Unity deletes old lighting data. A problem might occur when building your project if some of your Scenes rely on auto-generated lighting data that has been deleted. In this case, your Scenes might not have the correct lighting in the built project. Therefore, before building your game, you should uncheck Auto Generate, and generate the lighting data manually for all your Scenes. Unity then saves your lighting data as Asset files in your project folder, which means you have the data saved as part of your project and included in your build.

Enabling Baked GI or Realtime GI

Unity enables both Baked GI and Realtime GI by default. Baked GI is all precomputed; Realtime GI carries out some precomputation when indirect lighting is used. With both enabled, you then use each individual Light in your Scene to control which GI system it should use (in the Light component, use the Mode setting to do this). See documentation on the Lighting window and Global Illumination to learn more.

The most flexible way to use the lighting system is to use Baked GI and Realtime GI together. However, this is also the most performance-heavy option. To make your game less resource-intensive, you can choose to disable Realtime GI or Baked GI. Note that doing this this reduces the flexibility and functionality of your lighting system.

To manually enable or disable Global Illumination, open the Lighting window (Window > Lighting Settings > Scene). Tick Realtime Global Illumination to enable Realtime GI, and tick Baked Global Illumination to enable Baked GI. Untick these checkboxes to disable the respective GI system. If any Lights are set to the mode you have disabled, they are are overridden and set to the active GI system.

Per-light settings

To set properties for each individual Light, select it in the Scene or Hierarchy window, then edit the settings on the Light component in the Inspector window.

The default Mode for each light is Dynamic. This means that the Light contributes direct lighting to your Scene, and Unity’s Realtime GI handles indirect lighting.

If you set the Light’s Mode to Static, then that Light only contributes lighting to Unity’s Baked GI system. Both direct and indirect lighting from those Lights are baked into light maps, and cannot be changed during gameplay.

If you set the Light’s Mode to Stationary, GameObjects marked as Static still include this light in their Baked GI light maps. However, unlike Lights marked as Static, Stationary Lights still contribute real-time lighting, based on the stationary bake mode in the Lighting window (menu: Window > Lighting Settings). This is useful if you are using light maps in a static environment, but you still want a good integration between dynamic and light map static geometry.

A Directional Light with the Mode set to Dynamic.
A Directional Light with the Mode set to Dynamic.

See documentation on Lighting Modes for more details.

GI cache

In either Baked GI or Precomputed Realtime GI, Unity caches (stores) data about your scene lighting in the ‘GI Cache’, and will try to reuse this data whenever possible to save time during precompute. The number and nature of the changes you have made to your scene will determine how much of this data can be reused, if at all.

This cache is stored outside of your Unity project and can be cleared using (Preference > GI CacheThe cached intermediate files used when Unity precomputes real-time GI, and when baking Static Lightmaps, Light Probes and Reflection Probes. Unity keeps this cache to speed up computation. More info
See in Glossary
> Clear Cache). Clearing this means that all stages of the precompute will need to be recalculated from the beginning and this can therefore be time consuming. However in some cases, where perhaps you need to reduce disk usage, this may be helpful.

LOD for baked GI

Level-of-detail is taken into consideration when Unity generates baked lightmapsA pre-rendered texture that contains the effects of light sources on static objects in the scene. Lightmaps are overlaid on top of scene geometry to create the effect of lighting. More info
See in Glossary
. Direct lighting is computed using the actual surfaces of all LODsThe Level Of Detail (LOD) technique is an optimization that reduces the number of triangles that Unity has to render for a GameObject when its distance from the Camera increases. Each LOD level has either a Mesh with a Mesh Renderer component (Mesh LOD level) or a Billboard Asset with a Billboard Renderer component (Billboard LOD level). Typically a single GameObject has three or four Mesh LOD levels and one optional Billboard LOD level to represent the same GameObject with decreasing detail in the geometry. More info
See in Glossary
. Lower LOD levels use light probesLight probes store information about how light passes through space in your scene. A collection of light probes arranged within a given space can improve lighting on moving objects and static LOD scenery within that space. More info
See in Glossary
to fetch indirect lighting. The resulting lighting is baked into lightmap.

This means that you should place light probes around your LODs to capture indirect lighting. The object will not use lightprobes at runtime if you use fully baked GI.


  • 2019–08–01 Page published

  • Light Modes added in 5.6

Enlighten
LOD and Realtime GI
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961