Implementing light clusters
In this section, we are going to describe our implementation of the light clustering algorithm. It’s based on this presentation: https://www.activision.com/cdn/research/2017_Sig_Improved_Culling_final.pdf. The main (and very smart) idea is to separate the XY plane from the Z range, combining the advantages of both tiling and clustering approaches. The algorithms are organized as follows:
- We sort the lights by their depth value in camera space.
- We then divide the depth range into bins of equal size, although a logarithmic subdivision might work better depending on your depth range.
- Next, we assign the lights to each bin if their bounding box falls within the bin range. We only store the minimum and maximum light index for a given bin, so we only need 16 bits for each bin, unless you need more than 65,535 lights!
- We then divide the screen into tiles (8x8 pixels, in our case) and determine which lights cover a given tile. Each tile...