如果这篇文章对你有帮助,欢迎点赞与收藏~
目录
Rasterization
1 Points
2 Line
2.1 DDA(差分)
2.2 Bresenham’s algorithm:
2.3 Mid-point algorithm (0-45°)
3 Triangles
4 Polygon
5 Triangulation
6 Interpolation
7 Anti-aliasing
7.1 Box filtering
7.2 Weighted filtering
Light Science
1 Visual cues to 3D geometry
2 Illumination model (compare)
3 Local illumination model
4 Light Sources
4.1 Point light
4.2 Directional light
4.3 Spotlight
5 Phone reflection model (empirical model)
5.1 Ambient
5.2 Diffuse
5.3 Specular reflection
6 Blinn-Phone reflection model
7 Flat shading
8 Gourand shading
9 Phone shading
Texture mapping
1 Use of texture mapping
2 Texture vs material
3 Surface texture mapping:
3.1 UV Interpolation
3.2 UV Mapping
4 Aliasing of textures
4.1 Texture prefiltering
4.2 Mipmapping
5 Other mapping
5.1 Bump mapping
5.2 Displacement mapping
5.3 Environment mapping
5.4 Cubic mapping
Physically-based Rendering(新增,极易考到)
1 Equation
2 BRDF
3 Transmission
4 Randiance and Irradiance
划重点
Rasterization
First job: enumerate the pixels covered by a primitive
Second job: interpolate values across the primitive
1 Points
Inside + right-down point + right edge + down edge
2 Line
Given segment endpoints (x1,y1;x2,y2) are all integers
下面开始展开
2.1 DDA(差分)
float point computation, round operation
2.2 Bresenham’s algorithm:
If a < b ,then upper pixel
If a > b, then lower pixe
In order to avoid computing float point, multiple the Δx
2.3 Mid-point algorithm (0-45°)
Midpoint Circle Algorithm
公式:
递推公式:
3 Triangles
Draw edges vertically and fill in horizontal spans for each scan line
4 Polygon
Inside or outside test:
Send a ray from that specific point,
if the intersections are odd---inner
If the intersections are even ---- outer
Pay attention the ray can’t touch a vertex or tangent with an edge.
Triangle method works only for convex ones
Polygon fill in:
When touching a vertex, with adjacent two edges on one size, the vertex should be viewed as two vertices.
5 Triangulation
Ear-clipping : 每次选取凸顶点从原图中删除,并生成三角形,直到最后只剩三个顶点为止
Trapezoid decomposition: 先划分为梯形,再按对角线分开为三角形
6 Interpolation
Attributes are interpolated during rasterization
• Depth
• Color
• Texture coords
• Many others
7 Anti-aliasing
• Basic idea: replace “is the image black at the pixel center?” with “how much is pixel covered by black?”
• Replace yes/no question with quantitative question.
7.1 Box filtering
• Compute coverage fraction by counting subpixels
• Simple, accurate
• Slow
• Unweighted filtering
7.2 Weighted filtering
• Compute filtering integral by summing filter values for covered subpixels
• Simple, accurate
• But really slow
Light Science
Light color vs reflected color:
The resulting color of the object is light color and multiply the reflected color.
1 Visual cues to 3D geometry
• size (perspective)
• occlusion (depth)
• shading
Light color vs reflected color:
The resulting color of the object is light color and multiply the reflected color.
2 Illumination model (compare)
• Global illumination model
• Simulate not only the direct illuminations but also the indirect illuminations
• Ray-tracing
• Radiosity
• Photon Mapping
• Can handle
• Reflection (one object in another)
• Refraction (Snell’s Law)
• Shadows
• Color bleeding
• More computation and slow
• Local illumination model
• Considers light sources and surface properties only
• Gouraud shading
• Phong shading
• Shadow techniques
• Can approximate GI!
• Environmental Mapping
• Ambient occlusion
• Image based lighting
• Fast and real-time
• Not as accurate as GI
3 Local illumination model
• Light sources
• Geometry
• Material
• Viewing Direction
4 Light Sources
4.1 Point light
(a0,a1,a2) means coefficient for attenuation
4.2 Directional light
(平行光--太阳光)
Directional light has no attenuation because of the infinite distance.
4.3 Spotlight
单位向量点击小于cosθ,即角度大于θ(0<θ<90)
使用α来表示一个平缓变换的情况
5 Phone reflection model (empirical model)
Ambient + diffuse + specular
I: vector to light source
n: surface normal
v: vector to viewer
r: reflection of I at P (determined by I and n)
5.1 Ambient
Different surface can have different ambient reflection coefficient ka (0 ≤ ka ≤ 1)
5.2 Diffuse
Intensity depends on angle of incoming light
5.3 Specular reflection
Shiny surfaces have high specular coefficient
Model specular highlights
Can’t get mirror effect
The higher α is , the narrower specular light
6 Blinn-Phone reflection model
Use calculating a halfway vector between the viewer and light-source vectors to instead computing the dot product of r and v
-> the cost of computing reflecting vector is more than computing halfway vector
In addition, the angle of the Blinn-Phone model is smaller than the Phone model, which makes the specular look more natural.
7 Flat shading
All pixels inside each polygon have the same color. --- fast
Good for polyhedral objects but not good for smooth surfaces.
8 Gourand shading
An interpolation method.
Step:
-
Normal average vector (获取每个顶点邻接面的法向量的平均值作为每个顶点的法向量)
-
Vertex-lightening (based on illumination model)
-
Bilinear interpolation (for color) 双线性插值
Not good at highlight
9 Phone shading
An interpolation method.
Phong shading interpolates normals rather than colors
interpolates surface normal across rasterized polygons and computes pixel colors based on the interpolated normal
Computationally expensive but could capture the highlight
At each pixel, n is recomputed and normalized
Then l is computed at each pixel (lighting model is more expensive than interpolation algorithms)
Texture mapping
An image is pasted onto the 3D model, which is called a texture map.
1 Use of texture mapping
• Describe surface material properties
• Normal and Displacement
• Precomputed lighting and shadows
2 Texture vs material
Material is the intrinsic properties of a surface defining how lighting interacts with the surface
Texture is an “image-based” data describing appearance property
Texture mapping is a part of rasterization
3 Surface texture mapping:
Two mapping functions:
-
Find the mapping relation between texture coordinate and uv coordinate:
-
Find the mapping relation between uv coordinate and object coordinate:
UV coordinate is the transition between texture coordinate and object coordinate.
Finding the true color via uv coordinate
Backward mapping: 反向贴图,通过obj模型和相应的映射关系,将模型上的贴图展成纹理图片
3.1 UV Interpolation
(texture coordinate <--> uv coordinate)
In screen space can not use linear interpolation .
线性插值是基于仿射变换的,在屏幕坐标系中产生两个三角形的仿射变换不相同,而在UV坐标系中两个三角形是相同的,导致了映射函数虽然连续但不平滑(导数不连续)
(u,v) should be divided by the depth
3.2 UV Mapping
Mesh parameterization
(uv coordinate <--> object coordinate)
Orthogonal mapping
Cylindrical mapping:
柱面坐标系:
Linear relation between (u,v) and (s,t)
When u=0, s=0; u=2Π,s=1;
When v=0, t=0; v=h, t=1;
Spherical mapping:
球面坐标系:
4 Aliasing of textures
当许多纹理点被包含在同一像素中或纹理表面的分辨率过高时,会产生
4.1 Texture prefiltering
we can pre-compute the averages (once) and just look up these averages (many times) at run-time
4.2 Mipmapping
根据一个像素中包含的纹理数量来切换分辨率
• Use a texture of multiple resolutions
• Switch the resolution according to the number of texels in one pixel
防止jump:
Rather than clamping the Mipmap level to the closest integer, interpolating between levels
三线性插值
5 Other mapping
5.1 Bump mapping
Use texture to disturb the normal. (the visual illusion, shadow is very smooth)
5.2 Displacement mapping
Use the texture map to actually move the surface point
5.3 Environment mapping
simulate the reflection using texture mapping!
5.4 Cubic mapping
2D UV coordinates becomes 3D texture directions
Physically-based Rendering(新增,极易考到)
1 Equation
2 BRDF
BRDF是指双向反射分布函数(Bidirectional Reflectance Distribution Function)的缩写,是用于描述材料表面反射特性的函数。它描述了入射光线与出射光线之间的关系,包括反射角度、入射角度和光线波长等因素。
Encodes behavior of light that “bounces off” surface
3 Transmission
• In addition to reflecting off surface, light may be transmitted through surface.
• Light refracts when it enters a new medium
• BTDF (Bidirectional transmittance distribution function)
Law of refraction: Snell’s Law
Law of reflection: Fresnel's Law
4 Randiance and Irradiance
Radiance is the solid angle density of irradiance 辐射度是辐照度的立体角密度
-
辐射度(Radiance):
-
定义:辐射度是指从某一方向上单位立体角内,传递通过单位面积的光能量。它是一个方向性的量,不仅取决于光的强度,还取决于光的传播方向。
-
数学表达:通常用 L 表示,其单位是瓦特每平方米每球面度。
-
应用:辐射度在渲染方程中非常重要,用于计算从光源到观察者的光线强度,包括考虑物体表面的反射、吸收和散射等。
-
-
辐照度(Irradiance):
-
定义:辐照度是指单位面积上接收到的光能量,它描述了光源对物体表面的照射强度。
-
数学表达:通常用 E 表示,其单位是瓦特每平方米。
-
应用:辐照度用于计算物体表面由于光照而接收到的能量,是光照模型(如Phong光照模型)中的一个关键组成部分。
-
划重点
• What 3D clues do you know until now? (上文)
• How many types of light sources do you know? (上文)
• Reflection model vs Shading method?
• Why blinn phong is better than phong (上文)
• Why phong shading is better than gourand shading? (插值的对象)
• Material vs Texture? (上文)
• How to deal with multiple light sources simultaneously?
• How does the number of lights affect performance?
• How to rasterize an arbitrary polygon? (上文,扫描法)
• Mipmapping vs Bump mapping vs Displacement mapping vs Cubic mapping?
• The flexible usages of texture objects? (usage 上文)
• Shadow map vs Shadow volume?
• What is the definition of radiance and irradiance?
• What is the rendering equation?
• What is BRDF
如果这篇文章对你有帮助,欢迎点赞与收藏~