Advanced 3D Game Programming with DirectX* 10.0

Similar documents
CHAPTER 1 Graphics Systems and Models 3

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

Computer Graphics I Lecture 11

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

Computer Graphics: Programming, Problem Solving, and Visual Communication

Chapter Answers. Appendix A. Chapter 1. This appendix provides answers to all of the book s chapter review questions.

HE COMPLETE OPENGL PROGI FOR WINDOW WIND

CS GAME PROGRAMMING Question bank

Topics and things to know about them:

For each question, indicate whether the statement is true or false by circling T or F, respectively.

CS 130 Final. Fall 2015

CS451Real-time Rendering Pipeline

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Mathematical Tools in Computer Graphics with C# Implementations Table of Contents

Course Title: Computer Graphics Course no: CSC209

CMSC427 Final Practice v2 Fall 2017

Pipeline Operations. CS 4620 Lecture 14

Lahore University of Management Sciences. CS 452 Computer Graphics

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

Pipeline Operations. CS 4620 Lecture 10

The University of Calgary

Engineering Real- Time Applications with Wild Magic

Lahore University of Management Sciences. CS 452 Computer Graphics

Real-Time Rendering. Tomas Möller Eric Haines. A K Peters Natick, Massachusetts

Spring 2012 Final. CS184 - Foundations of Computer Graphics. University of California at Berkeley

Graphics Shaders. Theory and Practice. Second Edition. Mike Bailey. Steve Cunningham. CRC Press. Taylor&FnincIs Croup tootutor London New York

Computer Graphics CS 543 Lecture 13a Curves, Tesselation/Geometry Shaders & Level of Detail

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

Spring 2009 Prof. Hyesoon Kim

Ciril Bohak. - INTRODUCTION TO WEBGL

Shaders (some slides taken from David M. course)

The Rasterizer Stage. Texturing, Lighting, Testing and Blending

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Graphics for VEs. Ruth Aylett

Foundations of 3D Graphics Programming

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

GEOMETRIC TOOLS FOR COMPUTER GRAPHICS

Curves & Surfaces. Last Time? Progressive Meshes. Selective Refinement. Adjacency Data Structures. Mesh Simplification. Mesh Simplification

PROFESSIONAL. WebGL Programming DEVELOPING 3D GRAPHICS FOR THE WEB. Andreas Anyuru WILEY. John Wiley & Sons, Ltd.

Introduction to Visualization and Computer Graphics

Spring 2011 Prof. Hyesoon Kim

CS 354R: Computer Game Technology

Graphics and Interaction Rendering pipeline & object modelling

Game Mathematics. (12 Week Lesson Plan)

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley

Homework #2 and #3 Due Friday, October 12 th and Friday, October 19 th

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

Introduction to Computer Graphics

Graphics for VEs. Ruth Aylett

Deferred Rendering Due: Wednesday November 15 at 10pm

Real Time Rendering of Complex Height Maps Walking an infinite realistic landscape By: Jeffrey Riaboy Written 9/7/03

Lecture 2. Shaders, GLSL and GPGPU

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

OpenGL SUPERBIBLE. Fifth Edition. Comprehensive Tutorial and Reference. Richard S. Wright, Jr. Nicholas Haemel Graham Sellers Benjamin Lipchak

Computer Graphics. Instructor: Oren Kapah. Office Hours: T.B.A.

CS 464 Review. Review of Computer Graphics for Final Exam

Adaptive Point Cloud Rendering

Computer Animation. Algorithms and Techniques. z< MORGAN KAUFMANN PUBLISHERS. Rick Parent Ohio State University AN IMPRINT OF ELSEVIER SCIENCE

COMPUTER GRAPHICS, MULTIMEDIA AND ANIMATION, Second Edition (with CD-ROM) Malay K. Pakhira

QUESTION BANK 10CS65 : COMPUTER GRAPHICS AND VISUALIZATION

