## Volumetric Pathtracing / Small UPBP

Practical and theoretical implementation discussion.
XMAMan
Posts: 18
Joined: Tue Dec 01, 2015 7:52 am
Location: Germany, Dresden

### Volumetric Pathtracing / Small UPBP

Hello,

I have a question to the PDF from the Distance-Sampling-Function in particpating media.

In the SmallUPBP-Example is a function, that sample the ray-distance:

Code: Select all

virtual float SampleRay(
const Ray   &/*aRay*/,
const float aRandom,
float       *oPdf,
const uint  aRaySamplingFlags = 0,
float       *oRevPdf = NULL) const
{
float s = -std::log(aRandom) / mMinPositiveAttenuationCoefComp();

if (s < aDistToBoundary) // sample is before the boundary intersection
{
float att = EvalAttenuationInOneDim(mMinPositiveAttenuationCoefComp(), s);

if (oPdf) *oPdf = mMinPositiveAttenuationCoefComp() * att;
...
}
else // sample is behind the boundary intersection
{

if (oPdf) *oPdf = att;
...
}
}
float EvalAttenuationInOneDim(
const float aAttenuationCoefComp,
{
}

My question is: If the ray is shorter than the distance to the medium-boundary (Sample inside the medium) than he returns a PDF. If the ray is longer than the max-distance, then he returns a Probabilty.

A PDF is not the same as a Probabilty. So why can he mix this two things?

If I use his explanations
http://www.smallupbp.com/thesis.pdf Page 33
If the sampled distance
d is lesser than or equal to dmax, the method returns d along with the desired pdf p¯(d) = σt,mT0
r,m(d). If it is longer, dmax is returned with a probability Pr{d>dmax} = 1 − P(dmax) = T0r,m(dmax).
Or a other text to this topic:

http://www.cs.cornell.edu/courses/cs663 ... olpath.pdf Page 3
The probability
that s > smax is 1 – P(smax), which is exp(–σt smax): exactly the attenuation that needs to be applied
to the radiance from behind the medium
He also use this formula but I don't understand why he can mix PDF and Probability.

In the 'normal' pathtracer I get the Path-Pdf by multiplying all the Sampling-Pdfs (Direction-Sampling / Survace-Area-Sampling). This Path-Pdf is needet for the MC-Estimator. But what happens, if one of this Sampling-Pdfs is not a PDF but a Probability?

Can someone explain me why he can mix this two things, if he want to MonteCarlo-Integrate?

shocker_0x15
Posts: 70
Joined: Sun Aug 19, 2012 3:24 pm
Contact:

### Re: Volumetric Pathtracing / Small UPBP

Hi,

As you know, volume light transport equation consists of two terms where the one is attenuated light L_s leaving a surface and the other is "the integral of" light gain L_a due to in-scattering and emission.
L_i = T * L_s + int T * L_a ds
* L_a is volumetric emission and in-scattering
* The unit of L_s is [W/(m^2 sr)] but that of L_a is [W/(m^3 sr)]

In the case where the distance sampling produces a distance longer than the medium-boundary, it corresponds to evaluate the former term (there is no integral), otherwise evaluate the latter term (in integral).

Monte Carlo estimates for these terms are:
T * L_s / Probability
or
T * L_a / PDF
, and the units of these match.

Therefore, mix use of probability and PDF is valid.

XMAMan
Posts: 18
Joined: Tue Dec 01, 2015 7:52 am
Location: Germany, Dresden

### Re: Volumetric Pathtracing / Small UPBP

Ok. You write there are two cases

case 1: distance longer than the medium-boundary
L_i = T * L_s

case 2: distance shorter than the medium-boundary
L_i = int T * L_a ds

Why is in case 2 no 'T * L_s ' Term? Is there no leaving-energy?

shocker_0x15
Posts: 70
Joined: Sun Aug 19, 2012 3:24 pm
Contact:

### Re: Volumetric Pathtracing / Small UPBP

Sorry to be late.

This procedure implicitly includes selection between the two terms with probability.
select the case 1 with probability P_s
select the case 2 with probability 1 - P_s
P_s is a probability to perform evaluation on surface.

case 1:
immediately evaluate the attenuated radiance leaving a surface.
estimate: T * L_s / P_s

case 2:
contribution from the second term becomes:
int T * L_a ds / (1 - P_s),
but this still has an integration, so we need to sample distance in the medium interval with PDF p' (which produces a distance only between the interval).
estimate: T * L_a / ((1 - P_s) * p') = T * L_a / p,
where p is the original PDF (which can produce a distance even further than the medium boundary)

Therefore in the 2nd case, consideration for the 1st term is included in the implicit division by (1 - P_s).
I have found that you can also find a good explanation about this at the page 891 of the PBR 3rd book.

XMAMan
Posts: 18
Joined: Tue Dec 01, 2015 7:52 am
Location: Germany, Dresden

### Re: Volumetric Pathtracing / Small UPBP

Thank you. Your explanation now helps me more. I will check the PBR-Book too