Games 101(forth_part)

Games 101 学习笔记 – Geometry

Applications of Textures

In modern GPUs , texture = memory + range query (filtering) (纹理=内存+范围查询(过滤))

  • General method to bring data to fragment calculations (将数据引入碎片计算的一般方法)

Environment Map

用纹理来描述环境光,环境光在用来渲染其他物体。

Envirormental Lighting

Environment map (left) used to render realistic lighting(用于渲染真实照明的环境贴图(左侧))

Spherical Environment Map

假设空间中有一个完全光滑的球体,把环境光记录在球上。

Spherical Map -Problem(球面图-问题)

Prone to distortion (top and bottom parts)! (容易变形(顶部和底部)!)

高纬度的图像扭曲

Cube Map (解决球面问题)

把环境光从球上映射到立方体上

[ ]

vector maps to cube point along that direction.The cube is textured with 6 square texture maps. (向量沿着该方向映射到立方体点。立方体由6个方形纹理贴图组成。)

可以展开成6个面

[ ]

Textures can affect shading! (纹理会影响着色!)

Textures doesn’t have to only represent colors

  • What if it stores the height / normal? (如果它存储了高度/正常值怎么办?)

  • Bump / normal mapping (凹凸/法线贴图)

  • Fake the detailed geometry (伪造详细的几何图形)

Relative height to the underlying surface (与下垫面的相对高度)

Bump Mapping

Adding surface detail without adding more triangles ( 添加曲面细节而不添加更多三角形)

  • Perturb surface normal per pixel (for shading computations only) (每个像素的扰动曲面法线(仅用于着色计算))
  • “Height shift” per texel defined by a texture (纹理定义的每个texel的“高度偏移”)
  • How to modify normal vector? (如何修改法向量?)

Original surface normal n ( p ) = ( 0 , 1 ) n(p)=(0,1) n(p)=(0,1) (原始曲面法线)

Derivative at p is d p = c ∗ [ h ( p + 1 ) − h ( p ) ] d p=c *[h(p+1)-h(p)] dp=c[h(p+1)h(p)] (p处的导数 )

 Perturbed normal is then  n ( p ) = ( − d p , 1 ) .normalized  ( ) \text { Perturbed normal is then } n(p)=(-d p, 1) \text {.normalized }()  Perturbed normal is then n(p)=(dp,1).normalized () (扰动法向)

[]

How to perturb the normal (in 3D)

Original surface normal  n ( p ) = ( 0 , 0 , 1 ) \text{Original surface normal } n(p)=(0,0,1) Original surface normal n(p)=(0,0,1)

Derivative at p are \text{Derivative at p are} Derivative at p are

  • d p / d u = c 1 ∗ [   h ( u + 1 ) − h ( u ) ] \mathrm{dp} / \mathrm{du}=\mathrm{c} 1 *[\mathrm{~h}(\mathbf{u}+1)-\mathrm{h}(\mathbf{u})] dp/du=c1[ h(u+1)h(u)]
  • d p / d v = c 2 ∗ [   h ( v + 1 ) − h ( v ) ] \mathrm{dp} / \mathrm{dv}=\mathrm{c} 2 *[\mathrm{~h}(\mathbf{v}+1)-\mathrm{h}(\mathbf{v})] dp/dv=c2[ h(v+1)h(v)]

Perturbed normal is  n = ( − d p / d u , − d p / d v , 1 ) . n o r m a l i z e d ( ) \text{Perturbed normal is } n=(-d p / d u,-d p / d v, 1) . normalized() Perturbed normal is n=(dp/du,dp/dv,1).normalized()

Note that this is in local coordinate! (请注意,这是本地坐标!)

More will be elaborated in FAQ of HW3

Displacement mapping -a more advanced approach- (置换贴图-更高级的方法)

  • Uses the same texture as in bumping mapping (使用与凹凸贴图中相同的纹理)

  • Actually moves the vertices (实际移动顶点)

需要三角形非常细致

[ ]

3D Procedural Noise + Solid Modeling (3D程序噪波+实体建模)

[ ]
Provide Precomputed Shading (提供预计算阴影)

[ ]

