advanced graphics programming using opengl (morgan kaufmann series in computer graphics and geometric modeling)

672 353 0
advanced graphics programming using opengl (morgan kaufmann series in computer graphics and geometric modeling)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Advanced Graphics Programming Using OpenGL TOM McREYNOLDS DAVID BLYTHE AMSTERDAM • BOSTON • HEIDELBERG • LONDON NEW YORK • OXFORD • PARIS • SAN DIEGO SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO MORGAN KAUFMANN PUBLISHERS IS AN IMPRINT OF ELSEVIER TEAM LinG Advanced Graphics Programming Using OpenGL TEAM LinG The Morgan Kaufmann Series in Computer Graphics and Geometric Modeling Series Editor: Brian A. Barsky University of California, Berkeley This series publishes the finest works for the accomplished and aspiring graphics professional. The series includes intermediate and advanced textbooks, graphics programming books, surveys of important new areas and methods, and reference works. Advanced Graphics Programming Using OpenGL Tom McReynolds and David Blythe Digital Geometry Geometric Methods for Digital Picture Analysis Rienhard Klette and Azriel Rosenfeld Digital Video and HDTV Algorithms and Interfaces Charles Poynton Real-Time Shader Programming Ron Fosner Complete Maya Programming: An Extensive Guide to MEL and the C++ API David Gould MEL Scripting for Maya Animators Mark R. Wilkins and Chris Kazmier Digital Video and HDTV Algorithms and Interfaces Charles Poynton Texturing & Modeling: A Procedural Approach, Third Edition David S. Ebert, F. Kenton Musgrave, Darwyn Peachey, Ken Perlin, and Steven Worley Geometric Tools for Computer Graphics Philip Schneider and David Eberly Understanding Virtual Reality: Interface, Application, and Design William Sherman and Alan Craig Jim Blinn’s Corner: Notation, Notation, Notation Jim Blinn Level of Detail for 3D Graphics: David Luebke, Martin Reddy, Jonathan D. Cohen, Amitabh Varshney, Benjamin Watson, and Robert Huebner Pyramid Algorithms: A Dynamic Programming Approach to Curves and Surfaces for Geometric Modeling Ron Goldman Non-Photorealistic Computer Graphics: Modeling, Rendering, and Animation Thomas Strothotte and Stefan Schlechtweg Curves and Surfaces for CAGD: A Practical Guide, Fifth Edition Gerald Farin Subdivision Methods for Geometric Design: A Constructive Approach Joe Warren and Henrik Weimer Computer Animation: Algorithms and Techniques Rick Parent The Computer Animator’s Technical Handbook Lynn Pocock and Judson Rosebush Advanced RenderMan: Creating CGI for Motion Pictures Anthony A. Apodaca and Larry Gritz Curves and Surfaces in Geometric Modeling: Theory and Algorithms Jean Gallier Andrew Glassner’s Notebook: Recreational Computer Graphics Andrew S. Glassner Warping and Morphing of Graphical Objects Jonas Gomes, Lucia Darsa, Bruno Costa, and Luiz Velho Jim Blinn’s Corner: Dirty Pixels Jim Blinn Rendering with Radiance: The Art and Science of Lighting Visualization Greg Ward Larson and Rob Shakespeare Introduction to Implicit Surfaces Edited by Jules Bloomenthal Jim Blinn’s Corner: A Trip Down the Graphics Pipeline Jim Blinn Interactive Curves and Surfaces: A Multimedia Tutorial on CAGD Alyn Rockwood and Peter Chambers Wavelets for Computer Graphics: Theory and Applications Eric J. Stollnitz, Tony D. DeRose, and David H. Salesin Principles of Digital Image Synthesis Andrew S. Glassner Radiosity & Global Illumination François X. Sillion and Claude Puech Knotty: A B-Spline Visualization Program Jonathan Yen User Interface Management Systems: Models and Algorithms Dan R. Olsen, Jr. Making Them Move: Mechanics, Control, and Animation of Articulated Figures Edited by Norman I. Badler, Brian A. Barsky, and David Zeltzer Geometric and Solid Modeling: An Introduction Christoph M. Hoffmann An Introduction to Splines for Use in Computer Graphics and Geometric Modeling Richard H. Bartels, John C. Beatty, and Brian A. Barsky TEAM LinG Publishing Director: Diane Cerra Publishing Services Manager: Simon Crump Project Manager: Brandy Lilly Editorial Coordinator: Mona Buehler Cover Design: Dutton & Sherman Design Text Design: Julio Esperas Composition: Cepha Imaging Pvt. Ltd. Illustrations: Dartmouth Publishing, Inc. Copyeditor: Daril Bentley; Graphic World Proofreader: Graphic World Indexer: Graphic World Interior printer: China Translation & Printing Services, Ltd. Cover printer: China Tranalation & Printing Services, Ltd. Morgan Kaufmann Publishers is an imprint of Elsevier. 500 Sansome Street, Suite 400, San Francisco, CA 94111 This book is printed on acid-free paper. © 2005 by Elsevier Inc. All rights reserved. Designations used by companies to distinguish their products are often claimed as trademarks or registered trademarks. In all instances in which Morgan Kaufmann Publishers is aware of a claim, the product names appear in initial capital or all capital letters. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration. 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, scanning, or otherwise—without prior written permission of the publisher. Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, e-mail: permissions@elsevier.com.uk. You may also complete your request on-line via the Elsevier homepage (http://elsevier.com) by selecting “Customer Support” and then “Obtaining Permissions.” Library of Congress Cataloging-in-Publication Data Application Submitted ISBN: 1-55860-659-9 For information on all Morgan Kaufmann publications, visit our Web site at www.mkp.com or www.books.elsevier.com Printed in China 10987654321 TEAM LinG To my friends and colleaguesfrom Silicon Graphics; it was a fabulous time and place to learn about 3D graphics. –DB To Ede Forney and HarryMcGinnis; you were there when it counted. – TM TEAM LinG Contents Preface xxiii Acknowledgments xxvii Biographies xxviii PART I Concepts 1 CHAPTER 1 Geometry Representation and Modeling 3 1.1 Polygonal Representation 3 1.2 Decomposition and Tessellation 4 1.3 Shading Normals 8 1.3.1 Smooth Shading 9 1.3.2 Vertex Winding Order 11 1.4 Triangle Stripping 12 1.4.1 Greedy Tri-stripping 13 1.5 Vertices and Vertex Arrays 14 1.5.1 Vertex Buffer Objects 15 1.5.2 Triangle Lists 16 1.6 Modeling vs. Rendering Revisited 17 vi TEAM LinG Contents vii CHAPTER 2 3D Transformations 19 2.1 Data Representation 19 2.2 Overview of the Transformation Pipeline 20 2.2.1 Object Space and the Modelview Transform 20 2.2.2 Eye Space and Projection Transform 21 2.2.3 Clip Space and Perspective Divide 22 2.2.4 NDC Space and the Viewport Transform 22 2.2.5 Window Space 23 2.3 Normal Transformation 23 2.4 Texture Coordinate Generation and Transformation 25 2.4.1 Texture Matrix 25 2.4.2 Texture Coordinate Generation 25 2.5 Modeling Transforms 27 2.6 Visualizing Transform Sequences 28 2.7 Projection Transform 30 2.8 The Z Coordinate and Perspective Projection 30 2.8.1 Z Coordinates and Fog 32 2.9 Vertex Programs 32 2.10 Summary 34 CHAPTER 3 Color, Shading, and Lighting 35 3.1 Representing Color 35 3.1.1 Resolution and Dynamic Range 36 3.1.2 Gamma 37 3.1.3 Alpha 39 3.1.4 Color Index 39 3.2 Shading 40 3.3 Lighting 43 3.3.1 Intensities, Colors, and Materials 46 3.3.2 Light Source Properties 47 TEAM LinG viii Contents 3.3.3 Material Properties 49 3.3.4 Vertex and Fragment Lighting 50 3.4 Fixed-Point and Floating-Point Arithmetic 53 3.4.1 Biased Arithmetic 54 3.5 Summary 56 CHAPTER 4 Digital Images and Image Manipulation 57 4.1 Image Representation 57 4.2 Digital Filtering 60 4.3 Convolution 62 4.4 Images in OpenGL 63 4.5 Positioning Images 65 4.6 Pixel Store Operations 65 4.7 Pixel Transfer Operations 67 4.7.1 Scale and Bias 67 4.7.2 Pixel Mapping Operations 67 4.8 ARB Imaging Subset 68 4.8.1 Convolution 68 4.8.2 Color Matrix Transform 68 4.8.3 Histogram 69 4.8.4 MinMax 70 4.8.5 Color Tables 70 4.8.6 Blend Equation and Constant Color Blending 71 4.9 Off-Screen Processing 72 4.10 Summary 72 CHAPTER 5 Texture Mapping 73 5.1 Loading Texture Images 73 5.1.1 Texture Borders 74 5.1.2 Internal Texture Formats 75 TEAM LinG Contents ix 5.1.3 Compressed Textures 76 5.1.4 Proxy Textures 77 5.2 Texture Coordinates 77 5.2.1 Texture Coordinate Generation and Transformation 79 5.3 Loading Texture Images from the Frame Buffer 79 5.4 Environment Mapping 80 5.4.1 Generating Environment Map Texture Coordinates 81 5.4.2 Texture Maps Used in Environment Mapping 82 5.4.3 Cube Mapping 83 5.4.4 Sphere Mapping 85 5.5 3D Texture 88 5.5.1 Using 3D Textures to Render Solid Materials 89 5.6 Filtering 90 5.7 Additional Control of Texture Level of Detail 91 5.8 Texture Objects 93 5.9 Multitexture 95 5.9.1 Multitexture Model 96 5.9.2 Multitexture Texture Environments 97 5.10 Texture Environment 98 5.10.1 Advanced Texture Environment Functionality 99 5.10.2 Fragment Programs 100 5.11 Summary 102 CHAPTER 6 Rasterization and Fragment Processing 103 6.1 Rasterization 104 6.1.1 Rasterization Consistency 105 6.1.2 Z-Fighting 105 6.1.3 Bitmaps and Pixel Rectangles 107 6.1.4 Texture, Color, and Depth Interpolation 108 6.1.5 w Buffering 109 6.2 Fragment Operations 110 6.2.1 Multisample Operations 111 6.2.2 Alpha Test 111 6.2.3 Stencil Test 111 TEAM LinG x Contents 6.2.4 Blending 112 6.2.5 Logic Op 114 6.3 Framebuffer Operations 115 6.3.1 Accumulation Buffer 116 6.4 Summary 117 CHAPTER 7 Window System and Platform Integration 119 7.1 Renderer and Window State 120 7.2 Address Space and Threads 121 7.3 Anatomy of a Window 122 7.3.1 Overlay and Underlay Windows 122 7.3.2 Multiple Displays 123 7.4 Off-Screen Rendering 124 7.4.1 GLX Pbuffers 125 7.4.2 WGL Pbuffers 126 7.5 Rendering to Texture Maps 126 7.6 Direct and Indirect Rendering 127 CHAPTER 8 OpenGL Implementations 129 8.1 OpenGL Versions 129 8.2 OpenGL Extensions 131 8.3 OpenGL ES for Embedded Systems 131 8.3.1 Embedded Profiles 132 8.3.2 Common and Common-Lite Profiles 133 8.3.3 Safety Critical Profile 136 8.3.4 OpenGL ES Revisions 136 8.4 OpenGL Pipeline Evolution 137 8.5 Hardware Implementations of the Pipeline 138 8.5.1 Rasterization Acceleration 138 8.5.2 Primitive Setup Acceleration 141 8.5.3 Transform and Lighting Acceleration 141 8.5.4 Pipeline Balance 142 TEAM LinG [...]... available for internet download from www.mkp.com /opengl Conventions We use conventions and terminology similar to that found in the OpenGL specification and in the “red-blue-green-white” series of OpenGL books In addition, we use the following conventions: • Equations involving matrices, vectors, and points use single uppercase letters for most variables Vectors are emboldened (V), whereas points and matrices... divided into three parts We start with a conceptual overview of computer graphics, emphasizing areas important to the techniques in this book, with extra attention in some overlooked areas Hand in hand with our introduction to computer graphics, we’ll describe the OpenGL pipeline, with extra detail on the parts of the pipeline most techniques rely on heavily: lighting, texture mapping, rasterization, and. .. David’s other industry experience includes embedded and system-on-a-chip design, mobile devices, and wireless networking David is currently a graphics architect in the Windows Graphics and Gaming Technologies division at Microsoft working on DirectX and OpenGL graphics technologies Tom McReynolds Tom McReynolds has worked on 3D graphics at Sun Microsystems, Silicon Graphics, Gigapixel, 3Dfx, and NVIDIA... we have included extra introductory material where we thought it would improve understanding of later sections We also note that the computer graphics field has a lot of competing notation and vocabulary We have tried to be consistent with terminology and notation used in the OpenGL specification and the “standard” OpenGL books while at the same time providing some mention of alternative terminology... with OpenGL, it is useful to review the basic ideas behind polygonal modeling and how they relate to it 1.1 Polygonal Representation OpenGL supports a handful of primitive types for modeling two-dimensional (2D) and three-dimensional (3D) objects: points, lines, triangles, quadrilaterals, and TEAM LinG 3 4 C H A P T E R 1 Geometry Representation and Modeling (convex) polygons In addition, OpenGL includes... Shading 9.7 Summary 165 166 167 167 CHAPTER 10 Antialiasing 169 10.1 Full-Scene Antialiasing 10.2 Supersampling 10.2.1 10.2.2 10.2.3 10.2.4 170 171 Supersampling by Overdrawing 172 Supersampling with the Accumulation Buffer Multisample Antialiasing 175 Drawbacks 176 173 TEAM LinG xii Contents 10.3 Area Sampling 10.4 Line and Point Antialiasing 10.5 Antialiasing with Textures 10.6 Polygon Antialiasing... manuscript and have earned our gratitude: Ben Luna, Jeff Somers, Brandy Lilly, and Jessica Meehan in particular We are also greatly indebted to our reviewers: Ian Ashdown, Dave Shreiner, Noah Gibbs, Brian Paul, and Clay Budin TEAM LinG xxvii Biographies David Blythe David Blythe has worked in the 3D graphics field professionally for the last 14 years, including serving as Chief Engineer at Silicon Graphics, ... applications written in OpenGL will act predictably on many different graphics hardware and driver implementations OpenGL is also widely available It can be obtained for free on all the important architectures today: Apple Machintosh, all flavors of Microsoft Windows, nearly all Unix variants including Linux, and OS/2 Most commercial system and graphics hardware vendors support OpenGL as well, and support for... for embedded GPUs at NVIDIA, and contributing to the evolution of OpenGL ES by participating in the Khronos working group TEAM LinG xxviii I PART ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ Concepts TEAM LinG TEAM LinG 1 CHAPTER ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ Geometry Representation and Modeling Two principal tasks are required to create an image of a three-dimensional scene: modeling and rendering The modeling task generates a model,... Cross Hatching and 3D Halftones Halftoning 515 2D Drawing Techniques 19.7.1 19.7.2 19.7.3 19.8 511 Summary 525 Undo and Resolution Independence Painting in 3D 527 Painting on Images 529 527 530 CHAPTER 20 Scientific Visualization 20.1 531 Mapping Numbers to Pictures 531 TEAM LinG xx Contents 20.2 Visual Cues and Perception 20.3 Data Characterization 20.4 560 Icons 561 Particle Tracing 561 Stream Lines 563 . TOKYO MORGAN KAUFMANN PUBLISHERS IS AN IMPRINT OF ELSEVIER TEAM LinG Advanced Graphics Programming Using OpenGL TEAM LinG The Morgan Kaufmann Series in Computer Graphics and Geometric Modeling Series. Brian A. Barsky, and David Zeltzer Geometric and Solid Modeling: An Introduction Christoph M. Hoffmann An Introduction to Splines for Use in Computer Graphics and Geometric Modeling Richard H areas and methods, and reference works. Advanced Graphics Programming Using OpenGL Tom McReynolds and David Blythe Digital Geometry Geometric Methods for Digital Picture Analysis Rienhard Klette and

Ngày đăng: 01/06/2014, 01:06

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan