图形学


2D变换

scale matrix


reflection matrix

shear matrix

rotate(about the origin(0,0))

坐标变换的顺序为:先缩放->旋转->平移
这时因为:
在物体刚刚放入世界坐标系的时候使用的是本地坐标,也就是本地和全局坐标系的原点和坐标轴都是重合的(当然两者分别使用了左右手坐标系时除外 - 那是BUG),此时所有物体都“把世界坐标系当做自己的本地坐标系”。
而经过了坐标变换之后:
缩放变换不改变坐标轴的走向,也不改变原点的位置,所以两个坐标系仍然重合。
旋转变换改变坐标轴的走向,但不改变原点的位置,所以两个坐标系坐标轴不再处于相同走向。
平移变换不改变坐标轴走向,但改变原点位置,两个坐标系原点不再重合。

这样就可以解释问什么缩放不能在旋转之后,而缩放和旋转都不能在平移之后了。 于是没有问题的顺序只能是 缩放 -> 旋转 -> 平移 。

homogenous coordimates(齐次坐标系)

2D tansformation in homogenous

composing transforms

transform ordering matters!!!

坐标系统

各个空间,比如模型空间、世界空间、相机空间
Opengl初级

3D变换

homogenous coordimates

3D transformations


MVP transformation and viewport


待补充:
万向节死锁
四元数

model transformation

将物体放置在世界坐标指定的位置,可以理解为物体刚被导入时都放置在世界原点,然后通过model transformation放置到指定位置。

view transformation


注意相机原点不与世界原点重合,不要混淆。

更详细的参考虎书6.5

projection transformation

  • Orthographic projection

  • perspective projection

  • helper param
    field of view (fov Y) and aspect are used to define l, r, b, t

aspect ration = width / height

viewport transformation

??

rasterization

rasterize == drawing onto the screen

array of pixels

games101's defination to pixels coodinator is different from the "tiger book".

canonical cube to screen-(viewport transformation)

Triangle-fundamental shape primitives

Sampling is a core idea in graphics.
视频是由一帧一帧的构成,是时间上的一个采样。

aliasing and antialiasing

Sampling artifacts

Behind the aliasing artifacts:
signals are changing too fast (high frequency), but sampled too slowly.

antialiasing idea:
blurring(pre-filtering) before sampling.

傅里叶级数展开。

把一个函数描述成一系列正余弦的组合。

傅里叶变换,时域->频域。

filtering = getting rid of certain frequency contents.
就是去掉一系列的频率。

filtering = convolution=average

understand aliasing in frequency domain.

the solution to aliasing error.
option1: increase sampling rate.

option2: antialiasing
blurring(pre-filtering) before sampling.
i.e. filtering out high frequencies before sampling.

antialiasing by averaging values in pixel area.


1-pixel box??

每个像素覆盖的平均?解决办法MSAA


MSAA解决的是信号的模糊,通过更多的采样点来确定像素的覆盖率,并不是提高分辨率。

what's the cost of MSAA??
计算成分太高,工业界常用的方法?

其他的抗锯齿算法:
FXAA:(Fast Approximate AA)
TAA(Temporal AA)

super resolution:
DLSS(deep learning super sampling)

visibility / occlusion

  • painter's algorithm

  • z-buffering


O(n) for n triangles.


z-buffer透明物体处理不了

shading

the process of applying a material to an object.

shading model: blinn-phong reflectance model

shading != shadow


漫反射是向四面八方的,所以v向量的夹角是不用考虑的。
这只是个经验公式


经验模型


p=100-300

这里的环境光是非常非常简化的形式

这是一个简化模型

shading frequencies

  • flat shading: triangle face is flat——one normal vector
  • gouraud shading: interpolate colors from vertices across tirangle。each vectex has a normal vector
  • phong shading: 这是一种着色频率

如果模型足够复杂,逐面效果也不错,实际上选择什么取决于具体的物体

barycentric interpolation of vertex normal
don't forget to normalize the interpolated directions.

graphics pipeline

可编程shader

texture mapping

定义一个点任意的属性

任何三维物体的表面其实都是二维的。

三维空间最基本的是一个三角形,三维空间中的三角形的顶点和纹理中的点相对应。
如何知道这个对应关系??
美工来搞,或自动化实现


0 < u,v < 1

textures can be used multiple times.

interpolation across triangles: barycentric coordinates

