Version: 2022.2
光照贴图:入门
定向模式

光照贴图参数资源

光照贴图参数资源中包含了一组用于控制 Unity 光照功能的参数值。这些资源允许定义和保存不同的光照值集合,以便用于不同的情况。

光照贴图参数资源可以用来为不同类型的游戏对象或为不同平台和不同场景类型(例如,室内或室外场景)创建优化的预设。

创建光照贴图参数资源

要创建新的光照贴图参数资源,请在 Project 窗口中右键单击,然后选择 Create > New Parameters Asset。Unity 将此资源存储在 Project 文件夹中。

属性

在 Project 窗口中单击某个光照贴图参数资源时,Inspector 窗口将显示该资源中定义的值。下表中列出了参数及其描述。

Realtime GI

These parameters configure Enlighten Realtime Global Illumination.

See render pipeline feature comparison for more information about support for Enlighten Realtime Global Illumination across render pipelines.

属性 功能
Resolution 该值在 Lighting 窗口的 Scene 选项卡中缩放 Realtime Resolution 值(菜单:__Window__ > Rendering > Lighting > Scene__)以提供光照贴图的最终分辨率(纹理像素/距离单位)。 | | Cluster Resolution| 聚类分辨率(内部计算光反射的分辨率)与最终光照贴图分辨率的比率。请参阅有关 Scene 视图中的 GI 可视化的文档以了解更多信息。 | | Irradiance Budget| 此值确定用于照射光照贴图中每个纹理像素的入射光数据的精度。从纹理像素的位置对场景的“视图”采样来获得每个纹理像素的光照。较低的辐照度预算值会导致样本更模糊。值越高,样本的清晰度越高。较高的辐照度预算会改善光照,但这会增大运行时内存使用量并可能增大 CPU 使用率。 | | Irradiance Quality| 使用滑动条来定义投射的射线数量,并计算影响给定输出光照贴图纹理像素的集合。较高的值可在光照贴图中实现视觉改善,但会增加 Unity Editor 中的预计算时间。该值不会影响运行时性能。 | | Modelling Tolerance| 此值控制网格几何体中允许光线通过的间隙的最小大小。降低此值可允许光线穿过环境中更小的间隙。 | | Edge Stitching| 如果启用此属性,则表示光照贴图中的 UV 图表应无缝连接在一起,从而避免不必要的视觉瑕疵。 | | Is Transparent| 如果启用此属性,在全局光照计算期间,对象显示将为透明。背面对这些计算没有影响,光线将穿过表面。这可用于不可见的发光表面。 | | System Tag| 光照贴图纹理组合在同一个光照贴图图集内的一组对象称为“系统”。如果无法将所有对象放入单个图集中,Unity Editor 会自动定义其他系统及其附带的图集。但是,有时自己定义单独的系统会非常有用(例如,确保不同房间内的对象分组到每个房间的一个系统中)。更改 System Tag__ 号可强制创建新的系统和光照贴图。标签的确切数字序列值不重要。

Baked GI

这些参数用于配置光照贴图

See render pipeline feature comparison for more information about support for lightmapping across render pipelines.

属性 功能
Enlighten Baked Global Illumination 渐进光照贴图 (Progressive Lightmapper)
Blur Radius 后期处理过程中应用于直接光照的模糊过滤器的半径(单位:纹理像素)。此半径基本上是相邻纹理像素的平均距离。半径越大,效果越模糊。较高的模糊度往往会减少视觉瑕疵,但也会软化阴影的边缘。 使用渐进光照贴图时,__Blur Radius__ 不可用。
Anti-aliasing Samples Determines the number of sub-texel positions to use when sampling a lightmap texel. Set the value above 1 to use supersampling to improve lightmap quality and reduce artifacts related to aliasing.
•A value of 1 disables super sampling.
•Values between 2 and 8 provide 2x2 supersampling. The default value is 8, which removes most aliasing artifacts.
•Values between 9 and 256 provide 4x4 supersampling. Use these values to remove artifacts, like jagged edges in direct lighting. This can happen when you use baked shadows.

