Orthographic projection (cuboid to “canonical” cube)
Perspective projection (frustun to “canonical” cube)
Sampling Artifacts in Computer Graphics
Signal are changing too fast (high frequency), but sampled too slowly
Sampling = Repeat Frequency Contents
Aliasing = Mixed Frequency Contents
Antialiasing = Limit, then repeating
MSAA (Multi-Sample AA)
FXAA (Fast Approximate AA 图像的后处理方法)
TAA (Temporal AA 利用上一帧的信息)
Visibility / Occlusion
Painter’s Algorithm
Paint from back to front, overwirte in the framebuffer
Z-Buffer
Store current min. z-value for each sample (pixel)
Need an additional buffer for depth values
frame buffer stores color values
depth buffer stores (z-buffer) depth
z is always positive value
samller z -> closer
larger z -> further
Z-Buffer Algorithm
Initialize depth buffer to
During rasterization:
1 2 3 4 5 6 7
for (each triangle T) for (each sample (x, y, z) in T) if (z < zbuffer[x, y]) framebuffer[x, y] = rgb; zbuffer[x, y] = z else ...
Shading
Definition
In Merriam-Webster Dictionary
The darkening or coloring of an illustration or diagram with parallel lines or a block of color.
In Compute Graphics
The process of applying a material to an object. 不同物体应用不用的材质。
Lambertian (Diffuse) Shading
: diffusely reflected light : diffuse coefficient (color) 如果 是一个表示颜色的向量,可以表示在 shading point 上吸收 / 反射的颜色 : engry arrived at the shading point : engry received by the shading point
漫反射方向和视角方向没有关系
Specular Term (Blinn-Phong)
观察方向和镜面反射的方向接近的时候,就能得到高光
close to mirror direction half vector near normal
给定入射方向和法线方向,也可以算出反射方向进而计算出高光项,但计算量上要比半程向量复杂
指数:点乘向量能体现两个向量是否足够接近,用来控制高光的大小
Ambient Term
Add constant color to account for disregarded illumination and fill in black shadows
This is approximate
Graphics Pipeline
Interpolation Across Triangles
Why do we want to interpolate?
Specify values at vertices
Obtain smoothly varying values across triangles –希望在三角形内部实现平滑过渡
What do we want to interpolate?
Texture coordinates, colors, normal vectors, … –可以对三角形上任意属性进行插值
How do we interpolate?
Barycentric coordinates
Barycentric Coordinates
A coordinate system for triangles
重心坐标:三角形所在平面上任意一点都可以表示三个顶点坐标的线性组合,条件是线性组合的系数之和为 1 Inside the triangle if all three coordinates are non-negative
Texture Mapping
Simple Texture Mapping
1 2 3 4
for each rasterized screen sample(x, y): // usually a pixel's center (u, v) = evaluate texture coordinate at (x, y); // using barycentric coordinate(重心坐标) texcolor = texture.sample(u, v); set sample's color to texcolor;// using the diffuse albedo Kd