本章通过几何光学的视角建立计算机图形学的数学基础。我们将渲染方程作为核心框架,介绍关键的辐射度量概念,并建立路径积分表述,这将统一所有后续的渲染技术。通过将光传输视为高维积分问题,我们为理解基于点的渲染、基于图像的渲染和神经渲染方法作为解决同一基本方程的不同方法奠定了基础。
完成本章后,您将能够:
在几何光学中,我们使用光线来建模光的传播——在均匀介质中沿直线传播的无限细光束。当波长 $\lambda \ll$ 特征尺寸时,这种近似成立,使我们可以忽略衍射和干涉。光线参数化为:
$\mathbf{r}(t) = \mathbf{o} + t\mathbf{d}$
| 其中 $\mathbf{o} \in \mathbb{R}^3$ 是原点,$\mathbf{d} \in \mathbb{R}^3$ 是方向($ | \mathbf{d} | = 1$),$t \ge 0$ 是沿光线的参数。 |
光线方程源自程函方程 $\nabla S = n\mathbf{\hat{k}}$ 在 $\lambda \to 0$ 极限下的结果,其中 $S$ 是相位,$n$ 是折射率。在非均匀介质中,光线遵循满足以下方程的曲线路径:
$\frac{d}{ds}\left(n \frac{d\mathbf{r}}{ds}\right) = \nabla n$
当 $n$ 为常数时,这简化为直线。
与波动光学的联系:几何光学近似源自波动方程的WKB(Wentzel-Kramers-Brillouin)近似。当我们将 $\psi = A \exp(ikS)$ 代入亥姆霍兹方程并取 $k \to \infty$ 时:
$\nabla^2\psi + k^2n^2\psi = 0 \to (\nabla S)^2 = n^2$ (程函方程)
等相位面 $S = \text{const}$ 是波前,光线是这些波前的正交轨迹。当我们在后续章节扩展到波动光学时,这种联系变得至关重要。
光线光学的有效性:几何光学近似在以下情况下失效:
费马原理:光线遵循光程稳定的路径:
$\delta\int n(\mathbf{r}) ds = 0$
这个变分原理统一了光线行为:在均匀介质中的直线、界面处的斯涅尔定律以及梯度折射率介质中的曲线路径。它还与物理学中的最小作用量原理和微分几何中的测地线方程相关联。
在推导渲染方程之前,我们必须建立辐射度量框架。这些量形成一个层次结构,每个都建立在前一个的基础上:
辐射能 $Q$ 测量总电磁能量: $Q \text{ [J]}$
辐射通量(功率) $\Phi$ 测量单位时间的能量: $\Phi = \frac{dQ}{dt} \text{ [W]}$
辐射强度 $I$ 测量点源单位立体角的通量: $I = \frac{d\Phi}{d\omega} \text{ [W/sr]}$
辐照度 $E$ 测量入射单位面积的通量: $E = \frac{d\Phi}{dA} \text{ [W/m}^2\text{]}$
辐射出射度 $M$ 测量离开单位面积的通量: $M = \frac{d\Phi}{dA} \text{ [W/m}^2\text{]}$
辐射率 $L$ 测量单位面积单位立体角的通量: $L = \frac{d^2\Phi}{dA \cos \theta d\omega} = \frac{d^2\Phi}{dA_\perp d\omega} \text{ [W/(m}^2\text{·sr)]}$
其中 $dA_\perp = dA \cos \theta$ 是垂直于光线方向的投影面积。
辐射率是渲染中的基本量,因为:
光度量与辐射度量:虽然我们关注辐射度量(物理能量),但为人类感知进行渲染时通常使用光度量:
光谱辐射率:实际上,辐射率随波长变化: $L(\mathbf{x}, \omega, \lambda) \text{ [W/(m}^2\text{·sr·nm)]}$
对于渲染,我们通常使用:
相干与非相干叠加:辐射度量假设非相干光——强度直接相加。对于相干光源(激光),我们必须跟踪相位并叠加复振幅: $I_{\text{total}} = |E_1 + E_2|^2 \neq |E_1|^2 + |E_2|^2$ (一般情况下)
渲染方程由Kajiya(1986)提出,描述场景中光的平衡分布。它源于功率平衡:在任何表面点,输出功率等于发射功率加反射功率。
在具有法线 $\mathbf{n}$ 的表面点 $\mathbf{x}$ 处,沿方向 $\omega_o$ 的出射辐射率 $L_o$ 满足:
$L_o(\mathbf{x}, \omega_o) = L_e(\mathbf{x}, \omega_o) + \int_\Omega f_r(\mathbf{x}, \omega_i, \omega_o) L_i(\mathbf{x}, \omega_i) (\omega_i \cdot \mathbf{n}) d\omega_i$
其中:
积分表示散射积分——对所有入射方向的贡献求和,由BRDF和余弦投影加权。
能量守恒约束BRDF。方向-半球反射率(反照率)必须满足:
$\rho(\omega_o) = \int_\Omega f_r(\mathbf{x}, \omega_i, \omega_o) \cos \theta_i d\omega_i \le 1$ 对所有 $\omega_o$
对于无损表面,等号成立。白炉测试验证能量守恒:在均匀照明环境中($L_i = L_0$),封闭表面既不应获得也不应失去能量。
详细能量平衡:对于表面元素 $dA$,守恒要求:
$\int_\Omega L_o(\mathbf{x}, \omega) \cos \theta d\omega dA = L_e dA + \int_\Omega L_i(\mathbf{x}, \omega) \cos \theta d\omega dA$
在热平衡的封闭系统中,基尔霍夫定律将发射率与吸收率关联: $\varepsilon(\lambda, \theta) = \alpha(\lambda, \theta) = 1 - \rho(\lambda, \theta)$
测量方程:测量方程将场景辐射率与传感器响应联系起来:
$I_j = \int_A \int_\Omega W_j(\mathbf{x}, \omega) L(\mathbf{x}, \omega) \cos \theta d\omega dA$
其中 $W_j(\mathbf{x}, \omega)$ 是像素 $j$ 的重要性(灵敏度)函数。辐射率和重要性之间的这种对偶性使双向算法成为可能。
重要性传输:重要性满足伴随方程:
$W(\mathbf{x}, \omega) = W_e(\mathbf{x}, \omega) + \int_\Omega f_r(\mathbf{x}, \omega, \omega’) W(\mathbf{x}, \omega’) \cos \theta’ d\omega’$
这种对称性导致:
对于针孔相机,像素 $j$ 从针孔张成立体角 $\Omega_j$:
$I_j = \int_{\Omega_j} L(\mathbf{x}_{\text{lens}}, \omega) \cos^4 \theta d\omega$
$\cos^4 \theta$ 项考虑了:
有限孔径相机:对于具有孔径 $A_{\text{lens}}$ 的真实相机:
$I_j = \frac{1}{A_{\text{lens}}} \int_{A_{\text{lens}}} \int_{A_{\text{pixel}}} L(\mathbf{x}{\text{lens}} \to \mathbf{x}{\text{pixel}}) G(\mathbf{x}{\text{lens}} \leftrightarrow \mathbf{x}{\text{pixel}}) dA_{\text{pixel}} dA_{\text{lens}}$
这导致景深效果并需要仔细的采样策略。
渲染方程允许优雅的算子表述。定义传输算子 $\mathcal{T}$:
$(\mathcal{T}L)(\mathbf{x}, \omega) = \int_\Omega f_r(\mathbf{x}, \omega’, \omega) L(\mathbf{x}, \omega’) (\omega’ \cdot \mathbf{n}) d\omega’$
则渲染方程变为:
$L = L_e + \mathcal{T}L$
这是第二类弗雷德霍姆方程。通过诺伊曼级数的解:
$L = (I - \mathcal{T})^{-1}L_e = \sum_{k=0}^\infty \mathcal{T}^k L_e = L_e + \mathcal{T}L_e + \mathcal{T}^2L_e + \dots$
每项都有物理意义:
| 当 $ | \mathcal{T} | < 1$ 时级数收敛,这在最大反照率 $< 1$ 时发生。这种分解自然导致采样路径长度递增的路径追踪算法。 |
渲染方程可以改写为三点形式,使几何耦合明确:
$L(\mathbf{x} \to \mathbf{x}’) = L_e(\mathbf{x} \to \mathbf{x}’) + \int_M f_r(\mathbf{x}’’ \to \mathbf{x} \to \mathbf{x}’) L(\mathbf{x}’’ \to \mathbf{x}) G(\mathbf{x}’’ \leftrightarrow \mathbf{x}) dA(\mathbf{x}’’)$
其中几何因子是:
| $G(\mathbf{x} \leftrightarrow \mathbf{x}’) = V(\mathbf{x} \leftrightarrow \mathbf{x}’) \frac{\cos \theta \cos \theta’}{ | \mathbf{x} - \mathbf{x}’ | ^2}$ |
其中:
| $ | \mathbf{x} - \mathbf{x}’ | ^2$:平方反比衰减的平方距离 |
这种形式强调光传输耦合所有表面点,导致路径积分表述。
可见性复杂性:可见性函数 $V(\mathbf{x} \leftrightarrow \mathbf{x}’)$ 使渲染方程成为非线性和非局部的:
核函数性质:传输核 $K(\mathbf{x}’’ \to \mathbf{x}) = f_r G V$ 具有重要性质:
与热方程的联系:没有可见性时,渲染方程类似于具有非局部核的热方程。这个类比有助于理解:
渲染管线涉及坐标系统层次结构,每个都针对特定计算进行优化:
齐次坐标统一了平移和线性变换。3D点 $\mathbf{p} = (x, y, z)$ 变为 $\mathbf{\tilde{p}} = (x, y, z, 1)$,而向量使用 $\mathbf{\tilde{v}} = (x, y, z, 0)$。
一般仿射变换矩阵:
$\mathbf{M} = \begin{bmatrix} \mathbf{A} & \mathbf{t} \ \mathbf{0} & 1 \end{bmatrix}$
其中 $\mathbf{A}$ 是3$\times$3线性部分,$\mathbf{t}$ 是平移。常见变换:
平移 ($t_x, t_y, t_z$): $\begin{bmatrix} 1 & 0 & 0 & t_x \ 0 & 1 & 0 & t_y \ 0 & 0 & 1 & t_z \ 0 & 0 & 0 & 1 \end{bmatrix}$
绕轴 $\mathbf{a}$ 旋转角度 $\theta$: $\mathbf{R} = \cos \theta \mathbf{I} + (1 - \cos \theta) \mathbf{a}\mathbf{a}^T + \sin \theta [\mathbf{a}]_\times$
其中 $[\mathbf{a}]_\times$ 是反对称叉积矩阵。
缩放 ($s_x, s_y, s_z$): $\begin{bmatrix} s_x & 0 & 0 & 0 \ 0 & s_y & 0 & 0 \ 0 & 0 & s_z & 0 \ 0 & 0 & 0 & 1 \end{bmatrix}$
法线必须变换以保持与表面垂直。给定点的变换 $\mathbf{M}$:
| $\mathbf{n}’ = \frac{(\mathbf{M}^{-T})^{3\times3} \mathbf{n}}{ | (\mathbf{M}^{-T})^{3\times3} \mathbf{n} | }$ |
证明:对于表面上的切线 $\mathbf{t}$,$\mathbf{n} \cdot \mathbf{t} = 0$。变换后: $\mathbf{n}’ \cdot \mathbf{t}’ = (\mathbf{M}^{-T}\mathbf{n}) \cdot (\mathbf{M}\mathbf{t}) = \mathbf{n}^T \mathbf{M}^{-1} \mathbf{M} \mathbf{t} = \mathbf{n} \cdot \mathbf{t} = 0$
对于正交标架 ${\mathbf{t}, \mathbf{b}, \mathbf{n}}$:
面积和体积元素:在变换 $\mathbf{M}$ 下,微分元素缩放为:
| 长度:$dl’ = | \mathbf{M}\mathbf{v} | dl$(对于方向 $\mathbf{v}$) |
| 面积:$dA’ = | \det(\mathbf{M}) | (\mathbf{M}^{-T})\mathbf{n} | dA$ |
| 体积:$dV’ = | \det(\mathbf{M}) | dV$ |
非均匀缩放问题:非均匀缩放破坏各向同性:
手性保持:当 $\det(\mathbf{M}) < 0$ 时,变换翻转方向:
球面坐标为方向提供自然参数化:
$\omega = (\sin \theta \cos \phi, \sin \theta \sin \phi, \cos \theta)$
其中:
雅可比给出微分立体角:
| $d\omega = \left | \frac{\partial(\omega_x, \omega_y)}{\partial(\theta, \phi)}\right | d\theta d\phi = \sin \theta d\theta d\phi$ |
半球总立体角:$\int_\Omega d\omega = 2\pi$
用于采样的替代参数化:
同心圆盘映射(Shirley-Chiu): $(u, v) \in [-1, 1]^2 \to (r, \phi) \to (x, y)$ 在单位圆盘上
八面体映射: 单位球面 $\to$ 八面体 $\to$ 单位正方形 比球面坐标更好地保持面积
积分的一般变量替换公式:
| $\int_\Omega f(\mathbf{x}) d\mathbf{x} = \int_{\Omega’} f(\mathbf{x}(\mathbf{u})) \left | \det\left(\frac{\partial\mathbf{x}}{\partial\mathbf{u}}\right)\right | d\mathbf{u}$ |
对渲染至关重要:
立体角到面积: $\int_\Omega L(\mathbf{x}, \omega) \cos \theta d\omega = \int_A L(\mathbf{x}, \omega(\mathbf{x}’)) G(\mathbf{x} \leftrightarrow \mathbf{x}’) dA’$
| 其中 $G(\mathbf{x} \leftrightarrow \mathbf{x}’) = V(\mathbf{x} \leftrightarrow \mathbf{x}’) \frac{\cos \theta \cos \theta’}{ | \mathbf{x} - \mathbf{x}’ | ^2}$ |
半球到圆盘(用于余弦加权采样): 映射 $(\theta, \phi) \to (r, \phi)$ 其中 $r = \sin \theta$ 则 $p(r, \phi) = p(\theta, \phi) \left|\frac{\partial(\theta, \phi)}{\partial(r, \phi)}\right| = \frac{p(\theta, \phi)}{\cos \theta}$
测度论基础:变量替换公式具有测度论基础:
透视投影矩阵将视锥体映射到裁剪空间:
$\mathbf{P} = \begin{bmatrix}
n/r & 0 & 0 & 0
0 & n/t & 0 & 0
0 & 0 & -(f+n)/(f-n) & -2fn/(f-n)
0 & 0 & -1 & 0
\end{bmatrix}$
其中 $n, f$ 是近/远平面,$r, t$ 是近平面的右/顶。
透视除法后:
重要性质:
对于具有顶点 $\mathbf{v}_0, \mathbf{v}_1, \mathbf{v}_2$ 的三角形,重心坐标 $(u, v, w)$ 满足:
$\mathbf{p} = u\mathbf{v}_0 + v\mathbf{v}_1 + w\mathbf{v}_2$
约束条件 $u + v + w = 1$。通过面积计算:
$u = \frac{\text{Area}(\mathbf{p}, \mathbf{v}_1, \mathbf{v}_2)}{\text{Area}(\mathbf{v}_0, \mathbf{v}_1, \mathbf{v}_2)}$
性质:
透视正确的属性插值:
在每个表面点,我们构建用于着色计算的局部标架:
切空间基:
第一基本形式:度量张量描述局部表面几何: $\mathbf{I} = \begin{bmatrix} E & F \ F & G \end{bmatrix}$
其中:
弧长:$ds^2 = E du^2 + 2F du dv + G dv^2$ 面积元素:$dA = \sqrt{EG - F^2} du dv$
第二基本形式:描述表面曲率: $\mathbf{II} = \begin{bmatrix} e & f \ f & g \end{bmatrix}$
其中 $e = \mathbf{n} \cdot \frac{\partial^2\mathbf{p}}{\partial u^2}$ 等。
主曲率 $\kappa_1, \kappa_2$ 是 $\mathbf{II}\mathbf{I}^{-1}$ 的特征值
世界空间的变换: $\begin{bmatrix} \mathbf{t}{\text{world}} \ \mathbf{b}{\text{world}} \ \mathbf{n}{\text{world}} \end{bmatrix} = \begin{bmatrix} t_x & t_y & t_z \ b_x & b_y & b_z \ n_x & n_y & n_z \end{bmatrix} \begin{bmatrix} \mathbf{t}{\text{local}} \ \mathbf{b}{\text{local}} \ \mathbf{n}{\text{local}} \end{bmatrix}$
这个正交矩阵可以通过转置求逆。
各向异性BRDF参数化: 许多BRDF依赖于相对于切线的角度:
平行传输:在表面上追踪光线时,切标架必须平行传输:
BRDF $f_r$ 量化入射辐照度和反射辐射率之间的微分关系:
$f_r(\mathbf{x}, \omega_i, \omega_o) = \frac{dL_o(\mathbf{x}, \omega_o)}{dE_i(\mathbf{x}, \omega_i)} = \frac{dL_o(\mathbf{x}, \omega_o)}{L_i(\mathbf{x}, \omega_i) \cos \theta_i d\omega_i} \text{ [sr}^{-1}\text{]}$
物理上,它表示来自方向 $\omega_i$ 的光子散射到方向 $\omega_o$ 的概率密度(归一化后)。
BRDF可以分解为分量: $f_r = f_d + f_s + f_g + \dots$
其中 $f_d$ 是漫反射,$f_s$ 是镜面反射,$f_g$ 是光泽反射等。这种分解有助于重要性采样。
亥姆霍兹互易性: $f_r(\mathbf{x}, \omega_i, \omega_o) = f_r(\mathbf{x}, \omega_o, \omega_i)$
这源自麦克斯韦方程的时间反演对称性和细致平衡原理。它使双向路径追踪和光子映射成为可能。
能量守恒: 方向-半球反射率必须满足:
$\rho(\omega_i) = \int_\Omega f_r(\mathbf{x}, \omega_i, \omega_o) \cos \theta_o d\omega_o \le 1$ 对所有 $\omega_i$
对于能量守恒的BRDF,当吸收为零时等号成立。半球-半球反射率:
$\rho_{hh} = \frac{1}{\pi} \int_\Omega \int_\Omega f_r(\mathbf{x}, \omega_i, \omega_o) \cos \theta_i \cos \theta_o d\omega_i d\omega_o \le 1$
非负性: $f_r(\mathbf{x}, \omega_i, \omega_o) \ge 0$
负值将意味着依赖于出射方向的能量吸收,违反因果性。
可测性和可积性: 对于蒙特卡洛积分收敛: $f_r \in L^2(\Omega \times \Omega)$ (平方可积)
朗伯(完全漫反射): $f_r = \frac{\rho_d}{\pi}$
其中 $\rho_d \in [0, 1]$ 是漫反射率。构造上能量守恒。
Phong模型: $f_r = \frac{\rho_d}{\pi} + \rho_s \frac{n+2}{2\pi} (\mathbf{r} \cdot \omega_o)^n$
其中 $\mathbf{r} = 2(\mathbf{n} \cdot \omega_i)\mathbf{n} - \omega_i$ 是反射方向。不满足互易性!
Blinn-Phong(互易): $f_r = \frac{\rho_d}{\pi} + \rho_s \frac{n+2}{8\pi} \frac{(\mathbf{n} \cdot \mathbf{h})^n}{\max(\cos \theta_i, \cos \theta_o)}$
| 其中 $\mathbf{h} = \frac{\omega_i + \omega_o}{ | \omega_i + \omega_o | }$ 是半向量。 |
Cook-Torrance微面元模型: $f_r = \frac{\rho_d}{\pi} + \frac{D(\mathbf{h})G(\omega_i, \omega_o)F(\omega_i, \mathbf{h})}{4 \cos \theta_i \cos \theta_o}$
其中:
双向散射分布函数(BSDF)统一了反射和透射:
$f_s(\mathbf{x}, \omega_i, \omega_o) = \begin{cases}
f_r(\mathbf{x}, \omega_i, \omega_o) & \text{如果 } \omega_i \cdot \mathbf{n} \text{ 和 } \omega_o \cdot \mathbf{n} \text{ 同号}
f_t(\mathbf{x}, \omega_i, \omega_o) & \text{如果 } \omega_i \cdot \mathbf{n} \text{ 和 } \omega_o \cdot \mathbf{n} \text{ 异号}
\end{cases}$
对于电介质界面(如玻璃),斯涅尔定律控制折射: $n_i \sin \theta_i = n_o \sin \theta_o$
菲涅尔方程确定反射/透射概率: $F_r = \left(\frac{n_i \cos \theta_i - n_o \cos \theta_o}{n_i \cos \theta_i + n_o \cos \theta_o}\right)^2$ (s偏振)
BTDF的广义互易性: 由于界面上的辐射率压缩/扩展:
$n_i^2 f_t(\mathbf{x}, \omega_i, \omega_o) = n_o^2 f_t(\mathbf{x}, \omega_o, \omega_i)$
这解释了辐射率 $L/n^2$ 不变中的 $n^2$ 因子。
双向散射表面反射分布函数将BRDF推广到非局部传输:
$S(\mathbf{x}_i, \omega_i, \mathbf{x}_o, \omega_o) = \frac{dL_o(\mathbf{x}_o, \omega_o)}{d\Phi_i(\mathbf{x}_i, \omega_i)} \text{ [m}^{-2}\text{sr}^{-1}\text{]}$
与BRDF的关键区别:
带BSSRDF的渲染方程:
$L_o(\mathbf{x}o, \omega_o) = L_e(\mathbf{x}_o, \omega_o) + \int_A \int\Omega S(\mathbf{x}_i, \omega_i, \mathbf{x}_o, \omega_o) L_i(\mathbf{x}_i, \omega_i) \cos \theta_i d\omega_i dA_i$
扩散近似: 对于高散射介质,BSSRDF可以近似为:
| $S(\mathbf{x}_i, \omega_i, \mathbf{x}_o, \omega_o) \approx \frac{1}{\pi}F_t(\omega_i)R( | \mathbf{x}_i - \mathbf{x}_o | )F_t(\omega_o)$ |
其中 $R(r)$ 是扩散轮廓,$F_t$ 是菲涅尔透射率。
物理有效的BRDF必须满足:
对于具有方向结构的材料(拉丝金属、织物、毛发),BRDF依赖于方位角:
$f_r(\mathbf{x}, \omega_i, \omega_o, \phi)$
其中 $\phi$ 是半向量投影与切线方向之间的角度。
Ward各向异性模型: $f_r = \frac{\rho_d}{\pi} + \frac{\rho_s \exp\left(-\tan^2\theta_h\left(\frac{\cos^2\phi}{\alpha_x^2} + \frac{\sin^2\phi}{\alpha_y^2}\right)\right)}{4\pi \alpha_x \alpha_y \sqrt{\cos \theta_i \cos \theta_o}}$
其中 $\alpha_x, \alpha_y$ 控制各向异性粗糙度。
真实材料表现出空间变化: $f_r(\mathbf{x}, \omega_i, \omega_o) = f_r(u, v, \omega_i, \omega_o)$
其中 $(u, v)$ 是纹理坐标。这使得以下成为可能:
蒙特卡洛积分使用随机采样估计积分:
$I = \int_\Omega f(\mathbf{x}) d\mathbf{x} \approx \frac{1}{N} \sum_{i=1}^N \frac{f(\mathbf{X}_i)}{p(\mathbf{X}_i)}$
其中 $\mathbf{X}_i \sim p(\mathbf{x})$ 是来自概率密度 $p$ 的样本。
估计器是无偏的:$E[\hat{I}] = I$
方差是: $\text{Var}[\hat{I}] = \frac{1}{N} \int_\Omega \left(\frac{f(\mathbf{x})}{p(\mathbf{x})} - I\right)^2 p(\mathbf{x}) d\mathbf{x}$
| 最优采样通过匹配 $p$ 和 $ | f | $ 来最小化方差: |
| $p^*(\mathbf{x}) = \frac{ | f(\mathbf{x}) | }{\int_\Omega | f(\mathbf{x}) | d\mathbf{x}}$ |
对于渲染方程,好的采样策略包括:
当有多个采样策略可用时,MIS将它们最优地组合:
$\hat{I} = \sum_{i=1}^{n_f} w_f(\mathbf{X}{f,i}) \frac{f(\mathbf{X}{f,i})}{p_f(\mathbf{X}{f,i})} + \sum{j=1}^{n_g} w_g(\mathbf{X}{g,j}) \frac{f(\mathbf{X}{g,j})}{p_g(\mathbf{X}_{g,j})}$
平衡启发式提供好的权重: $w_f(\mathbf{x}) = \frac{n_f p_f(\mathbf{x})}{n_f p_f(\mathbf{x}) + n_g p_g(\mathbf{x})}$
为了用有限计算创建无偏估计器,俄罗斯轮盘赌随机终止路径:
$L’_i = \begin{cases}
L_i/q & \text{以概率 } q
0 & \text{以概率 } 1-q
\end{cases}$
这保持 $E[L’_i] = L_i$ 同时限制计算量。
蒙特卡洛收敛遵循中心极限定理:
| $P( | \hat{I} - I | \le \varepsilon) \approx 2\Phi(\varepsilon\sqrt{N}/\sigma) - 1$ |
其中 $\Phi$ 是正态分布CDF,$\sigma^2$ 是方差。误差以 $O(1/\sqrt{N})$ 递减,与维度无关——这对高维光传输至关重要。
我们可以将渲染方程重新表述为对所有可能光路径的积分。长度为k的路径是:
$\bar{\mathbf{x}} = \mathbf{x}_0\mathbf{x}_1\dots\mathbf{x}_k$
其中 $\mathbf{x}_0$ 在光源上,$\mathbf{x}_k$ 在相机传感器上。
路径空间 $\bar{\Omega}_k$ 包含所有长度为k的有效路径。路径的测度是:
$d\mu(\bar{\mathbf{x}}) = dA(\mathbf{x}0) \prod{i=1}^{k} dA(\mathbf{x}_i)$
路径的贡献是:
$f(\bar{\mathbf{x}}) = L_e(\mathbf{x}0 \to \mathbf{x}_1) \left(\prod{i=1}^{k-1} f_s(\mathbf{x}{i-1} \to \mathbf{x}_i \to \mathbf{x}{i+1}) G(\mathbf{x}i \leftrightarrow \mathbf{x}{i+1})\right) W(\mathbf{x}_{k-1} \to \mathbf{x}_k)$
其中G是几何因子:
| $G(\mathbf{x} \leftrightarrow \mathbf{x}’) = V(\mathbf{x} \leftrightarrow \mathbf{x}’) \frac{\cos \theta \cos \theta’}{ | \mathbf{x} - \mathbf{x}’ | ^2}$ |
路径积分表述类似于费曼对量子力学的方法:
$I = \sum_{k=2}^\infty \int_{\bar{\Omega}_k} f(\bar{\mathbf{x}}) d\mu(\bar{\mathbf{x}})$
这个对所有路径长度的无限和捕获了全局光照。每一项代表k-1次反弹的路径。
点上的值满足递归关系:
$L(\mathbf{x}, \omega) = L_e(\mathbf{x}, \omega) + \int_M f_s(\mathbf{y} \to \mathbf{x} \to \omega) L(\mathbf{y}, \mathbf{x} - \mathbf{y}) G(\mathbf{y} \leftrightarrow \mathbf{x}) dA(\mathbf{y})$
这导致诺伊曼级数解:
$L = L^{(0)} + L^{(1)} + L^{(2)} + \dots$
其中 $L^{(k)}$ 代表k次反弹照明。
路径积分自然扩展到参与介质。对于具有吸收 $\sigma_a$、散射 $\sigma_s$ 和相位函数 $p$ 的体积:
$L(\mathbf{x}, \omega) = \int_0^\infty T(0,t) \left[\sigma_a L_e + \sigma_s \int_{S^2} p(\omega’, \omega) L(\mathbf{x}+t\omega, \omega’) d\omega’\right] dt + T(0,\infty) L_\infty$
其中 $T(s,t) = \exp\left(-\int_s^t \sigma_t(\mathbf{x}+u\omega) du\right)$ 是透射率。
这个统一的表述将在后续章节中连接所有渲染方法。
本章通过几何光学建立了计算机图形学的数学基础:
这些概念构成了所有渲染算法的基础。路径积分表述特别使我们能够将基于点的、基于图像的和神经渲染方法统一处理为解决同一基本方程的不同方法。
证明在真空中沿光线辐射率保持恒定。从辐射率的定义开始,并使用平方反比定律。
提示: 考虑沿光线的两个微分面积 $dA_1$ 和 $dA_2$,并证明 $L_1 = L_2$。
证明朗伯BRDF $f_r = \rho/\pi$ 对于任何反照率 $\rho \le 1$ 都满足能量守恒。
提示: 使用球面坐标在半球上积分。
推导估计 $\int_0^1 \sqrt{x} dx$ 的最优重要性采样分布,并计算由此产生的方差。
| 提示: 最优PDF与 $ | f(x) | $ 成比例。 |
证明当场景中的最大反照率小于1时,渲染方程的诺伊曼级数收敛。
| 提示: 使用算子范数 $ | \mathcal{T} | \le \rho_{\text{max}} < 1$。 |
推导将渲染方程从立体角积分转换为表面面积积分的雅可比。
提示: 从 $d\omega = dA \cos \theta’/r^2$ 开始。
推导折射率分别为 $n_1$ 和 $n_2$ 的介质之间BSDF的广义互易关系。
提示: 使用相空间辐射率 $\tilde{L} = L/n^2$。
证明具有延续概率 $q$ 的俄罗斯轮盘赌创建了一个无偏估计器。
提示: 使用全期望定律。
考虑具有空间变化消光的体积渲染方程。在什么条件下路径积分公式收敛?讨论光学厚度与收敛速率之间的关系。
提示: 考虑沿任何光线的最大光学厚度 $\tau_{\text{max}}$。