程序媛大妞程序媛大妞12-03 05:58

Unity Lighting - The Precompute Process 预计算过程(二)


The Precompute Process



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

在Unity中,预先计算的照明在后台计算 - 既可以作为自动处理,也可以手动启动。无论哪种情况,都可以在编辑器中继续工作,而这些过程在幕后运行。

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.


Precompute StagesProgress 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 108 jobs remaining before that task is complete and the precompute moves on to task 6. The various stages are listed below:



Precomputed Realtime GI  Baked GI
01 - Create Geometry     01 - Create Geometry
02 - Layout Systems     02 - Atlassing
03 - Create Systems     03 - Create Baked Systems
04 - Create Atlas     04 - Baked Resources
05 - Clustering     05 - Bake AO
06 - Visibility     06 - Export Baked Texture
07 - Light Transport     07 - Bake Visibility
08 - Tetrahedralize Probes     08 - Bake Direct  
09 - Create ProbeSet     09 - Ambient and Emissive
      10 - Create Bake Systems
Probes     11 - Bake Runtime
      12 - Upsampling Visibility
01 - Ambient Probes     13 - Bake Indirect
02 - Baked/Realtime Ref. Probes     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 we need at least one GameObject marked as ‘static’ in our scene. This can either be done individually, or by shift-selecting multiple GameObjects from the hierarchy panel.


From the Inspector panel, the Static checkbox can be selected (Inspector>Static). This will set all of the GameObject’s ‘static options’, or ‘flags’, including navigation and batching, to be static, which may not be desirable. For Precomputed Realtime GI, only 'Lightmap Static' needs to be checked.

在Inspector面板中,可以选择静态复选框(Inspector> Static)。这会将GameObject的所有“静态选项”或“标志”(包括导航和批处理)设置为静态,这可能并不理想。对于预先计算好的实时GI,只需要检查“Lightmap Static”。

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 Inspector panel. Additionally, objects can also be set to Static in the Object area of the lighting window.


If your scene is set to Auto (Lighting>Scene>Auto), Unity’s lighting precompute will now begin automatically. Otherwise it will need to be started manually as described below.


Auto/Manual Precompute


If ‘Auto’ is checked from the bottom of Unity’s Lighting panel (Lighting>Scene>Auto), then this precompute will begin automatically as a background process whenever changes are made to static geometry within your scene.


However, if Auto is not selected, you will need to manually start a precompute by clicking the ‘Build’ button next to it. This will begin the precompute in much the same way, while giving you control over when this process starts.


Manually initiating a precompute will cause all aspects of your scene lighting to be evaluated and (re)computed. If you wish to selectively recalculate Reflection probes by themselves, this can be done via the drop-down menu next to the Build button (Lighting>Scene>Build).

手动启动预计算将导致评估和(重新)计算场景照明的各个方面。如果您希望有选择地单独重新计算反射探头,可以通过Build按钮旁边的下拉菜单(Lighting> Scene> Build)完成此操作。

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 Cache>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.

该缓存存储在Unity项目之外,可以使用(首选项> GI缓存>清除缓存)清除。清除它意味着预计算的所有阶段都需要从头开始重新计算,因此这可能非常耗时。但是,在某些情况下,您可能需要减少磁盘使用量,这可能会有所帮助。

<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">