Jim x. ehen With contributions by Chunyang Chen, Nanyang Yu, Yanlin Luo, Yanling Liu and Zhigeng Pan

Guide to Graphics Tools

Second edition

~ Springer Contents

Pre~ace ------v

Chapter 1 Objects and Models

1.1 Graphics Models and Libraries ------1 1.2 OpenGL Programming 2

Understanding Example 1.1 3 1.3 Frame Buffer, Scan-conversion, and Clipping ----- 5 Scan-converting Lines 6 Scan-converting Circles and Other Curves 11 Scan-converting Triangles and Polygons 11 Scan-converting Characters 16 Clipping 16 1.4 Attributes and Antialiasing ------17 Area Sampling 17 Antialiasing a Line with Weighted Area Sampling 18 1.5 Double-bl{tferingfor Animation - 21 1.6 Review Questions ------26 X Contents

1.7 Programming Assignments ------27

Chapter 2 Transformation and Viewing

2.1 Geometrie Transformation ----- 29

2.2 2D Transformation ------30 20 Translation 30 20 Rotation 31 20 Scaling 32 Composition of2D Transformations 33 2.3 3D Transformation and Hidden-surjaee Removal -- - 38

3D Translation, Rotation, and Scaling 38 Transfonnation in OpenGL 40 Hidden-surface Remova! 45 Collision Oetection 46 30 Models: Cone, Cylinder, and Sphere 46 Composition of30 Transfonnations 51 2.4 Viewing ------56

20 Viewing 56 30 Viewing 57 30 Clipping Against a Cube 61 Clipping Against an Arbitrary Plane 62 An Example ofViewing in OpenGL 62 2.5 Review Questions 65 2.6 Programming Assignments 67

Chapter 3 Color andLighting

3.1 Color ------69 RGß Mode and Index Mode 70 Eye Characteristics and Gamma Correction 71 Contents xi

3.2 Color Interpolation --- - 72 3.3 Lighting - - 74

Lighting Components 74 OpenGL Lighting Model 79 3.4 Visible-Surface Shading ------85

Back-Face Culling 85 Polygon Shading Models 87 and Radiosity 90

3.5 Review Questions - 96

3.6 Programming Assignments 100

Chapter 4 Blending and Texture Mapping

4.1 Blending ------101 OpenGL Blending Factors 102 Transparency and Hidden-Surface Removal 103 Antialiasing 105 Fog 105 4.2 Images ------107 4.3 Texture Mapping ------108

Pixel and Texel Relations 108 Texture Objects 112 Texture Coordinates 113 Levels ofDetail in Texture Mapping 116 4.4 Advanced Texture Mapping ------117

Bump Mapping 117 Light Mapping 119 Environment Mapping 120 Automatie Texture Coordinates 122 Displacement Mapping 123 4.5 RevieYv Questions ----­ 124 4.6 Programming Assignments 125 xii Contents

Chapter 5 OpenGL Programming in Java: JOGL

5.1 Introduction ------127 5.2 Setting Up Working Environment ------128 5.3 Drawing a Point --- - 132 5.4 Drawing Randomly Generated Points --- - 134 5.5 Building an Executable JAR File ------136 5.6 Review Questions ------­ ------138 5.7 Programming Assignments ------138

Chapter 6 Curved Models

6.1 Introduction ------141 6.2 Quadratic Surfaces ------142 Sphere 142 Ellipsoid 143 Cone 144 Cylinder 144 Texture Mapping on GLU Models 145 6.3 Tori, Po(vhedra, and Teapots in GLUT ------148

Tori 148 Polyhedra 148 Teapots 149 6.4 Cubic Curves - -152 Continuity Conditions 153 Hennite Curves 155 Bezier Curves 158 Natural Splines 163 B-splines 164 Non-unifonn B-splines 167 NURBS 168 Contents xiii

6.5 Bi-cubic Swlaces ------169 Hennite Surfaces 169 Bezier Surfaces 171 B-spline Surfaces 175 6.6 Review Questions 175 6.7 Programming Assignments 176

Chapter 7 Vertex Shading, Pixel Shading, and Parallel Processing

7.1 1ntrodllction 179 7.2 Programmable Pipelines 180 7.3 GLSL, Cg, and HLSL 182 Cg Basics 182 AVertex Program 183 Transfonnation and Viewing 186 A Fragment Program 188 7.4 Parallel Processing and Cuda 192 7.5 Introdllction 194 7.6 Per-Vertex Lighting 194

Vertex and Light Source Transfonnation 195 Vertex Nonnal Transfonnation 196 OpenGL Lighting Model 197 7.7 Per-Fragment Lighting 206 7.8 Per-Fragment Texture Mapping ----- 211

Texture Coordinates 211 Texture Objects 212 Texture and Lighting Blending 213 7.9 Per-Fragment Bump Mapping ------215

Bump Map Texture Coordinates 215 Bump Map Object 216 Nonnal Calculations 217 xiv Contents

Fragment Lighting Calculations 218 7.10 Review Questions ---- - 221 7.11 Programming Assignments --- - 221

Chapter 8 Programming in Java3D

8.1 1ntroduction --- - 223 8.2 Scene Graph --- - 223 Setting Up Working Environment 225 Drawing a ColorCube Object 228 8.3 The SimpleUniverse - - 229 8.4 Transformation - - 232 8.5 Multiple Scene Graph Branches ------233 8.6 Animation ------236 8.7 Primitives ------240 8.8 Appearance ------244 8.9 Texture Mapping - - 247 8.10 Files and Loaders - - 249 8.11 Summary ------251 8.12 Review Questions ------251

8.13 Programming Assignments ------251

Chapter 9 OpenGL Shading Language

9.1 Introduction ------253 9.2 Anatomy oIa GLSL Program - - 253 9.3 GLSL Basics - - 255 Contents XV

9.4 Compiling 256 9.5 Linking Shaders 257 9.6 ExeclIting Shaders 259 9.7 veuying Variables 260 9.8 Un!form Variables 261 9.9 Using TextlIres 263 9.10 Lighting 264 9.11 Advanced Shaders Techniqlles 267

Post Processing 267 Depth-based Texture Processing 270 Fog 274

Chapter 10 Direct3D Shader Programming

10.1 Introdllction ------283

Setting Up Working Environment 284 An Example Framework 285 10.2 Rendering Primitives ------288

Creating Primitives 289 Animation Using Shaders 294 10.3 Pixel Lighting ------298 Creating Depth Stencil View 299 Creating Input Layout 300 Creating Cube Geometry 301 Interfaces for Accessing Variables In Effect Object 303 Rendering the Scene 304 Lighting in Shaders 307 Directional Pixel Lighting 308 Directional Pixel Light with Specular 309 Point Pixel Lighting 310 Point Pixel Lighting with Specular 312 Spot Pixel Lighting 312 xvi Contents

Hemisphere Pixel Lighting 313 10.4 Texture Mapping ------314 Creating Views 314 Creating Input Layout 316 Render-to-texture Funetion 317 Texture Mapping in Shaders 319 Simple Texture Mapping 320 Multi-Texture Mapping 321 Texture and Lighting 321 Texture Animation 322 Light Mapping 323 Bump Mapping 323 10.5 Simu1ating Fixed Functiona1 Fog ------325 Linear Fog 325 Exponential Fog 326 Square Exponential Fog 326 10.6 Cube Mapping ------326 Creating Geometry 327 Creating Resourees far Cube Mapping 327 Rendering the Seene 329 Rendering to Cube Map in Shaders 330 Cube Mapping in Shaders 331 Cube Mapping with Refraetion 332 Cube mapping with Separated Refraction 334

Chapter 11 Advanced Topics

11.1 Introduction -- 335 11.2 Graphics Libraries -- 336 11.3 Visualization -- 336 Interaetive Visualization and Computational Steering 336 Data Visualization: Dimensions and Data Types 337 Parallel Coordinates 339 11.4 Modeling and Rendering ------340 Contents xvii

Curves and Surfaces 341 Sweep Representations 341 Ins tances 341 Constructive Solid Geometry 341 Procedural Models 342 Fractals 342 Partic1e systems 342 Image-based Modeling and Rendering 344 11.5 Animation andSimulation -- - 345 Physics-Based Modeling and Simulation: Triangular Polyhedra 346 Real-time Animation and Simulation: a Spider Web 348 The Efficiency of Modeling and Simulation 351 11.6 Virtual Reality 352 11.7 Graphics on the Internet: Web3D 354 Virtual Reality Modeling Language (VRML) 354 Java3D 354

Chapter 12 Low- Graphics Libraries

12.1 Introduction 355 12.2 OpenGL and Mesa ------355 12.3 Direct3D/DirectX ------356 12.4 PHIGS and GKS-3D ------356 12.5 QuickDraw3D andXGL ------356

Chapter 13 Visualization

13.1 Introduction 357 13.2 Multipurpose Visualization Tools 358 13.3 Volume Rendering 358 xviii Contents

13.4 Vector Field and Fluid Flow ------359 13.5 Large Data Sets ------359

Chapter 14 Modeling and Rendering

14.1 Modeling ------361 14.2 Rendering ------361 14.3 Multipurpose Tools: Modeling, Rendering, and Animation 362

Chapter 15 Animation and Simulation

15.1 Animation ------365 15.2 Simulation ------366

Chapter 16 Virtual Reality

16.1 Virtual Reality ------367

Chapter 17 Web3D Tools and Networked Environment

17.1 Web3D ------369 17.2 Distributed Interactive Simulation ------369 17.3 Synchronization in a DIS ------370

The Clock Reckoning - Wall Clock Synchronization 371 Contents xix

Chapter 18 3D File Formats

18.1 Introduction 373 18.2 3D File Formats 374 18.3 3D Programming Tool Libraries 375 18.4 3D Authoring Tools 375 18.5 3D File Format Converters 375 Built-In and Plug-In VRML Exporters 376 Independent 3D File Format Converters 376

AppendixA Basic Mathematics for 3D 377

A.1 Vector Operations ------377 The Length and Direction 377 Addition and Subtraction 378 Dot Product and Cross Product 379 Reflection 380 A.2 Matrix Operations ------381 Transpose 381 Addition and Subtraction 382 Multiplications 382 Square Matrix and Inverse 384

AppendixB Tools 387

B.1 Graphics Tools Listed by Categories ------387 Low-level Graphics Libraries 387 Visualization Tools 388 Modeling Tools 389 XX Contents

Rendering Tools 393 Animation Tools 395 Simulation Tools 397 Virtual Reality Tools 398 Web 3D Tools 399 3D File Format Converters 400 8.2 Alphabetical Listing andDescription ofGraphics Tools 401 20-sim 401 3DCANVAS 401 3D Choreographer 402 3D Grapher 402 3D INSTANT WEBSITE 403 3DSOM Pro 403 3D STUDIO MAX 404 3D Studio VIZ 404 3D Text Maker 405 3D Win 405 3DFieid 406 3dom 406 3DVIEWNIX 407 3D World Studio 407 AC3D 408 AccuRender 409 AccuTrans 3D 409 ACIS 3D Toolkits 410 ActiveWorlds 410 Active Dimensions 3 411 ADG Panorama Tools 411 Adobe Illustrator CS 412 AIR (Animation and Image Rendering) 412 Aladdin 4D 413 AliasStudio 414 Alice 414 3D 415 AMIRA 415 Amorphium 416 Analyze 416 Anark 417 Anfy 3D 417 ANIM80R 418 Animation Master 419 ANIMATION STAND 419 Antics 420 Contents xxi

Art of Illusion 420 Astex Viewer 42] AutoCAD 42] AVS5 422 bCAD 423 Behemot Graphics Editor 423 Biturn 424 BIaze 3D Studio 424 425 Blueberry 3D 425 Body 426 Brand Worlds TooIs 426 Breeze Designer 427 BRL-CAD 427 3D 428 Calimax 429 429 Cheetah3D 430 430 ClayWorks 43] Coin3D 43] Cosmo Worlds 432 CrystaI3D-Impact!Pro 432 CrystalGraphics PowerPlugs 433 Crystal Space 433 Cult3D 434 CyberMotion 3D-Designer 434 435 Deep Exploration Standard & CAD Edition 435 Deep Creator 436 Deep Paint 3D 437 DeieD 3D Editor 437 DesignCAD 3000 438 DESIGN WORKSHOP PRO 438 DICE 439 DigiCad 3D 439 Director 8.5 Shockwave Studio 440 DirectX (Dirct3D) 440 DIVE (Distributed Interactive Virtual Environment) 44] DIVERSE 44] DMesh 442 Draw3D 443 Effect3D 443 EIAS 444 ElectricImage Animation System 444 xxii Contents

