1

In the accepted answer for the question What is Importance Sampling?, in the example code there is this line:

// Accumulate the brdf attenuation
throughput = throughput * material->Eval(wi, wo, normal) / pdf;

If the PDF is between 0.0 and 1.0, the division will potentially increase the throughput. I do not think it makes sense. What am I missing?

dblouis
  • 133
  • 3

2 Answers2

2

Yes, throughput doesn't have to be in range [0, 1]. That's a reason why you have to use exposure settings, because for differente accumulation time, brightness of an image might differ. Nathan Reed described it in details here - https://computergraphics.stackexchange.com/a/10244/10129

Your final results and number of fireflies and bright surfaces, depends on PDF that you'll be using. By using Normal Distribution Function PDF, you'll get good results, because NDF is the most determining factor of BRDF shape. Relate to this blog post for details - https://schuttejoe.github.io/post/ggximportancesamplingpart1/


Back to throughput range. Assuming that you're sampling based on NDF, you'll get fireflies in case of having values in specific range, when light source is shining from very low angle and you're looking directly at the object. Therefore, your denominator might be much greater than nominator and result in small PDF causing fireflies:

$$ p_i(w_m, w_o) = \frac{D(w_m)(w_g \cdot w_i)}{4|w_g \cdot w_m|} $$

enter image description here

Since 2014, Heitz was working on BSDFs, presenting good results in same year by sampling visible normals [2]. In 2017, he published much simpler, faster and better paper, improving his method [3]. There are also 2015 and 2016 papers in related field, but I haven't read them, but it might be beneficial if you're interested in BSDF. I would recommend checking his first 2014's work (1) where he explains physical assumption on which BRDF is based. It's worth knowing, what NDF and Geometry Shadowing exactly means in BRDF.

Also, there is a lot of good reading in pbrt book, especially:


(1) Eric Heitz - Understanding the Masking-Shadowing Functionin Microfacet-Based BRDFs http://jcgt.org/published/0003/02/03/paper.pdf

(2) Eric Heitz, Eugene d’Eon - Importance Sampling Microfacet-Based BSDFs using the Distribution of Visible Normals https://hal.inria.fr/hal-00996995v1/document

(3) Eric Heitz - A Simpler and Exact Sampling Routine for the GGXDistribution of Visible Normals https://hal.archives-ouvertes.fr/hal-01509746/document

0

I have a similar question currently posted, so take the following with a grain of salt.

Throughput does not need to be smaller than 1. BRDF only needs to be non negative and to integrate to less than 1 (conservation of energy / albedo) over the hemisphere. It can be arbitrarily large - e.g. in the case of a mirror.

The pdf should approximate the BRDF to reduce variance. However, unless it is always larger than the BRDF, the throughput will be larger than 1 and should be able to reach infinity.

BRDF in your case corresponds to material->Eval(wi, wo, normal) / dot(normal, wi)

