材质与外观
材质与外观是渲染物体时非常重要的属性之一,光线的传播和材质具有密切的关系。
外观是光线与材质共同作用的结果。
材质的定义
在渲染方程中,分析各个参数可以知道材质和 BRDF 具有密切的关系。BRDF 定了物体的材质属性。下图中,从左到右依次是:漫反射材质、光泽表面材质以及折射材质。

材质 = BRDF.
漫反射材质
漫反射材质(Diffuse / Lambertian Material)的性质是当一束光线从任意方向射向材质表面时,将会向各个方向均匀的反射光。
对于漫反射材质,其 BRDF 为:\(f_r\). 所以反射方程为:
\[ \begin{align*} L_o\left(\omega_o\right) &= \int_{H^2}f_rL_i\left(\omega_i\right) \cos \theta_i \, \mathrm{d} \omega_i \\ &= f_rL_i\int_{H^2}\cos\theta_i \mathrm{d} \omega_i \\ &= \pi f_rL_i \end{align*} \]
所以:
\[ f_r = \frac{1}{\pi} \] 引入一个漫反射系数(albedo)来表示颜色(能量的衰减): \[ f_r= \frac{\rho}{\pi} \]
其中 \(\rho \in \left[0, 1\right]\)。
漫反射系数一方面可以表示能量的衰减,另外一方面也可表示颜色。
光泽表面材质和折射材质
光泽表面材质(Glossy material ):一般表示的是金属材质。这些材质相比于镜面来说没有那么光滑,但是依然可以产生非常类似于镜面反射的效果(光线的出射方向非常的集中)。
折射材质(Ideal reflective / refractive material):可以折射一定量的光线。这种材质通常是透明材质,例如玻璃和水。
反射与折射
反射定律
反射定律(Reflection Law):入射角等于出射角。

由出射角等于入射角可知:
\[ \begin{align*} \omega_o + \omega_i &= 2 \cos \theta \vec{n} = 2\left(\omega_i\cdot \vec{n}\right) \vec{n} \\ \omega_o &=-\omega_i + 2\left(\omega_i \cdot \vec{n}\right) \vec{n} \end{align*} \]
如果从平面上面往下看,入射光线和反射光线方向完全相反,也就是 \(\phi_o = \left(\phi_i + \pi\right)\mod 2 \pi\)
折射定律
折射定律(Snell’s Law)反映了折射角和入射角的关系。

折射定律的公式如下:
\[ \eta_i \sin \theta_i=\eta_t \sin \theta_t \]
其中 \(\eta\) 是材质的折射率。如果从平面上面往下看,两条光线方向是相反的。
常见的材质的折射率如下表所示:
材质 | \(\eta\) |
---|---|
真空 | 1.0 |
空气(海平面) | 1.00029 |
水(20 摄氏度) | 1.333 |
玻璃 | 1.5-1.6 |
钻石 | 2.42 |
根据折射定律,我们在知道入射角和法线方向以及材质的折射率的时候就可以求出出射角方向:
\[ \begin{align*} \cos \theta_t & =\sqrt{1-\sin ^2 \theta_t} \\ & =\sqrt{1-\left(\frac{\eta_i}{\eta_t}\right)^2 \sin ^2 \theta_i} \\ & =\sqrt{1-\left(\frac{\eta_i}{\eta_t}\right)^2\left(1-\cos ^2 \theta_i\right)} \end{align*} \]
根号下要为正数才有意义,如果 \(\frac{\eta_i}{\eta_t} > 1\),也就是说当入射介质的折射率大于反射介质的折射率时,有可能发生全反射现象。下图是一个全反射的例子:

菲涅耳项(Fresnel Reflection / Term)
在现实生活中,我们发现有这样的现象:当我们在不同的视角下进行观察的时候会用不同的现象。如下图所示,当我们从不同的视角观察桌子的时候,桌子对书反射的程度也不尽相同。这就是菲涅耳带来的结果。
对于导体和非导体,菲涅耳项满足:
- 对于非导体,入射光线和入射平面越近(入射角越大),被反射出去的光线越多。下图是非导体的反射率和入射角的关系图:

- 对于导体,反射出来光线的多少和入射角度没有直接关系,光线都可以被大量反射出去。下图是导体的反射率和入射角的关系图:

