Version: 2021.2
Lighting 窗口


A Lighting Settings Asset represents a saved instance of the LightingSettings class, which stores data for the Baked Global Illumination and the Enlighten Realtime Global Illumination systems. The Unity Editor uses this data when it precomputes lighting data for a Scene that uses one or both of these systems.

您可以为多个场景指定相同的光照设置资源或 LightingSettings 类的实例,这使得跨多个场景共享全局光照系统设置变得容易。


有两种方法可以在 Unity 编辑器中创建光照设置资源。


  1. 在项目视图中,单击添加 (+) 按钮,或者打开上下文菜单并导航至 Create
  2. 单击 Lighting Settings。Unity 会在项目视图中创建新的光照设置资源。

要从 Lighting 窗口创建并自动指定光照设置资源:

  1. 打开 Lighting 窗口(菜单:Window > Rendering > Lighting)。
  2. 打开 Scene 选项卡。
  3. 单击 New Lighting Asset。Unity 会在项目视图中创建一个新的光照设置资源,并立即将其指定给活动场景。

您还可以从脚本创建光照设置资源。为此,请创建一个 LightingSettings 类的实例并将其保存到磁盘,或将其指定给场景并保存该场景。有关更多信息和代码示例,请参阅 LightingSettings API 文档


要在 Unity 编辑器中为场景指定光照设置资源:

  1. 打开要为其指定光照设置资源的场景。
  2. 如果您打开了多个场景,请确保您要为其指定光照设置资源的场景是活动场景
  3. 打开 Lighting 窗口(菜单:Window > Rendering > Lighting)。
  4. 打开 Scene 选项卡。
  5. 将光照设置资源拖到 Lighting Settings 字段,或单击 Lighting Settings 字段右侧的图标,并从列表中选择光照设置资源。

您还可以从脚本将光照设置资源指定给活动场景。为此,请加载光照设置资源以获取 LightingSettings 类的实例,然后使用"Lightmapping.lightingSettingsAPI 将该LightingSettings` 实例指定给活动场景。有关更多信息和代码示例,请参阅 LightingSettings API 文档


您可以在 Unity 编辑器中的两个位置查看和编辑光照设置资源的属性:

在项目视图中,如果您选择一个光照设置资源,您可以在 Inspector 中查看和编辑其属性。 如果活动场景具有为其指定的光照设置资源,您可以在 Lighting 窗口的 Scene 选项卡中查看和编辑该光照设置资源的属性。

您还可以从脚本读取或写入光照设置资源的属性。为此,请加载光照设置资源以获取 LightingSettings 类的实例,并访问其属性。有关更多信息和代码示例,请参阅 LightingSettings API 文档

默认 LightingSettings 数据

当场景没有为其制定的光照设置资源时,Unity 会为该场景使用默认的 LightingSettings 对象。默认的 LightingSettings 对象是一个 LightingSettings 类的内部只读实例。

您不能对使用默认 LightingSettings 的场景的 LightingSettings 数据进行任何更改,但 Unity 可以使用其设置执行烘焙。

要更改场景的 LightingSettings 数据,您必须使用 Unity 编辑器创建和指定光照设置资源,或使用脚本创建、配置和指定一个 LightingSettings 对象。有关更多信息和代码示例,请参阅 LightingSettings API 文档

Unity automatically generates an ambient probe and a default Reflection Probe to ensure that environment lighting affects your scene and the GameObjects in it by default. To learn more about this functionality, see SkyManager.


当您在 Inspector 或 Lighting 窗口中查看光照设置资源时,可查看或编辑的属性分为以下部分:

Realtime Lighting

This section contains settings related to the Enlighten Realtime Global Illumination system.

属性 功能
实时全局光照 If this checkbox is ticked, Unity enables the Enlighten Realtime Global Illumination system in Scenes that use this Lighting Settings Asset.
Realtime Environment Lighting Enable this property to use the Enlighten Realtime Global Illumination system to calculate and update ambient light in real-time.

This property is only available when both Enlighten Realtime Global Illumination and Baked Global Illumination are enabled in the Scene.

Mixed Lighting


属性: 功能:
烘焙全局光照 启用此设置后,Unity 将为使用此光照设置资源的场景启用烘焙全局光照系统。禁用此设置时,Unity 会为使用此光照设置资源的场景禁用烘焙全局光照系统。

当烘焙全局光照系统启用时,Unity 将场景中的烘焙光源仅用于光照贴图,而混合光源的行为取决于 Lighting Mode 设置。禁用烘焙全局光照系统后,Unity 会强制场景中的所有烘焙光源和混合光源的行为就像实时光源一样。
Lighting Mode 指定 Unity 将哪个 Lighting Mode 用于场景中使用此光照设置资源的所有混合光源。

当您更改 Lighting Mode 时,您需要为使用此光照设置资源的场景重新烘焙光照数据。
Baked Indirect Baked Indirect Lighting Mode 用于场景中使用此光照设置资源的所有混合光源。
Subtractive Use Subtractive Lighting Mode for all Mixed Lights in the Scenes that use this Lighting Settings Asset.

