GPU Gems

GPU Gems

GPU Gems is now available, right here, online. You can purchase a beautifully printed version of this book, and others in the series, at a 30% discount courtesy of InformIT and Addison-Wesley.

The CD content, including demos and content, is available on the web and for download.


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


Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.

The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.

The publisher offers discounts on this book when ordered in quantity for bulk purchases and special sales. For more information, please contact:

U.S. Corporate and Government Sales
(800) 382-3419

For sales outside of the U.S., please contact:

International Sales

Visit Addison-Wesley on the Web:

Library of Congress Control Number: 2004100582

GeForce™ and NVIDIA Quadro® are trademarks or registered trademarks of NVIDIA Corporation.
RenderMan® is a registered trademark of Pixar Animation Studios.
"Shadow Map Antialiasing" © 2003 NVIDIA Corporation and Pixar Animation Studios.
"Cinematic Lighting" © 2003 Pixar Animation Studios.
Dawn images © 2002 NVIDIA Corporation. Vulcan images © 2003 NVIDIA Corporation.

Copyright © 2004 by NVIDIA Corporation.

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. Printed in the United States of America. Published simultaneously in Canada.

For information on obtaining permission for use of material from this work, please submit a written request to:

Pearson Education, Inc.
Rights and Contracts Department
One Lake Street
Upper Saddle River, NJ 07458

Text printed on recycled and acid-free paper.

5 6 7 8 9 10 QWT 09 08 07

5th Printing September 2007