Page 1 of 1

Volumetric Pathtracing / Small UPBP

Posted: Wed Dec 14, 2016 6:51 pm
by XMAMan

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 aDistToBoundary,	
		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
		float att = EvalAttenuationInOneDim(mMinPositiveAttenuationCoefComp(), aDistToBoundary);
		if (oPdf) *oPdf = att;
	float EvalAttenuationInOneDim(
		const float aAttenuationCoefComp,
		const float aDistanceAlongRay) const
		return std::exp(-aAttenuationCoefComp* aDistanceAlongRay);
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 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: ... 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?

Re: Volumetric Pathtracing / Small UPBP

Posted: Thu Dec 15, 2016 1:55 am
by shocker_0x15

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
T * L_a / PDF
, and the units of these match.

Therefore, mix use of probability and PDF is valid.

Re: Volumetric Pathtracing / Small UPBP

Posted: Thu Dec 15, 2016 6:01 pm
by XMAMan
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?

Re: Volumetric Pathtracing / Small UPBP

Posted: Mon Jan 09, 2017 5:15 pm
by shocker_0x15
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.

Re: Volumetric Pathtracing / Small UPBP

Posted: Sun Jan 22, 2017 4:45 pm
by XMAMan
Thank you. Your explanation now helps me more. I will check the PBR-Book too