GPU Gems: Programming Techniques, Tips and Tricks for Real-Time Graphics

Book description

GPU Gems has won a prestigious Front Line Award from Game Developer Magazine. The Front Line Awards recognize products that enable faster and more efficient game development, advancing the state of the art.

FULL COLOR THROUGHOUT!

“This collection of articles is particularly impressive for its depth and breadth. The book includes product-oriented case studies, previously unpublished state-of-the-art research, comprehensive tutorials, and extensive code samples and demos throughout.”
—Eric Haines, Author of Real-Time Rendering

GPU Gems is a cool toolbox of advanced graphics techniques. Novice programmers and graphics gurus alike will find the Gems practical, intriguing and useful.”
—Tim Sweeney, Lead Programmer of Unreal at Epic Games

GPU Gems is a compilation of articles covering practical real-time graphics techniques arising from the research and practice of cutting-edge developers. It focuses on the programmable graphics pipeline available in today’s graphics processing units (GPUs) and highlights quick and dirty tricks used by leading developers, as well as fundamental, performance-conscious techniques for creating advanced visual effects. The contributors and editors, collectively, bring countless years of experience to enlighten and propel the reader into the fascinating world of programmable real-time graphics.

Major topics covered include:

  • Natural effects

  • Lighting and shadows

  • Materials

  • Image processing

  • Performance and practicalities

  • Beyond triangles

  • Contributors are from the following universities and corporations:

  • Alias Systems

  • Brown University

  • Croteam

  • Cyan Worlds

  • Hochschule Bremen

  • Industrial Light & Magic

  • iXBT.com

  • Monolith Productions

  • New York University

  • Novarama

  • NVIDIA

  • Paralelo Computacao

  • Piranha Bytes

  • Pixar Animation Studios

  • Siemens Medical Solutions

  • Softimage Co.

  • Softlab-NSK

  • Sony Pictures Imageworks

  • Stanford University

  • UC Davis

  • UNC-Chapel Hill

  • Universitat Pompeu Fabra

  • University of Utah

  • University of Waterloo

  • The accompanying CD-ROM includes complementary examples and sample programs.



    Table of contents

    1. Copyright
      1. Dedication
    2. Foreword
    3. Preface
      1. Our Intended Audience
      2. Trying the Examples
      3. Acknowledgments
    4. Contributors
    5. I. Natural Effects
      1. 1. Effective Water Simulation from Physical Models
        1. 1.1. Goals and Scope
        2. 1.2. The Sum of Sines Approximation
          1. 1.2.1. Selecting the Waves
          2. 1.2.2. Normals and Tangents
          3. 1.2.3. Geometric Waves
            1. Directional or Circular
            2. Gerstner Waves
            3. Wavelength and Speed
            4. Amplitude
            5. Direction
          4. 1.2.4. Texture Waves
            1. Wavelength and Speed
            2. Amplitude and Precision
            3. Direction and Tiling
        3. 1.3. Authoring
          1. 1.3.1. Using Depth
          2. 1.3.2. Overrides
          3. 1.3.3. Edge-Length Filtering
          4. 1.3.4. Texture Coordinates
        4. 1.4. Runtime Processing
          1. 1.4.1. Bump-Environment Mapping Parameters
            1. Tangent-Space Basis Vectors
            2. Eye Vector
          2. 1.4.2. Vertex and Pixel Processing
        5. 1.5. Conclusion
        6. 1.6. References
      2. 2. Rendering Water Caustics
        1. 2.1. Introduction
        2. 2.2. Computing Caustics
        3. 2.3. Our Approach
        4. 2.4. Implementation Using OpenGL
        5. 2.5. Implementation Using a High-Level Shading Language
        6. 2.6. Conclusion
        7. 2.7. References
      3. 3. Skin in the “Dawn” Demo
        1. 3.1. Introduction
        2. 3.2. Skin Shading
        3. 3.3. Lighting the Scene
          1. 3.3.1. A High-Dynamic-Range Environment
          2. 3.3.2. The Occlusion Term
        4. 3.4. How Skin Responds to Light
        5. 3.5. Implementation
          1. 3.5.1. The Vertex Shader
          2. 3.5.2. The Fragment Shader
        6. 3.6. Conclusion
        7. 3.7. References
      4. 4. Animation in the “Dawn” Demo
        1. 4.1. Introduction
        2. 4.2. Mesh Animation
        3. 4.3. Morph Targets
          1. 4.3.1. Morph Targets in a High-Level Language
          2. 4.3.2. Morph Target Implementation
        4. 4.4. Skinning
          1. 4.4.1. Accumulated Matrix Skinning
        5. 4.5. Conclusion
        6. 4.6. References
      5. 5. Implementing Improved Perlin Noise
        1. 5.1. The Noise Function
        2. 5.2. The Original Implementation
        3. 5.3. Deficiencies of the Original Implementation
        4. 5.4. Improvements to Noise
        5. 5.5. How to Make Good Fake Noise in Pixel Shaders
        6. 5.6. Making Bumps Without Looking at Neighboring Vertices
        7. 5.7. Conclusion
        8. 5.8. References
      6. 6. Fire in the “Vulcan” Demo
        1. 6.1. Creating Realistic Flames
        2. 6.2. Implementing Animated Sprites
          1. 6.2.1. Animating Flames and Smoke
            1. Custom Smoke Generator
          2. 6.2.2. Adding Variety to the Flames
          3. 6.2.3. Storing the Animation
          4. 6.2.4. Blending Flames and Smoke
        3. 6.3. Particle Motion
        4. 6.4. Performance
          1. 6.4.1. Layer Composition
          2. 6.4.2. Custom Sprites
        5. 6.5. Post-Rendering Effects
          1. 6.5.1. Glow
          2. 6.5.2. Heat Shimmer
          3. 6.5.3. Grain
          4. 6.5.4. The Final Program
        6. 6.6. Conclusion
      7. 7. Rendering Countless Blades of Waving Grass
        1. 7.1. Introduction
        2. 7.2. Overview
        3. 7.3. Preparation of the Grass Objects
          1. 7.3.1. Grass Texture
          2. 7.3.2. Grass Objects
        4. 7.4. Animation
          1. 7.4.1. The General Idea
          2. 7.4.2. Animation per Cluster of Grass Objects
            1. Pros
            2. Cons
            3. Algorithm
          3. 7.4.3. Animation per Vertex
            1. Pros
            2. Cons
            3. Algorithm
          4. 7.4.4. Animation per Grass Object
            1. Pros
            2. Cons
            3. Algorithm
        5. 7.5. Conclusion
        6. 7.6. Further Reading
      8. 8. Simulating Diffraction
        1. 8.1. What Is Diffraction?
          1. 8.1.1. The Wave Theory of Light
          2. 8.1.2. The Physics of Diffraction
        2. 8.2. Implementation
        3. 8.3. Results
        4. 8.4. Conclusion
        5. 8.5. References
    6. II. Lighting and Shadows
      1. 9. Efficient Shadow Volume Rendering
        1. 9.1. Introduction
          1. 9.1.1. Where to Use Shadow Volumes
        2. 9.2. Program Structure
          1. 9.2.1. Multipass Rendering
          2. 9.2.2. Vertex Buffer Structure
          3. 9.2.3. Working at Infinity
        3. 9.3. Detailed Discussion
          1. 9.3.1. The Math
          2. 9.3.2. The Code
          3. 9.3.3. The markShadows Method
          4. 9.3.4. The findBackfaces Method
          5. 9.3.5. Light and Dark Caps
          6. 9.3.6. Sides
        4. 9.4. Debugging
        5. 9.5. Geometry Optimizations
          1. 9.5.1. Directional Lights
          2. 9.5.2. Point Lights and Spotlights
          3. 9.5.3. Culling Shadow Volumes
          4. 9.5.4. Uncapped Performance
        6. 9.6. Fill-Rate Optimizations
          1. 9.6.1. Finite Volumes
          2. 9.6.2. XY Clipping
          3. 9.6.3. Z-Bounds
        7. 9.7. Future Shadows
        8. 9.8. References
      2. 10. Cinematic Lighting
        1. 10.1. Introduction
        2. 10.2. A Direct Lighting Illumination Model
          1. 10.2.1. Selection
          2. 10.2.2. Color
          3. 10.2.3. Shaping
          4. 10.2.4. Shadowing
            1. Darkness
            2. Hue
            3. Reflection
            4. Shadow Maps
            5. Shadow Blurring
          5. 10.2.5. Texturing
          6. 10.2.6. Results
        3. 10.3. The Uberlight Shader
        4. 10.4. Performance Concerns
          1. 10.4.1. Speed
          2. 10.4.2. Expense
          3. 10.4.3. Optimization
        5. 10.5. Conclusion
        6. 10.6. References
      3. 11. Shadow Map Antialiasing
        1. 11.1. Introduction
        2. 11.2. Percentage-Closer Filtering
        3. 11.3. A Brute-Force Implementation
        4. 11.4. Using Fewer Samples
        5. 11.5. Why It Works
        6. 11.6. Conclusion
        7. 11.7. References
      4. 12. Omnidirectional Shadow Mapping
        1. 12.1. Introduction
          1. 12.1.1. Stencil Shadows
          2. 12.1.2. Shadow Mapping
        2. 12.2. The Shadow-Mapping Algorithm
          1. 12.2.1. Conditions
          2. 12.2.2. The Algorithm
          3. 12.2.3. Texture Format
          4. 12.2.4. The Size of the Shadow Map
          5. 12.2.5. The Range of Values for Geometry
        3. 12.3. Implementation
          1. 12.3.1. System Requirements
          2. 12.3.2. Resource Creation
          3. 12.3.3. Rendering Phase 1: Rendering into the Shadow Map
            1. The Vertex Shader
            2. The Pixel Shader
          4. 12.3.4. Rendering Phase 2: Base Rendering
          5. 12.3.5. The Lighting Calculation
          6. 12.3.6. The Shadow Calculation
          7. 12.3.7. Tips and Tricks
          8. 12.3.8. Finalizing the Shading Pass (Lighting × Shadow)
        4. 12.4. Adding Soft Shadows
        5. 12.5. Conclusion
        6. 12.6. References
      5. 13. Generating Soft Shadows Using Occlusion Interval Maps
        1. 13.1. The Gas Station
        2. 13.2. The Algorithm
        3. 13.3. Creating the Maps
        4. 13.4. Rendering
        5. 13.5. Limitations
        6. 13.6. Conclusion
        7. 13.7. References
      6. 14. Perspective Shadow Maps: Care and Feeding
        1. 14.1. Introduction
        2. 14.2. Problems with the PSM Algorithm
          1. 14.2.1. Virtual Cameras
            1. Virtual Camera Issues
            2. A Solution for Virtual Camera Issues
          2. 14.2.2. The Light Camera
            1. Unit Cube Clipping
            2. Using Cube Maps
          3. 14.2.3. Biasing
        3. 14.3. Tricks for Better Shadow Maps
          1. 14.3.1. Filtering
          2. 14.3.2. Blurring
        4. 14.4. Results
        5. 14.5. References
      7. 15. Managing Visibility for Per-Pixel Lighting
        1. 15.1. Visibility in a GPU Book?
        2. 15.2. Batches and Per-Pixel Lighting
          1. 15.2.1. A Per-Pixel Example
          2. 15.2.2. Just How Many Batches, Anyway?
        3. 15.3. Visibility As Sets
          1. 15.3.1. The Visible Set
          2. 15.3.2. The Lights Set
          3. 15.3.3. The Illumination Set
          4. 15.3.4. The Shadow Set
        4. 15.4. Generating Sets
          1. 15.4.1. The Visible Set
          2. 15.4.2. The Lights Set
          3. 15.4.3. The Illumination Set
          4. 15.4.4. The Shadow Set
            1. Shadows for Lights Inside a Frustum
            2. Shadows for Lights Outside a Frustum
        5. 15.5. Visibility for Fill Rate
        6. 15.6. Practical Application
        7. 15.7. Conclusion
        8. 15.8. References
    7. III. Materials
      1. 16. Real-Time Approximations to Subsurface Scattering
        1. 16.1. The Visual Effects of Subsurface Scattering
        2. 16.2. Simple Scattering Approximations
        3. 16.3. Simulating Absorption Using Depth Maps
          1. 16.3.1. Implementation Details
          2. 16.3.2. More Sophisticated Scattering Models
        4. 16.4. Texture-Space Diffusion
          1. 16.4.1. Possible Future Work
        5. 16.5. Conclusion
        6. 16.6. References
      2. 17. Ambient Occlusion
        1. 17.1. Overview
        2. 17.2. The Preprocessing Step
        3. 17.3. Hardware-Accelerated Occlusion
        4. 17.4. Rendering with Ambient Occlusion Maps
          1. 17.4.1. Environment Lighting
        5. 17.5. Conclusion
        6. 17.6. Further Reading
      3. 18. Spatial BRDFs
        1. 18.1. What Is an SBRDF?
        2. 18.2. Details of the Representation
        3. 18.3. Rendering Using Discrete Lights
          1. 18.3.1. Texture Sampling
        4. 18.4. Rendering Using Environment Maps
          1. 18.4.1. The Math
          2. 18.4.2. The Shader Code
        5. 18.5. Conclusion
        6. 18.6. References
      4. 19. Image-Based Lighting
        1. 19.1. Localizing Image-Based Lighting
        2. 19.2. The Vertex Shader
        3. 19.3. The Fragment Shader
          1. 19.3.1. Additional Shader Details
        4. 19.4. Diffuse IBL
        5. 19.5. Shadows
        6. 19.6. Using Localized Cube Maps As Backgrounds
        7. 19.7. Conclusion
        8. 19.8. Further Reading
      5. 20. Texture Bombing
        1. 20.1. Texture Bombing 101
          1. 20.1.1. Finding the Cell
          2. 20.1.2. Sampling the Image
          3. 20.1.3. Adjacent Cells’ Images
          4. 20.1.4. Image Priority
          5. 20.1.5. Procedural Images
            1. Multiple Images per Cell
          6. 20.1.6. Random Image Selection from Multiple Choices
        2. 20.2. Technical Considerations
          1. 20.2.1. Efficiency Issues
        3. 20.3. Advanced Features
          1. 20.3.1. Scaling and Rotating
          2. 20.3.2. Controlled Variable Density
          3. 20.3.3. Procedural 3D Bombing
          4. 20.3.4. Time-Varying Textures
          5. 20.3.5. Voronoi-Related Cellular Methods
        4. 20.4. Conclusion
        5. 20.5. References
    8. IV. Image Processing
      1. 21. Real-Time Glow
        1. 21.1. Overview of the Technique
        2. 21.2. Rendering Glows: Step by Step
          1. 21.2.1. Specifying and Rendering the Sources of Glow
          2. 21.2.2. Blurring the Glow Sources
          3. 21.2.3. Adapting the Separable Convolution
          4. 21.2.4. Convolution on the GPU
        3. 21.3. Hardware-Specific Implementations
          1. 21.3.1. Direct3D 9
          2. 21.3.2. Direct3D 8
          3. 21.3.3. Direct3D 7
        4. 21.4. Other Uses for Blur
        5. 21.5. Adding the Effects to a Game Engine
          1. 21.5.1. Rendering Context
          2. 21.5.2. Aliasing Issues
          3. 21.5.3. DirectX 7 Accuracy Issues
          4. 21.5.4. The After-Image Effect
          5. 21.5.5. The Variable Ramping Effect
        6. 21.6. Conclusion
        7. 21.7. References
      2. 22. Color Controls
        1. 22.1. Introduction
        2. 22.2. Channel-Based Color Correction
          1. 22.2.1. Levels
          2. 22.2.2. Curves
        3. 22.3. Multichannel Color Correction and Conversion
          1. 22.3.1. Grayscale Conversion
          2. 22.3.2. Color-Space Conversions
        4. 22.4. References
      3. 23. Depth of Field: A Survey of Techniques
        1. 23.1. What Is Depth of Field?
          1. 23.1.1. Calculating the Circle of Confusion
          2. 23.1.2. Major Techniques
        2. 23.2. Ray-Traced Depth of Field
        3. 23.3. Accumulation-Buffer Depth of Field
        4. 23.4. Layered Depth of Field
          1. 23.4.1. Analysis
        5. 23.5. Forward-Mapped Z-Buffer Depth of Field
          1. 23.5.1. Analysis
        6. 23.6. Reverse-Mapped Z-Buffer Depth of Field
          1. 23.6.1. Analysis
            1. Artifacts Due to Depth Discontinuities
            2. Artifacts Due to Bilinear Interpolation
            3. Artifacts Due to Pixel Bleeding
        7. 23.7. Conclusion
        8. 23.8. References
      4. 24. High-Quality Filtering
        1. 24.1. Quality vs. Speed
          1. 24.1.1. Filter Kernels: Image-to-Image Conversions
            1. User-Defined Kernels
            2. A Speedup for Grayscale Data
            3. When the Kernel Is Constant
            4. A Bicubic Filter Kernel
            5. Screen-Aligned Kernels
        2. 24.2. Understanding GPU Derivatives
        3. 24.3. Analytical Antialiasing and Texturing
          1. 24.3.1. Interacting with Graphics API Antialiasing
        4. 24.4. Conclusion
        5. 24.5. References
      5. 25. Fast Filter-Width Estimates with Texture Maps
        1. 25.1. The Need for Derivatives in Shaders
        2. 25.2. Computing Filter Width with Textures
        3. 25.3. Discussion
        4. 25.4. Further Reading
      6. 26. The OpenEXR Image File Format
        1. 26.1. What Is OpenEXR?
          1. 26.1.1. High-Dynamic-Range Images
          2. 26.1.2. A “Half” Format
          3. 26.1.3. Range of Representable Values
          4. 26.1.4. Color Resolution
          5. 26.1.5. C++ Interface
        2. 26.2. The OpenEXR File Structure
          1. 26.2.1. The Header
          2. 26.2.2. The Pixels
        3. 26.3. OpenEXR Data Compression
        4. 26.4. Using OpenEXR
          1. 26.4.1. Reading and Displaying an OpenEXR Image
          2. 26.4.2. Rendering and Writing an OpenEXR Image
        5. 26.5. Linear Pixel Values
        6. 26.6. Creating and Using HDR Images
        7. 26.7. Conclusion
        8. 26.8. References
      7. 27. A Framework for Image Processing
        1. 27.1. Introduction
        2. 27.2. Framework Design
          1. 27.2.1. Operators and Filters
          2. 27.2.2. Image Data
          3. 27.2.3. Missing Pieces
        3. 27.3. Implementation
          1. 27.3.1. The Image Class
          2. 27.3.2. The ImageFilter Class
          3. 27.3.3. Implementing a Filter
            1. Filter Parameters
            2. The Fragment Program
            3. Setting the Cg Parameters
        4. 27.4. A Sample Application
        5. 27.5. Performance and Limitations
        6. 27.6. Conclusion
        7. 27.7. References
    9. V. Performance and Practicalities
      1. 28. Graphics Pipeline Performance
        1. 28.1. Overview
          1. 28.1.1. The Pipeline
          2. 28.1.2. Methodology
        2. 28.2. Locating the Bottleneck
          1. 28.2.1. Raster Operations
          2. 28.2.2. Texture Bandwidth
          3. 28.2.3. Fragment Shading
          4. 28.2.4. Vertex Processing
          5. 28.2.5. Vertex and Index Transfer
        3. 28.3. Optimization
          1. 28.3.1. Optimizing on the CPU
            1. Reduce Resource Locking
            2. Maximize Batch Size
          2. 28.3.2. Reducing the Cost of Vertex Transfer
          3. 28.3.3. Optimizing Vertex Processing
          4. 28.3.4. Speeding Up Fragment Shading
          5. 28.3.5. Reducing Texture Bandwidth
          6. 28.3.6. Optimizing Frame-Buffer Bandwidth
        4. 28.4. Conclusion
        5. 28.5. References
      2. 29. Efficient Occlusion Culling
        1. 29.1. What Is Occlusion Culling?
          1. 29.1.1. Occlusion Query
          2. 29.1.2. Early-Z Rejection
        2. 29.2. How Does Occlusion Query Work?
        3. 29.3. Beginning to Use Occlusion Queries
          1. 29.3.1. How to Use Occlusion Queries Properly
          2. 29.3.2. Occluders vs. Occludees
        4. 29.4. One Step Further
          1. 29.4.1. Sorting Things Out
          2. 29.4.2. A Small Caveat
        5. 29.5. A Word About Bounding Boxes
          1. 29.5.1. Static Objects
          2. 29.5.2. Animated Objects
        6. 29.6. Other Issues
          1. 29.6.1. CPU Overhead Too High
          2. 29.6.2. Rendering at High Resolutions
          3. 29.6.3. Fast Depth-Writing Performance
          4. 29.6.4. Frustum Culling
        7. 29.7. A Little Reminder
        8. 29.8. An Application: Lens Flares
          1. 29.8.1. Rendering Lens Flares the Old Way
          2. 29.8.2. Rendering Lens Flares the New Way
        9. 29.9. Conclusion
        10. 29.10. References
      3. 30. The Design of FX Composer
        1. 30.1. Tools Development
        2. 30.2. Initial Features and Target Audience
        3. 30.3. Object Design
          1. 30.3.1. Benefits of the Interface Approach
            1. Object Querying
            2. Object Lifetime
            3. Plug-In Management
            4. Connection Parameters
            5. Message Senders and Receivers
        4. 30.4. File Format
        5. 30.5. User Interface
        6. 30.6. Direct3D Graphics Implementation
          1. 30.6.1. Device Windows
          2. 30.6.2. Direct3D Effects
          3. 30.6.3. ID3DXEffectCompiler
          4. 30.6.4. ID3DXEffect
        7. 30.7. Scene Management
          1. 30.7.1. Geometry Pipes
            1. Skinning
        8. 30.8. Conclusion
        9. 30.9. References
      4. 31. Using FX Composer
        1. 31.1. Getting Started
          1. 31.1.1. The Materials Panel
          2. 31.1.2. The Scene Graph Panel
          3. 31.1.3. The Editor Window
          4. 31.1.4. The Shader Perf Panel
          5. 31.1.5. The Properties Panel
          6. 31.1.6. The Scene Panel
          7. 31.1.7. The Textures Panel
          8. 31.1.8. The Tasks Panel
          9. 31.1.9. The Log Panel
        2. 31.2. Sample Project
        3. 31.3. Conclusion
      5. 32. An Introduction to Shader Interfaces
        1. 32.1. The Basics of Shader Interfaces
        2. 32.2. A Flexible Description of Lights
        3. 32.3. Material Trees
        4. 32.4. Conclusion
        5. 32.5. References
      6. 33. Converting Production RenderMan Shaders to Real-Time
        1. 33.1. Introduction
          1. 33.1.1. Conversion by Example
        2. 33.2. Lights
          1. 33.2.1. Light Sources
          2. 33.2.2. Light Source Shaders
          3. 33.2.3. Additional Lighting Parameters
        3. 33.3. The Vertex Program vs. the Fragment Program
        4. 33.4. Using Vertex and Fragment Programs
        5. 33.5. Optimization Techniques on the Fragment Program
          1. 33.5.1. Moving Code to the Application Level
          2. 33.5.2. Moving Code to the Vertex Program
          3. 33.5.3. Optimizing Through Texture Lookups
          4. 33.5.4. Optimizing for Vectorization
          5. 33.5.5. Final Optimizations
        6. 33.6. Results and Conclusions
        7. 33.7. References
      7. 34. Integrating Hardware Shading into Cinema 4D
        1. 34.1. Introduction
        2. 34.2. Connecting Cinema 4D to CgFX
        3. 34.3. Shader and Parameter Management
        4. 34.4. Emulating the Offline Renderer
        5. 34.5. Results and Performance
        6. 34.6. Lessons Learned
        7. 34.7. References
      8. 35. Leveraging High-Quality Software Rendering Effects in Real-Time Applications
        1. 35.1. Introduction
        2. 35.2. The Content Pipeline for Hardware Rendering
        3. 35.3. Components of Hardware Rendering
          1. 35.3.1. Geometric Data
          2. 35.3.2. Attribute Maps
        4. 35.4. Generating the Components
          1. 35.4.1. Creating the Geometry
          2. 35.4.2. Rendering to Textures and Vertices
        5. 35.5. Test Case and Results
        6. 35.6. Conclusion
        7. 35.7. References
      9. 36. Integrating Shaders into Applications
        1. 36.1. Introduction
        2. 36.2. About Shaders
          1. 36.2.1. Shader Languages
            1. Individual Programs
            2. Effect Files: Why Use Them?
        3. 36.3. The Anatomy of an Effect File
          1. 36.3.1. Variables
          2. 36.3.2. Structures
          3. 36.3.3. Passes
          4. 36.3.4. Techniques
          5. 36.3.5. Annotations
        4. 36.4. Types of Shader Data
          1. 36.4.1. Scene Information
          2. 36.4.2. Materials
          3. 36.4.3. Renderer Context
          4. 36.4.4. Vertex Data
        5. 36.5. Communicating with the Shader
          1. 36.5.1. Scene Information
            1. Use the Variable Name
            2. Use Semantics or Annotations
            3. Optimizing Scene Communication
          2. 36.5.2. Material Parameters
          3. 36.5.3. Vertex Format
          4. 36.5.4. Context
          5. 36.5.5. Techniques vs. Passes for Context
        6. 36.6. Extending the Effect File Format
          1. 36.6.1. Supporting the Preprocessor
          2. 36.6.2. Supporting Shader Variations
          3. 36.6.3. Adding Shader Inheritance
        7. 36.7. Conclusion
        8. 36.8. References
    10. VI. Beyond Triangles
      1. 37. A Toolkit for Computation on GPUs
        1. 37.1. Computing with the GPU
          1. 37.1.1. The Programming Model
          2. 37.1.2. Parallel Programming
          3. 37.1.3. Advanced GPU Programming
        2. 37.2. Reduce
          1. 37.2.1. Parallel Reductions
            1. Performance
          2. 37.2.2. Reduce Tidbits
        3. 37.3. Sort and Search
          1. 37.3.1. Bitonic Merge Sort
            1. Algorithm
            2. GPU Implementation
            3. Performance
          2. 37.3.2. Binary Search
            1. Algorithm
            2. GPU Implementation
            3. Performance
        4. 37.4. Challenges
          1. 37.4.1. Limited Outputs
          2. 37.4.2. Slow Readback
          3. 37.4.3. GPU vs. CPU
        5. 37.5. Conclusion
        6. 37.6. Further Reading
      2. 38. Fast Fluid Dynamics Simulation on the GPU
        1. 38.1. Introduction
          1. 38.1.1. Our Goal
          2. 38.1.2. Our Assumptions
          3. 38.1.3. Our Approach
        2. 38.2. Mathematical Background
          1. 38.2.1. The Navier-Stokes Equations for Incompressible Flow
          2. 38.2.2. Terms in the Navier-Stokes Equations
            1. Advection
            2. Pressure
            3. Diffusion
            4. External Forces
          3. 38.2.3. A Brief Review of Vector Calculus
          4. 38.2.4. Solving the Navier-Stokes Equations
            1. The Helmholtz-Hodge Decomposition
              1. First Realization
              2. Second Realization
            2. Advection
            3. Viscous Diffusion
            4. Solution of Poisson Equations
            5. Initial and Boundary Conditions
        3. 38.3. Implementation
          1. 38.3.1. CPU–GPU Analogies
            1. Textures = Arrays
            2. Loop Bodies = Fragment Programs
            3. Feedback = Texture Update
          2. 38.3.2. Slab Operations
          3. 38.3.3. Implementation in Fragment Programs
            1. Advection
            2. Viscous Diffusion
            3. Force Application
            4. Projection
            5. Boundary Conditions
        4. 38.4. Applications
          1. 38.4.1. Simulating Liquids and Gases
          2. 38.4.2. Buoyancy and Convection
            1. Smoke and Clouds
        5. 38.5. Extensions
          1. 38.5.1. Vorticity Confinement
          2. 38.5.2. Three Dimensions
          3. 38.5.3. Staggered Grid
          4. 38.5.4. Arbitrary Boundaries
          5. 38.5.5. Free Surface Flow
        6. 38.6. Conclusion
        7. 38.7. References
      3. 39. Volume Rendering Techniques
        1. 39.1. Introduction
        2. 39.2. Volume Rendering
        3. 39.3. Texture-Based Volume Rendering
          1. 39.3.1. A Simple Example
        4. 39.4. Implementation Details
          1. 39.4.1. Data Representation and Processing
          2. 39.4.2. Proxy Geometry
          3. 39.4.3. Rendering
            1. Transfer Functions
            2. Illumination
            3. Compositing
        5. 39.5. Advanced Techniques
          1. 39.5.1. Volumetric Lighting
          2. 39.5.2. Procedural Rendering
        6. 39.6. Performance Considerations
          1. 39.6.1. Rasterization Bottlenecks
            1. Fragment Program Limitations
            2. Texture Memory Limitations
        7. 39.7. Summary
        8. 39.8. References
      4. 40. Applying Real-Time Shading to 3D Ultrasound Visualization
        1. 40.1. Background
        2. 40.2. Introduction
          1. 40.2.1. Volume Rendering Data in a Cartesian Grid
            1. Enclosing Rectangles
            2. Polygons of Intersection
          2. 40.2.2. Volume Rendering Data in Pyramidal Grids
            1. The Vertex Program
            2. The Fragment Program
            3. Volume Rendering Ultrasound Data
        3. 40.3. Results
        4. 40.4. Conclusion
        5. 40.5. References
      5. 41. Real-Time Stereograms
        1. 41.1. What Is a Stereogram?
          1. 41.1.1. Stereo Photography
          2. 41.1.2. Random-Dot Stereograms
          3. 41.1.3. Single-Image Stereograms
        2. 41.2. Creating a Single-Image Stereogram
          1. 41.2.1. Parameters
          2. 41.2.2. Rendering
          3. 41.2.3. Creating Animated Single-Image Stereograms
          4. 41.2.4. Fragment Program
        3. 41.3. Sample Application
          1. 41.3.1. Application Options
        4. 41.4. References
      6. 42. Deformers
        1. 42.1. What Is a Deformer?
          1. 42.1.1. Mathematical Definition
            1. Controls
        2. 42.2. Deforming on the GPU
          1. 42.2.1. Formulating the Deformer
          2. 42.2.2. Writing the Vertex Program
            1. What About Normals?
          3. 42.2.3. Deforming Normals
            1. How Would We Compute Normals in Software?
            2. An Approximate Numerical Technique
            3. The Jacobian Matrix
        3. 42.3. Limitations
        4. 42.4. Performance
        5. 42.5. Example: Wave Deformer
        6. 42.6. Conclusion
      7. Appendix
        1. Addison-Wesley Warranty on the CD-ROM
        2. NVIDIA Statement on the Software
          1. No Warranty
          2. Limitation of Liability
      8. Appendix
        1. Natural Effects
        2. Lighting and Shadows
        3. Materials
        4. Image Processing
        5. Performance and Practicalities
        6. Beyond Triangles

    Product information

    • Title: GPU Gems: Programming Techniques, Tips and Tricks for Real-Time Graphics
    • Author(s): Randima Fernando
    • Release date: March 2004
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 9780321545404