GAMES101 16 Ray Tracing 4 Path Tracing
Ray Tracing 4 Path TracingMonte Carlo Integration
Definite intergral: $\int_{a}^{b}{f(x)dx}$
Random variable: $X_i\sim pdf(x)$ , pdf is the Probability Distribution Function
Monte Carlo estimator: $F_N=\frac{1}{N}\sum_{i=1}^{N}{\frac{f(x_i)}{pdf(x_i)}}$
我自己证明一下:中心极限定理,当 $ N\rightarrow \infty $
$\frac{1}{N}\sum_{i=1}^{N}{\frac{f(x_i)}{pdf(x_i)}}\rightarrow E(\frac{f(x_i)}{pdf(x_i)})$
$= \int_{a}^{b}{pdf(x_i)\times \frac{f(x_i)}{pdf(x_i)}}dx$
$=\int_{a}^{b}{f(x_i)}dx$
$= F_N|_{a}^{b}$
$F_N|_{a}^ ...
GAMES101 15 Ray Tracing 3 BRDF
15 Ray Tracing 3 BRDFBasic Radiometry 辐射度量学基础Irradiance
Definition: Power pur unit area.
$ E(x) \equiv \frac{d\Phi_{\perp}(x)}{dA}=\frac{\Phi}{A}cos\theta $
单位面积上接收到的能量
Radiance
Definition: Power pur unit solid angle pur unit area
$L(p,\omega)\equiv \frac{d^2\Phi(p,\omega)}{d\omega dAcos\theta}$
单位立体角单位面积上接收到的能量
Radiance 对单位立体角积分,就是Irradiance:
$E_i(\omega_i)=L_i(\omega_i)cos\theta_i d\omega_i$
Bidirectional Reflectance Distribution Function (BRDF)Reflection at a Point 光在一个点的反射
可以理解成,从外界来的Irrad ...
GAMES101 14 Ray Tracing 2 Accelerate
14 Ray Tracing 2 AccelerateAcceleration: Bounding Volumes
Ray-Intersection With a Box
Understanding : box is the intersection of 3 pairs of slabs.
Axis-Aligned Bounding Box: AABB 轴对齐包围盒
光线进入所有包围面,进入盒子。出去其中一个包围面,出去包围盒。
$t_{enter}=max{t_{min}}, t_{exit}=min{t_{max}}$
If $t_{enter}<t_{exit}$, ray stay a while in the box.
$t_{enter}<t_{exit} and t_{exit}>=0$, ray and AABB intersection.
Grid Solution: 在bounding box 里面再弄一堆格子
Spatial Partitioning Examples
Oct-Tree
KD-Tree
BSP-Tree
Object P ...
GAMES101 13 Ray Tracing 1 Whitted-Style
13 Ray Tracing 1 Whitted-StyleShadow Mapping before we move onTBD
Whitted-Style Ray TracingTBD
Why Ray Tracing?
Rasterization couldn’t handle global effects well
Soft shadow
Light bounces more than once
Ray Tracing is accurate, but is very slow
Rasterization: real-time, ray tracing: offline
~10k CPU core hours to render one frame in production.
Definition:
Light Rays:
Light travels in straight lines 直线传播
Light rays do not collide with each other if they cross 不相互影响
Light rays travel from th ...
GAMES101 12 Geometry 3 Mesh Operation
Geometry 3 Mesh Operationby @SankHyan24
Mesh Subdivision:
Loop Subdivision:(used only on triangle)
Add the number of triangle
Assign new vertex positions according to weight
New/old vertices updated differently
For new vertices: Updated to $\frac{3}{8}(A+B)+\frac{1}{8}(C+D)$
For old vertices: Updated to
$(1-nu)\times original position + u neighbor position sum$
$n: vertex degree$
$u:\frac{3}{16} if n=3, \frac{3}{8n} otherwise $
Catmull-Clark Subdivision (General Mesh)
Definition:
Quad fa ...
GAMES101 11 Geometry 2 Curves and Surface
11 Geometry 2 Curves and Surface 曲线和表面
Explicit Representations
Curves
Bezier Curves
De Casteljau’s Algorithm
B-splines, etc.
Surfaces
Bezier surfaces
Triangles & quads
Subdivision, simplification, regulation
Explicit Representations
Point Cloud (Explicit)
Easiest representation: list of points(x,y,z)
只要点足够密,表示任何面
经常被转化成多边形面
Polygon Mesh (Explicit)
Store vertices & polygons(一般是三角形/四边形)
更复杂的数据结构,更普遍的表达形式
The Wavefront Object File (.obj) Format
Curves
Bezier Curves 贝塞尔曲线
Defini ...
GAMES101 10 Geometry 1 Introduction
Lecture 10 Geometry 1 Introduction 几何
About how to describe a stuff by geometry.
A string -> fiber->ply->thread
very complex geometry: a city a dog .etc
Not every geometry can be described as triangles.
Many Ways to Represent Geometry
Implicit: 隐式
points satisfy some specified relationship, E.g. sphere:all points in 3D, where $x^2+y^2+z^2=1$
more generally, $f(x,y,z)=0$
Implict Surface: Sampling can be hard,Inside/Outside tests is easy.
Explicit: 显式
All points are given directly or ...
GAMES101 09 Texture Mapping
Texture Mapping 纹理映射Interpolation Across Triangles: Barycentric Coordinates 重心坐标
A coordinate system for triangles ( $\alpha ,\beta ,\gamma$ )
$(x,y)=\alpha A+\beta B+\gamma C, where \alpha ,\beta ,\gamma>0 and \alpha ,\beta ,\gamma+1=0$
How to Calculate them? Use the triangle area:$$ \alpha = \frac{A_A}{A_A+A_B+A_C}, \ \beta = \frac{A_B}{A_A+A_B+A_C}, \ \gamma = \frac{A_C}{A_A+A_B+A_C}$$
重心坐标不具有投影变换不变性,所以先三维插值,再投影到二维面上去
Texture Magnification: What if the texture is too small?)
A pixel o ...
GAMES101 08 SHADING 2
08 Shading 着色Blinn-Phong Reflection Model
Specular highlights Term 高光
Intensity depends on view direction
Bright near mirror reflection direction
V close to mirror direction <–> half vector near normal(h)
Measure “near” by dot productof unit vectors
Formula: $L_s = k_s(I/r^2)max(0,<n,h>)^p$
What is the p in $max(0,<n,h>)^p$ for? Make it real:
If $\alpha $ is too big, $<n,h>^p$ is small.
Ambient Term 环境光照
Assumption: Shading that does not depend on anything
Add ...
GAMES101 07 SHADING
07 Shading 着色解决遮挡(Visibility)与着色的问题———Z-bufferingBlinn-Phong Reflection Model现在只针对于一个点的着色1.Painter’s Algorithm
遮挡和覆盖overwrite
但是对于物体,填充顺序是个问题
nlog(n)
2.Z-Buffer 深度缓存,n triangle
idea :存储min.z-value, for every pixel
Frame buffer
Depth buffer
Algorithm 维护当前看到的最浅深度的信息
initialize depth buffer to infinity
zbuffer[x,y] denotes the screen’s pixel buffer
framebuffer[x,y] denotes the information(r,g,b) of the pixel
for(every triangle)
for(every sample(x,y,z)in Triangle)
if(z<zbuffer[x,y])
framebuffe ...