Computer Graphics Seminar
MTAT.03.305
Fall 2021
Raimond Tunnel
Computer Graphics
Math
Math
Skills for Computer Graphics
GLuint vaoHandle;
glGenVertexArrays(1, &vaoHandle);
glBindVertexArray(vaoHandle);
The Standard Graphics Pipeline
Data
Vertex Shader
Culling & Clipping
Rasterization
Fragment Shader
Visibility tests & Blending
Define geometry and transformations
Apply transformations on the geometry
Point
(x, y, z, w), w ≠ 0
Line (segment)
Line (segment)
Line (segment)
B
A
B
A
Triangle
Triangle
Why Triangles?
Why Triangles?
Examples of Polygons
A
B
C
D
E
F
G
I
J
K
L
C
C
B
B
C
A
A
B
D
D
E
F
H
A
OpenGL <3.1 primitives
OpenGL Programming Guide 7th edition, p49
After OpenGL 3.1
OpenGL Programming Guide 8th edition, p89-90
It’s all just points, lines and triangles!
It’s all just points, lines and triangles!
World’s Origin (0, 0, 0)
Transformations
Homogeneous coordinates are needed here...
...and for the perspective projection.
Transformations
Column-major format
Transformations
Column-major format
Linear function, which increases the first coordinate two times.
Transformations
Column-major format
Same function as a matrix
Transformations
DRAM
ALU
ALU
ALU
...
Control
Cache
ALU
ALU
ALU
ALU
...
Control
Cache
ALU
ALU
ALU
ALU
...
Control
Cache
ALU
ALU
ALU
ALU
...
Control
Cache
ALU
ALU
ALU
ALU
...
Control
Cache
ALU
ALU
ALU
ALU
...
Control
Cache
ALU
ALU
ALU
ALU
...
Control
Cache
ALU
Vertex shader code
Transformations
We will not use homogeneous coordinates at the moment, but they will be back...
Linear Transformation
Scale
Scaling
Scaling
Scaling
– x-axis scale factor
– y-axis scale factor
– z-axis scale factor
What happens to out triangles when an odd number of factors are negative?
Linear Transformation
Shear
Shearing
Shearing
Linear Transformation
Rotation
Rotation
Did you notice that the columns of the transformation matrix show the coordinates of the new basis vectors?
Rotation
Rotation
Rotation II
Rotation II
This is easily done via scalar projection.
Rotation II
Rotation II
Formula is simpler as we only need to rotate the first basis vector.
Rotation II
Rotation II
Rotation III
Rotation III
Rotation III
Rotation III
Rotation III
Rotation III
Back to the Main Track
Do we have everything now?
What if we have an object not centered in the origin?
Affine Transformation
Translation
Translation
Objects
The 1D World
Translation
Translation
Translation
Translation
tan(45°) = 1
tan(63.4°) = 2
Translation
1D
2D
3D
Transformations
Augmented transformation matrix
Linear transformations
Translation column
Used for perspective projection
Multiple Transformations
Multiple Transformations
Our initial geometry defined by vertices: (-1, -1), (1, -1), (1, 1), (-1, 1)
Multiple Transformations
Multiple Transformations
Multiple Transformations
Multiple Transformations
1. We first rotated.
2. Then translated.
Multiple Transformations
Now You Know
Data
Vertex Shader
Culling & Clipping
Rasterization
Fragment Shader
Visibility tests & Blending
vs
Next Time...
Data
Vertex Shader
Culling & Clipping
Rasterization
Fragment Shader
Visibility tests & Blending
vs