Shadowmask Use Shadowmask Lighting Mode for all Mixed Lights in the Scenes that use this Lighting Settings Asset.

Lightmapping Settings

属性 功能
Lightmap Resolution Specifies the number of texels per unit to use for lightmaps. Increasing this value improves lightmap quality, but also increases bake times. Note that doubling this value causes the number of texels to quadruple because it determines both the height and width of the lightmap. See the Occupied texels count in the statistics area of the Lighting window.
Lightmap Padding Determines the separation (in texel units) between separate shapes in the baked lightmap. The default is 2.
Max Lightmap Size Specifies the size (in pixels) of the full lightmap texture, which incorporates a separate region for each included GameObject. The default value is 1024.
Lightmap compression The level of compression the Editor uses for lightmaps.
- None: Does not compress lightmaps.
- Low Quality: This may use less memory and storage than Normal Quality, but can also introduce visual artifacts.
- Normal Quality: This is a good trade-off between memory usage and visual quality.
- High Quality: Requires more memory and storage than Normal Quality, but provides better visual results.
Ambient Occlusion Controls the relative brightness of surfaces in baked ambient occlusion. This only applies to the indirect lighting calculated by the lightmapper you are using to bake your lighting. Enabled by default. If Ambient Occlusion is enabled, it exposes three settings: Max Distance, Indirect Contribution, and Direct Contribution. For all three settings, higher values indicate a greater contrast between occluded and fully lit areas.
Max Distance Specifies how far the lighting system casts rays in order to determine whether or not to apply occlusion to an object. A higher value produces longer rays and contributes more shadows to the lightmap, while a lower value produces shorter rays that contribute shadows only when objects are very close to one another. A value of 0 casts an infinitely long ray that has no maximum distance. The default value is 1.
Indirect Contribution Scales the brightness of indirect ambient light bounced and emitted from objects in the final lightmap. This is a value between 0 and 10. The default value is 1. Values less than 1 reduce the intensity, while values greater than 1 increase it.
Direct Contribution Scales the brightness of direct light. This is a value between 0 and 10. The default value is 0. The higher this value is, the greater the contrast the Editor applies to the direct lighting.
Directional Mode Enables the lightmap to store information about the characteristics of the dominant incoming light at each point on an object’s surface. See Directional Lightmapping for more information. The default mode is Directional.
Directional In Directional mode, , Unity generates a second lightmap to store the dominant direction of incoming light. This makes it possible for diffuse normal mapped materials to work with the global illumination system. Shaders sample both lightmap textures during rendering. As a result, directional mode requires about twice as much video memory as non-directional mode for the additional lightmap data. Generating the additional directionality texture has an impact on baking performance. Directional lightmaps cannot be decoded on SM2.0 hardware or when using GLES2.0.
Non-directional Non-directional mode lightmaps only include a single texture. As a result, they require less video memory and less storage than directional lightmaps, and are faster to decode in shaders. These optimizations reduce visual quality.
Indirect Intensity Determines the brightness of indirect light stored in real-time and baked lightmaps. This is a value between 0 and 5. A value above 1 increases the intensity of indirect light while a value of less than 1 reduces indirect light intensity. The default value is 1.
Albedo Boost Specifies the amount of light Unity bounces between surfaces. This value is between 1 and 10. Increasing this value pulls the albedo value towards white for indirect light computation. The default value of 1 is physically accurate.
Lightmap Parameters A Lightmap Parameters Asset stores values for settings relevant to Baked Global Illumination. The Editor provides several default Lightmap Parameters Assets to choose from, but you can also create your own lightmap parameters file using the Create New option. See Lightmap Parameters for more information. The default value is Default-Medium. The options are Default-Medium, Default-HighResolution, Default-LowResolution, and Default-VeryLowResolution.

Some settings are specific to certain lightmapper backends. To see these settings, visit the page for the relevant lightmapper:

Auto Generation

当您在 Inspector 中查看光照设置资源时,此属性位于 Inspector 的顶部。当您在 Lighting 窗口中查看光照设置资源时,此属性位于 Lighting 窗口的底部,在 Generate Lighting 按钮附近。

属性 功能:
Auto Generate If Auto Generate is enabled, Unity precomputes lighting data automatically when you make changes to the Scene.

This data includes lightmaps for the Baked Global Illumination system, data for the Enlighten Realtime Global Illumination system, Light Probes, and Reflection Probes.

Unity usually begins the bake a few seconds after you make a change to the Scene. If Auto Generate is disabled, you must manually invoke a bake yourself, using the Generate Lighting button in the Lighting window, or the Lightmapping.Bake or Lightmapping.BakeAsync APIs.

Note that when you precompute lighting data using Auto Generate, the precomputed lighting data is not stored as Assets in your Project. It is instead stored in memory, and serialized as part of the Scene.

*光照设置资源添加于 2020.1 NewIn20201

Lighting 窗口