3D Textures and Volume Rendering (3D纹理和体积渲染)

[]

Geometry

Many Ways to Represent Geometry

lmplicit

  • algebraic surface (代数曲面)
  • level sets
  • distance functions (距离函数)

Explicit

  • point cloud (点云)
  • polygon mesh (多边形网格)
  • subdivision, NURBS

“implicit” Representations of Geometry (隐式几何)

Based on classifying points

  • Points satisfy some specified relationship

E.g. sphere: all points in 3D, where x2+y2+z2= 1 ,

More generally, f(x,y,z) = o

[]

lmpllcit Surface - Sampling Can Be Hard (采样可能很困难)

f ( x , y , z ) = ( 2 − x 2 + y 2 ) 2 + z 2 − 1 f(x, y, z)=\left(2-\sqrt{x^{2}+y^{2}}\right)^{2}+z^{2}-1 f(x,y,z)=(2x2+y2 )2+z21

What points lie on f(x,y,z)= 0? (f(x,y,z)=0上的点是什么?)

[]

lmplicit Surface - Inside/Outside Tests Easy

f ( x , y , z ) = x 2 + y 2 + z 2 − 1 f(x, y, z)=x^{2}+y^{2}+z^{2}-1 f(x,y,z)=x2+y2+z21

ls (3/4, 1/2,1/4) inside?

Just plug it in: f(x,y,z)= -1/8<0 Yes, inside.

[]

“Expiicit"Representations of Geometry

All points are given directly or via parameter mapping (直接或通过参数映射给出所有点)

f : R 2 → R 3 ; ( u , v ) ↦ ( x , y , z ) f: \mathbb{R}^{2} \rightarrow \mathbb{R}^{3} ;(u, v) \mapsto(x, y, z) f:R2R3;(u,v)(x,y,z)

[]

Explicit Surface - Sampling ls Easy

f ( u , v ) = ( ( 2 + cos ⁡ u ) cos ⁡ v , ( 2 + cos ⁡ u ) sin ⁡ v , sin ⁡ u ) f(u, v)=((2+\cos u) \cos v,(2+\cos u) \sin v, \sin u) f(u,v)=((2+cosu)cosv,(2+cosu)sinv,sinu)

What points lie on this surface?
Just plug in (u,v) values! (只需插入(u,v)值)

Explicit Surface - Inside/Outside Test Hard

f ( u , v ) = ( cos ⁡ u sin ⁡ v , sin ⁡ u sin ⁡ v , cos ⁡ v ) f(u, v)=(\cos u \sin v, \sin u \sin v, \cos v) f(u,v)=(cosusinv,sinusinv,cosv)

ls (3/4,1/2,1/4) inside?

No "Best Representation - Geometry is Hard! (没有“最佳表现-几何很难!)

More lmplicit Representations in Computer Graphics

Algebraic Surfaces (Ilmplicit) (代数曲面(Ilmplicit))

**[ ]**

Constructive Solid Geometry (Implicit) (构造实心几何图形(隐式))

Combine implicit geometry via Boolean operations (通过布尔运算合并隐式几何体)

[ ]

Distance Functions (Implicit) (距离函数)

Instead of Booleans, gradually blend surfaces together using (使用将曲面逐渐过渡到一起)

Distance functions:
giving minimum distance (could be signed distance)from anywhere to object (给出从任何地方到物体的最小距离(可以是符号距离))

[ ]

An Example: Blending a moving boundary ( 混合移动边界)

[ ]

Blending Distance Functions (lmplicit)

Can blend any two distance functions d1, d2:

[ ]

Level Set(水平集) Methods (Also implicit)

Closed-form equations are hard to describe complex shapes (封闭式方程很难描述复杂的形状)
Alternative: store a grid of values approximating function (替代方法:存储近似函数的值网格)

Surface is found where interpolated values equal zeroProvides much more explicit control over shape (like atexture)

(在插值值等于零的位置找到曲面提供对形状的更明确的控制(如纹理))

Level Sets from Medical Data (CT, MRI, etc.)

Level sets encode, e.g., constant tissue density

[ ]

Level Sets in Physical Simulation

