Skip to content
Median cut for deterministic biased sampling of environment maps.
Haskell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data
src
.gitignore
LICENSE
README.md
Setup.hs
median-cut.cabal
stack.yaml

README.md

Median Cut

The median cut algorithm is a method to deterministically sample an environment map. This is achieved by splitting the environment map along the longest dimension so that there is equal energy in both halves. This is repeated n times recursively in each partition. Once there have been n iterations, the lights are placed in the centroid of each region. Below is an example with 6 splits, meaning there are 2^6 = 64 partitions.

median cut

The average colour of each region is assigned to each light source that was created in each region.

median cut lights

Finally, these discrete lights can be used to light diffuse objects efficiently, by only having to sample a few lights.

lighting

Build and run

To compile and run, one has to first download stack

The simplest way to do this is by executing the following command:

curl -sSL https://get.haskellstack.org/ | sh

Then run setup in this directory:

stack setup

Finally the executable can be built and run using the following:

stack build --exec median-cut

This project relies on a open source library that I wrote to load PFM files which is hosted at PFM. It will automatically get downloaded when built with stack.

You can’t perform that action at this time.