What』s 「Shadow Ray Biasing」什麼是「Shadow Ray Biasing」

Note 注意

The shadow ray biasing switch can be found in Redshift』s 「System」 tab.

陰影射線偏置開關可以在Redshift的「系統」選項卡中找到

When a renderer computes shading, it uses the mesh』s vertex normals. This way, if the mesh has smooth normal, the renderer can generate smooth lighting even if the mesh is of a low-tessellation. However, this can create the unfortunate situation where a vertex normal might be able to 『see』 the light which the polygon might not!

渲染器會使用多邊形頂點的法線線計算光影。無論多邊形如何細分(Smooth)法線處理過的表面會產生平滑的光影。但這種處理方式帶來一個問題:有時頂點法線(Vertex Normal)有可能「看」見光影,但實際上多邊形本身其實無法「看到」!

To understand this, let』s look at a picture of a box and a light. The box has smooth normal. The green arrows represent the box』s vertex normals while the red arrows represent its polygon normals. The box』s right polygon cannot 『see』 the light because the light is behind that polygon』s normal. But the top right vertex can see the light (dashed line) because the light if in front of the vertex normal.

要了解這一點,我們來看一個盒子和燈光的照片。 盒子平滑正常。 綠色箭頭表示框的頂點法線,而紅色箭頭表示其多邊形法線。 由於光線在正多邊形的正後方,該盒子的右側多邊形不能「看到」光線。 但右上角的頂點可以看到光線(虛線),因為光線如果在頂點正前方。

When vertex normals 『disagree』 with polygon normals about which lights they can see, the polygon shadows itself! The problem appears mostly on low-poly meshes, like the sphere shown below.

當頂點法線「不一致」與多邊形法線有關,他們可以看到的光,多邊形本身的陰影!問題主要出現在低多邊形網格上,如下圖所示的球體。

Shadow ray biasing is a trick Redshift does in order to avoid self-shadowing artifacts.

陰影射線偏置是Redshift的一個技巧,以避免自陰影瑕疵。

When shadow ray biasing is disabled, polygonal artifacts can appear near the lighting silhouettes

當禁用陰影射線偏移時,多邊形偽影可能出現在照明剪影附近

Redshift performs shadow ray biasing by default in order to avoid such artifacts

Redshift默認執行陰影射線偏置,以避免這種偽像

Different renderers use different techniques to avoid this issue. Some renderers require the user to add a kind of 「epsilon」 on meshes. Redshift attempts to solve this issue automatically by looking at how big the polygon is and also how bent the vertex normals are with respect to the polygon normals. Based on these two factors, it decided how much to 『push』 the shadow ray away from the polygon so that the polygon doesn』t shadow itself!

不同的渲染器使用不同的方法修改這種問題。Redshift是通過分析多邊形的大小,以及與多邊形法線相關的頂點法線彎曲程度來修復的。因此,它將陰影採樣射線從多邊形表面移開陰影採樣射線,使得多邊形不再向其身投影。

Shadow ray biasing problems 帶來的問題

Even though shadow ray biasing can get rid of most self-shadowing issues, it can introduce other types of artifacts in certain situations. For example, if the geometry extremely low-poly and has very 『bent』 vertex normal with regards to the polygons, the rays might be pushed out too much and introduce the opposite problem of self-shadowing: light leaking!

儘管能修正絕大多數Self-Shadowing問題,但是有時他會產生一些其他的問題。如果幾何體沒有足夠的細分而且頂點法線彎曲很大,則可能導致採樣射線向外偏移過多,從而引起與Self-Shadowing相反的問題:Light Leaking(漏光)!

One of the worst-case scenarios for light leaking can be seen on a cube with smooth normals, as shown below. As it can be seen, all sorts of light leaking artifacts appear on the cube, including missed shadows.

光泄漏的最壞情況之一可以在平滑法線的立方體上看到,如下所示。 可以看出,各種各樣的光泄漏工件出現在立方體上,包括錯過的陰影。

The problem here is that we are trying to achieve smooth shading on a surface that is not smooth at all! As a result, the shadow rays are pushed away from the cube too much and 『skip』 the shadow-casting top mesh.

這裡的問題是,我們正在努力在一個不光滑的表面上實現平滑的陰影! 因此,陰影光線被太多地推離立方體,並且「跳過」陰影鑄造頂部網格物體。

Hard edges (normals), of course don』t have this problem, as shown below. That』s because the polygon normal and the vertex normal are now the same.

硬邊(法線)當然沒有這個問題,如下圖所示。 這是因為多邊形法線和頂點法線現在是一樣的。

Shadow ray biasing solutions陰影射線偏置解決方案

So what can we do to fix the above light leaking issue? There are a couple of options.

如何處理Light Leaking問題呢?下面提供了一些方案

  • Disable Shadow Ray Biasing關掉陰影射線偏移

If your scene is already tessellated enough you might not have any self-shadowing artifacts – or they might only be in places that are not seen by the camera. In this case, the quickest way is to globally disable shadow ray biasing.

如果已經場景做了足夠的細分,就不會再出現Self-Shadowing問題,或者它們只出現在攝像機的可見區域之處。此時,最方便的辦法是將Shadow Ray Biasing關閉。

  • Increase tessellation / Modify topology 增加Tessellation/修改模型拓撲結構

As mentioned above, Redshift determines how much to bias the shadow rays depending on the size of the polygons. So one possible solution is to apply a bit of tessellation to the problematic polygons. Smaller polygons will cause less shadow biasing and, therefore, fewer light leaking artifacts.

Shadow Ray Biasing問題與多邊形的大小有關。因此將出問題的多邊形進行細分是解決辦法。多邊形越小,Biasing(偏移量)就越少,Light Leaking問題也越小

Also, if the problems appear mostly near bevels, you can try adding extra edges near the bevels as shown below.

此外,如果問題大多出現在斜面附近,可以嘗試在斜面附近添加額外的邊,如下所示。

The first pair of images show a beveled cube. The mesh is still low-poly and all the edges are smooth. Notice the missing shadows and other artifacts on the cube』s left polygon.

第一組圖片顯示一個倒角過的立方體。這個多邊形物體的細分級別很低且所有邊緣都經過Smooth(法線光滑)。可以看到,立方體左側陰影出現了問題。

By adding an extra edge near the top bevel, the light leaking issues go away:

通過在頂部倒角處增加一條額外的線,Light Leaking問題就能解決。

推薦閱讀:

相關文章