Level set encodes distance to air-liquid boundary (液位设置编码到气液边界的距离)

[ ]

Fractals (implicit) (分形)

Exhibit self-similarity, detail at all scales “Language” for describing natural phenomenaHard to control shape ! (展示自相似性,所有尺度的细节描述自然现象的“语言”难以控制形状!)

[ ]

Many Explicit Representations in Graphics

Point Cloud (Explicit)

Easiest representation: list of points (x,y,z)

Easily represent any kind of geometry

Useful for LARGE datasets (>>1 point/pixel) (适用于大型数据集(>>1点/像素))

Often converted into polygon mesh (通常转换为多边形网格)

Difficult to draw in undersampled regions (在采样不足的区域很难绘制)

【】

Polygon(多边形) Mesh (Explicit)

Store vertices & polygons (often triangles or quads) (存储顶点和多边形(通常是三角形或四边形))

Easier to do processing / simulation, adaptive sampling (更容易进行处理/模拟,自适应采样)

More complicated data structures

Perhaps most common representation in graphics (可能是图形中最常见的表示)

The Wavefront Object File (.obj) Format (Wavefront对象文件(.obj)格式)

Commonly used in Graphics research
Just a text file that specifies vertices, normals, texturecoordinates and their connectivities (只是一个指定顶点、法线、纹理坐标及其连接性的文本文件)

【02】

Curves 曲线

Bezier Curves (贝塞尔曲线)

Defining Cubic Bezier Curve With Tangents (用切线定义三次Bezier曲线)

【03】

Evaluating Bézier Curves (de Casteljau Algorithm) (评估贝塞尔曲线(de Casteljau算法))

Consider three points (quadratic Bezier(二次贝塞尔))

Insert a point using linear interpolation

Insert on both edges

Repeat recursively (递归重复)

Run the same algorithm for every t in [0,1] (对[0,1]中的每t运行相同的算法)

【04】

Cubic Bezier Curve - de Casteljau 三次贝塞尔曲线-de Casteljau

Four input points in total
Same recursive linear interpolations (相同的递归线性插值)

【05】

Evaluating Bézier Curves Algebraic Formula (贝塞尔曲线代数公式的求值)

de Casteljau algorithm gives a pyramid of coefficients (de Casteljau算法给出了系数金字塔)

【06】

Example: quadratic Bezier curve from three points

b 0 1 ( t ) = ( 1 − t ) b 0 + t b 1 b 1 1 ( t ) = ( 1 − t ) b 1 + t b 2 b 0 2 ( t ) ∗ = ( 1 − t ) b 0 1 + t b 1 1 b 0 2 ( t ) = ( 1 − t ) 2 b 0 + 2 t ( 1 − t ) b 1 + t 2 b 2 \begin{array}{l} \mathbf{b}_{0}^{1}(t)=(1-t) \mathbf{b}_{0}+t \mathbf{b}_{1}\\ \mathbf{b}_{1}^{1}(t)=(1-t) \mathbf{b}_{1}+t \mathbf{b}_{2}\\ \mathbf{b}_{0}^{2}(t)^{*}=(1-t) \mathbf{b}_{0}^{1}+t \mathbf{b}_{1}^{1}\\\mathbf{b}_{0}^{2}(t)=(1-t)^{2} \mathbf{b}_{0}+2 t(1-t) \mathbf{b}_{1}+t^{2} \mathbf{b}_{2}\end{array} b01(t)=(1t)b0+tb1b11(t)=(1t)b1+tb2b02(t)=(1t)b01+tb11b02(t)=(1t)2b0+2t(1t)b1+t2b2

【07】

Bernstein form of a Bézier curve of order n: (n阶Bézier曲线的Bernstein形式:)

【08】

b n ( t ) = ∑ j = 0 n b j B j n ( t ) \mathbf{b}^{n}(t)=\sum_{j=0}^{n} \mathbf{b}_{j} B_{j}^{n}(t) bn(t)=j=0nbjBjn(t)

Example: assume n = 3 and we are in R3
i.e. we could have control points in 3D such as:

