Unity 的内置渲染管线支持不同渲染路径。渲染路径是与光照和阴影相关的一系列操作。不同的渲染路径具有不同功能和性能特征。应根据项目类型以及目标硬件,确定哪种渲染路径最适合您的项目。
可在 Graphics 窗口中选择项目使用的渲染路径,并可为每个摄像机覆盖该路径。
如果运行项目的设备上的 GPU 不支持所选的渲染路径,则 Unity 将自动使用较低保真度的渲染路径。例如,在无法处理延迟着色的 GPU 上,Unity 使用前向渲染。
前向渲染是内置渲染管线中的默认渲染路径。这是通用的渲染路径。
采用前向渲染方式渲染实时光源会非常消耗资源。为了抵消此成本,可以选择 Unity 在任何一个时间应该为每个像素渲染的光源数量。Unity 会以较低保真度渲染场景中的其余光源:每个顶点或每个对象。
如果项目没有使用大量实时光源,或者光照保真度对项目而言不重要,则此渲染路径可能是这个项目的不错选择。
有关更多详细信息,请参阅前向渲染页面。
延迟着色是内置渲染管线中具有最大光照和阴影保真度的渲染路径。
延迟着色需要 GPU 支持,并且有一些局限性。这种着色方式不支持半透明对象(Unity 使用前向渲染来渲染这些对象)、正交投影(Unity 对这些摄像机使用前向渲染)或硬件抗锯齿(但可以使用后期处理效果来获得类似结果)。延迟着色对剔除遮罩的支持有限,并会将 Renderer.receiveShadows 标志始终视为 true。
如果项目具有大量的实时光源并需要高级别的光照保真度,而目标硬件支持延迟着色,那么此渲染路径对于该项目而言可能是一个不错的选择。
有关更多详细信息(包括有关此渲染路径的局限性的建议),请参阅延迟着色页面。
旧版顶点光照 (Legacy Vertex Lit) 是具有最低光照保真度且不支持实时阴影的渲染路径。这是前向渲染路径的子集。
有关更多详细信息,请参阅顶点光照页面。
延迟 | 前向 | 顶点光照 | |
---|---|---|---|
功能 | |||
每像素光照(法线贴图、光照剪影) | 是 | 是 | - |
实时阴影 | 是 | 带有警告 | - |
反射探针 | 是 | 是 | - |
深度和法线缓冲区 | 是 | 其他渲染pass | - |
软粒子 | 是 | - | - |
半透明对象 | - | 是 | 是 |
抗锯齿 | - | 是 | 是 |
光照剔除遮罩 | 受限 | 是 | 是 |
光照保真度 | 全部每像素 | 部分每像素 | 全部每顶点 |
性能 | |||
每像素光照的成本 | 照射像素数量 | 像素数量 * 照射对象数量 | - |
正常渲染对象的次数 | 1 | 每像素光照的数量 | 1 |
简单场景的开销 | 高 | 无 | 无 |
平台支持 | |||
PC (Windows/Mac) | Shader Model 3.0+ 和 MRT | 所有 | 所有 |
移动端 (iOS/Android) | OpenGL ES 3.0 & MRT, Metal | 所有 | 所有 |
游戏主机 | XB1、PS4 | 所有 | - |
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.