Untiy Forward 渲染管线

在Unity Shader 经常会用填写一个标签

Tags{ "LightMode" = "ForwardBase" "OnlyDirectional" ="True"}

 指定LightMode,上面提过LightMode 有多种,我们现在在手游中,大部分是Forward管线。在刚刚开始学习Unity ShaderLab 非常困惑一点 为什么向前渲染还要分成两种管线,

一种叫ForwardBase 一种叫 ForwardAdd


Unity 官方文档里面对于这两个区别有说明,接合实际效果做个小测试看是不是。

Forward Rendering path renders each object in one or more passes, depending on lights that affect the object. Lights themselves are also treated differently by Forward Rendering, depending on their settings and intensity.

正向渲染路径渲染一个物件可能需要一个pass 或者多个pass,这取决物体受到灯光的影响。灯光也有不同的处理,根据的灯光的设置和强度。

Implementation Details

In Forward Rendering, some number of brightest lights that affect each object are rendered in fully per-pixel lit mode. Then, up to 4 point lights are calculated per-vertex. The other lights are computed as Spherical Harmonics (SH), which is much faster but is only an approximation. Whether a light will be a per-pixel light or not is dependent on this:

在正向渲染中,有些几个最亮的灯光是在像素着色器中处理,在顶点着色器中处理最多4个,多的灯光信息按照球谐函数方法处理。灯光是在顶点还是像素中计算取决下面几个情况

  • Lights that have their Render Mode set to Not Important are always per-vertex or SH. 如果灯光设置里面RenderMode 设置成 Not Import 那就是顶点光照或者球面光照
  • Brightest directional light is always per-pixel. 最强的那个方向光,肯定是像素光照
  • Lights that have their Render Mode set to Important are always per-pixel. 设置成Import的灯光,都是按照像素光照处理
  • If the above results in less lights than current Pixel Light Count Quality Setting, then more lights are rendered per-pixel, in order of decreasing brightness.
原文地址:https://www.cnblogs.com/wbaoqing/p/8985875.html