b 0 = ( 0 , 2 , 3 ) , b 1 = ( 2 , 3 , 5 ) , b 2 = ( 6 , 7 , 9 ) , b 3 = ( 3 , 4 , 5 ) \mathbf{b}_{0}=(0,2,3), \mathbf{b}_{1}=(2,3,5), \mathbf{b}_{2}=(6,7,9), \mathbf{b}_{3}=(3,4,5) b0=(0,2,3),b1=(2,3,5),b2=(6,7,9),b3=(3,4,5)

These points define a Bezier curve in 3D that is a cubicpolynomial in t: (这些点在3D中定义了一条贝塞尔曲线,该曲线在t中为三次多项式:)

b n ( t ) = b 0 ( 1 − t ) 3 + b 1 3 t ( 1 − t ) 2 + b 2 3 t 2 ( 1 − t ) + b 3 t 3 \mathbf{b}^{n}(t)=\mathbf{b}_{0}(1-t)^{3}+\mathbf{b}_{1} 3 t(1-t)^{2}+\mathbf{b}_{2} 3 t^{2}(1-t)+\mathbf{b}_{3} t^{3} bn(t)=b0(1t)3+b13t(1t)2+b23t2(1t)+b3t3

Cubic Bezier Basis Functions

Bernstein Polynomials (伯恩斯坦多项式)

B i n ( t ) = ( n i ) t i ( 1 − t ) n − i B_{i}^{n}(t)=\left(\begin{array}{c} n \\ i \end{array}\right) t^{i}(1-t)^{n-i} Bin(t)=(ni)ti(1t)ni

【09】

Properties of Bezier Curves (Bezier曲线的特性)

Interpolates endpoints (插值端点)

For cubic B e ˊ zier:  b ( 0 ) = b 0 ; b ( 1 ) = b 3 \text{For cubic Bézier: } \mathbf{b}(0)=\mathbf{b}_{0} ; \quad \mathbf{b}(1)=\mathbf{b}_{3} For cubic Beˊzier: b(0)=b0;b(1)=b3

Tangent to end segments (与末端线段相切)

 Cubic case:  b ′ ( 0 ) = 3 ( b 1 − b 0 ) ; b ′ ( 1 ) = 3 ( b 3 − b 2 ) \text { Cubic case: } \quad \mathbf{b}^{\prime}(0)=3\left(\mathbf{b}_{1}-\mathbf{b}_{0}\right) ; \quad \mathbf{b}^{\prime}(1)=3\left(\mathbf{b}_{3}-\mathbf{b}_{2}\right)  Cubic case: b(0)=3(b1b0);b(1)=3(b3b2)

Affine transformation property (仿射变换属性)

  • Transform curve by transforming control points (通过变换控制点变换曲线)

Convex hull property (多边形特性)

  • Curve is within convex hull of control points

BTW: What’s a Convex Hull (顺便说一句:什么是凸包)

【10】

贝塞尔曲线不能超出凸包的范围

Higher-Order(高阶) Bezier Curves?

控制点过多

【11】

贝塞尔曲线的曲线

Piecewise Bezier Curves(分段Bezier曲线)

Instead, chain many low-order Bézier curve (相反,链接许多低阶Bézier曲线)

Piecewise cubic Bézier the most common technique (分段三次Bézier最常用的技术)

【12】

widely used (fonts, paths, lllustrator, Keynote,…) (广泛使用(字体、路径、照明器、注释记号…))

Piecewise Bezier Curve - Continuity ( 分段Bezier曲线-连续性 )

Two Bézier curves

a : [ k , k + 1 ] → R N b : [ k + 1 , k + 2 ] → R N \mathbf{a}:[k, k+1] \rightarrow \mathbb{R}^{N} \\\mathbf{b}:[k+1, k+2] \rightarrow \mathbb{R}^{N} a:[k,k+1]RNb:[k+1,k+2]RN

C0 continuity: a n = b 0 \mathbf{a}_{n}=\mathbf{b}_{0} an=b0

C1 continuity: a n = b 0 = 1 2 ( a n − 1 + b 1 ) \mathbf{a}_{n}=\mathbf{b}_{0}=\frac{1}{2}\left(\mathbf{a}_{n-1}+\mathbf{b}_{1}\right) an=b0=21(an1+b1)

