Material Shaders -Material Ambient Occlusion Shader

Topics in this section本節主題

  • Ambient Occlusion環境閉塞節點
  • Architectural集成通用節點(建築著色器)
  • Bump Map凹凸貼圖節點
  • Bump Blender凹凸混合節點
  • Camera Map相機映射節點
  • Car Paint車漆節點
  • Displacement置換節點
  • Displacement Blender置換混合節點
  • Hair毛髮節點
  • Hair Position毛髮定位節點
  • Hair Random Color隨機毛髮顏色節點
  • Incandescent自發光節點
  • Material
  • Material Blender混合材質節點
  • Matte Shadow Catcher陰影遮罩捕捉節點
  • Normal Map法線貼圖節點
  • Ray Switch分光著色節點
  • Round Corners倒角節點
  • Skin
  • Sprite Node精靈節點
  • Subsurface Scattering次表面散射節點

Ambient Occlusion環境閉塞節點

General常規

Ambient Occlusion is a shading technique that was developed back in the time when

global illumination was impractical. Instead of shooting many rays and bouncing them around (which is what is needed for global illumination), ambient occlusion was used to detect parts of the scene that are occluded from the rest of the environment (such as corners and creases) and darken a constant ambient term or the direct lighting on these areas.

Ambient Occlusion(環境閉塞)是一種使用了比較久遠的技術。當時使用全局照明還是一個代價很高的計算過程。為了避免發射無數射線計算他們在周圍不斷反彈的結果(這是全局照明的原理),使用Ambient Occlusion來探測一個點四周被阻檔的狀況(比如拐角處、裂紋處等)。它以不同程度加深暗部和亮部的細節。

This is demonstrated in the scenes below. Please note that all GI is disabled for these scenes.

以下圖片可以展示這一點。請注意,這些場景渲染都沒有開啟GI。

Constant (0.5, 0.5, 0.5) ambient lighting looks too flat.

當環境色使用常量(0.5, 0.5, 0.5)時,顯得很平。

Ambient Occlusion between (0.0, 0.0, 0.0) and (0.5, 0.5, 0.5) brings out detail

Ambient Occlusion 使得(0.0, 0.0, 0.0)和(0.5, 0.5, 0.5)之間產生了很多細節。

Today』s computers are much more powerful than when Ambient Occlusion was first developed and the use of global illumination is now the norm. This reduces the usefulness of ambient occlusion as a primary lighting technique. However, people still use Ambient Occlusion to achieve different effects such as:

今天的計算機已經比研發出Ambient Occlusion演算法的時代強大很多,使用全局照明已經非常普遍。避免使用Ambient Occlusion已經成為一種主流技術。然而,人們依然願意在以下情況使用Ambient Occlusion。

1. Creating extra darkness/contrast in occluded areas for artistic reasons – when GI has failed to do so and has 『leaked』 too much lighting in these areas (because of multiple bounces)

為了滿足藝術審美,當GI無法提供足夠的場景細節,無法在凹陷區域提供足夠的明暗細節對比時。

2. Using it to implement techniques like 『dirtmaps』 where shading is modified around occluded areas by blending different textures (such as moss)

可以利用它來做舊材質紋理,比如說在AO的暗部混合上不同的紋理,比如Moss苔蘚。

Redshift allows the results of the Ambient Occlusion node to be connected and combined with other rendering techniques which provides the user with a very good degree of flexibility.

Redshift允許將Ambient Occlusion節點輸出到其它節點上,或者結合其他渲染演算法幫助用戶自由選擇使用方式。

Ambient Occlusion Parameters環境閉塞參數

Number of samples採樣數量

Ambient occlusion is a multi-sampled technique, which means that it uses several

samples (rays) per pixel. Thankfully, often times a fairly clean result can be obtain with relatively few samples (such as 32 or 64). Of course, if the Ambient Occlusion node is used to drive other shading nodes that might be of very high contrast, more samples might be needed.

