使用 Shadow Distance 属性可以确定 Unity 渲染实时阴影的最大距离(与摄像机之间的距离)。
游戏对象距摄像机的距离越远,产生的阴影就越不明显。这有两个原因:一个原因是阴影在屏幕上看起来更小,另一个原因是远处的游戏对象通常不是人们关注的焦点。可以通过为远处的游戏对象禁用实时阴影渲染来利用此原理。这样可以节省浪费的渲染操作,并可以提高运行时性能。此外,没了远处阴影后,场景通常看起来更好。
如果当前摄像机远平面小于阴影距离,Unity 将使用摄像机远平面而不是阴影距离。
要掩盖超出阴影距离的缺失阴影,可以使用诸如雾效之类的视觉效果。
在内置渲染管线中,请在项目的质量设置 (Quality Settings) 中设置 Shadow Distance 属性。
在通用渲染管线 (URP) 中,请在通用渲染管线资源中设置 Shadow Distance 属性。
在高清渲染管线 (HDRP) 中,请为每个体积 (Volume) 设置 Shadow Distance 属性。
如果场景使用 Shadowmask 光照模式,则 Unity 会使用光照探针或阴影遮罩纹理来渲染从混合光源产生的超出阴影距离的阴影。还可以配置 Unity 如何渲染超出阴影距离的阴影。
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.