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

当预计算过程在执行的时候,编辑器右下方会出现一个蓝色的进度条。取决于是否启用了 Baked GI 或者 预计算实时 GI,将会有不同的计算需要完成。当前进程的信息显示在进度条的顶部。

(Progress bar showing the current state of Unity’s precompute.)(进度条显示了当前 Unity 的预计算状态。)

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:

在上面的例子中,可以看到,正在执行到任务 5/11,也就是集群,在执行到任务 6 之前还有 108 个工作任务。 下面列出了不同阶段:

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 14 - Final Gather
Ref. Probes 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.

只有静态的几何体考虑使用 Unity 的预计算光照方案。为了开始进行光照的预计算过程,我们至少需要有一个 GameObject 在场景中标记为 “static”。这可以单独被完成,或者通过层次结构面板 Hierarchy 中选择多个 GameObjects 来实现。

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 检视面板中,有一个“Static” 复选框可以被选中(Inspector>Static)。这将设置所有的 GameObject 的“静态选项”,或者标志,包括导航和批处理,都设置了 “static” ,这可能是不可取的。 对于预计算的实时光照 GI,只需要把 “Lightmap” 勾选。

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.

如果你的场景设置成自动(Lighting>Scene>Auto),Unity 的光照预计算就会自动启动。否则,它会像下面描述的那样需要手动启动。

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

如果从 Unity 的灯光面板(Lighting>Scene>Auto)的底部勾选了“Auto”,那么这个预计算将自动作为一个后台过程自动开始,不管你的场景中的静态几何体发生了什么变化。

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.

但是,如果没有选择 Auto,则需要手动启动预计算,并单击旁边的 “Build” 按钮。这将以同样的方式开始预计算,同时可以让你控制这个进程何时开始。

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 GI 缓存

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.

在烘焙 GI 或预计算的实时 GI 中,Unity 会’缓存’(存储)关于你在“GI缓存”中的场景照明的数据,并将尝试在可能的情况下重用这些数据,以节省在预计算期间的时间。你对你的场景所做的更改的数量和性质将决定这些数据有多少可以被重用,如果有的话。

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 项目之外,并且可以使用(Preference>GI Cache>Clear Cache)清除。清除这意味着预计算的所有阶段都需要从一开始重新计算,因此需要花费大量时间。但是,在某些也许需要减少磁盘使用情的况下,这可能是有帮助的。