Ambient Occlusion是一種多採樣技術。它在每個像素中使用很多採樣射線。通常很少的採樣次數(比如32或者64)就足以得到比較乾淨的結果。當Ambient Occlusion節點被用來輸出到其到節點產生比較強的對比度時,可能需要更高的採樣值。

Bright/Dark Color 亮部/暗部顏色

The result of the ambient occlusion node is a color. These two parameters define

the darkest possible color (i.e. when the pixel is completely occluded) and the brightest possible color (when the pixel is totally unoccluded).

使用這兩個參數可以讓Ambient Occlusion節點產生有顏色的結果。它們分別定義了最暗的區域(比如很窄的縫隙)和最亮的區域(完全未被阻擋的區域)的顏色。

Spread分散度

Ambient occlusion works by shooting a number of rays for each pixel. These rays are

shot in a hemispherical fashion which produces a smoothly spread out result. The spread parameter makes the rays more concentrated around the pixel』s normal

which allows the AO effect to be 『tightened』. The lower this value is, the tighter the AO effect.

Ambient Occlusion的原理是在每個像素點處發射一系列的射線。這些射線以半球將向周圍方向輻射出去,從而獲得柔和散布的結果。通過調整分散度,可以讓這些像素髮出的射線將更趨向於其法線方向,從而得到AO效果也更密集。值越小,AO效果越密。

Falloff衰減

This allows you to control the tightness of the transition between occluded and un-occluded areas, with values less than 1.0 biasing towards un-occluded and values greater than 1.0 toward occluded.

這個值幫助用戶控制遮擋不同的區域的明暗過渡。比1小的數值傾向於擴大無遮擋區域,大於1則傾向於被遮擋區域。

Maximum Distance最大距離

Each one of the AO rays has a certain length. The larger the length, the more areas

will be considered 『occluded』 and vice-versa. Setting a length of 0.0 will use the maximum ray distance.

每個AO射線都有一個特定長度。射線長度越長,越有機會遇到遮擋物,也就是更傾向於「被遮擋」,反之亦然。設置為0時,意味著最大的長度容限。

Reflective反射

Normally, AO behaves as a 『diffuse』 effect. However, there are some (rare) cases where a user might prefer for AO to behave more like glossy reflection. This option

enables that mode. If 「Reflective」 is enabled, adjusting the spread will make the effect appear more or less glossy.

通常,AO的性質很接近於漫反射,然而,特定情況下(比較少見),AO會表現得更像是反射或者高光。這個選項會激活這個模式,通過調整Spread(分散度)可以控制AO的高光反射模式傾向。

Invert Normal反轉法線

This option allows you to reverse the occlusion effect, whereby open corners will

now receive the occlusion.

這個選項用來使遮擋效果翻轉,從而使開放區域受到遮擋。

Output Mode輸出模式

Normally the result of the AO node is a color that is interpolated between the Bright/Dark colors. This is what happens when 「Occlusion Using Shading Normal」

is selected.

通常情況下AO節點提供的顏色是白與黑之間的顏色,而這種輸出模式是受模式選擇Occlusion

Using Shading Normal(著色器法線決定遮擋)控制的。

When 「Sampled Environment」 is selected the rays will, instead, return the results of

the environment shader scaled by the occlusion. In other words, occluded pixels

will return a dark version of the environment lighting while unoccluded pixels

will return the environment lighting unmodified.

如果選擇Sample Environment(採樣環境),那麼射線將根據遮擋情況返回來 Environment Shader的顏色,也就是被遮擋的區域點,返回的是更暗一些的環境色,而開放的區域點,不受影響。

When 「Return Bent Normals (World Space)」 is selected, the results will be a normal

that is bent away from occlusion

當選擇Return Bent Normals(world Sapce)(基於世界坐標,返回法線調整)時,將得到朝向不被遮擋區域的法線調整值。

Occlusion In Alpha 在Alpha中輸出遮擋

Normally, the alpha channel returned by the AO node contains the interpolated alphas of the Bright/Dark colors. If 「Occlusion In Alpha」 is enabled, the alpha channel is replaced by a value which ranges between 0.0 and 1.0, where 0.0 means 「totally occluded」 and 1.0 means 「totally unoccluded」.