Problem Max. Points Total 80

Beginning Direct3D Game Programming: 1. The History of Direct3D Graphics

Rendering Objects. Need to transform all geometry then

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

Curves & Surfaces. MIT EECS 6.837, Durand and Cutler

Computer Graphics: Programming, Problem Solving, and Visual Communication

CMSC427: Computer Graphics Lecture Notes Last update: November 21, 2014

Mattan Erez. The University of Texas at Austin

Review. Stephen J. Guy

Programming Graphics Hardware

INFOGR Computer Graphics. Jacco Bikker - April-July Lecture 14: Grand Recap. Welcome!

Direct Rendering of Trimmed NURBS Surfaces

OXFORD ENGINEERING COLLEGE (NAAC Accredited with B Grade) DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING LIST OF QUESTIONS

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

Graphics Hardware. Graphics Processing Unit (GPU) is a Subsidiary hardware. With massively multi-threaded many-core. Dedicated to 2D and 3D graphics

GUERRILLA DEVELOP CONFERENCE JULY 07 BRIGHTON

Module 13C: Using The 3D Graphics APIs OpenGL ES

CS475/675: Computer Graphics End-Semester Examination (Solutions), Fall 2016

AGDC Per-Pixel Shading. Sim Dietrich

Chapter 2 A top-down approach - How to make shaded images?

CS 130 Exam I. Fall 2015

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

Shadow Techniques. Sim Dietrich NVIDIA Corporation

Chapter IV Fragment Processing and Output Merging. 3D Graphics for Game Programming

Volume Shadows Tutorial Nuclear / the Lab

3D Graphics and OpenGl. First Steps

TEXTURE MAPPING. DVA338 Computer Graphics Thomas Larsson, Afshin Ameri

MAXIS-mizing Darkspore*: A Case Study of Graphic Analysis and Optimizations in Maxis Deferred Renderer

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

Next-Generation Graphics on Larrabee. Tim Foley Intel Corp

Images from 3D Creative Magazine. 3D Modelling Systems

Final Exam CS 184: Foundations of Computer Graphics! page 1 of 12!

Computer Graphics Introduction. Taku Komura

CS 465 Program 4: Modeller

Transcription:

Advanced 3D Game Programming with DirectX* 10.0 Peter Walsh Wordware Publishing, Inc.

Acknowledgments Introduction xiii xv Chapter I Windows I A Word about Windows I Hungarian Notation 3 General Windows Concepts 4 Message Handling in Windows 5 Processing Messages 6 Hello World Windows Style 7 Explaining the Code II Registering the Application 13 Initializing the Window 13 WndProc The Message Pump 17 Manipulating Window Geometry 17 Important Window Messages 20 Class Encapsulation 23 COM: The Component Object Model 30 Conclusion 33 Chapter 2 Getting Started with DirectX 10 35 What Is DirectX? 35 Installation 36 Setting Up VC+ + 36 What Happened to DirectDraw? 39 Direct3D 40 2D Graphics 101 41 Textures 44 Complex Textures 46 Describing Textures 46 The ID3D10Texture2D Interface 50 Texture Operations 51 Modifying the Contents of Textures 51 Creating Textures 52 Implementing Direct3D with cgraphicslayer 53 Creating the Graphics Layer 58