Endorphin 445 EnLiten 445 Ensight 446 EON STUDIO 447 Equinox-3D 447 Evolver 448 eZ- 448 Facial Studio 449 FAST (Flow Analysis Software Toolkit) 449 FERRET 450 Fieldview 450 Finalrender 451 FORM-Z 451 Freeworld3D 452 Gamebryo 452 GameSpace 453 Genesis3D 453 GenTools 454 Geomagic Studio 455 Geomview 455 GKS-3D 456 GL Studio 456 Glu3D 457 GL4Java (OPENGL FOR JAVA) 457 GNUPlot 458 GRAFITTI 459 Grome Modeler 459 GURU 3D-CONVERTER 460 460 461 HyperFun 461 iClone 462 ICA (Internet Character Animator) 462 IDL 463 Igor Pro 464 Image Modeler 464 iModeller 3D 465 Indigo (Renderer) 465 INSPIRE 466 Insta3D Pro 467 ISA (INTERNET SCENE ASSEMBLER) 467 ISB (INTERNET SPACE BUILDER) 468 IRIS Explorer 468 iSpace 469 JAVA 3D 469 Contents xxiii

Jet 3D 470 JIG 471 Jmol 471 JogI (Java OpenGL) 472 Jsprited 472 JustCad 473 K-3D 473 Khoros 474 KiNG 474 Kyra Sprite Engine 475 LandForm 475 Lattiee Teehnology Produets 476 LIFESTUDJO:HEAD 476 LightRay3D 477 Lightseape 477 LightWave 3D 478 Lightworks 479 Lipserviee 479 LithTeeh Development System 480 LS-DYNA 480 LSS Vista 481 LumeTools 481 MapRender3D 482 Massive 482 Materialize 3D! 483 Mathematiea 483 MATLAB 484 485 Maya 485 MentalRay 486 Merlin 3D 486 Mesa 487 Meshwork 487 Studio 488 Metris Systems 488 MieroStation TriForma 489 MilkShape 3D 490 MindsEye 490 Mirai 491 Misfit Model 3D 491 Model Magie 3D 492 492 Mojoworld 493 Moray 493 MotionBuilder 494 xxiv Contents