【13】

Other types of splines

Spline

  • a continuous curve constructed so as to pass through a given set of points and have a certain number of continuous derivatives. (为了通过一组给定的点并具有一定数量的连续导数而构造的连续曲线。)
  • ln short, a curve under control (简而言之,一条曲线在控制之中)

B-splines

  • Short for basis splines
  • Require more information than Bezier curves (需要比Bezier曲线更多的信息)
  • Satisfy all important properties that Bézier curves have (i.e.superset) (满足Bézier曲线具有的所有重要特性(即叠加))

局部性

Surfaces (曲面)

Bezier Surfaces

Extend Bézier curves to surfaces (将Bézier曲线延伸到曲面)

【14】

Bicubic Bézier Surface Patch (双三次Bézier曲面片)

Bezier surface and 4 x 4 array of control points (Bezier曲面和4 x 4控制点阵列)

【15】

【16】

贝塞尔曲线通过参数映射实现

Evaluating Bézier Surfaces (评估贝塞尔曲面)

Evaiuatinig Surface Position For Parameters (u,v)

For bi-cubic Bezier surface patch,lnput: 4x4 control points (对于双三次Bezier曲面片,输入:4x4控制点)
Output is 2D surface parameterized by (u,v) in [O,1]2 (输出是由[O,1]2中的(u,v)参数化的2D曲面)

Metnod. Separable 1D de Casteljau Algorithm (方法可分离的1D de Casteljau算法)

Goal: Evaluate surface position corresponding to (u,v) (u,v)-separable application of de Casteljau algorithm (评估对应于(u,v)(u,v)的曲面位置-可分离应用de Casteljau算法)

  • Use de Casteljau to evaluate point u on each of the 4 Bezier curves inu.This gives 4 control points for the “moving” Bezier curve (使用de Casteljau在4条Bezier曲线中的每一条上计算点u。这为“移动”Bezier曲线提供了4个控制点)
  • Use 1D de Casteliau to evaluate point v on the “movina” curve ( 使用1D de Casteliau评估“movina”曲线上的点v)

【18】

Mesh Cperations: Geometry Processing (网格操作:几何图形处理)
  • Mesh subdivision (网格细分)
  • Mesh simplification (网格简化)
  • Mesh regularization (网格正则化)

【17】

Loop Subdivision (Loop 细分)

Common subdivision rule for triangle meshes (三角形网格的通用细分规则)

First, create more triangles (vertices)

Second, tune their positions (调整他们的位置)

loop细分是两步操作 (该算法建立者名字带loop)

【19】

Split each triangle into four

Assign new vertex positions according to weights New / old vertices updated differently (根据权重指定新顶点位置新/旧顶点更新方式不同)

【20】

更新顶点的方法 Update

For new vertices: (对于新顶点:)

Update to:
3/8*(A+B)+1/8*(C+D)

【21】

For old vertices (e.g.degree 6 vertices here): (对于旧顶点(例如此处的6个顶点):)

Update to:
( 1- n * u ) * original_position + u * neighbor_position_sum

n: vertex degree

u: 3 / 16 if n = 3 , 3/ ( 8n ) otherwise

【22】

Loop Subdivision Results

【23】

Catmuli-Clark Subdivision (General Mesh)(Catmuli Clark细分(常规网格))

网格细分

度:一个顶点和他相邻的边数叫度

Non-quad face (非四边形面)

Extraordinary vertex (奇异点) ( degree != 4)

【24】

Each subdivision step:

Add vertex in each face (在每个面中添加顶点)

Add midpoint on each edge (在每条边上添加中点)

Connect all new vertices (连接所有新顶点)

【25】

FYI: Catmull-Clark Vertex Update Rules (Quad Mesh) (仅供参考:Catmull-Clark顶点更新规则(四边形网格))

【26】

Convergence: Overall Shape and Creases (收敛:整体形状和折痕)

Loop Subdivision 只能用于三角形面

Catmuli-Clark Subdivision 可以用于四边形面

【27】

Mesh simplification (网格简化)

