# Sampling scattering direction around directions other than the last ray direction

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

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: 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).