Mova Contour 494 MultiGen Creator PRO 495 Mvox 495 Natural Motion 496 NATURAL SCENE DESIGNER 497 Navigram Planner 497 NCAR Command Language and NCAR Graphics 498 Netimmerse 498 Now3D 499 NuGraf 499 OpenDX (Open Data Explorer) 500 OpenFX 500 OpenGL 501 OPENGL FOR JAVA (GL4Java) 501 OpenGL VoLumizer 502 OpenGVS 502 Open Inventor 503 OpenWorlds 504 ParticleIllusion 504 PeoplePutty 505 PertKit 505 PhotoModeler 506 Pixel 3D 507 PLOT3D 507 Pointstream 3DImageSuite 508 PolyTrans 508 509 POVLAB 509 POV-Ray (Persistence ofVision Raytracer) 510 Pro-Engineer (PROfE) 510 ProPak 3D 511 Punch! Software 511 pV3 (PARALLEL VISUALJ) 512 PV-WAVE 512 Quartz Composer 513 Quick3D 514 QuickDraw3D 514 515 Rasmol 515 Rayshade 516 Realflow 516 Realimation 517 Realsoft 3D 518 RenderDrive 518 RenderMan 519 Contents XXV

RenderPark 519 Rhino 520 RXscene 520 Satellite Tool Kit (STK) 521 SCED (Constraint Based Scene Design) 521 Shade 522 ShapeCapture 523 Shave and a Haircut 523 Shout3D 524 524 Simi MotionCapture3D 525 SlMUL8 525 SketchUp 526 526 SOLlDS++ 527 SolidThinking 527 SolidWorks 528 SPECTER 529 STAR-CD 529 StereoPOV 530 Strata Live 3D 530 Summit 3D 531 Superficie 531 - 3D Vector Graphics Tool 532 SyFlex 532 Tao Framework 533 Tecplot 533 T.Ed 534 534 TerraTools 535 Texture Lab: Tiling Tools 536 The 3D Gamemaker 536 Tile Studio 537 TopSolid 537 TrueSpace 538 Tucan Series 538 TurboCAD 539 Ulead COOL 3D 539 Ultimate Unwrap 3D 540 Unity 540 541 UVMapper Professional 541 VARKON 542 Vecta 3D MAX 543 VectorWorks 543 xxvi Contents

VEGA 544 VFleet 544 View3D 545 Virtools Dev 545 Vis5D+ 546 VisAD 546 VisiQuest 547 VISVIVA AUTHORING STUDIO 548 Visual3 548 Visual Nature Studio 549 VMD 549 VolVis 550 VoxBlast 551 VP-Sculpt 551 VPYTHON 552 Vray 552 VREK (MindRender Virtual Reality Explore Kit) 553 VRML 553 VTK - the Visualization ToolKit 554 Vue 554 WebMol 555 WebSphere Studio 555 556 WorldBuilder 556 World Construction Set 557 WorldToolKit 558 World Up 558 Xara3D 559 XGL 559 XNA 560 YafRay 560 ZBrush 561

Index ------563