Mathematics for 3D Game Programming and Computer Graphics
Mathematics for
3D Game Programming &
Computer Graphics
Second Edition
Hardcover, 570 pages, 173 figures

This book illustrates the mathematics that a game programmer would need to develop a professional-quality 3D engine. Although the book is geared toward applications in game development, many of the topics appeal to general interests in 3D graphics. It starts at a fairly basic level in areas such as vector geometry and linear algebra, and then progresses to more advanced topics in 3D game programming such as illumination, visibility determination, and collision detection. Particular attention is given to derivations of key results, ensuring that the reader is not forced to endure gaps in the theory. The book assumes a working knowledge of trigonometry and calculus, but also includes sections that review the important tools used from these disciplines, such as trigonometric identities, differential equations, and Taylor series.

“Great coverage. Best book of its kind.”
—Mark Kilgard, Nvidia Corporation

Charles River Media Published by Charles River Media,
publisher of the Game Programming
Gems
series.
Amazon

Buy at Amazon.com

Average Customer Review: 5 stars

Second Edition Contents

Preface
What's New in the Second Edition
Contents Overview
Notational Conventions

Chapter 0: The Rendering Pipeline
0.1 Graphics Processors
0.2 Vertex Transformation
0.3 Rasterization and Fragment Operations

Chapter 1: Vectors
1.1 Vector Properties
1.2 Dot Products
1.3 Cross Products
1.4 Vector Spaces

Chapter 2: Matrices
2.1 Matrix Properties
2.2 Linear Systems
2.3 Matrix Inverses
2.4 Determinants
2.5 Eigenvalues and Eigenvectors
2.6 Diagonalization

Chapter 3: Transforms
3.1 Linear Transformations
    3.1.1 Orthogonal Matrices
    3.1.2 Handedness
3.2 Scaling Transforms
3.3 Rotation Transforms
    3.3.1 Rotation About an Arbitrary Axis
3.4 Homogeneous Coordinates
    3.4.1 Four-dimensional Transforms
    3.4.2 Points and Directions
    3.4.3 Geometrical Interpretation of the w-coordinate
3.5 Transforming Normal Vectors
3.6 Quaternions
    3.6.1 Quaternion Mathematics
    3.6.2 Rotations with Quaternions
    3.6.3 Spherical Linear Interpolation

Chapter 4: 3D Engine Geometry
4.1 Lines in 3D Space
    4.1.1 Distance Between a Point and a Line
    4.1.2 Distance Between Two Lines
4.2 Planes in 3D Space
    4.2.1 Intersection of a Line and a Plane
    4.2.2 Intersection of Three Planes
    4.2.3 Transforming Planes
4.3 The View Frustum
    4.3.1 Field of View
    4.3.2 Frustum Planes
4.4 Perspective Correct Interpolation
    4.4.1 Depth Interpolation
    4.4.2 Vertex Attribute Interpolation
4.5 Projections
    4.5.1 Perspective Projections
    4.5.2 Orthographic Projections
    4.5.3 Extracting Frustum Planes

Chapter 5: Ray Tracing
5.1 Root Finding
    5.1.1 Quadratic Polynomials
    5.1.2 Cubic Polynomials
    5.1.3 Quartic Polynomials
    5.1.4 Newton’s Method
    5.1.5 Refinement of Reciprocals and Square Roots
5.2 Surface Intersections
    5.2.1 Intersection of a Ray and a Triangle
    5.2.2 Intersection of a Ray and a Box
    5.2.3 Intersection of a Ray and a Sphere
    5.2.4 Intersection of a Ray and a Cylinder
    5.2.5 Intersection of a Ray and a Torus
5.3 Normal Vector Calculation
5.4 Reflection and Refraction Vectors
    5.4.1 Reflection Vector Calculation
    5.4.2 Refraction Vector Calculation

Chapter 6: Illumination
6.1 RGB Color
6.2 Light Sources
    6.2.1 Ambient Light
    6.2.2 Directional Light Sources
    6.2.3 Point Light Sources
    6.2.4 Spot Light Sources
6.3 Diffuse Lighting
6.4 Texture Mapping
    6.4.1 Standard Texture Maps
    6.4.2 Projective Texture Maps
    6.4.3 Cube Texture Maps
    6.4.4 Filtering and Mipmaps
6.5 Specular Lighting
6.6 Emission
6.7 Shading
    6.7.1 Calculating Normal Vectors
    6.7.2 Gouraud Shading
    6.7.3 Phong Shading
6.8 Bump Mapping
    6.8.1 Bump Map Construction
    6.8.2 Tangent Space
    6.8.3 Calculating Tangent Vectors
    6.8.4 Implementation
6.9 A Physical Reflection Model
    6.9.1 Bidirectional Reflectance Distribution Functions
    6.9.2 Cook-Torrance Illumination
    6.9.3 The Fresnel Factor
    6.9.4 The Microfacet Distribution Function
    6.9.5 The Geometrical Attenuation Factor
    6.9.6 Implementation