Initializing Direct3D 58 Step I: Creating a Device and Swap Chain 58 Step 2: Creating a Render Target View 62 Step 3: Putting It All Together 62 Shutting Down Direct3D 64 Sample Application: Direct3D Sample 64 Conclusion 66 Chapter 3 Input and Sound 67 Directlnput 67 Devices 68 Receiving Device States 70 Cooperative Levels 73 Application Focus and Devices 73 The Directlnput Object 74 Implementing Directlnput with cinputlayer 74 Additions to capplication 87 Sound 87 The Essentials of Sound 88 DirectSound Concepts 89 DirectSound Buffers 90 Operations on Sound Buffers 93 Loading WAV Files 96 Implementing DirectSound with csoundlayer 103 Creating the DirectSound Object 103 Setting the Cooperative Level 104 Grabbing the Primary Buffer 105 The csound Class 108 Additions to capplication I 14 Application: DirectSound Sample 114 Conclusion 119 Chapter 4 3D Math Foundations 121 Points 121 The point3 Structure 124 Basic point3 Functions 125 Assign 125 Mag and MagSquared 126 Normalize 126 Dist 126 point3 Operators 127 Addition/Subtraction 127 Vector-Scalar Multiplication/Division 129 Vector Equality 130 Dot Product 131 vi

Cross Product 134 Polygons 135 Triangles 138 Strips and Fans 139 Planes 141 Defining Locality with Relation to a Plane 144 Back-face Culling 147 Clipping Lines 148 Clipping Polygons 149 Object Representations 153 Transformations 156 Matrices 156 The matrix4 Structure 166 Translation 168 Basic Rotations 169 Axis-Angle Rotation 170 The LookAt Matrix 172 Perspective Projection Matrix 174 Inverse of a Matrix 174 Collision Detection with Bounding Spheres 175 Lighting 178 Representing Color 178 Lighting Models 180 Specular Reflection 182 Light Types 183 Parallel Lights (or Directional Lights) 183 Point Lights 184 Spotlights 185 Shading Models 186 Lambert 186 Gouraud 186 Phong 187 BSP Trees 187 BSP Tree Theory 188 BSP Tree Construction 189 BSP Tree Algorithms 194 Sorted Polygon Ordering 194 Testing Locality of a Point 196 Testing Line Segments 196 BSP Tree Code 197 Wrapping It Up 207 Chapter 5 Artificial Intelligence 209 Starting Point 210 Locomotion 210

Steering Basic Algorithms 211 Chasing 211 Evading 211 Pattern-based Al 212 Steering Advanced Algorithms 213 Potential Functions 214 The Good 215 The Bad 215 Application: potentialfunc 216 Path Following 218 Groundwork 220 Graph Theory 221 Using Graphs to Find Shortest Paths 225 Application: Path Planner 227 Motivation 230 Nondeterministic Finite Automata (NFAs) 230 Genetic Algorithms 233 Rule-Based Al 234 Neural Networks 235 A Basic Neuron 236 Simple Neural Networks 238 Training Neural Networks 240 Using Neural Networks in Games 241 Application: NeuralNet 241 Extending the System 253 Chapter 6 Multiplayer Internet Networking with UDP 255 Terminology 255 Endianness 255 Network Models 257 Protocols 258 Packets 259 Implementation I: MTUDP 260 Design Considerations 260 Things to Watch Out For 260 Mutexes 263 Threads, Monitor, and the Problem of the try/throw/catch Construction 264 MTUDP: The Early Years 265 MTUDP::Startup() and MTUDP::Cleanup() 266 MTUDP::MTUDP() and MTUDP::~MTUDP() 267 MTUDP::StartListening() 267 MTUDP::StartSending() 268 MTUDP::ThreadProc() 269 MTUDP::ProcesslncomingData() 270 viii

