Graphics Reference
In-Depth Information
around this by repeatedly executing the same loops but with iteration-dependent
state data stored in texture maps. The use of the stencil buffer to record the state
of each ray so that the appropriate kernel can be dispatched was an innovation
for efficiency. The algorithm can be extended to path tracing by using different
shading kernels, making it possible to do true GI in graphics hardware.
2.5.4 GPU Photon Mapping
In 2003, a year after the publication of the GPU ray-tracing paper, Purcell and
others authored a paper describing how to do photon mapping on a GPU [Purcell
et al. 03]. This offers a significant advantage in addition to the speedup gained by
using hardware rendering: it allows the photon-map construction to be visualized,
and even directed, during the photon particle simulation. GPU programming had
limitations at the time (and still does) that make it difficult to implement complex
algorithms, so the algorithm implemented in Purcell's 2003 paper is a modified
form of photon mapping that lacks the power of a full implementation. Nonethe-
less, it introduced a new way of rendering using particle simulation.
The main problems of implementing photon mapping on the GPU are how
to do the particle-simulation phase, and how to do the photon map lookup in the
rendering phase. The rendering phase is essentially just ray tracing with map
lookup, and the ray-tracing part was already done. The method proposed in the
2003 paper stores all the photons in a texture called the photon texture or photon
frame ( Figure 2.16 ) . This texture contains all the photon positions, directions,
and power at a particular bounce depth for the entire scene. At each bounce, the
photons at the current bounce are stored in a frame taken as the input for the
process that computes the next bounce. The photons in the subsequent bounce are
stored into the next photon texture. The simulation can be viewed as it evolves by
displaying the texture for each bounce.
The second problem, that of photon lookup in the rendering phase, is han-
dled by transferring the photon-map information into a framebuffer. Ideally there
would be one photon per pixel, and each pixel would contain the index of the
photon in the photon texture. But implementing this ends up being too slow and
cumbersome. Instead, the photons are arranged in a uniform grid for efficiency,
and each grid cell corresponding to a square group of pixels in the framebuffer is
known as a point ( Figure 2.17 ) . Each “point” thus consists of multiple pixels, and
each pixel corresponds to a photon. The value of each pixel contains the index of
the photon in the final photon texture. The collection of all the pixels makes up
the photon map.
The pixels of each point are drawn using the glPoint function; a vertex pro-
gram handles mapping the grid cells to the points in the framebuffer. An added
Search WWH ::




Custom Search