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 的渲染功能逼真地模拟现实世界,并快速实现项目的可信视觉效果目标。这包括:
有关更深入的信息,请参阅 Unity 的光照和渲染教程。
简单来说,线性渲染模式使 Unity 能够在将最终输出转换为最适合显示屏的格式之前使用物理上精确的数学进行光照和着色计算。
要指定伽马或线性工作流程,请执行以下操作:
在 Unity 中,导航到主菜单中的 Edit > Project Settings__,然后选择 Player__ 类别。
选择 Other Settings > Rendering 并将 Color Space 更改为 Linear。
定义颜色空间应该是项目中最早的决策之一,因为它会对最终的着色和光照结果产生巨大影响。有关每个工作流程的更多建议,请参阅线性或伽马工作流程。
Spotlight Tunnel 示例场景使用延迟着色渲染路径。因此,您可以:
高效使用多个动态光照
组合多个反射立方体贴图
使用 Unity 2017+ 中的现有屏幕空间反射功能
要在 Editor 中设置渲染路径,请选择 Edit > Project Settings__,然后选择 Graphics__ 类别。或者,可以在场景中选择 Main Camera__,然后在 Inspector 窗口中设置 Rendering Path__。
有关渲染模式的更多信息,请参阅渲染管线详细信息。
To display HDR lighting properly, follow these steps to set it up and enable tonemapping:
在项目中创建 Post-Processing Profile 资源并对其进行配置:
在场景中选择 Main Camera__,单击 Inspector 窗口中的 Add Component__,然后选择 Post-Processing Behaviour。
在 Profile 字段中,输入您创建的后处理配置文件。
Spotlight Tunnel 示例场景使用的是后期处理栈 V1。有关使用后期处理栈 V2 的建议,请参阅包自述文件。
渲染可信光照时,您需要处理亮度高于 1(高动态范围)的光照值和发光表面,就像现实生活一样。然后,您需要将这些值重新映射到适当的屏幕范围(请参阅色调映射)。高动态范围设置至关重要,因为它允许 Unity 摄像机处理高值,而不是修剪它们。 要启用 HDR,请在场景中选择 Main Camera__,并确保选中 Inspector 窗口中的 Allow HDR__ 复选框。
Spotlight Tunnel 示例场景不使用烘焙光照。但是,如果您计划使用 HDR 烘焙光照,请将光照贴图编码设置为 HDR 光照贴图以获得一致的结果。
要在 Unity 中设置光照贴图编码,请选择 Edit > Project Settings__,选择 Player__ 类别,展开 Other Settings 面板,然后导航到 Lightmap Encoding。有关更多信息,请参阅光照贴图:技术信息。
要在使用场景时查看色调映射器,请在 Scene 视图顶部的下拉工具栏菜单中启用 Image Effects。在下图中,请注意色调映射场景中的高光再现和黑暗隧道值分离改进情况。如果观察非色调映射场景,您可以看到高光如何不聚合到统一的颜色(在此处为黄色烈日)。
此设置在本质上试图复制数码相机以固定曝光值捕获场景的情况(未启用曝光适应/人眼适应功能)。
到目前为止,您已完成适当的基础场景渲染设置,应该能为广泛的内容提供可信结果:
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.