【计算机图形学】体渲染专题 (二)
首先,老规矩:
未经允许禁止转载(防止某些人乱转,转着转着就到蛮牛之类的地方去了)
B站:Heskey0
【Computer Graphics】Photorealistic Rendering of Volume Effect
Heskey0 (Bilibili)
December 2021
Based On Mark Pauly's Thesis[1999] and 《PBRT》
Chapter 1 . Sampling Techniques In Path Tracing
1.1. Inverse CDF (Cumulative Density Function)
There are many techniques for generating random variates from a specified probability distribution such as the normal, exponential, or gamma distribution. However, one technique stands out because of its generality and simplicity: the inverse CDF sampling technique.
The algorithm is as follows:
- Obtain or generate a draw (realization) \(u\) from the standard uniform distribution \(U∼Unif(0,1)\)
- The draw \(x\) from the CDF \(F(x)\) is given by \(x=F^{-1}(u)\)
Example of inverse CDF method:
Let \(p(\theta)=sin\theta\) be the probability density function, \(F(\theta)=1-cos\theta\) the cumulative density function of \(\theta\)
-
generate a draw \(\xi\) from the standard uniform distribution \(U∼Unif(0,1)\)
-
the draw \(\theta\) from the PDF \(p(\theta)\) is given by \(\theta=F^{-1}(\xi)=arccos(1-\xi)\)
1.2. Uniformly sampling a hemisphere
a uniform distribution means that the density function is a constant, so we know that \(p(x)=c\)
hence \(p(\omega)=\frac1{2\pi}\), \(d\omega=sin\theta d\theta d\phi\), \(p(\theta,\phi)=\frac{sin\theta}{2\pi}\)
Consider sampling \(\theta\) first. To do so, we need \(\theta\)'s marginal density function \(p(\theta)\):
Now, compute the conditional density for \(\phi\):
Notice that the density function for \(\phi\) itself is uniform, then use the inverse CDF sampling technique to sample each of these PDFs in turn
Converting these back to Cartesian coordinates, we get the final sampling formula:
1.3. Sample area light
def sample_area_light(hit_pos, pos_normal):
# sampling inside the light area
x = ti.random() * light_x_range + light_x_min_pos
z = ti.random() * light_z_range + light_z_min_pos
on_light_pos = ti.Vector([x, light_y_pos, z])
return (on_light_pos - hit_pos).normalized()
1.4. Cosine-weighted Sampling
We could use the inverse CDF sampling technique as before, but instead we can use a technique known as Malley’s method to generate these cosine-weighted points.
The algorithm is as follows:
-
sample a unit disk (Concentric Mapping)
\[r=x;\phi=\frac yx\frac{\pi}4 \] -
project up to the unit hemisphere
1.5. Multiple importance sampling
MIS allows us to combine \(m\) different sampling strategies to produce a single unbiased estimator by weighting each sampling strategy by its probability distribution function.
where \(X_{i,j}\) are independent random variables drawn from some distribution function pi and \(w_i(X_{i,j})\) is some heuristic for weighting each sampling technique with respect to pdf.
balance heuristic:
power heuristic:
Veach determined empirically that \(\beta=2\) is a good value
本文未经允许禁止转载
作者:Heskey0
B站:https://space.bilibili.com/455965619
邮箱:3495759699@qq.com