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.
动态照亮的游戏对象(尤其是大型游戏对象)比静态对象需要更多的技巧。如果游戏对象在场景中改变位置,则通常需要动态光照,因此预计算的光照不适用。但是,动态游戏对象的处理必须满足某些限制。要提高动态游戏对象光照的质量,请注意以下方面:
未被动态光照照亮的动态游戏对象的表面通常使用光照探针数据来填充其光照信息(在不存在光照探针的场景中,使用环境光照)。根据场景中使用的光照策略,这些信息可能包括多种信息,从间接光照信息一直到阴影和烘焙漫射光照探针光照信息。这种光照探针策略通常很适合小型动态游戏对象。但是,较大的游戏对象需要更精细的光照探针光照。这便是光照探针代理体 (Light Probe Proxy Volume) 的用武之地。有关更多信息,请参阅光照探针代理体组件。
使用光照探针代理体允许动态照亮的大型游戏对象使用多个光照探针,从而提高光照精度。以下示例显示了具有 LPPV 的胶囊体如何表现出更高的光照探针采样精度(尽管仅使用 2x2x2 代理体网格):
动态游戏对象仅接收来自光照探针或环境光的光照。因此,您需要预计算游戏对象的遮挡,特别是游戏对象包含凹陷内部的情况(例如示例中的电车)。在下面的示例中,未使用 AO 的左侧电车应用了光照探针光照数据,不知道如何区分内部和外部表面。采用预烘焙的 AO 后,该贴图可作为降低外部光线和反射强度的指引,使外观更加接近现实:
具体游戏对象 AO 离线烘焙甚至可从细节程度更高的网格烘焙到细节程度更低的网格来提供进一步细节化的遮挡,其原理与法线贴图烘焙的工作原理类似。
注意:具体游戏对象 AO 不与其他动态游戏对象相互作用。例如,动态游戏对象(例如进入电车的角色)从场景接收光照探针数据,不一定要与电车内部的遮挡匹配。
大多数动态游戏对象都不需要有自己的反射。但是,对于包含凹面内部的游戏对象,将反射探针连接到游戏对象并允许其实时运行有助于减少来自环境反射探针的误反射命中。
如果您能为游戏对象做出某些假设,则可以使用一些技巧来提高视觉品质。在下面显示的示例中,电车应始终在轨道上。因此,为了改善阴影区域中的地面光照遮挡,我们可以使用“Particle/Multiply”透明材质平面:
一种类似的技巧是将模糊阴影投影器 (blob shadow projector) 放置在角色下,而不是角色投射真实阴影。
在实时渲染中,如果能找到一种有效的技巧,并且性能代价较低,那么它通常便是可行的解决方案。肯定还有更多的提示和技巧有助于改善视觉渲染效果。上面列出的内容应该能启发您针对不同类型的视觉化要求思考相应的解决方案。
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.