MTUDP::GetReliableData() 271 Reliable Communications 271 cdatapacket 271 cqueueln 272 chost 274 MTUDP::ReliableSendTo() 278 cunreliablequeueln 284 chost::addackmessage()/chost::processlncomingacks().. 285 cnetclock 290 Implementation 2: Smooth Network Play 292 Geographie and Temporal Independence 293 Timing Is Everything 294 Pick and Choose 295 Prediction and Extrapolation 295 Conclusion 297 Chapter 7 Direct3D Fundamentals 299 Introduction to D3D 299 Getting Started with Direct3D 300 Step I: Creating the ID3DI ODevice and Swap Chain 300 Step 2: Creating a Depth/Stencil Buffer 302 Bringing It All Together 306 Step 3: Creating a Viewport 308 Step 4: Creating a Default Shader 309 Introduction to Shaders 309 Your First HLSL Shader 311 The Vertex Shader 312 The Pixel Shader 313 The Technique 313 Setting Up the Shader in Code 315 More about Depth Buffers 322 Stencil Buffers 325 Vertex Buffers 325 Lighting with Shaders 328 Application: D3D View 330 The.o3d Format 330 The cmodel Class 331 Chapter 8 Advanced 3D Techniques 341 Animation Using Hierarchical Objects 341 Forward Kinematics 343 Inverse Kinematics 346 Application: InvKim 349 Parametric Curves and Surfaces 355 Bezier Curves and Surfaces 355 ix

Bezier Concepts 355 The Math 358 Finding the Basis Matrix 360 Calculating Bezier Curves 361 Forward Differencing 363 The cfwddifflterator Class 365 Drawing Curves 367 Drawing Surfaces 367 Application: Teapot 369 B-Spline Curves 376 Application: BSpline 377 Subdivision Surfaces 379 Subdivision Essentials 380 Triangles vs. Quads 382 Interpolating vs. Approximating 382 Uniform vs. Non-Uniform 383 Stationary vs. Non-Stationary 383 Modified Butterfly Method Subdivision Scheme 383 Application: SubDiv 387 Progressive Meshes 399 Progressive Mesh Basics 401 Choosing Our Edges 402 An Edge Selection Algorithm 403 Quadric Error Metrics 403 Implementing a Progressive Mesh Renderer 405 Radiosity 406 Radiosity Foundations 407 Progressive Radiosity 410 The Form Factor 41 I Application: Radiosity 412 Conclusion 416 Chapter 9 Advanced Direct3D 417 Alpha Blending 417 The Alpha Blending Equation 418 A Note on Depth Ordering 419 Enabling Alpha Blending 419 Using Alpha Blending from C++ 419 Using Alpha Blending from Shaders 422 Texture Mapping 101 423 Fundamentals 424 Affine vs. Perspective Mapping 425 Texture Addressing 426 Wrap 426 Mirror and Mirror Once 427

Clamp 427 Border Color 428 Texture Wrapping 429 Texture Aliasing 430 MIP Maps 432 Filtering 433 Point Sampling 433 Linear Filtering 434 Anisotropic Filtering 435 Textures in Direct3D 436 Texture Loading 437 DDS Format 437 The ctexture Class 438 Activating Textures 440 Creating a Shader View 441 Adding Textures to the Shader 441 Sending the Texture to the Shader 442 Texture Sampling 442 Texture Mapping 202 443 Texture Arrays 443 Effects Using Multiple Textures 443 Light Maps (a.k.a. Dark Maps) 444 Environment Maps 446 Spherical Environment Maps 446 Cubic Environment Maps 450 Specular Maps 452 Detail Maps 452 Application: Detail 455 Glow Maps 463 Gloss Maps 463 Other Effects 464 Application: MultiTex 465 Using the Stencil Buffer 483 Overdraw Counter 485 Dissolves and Wipes 485 Conclusion 485 Chapter 10 Scene Management 487 The Scene Management Problem and Solutions 487 Quadtrees/Octrees 488 Portal Rendering 490 Portal Rendering Concepts 491 Exact Portal Rendering 497 Approximative Portal Rendering 498 Portal Effects 499 xi

Mirrors 499 Translocators and Non-Euclidean Movement 502 Portal Generation 503 Precalculated Portal Rendering (with PVS) 505 Advantages/Disadvantages 506 Implementation Details 506 Application: Mobots Attack! 507 Interobject Communication 507 Network Communication 511 Code Structure 514 Closing Thoughts 515 Appendix An STL Primer 517 Templates 517 Containers 518 Iterators 519 Functors 521 Index 523 xii