本书采用自顶向下的方法并辅以面向编程的方式,基于现代可编程GPU的WebGL 2.0着色器编程,综合利用HTML5、JavaScript和GLSL(OpenGL ES 3.0),开发可以在所有*浏览器中运行的三维图形应用程序,同时系统地介绍了现代计算机图形学的核心概念、原理和方法。本书是作者多年教学与科研的结晶,涵盖了交互式图形编程、可编程GPU绘制流水线、变换与观察、光照与着色、曲线与曲面建模、离散技术等计算机图形学的基本内容,以及层级建模、过程建模、光线跟踪、并行绘制、体绘制和虚拟现实等高级内容。为了方便读者进一步深入学习和研究计算机图形学,本书在每章末尾提供了相关的建议阅读资料。
關於作者:
Edward Angel是新墨西哥大学(UNM)计算机科学的退休教授,并担任过艺术、技术和科学实验室(ARTS Lab)的主任。直到2007年7月,他一直是UNM的计算机科学、电子与计算机工程、媒体艺术教授。Angel于1964年在加州理工大学获得学士学位,并于1968年在南加州大学获得博士学位。他曾任职于加州大学伯克利分校、南加州大学和罗切斯特大学。Angel目前的研究领域是计算机图形学及科学可视化、虚拟现实和大规模并行计算等。
Edward Angel是新墨西哥大学(UNM)计算机科学的退休教授,并担任过艺术、技术和科学实验室(ARTS Lab)的主任。直到2007年7月,他一直是UNM的计算机科学、电子与计算机工程、媒体艺术教授。Angel于1964年在加州理工大学获得学士学位,并于1968年在南加州大学获得博士学位。他曾任职于加州大学伯克利分校、南加州大学和罗切斯特大学。Angel目前的研究领域是计算机图形学及科学可视化、虚拟现实和大规模并行计算等。
目錄:
CONTENTS
CHAPTER 1 GRAPHICS SYSTEMS AND MODELS 1
1.1 Applications of Computer Graphics 2
1.1.1 Display of Information 2
1.1.2 Design 3
1.1.3 Simulation and Animation 4
1.1.4 User Interfaces 6
1.2 A Graphics System 7
1.2.1 Pixels and the Framebuffer 8
1.2.2 The CPU and the GPU 9
1.2.3 Output Devices 10
1.2.4 Input Devices 13
1.3 Images: Physical and Synthetic 13
1.3.1 Objects and Viewers 14
1.3.2 Light and Images 15
1.3.3 Imaging Models 17
1.4 Imaging Systems 19
1.4.1 The Pinhole Camera 19
1.4.2 The Human Visual System 21
1.5 The Synthetic-Camera Model 22
1.6 The Programmers Interface 24
1.6.1 The Pen-Plotter Model 25
1.6.2 Three-Dimensional APIs 28
1.6.3 A Sequence of Images 31
1.6.4 The Modeling?CRendering Paradigm 32
1.7 Graphics Architectures 35
1.7.1 Display Processors 36
1.7.2 Pipeline Architectures 37
1.7.3 The Graphics Pipeline 38
1.7.4 Vertex Processing 39
1.7.5 Clipping and Primitive Assembly 40
1.7.6 Rasterization 40
1.7.7 Fragment Processing 40
1.8 Programmable Pipelines 41
1.9 Performance Characteristics 42
1.10 OpenGL Versions and WebGL 43
Summary and Notes 44
Suggested Readings 45
Exercises 45
CHAPTER 2 GRAPHICS PROGRAMMING 49
2.1 The Sierpinski Gasket 49
2.2 Programming Two-Dimensional Applications 52
2.3 The WebGL Application Programming Interface 58
2.3.1 Graphics Functions 59
2.3.2 The Graphics Pipeline and State Machines 61
2.3.3 OpenGL and WebGL 61
2.3.4 The WebGL Interface 62
2.3.5 Coordinate Systems 64
2.4 Primitives and Attributes 65
2.4.1 Polygon Basics 67
2.4.2 Polygons in WebGL 70
2.4.3 Triangulation 71
2.4.4 Text 73
2.4.5 Vertex Attributes 75
2.5 Color 76
2.5.1 RGB Color 78
2.5.2 Color Tables 80
2.5.3 Setting of Color Attributes 81
2.6 Viewing 82
2.6.1 The Orthographic View 83
2.6.2 Two-Dimensional Viewing 84
2.7 Control Functions 85
2.7.1 The HTML Canvas 87
2.7.2 Aspect Ratio and Viewports 88
2.7.3 Application Execution 89
2.8 The Gasket Program 90
2.8.1 Sending Data to the GPU 93
2.8.2 Rendering the Points 94
2.8.3 The Vertex Shader 94
2.8.4 The Fragment Shader 96
2.8.5 Combining the Parts 96
2.8.6 The initShaders Function 97
2.8.7 The init Function 98
2.8.8 Reading the Shaders from the Application 99
2.9 Polygons and Recursion 100
2.10 The Three-Dimensional Gasket 102
2.10.1 Use of Three-Dimensional Points 103
2.10.2 Use of Polygons in Three Dimensions 106
2.10.3 Hidden-Surface Removal 109
Summary and Notes 110
Code Examples 113
Suggested Readings 113
Exercises 114
CHAPTER 3 INTERACTION AND ANIMATION 119
3.1 Animation 119
3.1.1 The Rotating Square 120
3.1.2 The Display Process 122
3.1.3 Double Buffering 123
3.1.4 Using a Timer 124
3.1.5 Using requestAnimationFrame 125
3.2 Interaction 125
3.3 Input Devices 127
3.4 Physical Input Devices 127
3.4.1 Keyboard Codes 128
3.4.2 The Mouse and the Trackball 128
3.4.3 Data Tablets,Touch Pads, and Touch Screens 130
3.4.4 Multidimensional Input Devices 131
3.4.5 Logical Devices 132
3.4.6 Input Modes 133
3.4.7 Clients and Servers 134
3.5 Programming Event-Driven Input 135
3.5.1 Events and Event Listeners 135
3.5.2 Adding a Button 136
3.5.3 Menus 137
3.5.4 Using Key Codes 138
3.5.5 Sliders 139
3.6 Position Input 140
3.7 Window Events 142
3.8 Gesture and Touch 143
3.9 Picking 145
3.10 Building Models Interactively 146
3.11 Design of Interactive Programs 150
Summary and Notes 151
Code Examples 153
Suggested Readings 153
Exercises 154
CHAPTER 4 GEOMETRIC OBJECTS AND TRANSFORMATIONS 159
4.1 Scalars, Points, and Vectors 160
4.1.1 Geometric Objects 160
4.1.2 Coordinate-Free Geometry 162
4.1.3 The Mathematical View: Vector and Affine Spaces 163
4.1.4 The Computer Science View 164
4.1.5 Geometric ADTs 165
4.1.6 Lines 166
4.1.7 Affine Sums 167
4.1.8 Convexity 168
4.1.9 Dot and Cross Products 169
4.1.10 Planes 170
4.2 Three-Dimensional Primitives 172
4.3 Coordinate Systems and Frames 175
4.3.1 Representations and N-Tuples 177
4.3.2 Change of Coordinate Systems 178
4.3.3 Example: Change of Representation 180
4.3.4 Homogeneous Coordinates 182
4.3.5 Example: Change in Frames 185
4.3.6 Working with Representations 187
4.4 Frames in WebGL 189
4.5 Matrix and Vector Types 193
4.5.1 Row Versus Column Major Matrix Representations 195
4.6 Modeling a Colored Cube 195
4.6.1 Modeling the Faces 196
4.6.2 Inward- and Outward-Pointing Faces 197
4.6.3 Data Structures for Object Representation 198
4.6.4 The Colored Cube 198
4.6.5 Color Interpolation 200
4.6.6 Displaying the Cube 201
4.6.7 Drawing by Elements 202
4.6.8 Primitive Restart 203
4.7 Affine Transformations 204
4.8 Translation, Rotation, and Scaling 207
4.8.1 Translation 207
4.8.2 Rotation 207
4.8.3 Scaling 209
4.9 Transformations in Homogeneous Coordinates 211
4.9.1 Translation 212
4.9.2 Scaling 213
4.9.3 Rotation 214
4.9.4 Shear 215
4.10 Concatenation of Transformations 217
4.10.1 Rotation About a Fixed Point 218
4.10.2 General Rotation 219
4.10.3 The Instance Transformation 220
4.10.4 Rotation About an Arbitrary Axis 222
4.11 Transformation Matrices in WebGL 226
4.11.1 Current Transformation Matrices 227
4.11.2 Basic Matrix Functions 228
4.11.3 Rotation, Translation, and Scaling 229
4.11.4 Rotation About a Fixed Point 229
4.11.5 Order of Transformations 230
4.12 Spinning of the Cube 231
4.12.1 Uniform Matrices 233
4.13 Smooth Rotations 235
4.13.1 Incremental Rotation 236
4.14 Quaternions 237
4.14.1 Complex Numbers and Quaternions 237
4.14.2 Quaternions and Rotation 238
4.14.3 Quaternions and Gimbal Lock 240
4.15 Interfaces to Three-Dimensional Applications 242
4.15.1 Using Areas of the Screen 242
4.15.2 A Virtual Trackball 243
4.15.3 Implementing the Trackball with Quaternions 245
Summary and Notes 247
Code Examples 247
Suggested Readings 248
Exercises 248
CHAPTER 5 VIEWING 253
5.1 Classical and Computer Viewing 253
5.1.1 Classical Viewing 255
5.1.2 Orthographic Projections 255
5.1.3 Axonometric Projections 256
5.1.4 Oblique Projections 258
5.1.5 Perspective Viewing 259
5.2 Viewing with a Computer 260
5.3 Positioning of the Camera 262
5.3.1 From the Object Frame to the Camera Frame 262
5.3.2 Two Viewing APIs 267
5.3.3 The Look-At Function 271
5.4 Parallel Projections 272
5.4.1 Orthogonal Projections 274
5.4.2 Parallel Viewing with WebGL 275
5.4.3 Projection Normalization 276
5.4.4 Orthogonal Projection Matrices 277
5.4.5 Oblique Projections 279
5.4.6 An Interactive Viewer 282
5.5 Perspective Projections 284
5.5.1 Simple Perspective Projections 285
5.6 Perspective Projections with WebGL 288
5.6.1 Perspective Functions 289
5.7 Perspective Projection Matrices 290
5.7.1 Perspective Normalization 291
5.7.2 WebGL Perspective Transformations 294
5.7.3 Perspective Example 296
5.8 Hidden-Surface Removal 296
5.8.1 Culling 298
5.9 Displaying Meshes 299
5.9.1 Displaying Meshes as Surfaces 302
5.9.2 Polygon Offset 304
5.9.3 Walking Through a Scene 305
5.10 Projections and Shadows 306
5.10.1 Projected Shadows 306
5.11 Shadow Maps 310
Summary and Notes 312
Code Examples 313
Suggested Readings 313
Exercises 313
CHAPTER 6 LIGHTING AND SHADING 317
6.1 Light and Matter 318
6.2 Light Sources 321
6.2.1 Color Sources 322
6.2.2 Ambient Light 322
6.2.3 Point Sourc