Chapter 7: Visibility Determination
7.1 Bounding Volume Construction
    7.1.1 Principal Component Analysis
    7.1.2 Bounding Box Construction
    7.1.3 Bounding Sphere Construction
    7.1.4 Bounding Ellipsoid Construction
    7.1.5 Bounding Cylinder Construction
7.2 Bounding Volume Tests
    7.2.1 Bounding Sphere Test
    7.2.2 Bounding Ellipsoid Test
    7.2.3 Bounding Cylinder Test
    7.2.4 Bounding Box Test
7.3 Spatial Partitioning
    7.3.1 Octrees
    7.3.2 Binary Space Partitioning Trees
7.4 Portal Systems
    7.4.1 Portal Clipping
    7.4.2 Reduced View Frustums

Chapter 8: Collision Detection
8.1 Plane Collisions
    8.1.1 Collision of a Sphere and a Plane
    8.1.2 Collision of a Box and a Plane
    8.1.3 Spatial Partitioning
8.2 General Sphere Collisions
8.3 Sliding
8.4 Collision of Two Spheres

Chapter 9: Polygonal Techniques
9.1 Depth Value Offset
    9.1.1 Projection Matrix Modification
    9.1.2 Offset Value Selection
    9.1.3 Implementation
9.2 Decal Application
    9.2.1 Decal Mesh Construction
    9.2.2 Polygon Clipping
9.3 Billboarding
    9.3.1 Unconstrained Quads
    9.3.2 Constrained Quads
    9.3.3 Polyline Quadstrips
9.4 Polygon Reduction
9.5 T-Junction Elimination
9.6 Triangulation

Chapter 10: Shadows
10.1 Algorithm Overview
10.2 Infinite View Frustums
10.3 Silhouette Determination
10.4 Shadow Volume Construction
10.5 Determining Cap Necessity
10.6 Rendering Shadow Volumes
10.7 Scissor Optimization

Chapter 11: Linear Physics
11.1 Position Functions
11.2 Second-Order Differential Equations
    11.2.1 Homogeneous Equations
    11.2.2 Nonhomogeneous Equations
    11.2.3 Initial Conditions
11.3 Projectile Motion
11.4 Resisted Motion
11.5 Friction

Chapter 12: Rotational Physics
12.1 Rotating Environments
    12.1.1 Angular Velocity
    12.1.2 The Centrifugal Force
    12.1.3 The Coriolis Force
12.2 Rigid Body Motion
    12.2.1 Center of Mass
    12.2.2 Angular Momentum and Torque
    12.2.3 The Inertia Tensor
    12.2.4 Principal Axes of Inertia
12.3 Oscillatory Motion
    12.3.1 Spring Motion
    12.3.2 Pendulum Motion

Chapter 13: Fluid Simulation
13.1 The Wave Equation
13.2 Approximating Derivatives
13.3 Evaluating Surface Displacement
13.4 Implementation

Chapter 14: Numerical Methods
14.1 Linear Systems
    14.1.1 Triangular Systems
    14.1.2 Gaussian Elimination
    14.1.3 LU Decomposition
    14.1.4 Error Reduction
    14.1.5 Tridiagonal Systems
14.2 Eigenvalues and Eigenvectors
14.3 Ordinary Differential Equations
    14.3.1 Euler’s Method
    14.3.2 Taylor Series Method
    14.3.3 Runge-Kutta Method
    14.3.4 Higher-Order Differential Equations

Chapter 15: Curves and Surfaces
15.1 Cubic Curves
15.2 Hermite Curves
15.3 Bézier Curves
    15.3.1 Cubic Bézier Curves
    15.3.2 Bézier Curve Truncation
    15.3.3 The de Casteljau Algorithm
15.4 Catmull-Rom Splines
15.5 Cubic Splines
15.6 B-Splines
    15.6.1 Uniform B-Splines
    15.6.2 B-Spline Globalization
    15.6.3 Nonuniform B-Splines
    15.6.4 NURBS
15.7 Bicubic Surfaces
15.8 Curvature and Torsion

Appendix A: Complex Numbers
A.1 Definition
A.2 Addition and Multiplication
A.3 Conjugates and Inverses
A.4 The Euler Formula

Appendix B: Trigonometry Reference
B.1 Function Definitions
B.2 Symmetry and Phase Shifts
B.3 Pythagorean Identities
B.4 Exponential Identities
B.5 Inverse Functions
B.6 Laws of Sines and Cosines

Appendix C: Coordinate Systems
C.1 Cartesian Coordinates
C.2 Cylindrical Coordinates
C.3 Spherical Coordinates
C.4 Generalized Coordinates

Appendix D: Taylor Series
D.1 Derivation
D.2 Power Series
D.3 The Euler Formula

Appendix E: Answers to Exercises

Bibliography

Index

Source Code

Listing 6.1
Listing 6.2
Listing 6.3
Listing 6.4
Listing 9.1
Listing 9.2
Listing 10.1
Listing 10.2
Listing 10.3
Listing 10.4
Listing 13.1
Listing 14.1
Listing 14.2
Listing 14.3
Listing 14.4
Listing 14.5
Listing 14.6

Errata