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 编辑器中创建光照设置资源。
要从项目视图创建光照设置资源:
要从 Lighting 窗口创建并自动指定光照设置资源:
Select Clone instead to create a duplicate of the current Lighting Settings Asset, and immediately assign it to the active Scene.
您还可以从脚本创建光照设置资源。为此,请创建一个 LightingSettings 类的实例并将其保存到磁盘,或将其指定给场景并保存该场景。有关更多信息和代码示例,请参阅 LightingSettings API 文档。
要在 Unity 编辑器中为场景指定光照设置资源:
您还可以从脚本将光照设置资源指定给活动场景。为此,请加载光照设置资源以获取 LightingSettings
类的实例,然后使用"Lightmapping.lightingSettingsAPI 将该
LightingSettings` 实例指定给活动场景。有关更多信息和代码示例,请参阅 LightingSettings API 文档。
您可以在 Unity 编辑器中的两个位置查看和编辑光照设置资源的属性:
在项目视图中,如果您选择一个光照设置资源,您可以在 Inspector 中查看和编辑其属性。 如果活动场景具有为其指定的光照设置资源,您可以在 Lighting 窗口的 Scene 选项卡中查看和编辑该光照设置资源的属性。
您还可以从脚本读取或写入光照设置资源的属性。为此,请加载光照设置资源以获取 LightingSettings
类的实例,并访问其属性。有关更多信息和代码示例,请参阅 LightingSettings API 文档。
当场景没有为其制定的光照设置资源时,Unity 会为该场景使用默认的 LightingSettings
对象。默认的 LightingSettings
对象是一个 LightingSettings
类的内部只读实例。
您不能对使用默认 LightingSettings
的场景的 LightingSettings
数据进行任何更改,但 Unity 可以使用其设置执行烘焙。
要更改场景的 LightingSettings
数据,您必须使用 Unity 编辑器创建和指定光照设置资源,或使用脚本创建、配置和指定一个 LightingSettings
对象。有关更多信息和代码示例,请参阅 LightingSettings API 文档。
当您在 Inspector 或 Lighting 窗口中查看光照设置资源时,可查看或编辑的属性分为以下部分:
This section contains settings related to the Enlighten Realtime Global Illumination system.
属性 | 功能 |
---|---|
实时全局光照 | Enable this property to use 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. |
Indirect Resolution | Specifies the number of texels per unit to use for realtime lightmaps. Increasing this value improves lightmap quality, but also increases render time. This property is only available if you enable Realtime Global Illumination. |
在使用光照设置资源的场景中,此部分包含的设置会影响烘焙光源和混合光源的行为。
属性: | 功能: | |
---|---|---|
烘焙全局光照 | 启用此设置后,Unity 将为使用此光照设置资源的场景启用烘焙全局光照系统。禁用此设置时,Unity 会为使用此光照设置资源的场景禁用烘焙全局光照系统。 当烘焙全局光照系统启用时,Unity 将场景中的烘焙光源仅用于光照贴图,而混合光源的行为取决于 Lighting Mode 设置。禁用烘焙全局光照系统后,Unity 会强制场景中的所有烘焙光源和混合光源的行为就像实时光源一样。 |
|
Lighting Mode | 指定 Unity 将哪个 Lighting Mode 用于场景中使用此光照设置资源的所有混合光源。 当您更改 Lighting Mode 时,您需要为使用此光照设置资源的场景重新烘焙光照数据。 |
|
Baked Indirect | Use Baked Indirect Lighting Mode for all Mixed Lights in the Scenes that use this Lighting Settings Asset. In Baked Indirect Lighting Mode, Mixed Lights provide real-time direct lighting and Unity bakes indirect light into lightmaps and Light Probes. Real-time shadow maps provide shadows. |
|
Shadowmask | Use Shadowmask Lighting Mode for all Mixed Lights in the Scenes that use this Lighting Settings Asset. In Shadowmask Lighting Mode Mixed Lights provide real-time direct lighting while indirect light is baked into lightmaps and probes. This mode combines real-time and baked shadows. |
|
Subtractive | Use Subtractive Lighting Mode for all Mixed Lights in the Scenes that use this Lighting Settings Asset. In Subtractive Lighting Mode Mixed Lights provide baked direct and indirect lighting for static objects. Dynamic objects receive real-time direct lighting and cast shadows using the Directional Light. |
属性 | 功能 |
---|---|
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. |
See Progressive Lightmapper for additional settings specific to it.
*光照设置资源添加于 2020.1 NewIn20201
LightingSettings