徹底看懂 PBR/BRDF

icewalnut發表於2024-07-24

徹底看懂 PBR/BRDF

知乎- 徹底看懂 PBR/BRDF

本文是在上文的基礎上進行的增減

實時渲染中的 PBR 方程是這樣的

\[L_o= \displaystyle \int_\Omega f_rL_i \cos\theta_i \ \mathrm d\omega_i = \int_{\Omega}(k_d\frac{c}{\pi}+k_s \frac{DFG}{4 \cos\theta_i \cos\theta_o})L_i \cos\theta_i \mathrm \ d \omega_i \tag{0.0} \]

1. L 的單位

1.1 輻亮度是什麼

首先,給上一堆光學和照明中常用概念和單位對比,上面文章中給的還不是很清晰。

參考連結:https://www.zhihu.com/question/407170937/answer/1415758129https://www.cnblogs.com/snake553/p/5206545.html 以及ChatGPT。

  • 發光強度 Luminous Intensity

    • 符號: \(I\) . 國際單位制中,1cd (坎德拉)為一光源在給定方向上的發光強度,該光源發出頻率為 \(540 \times 10^{12} \mathrm {Hz}\) 的單色輻射,且在此方向上的輻射強度為 \(1/683 \mathrm{W/ \textcolor{red}{sr}}\) (瓦特每球面度)
  • 立體角

    • Solid Angle , 符號 : \(\Omega\)

    • 以圓錐體的頂點為球心,半徑為 1 的球面被錐面所截得的面積來度量的,度量單位為 "立體弧度 (steradian,縮寫為 sr)"。立體弧度,又稱為球面弧,可以看作是三維的弧度,是立體角的國際單位。

      • 二維角度 \(\Delta\theta=s/r\)

        • image-20240329181306141
      • 三維角度 \(\Delta\Omega=A/r^2\)

        • image-20240329181358597

        \[\mathrm d\Omega=\frac{\mathrm dA}{r^2} \tag{1.1} \]

  • 光通量 Luminous Flux

    • 符號: \(\Phi\). 從一光源發射出光的量度。單位是流明 lumen, lm。

      \(1 lm\)為發光強度 \(I\)\(1 cd\) 的均勻點光源在 \(1 sr\) 球面度立體角 \(\Omega\) 內發出的光通量 \(\Phi\)流明一般用來作為鎢絲燈與日光燈的量測單位。例如一支 40 W 日光燈管則可產生 2100 lm 的光通量

      • 通量

        • 通量(flux)是一個廣義概念,通常指的是一個向量場透過一個給定表面的“流量”或“量”。這個概念在物理學、工程學和數學中都有應用。

          在物理學中,通量可以表示為一個向量場透過一個給定表面的流量,比如磁通量、電通量或者光通量。

          在數學中,通量可以描述為一個向量場穿過一個給定曲面的“流動”量。在向量場理論中,通量通常用來描述場的強度或者場的流動情況。通常透過對向量場的法向分量在曲面上的積分來計算。

  • Illuminance 照度

    • 符號: \(E\).

    • 定義:在給定表面上單位面積接收到的光通量,也就是光源發射出的光能量落在表面上的密度。

      評價光照環境質量的引數,通常用於建築照明設計、攝影、光學工程等多個領域。

      單位:\(Lux, lx\) 勒克斯。\(1lx=1lm/1m^2\) ,1 流明的光通量均勻分佈在 1 平米麵積上的照度為 1 勒克斯

    • 公式:

      \[E=\Phi/A \tag{1.2} \]

    • 照度的概念不同於 Luminous Intensity 和 Luminance ,它關注的是光源照射在物體表面後的光能量分佈情況,而非光源本身發射光的能力或是物體表面發射光的能力。

  • 光亮度 Luminance

    • 符號 \(L\).

    • 定義: 在一個平面上,單位面積在單位立體角內發出或反射的光通量,它是視覺系統能夠感知到的一個表面亮度屬性。

      光亮度主要反映了光源或者物體表面朝向觀察者方向的光強密度,是一個方向性和麵積相關的物理量。

    • 公式

      \[L=I/S=\frac{\mathrm d^2{\Phi_v}}{\mathrm dA \cdot \mathrm d\Omega} \tag{1.3} \]

      • \(L\) 是光亮度
      • \(\Phi_v\) 是垂直於表面的單位面積 \(dA\) 上,在單位立體角 \(d\Omega\) 內發出或反射的光通量(光通量的視覺貢獻部分
      • \(dA\) 是微小面積
      • \(d\Omega\) 是立體角微分
    • 單位:Luminance 的國際單位是坎德拉每平方米 \(cd/m^2\),也稱為 尼特 \(nit\)

    • 對於一個漫散射面,儘管各個方向的光強和光通量不同,但各個方向的亮度是相等的(後面有證明)。早期電視機的熒光屏就是近似於這樣的漫散射面,所以從各個方向上觀看的影像都有相同的亮度感。早期黑白電視機熒光屏的亮度在120nits左右

幅度學符號 名稱 單位 對應色度學名稱 色度學符號 色度學單位
\(Q\) Radiant Energy 輻射能 焦耳 \(J\) Luminous Energy 光能量 \(Q\) lumen-second 表示光源在一秒內釋放的光的總量
\(\Phi_e\) Radiant flux 幅通量 瓦特 \(W\) Luminous flux 光通量 \(\Phi_v\)
\(v\) 表示 visual,表示光通量是根據人眼對光的感知來定義的
流明,lumen,通常表示為 lm
\(I\) Intensity 輻強度 \(W/sr\) Luminous Intensity 發光強度/光度 \(I_v = \Phi_v/\Omega\) 坎德拉,candela, \(cd=lm/sr\)
\(E\) Irradiance 輻照度 \(W/m^2\) Illuminance 照度 \(E=\Phi_v/A\) 勒克斯 lx, \(lx=lm/m^2\)
\(L\) Radiance 輻亮度 \(W/(m^2sr)\) Lunimance 光亮度 \(L = I/S=\Phi/(\Omega S)\) 尼特 \(nit=lm/(m^2sr)=cd/m^2\)
  • Irradiance 輻照度

    • 符號: \(E\)

    • 定義:單位時間內 垂直於輻射傳播方向上的 單位面積行接收到的輻射能量通量。簡單來說,輻照度 irradiance 就是輻射能量落在某個表面上的強度,即 每平方米麵積上每秒鐘接收到的能量(功率)。

    • 公式:

      \[E=\Phi_e/A \tag{1.4} \]

    • 單位:\(W/m^2\)

  • Radiance 輻亮度

    • 從某一表面或透過某一體積元素,在給定方向上 單位立體角內單位投影面積 和單位波長間隔內的輻射通量。簡單來說,輻亮度衡量的是輻射能量沿特定方向傳輸的密度。

      \[L_e(\omega, \bold n) = \frac{\mathrm d^2 \Phi_e}{\mathrm d A^{\scriptstyle{\perp}} \cdot \mathrm d\Omega} = \frac{\mathrm d^2 \Phi_e}{\cos \theta \cdot \mathrm dA \cdot \mathrm d\Omega} \tag{1.5} \]

    • 這個公式非常重要,是理解一切的基礎

    • 為什麼是 \(\cos \theta\) ,看下圖就知道了

      image-20240405102036751

      穿過座標原點的兩個平面只是為了說明 \(\cos \theta\),並不是真正的 \(\mathrm dA\)

      • \(L_e\): 輻射亮度,單位 \(W/(m^2sr)\)
      • \(\Phi_e\): 透過包含指定點的輻射束截面積 \(\mathrm dA\) 在立體角元 \(\mathrm d\Omega\) 內的幅射通量
      • \(\bold n\): 表面法線方向
      • \(\omega\) : 輻射的方向
      • \(\theta\) : 輻射方向 \(\omega\) 與 表面法線 \(\bold n\) 之間的角度
      • \(\cos \theta\) 用來歸一化輻射強度,\(\mathrm dA\cos\theta\) 是輻射束截面積 \(dA\) 在垂直於 輻射角度 \(\omega\) 的平面內的投影面積

光亮度不隨距離變化的理解

距離變遠之後,雖然到達人眼的光通量變小了,但是形成的影像也小了。(理解通量的定義很好理解這個,這裡不貼證明了,想要證明的直接看原文)

2. BRDF 到底是什麼

首先,根據公式(1.4)

\[E=\Phi_e/A \]

以及公式(1.5)

\[L_e(\omega, \bold n)=\frac{\mathrm d^2\Phi_e}{\cos\theta \mathrm \cdot dA \cdot \mathrm d\Omega} \]

可以計算下整個半球面上面的輻照度 \(E\)

\[E(p) = \displaystyle \int_{\Omega^+} L_i(p, \omega)\cos\theta_i \ \mathrm d\Omega \tag{2.1} \]

在數學和物理中,尤其是光學和輻射傳輸領域,\(\omega\)​ 通常用來表示三維空間中的方向向量,它可以視為從原點指向一個方向的單位向量。儘管如此,當涉及到輻射強度或輻射亮度隨方向變化時,我們確實可以藉助 \(\omega\) 來間接表示立體角 \(\Omega\) 的變化,即立體角微分 \(\mathrm d\Omega\)

在三維空間中,一個完整的立體角 \(\Omega\) 單位是立體弧度(steradian,縮寫為 sr),它描述的是一個圓錐(所有射線匯聚於一點形成的立體角)相對於整個球面的面積比例。當我們談論 dω 時,儘管它不是一個嚴謹的數學符號,但很多時候被當作是立體角 \(\Omega\) 的微小變化的簡寫,即 \(\mathrm d\Omega\)

所以,儘管 \(\omega\) 可以想象為一個二維角度的延伸,但在輻射傳輸的語境下,它實際上代表的是三維空間中的方向,而 \(\mathrm d\omega\) 被用來直觀地表示立體角 \(\Omega\) 的微小增量,其單位仍是立體弧度(sr)。

則輻照度 \(E\) 對 角度 \(\omega_i\) 微分

\[\mathrm dE(p, \omega_i) = L_i(p,\omega_i)\cos\theta_i \ \mathrm d\omega_i \tag{2.2} \]

儘管單位不同,但在表示式 \(\mathrm dE(p, \omega_i) = L_i(p, \omega_i) \cos\theta_i \mathrm d\omega_i\),這裡的 \(\mathrm d\omega_i\) 應該理解為在輻射亮度 \(L_i(p, \omega_i)\) 計算中的立體角微分 \(\mathrm d\Omega\) 的一種簡寫或符號約定。在物理意義和數值上,它們應當是一致的,儘管嚴格來說單位並不相同(立體角的單位是sr,而方向向量本身並沒有明確的單位)。所以在這裡,\(\mathrm d\omega_i\) 更像是借用方向向量符號來表達立體角微分的意思。

2.1 BRDF 定義

以下摘自毛星雲《Real-Time Rendering 3rd 提煉總結》以及 《Real-Time Rendering (2018, CRC Press)》

可以將一個表面著色的過程,理解為給定入射的光線數量和方向,計算出指定方向的出射光亮度(radiance,\(L_o\))。

在 computer graphics 中,BRDF(Bidirectional Reflection Distribution Function,雙向反射分佈函式)是一個用來描述表面如何反射光線的方程。(這裡的雙向,是指 入射光方向出射光方向)。

  • 精確定義

    • 出射輻射率的微分(differential outgoing radiance)和 入射輻照度的微分(differential incoming irradiance) 之比:

    \[f(\bold l, \bold v)=\frac{\mathrm dL_o(\bold v)}{\mathrm dE(\bold l)} \tag{2.3} \]

    \(\bold l\) for incoming light direction

    \(\bold v\) for outgoing view direction

    Real-Time Rendering 2018, Chapter 9, Section3, The BRDF

    \(\bold n\)\(\bold l\) 如下圖

    image-20240406183847492

    • 這裡解釋一下為什麼 \(\bold l\) 是這個方向不是反方向?

      image-20240406184456605

      上圖中是原有的方向,用 \(\displaystyle \cos \theta = \frac{\bold l \cdot \bold n}{|\bold n||\bold l|}\) 可以得到 \(\theta\) ,但是 \(\theta_i\) 是我們想要的,計算更方便,又 \(\displaystyle \cos \theta_i = \cos (\pi -\theta) = - \frac{\bold l \cdot \bold n}{|\bold n||\bold l|} = \frac{(-\bold l) \cdot \bold n}{|\bold n||\bold l|}\) ,所以直接用 \(-\bold l\) 代替 \(\bold l\)

2.2 為什麼用 \(L_o/E\)

因為照射到入射點的不同方向的光,都可能從指定的反射方向出射,所以當考慮入射時,需要對面積進行積分。而輻照度 irradiance 正好表示單位時間內到達單位面積的輻射通量 (\(E=\Phi/A\))。

所以 BRDF 函式選取入射時的輻照度 irradiance \(E\),和出射時的輻亮度 radiance \(L\),可以簡單明瞭地描述入射光線經過某個表面反射後如何在各個出射方向上分佈。

直觀來說,BRDF 的值給定了入射方向和出射方向能量的相對量。

\(E = \Phi/A\)\(L=\displaystyle \frac{\mathrm d^2\Phi}{\cos \theta \mathrm d A \mathrm d\Omega}\) 所以 得 \(\mathrm dE(p, \omega_i)=L_i(p, \omega)\cos \theta_i \mathrm \ d\omega_i\) ,故 BRDF 的單位為 \(sr^{-1}\)


這裡毛星雲大神的解釋沒太看懂,以下是 通義千問 的解釋:

在圖形學和光度學中,BRDF 的這種定義方式確保了其具有以下性質:

  1. 歸一性 Energy Conversation

    考慮整個半球上的入射光,散射出去的光能量不會超過入射光能量,即對於所有的出射方向, BRDF 積分必須 <= 1.

    \[\int_{\Omega}f_r(\omega_o, \omega_i) \cos\theta_i \ \mathrm d\omega_o \le 1 \tag{2.4} \]

  2. 物理意義

    BRDF 描述了光在反射過程中的 能量轉換分佈規律,將入射光的能量分佈轉化為出射光的能量分佈。因此將其作為出射亮度與入射照度的比率是合理的。

  3. 方向相關性

    BRDF 依賴於入射和出射的方向,因此透過這種方式定義的函式可以捕捉到不同材質表面(如鏡面、粗糙表面、各向異性表面等)特有的反射行為。

通義千問給出的公式:

\[f_r(\omega_o, \omega_i) = \frac{\mathrm d L_e(\omega_o)}{\mathrm d E_i(\omega_i)} \tag{2.5} \]

實際上,在某些簡化情況下,特別是在一些圖形學應用中,可能會省略掉 \(\mathrm dE_i\) 分母上的 \(d\omega_i\),因為在理想化的假設下(如均勻照明或者微平面近似下),入射照度可以認為是常數,此時 BRDF 可以直接表示為出射輻亮度和入射輻照度的比例。但是嚴格意義上講,BRDF 應當提現的是兩個方向間亮度微分和照度微分之間的關係。

如果還不懂,看下面的就懂了

為什麼不用 \(L_o/L_i\) 或者 \(E_o/E_i\)

  • 定義目的

    BRDF 旨在描述表面材質如何改變 入射光的方向和能量分佈,使其變為出射光。它關注的是在給定入射光條件下,單位面積上單位立體角的出射輻亮度 radiance 與單位面積上的入射輻照度 irradiance 之間的關係,而不是兩種亮度或者照度之間的直接比例關係。

    這句話我覺得是廢話

  • 物理意義

    入射輻照度 \(E_i\) 是單位面積上接收到的輻射能量通量,而出射輻射亮度 \(L_o\) 是單位面積、單位立體角上發出的輻射能量通量。BRDF 透過 \(L_o/E_i\) 表達了從入射能量轉化到出射方向上的效率和分佈特點。

    這句也是廢話,但是上面兩句廢話還是列在這裡,其實幫助重複理解一下 \(E_i\)\(L_o\) 的定義。

  • 能量守恆

    BRDF 要求滿足能量守恆定律,即入射到物體表面的所有輻射能量不能超過反射出的能量。透過 \(L_o/E_i\) 的形式,可以確保在對所有的出射方向進行積分時,總出射能量不會超過入射能量。

    \(L_o/E_i\) 的形式就能量守恆?用 \(L_o/L_i\) 或者 \(E_o/E_i\) 的形式就可能不遵循能量守恆嗎?為什麼?

    1. 能量守恆的考量
      • 入射輻照度 \(E_i\) 是單位面積上接收到的輻射能量通量,是 所有入射方向能量的總和

最終能讓我大概看懂的Why isn't a BRDF a ratio of radiances? - Computer Graphics Stack Exchange

There are a couple of ways to answer this question: an algebraic way and a geometric way.

Algebraically, we can identify this units that the BRDF must have by looking at its place in the rendering equation. The classic rendering equation is:

\[L_{outgoing}(\omega) = L_{emitted}(\omega) + \int_\Omega L_{incoming}(\omega') f_{BRDF}(\omega, \omega')(n \cdot \omega') \mathrm d\omega' \tag{2.6} \]

The output value on the left is a radiance, so the result of the integral must also be a radiance. The integrand contains a radiance multipled by a solid angle \(\mathrm d\omega'\), so something else in the integrand has to cancel out that factor of solid angle. The \(n \cdot \omega'\) factor is dimentionless, and the only other thing is the BRDF--so to make the whole thing work out, the BRDF must have units of inverse solid angle. Equivalently, the BRDF can be seen as a ratio of radiance to irradiance, since they difer by a factor of solid angle in the denominator of radiance.

  • integrand 被積函式
  • solid angle 立體角
  • denominator 分母

Another way to see it is that the BRDF plays a role similar to a probability density. If you look at how probability densities work, they have units inverse to the volume of their domain. For instance, a 1D probability density has units of inverse length (probability per unit length, but probability itself is dimensionless), a 2D one has units of inverse area, and so on. The BRDF acts much like a probability density defined on the hemisphere, giving a likelihood for a photon coming in from a given direction to be reflected into some other direction. So, like any other probability density on a spherical domain, it has units of inverse solid angle.

Geometrically, we can get right down to brass tacks and take apart what's going on in the integral in the rendering equation. Recall that an integral means to subdivide the domain into many tiny pieces and sum the integrand over all the pieces (in the limit as pieces get infinitesimally small). Let's look at one such piece. The integrand should result in an infinitesimal amount of radiance \(\mathrm dL\), since we are going to sum over many pieces to arrive at a finite outgoing radiance. So a single infinitesimal piece of the integral looks like:

\[\mathrm dL=L_{incoming}f_{BRDF}(n \cdot \omega') \mathrm d\omega' \tag{2.7} \]

  • brass tack 基本事實
  • infinitesimal a. 無窮小的
    • infinitesimally adv. 極小的

If we regroup the factor a bit, the combination \(L_{incoming}(n \cdot \omega') \mathrm d \omega'\) calculates the irradiance on the surface due to the light coming from the infinitesimal solid angle \(\mathrm d\omega'\). Since it's arriving from an infinitesimal amount of solid angle, it produces an infinitesimal irradiance \(\mathrm dE\).

\[\mathrm d L = f_{BRDF}\mathrm dE \tag{2.8} \]

or

\[f_{BRDF} = \frac{\mathrm dL}{\mathrm dE} \tag{2.9} \]

So the BRDF acts as a proportionality constant between the infinitesimal irradiance arriving at the surface from an infinitesimal solid angle, and the infinitesimal outgoing radiance generated thereby. It couldn't be a ratio of radiances, because we have a finite incoming radiance, and we need an infinitesimal outgoing radiance if we want to sum up many pieces of the integral and get a finite result. To make that happen, the BRDF would have to be infinitesimal-valued, which ... isn't a thing, in standard mathematics.

所以 BRDF 作為從無限小的立體角到達表面的無限小的輻照度 irradiance 與 由此產生的無限小的出射輻亮度 radiance 之間的比例常量。

3. 菲涅爾反射

3.1 Fresnel 定律

Fresnel 反射描述一個完全平坦的,由兩個不同折射率介質組成的表面對光的反射率。

在不同的折射率的介質相交表面,光會部分反射且部分折射,反射的比例就是 Fresnel 係數。Fresnel 係數滿足 \(0 \le F_r \le 1\).

已知兩種介質的折射率分別是 \(\eta_i\), \(\eta_t\)。根據斯涅爾定律得到折射角和入射角之間的關係:

\[\eta_i \sin \theta_i = \eta_t \sin \theta_t \tag{3.1} \]

然後根據推導可以得到平行和垂直偏振光的 Fresnel 反射公式:

\[r_{||} = \frac{\eta_t \cos \theta_i - \eta_i \cos \theta_t}{\eta_t \cos \theta_i + \eta_i \cos \theta_t} \tag{3.2} \]

\[r_{\perp} = \frac{\eta_i \cos\theta_i - \eta_t\cos\theta_t}{\eta_i \cos\theta_i + \eta_t \cos \theta_t} \tag{3.3} \]

此處 標註 一下 Fresnel 定律的推導 菲涅耳公式推導 - 知乎 (zhihu.com),感興趣的可以看一下(我只是為了複習下讀研時期的電磁場與電磁波知識)

實時渲染中無需考慮偏振光的影響,得到:

\[F_r = \frac{1}{2}(r_{||}^2 + r_{\perp}^2) \tag{3.4} \]

  • 解釋:

    • 平行 (\(r_{||}\)) 和垂直 (\(r_{\perp}\)​) 偏振光的 Fresnel反射率公式分別描述了不同偏振狀態的光在從一個介質進入另一個介質時的反射率。在自然光(非偏振光)入射的情況下,我們可以認為入射光是由平行和垂直偏振分量組成的,因此總的反射光強是這兩個分量反射光強的疊加。

      \(F_r\) 是總反射率( Fresnel 反射係數的平方),它是平行和垂直偏振分量反射率平方的平均值。這是因為自然光在理想情況下是均勻隨機偏振的,所以各偏振態的反射貢獻應該按各自機率進行統計平均。對於非偏振光,兩種偏振態的能量貢獻是相同的,因此總反射率為兩種偏振態反射率的算術平均的平方,這樣才能保證能量守恆。

      \(r = E'_{1s}/E_{1s}\) (\(E\) 是電場強度 ) 能量對應 \(E^2\) 所以 \(F_r=(r_{||}^2 + r_\perp^2)/2\)

      這是因為在非偏振光照射下,無論光是何種初始偏振狀態,均等機率地表現為平行偏振成分和垂直偏振成分,每種成分單獨的反射率由對應的Fresnel公式給出,它們各自的平方代表了對應偏振態的能量反射比例,因此取平均值就得到了非偏振光總的能量反射比例。

不同材質的Fresnel係數如圖:

img

玻璃、銅、鋁的Fresnel係數

可以看出在觀察角度接近掠奪角(90°)的時候,Fresnel係數都是趨近於 1 的,這種現象叫做Fresnel現象。

接下來要分開討論電介質和金屬:

3.2 電介質

從上圖中可以看出,對於電介質(非金屬)來說,Fresnel係數基本上不會隨著波長變化。

我們現在用 Schlick 來近似表示Fresnel係數:

Christophe Schlick, An Inexpensive BRDF Model for Physically-based Rendering, 1994

將觀察角為 0 時的 Fresnel 係數記為 \(F_0\) ,將兩種介質的折射率比例記為 \(n\),得

\[F_0=(\frac{n+1}{n-1})^2 \tag{3.5} \]

觀察角為 0 則 \(\theta_i=\theta_t = 0\),代入到 (3.2), (3.3), (3.4) 中計算可得 (3.5)

Schilick 近似為

\[F_r \approx F_0 + (1-F_0)(1-\cos\theta_i)^5 \tag{3.6} \]

注意,Schlick 近似不是推導 BRDF 的過程的一部分,反而是先有的 BRDF,後有的 Schlick 近似,可以去看上面的論文。這裡只是簡單講述 Schlick 近似

img

可以看出電介質的 \(F_0\) 一般都很小,在實時渲染中,我們直接取 0.04 作為預設值。

另外需要知道的是,我們這裡的 Fresnel 項是 反射的比例,沒有被反射的部分自然是形成了折射。因為這裡討論的是不透明表面光,折射部分的光傳入介質內部後,部分被吸收,部分再次出射形成漫反射/次表面散射。

img

漫反射的形成

3.3 金屬

電介質和金屬主要區別在於:

3.3.1 金屬的折射率是複數

可表示為 \(\bar{\eta} = \eta+ik\) ([參考文獻](RefractiveIndex.INFO - Refractive index database)),\(k\) 表示吸收率。

這裡菲涅爾公式仍然適用,只是計算起來會複雜一點。

上面我們說電介質的菲涅爾表示反射比例,剩餘的部分是折射。對於金屬來說,因為金屬內部是可以自由運動的電子,其內部自由電子能夠在光子作用下集體震盪,形成等效於連續介電層頂的表面電流,這種現象成為表面等離子體共振(Surface Plasmon Resonance, SPR)。這導致金屬在可見光以及近紅外波段通常具有極高的反射率。根據金屬種類、表面狀態以及入射光的波長和角度,反射率可以非常高,接近甚至達到100%,尤其是在可見光和近紅外波段。

在計算機圖形學中,重點通常放在精確模擬金屬的鏡面反射、高光(specular highlights)以及可能存在的邊緣光 (rim lighting)等現象,漫反射成分相比之下總體外觀影響較小。

3.3.2 金屬的折射率隨光波長變化劇烈

因此在 Schlick 近似時,我們要把 \(F_0\) 用 RGB 三個分量來表示,常見的金屬 \(F_0\) 值如下所示:

img

4. BRDF 如何表示全鏡面反射

對一個全鏡面反射來說,只需要考慮 Fresnel 反射的係數,也就是說

\[L_o(\omega_o) = F_r(\omega_r)L_i(\omega_r) \tag{4.1} \]

式 (4.1) 的由來:只考慮鏡面反射,沒有其他漫反射等等,因此只有 \(\omega_r\)

  • \(\omega_r\) 是什麼?

由式 (0.0) 得:

\[L_o(\omega_o) = \int_\Omega f_r(\omega_o, \omega_i)L_i(\omega_i) \cos\theta_i \ \mathrm d\omega_i \tag{4.2} \]

由 式(4.1) 和 (4.2) 可得:

\[F_r(\omega_r)L_i(\omega_r) = \int_\Omega f_r(\omega_o, \omega_i)L_i(\omega_i) \cos\theta_i \ \mathrm d\omega_i \tag{4.3} \]

要知道 BRDF 如何表示全鏡面反射,其實就是求解 (4.3) 得到 \(f_r(\omega_o, \omega_i)\)

已知 狄拉克函式 (Dirac delta function, \(\textcolor{red}{\delta(x)}\) ) 有如下性質

\[\delta(x) = \left\{ \begin{aligned} & +\infty, && x=0 \\ & 0, && x \neq 0 \end{aligned} \right. \tag{4.4} \]

\[\int_{-\infty}^{+\infty} \delta(x) \mathrm dx=1 \tag{4.5} \]

\[\int_{-\infty}^{+\infty} f(x) \delta(x-x_0) \mathrm dx=f(x_0) \tag{4.6} \]

式 (4.6) 和 (4.3) 比較,令

\[f_r(\omega_o, \omega_i) = F_r(\omega_i) \frac{\delta(\omega_i - \omega_r)}{\cos\theta_i} \tag{4.7} \]

代入 \(\displaystyle \int_\Omega f_r(\omega_o, \omega_i)L_i(\omega_i)\cos\theta_i\mathrm d\omega_i\)

\[\begin{aligned} \int_\Omega f_r(\omega_o, \omega_i)L_i(\omega_i)\cos\theta_i\mathrm d\omega_i &= \int_\Omega F_r(\omega_i) \frac{\delta(\omega_i - \omega_r)}{\cos\theta_i} \cdot L_i(\omega_i) \cdot \cos\theta_i \mathrm d\omega_i \\ &= F_r(\omega_r)L_i(\omega_r) \end{aligned} \]

因此,全鏡面反射的 BRDF 為

\[f_r(p, \omega_o, \omega_i) = F_r(\omega_i) \frac{\delta({\omega_i - \omega_r})}{\cos\theta_i} \tag{4.8} \]

5. 如何理解漫反射

前面講過漫反射的成因:沒有被菲涅爾反射的部分再次出射形成的。

通常用 Lambertian Model 來描述漫反射。

5.1 Lambertian Reflectance

以下摘自 Lambertian reflectance - Wikipedia

Lambertian reflectance is the property that defines an ideal "matte" or diffusely reflecting surface. The apparent brightness of a Lambertian surface to an observer is the same regardless of the observer's angle of view. More precisely, the reflected radiant intensity obeys Lambert's cosine law, which makes the reflected radiance the same in all directions.

  • Examples
    • Unfinished wood exhibits roughly Lambertian reflectance, but wood finished with a glossy coat of polyurethane(聚氨酯) does not, since the glossy coating creates specular highlights. Though not all rough surfaces are Lambertian, this is often a good approximation, and is frequently used when the characteristics of the surface are unknown.

Use in computer graphics

undefined

In computer graphics, Lambertian reflection is often used as a model for diffuse reflection. This techneque causes all closed polygons (such as a triangle within a 3D mesh) to reflect light equally in all directions when rendered. The reflection decreases when the surface is tilted away from being perpendicular to the light source, however, because the area is illuminated by a smaller fraction of the incident radiation.

The reflection is calculated by taking the dot product of the surface's unit normal vector, \(\vec{N}\), and a normalized light-direction vector \(\vec{L}\), pointing from the surface to the light source. This number is then multiplied by the color of the surface and the intensity of the light hitting the surface:

\[B_D = \vec{L} \cdot \vec{N}CI_L \tag{5.1} \]

  • \(B_D\)
    • brightness of the diffusely reflected light
  • \(C\) color
  • \(I_L\) intensity of the cincoming light

Because $\vec{L} \cdot \vec{N} = \cos\alpha $ where \(\alpha\) is the angle between the directions of the two vectors, the brightness will be highest if the surface is perpendicular to the light vector, and lowest if the light vector intersects the surface at a grazing angle.

  • tilted
    • adj. 傾斜的

簡單來說,表面法線為 \(\vec{N}\) (歸一化向量), 入射光線歸一化向量 \(\vec{L}\) 與表面法線的夾角為 \(\alpha\),$\vec{L} \cdot \vec{N} = \cos\alpha $

5.2 Lambertian Model

PBR Step by Step(四)Lambertian反射模型

上面這個連結講的挺好,和 知乎- 徹底看懂 PBR/BRDF 這裡講的大差不差

這裡主要融合這兩篇

在 Lambertian 漫反射模型下,由能量守恆知 (\(c\) 是反照率或者固有色,是光在介質內部出射部分的比例\(1-c\) 表示被介質吸收的比例)

\[\int_\Omega f_r(\omega_o, \omega')\cos \theta \ \mathrm d\omega' = c \tag{5.2} \]

PBR Step by Step(四)Lambertian反射模型 這篇文章中提到了

反射率

\[\rho_d(p) = \frac{\mathrm d \phi_o}{\mathrm d\phi_i} \tag{5.3} \]

又因為,在整個 Lambertian 表面半球積分中 (\(\Omega_o = 2\pi\)) 中,出射通量

\[\mathrm d\Phi_o = \mathrm d A L_r(p) \int_{2\pi} \cos \theta_i \ \mathrm d\omega_o = \mathrm dAL_r(p) \pi \tag{5.4} \]

式中的 \(\displaystyle \int_{2\pi} \cos \theta_o \mathrm d\omega_o = \pi\) 推導如下

複習下球面積分,看 Triple Integrals in Spherical Coordinates(球座標中的三重積分) - 知乎 (zhihu.com)

簡單來講,看這張圖

image-20240419113820676

和這張圖就能大致回憶起來了

image-20240419113859736 image-20240419133437854
  • \(r = \rho \sin\phi\)
  • $x=r\cos\theta = \rho\sin\phi\cos\theta $
  • $y=r\sin\theta = \rho\sin\phi\sin\theta $
  • \[z=\rho\cos\phi \]

\[\int\int\int_E f(x,y,z)\mathrm dV = \int_a^b \int_\alpha^\beta \int_\gamma^\delta f(\rho\sin\phi\cos\theta, \rho\sin\phi\cos\theta, \rho\cos\phi) \textcolor{red}{\rho^2\sin\theta} \mathrm d\rho \mathrm d\phi \mathrm d\theta \]

入射通量

\[\mathrm d \Phi_i = \mathrm d A \int_{2\pi} L_i(p, \omega_i) \cos \theta_i \ \mathrm d \omega_i = \mathrm dA E_i(p) \tag{5.5} \]

  • 反射率 \(\textcolor{red}{\rho_d}\)

\[\rho_d(p) = \frac{\mathrm d\Phi_o}{\mathrm d\Phi_i} = \frac{L_r(p)\pi}{E_i(p)} = f_r(p)\pi \tag{5.6} \]

這樣,我們就得到了 Lambertian BRDF:

\[\textcolor{red}{f_r(p) = \frac{\rho_d(p)}{\pi}} \tag{5.7} \]

這裡 \(\rho_d\) 可以用常數項表示,\(\rho_d = k_dc_d\)

  • 漫反射係數 \(k_d\), \(k_d \in [0, 1]\)
  • 漫反射顏色 \(c_d\)

Lambertian BRDF 又可以寫為:

\[f_r(p) = \frac{k_dc_d}{\pi} \tag{5.8} \]


另一種解釋:

Lambertian 漫反射假設在所有方向上觀察亮度都是相同的,因此 漫反射的 BRDF 中 \(f_r\)\(\omega_i, \omega'\) 是無關的,是一個常數(\(f_r(p, \omega_o, \omega_i)\)\(\omega_i\)\(\omega_o\) 無關,則變成 \(f_r(p)\)),將 \(f_r\) 提到外面得

\[f_r\int_\Omega \cos\theta \mathrm d\omega' = c \]

\[f_r\int_0^{2\pi} \mathrm d\phi \int_0^{{\pi}/{2}}\cos\theta \sin\theta \ \mathrm d\theta = f_r \pi = c \]

\[f_r = \frac{c}{\pi} \]

前面說過 BRDF 的作用之一就是將輻照度 \(E\) 轉換為輻亮度 \(L\) ,這裡的 \(\displaystyle \frac{1}{\pi}\) 也可以看做是一個用來實現轉換的係數。

現實生活中的漫反射並不是完全符合 Lambertian 漫反射模型的,Oren–Nayar reflectance model 模型等一些更加複雜的模型可以更好地表示現實中的漫反射。但是在實際渲染中,使用更加複雜的模型的提升很小。出於效能考慮,目前在實時渲染中 Lambertian 模型還是主流。

6. 微表面模型鏡面反射

參考文獻:Microfacet Models (pbr-book.org)

以及 Bruce Walter - Microfacet Models for Refraction through Rough Surfaces, Eurographics Symposium on Rendering (2007)

\[f(i, o) = \frac{F(i, h)G(i, o, h)D(h)}{4(\vec{n} \cdot \vec{i})(\vec{n} \cdot \vec{o})} \]

未完待續...

相關文章