<p>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.</p>

<p>In volume scattering, when a medium is homogeneous, we have the <a href="https://en.wikipedia.org/wiki/Beer%E2%80%93Lambert_law" rel="nofollow noreferrer">Beer–Lambert law</a>, 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.</p>

<p>So, if you sample points along the ray from an <a href="https://en.wikipedia.org/wiki/Exponential_distribution" rel="nofollow noreferrer">exponential distribution</a>, the samples cluster toward the closer, more important regions. Then you just have to evaluate the scattering at those points and average over them.</p>

<p>BTW, importance sampling in the context of <em>surface</em> scattering is explained pretty well by <a href="https://computergraphics.stackexchange.com/a/1667/48">this answer</a> to another question.</p>

<hr>

<p>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:</p>

<p>$$ \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' $$</p>

<p>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.</p>

<p>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.</p>

CC BY-SA 3.0
2016-01-22T03:16:56.483Z
Is the dipole approximation at all related to the Beer–Lambert law?
maogenc
CC BY-SA 3.0
2016-01-22T06:38:14.047Z
@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.
Nathan Reed
CC BY-SA 3.0
2016-01-21T07:44:20.010Z
2016-01-21T07:44:20.010Z
2017-04-13T13:00:43.660Z
Nathan Reed
<p><a href="http://renderman.pixar.com/view/implementing-a-skin-bssrdf">http://renderman.pixar.com/view/implementing-a-skin-bssrdf</a></p>

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

<p>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:</p>

<blockquote>
  <p>$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)}$</p>
  
  <p>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$.</p>
</blockquote>

<p><br><br>
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?</p>

<p>$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)}$</p>

<p>Also, where does single scattering fit into the general rendering equation?</p>

<p>$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}}$</p>

<rendering><importance-sampling>
using importance sampling to reduce the error of outscattered radiance
maogenc
# using importance sampling to reduce the error of outscattered radiance

(Asked by: username_0 on 2016-01-18)

<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}}$

**Tags:** rendering, importance-sampling


---

## 1 answers

### Answer by username_1 on 2016-01-21. Score: 2 | Accepted answer

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](https://en.wikipedia.org/wiki/Beer%E2%80%93Lambert_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](https://en.wikipedia.org/wiki/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](https://computergraphics.stackexchange.com/a/1667/48) 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.

> **Comments:**
> **username_0**: Is the dipole approximation at all related to the Beer–Lambert law?  
> **username_1**: @username_0 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.  

---

