To perform importance sampling on a light source, a probability density function must be provided for the sampling distribution. For most light sources, a valid probability distribution can be found, but point lights and pure directional lights (directional lights which emit light exclusively in one direction, with 0 spread angle) do not have this property, as there is only one valid light path connecting them with any given point. This would require an infinite probability density, which would result in an infinitely small light contribution due to importance sampling. My question is: how can these light types be sampled without introducing bias?

I've asked more specifically about the mathematics behind this on the Mathematics Stack Exchange, but seeing as I received no replies there, I think this would be a more appropriate place to ask.

  • 4
    $\begingroup$ There's nothing to integrate for those. You just directly evaluate the contribution. You can see this as having to compute $\int_{\Omega}f(x)g(x)\,dx$, where $g(x) =\delta(x-y) + h(x)$, and thus getting $f(y) + \int_{\Omega}f(x)h(x)\,dx$. The $f(y)$ is just a pointwise evaluation and doesn't require any importance sampling in the usual sense. Dirac deltas due to point/directional lights or ideal mirrors or refractors simply collapse an integral in the continuous formulation. Numerical methods would not be able to handle the singularity, so you get rid of it in the continuous setting still. $\endgroup$
    – lightxbulb
    Jan 12, 2022 at 2:11
  • $\begingroup$ To add to this I think you can also sample it as you would any other light and set the pdf to be very very high and multiply the value by that pdf as well. This ensures that the multiple importance sampling weight becomes ~1 and when you divide by the pdf the value is still the same. This should be equivelent to directly evaluating it as above but might be easier to implement if you have a system for lights you dont want to modify. $\endgroup$
    – Peter
    Jan 13, 2022 at 16:35
  • $\begingroup$ @Peter This approach may run into numerical precision issues. Ideally you want to use analytical methods everywhere where it is possible. For example if you use a cosine weighted distribution you would ideally cancel out the cosines for the implementation as $0/0$ isn't handled well by floating point numbers. A Dirac delta is a much more problematic singularity (it's not even a function in the classical sense, i.e. it's not enough setting it to infinity at a point and zero everywhere else), you're supposed to get rid of it in the continuous setting. $\endgroup$
    – lightxbulb
    Jan 14, 2022 at 13:22
  • $\begingroup$ @lightxbulb Yep I would recomend using your method where possible. Could you explain where you are getting the 0/0 from to me though? In out = MIS * bxdf * light / pdf $\endgroup$
    – Peter
    Jan 14, 2022 at 17:06
  • $\begingroup$ @Peter $\frac{\cos\theta}{\cos\theta} \rightarrow \frac{0}{0}$ for $\theta \rightarrow \pm \frac{\pi}{2}$. Due to how floating point works you get issues even if $\cos\theta$ is not zero but small enough. Ideally you would cancel out the denominator analytically and then apply the numerical methods on the simplified expression. As far as the Dirac delta goes, I am not even sure what pdf you plan to use there. $\endgroup$
    – lightxbulb
    Jan 14, 2022 at 17:40


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.