Foundations of 3D Computer Graphics
Steven J. Gortler
July 13, 2012
Foundations of 3D Computer Graphics
S.J. Gortler
MIT Press, 2012
2
To A.L.G., F.J.G, and O.S.G.
Foundations of 3D Computer Graphics
S.J. Gortler
MIT Press, 2012
ii
Contents
Preface
I Getting Started
1 Introduction
1.1 OpenGL . .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
2 Linear
2.1 Geometric Data Types
. .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
2.2 Vectors, Coordinate Vectors, and Bases
. . . .
. . . .
. . . .
. . . .
2.3 Linear Transformations and 3 by 3 Matrices . .
. . . .
. . . .
. . . .
2.4 Extra Structure . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
2.5 Rotations
.
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
2.6 Scales . . .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
3 Affine
3.1 Points and Frames .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
3.2 Affine transformations and Four by Four Matrices . . .
. . . .
. . . .
3.3 Applying Linear Transformations to Points
. .
. . . .
. . . .
. . . .
3.4 Translations . . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
3.5 Putting Them Together
. .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
3.6 Normals . .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
4 Respect
iii
ix
1
3
3
9
9
11
12
15
16
19
21
21
22
24
25
25
26
29
CONTENTS
CONTENTS
4.1 The Frame Is Important .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
4.2 Multiple Transformations . . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
5 Frames In Graphics
5.1 World, Object and Eye Frames .
. . .
. . . .
. . . .
. . . .
. . .
. .
5.2 Moving Things Around .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
5.3 Scales . .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
5.4 Hierarchy . . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
6 Hello World 3D
6.1 Coordinates and Matrices . . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
6.2 Drawing a Shape . . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
6.3 The Vertex Shader . . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
6.4 What Happens Next . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
6.5 Placing and Moving With Matrices . .
. . . .
. . . .
. . . .
. . .
. .
II Rotations and Interpolation
7 Quaternions (a bit technical)
7.1
Interpolation . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
7.2 The Representation . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
7.3 Operations . . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
7.4 Power
. .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
7.5 Code . . .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
7.6 Putting Back the Translations . .
. . .
. . . .
. . . .
. . . .
. . .
. .
8 Balls: Track and Arc
8.1 The Interfaces . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
8.2 Properties . . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
8.3
Implementation .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
9 Smooth Interpolation
9.1 Cubic Bezier Functions .
. . . .
. . .
. . . .
. . . .
. . . .
. . .
. .
Foundations of 3D Computer Graphics
S.J. Gortler
MIT Press, 2012
iv
29
31
35
35
37
40
40
45
45
46
51
52
53
57
59
59
63
64
65
68
68
73
73
74
75
77
78
CONTENTS
CONTENTS
9.2 Catmull-Rom Splines . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
9.3 Quaternion Splining . . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
9.4 Other Splines . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
9.5 Curves in Space ......
. . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
III Cameras and Rasterization
10 Projection
10.1 Pinhole Camera . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
10.2 Basic Mathematical Model
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
10.3 Variations .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
10.4 Context
. .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
11 Depth
11.1 Visibility .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
11.2 Basic Mathematical Model
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
11.3 Near And Far
. . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
11.4 Code .
. . .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
12 From Vertex to Pixel
12.1 Clipping . .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
12.2 Backface Culling .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
12.3 Viewport . .
. . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
12.4 Rasterization . . .
. . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
13 Varying Variables (Tricky)
13.1 Motivating The Problem .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
13.2 Rational Linear Interpolation . . .
. . .
. . . .
. . . .
. . . .
. . . .
IV Pixels and Such
14 Materials
14.1 Basic Assumptions . . . .
. . . .
. . .
. . . .
. . . .
. . . .
. . . .
Foundations of 3D Computer Graphics
S.J. Gortler
MIT Press, 2012
v
80
81
82
83
87
89
89
90
92
97
101
101
102
105
107
109
109
112
113
116
119
119
120
125
127
127