菲涅耳项的准确计算公式为:
\[ \begin{gathered} R_{\mathrm{s}}=\left|\frac{n_1 \cos \theta_{\mathrm{i}}-n_2 \cos \theta_{\mathrm{t}}}{n_1 \cos \theta_{\mathrm{i}}+n_2 \cos \theta_{\mathrm{t}}}\right|^2=\left|\frac{n_1 \cos \theta_{\mathrm{i}}-n_2 \sqrt{1-\left(\frac{n_1}{n_2} \sin \theta_{\mathrm{i}}\right)^2}}{n_1 \cos \theta_{\mathrm{i}}+n_2 \sqrt{1-\left(\frac{n_1}{n_2} \sin \theta_{\mathrm{i}}\right)^2}}\right|^2, \\ R_{\mathrm{p}}=\left|\frac{n_1 \cos \theta_{\mathrm{t}}-n_2 \cos \theta_{\mathrm{i}}}{n_1 \cos \theta_{\mathrm{t}}+n_2 \cos \theta_{\mathrm{i}}}\right|^2=\left|\frac{n_1 \sqrt{1-\left(\frac{n_1}{n_2} \sin \theta_{\mathrm{i}}\right)^2}-n_2 \cos \theta_{\mathrm{i}}}{n_1 \sqrt{1-\left(\frac{n_1}{n_2} \sin \theta_{\mathrm{i}}\right)^2}+n_2 \cos \theta_{\mathrm{i}}}\right|^2 . \end{gathered} \]
\(R_s\) 和 \(R_p\) 是在 s 极点和 p 极点的菲涅耳项,将他们平均一下可得到不极化的菲涅尔项:
\[ R_{\text{eff}} = \frac{1}{2}\left(R_\mathrm{s} + R_\mathrm{p}\right) \]
上述计算太复杂,我们可以做一个近似计算:
\[ \begin{align*} R\left(\theta\right) &= R_0 + \left(1 - R_0\right)\left(1- \cos \theta\right)^5 \\ R_0 &= \left(\frac{n_1 - n_2}{n_1 + n_2}\right)^2 \end{align*} \]
微表面模型(Microfacet Material)
微表面模型是更接近于物理的材质描述。我们认为广表面(Macroscale)是平坦且粗糙的,但是微表面(Microsurface)是凹凸不平但是光滑的(每一个小的面都是光滑平坦的),那么整体的光线反射情况应当是所有微表面反射情况的总和。从近处看是几何,从远处看就是一种材质。
对于任何一种材质,我们使用法线分布来描述其材质。如果是光滑的表面,那么法线分布比较集中;否则,法线会分布在四处。

在微表面的情况下 BDRF 可以写作:
\[ f(\mathbf{i}, \mathbf{o})=\frac{\mathbf{F}(\mathbf{i}, \mathbf{h}) \mathbf{G}(\mathbf{i}, \mathbf{o}, \mathbf{h}) \mathbf{D}(\mathbf{h})}{4(\mathbf{n}, \mathbf{i})(\mathbf{n}, \mathbf{o})} \] 其中,\(\mathbf{F}(\mathbf{i}, \mathbf{h})\) 是菲涅尔项,\(\mathbf{D}(\mathbf{h})\) 是沿着半程向量方向的法线分布,\(\mathbf{G}(\mathbf{i}, \mathbf{o}, \mathbf{h})\) 是一个集合项,微表面内部可能会有几何遮挡,使一些微表面失去了作用。自遮挡容易发生在几乎和反射面平行入射的方 向(Grazing angle)。
材质的分类
将材质分类为各向同性材质(Isotropic Material)和各向异性材质(Anisotropic Material)。
- 各向同性材质(Isotropic Material):各个方向上法线分布一致的材质,满足 \(f_r\left(\theta_i, \phi;\theta_r, \phi_r\right) = f_r\left(\theta_i, \theta_r, \phi_r - \phi_i\right)\).
- 各向异性材质(Anisotropic Material):各个方向上法线分布不一致的材质,有: \(f_r\left(\theta_i, \phi;\theta_r, \phi_r\right) \neq f_r\left(\theta_i, \theta_r, \phi_r - \phi_i\right)\),常见于打磨过的金属,尼龙材料。
BRDF 的性质
- 非负性(Non-negativity)
\[ f_r\left(\omega_i \rightarrow \omega_r \right) \ge 0 \]
- 线性(Linearity)
\[ L_r\left(\mathrm{p}, \omega_r\right) = \int_{H^2}f_r\left(\mathrm{p}, \omega_i \rightarrow \omega_r\right)L_i\left(\mathrm{p}, \omega_i \right) \cos \theta_i \, \mathrm{d} \omega_i \]

- 可逆性(Reciprocity principle)
\[ f_r\left(\omega_r \rightarrow \omega_i\right) = f_r\left(\omega_i \rightarrow \omega_r\right) \]

- 能量守恒(Energy conservation)
\[ \forall \omega_r \int_{H^2}f_r\left(\omega_i \rightarrow \omega_r\right) \cos \theta_i \, \mathrm{d}\omega_i \le 1 \]
- 各向同性 vs. 各向异性
- 对于各向同性:\(f_r\left(\theta_i, \phi_i;\theta_r, \phi_r\right) = f_r\left(\theta_i, \theta_r, \phi_r - \phi_i\right)\).
- 对于各向异性:\(f_r\left(\theta_i, \theta_r, \phi_r - \phi_i\right) = f_r\left(\theta_r, \theta_i, \phi_i - \phi_r\right) = f_r\left(\theta_i, \theta_r, \left|\phi_r - \phi_i\right|\right)\)
BRDF 的测量
我们希望准确的测量出真实世界材质的 BDRF。如下图所示,我们可以通过以下的实验方式测量某一种材质的 BDRF。

我们可以通过这样的装置得到各个入射方向和出射方向的 BDRF,测量的算法如下:
1 | foreach outgoing direction wo |