插值的目的:obtain smoothly varying values across triangles.

remember:
barycentric coordinates are not invariant under projection,
要插值三维空间中的一些属性,要放在三维空间中去做。
所以,对于像深度的插值需要在三维空间中做,然后应用到二维屏幕,涉及一个屏幕二维点逆变换到三维空间中这一个过程。

存在的问题:
纹理过小
贴到高分辨率的屏幕上,纹理就会被拉大。
非整数位置上纹理的值
多个pixel会映射到同一个texel这样。

双线性插值:跟其他高级方法,质量还是差一些

存在的问题:
纹理过大
一个pixel覆盖了一片纹理

在一个pixel中,纹理变化很大,频率很高,但却采用了一个采样点。

在一个pixel中进行超采样可以,但计算代价太大。

换个思路,我们不采样,而是get the average value within a range.
how can we do it? query range

query range有多种,比如范围中的最大值最小值、平均值等。

mipmap:可以做范围查询,但是是近似的正方形查询。


找到mipmap对应层中的那个texel??

如何查询1.8层??
三线性插值

三线性插值的结果:

mipmap到了远处会把所有的细节糊掉。

各向异性过滤-解决mipmap中存在的overblur

对于矩形的查询不错,但对于斜着的就不行了。

EWA过滤

环境光照:
环境贴图
假设光源,我们只记录它的方向信息,认为他们无限远。

纹理用来描述环境光。

不同的环境光记录在球面上,然后展开,但会有扭曲问题

解决扭曲的办法:记录在一个立方体上

reference: Interactive Graphics 19 - Bump, Normal, Displacement, and Parallax Mapping

bump vs normal vs displacement mapping

凹凸贴图:(不常用了)
法线贴图

任何一个点都可以通过纹理映射求出一个假的法线,通过假的法线可以得到一个假的结果,从而欺骗人的眼睛。实际上我们并没有改变几何。

bump map中的texture是灰度图,代表的是高度。


然后将计算出的法线重新计算回世界坐标里(设计坐标变换)??

位移贴图:


Normal maps give your models fake depth, displacement maps give your models actual depth.
代价:要求三角形足够多,足够细
offline rendering
只移动vertex是不够的,还需要normal mapping一起来改变表面法线。

parallax mapping

切线空间 为什么要有切线空间(Tangent Space),它的作用是什么?

Normal Mapping-解释的很好

补充一下关于坐标系转换的知识。

3维纹理:
3维噪声

应用:provide precomputed shading

应用:3D textures and volume rendering

geometry

implicit representaions of geometry

  • sampling can be hard
  • inside / outside test easy

explicit representaions of geometry

  • inside/outside test hard

curves

bezier curves贝塞尔曲线

1自己的n阶展开。

piecewise bezier curves

splines 样条


局部性

surfaces

bezier surfaces

mesh operations

细分 subdivision


loop细分只能用于三角形面,而catmull细分可以用于任何面。

0:49:42 shadow

ray tracing

whitted-style ray-tracing

whitted-style ray-tracing: simplification

  • always perform specular reflections/refractions
  • stop bouncing at diffuse surfaces

whitted-style ray tracing: problem:

  • for glossy materials, can't perform well
  • no reflection between diffuse materials is not true

ray-surface intersection

accelerating ray-surface(triangle) intersection

using AABBs to accelerate ray tracing

uniform spatial partitions(grids)

类似均匀的划分

spatial partitioning


kd-tree不太好用

object partitions & bounding volume hierarchy(BVH)*

解决了kd-tree存在的两个问题。

P14 0::55:57

basic radiometry(辐射度量学)

问题:更精确的度量会生成更真实的,比如对于二次元风格的游戏有必要非常真实吗?

radiant energy and flux(power)

irradiance and radiance

BRDF

bidirectional Reflectance Distribution Function(BRDF)

reflection equation

rendering equation

再加一个自发光项


global illumination
全局=直接和间接光照的集合

概率论补充

Monte Carlo Path Tracing

点光源不好处理,可以简单看做面积很小的面光源。

Material and appearances

material == BRDF

glossy material
ideal reflective/refractive material

Fresnel reflection/term
??

microfacet material(微表面材质)
在近处看的是几何,远处看的是材质。

microfacet BRDF

lsotropic/anisotropic materials (各向同性、各向异性)

measuring BRDFs

Advanced topics in rendering

Cameras, lenses and light fields