Thursday, April 16, 2009

GPU Global Illumination

By this point it must be clear that my hobby programming has a very short attention span.


A purplish glow is cast on the wall. The ceiling is softly illuminated by reflections from the floor.


Some color bleeding is visible on the wall and floor. The spheres display the captured incident light at each probe point.


Wide view with indirect lighting disabled.


Wide view with indirect lighting enabled.

This demo divides the space in a small room into a voxel grid. Light probes (16x16 cube maps) are captured at the center points of each voxel, arranged as tiles on a huge 96x4096 RGB16F texture. This texture is then modulated by the first nine real spherical harmonic basis functions and rendered to a set of nine more 96x4096 RGB16F textures, three per pass. These nine huge float textures are reduced and rearranged in a number of passes to a set of nine 8x8x4 RGB16F volume textures representing the (rather low-resolution) incident light at every point in the room as a set of real spherical harmonic coefficients. The final pass is rendered using these volume textures to provide one bounce of interpolated indirect light in addition to the direct light cast by the static and camera-mounted spot lights.

Whew.

To summarize, this demo renders a scene with one bounce of indirect light, based on real spherical harmonic coefficients interpolated from a regular grid of 256 light probes.

The sample scene runs at about 15 FPS on my aging desktop with an NVIDIA GeForce 7800 GT.

Now to optimize the slow out of it.