前向渲染路径细节 Forward Rendering Path Details
正向渲染路徑細節?Forward Rendering Path Details
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.
根據影響物體的光源的不同,正向渲染路徑用單個或多個通道來渲染物體。在正向渲染中,光源本身也會根據他們的設置和強度受到不同的對待。
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 per-pixel light or not is dependent on this:
在正向渲染中,影響物體的最亮的幾個光源使用逐像素光照模式。接下來,最多有4個點光源會以逐頂點渲染的方式被計算。其他光源將以球面調和(Spherical Harmonics)的方式進行計算,球面調和技術計算很快但只能得到近似值。根據以下的規則判斷一個光源是否為逐像素光源:
- Lights that have their Render Mode set to?Not Important?are always per-vertex or SH.?
渲染模式被設置為不重要(Not Important)的光源以逐頂點或球面調和的方式進行計算 - Brightest directional light is always per-pixel.?
最亮的方向光源為像素光源 - Lights that have their Render Mode set to?Important?are always per-pixel.?
渲染模式被設置重要(Important)的光源為像素光源 - 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.?
如根據以上規則得到的像素光源數量小于質量設置中的像素光源數量(Pixel Light Count),為了減少亮度,會有更多的光源以逐像素的方式進行渲染
Rendering of each object happens as follows:
用以下的方法渲染每個物體:
- Base Pass applies one per-pixel directional light and all per-vertex/SH lights.?
基礎通道渲染一個逐像素方向光和所有的逐頂點/球面調和光。 - Other per-pixel lights are rendered in additional passes, one pass for each light.?
其他逐像素光在附加的通道中進行渲染,每個光源都需要一個通道
For example, if there is some object that's affected by a number of lights (a circle in a picture below, affected by lights A to H):
例如,如果有一個物體受到若干光源的影響(下圖中的圓圈,受到光源A到H的影響)
?
Let's assume lights A to H have the same color & intensity, all all of them have Auto rendering mode, so they would be sorted in exactly this order for this object. The brightest lights will be rendered in per-pixel lit mode (A to D), then up to 4 lights in per-vertex lit mode (D to G), and finally the rest of lights in SH (G to H):
假設光源A到H都有相同的顏色和強度,且它們的渲染模式都為自動的(Auto),那么它們嚴格的按照其名字排序。最亮的光源以逐像素光照模式的方式進行渲染(A到D),然后最多有4個光源以逐頂點光照模式進行渲染(D到G),其他光源以球面調和的方式進行渲染(G到H)。
?
Note that light groups overlap; for example last per-pixel light blends into per-vertex lit mode so there are less "light popping" as objects and lights move around.
注意不同的光照組間有重疊,如,最后一個逐像素光源也以逐頂點光照模式的方式渲染,這樣能減少當物體和燈光移動時可能出現的"光照跳躍"現象。
Base Pass 基本通道
Base pass renders object with one per-pixel directional light and all SH lights. This pass also adds any lightmaps, ambient and emissive lighting from the shader. Directional light rendered in this pass can have Shadows. Note that Lightmapped objects do not get illumination from SH lights.
基礎通道用一個逐像素方向光和所有球面調和光渲染物體。此通道還負責渲染著色器中的光照貼圖,環境光和自發光。在此通道中渲染的方向光可以產生陰影。需要注意的是,使用了光照貼圖的物體不會得到球面調和光的光照。
Additional Passes 附加通道
Additional passes are rendered for each additional per-pixel light that affect this object. Lights in these passes can't have shadows (so in result, Forward Rendering supports one directional light with shadows).
附加通道用于渲染影響物體的其他逐像素光源。這些通道中渲染的光源無法產生陰影(因此,前向渲染支持一個能產生陰影的方向光)。
Performance Considerations 性能注意事項
Spherical Harmonics lights are?very?fast to render. They have a tiny cost on the CPU, and are?actually free?for the GPU to apply (that is, base pass always computes SH lighting; but due to the way SH lights work, the cost is exactly the same no matter how many SH lights are there).
渲染球面調和光很快。它們只花費很少的CPU計算時間,并且實際上無需花費任何GPU計算時間(換言之,基礎通道會計算球面調和光照,但由于球面調和光的計算方式,無論有多少球面調和光源,計算它們所花費的時間都是相同的)。
The downsides of SH lights are:
球面調和光源的缺點有:
- They are computed at object's vertices, not pixels. This means they do not support light Cookies or normal maps.?
它們計算的是物體的頂點而不是像素。這意味著它們不支持投影遮罩和發現貼圖。 - SH lighting is very low frequency. You can't have sharp lighting transitions with SH lights. They are also only affecting the diffuse lighting (too low frequency for specular highlights).?
球面調和光只有很低的頻率。球面調和光不能產生鋒利的照明過渡。它們也只會影響散射光照(對高光來說,球面調和光的頻率太低了)。 - SH lighting is is not local; point or spot SH lights close to some surface will "look wrong".?
球面調和不是局部的,靠近曲面的球面調和點光和聚光可能會"看起來不正確"。
In summary, SH lights are often good enough for small dynamic objects.
總的來說,球面調和光的效果對小的動態物體來說已經足夠好了。
總結
以上是生活随笔為你收集整理的前向渲染路径细节 Forward Rendering Path Details的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 优达学城数据分析师纳米学位——P5项目知
- 下一篇: springsession 实现sess