1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu lập trình - Interactive computer graphics a top down approach with shader based OpenGL (6th ed ) angel shreiner 2011 04 10

778 2,3K 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 778
Dung lượng 12,54 MB

Nội dung

Tài liệu lập trình - Interactive computer graphics a top down approach with shader based OpenGL (6th ed ) angel shreiner 2011 04 10

This page intentionally left blank INTERACTIVE COMPUTER GRAPHICS A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL® 6th Edition This page intentionally left blank INTERACTIVE COMPUTER GRAPHICS A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL® 6th Edition EDWARD ANGEL University of New Mexico • DAVE SHREINER ARM, Inc Editorial Director: Marcia Horton Editor-in-Chief: Michael Hirsch Acquisitions Editor: Matt Goldstein Editorial Assistant: Chelsea Bell Vice President, Marketing: Patrice Jones Marketing Manager: Yezan Alayan Marketing Coordinator: Kathryn Ferranti Vice President, Production: Vince O’Brien Managing Editor: Jeff Holcomb Senior Production Project Manager: Marilyn Lloyd Senior Operations Supervisor: Alan Fischer Operations Specialist: Lisa McDowell Text Designer: Beth Paquin Cover Designer: Central Covers Cover Art: Hue Walker, Fulldome Project, University of New Mexico Media Editor: Daniel Sandin Media Project Manager: Wanda Rockwell Full-Service Project Management: Coventry Composition Composition: Coventry Composition, using ZzTEX Printer/Binder: Edwards Brothers Cover and Insert Printer: Lehigh-Phoenix Color Text Font: Minion Credits and acknowledgments borrowed from other sources and reproduced, with permission, in this textbook appear on appropriate page within text Copyright © 2012, 2009, 2006, 2003, 2000 Pearson Education, Inc., publishing as AddisonWesley All rights reserved Manufactured in the United States of America This publication is protected by Copyright, and permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise To obtain permission(s) to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, 501 Boylston Street, Suite 900, Boston, Massachusetts 02116 Many of the designations by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed in initial caps or all caps Library of Congress Cataloging-in-Publication Data Angel, Edward Interactive computer graphics : a top-down approach with shader-based OpenGL / Edward Angel, David Shreiner — 6th ed p cm Includes bibliographical references and index ISBN-13: 978-0-13-254523-5 (alk paper) ISBN-10: 0-13-254523-3 (alk paper) Computer graphics OpenGL I Shreiner, Dave II Title T385.A5133 2012 006.6—dc22 2011004742 10 1—EB—15 14 13 12 11 Addison-Wesley is an imprint of ISBN 10: 0-13-254523-3 ISBN 13: 978-0-13-254523-5 To Rose Mary —E.A To Vicki, Bonnie, Bob, and Phantom —D.S This page intentionally left blank CONTE NTS Preface xxi CHAPTER GRAPHICS SYSTEMS AND MODELS 1.1 Applications of Computer Graphics 1.1.1 1.1.2 1.1.3 1.1.4 Display of Information Design Simulation and Animation User Interfaces 1.2 A Graphics System 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 Pixels and the Frame Buffer The CPU and the GPU Output Devices Input Devices Physical Input Devices 10 Logical Devices 12 Input Modes 13 1.3 Images: Physical and Synthetic 1.3.1 1.3.2 1.3.3 Objects and Viewers 15 Light and Images 16 Imaging Models 18 1.4 Imaging Systems 1.4.1 1.4.2 The Pinhole Camera 20 The Human Visual System 1.5 The Synthetic-Camera Model 23 1.6 The Programmer’s Interface 25 1.6.1 1.6.2 1.6.3 1.6.4 The Pen-Plotter Model 27 Three-Dimensional APIs 28 A Sequence of Images 31 The Modeling–Rendering Paradigm 1.7 Graphics Architectures 1.7.1 1.7.2 Display Processors 34 Pipeline Architectures 34 5 15 20 22 32 33 vii viii Contents 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 The Graphics Pipeline 35 Vertex Processing 36 Clipping and Primitive Assembly Rasterization 37 Fragment Processing 37 1.8 Programmable Pipelines 37 1.9 Performance Characteristics 38 Summary and Notes 39 Suggested Readings 40 Exercises CHAPTER 36 41 GRAPHICS PROGRAMMING 43 2.1 The Sierpinski Gasket 43 2.2 Programming Two-Dimensional Applications 46 50 2.3 The OpenGL Application Programming Interface 2.3.1 2.3.2 2.3.3 2.3.4 Graphics Functions 51 The Graphics Pipeline and State Machines The OpenGL Interface 53 Coordinate Systems 55 2.4 Primitives and Attributes 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 Polygon Basics 58 Polygons in OpenGL 59 Approximating a Sphere 60 Triangulation 62 Text 64 Curved Objects 65 Attributes 65 2.5 Color 2.5.1 2.5.2 2.5.3 RGB Color 69 Indexed Color 71 Setting of Color Attributes 2.6 Viewing 2.6.1 2.6.2 The Orthographic View 74 Two-Dimensional Viewing 77 2.7 Control Functions 2.7.1 2.7.2 2.7.3 2.7.4 Interaction with the Window System 78 Aspect Ratio and Viewports 79 The main, display, and init Functions 80 Program Structure 83 53 56 67 72 73 78 Color Plate Flat-shaded polygonal rendering of sun object (Courtesy of Fulldome Project, University of New Mexico.) Color Plate Smooth-shaded polygonal rendering of sun object (Courtesy of Fulldome Project, University of New Mexico.) Color Plate Wire-frame of NURBS representation of sun object showing the high number of polygons used in rendering the NURBS surfaces (Courtesy of Fulldome Project, University of New Mexico.) Color Plate Rendering of sun object showing bump map (Courtesy of Fulldome Project, University of New Mexico.) Color Plate Rendering of sun object with an environment map (Courtesy of Fulldome Project, University of New Mexico.) Color Plate Rendering of a small part of the sun object with an environment map (Courtesy of Fulldome Project, University of New Mexico.) (a) Without antialiasing (b) With antialiasing Color Plate Axonometric view from outside of temple (Courtesy of Richard Nordhaus, Architect, Albuquerque, NM.) Color Plate 10 Perspective view of interior of temple (Courtesy of Richard Nordhaus, Architect, Albuquerque, NM.) Color Plate 11 Cartoon-shaded teapot (Courtesy of Ed Angel, University of New Mexico.) Color Plate 12 Reflection map from a color cube on teapot (Courtesy of Ed Angel, University of New Mexico.) Color Plate 13 Interface for animation using Maya (Courtesy of Hue Walker, ARTS Lab, University of New Mexico.) Color Plate 14 (a) Wire-frame model of a wave (Courtesy of Sony Pictures Entertainment.) Color Plate 14 (b) White water and spray created by particle system (Courtesy of Sony Pictures Entertainment.) Color Plate 14 (c) Final composited image from “Surf’s Up.” (Courtesy of Sony Pictures Entertainment.) Color Plate 15 Rendering using ray tracer (Courtesy of Patrick McCormick.) Color Plate 16 Radiosity rendering showing soft shadows and diffuse–diffuse reflections (Courtesy of A Van Pernis, K Rasche, R Geist, Clemson University.) Color Plate 17 Array of Utah teapots with different material properties (Courtesy of SGI.) Color Plate 18 Phong-Blinn shaded teapots (Courtesy of Ed Angel, University of New Mexico.) (a) Using per-vertex lighting (b) Using per-fragment lighting (c) Area near highlight (d) Area near highlight Color Plate 19 Fluid dynamics of the mantle of the Earth Pseudocolor mapping of temperatures and isotemperature surface (Courtesy of James Painter, Los Alamos National Laboratory.) Color Plate 20 Volume rendering of CT data (Courtesy of J Kniss, G Kindlmann, C Hansen, Scientific Computing and Imaging Institute, University of Utah.) Color Plate 21 RGB color cube (Courtesy of University of New Mexico.) Color Plate 22 Avatar representing a patient who is being diagnosed and treated by a remotely located health professional (inset) (Courtesy of Tom Caudell, Visualization Laboratory, Albuquerque High Performance Computing Center, University of New Mexico.) Color Plate 23 One frame from Pixar’s “Geri’s Game” showing refraction through reflections on Geri’s glasses (Courtesy of Pixar Animation Studios.) Color Plate 24 Reflection map from environment computed from the center of the lens on Geri’s glasses The reflection map is then mapped to the glasses as part of the rendering process (Courtesy of Pixar Animation Studios.) Color Plate 25 Elevation data for Honolulu, Hawaii, displayed using a quadmesh to define control points for a Bezier surface (Courtesy of Brian Wylie, University of New Mexico and Sandia National Laboratories.) Color Plate 26 Wire frame of the quadmesh showing lower resolution in flat areas (Courtesy of Brian Wylie, University of New Mexico and Sandia National Laboratories.) Color Plate 27 Rendering of hierarchical robot figure (Courtesy of University of New Mexico.) Color Plate 28 Sphere computed by recursive subdivision of tetrahedrons; triangle colors assigned randomly (Courtesy of University of New Mexico.) Color Plate 29 Shadows from a cube onto ground Computed by two passes over the data with viewpoint shifted between viewer and light source (Courtesy of University of New Mexico.) Color Plate 30 Visualization of thermohaline flows in the Carribean Sea using streamtubes colored by water temperature (Courtesy of David Munich, High Performance Computing Center, University of New Mexico.) Color Plate 31 Particle system (Courtesy of Team One Advertising.) (a) Mesh of particles b) Model of Lexus with surface (c) Wind blowing mesh off Lexus (d) Mesh blown away from Lexus [...]... does she provide warmth and companionship, but also provides invaluable feedback on our presentation and materials She’s been a valuable, unrecognized partner in all of Dave’s OpenGL endeavors Ed Angel Dave Shreiner Preface INTERACTIVE COMPUTER GRAPHICS A TOP- DOWN APPROACH WITH SHADER- BASED OPENGL 6th Edition xxix This page intentionally left blank CHA P TE R 1 GRAPHICS SYSTEMS AND MODELS I t would... driving That same analogy applies to the way we teach computer graphics One approach the algorithmic approach is to teach everything about what makes a car function: the engine, the transmission, the combustion process A second approach the survey approach is to hire a chauffeur, sit back, and see the world as a spectator The third approach the programming approach that we have adopted here—is to teach you... are available for virtually all graphics cards There is also an OpenGL API called Mesa that is included with most Linux distributions A graphics class teaches far more than the use of a particular API, but a good API makes it easier to teach key graphics topics, including three-dimensional graphics, lighting and shading, client–server graphics, modeling, and implementation algorithms We believe that... somewhat revolutionary in using a standard graphics library and a top- down approach Over the succeeding 13 years and five editions, this approach has been adopted by most introductory classes in computer graphics and by virtually all the competing textbooks The major changes in graphics hardware over the past few years have led to major changes in graphics software For its first fifteen years, new OpenGL versions... Exercises APPENDIX A 600 600 604 SAMPLE PROGRAMS A. 1 Shader Initialization Function A. 1.1 Application Code 608 607 608 Contents A. 2 Sierpinski Gasket Program A. 2.1 A. 2.2 A. 2.3 Application Code 610 Vertex Shader 612 Fragment Shader 612 A. 3 Recursive Generation of Sierpinski Gasket A. 3.1 A. 3.2 A. 3.3 Application Code 613 Vertex Shader 615 Fragment Shader 615 A. 4 Rotating Cube with Rotation in Shader A. 4.1 A. 4.2... A. 4.2 A. 4.3 Application Code 615 Vertex Shader 620 Fragment Shader 620 A. 5 Perspective Projection A. 5.1 A. 5.2 A. 5.3 Application Code 621 Vertex Shader 625 Fragment Shader 626 A. 6 Rotating Shaded Cube A. 6.1 A. 6.2 A. 6.3 Application Code 626 Vertex Shader 631 Fragment Shader 632 A. 7 Per-Fragment Lighting of Sphere Model A. 7.1 A. 7.2 A. 7.3 Application Code 632 Vertex Shader 637 Fragment Shader 638 A. 8 Rotating... Rotating Cube with Texture A. 8.1 A. 8.2 A. 8.3 Application Code 638 Vertex Shader 644 Fragment Shader 645 A. 9 Figure with Tree Traversal A. 9.1 A. 9.2 A. 9.3 Application Code 646 Vertex Shader 659 Fragment Shader 659 A. 10 Teapot Renderer A. 10. 1 A. 10. 2 A. 10. 3 Application Code 659 Vertex Shader 664 Fragment Shader 664 APPENDIX B SPACES 610 613 615 621 626 632 638 646 659 665 B.1 Scalars 665 B.2 Vector Spaces 666... systems, fractals, and procedural noise Curves and surfaces, including subdivision surfaces, are discussed in Chapter 10 Chapter 11 surveys alternate approaches to rendering It includes expanded discussions of ray tracing and radiosity, and an introduction to image -based rendering and parallel rendering Programs, primarily from the first part of the book, are included in Appendix A They are also available... and positron-emission tomography (PET)—generate three-dimensional data that must be subjected to algorithmic manipulation to provide useful information Color Plate 20 shows an image of a person’s head in which the skin is displayed as transparent and the internal structures are displayed as opaque Although the data were collected by a medical imaging system, computer graphics produced the image that... unrivaled both as a processor of data and as a pattern recognizer More than 4000 years ago, the Babylonians displayed floor plans of buildings on stones More than 2000 years ago, the Greeks were able to convey their architectural ideas graphically, even though the related mathematics was not developed until the Renaissance Today, the same type of information is generated by architects, mechanical designers, ...This page intentionally left blank INTERACTIVE COMPUTER GRAPHICS A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL 6th Edition This page intentionally left blank INTERACTIVE COMPUTER GRAPHICS A TOP-DOWN. .. designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed in initial caps or all caps Library of Congress Cataloging-in-Publication Data... Cataloging-in-Publication Data Angel, Edward Interactive computer graphics : a top-down approach with shader-based OpenGL / Edward Angel, David Shreiner — 6th ed p cm Includes bibliographical references and index

Ngày đăng: 07/01/2017, 21:19

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w