
GPU Gems 3
GPU Gems 3 is now available for free online!The CD content, including demos and content, is available on the web and for download.
You can also subscribe to our Developer News Feed to get notifications of new material on the site.
Part II: Light and Shadows

The subject of light and shadows may appear simplistic, but in reality it concisely represents what modern rendering is all about. Modeling light visibility is fundamental and sublime in the field of computer graphics. After all, it is the subtleties of reality that we strive most fervently to capture—the fine differences that allow the human eye to accept what is being presented as more than just a simulation. With the rise in popularity of programmable shading and the refinement of highlevel shading languages, we have come a long way from static light maps and projected shadows, so this part of the book presents six chapters that are the state of the art in representing the interplay of light and shadow.
The shadow map is the primary light visibility tool currently used in real-time applications. The simplicity of the algorithm is what makes using shadow maps so attractive. At the same time, the latest applications require more than a pedestrian point light. Shadow-map filtering has long been used to mitigate shadow-map aliasing. Today filtering is used to simulate the effect of area lights. With some clever filtering, plausible soft shadows can be constructed from a shadow map using algorithms such as percentage-closer soft shadows. Large filter kernels needed for area light simulation are expensive because each shadow-map sample must be compared against the shaded fragment's distance from the light. One method for accelerating this, introduced in 2006, is variance shadow maps (VSMs), which can be prefiltered. In Chapter 8, "Summed-Area Variance Shadow Maps," Andrew Lauritzen of the University of Waterloo presents a detailed explanation of VSMs and introduces a method for changing the filtered kernel arbitrarily per pixel.
Offline rendering does not have the same time constraints as, say, a first-person shooter. Time is still important, though, and making full use of the computing resources at hand is critical as the complexity of the rendering algorithms and scenes increases. When artists need to iterate on scenes many times to achieve the desired effect, it is critical that each iteration have the highest possible performance. To meet this requirement, relighting engines have been developed that make assumptions about the scene, such as the camera position not changing, to accelerate each step of the lighting refinement. In Chapter 9, "Interactive Cinematic Relighting with Global Illumination," Fabio Pellacini of Dartmouth College, Milo
Ha
an of Cornell University, and Kavita Bala, also of Cornell, present how to use the GPU to achieve much faster relighting than was possible with a CPU.
An issue that haunts many shadow map implementations is the limited resolution of the shadow map. Because a shadow map discretizes a continuous function of depth, aliasing is inherent without infinite resolution. Compounding the problem is the lack of correlation between the distribution of samples in the shadow map and the distribution of fragments in the final scene. It is therefore imperative that the limited resolution of the shadow map be used properly. In Chapter 10, "Parallel-Split Shadow Maps on Programmable GPUs," Fan Zhang and Hanqiu Sun of The Chinese University of Hong Kong and Oskari Nyman of Helsinki University of Technology present an intuitive approach to partitioning the resolution for shadow mapping to more correctly map to the actual usage.
Although shadow maps have received much attention, they are not perfect, and their limitations are unacceptable for some applications. The most widely accepted alternative for real-time dynamic shadows is stencil shadow volumes (SSVs). Like shadow maps, SSVs have been well studied and have been shown to be an elegant solution to the aliasing problems that plague shadow maps. Because the complexity of SSVs is tied to the complexity of the shadowing geometry, robust and fast SSVs have been a topic of much research. With Chapter 11, "Efficient and Robust Shadow Volumes Using Hierarchical Occlusion Culling and Geometry Shaders," Martin Stich of mental images and Carsten Wächter and Alexander Keller of Ulm University show how to handle many of the SSV "gotchas" and detail a system that can even handle nonclosed meshes.
Beyond modeling local lighting with shadow maps or SSVs, current applications demand global illumination techniques that provide more immersive sensory feedback by taking into account the entire scene. Several techniques, from radiosity to precomputed radiance transfer, can achieve good results for static scenes but are difficult to adapt to the dynamic world of a game. Hybrid techniques that combine traditional real-time dynamic lighting models for local lights, along with some representation of the global lighting contribution, will be used more frequently to achieve greater realism without sacrificing too much performance. One such technique, which works well to simulate the contribution of a distant light such as the sun, is ambient occlusion. Real-time ambient occlusion is possible today, even for dynamic scenes, but it suffers from several artifacts caused by approximations assumed in Michael Bunnell's original approach (which appeared in GPU Gems 2). Chapter 12, "High-Quality Ambient Occlusion" by Jared Hoberock and Yuntao Jia of the University of Illinois at Urbana-Champaign, builds upon Bunnell's work and robustly and efficiently solves many of these artifacts.
Chapter 13, "Volumetric Light Scattering as a Post-Process" by Kenny Mitchell of Electronic Arts, tackles the topic of modeling light as it travels through morecomplex mediums. Often called "god rays," this effect that the atmosphere has upon light transport adds more believability to outdoor scenes. This chapter presents a functional approach to estimating such scattering with a postprocess shader, which properly handles occlusion by opaque objects such as large buildings.
Kevin Myers, NVIDIA Corporation
- Contributors
- Foreword
- Part I: Geometry
- Chapter 1. Generating Complex Procedural Terrains Using the GPU
- Chapter 2. Animated Crowd Rendering
- Chapter 3. DirectX 10 Blend Shapes: Breaking the Limits
- Chapter 4. Next-Generation SpeedTree Rendering
- Chapter 5. Generic Adaptive Mesh Refinement
- Chapter 6. GPU-Generated Procedural Wind Animations for Trees
- Chapter 7. Point-Based Visualization of Metaballs on a GPU
- Part II: Light and Shadows
- Chapter 10. Parallel-Split Shadow Maps on Programmable GPUs
- Chapter 11. Efficient and Robust Shadow Volumes Using Hierarchical Occlusion Culling and Geometry Shaders
- Chapter 12. High-Quality Ambient Occlusion
- Chapter 13. Volumetric Light Scattering as a Post-Process
- Chapter 8. Summed-Area Variance Shadow Maps
- Chapter 9. Interactive Cinematic Relighting with Global Illumination
- Part III: Rendering
- Chapter 14. Advanced Techniques for Realistic Real-Time Skin Rendering
- Chapter 15. Playable Universal Capture
- Chapter 16. Vegetation Procedural Animation and Shading in Crysis
- Chapter 17. Robust Multiple Specular Reflections and Refractions
- Chapter 18. Relaxed Cone Stepping for Relief Mapping
- Chapter 19. Deferred Shading in Tabula Rasa
- Chapter 20. GPU-Based Importance Sampling
- Part IV: Image Effects
- Chapter 21. True Impostors
- Chapter 22. Baking Normal Maps on the GPU
- Chapter 23. High-Speed, Off-Screen Particles
- Chapter 24. The Importance of Being Linear
- Chapter 25. Rendering Vector Art on the GPU
- Chapter 26. Object Detection by Color: Using the GPU for Real-Time Video Image Processing
- Chapter 27. Motion Blur as a Post-Processing Effect
- Chapter 28. Practical Post-Process Depth of Field
- Part V: Physics Simulation
- Chapter 29. Real-Time Rigid Body Simulation on GPUs
- Chapter 30. Real-Time Simulation and Rendering of 3D Fluids
- Chapter 31. Fast N-Body Simulation with CUDA
- Chapter 32. Broad-Phase Collision Detection with CUDA
- Chapter 33. LCP Algorithms for Collision Detection Using CUDA
- Chapter 34. Signed Distance Fields Using Single-Pass GPU Scan Conversion of Tetrahedra
- Chapter 35. Fast Virus Signature Matching on the GPU
- Part VI: GPU Computing
- Chapter 36. AES Encryption and Decryption on the GPU
- Chapter 37. Efficient Random Number Generation and Application Using CUDA
- Chapter 38. Imaging Earth's Subsurface Using CUDA
- Chapter 39. Parallel Prefix Sum (Scan) with CUDA
- Chapter 40. Incremental Computation of the Gaussian
- Chapter 41. Using the Geometry Shader for Compact and Variable-Length GPU Feedback
- Preface