<p>It's not that hard. If you have just planar or angular light sources, you can think of them as one light source split into multiple chunks and the only thing to deal with is how to sample this multi-light and how to compute the PDF of the resulting samples.</p>
<h2>Picking probability</h2>
<p>First, you need to setup the picking probability <span class="math-container">$P(l)$</span> for each light source <span class="math-container">$l$</span>. The picking probabilities can be any non-negative numbers, you just have to make sure that are always non-zero if the contributions of the respective lights are non-zero. However, the closer the probabilities are to the actual (relative) light contribution, the better the overall performance of your Monte Carlo estimator will be.</p>
<p>Contribution estimates may be:</p>
<ul>
<li><span class="math-container">$1$</span>: naive, uniform probability; good to start with; used by PBRT</li>
<li><span class="math-container">$power$</span>: better</li>
<li><span class="math-container">$power / distance^2$</span>: even better; closer light sources have greater contributions</li>
<li>…and other improvements: make zero if not visible at all, multiply by the cosine of the inclination angle, etc.</li>
</ul>
<p>Note that to get the light-picking probabilities, you need to normalise the contribution estimates to the sum of all of them:</p>
<p><span class="math-container">$$
P(l)=
  \frac
    {ContribEst_l}
    {\sum_{a\in\mathrm{Lights}}
      {ContribEst_a}}
$$</span></p>
<p>You could even use more different picking strategies if you find they work just for certain type of scenes and combine them using multiple importance sampling technique…</p>
<h2>Sampling</h2>
<p>When sampling the lights, you just select one light <span class="math-container">$l$</span> with the appropriate probability <span class="math-container">$P(l)$</span> and then sample the light surface/angle with its own sampling strategy (with PDF <span class="math-container">$p_l$</span>). The resulting PDF <span class="math-container">$p$</span> will be:
<span class="math-container">$$
p(x)=P(l) * p_l(x)
$$</span></p>
<h2>Evaluating PDF</h2>
<p>When computing the light sampling PDF for given direction (as needed for multiple importance sampling), you just find the light source at the direction, evaluate the PDF of the lights own strategy and, again, multiply it by the probability of picking this particular light.</p>
<h2>Conclusion</h2>
<p>Now you have a sampling strategy which gives you PDF which can be used in the Monte Carlo estimators (e.g. <span class="math-container">$f(x)/p(x)$</span>) and the resulting estimator will be unbiased.</p>

CC BY-SA 3.0
2017-03-11T16:17:44.600Z
So for designing a PDF for picking a light, is there a specific method that's proven to be effective? Or does everyone have their own combination of techniques such as the output power, orientation, etc as you mentioned? Also, will it make biased if I do that? Or does dividing by the PDF keep it unbiased?
Henry Bergin
CC BY-SA 3.0
2017-03-11T21:52:16.563Z
Unfortunately, I don't know any production-proven approaches in detail and even PBRT proposes only very simple methods. I extended the answer with what I know. And, just to be clear, for picking a light source you need to use probability, not PDF (probability density function).
ivokabel
CC BY-SA 4.0
2017-03-05T22:31:17.853Z
2021-03-15T20:20:27.937Z
2021-03-15T20:20:27.937Z
ivokabel
<p>I've got my path tracer working great for a single light, but I'm having trouble coming up with a solution for scenes with multiple lights. My first thought was to just send a ray to each light and sum up all the contributions. That worked fine, but it was very slow, especially for many lights. I tried researching techniques for working around this, but I found very little. I did find that some renderers weight each light and then pick one based on how much light they might contribute, but I couldn't find any detailed process of how that's actually done.</p>

<p>So my question is, could someone give me an overview of how this might be accomplished, or point me to a resource that goes over multiple lights? </p>

<lighting><pathtracing><sampling><monte-carlo><render>
Path Tracing With Multiple Lights
Henry Bergin
# Path Tracing With Multiple Lights

(Asked by: username_0 on 2017-03-02)

I've got my path tracer working great for a single light, but I'm having trouble coming up with a solution for scenes with multiple lights. My first thought was to just send a ray to each light and sum up all the contributions. That worked fine, but it was very slow, especially for many lights. I tried researching techniques for working around this, but I found very little. I did find that some renderers weight each light and then pick one based on how much light they might contribute, but I couldn't find any detailed process of how that's actually done.

So my question is, could someone give me an overview of how this might be accomplished, or point me to a resource that goes over multiple lights?

**Tags:** lighting, pathtracing, sampling, monte-carlo, render


---

## 1 answers

### Answer by username_1 on 2017-03-05. Score: 6 | Accepted answer

It's not that hard. If you have just planar or angular light sources, you can think of them as one light source split into multiple chunks and the only thing to deal with is how to sample this multi-light and how to compute the PDF of the resulting samples.

## Picking probability

First, you need to setup the picking probability $P(l)$ for each light source $l$. The picking probabilities can be any non-negative numbers, you just have to make sure that are always non-zero if the contributions of the respective lights are non-zero. However, the closer the probabilities are to the actual (relative) light contribution, the better the overall performance of your Monte Carlo estimator will be.

Contribution estimates may be:

* $1$: naive, uniform probability; good to start with; used by PBRT
* $power$: better
* $power / distance^2$: even better; closer light sources have greater contributions
* …and other improvements: make zero if not visible at all, multiply by the cosine of the inclination angle, etc.

Note that to get the light-picking probabilities, you need to normalise the contribution estimates to the sum of all of them:

$$
P(l)=
\frac
{ContribEst\_l}
{\sum\_{a\in\mathrm{Lights}}
{ContribEst\_a}}
$$

You could even use more different picking strategies if you find they work just for certain type of scenes and combine them using multiple importance sampling technique…

## Sampling

When sampling the lights, you just select one light $l$ with the appropriate probability $P(l)$ and then sample the light surface/angle with its own sampling strategy (with PDF $p\_l$). The resulting PDF $p$ will be:
$$
p(x)=P(l) \* p\_l(x)
$$

## Evaluating PDF

When computing the light sampling PDF for given direction (as needed for multiple importance sampling), you just find the light source at the direction, evaluate the PDF of the lights own strategy and, again, multiply it by the probability of picking this particular light.

## Conclusion

Now you have a sampling strategy which gives you PDF which can be used in the Monte Carlo estimators (e.g. $f(x)/p(x)$) and the resulting estimator will be unbiased.

> **Comments:**
> **username_0**: So for designing a PDF for picking a light, is there a specific method that's proven to be effective? Or does everyone have their own combination of techniques such as the output power, orientation, etc as you mentioned? Also, will it make biased if I do that? Or does dividing by the PDF keep it unbiased?  
> **username_1**: Unfortunately, I don't know any production-proven approaches in detail and even PBRT proposes only very simple methods. I extended the answer with what I know. And, just to be clear, for picking a light source you need to use probability, not PDF (probability density function).  

---

