Importance Sampling for Cube Maps

Importance sampling of environment maps is useful especially when the map contains bright lights, such as daylight sky maps.

Renderers like Mitsuba and pbrt implement importance sampling for equirectangular environment maps as explained in Sec. 12.5.2 of Physically Based Rendering. This method requires an equirectangular importance map to sample light directions and compute their corresponding probability density function (pdf) values. It must therefore take the non-uniform nature of the map into account for both steps.

But what if you want to use cube maps? Using the same approach would lead to complicated sample and pdf computations.

Instead, you can use an equal-area importance map, i.e. a map that does not suffer from area distortions. This allows uniform sampling and thus simplifies both sampling and pdf computation.

WurblPT uses a combination of Lambert Equal Area projection from sphere to disk followed by Shirley's equal-area projection from disk to square. This mapping and its inverse can be computed efficiently. Here's an example of a cube map and the corresponding equal-area importance map:
Cube Map Importance Map

This approach allows efficient importance sampling for cube maps. And, since the importance map is completely independent from the environment map, it also works unmodified for equirectangular maps, and in fact for any other type of environment map you can come up with! Furthermore, you can adapt the importance map resolution to your needs to reduce memory usage.

The original implementation consists of just 150 lines of C++ code. In WurblPT, the method is implemented in envmap.hpp. You can use the wurblpt-material-comparison example to test the effects of various environment maps and importance map resolutions.

The technique can also be used in GPU-based renderers: you need one additional square texture for the importance map (which can have low resolution), and you can leverage the existing hardware support for high-quality cubemap sampling for your environment map.

For full details, see M. Lambers. Parameterization-Independent Importance Sampling of Environment Maps. Tech. rep. Computer Graphics Group, University of Siegen, Aug. 2022. doi: 10.48550/arXiv.2208.10815. (PDF, Code, Bib)