# using importance sampling to reduce the error of outscattered radiance

http://renderman.pixar.com/view/implementing-a-skin-bssrdf

In this paper on subsurface scattering, I'm trying to understand how importance sampling is used to compute single scattering.

It says that the outscattered radiance for the single term, $L_o$, can be rewritten as the product of the exponential falloff in $s'_o$ with another function:

$L_o(x_o,\vec{\omega}_o) = \bigg[ L_i(x_i,\vec{\omega}_i)\cfrac{\sigma_s(x_o)F_p(\vec{\omega}'_i \cdotp \vec{\omega}'_o )}{\sigma_{tc}}e^{-s'_i \sigma_t(x_i)} \bigg] e^{-s_o\sigma(x_o)}$

By picking samples according to $x \sim \sigma_t e^{-\sigma_t x}$, the integration in $L_o$ can be approximated by a summation by applying importance sampling. Also by choosing $s'_o = \cfrac{-\mathbb{log(random())}}{\sigma_{tr}}$, you can sum up all contributions without computing the falloff term in $s_o$.

I understand you can approximate an integral using importance sampling, but I didn't follow how it applies to the rendering equation. Please could you describe how this works in greater detail?

$E[f(x)]=\int f(x)p(x) = \int f(x)\cfrac{p(x)}{q(x)}q(x) \approx \cfrac{1}{n}\sum \limits_{i=1}^n f(x_i)\cfrac{p(x_i)}{q(x_i)}$

Also, where does single scattering fit into the general rendering equation?

$L_{\text{o}}(\mathbf x,\, \omega_{\text{o}}) \,=\, L_e(\mathbf x,\, \omega_{\text{o}}) \ +\, \int_\Omega f_r(\mathbf x,\, \omega_{\text{i}},\, \omega_{\text{o}})\, L_{\text{i}}(\mathbf x,\, \omega_{\text{i}})\, (\omega_{\text{i}}\,\cdot\,\mathbf n)\, \operatorname d \omega_{\text{i}}$

In general, the idea of importance sampling is to distribute samples in a way that matches the function being integrated (or more practically, matching some factor in it). This reduces the variance of the output values, allowing the Monte Carlo integration to converge faster.

In volume scattering, when a medium is homogeneous, we have the Beer–Lambert law, which states that the transmittance falls off exponentially with depth. That's the source of factors like $e^{-\sigma x}$ in those equations. So when raymarching through a medium, the regions closer to the start of the ray generally contribute more light to the output, while the farther regions have more of their light absorbed along the way.

So, if you sample points along the ray from an exponential distribution, the samples cluster toward the closer, more important regions. Then you just have to evaluate the scattering at those points and average over them.

BTW, importance sampling in the context of surface scattering is explained pretty well by this answer to another question.

On your second question, "where does single scattering fit into the general rendering equation?", well, it doesn't! What people call the "general rendering equation" actually only includes surface scattering, not volume scattering. So it's not really that "general". A general rendering equation for volume scattering might look something like:

$$\nabla_\omega \, L(x, \omega) = \sigma_e(x) L_e(x, \omega) - \sigma_t(x) L(x, \omega) + \sigma_s(x) \int p(\omega, \omega') \, L(x, \omega') \, d\omega'$$

This states that the derivative of radiance as you move along a ray is given by the sum of emitted light from the volume, minus extinction, plus in-scattering.

To combine surface and volume scattering, we usually just say that the surface version of the equation applies at points on surfaces, and the volume version applies everywhere else.

• Is the dipole approximation at all related to the Beer–Lambert law? Jan 22 '16 at 3:16
• @maogenc The dipole approximation concerns homogeneous materials with a very high scattering coefficient, such that they're dominated by multiple scattering. The Beer–Lambert law would also apply to such materials. Jan 22 '16 at 6:38