表面着色器和渲染路径
在内置渲染管线中,使用表面着色器时,如何应用光照以及使用着色器的哪些通道取决于使用的渲染路径。着色器中的每个通道均通过通道标签来表达其光照类型。
功能名称 | 内置渲染管线 | 通用渲染管线 (URP) | 高清渲染管线 (HDRP) | 自定义 SRP |
---|---|---|---|---|
表面着色器 | 是 | 否 有关在 URP 中创建 Shader 对象的简化方法,请参阅 Shader Graph。 |
否 有关在 HDRP 中创建 Shader 对象的简化方法,请参阅 Shader Graph。 |
否 |
ForwardBase
和 ForwardAdd
通道。Deferred
通道。Vertex
、VertexLMRGBM
和 VertexLM
通道。ShadowCaster
通道。ForwardBase
通道可一次性渲染环境光、光照贴图、主方向光和不重要的(顶点/SH)光源。ForwardAdd
通道用于任何附加的每像素光源;针对此类光源照亮的每个对象进行一次调用。请参阅前向渲染以了解详细信息。
如果使用前向渲染,但着色器没有适合前向渲染的通道(即,ForwardBase
和 ForwardAdd
通道类型均不存在),则会按照在顶点光照通道中的方式来渲染该对象,请参阅下文。
Deferred
通道将渲染光照需要的所有信息(在内置着色器中:漫射颜色、镜面反射颜色、平滑度、
世界空间法线、发光)。它还在发光通道中增加光照贴图、反射探针和环境光照。有关详细信息,请参阅延迟着色。
由于顶点光照最常用于不支持可编程着色器的平台,因此 Unity 无法在内部创建多个着色器变体来处理光照贴图与非光照贴图的情况。所以,要处理光照贴图对象和非光照贴图对象,必须显式编写多个通道。
Vertex
通道用于非光照贴图对象。所有光源均通过固定函数 OpenGL/Direct3D 光照模型 (Blinn-Phong) 立即渲染VertexLMRGBM
pass is used for lightmapped objects, when lightmaps are RGBM encoded (PC and consoles). No real-time lighting is applied; pass is expected to combine textures with a lightmap.VertexLM
pass is used for lightmapped objects, when lightmaps are double-LDR encoded (mobile platforms). No real-time lighting is applied; pass is expected to combine textures with a lightmap.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.