Goal: reduce number of mesh elements while maintaining the overall shape (目标:减少网格元素的数量,同时保持整体形状)

【28】

怎么进行网格简化 ?

Coilapsing An Edge (卷曲边缘)

Suppose we simplify a mesh using edge collapsing (假设我们使用边塌陷简化网格)

How much does it cost to collapse an edge?

ldea: compute edge midpoint, measure quadric error (ldea:计算边中点,测量二次误差)

【29】

Quadric Error Metrics (二次误差度量)

How much geometric error is introduced by simplification? (简化会带来多少几何误差?)

Not a good idea to perform local averaging of vertices (执行顶点的局部平均不是一个好主意)

Quadric error: new vertex should minimize its sum of squaredistance (L2 distance) to previously related triangle planes! (二次误差:新顶点应将其与之前相关三角形平面的平方距离(L2距离)之和最小化!)

【30】

Simpification via Quadric Error(通过二次误差简化)

lteratively collapse edges (交替塌陷边缘)

Which edges? Assign score with quadric error metric (哪些边缘?使用二次误差度量指定分数)

  • approximate distance to surface as sum of distances toplanes containing triangles ( 以包含三角形的顶面距离之和表示到曲面的近似距离)
  • iteratively collapse edge with smallest score (具有最小分数的迭代折叠边)
  • greedy algorithm… great results! (贪婪的算法……结果很好!)

Ouadric Error Mesh Simplification (Ouadric误差网格简化)

【31】

Before we move on… (在我们继续之前。。。)

Shadow

  • How to draw shadows using rasterization? (如何使用光栅化绘制阴影?)
  • Shadow mapping!

Shadow mapping

  • An lmage-space Algorithm (一种图像空间算法)

    • no knowledge of scene’s geometry during shadowcomputation (阴影计算期间不了解场景的几何体)

    • must deal with aliasing artifacts

  • Key idea:

    • the points NOT in shadow must be seen bothby the light and by the camera (不在阴影中的点必须同时被光线和相机看到)

Pass 1: Render from Light

Depth image from light source (光源的深度图像)

【32】

Pass 2B: Project to light

Project visible points in eye view back to light source (将眼睛视图中的可见点投射回光源)

【33】

Visualizing Shadow Mapping (可视化阴影贴图)
  • The scene from the light’s point-of-view (灯光视角下的场景)
  • The depth buffer from the light’s point-of-view (灯光视角的深度缓冲区)
  • Comparing Dist(light,shading point) with shadow map (比较距离(灯光、着色点)与阴影贴图)

Shadow Mapping

  • Well known rendering technique (著名的渲染技术)
    • Basic shadowing technique for early animations (Toy Story, etc.) and in EVERY 3D video game (早期动画(玩具总动员等)和每个3D视频游戏中的基本阴影技术)

Problems with shadow maps

  • Hard shadows (point lights only) (硬阴影(仅限于点光源))
  • Quality depends on shadow map resolution(general problem with image-based techniques) (质量取决于阴影贴图分辨率(基于图像的技术的一般问题))
  • Involves equality comparison of floating point depthvalues means issues of scale, bias, tolerance (涉及浮点深度值的相等比较意味着刻度、偏差和公差问题)

【34】
view (灯光视角的深度缓冲区)

  • Comparing Dist(light,shading point) with shadow map (比较距离(灯光、着色点)与阴影贴图)

Shadow Mapping

  • Well known rendering technique (著名的渲染技术)
    • Basic shadowing technique for early animations (Toy Story, etc.) and in EVERY 3D video game (早期动画(玩具总动员等)和每个3D视频游戏中的基本阴影技术)

Problems with shadow maps

  • Hard shadows (point lights only) (硬阴影(仅限于点光源))
  • Quality depends on shadow map resolution(general problem with image-based techniques) (质量取决于阴影贴图分辨率(基于图像的技术的一般问题))
  • Involves equality comparison of floating point depthvalues means issues of scale, bias, tolerance (涉及浮点深度值的相等比较意味着刻度、偏差和公差问题)

[外链图片转存中…(img-wbIAW56h-1666086584944)]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值