This is an implementation of Paul Debevec's A Median Cut Algorithm for Light Probe Sampling. The code generates sample positions for 2^n light sources. You will still need to sum up the energy of the respective cut region to get the final flux. To run the sample, please fetch Sean Barrett's stb_image.