arctiq
  • 31
  • 4
  • BRDF in your case corresponds to material->Eval(wi, wo, normal) / dot(normal, wi) why? – lightxbulb May 07 '20 at 09:37
  • @lightxbulb, that is more or less the definition of Brdf. E.g. a Diffuse brdf is a constant, non negative, (obviously)reciprocal function. Using the functions of the OPs referenced question, that's what it would look like. People have a tendency to fold terms together to avoid repeated computation, which is confusing to beginners trying to understand path tracing from the underlying physics. – arctiq May 08 '20 at 10:59
  • 1
    Where did the dot pop out from? – lightxbulb May 08 '20 at 11:33
  • @lightxbulb, in the definition of BRDF, there is a "normalizing" (normal direction) term $1 / \cos \theta_i$, which is the angle between the normal and the incomming $w_i$. When $n$ and $w_i$ have unit length, the $\cos \theta_i = \ w_i \cdot normal$, because $a \cdot b \equiv |a| \times |b| \times \cos \theta$, where $\theta$ is the angle between $a$ and $b$. Makes sence? – arctiq May 08 '20 at 12:59
  • Can you link the definition of BRDF that you are citing? – lightxbulb May 08 '20 at 14:13
  • @lightxbulb, hmm, depends on what you need. There is nothing wrong with the definition on wikipedia, but if you want context too, maybe try Ray Tracing in One Weekend (specifically the 3rd book, I think, goes into some detail), or the popular Physically Based Rendering: From Theory To Implementation, both of which are online, free, and contain source code too. – arctiq May 08 '20 at 15:54
  • Seems you are confusing what your function is defined as formally, and what you have in practice. You do not have the analytical form of the $dL_r$ or $L_i$ in practice, so the eval/dot makes no sense. Instead you define some function (which describes your material) that fulfills the 3 required properties. There is no cosine division requirement. In fact the simplest BRDF - Lambertian, is just a constant function that is in $[0,\frac{1}{\pi}]$. I would suggest just deleting your answer, as it is mostly wrong: e.g. the BRDF thing, the BRDF reaching inifnity for mirrors. – lightxbulb May 08 '20 at 16:14
  • I have told you what the function is, and why the division is there (because it is folded into eval in OPs referenced question). I have also told you that a lambertian diffuse is a constant function. The fact that BRDF is infinite for perfectly specular reflections has been answered here. – arctiq May 08 '20 at 16:41
  • And I am telling you that you are wrong - for the cosine division entirely, for the infinity thing: depending on how informal you want to get. The BRDF for mirrors is not "infinite" - it is a Dirac delta. You're not plugging infinity into your tracer upon implementation due to that reason - instead you're getting rid of the integral due to the main property of the Dirac delta. While it may be easier to explain it to readers without mathematical background as being "infinite" (which is why I assume the authors of AGI did it), that doesn't change the fact that it is a wrong explanation. – lightxbulb May 08 '20 at 17:53
  • In your "example" material->Eval(wi, wo, normal) / dot(normal, wi) material->Eval(wi,wo,normal) should by all means be the BRDF, and there is no cosine factor required in the numerator. In no BRDF is such a factor required - only if you want to model a material that has a behaviour $\propto \frac{1}{\cos\theta}$ will you introduce such a factor in the BRDF. I suggest reading up on measure theory if you want to understand in depth where your misunderstanding came from. – lightxbulb May 08 '20 at 17:57
  • @lightxbulb, there is no cosine division. Focus on the lambertian diffuse, a constant function, $f_r = \rho / \pi$, where do you see a cosine division? – arctiq May 08 '20 at 21:30
  • That's exactly what I have been trying to explain to you - see what you wrote: material->Eval(wi, wo, normal) / dot(normal, wi), in the definition of BRDF, there is a "normalizing" (normal direction) term $1/\cos\theta_i$. The above simply do not hold in the general case. – lightxbulb May 08 '20 at 21:47
  • @lightxbulb, oh I see, that's my mistake, that is very confusing. The reason for $/ \cos$ in my answer, is to cancel out $* cos$ in eval, because only the constant part of eval is the Lambertian BRDF (despite eval being called brdf by the author). The reason why it is usualy folded together is to avoid repeated computation. The place it came from is the rendering equation, and the reason why it's there is to cancel out the normalizing $\cos$ from the definition of BRDF. – arctiq May 08 '20 at 23:25
  • You're not supposed to cancel out the cosine in the rendering equation. The only reason I can think of why you would have the division is from the probability density function. – lightxbulb May 09 '20 at 04:30
  • @lightxbulb, no. The cos is the attenuation due to angle... This is ridiculous. It is not helping anyone. Lambertian diffuse being equal to material->Eval(wi, wo, n) / dot(n, wi) or $f_r = \rho / \pi$ (a constant function) is a fact. BRDF not being upper-bounded is a fact. PLEASE... – arctiq May 09 '20 at 13:48
  • The attenuation due to angle (Lambert's cosine law) doesn't show up in the denominator of arbitrary BRDFs, it shows up in the rendering equation as a factor not part of the BRDF. I already explained that Lambertian diffuse is constant - no cosine division required. Neither did I argue that the BRDF needs to be bounded from above - however, that does not mean that the mirror BRDF is infinity - it is a Dirac delta. – lightxbulb May 09 '20 at 15:02
  • I finally got why you are saying this - I apologize. Seems like in that code they stuck in the cosine into eval for some reason, which confused me. I thought you were dividing the brdf itself by cosine for some reason (but you clarified it was not in the answer before your last). Please do remove the infinity thing about the mirror though - a Dirac delta has very specific properties - it's not just an "infinity". I can give you a brdf that is infinity over sets of measure zero though, and it will not matter. – lightxbulb May 09 '20 at 16:09