This page has been translated automatically.
UNIGINE 基础课程
1. 简介
2. 虚拟世界管理
3. 3D模型准备
4. 材质
6. 实现应用程序逻辑
7. 制作过场动画与动画序列
8. 准备发布项目
9. 物理系统
10. 优化基础
11. 项目2:第一人称射击游戏
12. PROJECT3: Third-Person Cross-Country Arcade Racing Game
13. PROJECT4: VR Application With Simple Interaction

光照贴图技术

Lightmapping is a static global illumination technique using precalculated textures (lightmaps) that store brightness and reflected color of lit surfaces. By using lightmapping you can avoid heavy computations of lighting in primarily static scenes.光照贴图(Lightmapping)是一种静态全局光照技术,通过预计算纹理(即光照贴图)来存储受光表面的亮度与反射颜色。该技术可避免在静态场景中进行耗时的实时光照计算。

Lightmapping is the most efficient solution enabling to achieve realistic diffuse lighting and keep the high performance. It is capable of giving high-detailed global illumination combined with simulation of many light bounces. The number of bounces is the key aspect of creating realistic lighting in bright scenes. When you use lightmapping it doesn’t matter how many rays, bounces or light sources are there, as everything is calculated once and then baked in textures. These textures are then simply projected onto the surfaces of objects, creating a realistic look.作为最高效的解决方案,光照贴图既能实现逼真的漫反射光照,又能保持高性能表现。它能结合多次光线反弹模拟,提供高精度的全局光照效果。在明亮场景中,光线反弹次数是营造真实光照的关键要素。使用光照贴图时,光线数量、反弹次数或光源数量都不再影响性能,因为所有计算只需执行一次并烘焙至纹理中。这些纹理随后简单投射到物体表面即可呈现真实视觉效果。

UNIGINE provides an integrated GPU-accelerated Lightmapper tool available in the Bake Lighting window.UNIGINE提供集成化的GPU加速光照贴图工具(Lightmapper),可通过 Bake Lighting 窗口访问。

Baking correct lightmaps requires proper and non-overlapping UV coordinates for all scene geometry. If your assets do not have such UV coordinates (for example, CAD models), use the automatic UV unwrapping option when importing the model.要烘焙正确的光照贴图,场景几何体必须具有规范且无重叠的UV坐标。若资源缺乏此类UV坐标(如CAD模型),在导入模型时需启用自动UV展开选项。

In the Import Settings for FBX, CAD models and UNIGINE *.mesh assets, select the UV Channel and Target Resolution to be used for lightmaps (it directly affects the map quality and baking time) and, if needed, toggle UV channels for unwrapping. Traditionally, UV Channel 0 is used for texturing and Channel 1 is for lightmapping. 在模型资源(FBX、CAD、*.mesh)的导入设置中,选择用于光照贴图的UV通道和目标分辨率(这将直接影响贴图质量与烘焙时间),必要时可切换UV通道进行展开操作。按照惯例,UV通道0用于纹理贴图,通道1专用于光照贴图。

For all surfaces of static objects that are intended to be lightmapped, the following Lightmaps parameters are to be adjusted: 对于所有需要生成光照贴图的静态物体表面,必须调整以下Lightmaps参数:

  1. Toggle the Enabled flag to enable the feature.启用Enabled开关激活功能。
  2. Select Bake Unique Texture if you want to bake a new lightmap (if you want to use an already generated map, select the Use Custom Texture mode).选择Bake Unique Texture烘焙新光照贴图(若使用已有贴图则选择Use Custom Texture模式)。
  3. Moreover, you can specify the lightmap Texture generated in a third-party software. Select the Use Custom Texture mode for this purpose.还可指定第三方软件生成的光照贴图纹理,此时需选择Use Custom Texture模式。
注意
You can select Baked Lightmap Checker from the Rendering Debug menu to check unwrapping and resolution uniformity on scene objects.通过Rendering Debug菜单中的Baked Lightmap Checker选项,可检查场景物体的UV展开与分辨率均匀性。

For a surface to contribute to the lightmap, it must have the Cast Global Illumination option enabled (this option should be disabled for dynamic objects). 要使表面参与光照贴图计算,必须启用Cast Global Illumination选项(动态物体应禁用此选项)。

Prepare light sources: set the Static mode for the sources that should contribute to lightmapping (these light sources are to be enabled during the baking process), in order to bake direct and reflected light from emissive surfaces (with the enabled Emission state in the material parameters) enable the Emission Bake GI option.准备光源:将需要参与光照贴图的光源设置为Static(静态)模式(这些光源在烘焙过程中需要保持启用),为了烘焙自发光表面(材质参数中启用了自发光状态)的直接光和反射光,需要启用Emission Bake GI(自发光烘焙全局光照)选项。

Baking Process
烘焙流程#

  1. Enable the Lightmap buffer: Rendering -> Buffers -> Lightmap.启用光照贴图缓冲区:Lightmap: Rendering -> Buffers -> Lightmap
  2. Open the Bake Lighting window.打开Bake Lighting(烘焙光照)窗口。
  3. Enable Bake Lightmaps for Surfaces. Adjust the baking settings:启用 Bake Lightmaps for Surfaces(表面光照贴图烘焙),调整烘焙设置:

    • Set up Baking Viewport Masks.配置 Baking Viewport Masks(烘焙视口遮罩)。
    • Select the baking Quality: Draft is suitable for quick iterations, and Ultra provides the maximum quality.选择烘焙质量(Quality):草稿(Draft)适合快速迭代,极致(Ultra)提供最高质量。
    • Adjust Far Clipping Distance for clipping the light rays.调整 Far Clipping Distance(远裁剪距离)控制光线裁剪范围。
  4. Set the number of light ray bounces (higher values will result in a brighter lighting).设置光线反弹次数(数值越高光照越亮)。
  5. Start the baking process for all objects by clicking Bake All Lighting and wait for it to finish. Live preview of the process is available (the number of samples counted per frame can be adjusted during the baking process).点击Bake All Lighting(烘焙全部光照)开始全场景烘焙,等待完成(可实时预览烘焙进度,烘焙过程中可调整每帧采样数)。
  6. The generated lightmaps are saved to the bake_lighting/lightmaps folder and applied to the corresponding surfaces.生成的光照贴图将保存至bake_lighting/lightmaps文件夹,并自动应用到对应表面。
  7. To improve the quality, you can also enable Lightmap Cubic Filtering in the material settings of the surfaces with the light map.如需提升质量,可在材质设置中为Lightmap Cubic Filtering(光照贴图表面启用立方体过滤)。
  8. The result can be checked by selecting the Indirect Lighting mode in the Rendering Debug menu.通过Rendering Debug(渲染调试菜单)选择Indirect Lighting(间接光照模式)查看效果。

注意
If you are not satisfied with the baking result on certain objects or surfaces, you can select them and perform partial re-bake with different settings by clicking Bake Selected.若对特定物体/表面的烘焙效果不满意,可选中目标后点击 Bake Selected(烘焙选中对象)使用不同设置进行局部重烘焙。

Lightmaps can be combined with Voxel Probes and Environment Probes.光照贴图可与体素探针(Voxel Probe)及环境探针(Environment Probe)配合使用。

本页面上的信息适用于 UNIGINE 2.20 SDK.

最新更新: 2025-06-09
Build: ()