<p>I think I got the answer via extensive numerical simulation. The result of the simulation is not listed here, so if you need it then you can comment to let me know.</p>
<p>Ok, I think I've derived the mathematical form of this conversion, but <strong>whether the conversion is needed</strong> still remains unknown and I will leave it behind for now since I am contacting someone with this kind of area expertise to help, and the answer will be updated if I get a reasonable answer. <strong>But I do need some reassurance for the correctness of this derivation</strong> and I'd appreciate any help.</p>
<p>Ok so first we re-formulate the problem setup, as shown in the following figure:
<a href="https://i.sstatic.net/aMEF8.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/aMEF8.png" alt="enter image description here" /></a></p>
<p>So we will always have <span class="math-container">$\theta = \alpha - \beta$</span> and note that <span class="math-container">$\alpha$</span> (its cosine term) is the value to sample for the new approach, <span class="math-container">$\theta$</span> is the angle for original phase function sampling and <span class="math-container">$\beta$</span> is a known constant (given the ray direction before sampling and the position of current vertex and target vertex). So:
<span class="math-container">$$
\frac{dP}{d\cos\theta} =\underbrace{\frac{dP}{d\cos\alpha}}_{\text{known, should be converted}} \times |\frac{d\cos\alpha}{d\cos\theta}| = \frac{dP}{d\cos\alpha} |\frac{d\cos\alpha}{d\alpha}\left(\frac{d\cos(\alpha - \beta)}{d\alpha}\right)^{-1}|\\
=\frac{dP}{d\cos\alpha} |\frac{\sin \alpha}{\sin(\alpha - \beta)}|
$$</span>
The term:
<span class="math-container">$$
|\frac{\sin \alpha}{\sin(\alpha - \beta)}|
$$</span>
should be able to do this conversion (if needed). Note that this is just a Jacobian conversion.</p>
<p>My point is, to apply MIS, <strong>we can't directly use</strong> PDF for sampling <span class="math-container">$\theta$</span> (cosine) and the PDF for sampling <span class="math-container">$\alpha$</span>. The meaning of these two terms just doesn't match. We should convert both of them to the same meaning, like we are both talking about sampling <span class="math-container">$\alpha$</span> or <span class="math-container">$\theta$</span>. I have done some numerical experiments, comparing hisogram of the cosine value with the analytical Jacobian I derived and I think the results match with each other.</p>
<p><strong>So, this question now becomes</strong>:</p>
<ul>
<li>Whether my derivation is correct?
<ul>
<li>The answer is yes. I did a numerical simulation, compared the histogram and the analytical curve and found they are matched.</li>
</ul>
</li>
<li>Whether this conversion is needed for MIS? Or even, since Monte Carlo estimator is of form <span class="math-container">$f(x) / p(x)$</span>, should I multiply the PDF in the denominator by this Jacobian?
<ul>
<li>I think the answer is no, it is not needed. A numerical simulation again showed that when I add this conversion, the result will not be correct (won't match).</li>
</ul>
</li>
</ul>

CC BY-SA 4.0
2023-08-31T04:17:31.793Z
2023-09-01T09:28:57.863Z
2023-09-01T09:28:57.863Z
Enigmatisms
<p>In a path tracer, if we want to sample a ray direction in scattering medium, we can use phase function sampling, which actually use the direction of the ray before sampling as a sort of anchor to sample around (just like normal vector in surface scattering).</p>
<p>However, we could break this convention by devising new sampling approach. For example, if I want to point the ray towards the emitter. So maybe this sampling method does not sample around the incident (or, out-going, depends on what direction we are talking about) direction, as shown in the following figure. We sample <span class="math-container">$\beta$</span> instead of <span class="math-container">$\theta$</span>.
<a href="https://i.sstatic.net/tEQxj.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tEQxj.png" alt="enter image description here" /></a></p>
<p>My question is: should we convert the PDF of <span class="math-container">$\cos\beta$</span> to <span class="math-container">$\cos\theta$</span>? I think it is necessary when we want to use MIS. So how does this change of PDF work mathematically? Is this some kind of measure conversion like 'solid-angle to area product' problem? As I can tell, for example, if <span class="math-container">$\cos\beta$</span> is uniformly distributed, we won't have a uniformly distributed <span class="math-container">$\cos\theta$</span> so I think a conversion should be necessary.</p>

<rendering><mathematics><importance-sampling><volumetric-scattering>
Sampling scattering direction around directions other than the last ray direction
Enigmatisms
# Sampling scattering direction around directions other than the last ray direction

(Asked by: username_0 on 2023-08-30)

In a path tracer, if we want to sample a ray direction in scattering medium, we can use phase function sampling, which actually use the direction of the ray before sampling as a sort of anchor to sample around (just like normal vector in surface scattering).

However, we could break this convention by devising new sampling approach. For example, if I want to point the ray towards the emitter. So maybe this sampling method does not sample around the incident (or, out-going, depends on what direction we are talking about) direction, as shown in the following figure. We sample $\beta$ instead of $\theta$.
[![enter image description here](https://i.sstatic.net/tEQxj.png)](https://i.sstatic.net/tEQxj.png)

My question is: should we convert the PDF of $\cos\beta$ to $\cos\theta$? I think it is necessary when we want to use MIS. So how does this change of PDF work mathematically? Is this some kind of measure conversion like 'solid-angle to area product' problem? As I can tell, for example, if $\cos\beta$ is uniformly distributed, we won't have a uniformly distributed $\cos\theta$ so I think a conversion should be necessary.

**Tags:** rendering, mathematics, importance-sampling, volumetric-scattering


---

## 1 answers

### Answer by username_0 on 2023-08-31. Score: 1 | Accepted answer

I think I got the answer via extensive numerical simulation. The result of the simulation is not listed here, so if you need it then you can comment to let me know.

Ok, I think I've derived the mathematical form of this conversion, but **whether the conversion is needed** still remains unknown and I will leave it behind for now since I am contacting someone with this kind of area expertise to help, and the answer will be updated if I get a reasonable answer. **But I do need some reassurance for the correctness of this derivation** and I'd appreciate any help.

Ok so first we re-formulate the problem setup, as shown in the following figure:
[![enter image description here](https://i.sstatic.net/aMEF8.png)](https://i.sstatic.net/aMEF8.png)

So we will always have $\theta = \alpha - \beta$ and note that $\alpha$ (its cosine term) is the value to sample for the new approach, $\theta$ is the angle for original phase function sampling and $\beta$ is a known constant (given the ray direction before sampling and the position of current vertex and target vertex). So:
$$
\frac{dP}{d\cos\theta} =\underbrace{\frac{dP}{d\cos\alpha}}\_{\text{known, should be converted}} \times |\frac{d\cos\alpha}{d\cos\theta}| = \frac{dP}{d\cos\alpha} |\frac{d\cos\alpha}{d\alpha}\left(\frac{d\cos(\alpha - \beta)}{d\alpha}\right)^{-1}|\\
=\frac{dP}{d\cos\alpha} |\frac{\sin \alpha}{\sin(\alpha - \beta)}|
$$
The term:
$$
|\frac{\sin \alpha}{\sin(\alpha - \beta)}|
$$
should be able to do this conversion (if needed). Note that this is just a Jacobian conversion.

My point is, to apply MIS, **we can't directly use** PDF for sampling $\theta$ (cosine) and the PDF for sampling $\alpha$. The meaning of these two terms just doesn't match. We should convert both of them to the same meaning, like we are both talking about sampling $\alpha$ or $\theta$. I have done some numerical experiments, comparing hisogram of the cosine value with the analytical Jacobian I derived and I think the results match with each other.

**So, this question now becomes**:

* Whether my derivation is correct?
  + The answer is yes. I did a numerical simulation, compared the histogram and the analytical curve and found they are matched.
* Whether this conversion is needed for MIS? Or even, since Monte Carlo estimator is of form $f(x) / p(x)$, should I multiply the PDF in the denominator by this Jacobian?
  + I think the answer is no, it is not needed. A numerical simulation again showed that when I add this conversion, the result will not be correct (won't match).


---