通常,Alpha通道中包含的是Alpha透明信息。如果開啟Occlusion In Alpha,那麼AO節點將向Alpha通道輸出0到1之間的AO信息。0意味著完全被遮蔽區域,1意味著完全開發區域。

Using Ambient Occlusion使用環境遮擋著色器

For this tutorial, we』ll use a simple scene that uses the Ambient Occlusion node

connected directly to the material』s surface input. Even though people don』t

typically use AO like that, doing so will help show the effect of the parameters a bit clearer.

這一部分的內容使用一個簡單的場景,將Ambient Occlusion節點直接連接到材質的Surface輸入埠 (Maya Shading Engine節點Shading Group Attributes>Surface Material 埠或者Redshift>Surface Shading埠)。儘管通常用戶不會這樣使用AO,但這樣做我們可以通過它更清晰的講述參數。

The two images below show the effect of 「Number of Samples」.

下面兩張圖展示了Number of Samples的作用。

「Number of Samples」 set to 1

「Number of Samples」 set to 64 for a cleaner result

In the following example Bright Color was set to green and Dark Color was set to red. Notice how occluded areas are red and unoccluded areas are green.

在下面的例子中,將Bright Color設為綠色,Dark Color設為紅色。注意被遮擋區域是紅的,開發區域是綠色的。

「Bright Color」 set to green and 「Dark Color」 set to red.

Bright Color設為綠色,Dark Color設為紅色。

The following pictures show the effect of the spread. Notice that low spreads create a 『tighter』 effect.

下圖顯示Spread參數的影響。注意,Spread值越小,暗區越緊緻。

「Spread」 0.25

「Spread」 0.5

「Spread」 0.75

「Spread」 1.0

The 「Maximum Distance」 controls how far away geometry has to be from a pixel in order to be considered an 『occluder』. The smaller the 「Maximum Distance」, the tighter and fainter the AO effect is. Please note that, for this scene, the model is approximately 20 units tall.

最大距離射線用於控制距離多遠的多邊形物體可以作為遮擋。這個值越小,AO也就越微弱,請注意,這個例子的模型大致是20單位高。

「Maximum Distance」 1.0.

「Maximum Distance」 4.0

「Maximum Distance」 10.0

The 「Reflective」 parameter makes AO look like glossy reflections. This can be useful if you are combining AO with environment shaders (using the 「Sampled Environment」 output mode explained below) and you only want to show the environment in the reflections. The 「Spread」 parameter controls how glossy these fake reflections are.

Reflective參數使AO看起來很像高光反射。如果只想得到對於環境的反射,可以將AO Environment Shader結合(用Sample Environment輸出模式,下面會解釋)。Spread參數可以用來調整反射的模糊度。

「Reflective」 enabled. 「Spread」 set to 0.5

「Spread」 increased to 0.8. The larger the spread, the blurrier the reflections. Spread增加到0.8。散布度越大,反射效果就越模糊。

When the user uses the output mode 「Return Bent Normals (World Space)」, the AO node will return normals as colors. These normals will be pointing away from occlusion. This functionality will mostly be useful for people that are very experienced with shader networks and could use the bent normal to look up other textures, perform more advanced dirt maps (directionally aware), etc.

如果將輸出模式設置為Return Bent Normals(World Space),AO節點將返回法線的顏色,這些法線將指向不被遮擋的區域。這個功能對於那些熟練掌握節點網格,且能用變向後的法線問題來製作高級貼圖(使用意圖很明確)時很有用。

Bent Normals變向法線

The 「Sampled Environment」 output mode can also be useful when you want to use AO for simple lighting effects. If you have configured your scene to use environment shaders (such as the physical sky or an HDR spherical map), enabling this output mode will skip the usage of the AO』s Dark/Bright colors and will, instead, fetch the colors from the environment shader. The result looks similar to global illumination (Brute-Force) but is typically faster than GI because it skips certain computations (such as multiple GI bounces, for example).

