Home > Store

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

Register your product to gain access to bonus material or receive a coupon.

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

Premium Website

  • Sorry, this book is no longer in print.
Not for Sale



The first comprehensive collection of practical techniques, tips, and tricks for programming real-time computer graphics.

° Removes the mystery behind complex effects and reveals the full potential of programmable GPUs (graphics processing units)

° Covers some of the coolest and most difficult effects, such as simulating fire, water, and waving blades of grass

° Contains advice from experts with major graphics companies such as Softimage, AliasWavefront, Industrial Light and Magic, and Sony


  • Copyright 2004
  • Edition: 1st
  • Premium Website
  • ISBN-10: 0-321-22832-4
  • ISBN-13: 978-0-321-22832-1

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.


“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
  • 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.

    Sample Content

    Downloadable Sample Chapter

    Chapter 3 was such a huge demand from our readers that the authors have agreed to share with you an additional free chapter from their book.

    Download the sample chapters related to this title:

    Chapter 3: Skin in the "Dawn: demo
    Chapter 14: Perspective Shadow Maps

    Table of Contents





    1. Effective Water Simulation from Physical Models, Mark Finch, (Cyan Worlds).

    Goals and Scope.

    The Sum of Sines Approximation.


    Runtime Processing.



    2. Rendering Water Caustics, Juan Guardado, (NVIDIA) and Daniel Sanchez-Crespo, (Universitat Pompeu Fabra/Novarama Technology).


    Computing Caustics.

    Our Approach.

    Implementation Using OpenGL.

    Implementation Using a High-Level Shading Language.



    3. Skin in the "Dawn" Demo, Curtis Beeson, (NVIDIA) and Kevin Bjorke, (NVIDIA).


    Skin Shading.

    Lighting the Scene.

    How Skin Responds to Light.




    4. Animation in the "Dawn" Demo, Curtis Beeson, (NVIDIA).


    Mesh Animation.

    Morph Targets.




    5. Implementing Improved Perlin Noise, Ken Perlin, (New York University).

    The Noise Function.

    The Original Implementation.

    Deficiencies of the Original Implementation.

    Improvements to Noise.

    How to Make Good Fake Noise in Pixel Shaders.

    Making Bumps Without Looking at Neighboring Vertices.



    6. Fire in the "Vulcan" Demo, Hubert Nguyen, (NVIDIA).

    Creating Realistic Flames.

    Implementing Animated Sprites.

    Particle Motion.


    Post-Rendering Effects.


    7. Rendering Countless Blades of Waving Grass. Kurt Pelzer, (Piranha Bytes).



    Preparation of the Grass Objects.



    Further Reading.

    8. Simulating Diffraction, Jos Stam, (Alias Systems).

    What Is Diffraction?






    9. Efficient Shadow Volume Rendering, Morgan McGuire, (Brown University).


    Program Structure.

    Detailed Discussion.


    Geometry Optimizations.

    Fill-Rate Optimizations.

    Future Shadows.


    10. Cinematic Lighting, Fabio Pellacini and Kiril Vidimce, (Pixar Animation Studios).


    A Direct Lighting Illumination Model.

    The Uberlight Shader.

    Performance Concerns.



    11. Shadow Map Antialiasing, Michael Bunnell, (NVIDIA) and Fabio Pellacini, (Pixar Animation Studios).


    Percentage-Closer Filtering.

    A Brute-Force Implementation.

    Using Fewer Samples.

    Why It Works.



    12. Omnidirectional Shadow Mapping, Philipp S. Gerasimov, (iXBT.com).


    The Shadow-Mapping Algorithm.


    Adding Soft Shadows.



    13. Generating Soft Shadows Using Occlusion Interval Maps, William Donnelly, (University of Waterloo) and Joe Demers, (NVIDIA).

    The Gas Station.

    The Algorithm.

    Creating the Maps.





    14. Perspective Shadow Maps: Care and Feeding, Simon Kozlov, (SoftLab-NSK).


    Problems with the PSM Algorithm.

    Tricks for Better Shadow Maps.



    15. Managing Visibility for Per-Pixel Lighting, John O'Rorke, (Monolith Productions).

    Visibility in a GPU Book?

    Batches and Per-Pixel Lighting.

    Visibility As Sets.

    Generating Sets.

    Visibility for Fill Rate.

    Practical Application.




    16. Real-Time Approximations to Subsurface Scattering, Simon Green, (NVIDIA).

    The Visual Effects of Subsurface Scattering.

    Simple Scattering Approximations.

    Simulating Absorption Using Depth Maps.

    Texture-Space Diffusion.



    17. Ambient Occlusion, Matt Pharr, (NVIDIA) and Simon Green, (NVIDIA).


    The Preprocessing Step.

    Hardware-Accelerated Occlusion.

    Rendering with Ambient Occlusion Maps.


    Further Reading.

    18. Spatial BRDFs. David McAllister, (NVIDIA

    What Is an SBRDF?

    Details of the Representation.

    Rendering Using Discrete Lights.

    Rendering Using Environment Maps.



    19. Image-Based Lighting, Kevin Bjorke, (NVIDIA).

    Localizing Image-Based Lighting.

    The Vertex Shader.

    The Fragment Shader.

    Diffuse IBL.


    Using Localized Cube Maps As Backgrounds.


    Further Reading.

    20. Texture Bombing, R. Steven Glanville, (NVIDIA).

    Texture Bombing.

    Technical Considerations.

    Advanced Features.




    21. Real-Time Glow, Greg James, (NVIDIA) and John O'Rorke, (Monolith Productions).

    Overview of the Technique.

    Rendering Glows: Step by Step.

    Hardware-Specific Implementations.

    Other Uses for Blur.

    Adding the Effects to a Game Engine.



    22. Color Controls, Kevin Bjorke, (NVIDIA).


    Channel-Based Color Correction.

    Multichannel Color Correction and Conversion.


    23. Depth of Field: A Survey of Techniques, Joe Demers, (NVIDIA).

    What Is Depth of Field?

    Ray-Traced Depth of Field.

    Accumulation-Buffer Depth of Field.

    Layered Depth of Field.

    Forward-Mapped Z-Buffer Depth of Field.

    Reverse-Mapped Z-Buffer Depth of Field.



    24. High-Quality Filtering, Kevin Bjorke, (NVIDIA).

    Quality vs. Speed.

    Understanding GPU Derivatives.

    Analytical Antialiasing and Texturing.



    25. Fast Filter-Width Estimates with Texture Maps, Matt Pharr, (NVIDIA).

    The Need for Derivatives in Shaders.

    Computing Filter Width with Textures.


    Further Reading.

    26. The OpenEXR Image File Format, Florian Kainz, Rod Bogart, and Drew Hess, (Industrial Light and Magic).

    What Is OpenEXR?

    The OpenEXR File Structure.

    OpenEXR Data Compression.

    Using OpenEXR.

    Linear Pixel Values.

    Creating and Using HDR Images.



    27. A Framework for Image Processing, Frank Jargstorff, (NVIDIA).


    Framework Design.


    A Sample Application.

    Performance and Limitations.




    28. Graphics Pipeline Performance, Cem Cebenoyan, (NVIDIA).


    Locating the Bottleneck.




    29. Efficient Occlusion Culling, Dean Sekulic, (Croteam).

    What Is Occlusion Culling?

    How Does Occlusion Query Work?

    Beginning to Use Occlusion Queries.

    One Step Further.

    A Word About Bounding Boxes.

    Other Issues.

    A Little Reminder.

    An Application: Lens Flares.



    30. The Design of FX Composer, Christopher Maughan, (NVIDIA).

    Tools Development.

    Initial Features and Target Audience.

    Object Design.

    File Format.

    User Interface.

    Direct3D Graphics Implementation.

    Scene Management.



    31. Using FX Composer, Christopher Maughan, (NVIDIA).

    Getting Started.

    Sample Project.


    32. An Introduction to Shader Interfaces, Matt Pharr, (NVIDIA).

    The Basics of Shader Interfaces.

    A Flexible Description of Lights.

    Material Trees.



    33. Converting Production RenderMan Shaders to Real-Time, Stephen Marshall, (Sony Pictures Imageworks).



    The Vertex Program vs. the Fragment Program.

    Using Vertex and Fragment Programs.

    Optimization Techniques on the Fragment Program.

    Results and Conclusions.


    34. Integrating Hardware Shading into Cinema 4D, Jorn Loviscach, (Hochschule Bremen).


    Connecting Cinema 4D to CgFX.

    Shader and Parameter Management.

    Emulating the Offline Renderer.

    Results and Performance.

    Lessons Learned.


    35. Leveraging High-Quality Software Rendering Effects in Real-Time Applications, Alexandre Jean Claude, and Marc Stevens, (Softimage).


    The Content Pipeline for Hardware Rendering.

    Components of Hardware Rendering.

    Generating the Components.

    Test Case and Results.



    36. Integrating Shaders into Applications, John O'Rorke, (Monolith Productions).


    About Shaders.

    The Anatomy of an Effect File.

    Types of Shader Data.

    Communicating with the Shader.

    Extending the Effect File Format.




    37. A Toolkit for Computation on GPUs, Ian Buck, and Tim Purcell, (Stanford University).

    Computing with the GPU.


    Sort and Search.



    Further Reading.

    38. Fast Fluid Dynamics Simulation on the GPU, Mark J. Harris, (University of North Carolina at Chapel Hill).


    Mathematical Background.






    39. Volume Rendering Techniques, Milan Ikits, (University of Utah), Joe Kniss, (University of Utah), Aaron Lefohn, (University of California, Davis) and Charles Hansen, (University of Utah).


    Volume Rendering.

    Texture-Based Volume Rendering.

    Implementation Details.

    Advanced Techniques.

    Performance Considerations.



    40. Applying Real-Time Shading to 3D Ultrasound Visualization, Thilaka Sumanaweera, (Siemens Medical Solutions USA, Inc.).






    41. Real-Time Stereograms, Fabio Policarpo, (Paralelo Computacao Ltda.).

    What Is a Stereogram?

    Creating a Single-Image Stereogram.

    Sample Application.


    42. Deformers, Eugene d'Eon, (University of Waterloo).

    What Is a Deformer?

    Deforming on the GPU.



    Example: Wave Deformer.




    Untitled Document

    Now is an excellent time to be working in the field of computer graphics. Over the past five years, GPU technology has advanced in astounding ways, and at an explosive pace. The rendering rate, as measured in pixels per second, has been approximately doubling every six months during those five years. A factor of two is certainly exciting enough, but more exciting is the wonder of compounding. Five years represents the doubling of performance ten times-that's two to the tenth power, a factor of one thousand!

    Not only has performance increased, but also the quality of computation and the flexibility of graphics programming have steadily improved during that same time. Five years ago, PCs and computer workstations had graphics accelerators, not graphics processing units (GPUs). The implication was that a graphics accelerator does simply that: it accelerates graphics. Furthermore, the word accelerator implied that the computer would perform exactly the same rendering operations as before, only faster. As graphics accelerators were replaced by GPUs, we abandoned the old concept of graphics acceleration. We advanced to graphics processing, embracing the idea of processors that enable new graphics algorithms and effects.

    We have entered the era of programmable GPUs. The graphics hardware pipeline, which had not previously changed significantly in twenty years, was broken down to its component, hard-wired elements and rebuilt out of programmable, parallel-pipelined processors. In a hard-wired pipeline, triangle vertices are transformed and lit, triangles are rasterized, and pixels are shaded with diffuse lighting, specular exponentiation, fog blending, and frame-buffer blending. In a programmable pipeline, each of these operations is abstracted to its component memory accesses and mathematical operations. A programmer can still write a program that calculates the same results as a hard-wired pipeline (and in fact, such a program is often the first one a student programmer writes for a programmable processor!), but the opportunity presented is so much greater than this.

    The first effects of fast, programmable GPUs are subtle. Previously difficult graphics problems become much more tractable through the application of one thousand-fold performance increases. Offline rendering techniques become more practical for interactive applications. Historically, brute force has been a popular algorithmic approach; simply casting a graphics problem in a way that it can run on a GPU is an unsubtle application of brute force-it works, but it leaves opportunity on the table.

    Beyond that, algorithm development gets more interesting. Graphics programmers can now experiment with new algorithms and techniques that would not have been practical on a slower, single-threaded serial processor such as a CPU. The parallel-stream-processing nature of the GPU, coupled with flexibility and programmability, allows new algorithms to be developed and invites experimentation. Any computationally demanding problem-not just graphics-that can take advantage of large-scale parallelism, larger memory bandwidth, and geometric performance growth is a good candidate for GPU implementation. As an industry, we're still learning which problems will benefit most from GPU solutions.

    The true beneficiaries of the programmable GPU revolution are the computer graphics algorithm designer, the researcher, the application developer, and ultimately the end user or consumer-the gamer, the moviegoer, and so on. GPU Gems is a timely book, as the GPU programming field is young and vibrant, and many developers are reinventing the same techniques again and again. This volume contains straightforward applications of known techniques to a structure more amenable to GPU execution, as well as innovative new algorithms and effects that were not previously possible.

    At this time in the history of GPU programming, many problems remain unsolved and many challenges remain unmet. Consequently, this first volume of GPU Gems is a compendium of approaches and examples of work carried out so far, rather than a cookbook of completed effects to be plugged into applications. This collection will allow programmers to benefit from the exciting progress already made, and it will enable tomorrow's developers to stand on the shoulders of giants, the pioneers of programming GPUs. It's up to you to take the next steps of innovation!

    David Kirk
    Chief Scientist
    NVIDIA Corporation


    Download the Index file related to this title.


    Submit Errata

    More Information

    InformIT Promotional Mailings & Special Offers

    I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


    Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

    This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

    Collection and Use of Information

    To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

    Questions and Inquiries

    For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

    Online Store

    For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


    Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

    Contests and Drawings

    Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


    If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

    Service Announcements

    On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

    Customer Service

    We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

    Other Collection and Use of Information

    Application and System Logs

    Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

    Web Analytics

    Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

    Cookies and Related Technologies

    This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

    Do Not Track

    This site currently does not respond to Do Not Track signals.


    Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


    This site is not directed to children under the age of 13.


    Pearson may send or direct marketing communications to users, provided that

    • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
    • Such marketing is consistent with applicable law and Pearson's legal obligations.
    • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
    • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

    Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

    Correcting/Updating Personal Information

    If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


    Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

    Sale of Personal Information

    Pearson does not rent or sell personal information in exchange for any payment of money.

    While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

    Supplemental Privacy Statement for California Residents

    California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

    Sharing and Disclosure

    Pearson may disclose personal information, as follows:

    • As required by law.
    • With the consent of the individual (or their parent, if the individual is a minor)
    • In response to a subpoena, court order or legal process, to the extent permitted or required by law
    • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
    • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
    • To investigate or address actual or suspected fraud or other illegal activities
    • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
    • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
    • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


    This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

    Requests and Contact

    Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

    Changes to this Privacy Notice

    We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

    Last Update: November 17, 2020