When most people think of GPU power, they focus on purely 3D applications, yet the pictures we actually see on our monitors are 2D. Programmable pixel shaders provide personal computers with unprecedented image-processing power, extending our abilities for both 2D and 3D development.
Graphic designers and illustrators have long used complex controls in still-image photo-editing applications, but such programs can process only one picture at a time. The newest GPUs can perform these previously slow operations at interactive rates, allowing us to apply the full power of complex compositing and color-control applications not just to still images and layouts, but also to full-motion video and gameplay. Complex video coloring that previously required an entire suite of specialized equipment can now be done on a laptop PC.
Understanding color spaces is one aspect of image processing, whether we are mapping 2D images into new 2D images or rendering 3D scenes to the screen. Equally important is understanding how images of varying sizes and shapes can be filtered during manipulations to provide smooth, fast results. GPUs are capable of executing the same filtering algorithms as CPU-based image-processing tools, but they also can invoke new hardware-accelerated methods.
In Chapter 21, "Real-Time Glow," Greg James and John O'Rorke give us an example of how 3D gameplay can be enhanced with 2D image processing. By adding 2D lighting effects such as glows, they show how a little image processing can completely alter the feel and play-action of 3D imagery. Once you see how these results are accomplished, you may not be able to enjoy 3D imagery without them again.
In Chapter 22, "Color Controls," I extend the discussion of image processing in games to the uses and methods of technical and artistic color control, for moving imagery into and out of unusual color spaces, as well as quickly adding polished color-tuning to any scene, 2D or 3D. The colors we see in print and on television today are almost universally color-controlled. Developers should be able to understand and use the same tools for their game engines.
In Chapter 23, "Depth of Field: A Survey of Techniques," Joe Demers writes about using GPU operations to create depth-of-field effects in real time. By following a few simple filtering rules, developers can simulate the complex effects of real-world camera focusing, film saturation, and more on 3D models.
Chapter 24, "High-Quality Filtering," generalizes image filtering and effects to images of arbitrary size, applying the notion of filter kernels and analytic calculation to the problem of 2D and 3D antialiasing. Significantly, we can see that some "classical" antialiasing and filtering problems are best solved on the GPU by using hardware accelerations not typically available to CPU-based approaches.
Matt Pharr describes an unusual application of texturing in 2D space in Chapter 25, "Fast Filter-Width Estimates with Texture Maps." By cleverly manipulating the results of texture operations, he's able to determine local partial derivatives of complex functions, even when using hardware profiles that don't provide direct hardware support for these operations.
In Chapter 26, "The OpenEXR Image File Format," Florian Kainz, Rod Bogart, and Drew Hess of Industrial Light & Magic (ILM) describe the OpenEXR standard, a new, high-dynamic-range image format that's quickly spreading through the top tiers of motion-picture computer imaging. OpenEXR is a key tool for developers looking to exploit the new world of image-based lighting, and the ILM team shows how they've adopted GPU processing speed to make OpenEXR a valuable day-to-day tool at ILM—not just for 3D work, but also for image acquisition, compositing, and playback—again, in real time.
Of course, to apply these techniques requires the developer to manage image-processing tasks. In Chapter 27, "A Framework for Image Processing," Frank Jargstorff presents a scheme for 2D image processing that's flexible and applicable to a variety of applications. The framework can even be extended to mix GPU and CPU operations in a way that's fairly transparent to developers of games, photo applications, and video applications alike.
Kevin Bjorke, NVIDIA
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
For sales outside of the U.S., please contact:
Visit Addison-Wesley on the Web: www.awprofessional.com
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