Sampled Environment輸出模式也可以用作模擬簡單的光照。如果用戶為場景設置了Environment Shader(如Physical Sky、HDR貼圖),使用這一輸出模式將不再只渲染黑白顏色,而是能從Environment Shader中提取所需的顏色。渲染結果類似於全局照明(Brute-Force暴力模式),但要快很多。因為這一過程跳過了一些計算步驟(比如多次GI反彈等等)。

The 「Sampled Environment」 output mode can also be useful when you want to use AO for simple lighting effects. If you have configured your scene to use environment shaders (such as the physical sky or an HDR spherical map), enabling this output mode will skip the usage of the AO』s Dark/Bright colors and will, instead, fetch the colors from the environment shader. The result looks similar to global illumination (Brute-Force) but is typically faster than GI because it skips certain computations (such as multiple GI bounces, for example).

Sampled Environment輸出模式也可以用作模擬簡單的光照。如果用戶為場景設置了Environment Shader(如Physical Sky、HDR貼圖),使用這一輸出模式將不再只渲染黑白顏色,而是能從Environment Shader中提取所需的顏色。渲染結果類似於全局照明(Brute-Force暴力模式),但要快很多。因為這一過程跳過了一些計算步驟(比如多次GI反彈等等)。

「Sampled Environment」 output mode. 「Physical Sky」 used for the environment shader.

Sampled Environment輸出模式。用Physical Sky Environment節點

「Sampled Environment」 output mode. 「Reflective」 is enabled. 「Spread」 is set at 0.7.

Sampled Environment輸出模式 Reflective勾選,Spread設置為0.7。

Finally, we』ll show how to use the AO node to achieve 「Dirtmap」-type effects. The 「dirtmap」 technique uses AO to blend between two textures. To achieve this, we』ll use the output of the AO node to drive a 「Mix 2 colors」 node which has two textures connected to its inputs: the brick and the dirt. The 「Mix 2 colors」 node』s mode is set to 「Mix」 (that node can combine the two inputs in many different ways, 「mix」 is just one of them!). The 「weight」 parameter controls how the mix should happen – that』s where we』ll connect our AO node. The output of the mix is then connected a Phong node as both a diffuse and specular map. If we had different specular or normal maps, we could mix those.

最後我們來看看怎麼用AO節點來做舊。做舊技術其實就是使用AO來混合兩種紋理。為了實現這一點,我們用AO的輸出來驅動Mix 2 Color節點,這個節點的兩個輸入端連在兩個紋理節點上:一個是Brick磚塊,一個是Dirt污漬。Mix2 Color節點的模式設為Mix(這個節點有很多種混合輸入紋理的方式,Mix是其中一種)。Weight(權重)參數控制混合如何進行------我們就將AO連到這個埠。然後將Mix節點的輸出連接Phong材質節點的Diffuse和Specular上,假如我們還有其它的高光或者法線貼圖,我們可以用下面Softimage節點流類似的連接方式:

The shader network in Softimage looks like this:

Final result with the dirtmap configuration shown above

上面就是使用了做舊之後的最終效果。

Without the dirtmap (i.e. connecting the brick texture straight into the phong node)

沒有做舊(直接將Brick紋理連到Phong上)

Of course, one could use more exotic ways of configuring the blending. For example, you can use the AO results to drive Redshift』s 「Material Blender」 node which will blend between two materials, instead of textures. Even though blending materials is slower than blending textures, sometimes that』s necessary because blending diffuse, specular and normal maps and connecting the results to a single material node (for example, Phong) is not the same as blending the results for two Phong nodes.

當然,我們還可以用其他特殊方式來配置混合節點。例如,可以用AO的輸出連到Redshift的Material Blender節點上,這可以混合兩種材質而不是紋理。儘管混合材質要比混合紋理速度慢,但有時這是必要的。因為混合漫反射、高光和法線貼圖並將結果輸出給一個單獨的材質(比如說Phong)與混合兩個Phong節點的效果是不同的。


推薦閱讀:

Titan V
Redshift System
Redshift Global Illumination

TAG:redshift | gpu渲染 | 渲染 |