Unity前向渲染路径细节(Forward Rendering Path Details)
2017-08-30 13:12
609 查看
Forward Rendering Path Details
该文章详述了 Forward rendering path.Forward Rendering path 渲染每个对象在一个或多个pass中,取决于作用在物体上的光照。这些光照本身也被Forward Rendering处理过,取决于它们的设置和强度。
Implementation Details
在 Forward Rendering 中作用在每个物体上一定数量最亮的光,被渲染在全逐像素(per-pixel)光照模式下。然后最多4个点光源会被逐顶点(per-vertex)计算。其他的光照被作为 Spherical Harmonics (SH) 计算, 它很快但是只是一个近似值。一个光源是否为一个逐像素光照取决于下表:光源的 Render Mode 被设置为 Not Important 永远是 per-vertex or SH.
最亮的平行光永远是 per-pixel.
渲染模式被设置为 Important 的光永远是per-pixel。
如果符合上述条件的光的数量,小于当前 Pixel Light Count Quality Setting,那么更多的光会被渲染为 per-pixel,根据光照亮度的顺序由高到低。
每个对象渲染发生在:
Base Pass 提供给一个逐像素平行光和所有的逐顶点/SH 光照。
其它的逐像素光照被选择在其他的pass中,每个光照一个pass。
例如,如果有一个对象被多个光照影响 (图片下方的圆圈,被A-H的光源影响):
让我们假设,光源A-H有相同的颜色和亮度,并且它们都是在 Auto rendering mode,因此对于该对象它们一定会按照A-H的顺序被分类。最亮的光源使用逐像素光照模式(A to D),然后最多4个光会使用逐顶点光照模式(D to G),最后剩下的光会使用SH模式(G to H):
注意光照组是有重叠的;例如最后一个逐像素光源混入逐顶点光照模式,因此当对象和光移动时,会有较少的“light popping(光爆)” 。
Base Pass
Base pass渲染对象的一个逐像素平行光和所有SH/vertex光源。该pass也添加来自shader的任何 lightmaps, ambient 和 emissive lighting。在该pass中渲染的平行光可以有阴影。注意光照贴图的对象,不被SH光源照亮。如果 “OnlyDirectional” pass flag 被用在shader中,那么 forward base pass 只会渲染 主平行光源, ambient/lightprobe 和 lightmaps (SH 和 vertex lights 不会被包含进pass的数据中).
Additional Passes
Additional passes 被用来渲染影响对象的每个额外的逐像素光源。该pass中的光照默认是没有阴影的。(所以结论是, Forward Rendering 支持一个有阴影的平行光), 除非 multi _ compile _ fwdadd _ fullshadows 类型的 shortcut 被使用。Performance Considerations
Spherical Harmonics lights 渲染 非常 迅速。它们在CPU上有极小的成本,并且对提供的GPU来说是真正无成本的 (因此, base pass 总是计算 SH lighting;但是由于 SH light的工作方式,它们的成本是相同的,不管有多少SH 光源)。SH lights不好的一面:
它们在对象的顶点中被计算,而不是逐像素的。这意味的它们不支持光照 Cookies 或 法向贴图。
SH lighting 是非常低频率的。 使用SH light你不会得到清晰的光照过度。它们也只作用于漫反射光照 (对镜面高光来说,频率太低了)。
SH lighting 不是本地化的; 点或放射 SH lights 接近一些平面会“看起来不对“。
总之,SH light 对小的动态对象来说,足够好了。
相关文章推荐
- 前向渲染路径细节 Forward Rendering Path Details
- 正向渲染路径细节 Forward Rendering Path Details
- U3D 延迟光照渲染路径的细节 Deferred Lighting Rendering Path Details
- Unity顶点光照路径细节(Vertex Lit Rendering Path Details)
- Unity Shader 学习笔记(12) 渲染路径(Rendering Path)
- Unity渲染路径 Rendering Paths_2_Forward Rendering 正向渲染
- Unity旧延迟光照渲染路径( Legacy Deferred Lighting Rendering Path)
- RenderingPath 渲染路径
- Unity渲染路径 Rendering Paths_1_Deferred Lighting 延时光照
- unity3d渲染路径Rendering Path
- Unity forward vs deferred rendering path
- 渲染路径-实时渲染中常用的几种Rendering Path
- RenderingPath 渲染路径
- Unity渲染路径(Rendering Paths)
- Unity延迟渲染路径(Deferred shading rendering path)
- unity3d渲染路径Rendering Path
- shader实例(八)渲染路径RenderingPath
- Unity渲染路径 Rendering Paths_3_Vertex Lit 顶点光照
- Unity渲染管线细节(Rendering Pipeline Details)
- Unity&Shader高级篇-渲染路径(Rendering Paths)