Interactive Computer Graphics



Similar documents
Introduction to Computer Graphics

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur

Course Overview. CSCI 480 Computer Graphics Lecture 1. Administrative Issues Modeling Animation Rendering OpenGL Programming [Angel Ch.

GAME ENGINE DESIGN. A Practical Approach to Real-Time Computer Graphics. ahhb. DAVID H. EBERLY Geometrie Tools, Inc.

Computer Graphics CS 543 Lecture 12 (Part 1) Curves. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

INTRODUCTION TO RENDERING TECHNIQUES

A Short Introduction to Computer Graphics

Content. Chapter 4 Functions Basic concepts on real functions 62. Credits 11

Introduction Week 1, Lecture 1

Dhiren Bhatia Carnegie Mellon University

Computer Applications in Textile Engineering. Computer Applications in Textile Engineering

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

COMPUTER GRAPHICS Computer Graphics

B2.53-R3: COMPUTER GRAPHICS. NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions.

GUI GRAPHICS AND USER INTERFACES. Welcome to GUI! Mechanics. Mihail Gaianu 26/02/2014 1

Essential Mathematics for Computer Graphics fast

COMP-557: Fundamentals of Computer Graphics McGill University, Fall 2010

Programming 3D Applications with HTML5 and WebGL

Lecture Notes, CEng 477

SkillsUSA 2014 Contest Projects 3-D Visualization and Animation

Computer Graphics. Geometric Modeling. Page 1. Copyright Gotsman, Elber, Barequet, Karni, Sheffer Computer Science - Technion. An Example.

Curves and Surfaces. Goals. How do we draw surfaces? How do we specify a surface? How do we approximate a surface?

Computer Graphics. Introduction. Computer graphics. What is computer graphics? Yung-Yu Chuang

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

Using Photorealistic RenderMan for High-Quality Direct Volume Rendering

Teaching Introductory Computer Graphics Via Ray Tracing

Bachelor of Games and Virtual Worlds (Programming) Subject and Course Summaries

Instructor. Goals. Image Synthesis Examples. Applications. Computer Graphics. Why Study 3D Computer Graphics?

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Advanced Computer Science. Friday 18 th January 2008.

COMP175: Computer Graphics. Lecture 1 Introduction and Display Technologies

We can display an object on a monitor screen in three different computer-model forms: Wireframe model Surface Model Solid model

Introduction to Computer Graphics Marie-Paule Cani & Estelle Duveau

Introduction to Computer Graphics

Geometric Modelling & Curves

Computer Graphics. Anders Hast

Introduction Week 1, Lecture 1

CPIT-285 Computer Graphics

Cork Education and Training Board. Programme Module for. 3 Dimensional Computer Graphics. Leading to. Level 5 FETAC

3D Math Overview and 3D Graphics Foundations

CSE 564: Visualization. GPU Programming (First Steps) GPU Generations. Klaus Mueller. Computer Science Department Stony Brook University

CSE 167: Lecture 13: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

CS 4204 Computer Graphics

Lezione 4: Grafica 3D*(II)

How To Teach Computer Graphics

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

How To Draw A 3D Virtual World In 3D Space (Computer Graphics)

Interactive visualization of multi-dimensional data in R using OpenGL

SAN DIEGO COMMUNITY COLLEGE DISTRICT MESA COLLEGE ASSOCIATE DEGREE COURSE OUTLINE

Fundamentals of Computer Graphics

Introduction to Computer Graphics. Reading: Angel ch.1 or Hill Ch1.

Introduction to GPGPU. Tiziano Diamanti

COMPUTER GRAPHICS IMPORTANT QUESTION AND ANSWERS. Computer graphics

Digital 3D Animation

William Paterson University of New Jersey Department of Computer Science College of Science and Health Course Outline

Recent Advances and Future Trends in Graphics Hardware. Michael Doggett Architect November 23, 2005

Our One-Year 3D Animation Program is a comprehensive training in 3D using Alias

Modern Graphics Engine Design. Sim Dietrich NVIDIA Corporation

CUBE-MAP DATA STRUCTURE FOR INTERACTIVE GLOBAL ILLUMINATION COMPUTATION IN DYNAMIC DIFFUSE ENVIRONMENTS

Univariate and Multivariate Methods PEARSON. Addison Wesley

Specular reflection. Dielectrics and Distribution in Ray Tracing. Snell s Law. Ray tracing dielectrics

Realtime 3D Computer Graphics Virtual Reality

Game Development in Android Disgruntled Rats LLC. Sean Godinez Brian Morgan Michael Boldischar

DATA VISUALIZATION OF THE GRAPHICS PIPELINE: TRACKING STATE WITH THE STATEVIEWER

CS 4810 Introduction to Computer Graphics

Plug-in Software Developer Kit (SDK)

Computer Graphics Hardware An Overview

521493S Computer Graphics. Exercise 2 & course schedule change

Three-Dimensional Data Recovery Using Image-Based Modeling

Mathematics (MAT) MAT 061 Basic Euclidean Geometry 3 Hours. MAT 051 Pre-Algebra 4 Hours

INTERACTIVE COMPUTER GRAPHICS Data Structures, Algorithms, Languages

Solving Simultaneous Equations and Matrices

B4 Computational Geometry

Computer Graphics Global Illumination (2): Monte-Carlo Ray Tracing and Photon Mapping. Lecture 15 Taku Komura

Computer Animation: Art, Science and Criticism

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

Introduction to Computer Graphics

Computer Graphics. Introduction. Aleksandra Pizurica. Ghent University

3D Computer Games History and Technology

Introduction to Computer Graphics

Modeling Curves and Surfaces

Hardware design for ray tracing

Rally Sport Racing Game: CodeName Space Racer

ESSENTIAL CURRICULUM GUIDLINE FOR ANIMATION I INTRODUCTION

Touchstone -A Fresh Approach to Multimedia for the PC

The Data Access Handbook

Introduction Computer stuff Pixels Line Drawing. Video Game World 2D 3D Puzzle Characters Camera Time steps

Cortona3D Viewer. User's Guide. Copyright ParallelGraphics

Maya 2014 Still Life Part 1 Texturing & Lighting

Computer Animation: Art, Science and Criticism

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

Monte Carlo Path Tracing

Triangle Scan Conversion using 2D Homogeneous Coordinates

Abstract. These two vectors define a plane tangent to the surface at that point. Their cross product is Recent work in computer graphics has been

Computer Organization

Transcription:

Interactive Computer Graphics A Top-Down Approach Using OpenGL FIFTH EDITION EDWARD ANGEL UNIVERSITY OF NEW MEXICO PEARSON Addison Wesley Boston San Francisco New York London Toronto Sydney Tokyo Singapore Madrid Mexico City Munich Paris Cape Töwn Hong Kong Montreal

Preface xxv CHAPTER 1 GRAPHICS SYSTEMS AND MODELS 1.1 Applications of Computer Graphics 1.1.1 Display of Information 2 1.1.2 Design 3 1.1.3 Simulation and Animation 3 1.1.4 User Interfaces 5 1.2 A Graphics System 1.2.1 Pixels and the Frame Buffer 5 1.2.2 Output Devices 7 1.2.3 Input Devices 10 1.3 Images: Physical and Synthetic 1.3.1 Objects and Viewers 11 1.3.2 Light and Images 12 1.3.3 Image Formation Models 14 1.4 Imaging Systems 1.4.1 The Pinhole Camera 16 1.4.2 The Human Visual System 18 1.5 The Synthetic-Camera Model 1.6 The Programmer's Interface 1.6.1 The Pen-Plotter Model 23 1.6.2 Three-Dimensional APIs 24 1.6.3 A Sequence of Images 27 1.6.4 The Modeling-Rendering Paradigm 28 1.7 Graphics Architectures 1.7.1 Display Processors 30 1.7.2 Pipeline Architectures 30 1.7.3 The Graphics Pipeline 31 1.7.4 Vertex Processing 32

viii Contents 1.7.5 Clipping and Primitive Assembly 32 1.7.6 Rasterization 33 1.7.7 Fragment Processing 33 1.8 Programmable Pipelines 33 1.9 Performance Characteristics 34 Summary and Notes 35 Suggested Readings 36 Exercises 36 CHAPTER2 GRAPHICS PROGRAMMING 39 2.1 The Sierpinski Gasket 39 2.2 Programming Two-Dimensional Applications 40 2.2.1 Coordinate Systems 45 2.3 The OpenGL API 46 2.3.1 Graphics Functions 47 2.3.2 The Graphics Pipeline and State Machines 48 2.3.3 The OpenGL Interface 49 2.4 Primitives and Attributes 50 2.4.1 Polygon Basics 52 2.4.2 Polygon Types in OpenGL 53 2.4.3 Approximating a Sphere 55 2.4.4 Text 56 2.4.5 Curved Objects 58 2.4.6 Attributes 58 2.5 Color 60 2.5.1 RGB Color 62 2.5.2 Indexed Color 63 2.5.3 Setting of Color Attributes 65 2.6 Viewing 66 2.6.1 The Orthographie View 66 2.6.2 Two-Dimensional Viewing 69 2.6.3 Matrix Modes 70 2.7 Control Functions 70 2.7.1 Interaction with the Window System 71 2.7.2 Aspect Ratio and Viewports 72 2.7.3 The main, display, and myinit Functions 74 2.7.4 Program Structure 75 2.8 The Gasket Program 76 2.9 Polygons and Recursion 77

Contents 2.10 The Three-Dimensional Gasket 80 2.10.1 Use of Three-Dimensional Points 80 2.10.2 Use of Polygons in Three Dimensions 82 2.10.3 Hidden-Surface Removal 83 2.11 Plotting Implicit Functions 85 2.11.1 Marching Squares 86 Summary and Notes 92 Suggested Readings 94 Exercises 94 CHAPTF.R3 INPUT AND INTERACTION 99 3.1 Interaction 99 3.2 Input Devices 100 3.2.1 Physical Input Devices 101 3.2.2 Logical Devices 104 3.2.3 Input Modes 105 3.3 Clients and Servers 107 3.4 Display Lists 109 3.4.1 Definition and Execution of Display Lists 110 3.4.2 Text and Display Lists 112 3.4.3 Fonts in GLUT 115 3.5 Display Lists and Modeling 116 3.6 Programming Event-Driven Input 117 3.6.1 Using the Pointing Device 117 3.6.2 Window Events 121 3.6.3 Keyboard Events 122 3.6.4 The Display and Idle Callbacks 123 3.6.5 Window Management 124 3.7 Menüs 124 3.8 Picking 126 3.8.1 Picking and Selection Mode 127 3.9 A Simple CAD Program 133 3.10 Building Interactive Models 140 3.11 Animating Interactive Programs 142 3.11.1 The Rotating Square 143 3.11.2 Double Buffering 144 3.11.3 Using a Timer 146 3.12 Design of Interactive Programs 147 3.12.1 Toolkits, Widgets, and the Frame Buffer 148

Contents 3.13 3.13.1 3.13.2 3.13.3 Logic Operations Drawing Erasable Lines 150 XORandColor 153 Cursors and Overlay Planes 153 Summary and Notes 154 Suggested Readings 155 Exercises 155 149 CHAPTER 4. GEOMETRIC OBJECTS AND TRANSFORMATIONS 159 4.1 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.1.10 4.2 4.3 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.4 4.5 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.6 4.7 4.7.1 4.7.2 Sealars, Points, and Vectors Geometrie Objects 160 Coordinate-Free Geometry 161 The Mathematical View: Vector and Affine Spaces 162 The Computer Science View 163 Geometrie ADTs 163 Lines 165 Affine Sums 165 Convexity 166 Dot and Cross Products 166 Planes 167 Three-Dimensional Primitives Coordinate Systems and Frames Representations and N-Tuples 172 Change of Coordinate Systems 172 Example Change of Representation 175 Homogeneous Coordinates 176 Example Change in Frames 179 Working with Representations 181 Frames in OpenGL Modeling a Colored Cube Modeling the Faces 188 Inward- and Outward-Pointing Faces 189 Data Structures for Object Representation 189 The Color Cube 190 Bilinear Interpolation 191 Vertex Arrays 192 Affine Transformations Translation, Rotation, and Scaling Translation 198 Rotation 198 160 168 170 183 187 195 197

4.7.3 Scaling 200 4.8 Transformations in Homogeneous Coordinates 202 4.8.1 Translation 203 4.8.2 Scaling 204 4.8.3 Rotation 205 4.8.4 Shear 206 4.9 Concatenation of Transformations 207 4.9.1 Rotation About a Fixed Point 208 4.9.2 General Rotation 209 4.9.3 The Instance Transformation 211 4.9.4 Rotation About an Arbitrary Axis 212 4.10 OpenGL Transformation Matrices 215 4.10.1 The Current Transformation Matrix 215 4.10.2 Rotation, Translation, and Scaling 216 4.10.3 Rotation About a Fixed Point in OpenGL 217 4.10.4 Order of Transformations 217 4.10.5 Spinning of the Cube 218 4.10.6 Loading, Pushing, and Popping Matrices 219 4.11 Interfaces to Three-Dimensional Applications 220 4.11.1 Using Areas of the Screen 221 4.11.2 A Virtual Trackball 221 4.11.3 Smooth Rotations 224 4.11.4 Incremental Rotation 225 4.12 Quaternions 226 4.12.1 Complex Numbers and Quaternions 226 4.12.2 Quaternions and Rotation 228 Summary and Notes 230 Suggested Readings 231 Exercises 231 5 VIEWING 235 5.1 Classical and Computer Viewing 235 5.1.1 Classical Viewing 237 5.1.2 Orthographie Projections 237 5.1.3 Axonometrie Projections 238 5.1.4 Oblique Projections 240 5.1.5 Perspective Viewing 241 5.2 Viewing with a Computer 242

xii Contents 5.3 Positioning of the Camera 244 5.3.1 Positioning of the Camera Frame 244 5.3.2 Two Viewing APIs 249 5.3.3 The Look-At Function 252 5.3.4 Other Viewing APIs 253 5.4 Simple Projections 254 5.4.1 Perspective Projections 254 5.4.2 Orthogonal Projections 257 5.5 Projections in OpenGL 258 5.5.1 Perspective in OpenGL 259 5.5.2 Parallel Viewing in OpenGL 261 5.6 Hidden-Surface Removal 262 5.6.1 Culling 264 5.7 Interactive Mesh Displays 264 5.7.1 Meshes 264 5.7.2 Walking Through a Scene 266 5.7.3 Polygon Offset 268 5.8 Parallel-Projection Matrices 269 5.8.1 Projection Normalization 270 5.8.2 Orthogonal-Projection Matrices 271 5.8.3 Oblique Projections 273 5.9 Perspective-Projection Matrices 276 5.9.1 Perspective Normalization 276 5.9.2 OpenGL Perspective Transformations 280 5.10 Projections and Shadows 281 Summary and Notes 284 Suggested Readings 285 Exercises 285 CHAPTER6 LIGHTING AND SHADING 289 6.1 Light and Matter 290 6.2 Light Sources 294 6.2.1 Color Sources 294 6.2.2 Ambient Light 295 6.2.3 Point Sources 296 6.2.4 Spotlights 297 6.2.5 Distant Light Sources 297 6.3 The Phong Lighting Model 298 6.3.1 Ambient Reflection 300

Contents xiii 6.3.2 Diffuse Reflection 300 6.3.3 Specular Reflection 301 6.3.4 The Modified Phong Model 303 6.4 Computation of Vectors 304 6.4.1 Normal Vectors 304 6.4.2 Angle of Reflection 308 6.5 Polygonal Shading 309 6.5.1 Fiat Shading 310 6.5.2 Smooth and Gouraud Shading 311 6.5.3 Phong Shading 313 6.6 Approximation of a Sphere by Recursive Subdivision 314 6.7 Light Sources in OpenGL 317 6.8 Specification of Materials in OpenGL 320 6.9 Shading of the Sphere Model 322 6.10 Global Illumination 323 Summary and Notes 325 Suggested Readings 326 Exercises 326 CHAPTER 7 FROM VERTICES TO FRAGMENTS 329 7.1 Basic Implementation Strategies 330 7.2 Four Major Tasks 332 7.2.1 Modeling 332 7.2.2 Geometry Processing 333 7.2.3 Rasterization 334 7.2.4 Fragment Processing 335 7.3 Clipping 336 7.4 Line-Segment Clipping 336 7.4.1 Cohen-Sutherland Clipping 337 7.4.2 Liang-Barsky Clipping 339 7.5 Polygon Clipping 341 7.6 Clipping of Other Primitives 343 7.6.1 Bounding Boxes and Volumes 344 7.6.2 Curves, Surfaces, and Text 345 7.6.3 Clipping in the Frame Buffer 345 7.7 Clipping in Three Dimensions 346 7.8 Rasterization 349 7.9 Bresenham's Algorithm 352

xiv Contents 7.10 Polygon Rasterization 354 7.10.1 Inside-Outside Testing 354 7.10.2 OpenGL and Concave Polygons 355 7.10.3 Fill and Sort 356 7.10.4 Flood Fill 357 7.10.5 Singularities 357 7.11 Hidden-Surface Removal 358 7.11.1 Object-Space and Image-Space Approaches 358 7.11.2 Sorting and Hidden-Surface Removal 360 7.11.3 ScanLine Algorithms 360 7.11.4 Back-Face Removal 361 7.11.5 The z-buffer Algorithm 362 7.11.6 Scan Conversion with the z-buffer 365 7.11.7 Depth Sort and the Painter's Algorithm 367 7.12 Antialiasing 369 7.13 Display Considerations 371 7.13.1 Color Systems 372 7.13.2 The Color Matrix 375 7.13.3 Gamma Correction 376 7.13.4 Dithering and Halftoning 376 Summary and Notes 377 Suggested Readings 379 Exercises 379 8 DISCRETE TECHNIQUES 333 8.1 Buffers 383 8.2 Digital Images 385 8.3 Writing into Buffers 388 8.3.1 Writing Modes 389 8.3.2 Writes with XOR 391 8.4 Bit and Pixel Operations in OpenGL 392 8.4.1 OpenGL Buffers and the Pixel Pipeline 392 8.4.2 Bitmaps 394 8.4.3 Raster Fonts 395 8.4.4 Pixels and Images 396 8.4.5 Lookup Tables 397 8.5 Examples 399 8.5.1 Displaying a Color Gamut 400 8.5.2 Testing Algorithms 400 8.5.3 Buffers for Picking 401

8.6 Mapping Methods 401 8.7 Texture Mapping 403 8.7.1 Two-Dimensional Texture Mapping 404 8.8 Texture Mapping in OpenGL 410 8.8.1 Two-Dimensional Texture Mapping 411 8.8.2 Texture Sampling 414 8.8.3 Working with Texture Coordinates 417 8.8.4 Texture Objects 419 8.8.5 Multitexturing 420 8.9 Texture Generation 421 8.10 Environment Maps 422 8.11 Compositing Techniques 427 8.11.1 Opacity and Blending 428 8.11.2 Image Compositing 429 8.11.3 Blending and Compositing in OpenGL 429 8.11.4 Antialiasing Revisited 431 8.11.5 Back-to-Front and Front-to-Back Rendering 432 8.11.6 Depth Cueing and Fog 433 8.12 Multirendering and the Accumulation Buffer 434 8.12.1 Scene Antialiasing 435 8.12.2 Bump Mapping and Embossing 436 8.12.3 Image Processing 436 8.12.4 Imaging Extensions 438 8.12.5 Other Multipass Methods 438 8.13 Sampling and Aliasing 439 8.13.1 Sampling Theory 440 8.13.2 Reconstruction 444 8.13.3 Quantization 446 Summary and Notes 447 Suggested Readings 448 Exercises 448 cnarr-:f<9 PROGRAMMABLE SHADERS 451 9.1 Programmable Pipelines 451 9.2 Shading Languages 453 9.2.1 ShadeTrees 453 9.3 Extending OpenGL 454 9.3.1 OpenGL Versions and Extensions 455 9.3.2 GLSL and Cg 456

XVI Contents 9.4 9.4.1 9.4.2 9.5 9.5.1 9.5.2 9.5.3 9.6 9.7 9.7.1 9.7.2 9.7.3 9.8 9.8.1 9.8.2 9.9 9.10 9.11 9.12 9.12.1 9.12.2 9.12.3 9.13 9.13.1 9.13.2 The OpenGL Shading Language Vertex Shaders 457 Fragment Shaders 459 The OpenGL Shading Language GLSL Execution 461 Data Types and Qualifiers 461 Operators and Functions 464 Linking Shaders with OpenGL Programs Moving Vertices Scaling Vertex Positions 470 Morphing 472 Particle Systems 474 Vertex Lighting with Shaders Phong Lighting 475 Nonphotorealistic Shading 478 Fragment Shaders Per-Vertex Versus Per-Fragment Lighting Samplers Cube Maps Reflection Maps 486 Refraction 487 Normalization Maps 490 Bump Mapping Finding Bump Maps 492 Examples 495 Summary and Notes 499 Suggested Readings 499 Exercises 500 456 460 465 470 475 479 480 483 485 492.- 10 MODELING AMD rü=rarchy 503 10.1 Symbols and Instances 504 10.2 Hierarchical Models 505 10.3 A Robot Arm 507 10.4 Trees and Traversal 509 10.4.1 A Stack-Based Traversal 511 10.5 Use of Tree Data Structures 513 10.6 Animation 517

Contents xvii 10.7 Graphical Objects 519 10.7.1 Methods, Attributes, and Messages 519 10.7.2 ACubeObject 521 10.7.3 Implementing the Cube Object 523 10.7.4 Objects and Hierarchy 524 10.7.5 Geometrie Objects 525 10.8 Scene Graphs 526 10.9 A Simple Scene Graph API 528 10.9.1 TheNodeClass 528 10.9.2 Geometry Nodes 530 10.9.3 Camera Class 532 10.9.4 Lights and Materials 533 10.9.5 Transformations 535 10.9.6 The Robot Figure 535 10.9.7 Implementing the Viewer 537 10.9.8 Implementing a Node 541 10.10 Open Scene Graph 544 10.11 Graphics and the Internet 546 10.11.1 Networks and Protocols 546 10.11.2 Hypermedia and HTML 547 10.11.3 Databases and VRML 548 10.11.4 Java and Applets 549 10.12 Other Tree Structures 549 10.12.1 CSGTrees 550 10.12.2 BSPTrees 551 10.12.3 Quadtrees and Octrees 554 Summary and Notes 555 Suggested Readings 556 Exercises 556 : ipter 11 PROCEDURAL METHODS 559 11.1 Algorithmic Models 559 11.2 Physically-Based Models and Particle Systems 561 11.3 Newtonian Particles 562 11.3.1 Independent Particles 564 11.3.2 Spring Forces 565 11.3.3 Attractive and Repulsive Forces 566 11.4 Solving Particle Systems 568

XVU1 Contents 11.5 11.5.1 11.5.2 Constraints Collisions 571 Soft Constraints 573 570 11.6 11.6.1 11.6.2 11.6.3 11.6.4 11.6.5 11.6.6 A Simple Partial System Displaying the Particles 574 Updating Particle Positions 575 Initialization 575 Collisions 576 Forces 577 Flocking 577 574 11.7 11.8 11.8.1 11.8.2 11.8.3 11.8.4 11.8.5 Language-Based Models Recursive Methods and Fractals Rulers and Length 582 Fractal Dimension 583 Midpoint Division and Brownian Motion Fractal Mountains 585 The Mandelbrot Set 586 584 578 582 11.9 Procedural Noise 590 Summary and Notes 594 Suggested Readings 594 Exercises 595 CHAP11:? 12 CURVES AND SUSPACES 597 12.1 Representation of Curves and Surfaces 597 12.1.1 Explicit Representation 597 12.1.2 Implicit Representations 599 12.1.3 Parametric Form 600 12.1.4 Parametric Polynomial Curves 601 12.1.5 Parametric Polynomial Surfaces 602 12.2 Design Criteria 603 12.3 Parametric Cubic Polynomial Curves 604 12.4 Interpolation 605 12.4.1 Blending Functions 607 12.4.2 The Cubic Interpolating Patch 609 12.5 Hermite Curves and Surfaces 611 12.5.1 The Hermite Form 611 12.5.2 Geometrie and Parametric Continuity 613 12.6 Bezier Curves and Surfaces 614 12.6.1 Bezier Curves 615

Contents xix 12.6.2 Bezier Surface Patches 617 12.7 Cubic B-Splines 12.7.1 The Cubic B-Spline Curve 618 12.7.2 B-Splines and Basis 621 12.7.3 Spline Surfaces 623 12.8 General B-Splines 12.8.1 Recursively Defined B-Splines 624 12.8.2 Uniform Splines 625 12.8.3 Nonuniform B-Splines 626 12.8.4 NURBS 626 12.8.5 Catmull-Rom Splines 628 12.9 Rendering Curves and Surfaces 12.9.1 Polynomial Evaluation Methods 629 12.9.2 Recursive Subdivision of Bezier Polynomials 630 12.9.3 Rendering Other Polynomial Curves by Subdivision 12.9.4 Subdivision of Bezier Surfaces 634 12.10 The Utah Teapot 12.11 Algebraic Surfaces 12.11.1 Quadrics 638 12.11.2 Rendering of Surfaces by Ray Casting 639 12.11.3 Subdivision Curves and Surfaces 640 12.11.4 Mesh Subdivision 641 12.12 Curves and Surfaces in OpenGL 12.12.1 Bezier Curves 644 12.12.2 Bezier Surfaces 645 12.12.3 Displaying the Teapot 646 12.12.4 NURBS Functions 648 12.12.5 Quadrics 648 Summary and Notes 649 Suggested Readings 650 Exercises 650 633 618 623 629 636 638 644 CHARTER 13 ADVANCED RENDERING 653 13.1 Going Beyond Pipeline Rendering 13.2 Ray Tracing 13.3 Building a Simple Ray Tracer 13.3.1 Recursive Ray Tracing 658 13.3.2 Calculating Intersections 660 13.3.3 Ray-Tracing Variations 663 653 654 658

xx Contents 13.4 The Rendering Equation 664 13.5 Radiosity 666 13.5.1 The Radiosity Equation 666 13.5.2 Solving the Radiosity Equation 668 13.5.3 Computing Form Factors 669 13.5.4 Carrying Out Radiosity 672 13.6 RenderMan 673 13.7 Parallel Rendering 674 13.7.1 Sort-Middle Rendering 675 13.7.2 Sort-Last Rendering 677 13.7.3 Sort-First Rendering 680 13.8 Image-Based Rendering 682 13.8.1 A Simple Example 682 Summary and Notes 684 Suggested Readings 685 Exercises 686 APPENDIX A SAMPLE PROGRAMS 689 A.1 Sierpinski Gasket Program 690 A.2 Recursive Generation of Sierpinski Gasket 692 A.3 Recursive Three-Dimensional Sierpinski Gasket 693 A.4 Marching Squares 696 A.5 Polygon Modeling Program 701 A.6 Double-Buffering program 707 A.7 Selection-Mode Picking Program 710 A.8 Rotating-Cube Program 712 A.9 Rotating Cube Using Vertex Arrays 715 A.10 Rotating Cube with a Virtual Trackball 717 A.11 Moving Viewer 721 A.12 Sphere Program 724 A.13 Mandelbrot Set Program 727 A.14 Bresenham's Algorithm 730 A.15 Rotating Cube with Texture 733 A.16 GLSL Example 735 A.17 Scene Graph Program 741 A.18 Particle System Program 746 A.19 Program for Drawing Bezier Curves 751

Contents xxi APPENDIX B SPACES B.1 Sealars B.2 Vector Spaces B.3 Affine Spaces B.4 Euclidean Spaces B.5 Projections B.6 Gram-Schmidt Orthogonalization Suggested Readings 762 Exercises 762 755 755 756 758 759 760 761 APPENDIX C MATRICES C.1 Definitions C.2 Matrix Operations C.3 Row and Column Matrices C.4 Rank C.5 Change of Representation C.6 The Cross Product C.7 Eigenvalues and Eigenvectors Suggested Readings 773 Exercises 774 765 765 766 767 768 769 771 772 APPENDIX D SYNOPSIS OF OPENGL FUNCTIONS D.1 Specifying Simple Geometry D.2 Attributes D.3 Working with the Window System D.4 Interaction D.5 Enabling Features D.6 Transformations D.7 Viewing D.8 Defining Discrete Primitives D.9 Display Lists D.10 Picking D.11 Lighting D.12 Texture Mapping D.13 State and Buffer Manipulation D.14 Vertex Arrays 775 775 776 777 779 780 781 782 783 784 785 786 786 788 788

xxii Contents D.15 Blending Functions 789 D.16 Query Functions 789 D.17 Curve and Surface Functions 790 D.18 GLUQuadrics 791 D.19 GLSL Functions 791 References 795 OpenGL Function Index 805 Subject Index 807