Note that this guide was originally created for use with the Built-in Render Pipeline in Unity 2017.3. For information on adapting this guide for use with the Universal Render Pipeline (URP) and the High Definition Render Pipeline (HDRP), see Update: believable visuals in URP and HDRP.
在开始为场景创建最终资源并处理光照之前,您需要弄清楚自己的光照策略。在开发后期改变光照策略会对工作流程产生很大影响。在您进入生产之前花些时间确定好光照策略可以节省整体时间,还能让您获得更好的性能和更高的视觉保真度。
与所有开发一样,每项设置几乎总是存在优缺点,需要在二者之间进行权衡。但有时,某些技术会为您提供在特定约束条件下减少这些折中的选项。了解每个功能的利弊可以让您选择最适合项目的功能。
一个具有室外区域的典型白天场景拥有以下光照组件:
这三个组件看起来似乎很简单。但是,由于您可以混搭__实时__光照、混合__光照、烘焙__光照、静态游戏对象和动态游戏对象,因此最后可得出多种光照选择。
Unity 支持许多不同的光照策略和项目场景。要了解光照模式和设置,请参阅有关光照模式的文档。
对于新手来说,要弄清楚哪种设置最适合他们的场景以及如何权衡取舍,可能会让他们不知所措。因此,让我们考虑最常用的光照设置:
以下图像显示了这些设置之间的显著差异:
注意__:__实时 GI 不能烘焙静态环境光遮挡,因此未包括在内。
基本实时光照通常用于可视化风格的项目以及原型设计阶段。
典型的平台目标:游戏主机和 PC
优点:
缺点:
烘焙光照通常适用于存在运行时性能问题但还有可利用的内存空间的游戏,例如自上而下的等距移动端游戏和高帧率 VR 游戏。
典型的平台目标:移动平台、VR、游戏主机和低端 PC
优点:
缺点:
混合光照通常在日常光照(例如太阳运动)不重要的游戏中有用。
典型的平台目标:VR、游戏主机和 PC
优点:
缺点:
有关阴影遮罩光照的更多信息,请参阅阴影遮罩。
此设置在开放区域游戏中非常有用,在此类游戏中,您需要日常光照更新(例如太阳移动)和动态光照效果。
典型的平台目标:游戏主机和 PC
优点:
缺点:
有关优化__实时 GI__ 的深入信息,请参阅 Unity 提供的预计算的实时 GI 简介教程。
通常情况下,您只希望在严格控制内存使用量和限制性能并具有高保真要求的游戏中启用所有光照选项。仅当您完全了解每个系统并知道如何处理每个光照组合的情况下,才应这样做。
典型的平台目标:游戏主机和 PC
优点:
缺点:
为了帮助您了解光照,Spotlight Tunnel 示例场景使用具有实时 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.