Note: A higher anti-aliasing sample value uses more memory. This means that if you use a high sample number in a large Scene, with large lightmap texture sizes the lightmap bake might not complete.
Direct Light Quality 用于评估直接光照的光线数量。较高数量的光线往往会产生更准确的柔和阴影,但会增加烘焙时间。 使用渐进光照贴图时,__Direct Light Quality__ 不可用。
Backface Tolerance 网格的结构有时会导致某些纹理像素含有背面带有几何体的“视图”。来自背面的入射光在任何场景中都无意义。因此,此属性用于选择有多少光量(百分比阈值)来自正面几何体才能将纹理像素视为有效。无效纹理像素的光照值通过相邻纹理像素的值估算得出。降低此值可以解决由背面入射光引起的光照问题。 Specifies the percentage of front-facing geometry sampling ray hits a texel must have for Unity to consider it valid. This makes it possible for Unity to invalidate a texel if too many of the rays cast from it hit backfaces (e.g. if the texel is inside geometry). A value of 1.0 means that Unity considers a texel invalid when any of its rays hits a backface, for example. When a texel is invalid, Unity clones valid values from surrounding texels to prevent artifacts. Lower this value to solve lighting problems caused by backface samples. Use the Texel Validity Scene View Draw Mode to adjust this value.
Pushoff Pushes ray origins away from geometry along the normal based on the value you specify in modelling units. Unity applies this value to all baked lightmaps. It affects direct light, indirect light, and baked ambient occlusion. Adjust this setting to reduce self-occlusion and self-shadowing artifacts.
Baked Tag Groups specific sets of objects in atlases. As with the System Tag, the exact numeric value is not significant. Unity never puts GameObjects with different Baked Tag values in the same atlas. However, there is no guarantee that objects with the same tag end up in the same atlas because there may be too many objects with that tag to fit into one atlas. See image A (below) for an example of this. You do not need to set this value when you use the multi-scene bake API because Unity groups automatically in that case. You can use Baked Tag to replicate some of the behavior of the Lock Atlas option. See Baked Tags: Details for more information.
Limit Lightmap Count Limit Lightmap Count is not available when you use Enlighten Baked Global Illumination. Applies a limit to the number of lightmaps that Unity can use to pack together GameObjects with the same Baked Global Illumination settings. When you enable this limit, a related setting appears called Max Lightmaps. That setting determines the lightmap limit. The Lightmapping Settings define the size of these lightmaps.

Unity considers GameObjects to have the same Baked Global Illumination settings if they have equal values for Anti-aliasing Samples, Pushoff, Baked Tag, and Backface Tolerance. This means that Unity might pack together GameObjects associated with different Lightmap Parameter Assets.

To pack GameObjects into a set number of lightmaps, Unity scales down UV layouts until all fit within the specified number of lightmaps. This process may reduce lightmap resolution.

烘焙标签 (Baked Tags):详细信息

The two images above shows two views of the same Scene:

  1. Top: Everything is in one atlas because all the GameObjects have the same Baked Tag.

  2. Bottom: One GameObject is assigned a different Baked Tag, and forced into a second lightmap.

Baked AO

这些参数用于配置烘焙环境光遮挡。

属性 功能
Quality 评估烘焙环境光遮挡 (AO) 时投射的射线数量。射线数量越多,AO 质量越高,但烘焙时间也越长。
Anti-aliasing Samples 进行 AO 抗锯齿时要采集的样本数。样本数量越多,AO 质量越高,但烘焙时间也越长。

General GI

属性 功能
Backface Tolerance 必须照射到光照系统正面才会被视为可用的输出纹理像素发射光线的百分比。如果从纹理像素投射的太多光线照射到背面(例如,如果纹理像素在某个几何体内),此设置允许 Unity 让纹理像素无效。光照系统从周围纹理像素克隆有效值来避免意外的瑕疵。

如果 Backface Tolerance 设置为 0.0,则光照系统仅在纹理像素只能看到背面的情况下才会拒绝该纹理像素。如果此设置为 1.0,即使射线原点有一条射线照射到背面,光照系统也会拒绝该原点。

分配光照贴图参数资源

场景

To assign a Lightmap Parameters Asset to the whole Scene:

  1. Open the Lighting window (Window > Rendering > Lighting)
  2. Click the Scene tab
  3. Navigate to the Lightingmapping Settings.
  4. Use the Lightmap Parameters drop-down to assign a default Lightmap Parameters Asset. This drop-down lists all available Lightmap Parameters Assets.

游戏对象

要将光照贴图参数资源分配给单个游戏对象,请确保游戏对象已附加网格渲染器 (Mesh Renderer) 或地形 (Terrain) 组件。

To assign a Lightmap Parameters Asset to a Mesh Renderer component:

  1. In the Inspector, go to Mesh Renderer > Lighting
  2. Enable Contribute Global Illumination
  3. In the mesh Renderer component, go to Lightmapping > Lightmap Parameters.
  4. Select an option from the menu. Select Scene Default Parameter to use the same Lightmap Parameters Asset that’s assigned to the whole Scene.

To assign a Lightmap Parameters Asset to a Terrain component:

  1. In the Inspector, go to Terrain > Terrain Settings > Lighting
  2. Enable Contribute Global Illumination
  3. In Terrain Settings, go to Lightmapping > Lightmap Parameters.
  4. Select an option from the menu. Select Scene Default Parameter to use the same Lightmap Parameters Asset that’s assigned to the whole Scene.

2019–03–28 页面已修订

2018–03–28 页面已修订

2019.1 版中添加了 Limit Lightmap Count NewIn20191

2018.1 版中添加了渐进光照贴图 NewIn20181

LightmapParameters

光照贴图:入门
定向模式