文章目录
Lecture 05
Screen Space
(0,0) at left bottom
Pixel (x, y) is centered at (x+0.5, y+0.5)
Viewport Transform
视口变换: [ − 1 , 1 ] 2 → [ 0 , w i d t h ] × [ 0 , h e i g h t ] [-1,1]^{2} \rightarrow [0, width] \times [0,height] [−1,1]2→[0,width]×[0,height]
M v i e w p o r t = ( w i d t h 2 0 0 w i d t h 2 0 h e i g h t 2 0 h e i g h t 2 0 0 1 0 0 0 0 1 ) M_{viewport} = \left(\begin{matrix} \frac{width}{2} & 0 & 0 & \frac{width}{2}\\ 0 & \frac{height}{2} & 0 & \frac{height}{2}\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{matrix}\right) Mviewport=⎝⎜⎜⎛2width00002height0000102width2height01⎠⎟⎟⎞
Raster Displays
LCD(Liquid Crystal Display): block or transmit light by twisting polarization
LED(light emitting diode) 发光二极管
Rasterization
光栅化的关键:判断像素中心点与三角形的位置关系
判断方法:叉积,若三个叉积同号,则点在三角形内
Sampling: discretize a function 函数离散化
Rasterization = Sampling A 2D Indicator Function
光栅化就是在每个像素中心点处对2D函数inside进行采样
for (int x = 0; x < xmax; ++x)
for (int y = 0; y < ymax; ++y)
image[x][y] = inside(tri, x + 0.5, y + 0.5);
Acceleration
When finding all the pixels covered by a triangle, we don’t need to check all pixels on the screen, using a bounding box(包围盒) to accelerate the caculation.
当三角形是细长的、斜着的时候,虽然覆盖的点很少,但包围盒很大,尽量避免在建模时构造这样的三角形
Lecture 06
Why jaggies appear
锯齿产生的原因:signals are changing too fast, but sampled too slowly,采样的频率跟不上信号变化的频率,导致高频信息丢失
抗锯齿的方法:
(1)Bluring before sampling,在采样前先模糊,让高频变成低频
(2)Use higher resolution when sampling,提高采样的分辨率
Fourier Transform
Any function can be represented as a weighted sum of sines and cosines
Filtering
Filtering = Get rid of certain frequency contents
High pass filter:高通滤波,留下图像的边界
Low pass filter: 低通滤波,图像变得模糊
时域上的卷积=频域上的乘积