==============
BSSRDF
https://gao-duan.github.io/blogs/bssrdf/index.html
https://gao-duan.github.io/blogs/bssrdf/index.html
BSSRDF aims to simulate volume scatterings using simplified assumption.
进入
https://gao-duan.github.io/
点击 Blog 进入
https://gao-duan.github.io/blogs/blog.html
点击 Implementation of BSSRDF model 进入
https://gao-duan.github.io/blogs/bssrdf/index.html
BSSRDF
Duan gao
bssrdf
Bunny rendered by my own renderer Elegans.
BSSRDF aims to simulate volume scatterings using simplified assumption.
Separate BSSRDF
Split the BSSRDF into 3 parts: (Eq 11.7 in PRRT-v3)
About c (normalized factor),
And assume the
is only related to
:
And the render equation:
Next I will introduce
of normalized diffusion BSSRDF model and how to important sampling this BSSRDF.
Normalized diffusion BSSRDF
The key idea is using Exp function to approximate
(including single-scattering and multiple-scattering).
formula (using mean free path
as parameter )
From equation 3 in [1],
change
to , because
in dipole diffusion represents the internal reflection parameter;
represents effective albedo, which is described in PBRT-v3 eq 11.11)
where
is the distance between and , is scale factor and
is mean free path length.
Another formula (using diffuse mean free path
as parameter)
Compute
and from physically based parameters (, , ,
):
(diffuse mean free path)
(scale factor)
(define
):
[1] Christensen P H. An approximate reflectance profile for efficient subsurface scattering[C]//ACM SIGGRAPH 2015 Talks. ACM, 2015: 25.
https://graphics.pixar.com/library/ApproxBSSRDF/paper.pdf
[2] Jensen H W, Marschner S R, Levoy M, et al. A practical model for subsurface light transport[C]//Proceedings of the 28th annual conference on Computer graphics and interactive techniques. ACM, 2001: 511-518.
https://http://graphics.stanford.edu/papers/bssrdf/bssrdf.pdf
Importance Sampling BSSRDF
There are two main approaches to implement BSSRDF model in physically based renderer.
precompute irradiance in point cloud which sampled uniformly and compute the contribution in rendering.
For example, the implementation in Mitsuba dipole.cpp.
importance sampling the BSSRDF directly in rendering.
More details about importance sampling the BSSRDF can be found in Section 6 of [1] and [2].
In the normalized diffusion BSSRDF model implementation, I use the second approach.
- Sample BSSRDF and corresponding pdf
It is nontrivial to sample a neighborhood point of
based on profile
.
1.1 Basic disk-based BSSRDF sampling
In the disk based sampling strategy, we map the 1D profile
to 3D point in the surface geometry.
The key idea is :
using
to define a bounding sphere of , the sampled
will located in some position on this sphere.
1567511127759
sample
from (
[we need to map this radius value to a 3D point].
1567510267483
sample angle
(
) of the disk.
1567510385749
project the point on 2D-disk to 3D sphere.
1567510932190
emit probe ray (from base to target) and find the interaction which serve as the sampled point
.
The contribution is:
1567511538632
1.2 Axis and channels sampling
Using normal vector
as the axis will lead to high variance in some sharp corners. (due to the dot product of and
will be very small (close to zero)) :
1567512217208
The solution is picking z axis from
randomly .
For the channels, each channels may have different
profiles, so we can also randomly pick one channel from R,G,B.
Now the contribution of each sample is (
) :
For the axis and channel sampling, we use MIS to combine them (regarding each axis and channel as one sampling strategy):
Recall the MIS:
and
.
=>
1.3 Sampling scheme (NormalizedDiffusionBSSRDF::Sample)
sample vertical axis randomly
sample channel randomly [r,g,b]
sample
from to get bounding sphere // [remain] how to sample from
sample
from and angle in disk // [remain] how to sample from
project point in disk into bounding sphere to get base and target
use probe ray (base => target) to find all possible interactions and random pick one (serve as
)
evaluate the BSSRDF
In the implementation,
, ,
are considered separately.
For NormalizedDiffusionBSSRDF::Sample(), we only need to return
.
For
, it is already considered in the BRDF (glass material). It is the pdf of transmit and only need to consider BSSRDF in this case.
For
, it is considered in
, which is called in NormalizedDiffusionAdaptor::Eval()
1.4 Pdf of above sampling (NormalizedDiffusionBSSRDF::Pdf_Sample)
For n sample strategies, the estimator is:
So the total pdf is
(the pdf of all strategies).
For each
, (
)
is trivial to evaluate,
will be introduced in next part.
- Sample
and
How to sample
from
profile?
Recall Monte Carlo estimator for
is
,
And the PDF should satisfies:
Inversion method to sample
from
:
compute CDF:
inverse of CDF:
uniform random number
Recall
:
satisfies: (integration in polar coordinates is always 1)
So the desired PDF is proportional to
.
Assume
,
So the PDF is
And the CDF is:
However, the CDF is not analytically invertible.
There are too methods to solve this problem.
We can use MIS to sample the 2 exp term separately:
Strategy 1(for first exp term)
Assume the PDF is
So the PDF is
CDF is:
:
Strategy 2 (for second exp term)
Assume the PDF is
So the PDF is
CDF is:
:
Precompute the
when
, and multiply d in rendering.
:
python script to precompute the inverse CDF
import scipy
from math import exp
def F(r, xi):
return 1.0 - 0.25 * exp(-r) - 0.75 * exp(-r/3) - xi
steps = 1024
x0 = 0
R = []
XI= []
for i in range(steps + 1):
xi = 1.0 / (steps) * r
r = scipy.optimize.newton(F,x0,args=(xi,))
x0 = r
XI.append(xi)
R.append(r)
print®
-
Sample
- (precompute
)
given random variable
:
locate
in
array.
Linear interpolate two neighborhood.
multiply d.
Pdf: just return
.
[1] Christensen P H. An approximate reflectance profile for efficient subsurface scattering[C]//ACM SIGGRAPH 2015 Talks. ACM, 2015: 25.
https://graphics.pixar.com/library/ApproxBSSRDF/paper.pdf
[2]King A, Kulla C, Conty A, et al. BSSRDF importance sampling[C]//ACM SIGGRAPH 2013 Talks. ACM, 2013: 48.
http://www.aconty.com/pdf/bssrdf.pdf
[3] http://shihchinw.github.io/2015/10/bssrdf-importance-sampling-of-normalized-diffusion.html
Combining BSSRDF in path tracing
1567661953093
direct lighting of BSSRDF compute in
.
indirect lighting (from
sample the next direction)
In
and , there are BSDF sample happened (contains Fresnel transmit and
).
(there are some discussions about the implementation details in [1])
[1] https://github.com/mmp/pbrt-v3/issues/19