Unity 将称为 Enlighten 的中间件用于实时 GI。
已弃用 Enlighten,很快就会将其删除。作为一种替代的光照贴图,可以使用渐进 GPU 光照贴图 (Progressive GPU Lightmapper)(预览)或渐进 CPU 光照贴图 (Progressive CPU Lightmapper)。Unity 正在开发一种用于实时全局光照的新解决方案。有关更多相关信息,请参阅 Unity 博客。
默认情况下,实时光源仅为场景提供直接光照。如果在场景中启用实时全局光照(实时 GI),实时光源还会为场景提供间接光照。
如果光源会缓慢变化并对场景具有很高的视觉影响(例如在天空中移动的太阳,或者在封闭的走廊中缓慢闪烁的光源),实时 GI 就很有用。对于快速变化的光源或对于特殊效果,由于性能成本和延迟,不适合使用实时 GI。
实时 GI 适用于面向中端到高端 PC 系统和游戏主机的游戏。一些高端移动设备也可能足够强大到能够使用此功能,但应保持场景较小且实时光照贴图的分辨率较低,从而节省系统资源。
要在场景中启用 Realtime GI,请打开 Lighting 窗口(菜单:__Window__ > Rendering > Lighting__),然后启用 Realtime Global Illumination__。
要禁用__实时 GI__ 对特定光源的影响,请选择光源游戏对象,然后在光源组件中将 Indirect Multiplier 设置为 0。这意味着该光源不会为场景提供任何间接光。
要完全禁用 Realtime GI__,请打开 Lighting 窗口(菜单:__Window > Rendering > Lighting__),然后取消选中 Realtime Global Illumination__。
有关使用实时 GI 的详细分步式建议,请参阅关于预计算实时 GI (Precomputed Realtime GI) 的 Unity 教程。
在 Unity Editor 中,Enlighten 将场景拆分为小的面片,并确定这些面片彼此可见的程度。在运行时,Enlighten 使用此预计算的可见性信息来估计实时光源在场景中的反射方式,将结果保存在一组光照贴图中,然后使用这些光照贴图将间接光照应用于场景。
更新光照贴图的计算量很大,因此该过程被拆分为几帧。换言之,Enlighten 需要几帧才能通过场景将更改传播到间接光照。
请注意,启用实时 GI 后,光照探针的行为方式将会不同。
在场景中启用实时 GI 后,光照探针会在运行时迭代地对光照采样。这意味着光照探针会对场景光照中的运行时变化做出反应。
在场景中禁用实时 GI 后,光照探针仅使用烘焙光照数据。这意味着光照探针不会对场景光照中的运行时变化做出反应。
如果光源也投射阴影,则 Unity 会将场景中的动态和静态游戏对象都渲染到光源的阴影贴图中。然后,静态和动态游戏对象的材质着色器对此阴影贴图进行采样,并相互投射实时阴影。阴影距离 (Shadow Distance)(菜单:__Edit__ > Project Settings__,然后选择 Quality__ 类别,并导航到 Shadows 部分)控制阴影开始淡出和完全消失的最大距离,从而影响性能和图像质量。
请注意,虽然实时 GI 也会产生柔和阴影,但较之于光照贴图可以实现的精细程度,实时 GI 通常更加粗糙(除非场景非常小)。
实时 GI 可能会增加内存需求,因为 Enlighten 使用一组额外的光照贴图来存储实时间接反弹光线。
实时 GI 增加了着色器计算,因为 Enlighten 会对另外一组光照贴图和探针进行采样。
如果实时 GI 不能对场景光照的变化产生足够迅速的响应,有几种方法可以解决此问题:
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.