# 基于物理的BRDF

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

## 引言

KlayGE 3.11.0开始，Lighting.fxml里提供了calc_brdf()函数，用于计算本文所描述的基于物理的BRDF

## 反射方程

$LaTeX: L_0(\mathbf{v})=\int_{\Omega} \rho(\mathbf{l},\mathbf{v}) \otimes L_i(\mathbf{l}) (\mathbf{n} \cdot \mathbf{l}) d\omega_i$

## Diffuse项

$LaTeX: \rho_{lambert}(\mathbf{l},\mathbf{v})=\frac{\mathbf{c}_{diff}}{\pi}$

## 精确光源

$LaTeX: \forall\mathbf{l}|\angle(\mathbf{l}, \mathbf{l_c})>\varepsilon, L_{tiny}(\mathbf{l})=0$
$LaTeX: if \mathbf{l_c}=\mathbf{n}, \mathbf{c}_{light}=\frac{1}{\pi}\int_{\Omega} L_{tiny}(\mathbf{l}) (\mathbf{n} \cdot \mathbf{l}) d\omega_i$

$LaTeX: if \mathbf{l_c}=\mathbf{n}, \mathbf{c}_{light}=\lim_{\varepsilon \to 0}(\frac{1}{\pi}\int_{\Omega} L_{tiny}(\mathbf{l}) (\mathbf{n} \cdot \mathbf{l}) d\omega_i)$

$LaTeX: \mathbf{c}_{light}=\lim_{\varepsilon \to 0}(\frac{1}{\pi}\int_{\Omega} L_{tiny}(\mathbf{l}) d\omega_i)$

$LaTeX: \lim_{\varepsilon \to 0}(\int_{\Omega} L_{tiny}(\mathbf{l}) d\omega_i) = \pi \mathbf{c}_{light}$

$LaTeX: L_0(\mathbf{v})=\lim_{\varepsilon \to 0}(\int_{\Omega} \rho(\mathbf{l},\mathbf{v}) \otimes L_{tiny}(\mathbf{l}) (\mathbf{n} \cdot \mathbf{l}) d\omega_i)=\rho(\mathbf{l_c}, \mathbf{v}) \otimes \lim_{\varepsilon \to 0}(\int_{\Omega} L_{tiny}(\mathbf{l}) d\omega_i)(\mathbf{n} \cdot \mathbf{l_c})$

$LaTeX: L_0(\mathbf{v})=\pi \rho(\mathbf{l_c}, \mathbf{v}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

## Microfacet BRDF

Microfacet

$LaTeX: \rho(\mathbf{l}, \mathbf{v})=\frac{F(\mathbf{l},\mathbf{h})G(\mathbf{l},\mathbf{v},\mathbf{h})D(\mathbf{h})}{4(\mathbf{n} \cdot \mathbf{l})(\mathbf{n} \cdot \mathbf{v})}$

F(l, h)是有效microfacetm = h）产生的Fresnel反射。G(l, v, h)是有效microfacet中没有被shadow或mask的比例。D(h)是microfacet的法线分布函数，或者说，microfacet的法线等于h的密度。最后，分母4(n·l)(n·v)是个校正因子，用来校正从microfacet的局部空间转到整体表面的数量差异。

## Fresnel项

Fresnel反射项计算从光学平滑的表面反射的比率。它的值取决于两件事情：入射角（光源方向和表面法线之间的角），以及材质的折射率。Schlick近似的Fresnel项是：

$LaTeX: F_{Schlick}(\mathbf{c}_{spec}, \mathbf{l}, \mathbf{h})=\mathbf{c}_{spec}+(1-\mathbf{c}_{spec})(1-\mathbf{l} \cdot \mathbf{h})^5$

## 对比

$LaTeX: L_{o}(\mathbf{v})=(\mathbf{c}_{diff} (\mathbf{n} \cdot \mathbf{l_c}) + \mathbf{c}_{spec}(\mathbf{r_v} \cdot \mathbf{l_c})^{\alpha}) \otimes \mathbf{c}_{light}$

$LaTeX: L_{o}(\mathbf{v})=(\mathbf{c}_{diff} + \mathbf{c}_{spec}(\mathbf{r_v} \cdot \mathbf{l_c})^{\alpha}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

$LaTeX: L_{o}(\mathbf{v})=(\mathbf{c}_{diff} + \pi \mathbf{c}_{spec}(\mathbf{n} \cdot \mathbf{h})^{\alpha}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

$LaTeX: \mathbf{c}_{diff} = \pi \frac {\mathbf{c}_{diff}} {\pi}$

$LaTeX: L_{o}(\mathbf{v})=\pi (\mathbf{n} \cdot \mathbf{h})^{\alpha} \mathbf{c}_{spec} \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

$LaTeX: L_{o}(\mathbf{v})=\pi \frac{D(\mathbf{h})G(\mathbf{l_c},\mathbf{v},\mathbf{h})}{4(\mathbf{n} \cdot \mathbf{l_c})(\mathbf{n} \cdot \mathbf{v})}F(\mathbf{c}_{spec}, \mathbf{l_c},\mathbf{h}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

$LaTeX: (\mathbf{v} \cdot \mathbf{n}) = \int_{\Theta} D(\mathbf{m})(\mathbf{v} \cdot \mathbf{m}) d\omega_m$

$LaTeX: 1 = \int_{\Theta} D(\mathbf{m})(\mathbf{n} \cdot \mathbf{m}) d\omega_m$

Blinn-Phong的项如果也要满足这个方程，就得乘上一个归一化系数：

$LaTeX: D_{BP}=\frac {\alpha + 2} {2\pi}(\mathbf{n} \cdot \mathbf{m})^{\alpha}$

$LaTeX: \frac {G(\mathbf{l_c},\mathbf{v},\mathbf{h})}{(\mathbf{n} \cdot \mathbf{l_c})(\mathbf{n} \cdot \mathbf{v})}$

$LaTeX: G_{implicit}(\mathbf{l_c},\mathbf{v},\mathbf{h}) = (\mathbf{n} \cdot \mathbf{l_c})(\mathbf{n} \cdot \mathbf{v})$

$LaTeX: L_{o}(\mathbf{v})=\frac {\alpha + 2} {8}(\mathbf{n} \cdot \mathbf{h})^{\alpha} F(\mathbf{c}_{spec}, \mathbf{l_c},\mathbf{h}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

$LaTeX: L_{o}(\mathbf{v})=(\mathbf{c}_{diff} + \frac {\alpha + 2} {8}(\mathbf{n} \cdot \mathbf{h})^{\alpha} F(\mathbf{c}_{spec}, \mathbf{l_c},\mathbf{h})) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

## 未来的工作

$LaTeX: \frac {G_{CT}(\mathbf{l_c}, \mathbf{v}, \mathbf{h})} {(\mathbf{n} \cdot \mathbf{l_c})(\mathbf{n} \cdot \mathbf{v})} \approx \frac {1} {(\mathbf{l_c} \cdot \mathbf{h})^2}$