Transforms & Texture Mapping
Computer Graphics and Imaging
UC Berkeley CS 184/284A
Discussion 03
Worksheet link!
https://tinyurl.com/2wmh4ewe
✨Icebreaker!✨
celebrationFavorite Movie?
Share with your neighbors!
Week 3 Announcements
alarm
Homework 0
Due on Thursday (9/10)!
assignment
Homework 1
Will be released on Wednesday (9/15)!
groups
Project Partners
Homeworks can be completed with a partner.
Search on Ed:�"Find a Project Partner"
Disc 2 Review!
Review Discussion
1. Rasterization
2. Aliasing
3. Nyquist Theorem
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
Disc 2 Leftovers!
3. Nyquist Theorem
Nyquist frequency
The Nyquist frequency is half of the sampling frequency of your device.
Ex: If your camera has a frame rate of 24 (runs at 24 Hz), the Nyquist frequency is 12 Hz.
Nyquist theorem
There is no aliasing from frequencies in the signal that are less than the Nyquist frequency.
Ex (previous slide): Your camera can capture signals with frequency less than 12 Hz without aliasing.
11
12
1/16
1/32
1/64
1/128
1/256
> 2 * 1/16 = ⅛
> 1/16
> 1/32
> 1/64
> 1/128
Hint:
In 1 rotation, a wheel with n spokes shows the same ”image” n times, so if that rotation took 1 second, it would have a frequency of n hz
Hint:
In 1 rotation, a wheel with n spokes shows the same ”image” n times, so if that rotation took 1 second, it would have a frequency of n hz
Wheel A: 4 * 6 = 24 Hz → frame rate: 48
Wheel B: 6 * 5 = 30 Hz → frame rate: 60
4. Ashley’s Helicopter
What’s the Nyquist frequency of Ashley’s video camera?
The Nyquist frequency of Ashley’s video camera is 64 frames per second
So long as the helicopter rotates at less than 64 cycles per second, Ashley will not see any aliasing. The helicopter has 8 blades, so rotating at 8 rotations/second achieves the Nyquist frequency of 64 cycles per second.
Moving onto this week's topic!
Transformation Matrices
1. Basic Transforms
Transformations
Isometric - transformation that preserves size, shape, and distance
Which transformation method holds this property?
22
23
[Review] Matrix Vector Manipulation
Matrix-Vector Multiplication
| cosθ | -sinθ | |
| sinθ | cosθ | |
| 1 | |
| 0 | |
=
| | |
| | |
Matrix-Vector Multiplication
| cosθ | -sinθ | |
| sinθ | cosθ | |
| 1 | |
| 0 | |
=
| cosθ | |
| | |
Matrix-Vector Multiplication
| cosθ | -sinθ | |
| sinθ | cosθ | |
| 1 | |
| 0 | |
=
| cosθ | |
| sinθ | |
Matrix-Vector Multiplication
| cosθ | -sinθ | |
| sinθ | cosθ | |
| 1 | |
| 0 | |
=
| cosθ | |
| sinθ | |
| cosθ | -sinθ | |
| sinθ | cosθ | |
| 0 | |
| 1 | |
=
| -sinθ | |
| | |
Matrix-Vector Multiplication
| cosθ | -sinθ | |
| sinθ | cosθ | |
| 1 | |
| 0 | |
=
| cosθ | |
| sinθ | |
| cosθ | -sinθ | |
| sinθ | cosθ | |
| 0 | |
| 1 | |
=
| -sinθ | |
| cosθ | |
Matrix-Vector Multiplication
| cosθ | -sinθ | |
| sinθ | cosθ | |
| 1 | |
| 0 | |
=
| cosθ | |
| sinθ | |
| cosθ | -sinθ | |
| sinθ | cosθ | |
| 0 | |
| 1 | |
=
| -sinθ | |
| cosθ | |
θ
θ
31
Why do we have points defined in 3D?
Translation
Goal: We want x + t_x, y + t_y
⇒ We need constant terms
Homogeneous Coordinates
Homogeneous Coordinates
Homogeneous Coordinates
| cosθ | -sinθ | |
| sinθ | cosθ | |
| cosθ | -sinθ | 0 | |
| sinθ | cosθ | 0 | |
| 0 | 0 | 1 | |
(x, y)T → (x, y, w)T (x, y, z)T → (x, y, z, w)T |
|
→
| x | |
| y | |
| x | |
| y | |
| 1 | |
Homogeneous Coordinates
| 1 | 0 | tx | |
| 0 | 1 | ty | |
| 0 | 0 | 1 | |
| x | |
| y | |
| 1 | |
| x + tx | |
| y + ty | |
| 1 | |
=
37
What does this mean?
38
39
40
NOTHING :)
Homogeneous Coordinates
Transformation Matrices
Transformation Matrices
Coordinate System�Change
Hint:
⚠️Order matters!⚠️
Slide link!
https://tinyurl.com/57ttm8kd
Attendance!
https://tinyurl.com/4p3xcpsx
Attendance Code:
In case you are VERY ambitious…
[Next week's overview & worksheet sols!]
Coordinate Spaces
How do we specify coordinate spaces?
Coordinate System Transformation
Coordinate System Transformation
Coordinate System Transformation
Affine Transformation (General Form)
A is a standard linear transform and b is the translation vector
Vector u represents y’s first basis vector inside of x space
Camera coordinates
Given an object’s camera coordinates, how do we find its world coordinates?
Camera has e, u, v in world coordinates
Given an object’s camera coordinates, how do we find its world coordinates?
Camera has e, u, v in world coordinates
Transformation matrix
Diagram
2. Rebecca Takes a Look
1. Realize that the view direction = -z axis of camera coordinates.
2. Draw the camera coordinate frame axes, and then we find that +z = -v
use right hand rule
Barycentric Coordinates
Barycentric Coordinates
68
Barycentric Coordinates
Barycentric Coordinates
71
Barycentric Interpolation
72
3. Barycentric Coordinates
74
75
76
77
78
79
80
81
82
83
Texture Mapping
Texture Coordinates
Texture Coordinates
86
Texture Coordinates
Dealing with aliasing – Minecraft
88
Dealing with aliasing – Minecraft
89
Dealing with aliasing – Minecraft
90
Antialiasing disabled (not using mipmaps): visible artifacts
Dealing with aliasing – Minecraft
91
Antialiasing via mipmaps enabled
Antialiasing Textures
Antialiasing Textures
93
Antialiasing Textures
94
Halve the dimensions each time →
Choosing Mipmap Levels
Choosing Mipmap Levels
97
Mipmap Example
98
512 x 512
256 x 256
128 x 128
64 x 64
Mipmaps
99
100
101
How do we determine which Mipmap level to use?
Idea: Look at a pixel’s neighbors:
102
Level 0
Level 5
D = level�L = factor that you downsample by
Mathematical Deep Dive - Mipmap Equation
103
(u,v)01
(u,v)10
104
111
Mipmap Equation
112
Bilinear Filtering
Only use values from�one mipmap level
Trilinear Filtering
Linearly interpolate between�two mipmap levels
113
Mathematical Deep Dive - Mipmap Equation
114
Why max?
Consider this case:
Using max(): →
Using min(): →
Using avg(): →
Using min would mean we lose 8-10 texture pixels worth of info per pixel in the y direction!
Intuition: We always want to use the “worst-case” mipmap to avoid aliasing
Mathematical Deep Dive - Mipmap Equation
115
Consider are all 1: → D = 0
are all 2: → D = 1
are all 4: → D = 2
Why log2?
In Practice, we use one of two techniques:
Bilinear: If we only want one level we use:
Exactly what we want!
Trilinear: log2 keeps a consistent scaling as the size increases