# Path Tracing With Multiple Lights

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?

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 {ContrEstimate_l} {\sum_{a\in\mathrm{Lights}} {ContrEstimate_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.

• 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 Mar 11 '17 at 16:17
• 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 Mar 11 '17 at 21:52