Course Homepage: 15-462/662 Fall 2020

For assignments implementations: tbbbk/Scotty3D_Benky

Author: Bingkui Tong

1. Basic Math Review1.1 Linear Algebra Review1.1.1 Norm1.1.2 Linear Map1.1.3 Gram-Schmidt1.2 Vector Calculus1.2.1 Matrix Representation of Cross Product1.2.2 Determinant of a Linear Map1.2.3 Derivative as Best Linear Approximation1.2.3 Gradients of Matrix-Valued Expressions1.2.4 Vector Fields1.2.5 Divergence 散度1.2.6 Curl 旋度1.2.7 Hessian in Coordinates2. Rasterization2.1 Rasterization 101: Drawing a Triangle2.1.1 Pinhole camera2.1.2 Computing triangle coverage2.1.3 Aliasing2.1.4 SuperSampling2.2 Spatial Transformations2.2.1 Rotation2.2.2 Scaling2.2.3 Shear2.2.4 Composition2.2.5 Polar & Singular Value Decomposition2.2.6 Interpolating Transformations—Polar2.2.7 Translation!2.2.8 Homogeneous Coordinates2.2.9 Transformation Composition Order2.2.10 Scene Graph2.3 3D Rotations and Complex Representations2.3.1 Degree of Freedom2.3.2 Commutativity of Rotation—3D2.3.3 Euler Angles—Gimbal Lock2.3.4 Complex Analysis2.3.5 Rotation: Matrices vs.Complex2.3.6 Quaternions 四元数2.3.7 3D Rotations via Quaternions2.4 Perspective Projection2.4.1 View Frustum2.4.2 Clipping2.4.3 Mapping Frustum to Unit Cube2.5 Texture Mapping2.5.1 Barycentric Coordinates2.5.2 Perspective Correct Interpolation2.5.3 Texture Coordinates2.5.4 Magnification vs. Minification2.5.5 Bilinear Interpolation (Magnification)2.5.6 MIP Map (Minification)2.5.7 Trilinear Interpolation for MIP Map2.5.8 Anisotropic Filtering2.6 Depth and Transparency2.6.1 Depth-Buffer2.6.2 Compositing2.6.3 Fringing2.6.4 (Non-) Premultiplied Alpha2.7 Rasterization Pipeline Summary3. Geometry3.1 Encode Geometry3.1.1 Implicit Representations3.1.2 Explicit Representations3.1.3 Summary3.2 Meshes and Manifolds3.2.1 Manifold Assumption3.2.2 Why Do We Need Manifold?3.2.3 Halfedge Data Structure3.2.4 Halfedge Meshes Edition3.3 Digital Geometry Processing3.3.1 Remeshing as Resampling3.3.2 Upsampling via (Catmull-Clark/Loop) Subdivision3.3.3 Simplification via Edge Collapse3.3.4 Isotropic Remeshing Algorithm3.5 Geometric Queries3.5.1 Ray Equation3.5.2 Intersection3.6 Spatial Acceleration Data Structures3.6.1 Affine Map for Triangle3.6.2 Bounding Box3.6.3 Bounding Volume Hierarchy (BVH)4. Ray Tracing4.1 Color4.1.1 Intensity or Absorption4.1.2 Emission and Reflection4.1.3 Color Models4.1.4 Y’CbCr4.2 Radiometry4.2.1 Photon4.2.2 Radiant Energy 4.2.3 Radiant Flux (Power) 4.2.4 Irradiance 4.2.5 Lambert's Law4.2.6 Irradiance Falloff with Distance4.2.7 Solid Angles4.2.8 Radiance 4.2.9 Spectral Radiance4.2.10 Ambient Occlusion4.2.11 Radiant Intensity 4.3 The Rendering Equation4.3.1 Recursive Raytracing4.3.2 Reflection4.3.3 Models of Scattering4.3.4 BRDF (Bidirectional Reflectance Distribution Function)4.3.5 Subsurface scattering5. Optimization for Ray Tracing5.1 Numerical Integration5.1.1 Gauss Quadrature5.1.2 Trapezoid rule5.1.3 Curse of Dimensionality for Trapezoid Rule5.1.4 Sampling from Discrete Probability Distributions5.1.5 Sampling Continuous Random Variables using the Inversion Method5.1.6 Rejection Sampling5.2 Monte Carlo Rendering5.2.1 Expected Value and Variance5.2.2 Law of Large Number5.2.3 Biasing5.2.4 Importance Sampling5.2.5 Monte Carlo Integration5.2.6 Russian Roulette5.3 Variance Reduction5.3.1 Estimator5.3.2 Bias & Consistency5.3.3 Bidirectional Path Tracing5.3.4 Metropolis-Hastings Algorithm (MH)5.3.5 Multiple Importance Sampling5.3.6 Sampling Patterns & Variance Reduction6. Animation6.1 Keyframe6.1.1 Keyframing6.1.2 Spline Interpolation6.1.3 Natural Splines6.1.4 Hermite/Bézier Spline6.1.5 Catmull-Rom Spline6.1.6 Evaluation of Spline6.2 Dynamics6.2.1 Inverse Kinematics6.2.2 Animation EquationF6.2.3 Generalized Config6.2.3 Ordinary Differential Equation (ODE)6.2.4 Lagrangian Mechanics6.2.5 Particle Systems6.2.6 Forward/Backward Euler6.2.7 Symplectic Euler6.2.8 Automatic Differentiation6.2.9 Symbolic Differentiation6.2.10 Geometric Differentiation6.3 Partial Differential Equation (PDE)6.3.1 Definition of a PDE6.3.2 Lagrangian vs. Eulerian6.3.3 The Laplace Operator

1. Basic Math Review

I didn't write everything in detail for this section.

1.1 Linear Algebra Review

1.1.1 Norm

Which measures total size, length, volume, intensity, etc.

Warning: L2 Norm does not encode geometric length unless vectors are encoded in an orthonormal basis.

1.1.2 Linear Map

Key Idea: linear maps take lines to lines while keeps the origin fixed

image-20250717152040852

It doesn't matter whether we add the vectors or apply the linear map first.

image-20250717152109816

1.1.3 Gram-Schmidt

image-20250717154153328

Warning: for large number of vectors / nearly parallel vectors, this is not the best algorithm

1.2 Vector Calculus

1.2.1 Matrix Representation of Cross Product

u:=(u1,u2,u3)u^:=[0u3u2u30u1u2u10]u×v=u^v=[0u3u2u30u1u2u10][v1v2v3]

1.2.2 Determinant of a Linear Map

image-20250717161401840

1.2.3 Derivative as Best Linear Approximation

Taylor series:

image-20250717162139822

Replacing complicated functions with a linear (and sometimes quadratic) approximation is a powerful trick in graphics algorithms.

1.2.3 Gradients of Matrix-Valued Expressions

image-20250717162939364

resource: matrixcookbook.pdf

1.2.4 Vector Fields

In general, a vector filed assigns a vector to each point in space, for example, we saw a gradient field:

f(x,y)=x2+y2vector filed: f(x,y)=(2x,2y)

1.2.5 Divergence 散度

image-20250717170702343

Commonly written as ·X.

image-20250717164601687

=(u1,,un)X(u)=(X1(u),,Xn(u))X:=i=1nXiuiRnR

1.2.6 Curl 旋度

image-20250717171020355

Commonly written as ×X

=(u1,u2,u3)X(u)=(X1(u),X2(u),X3(u))×X:=[X3u2X2u3X1u3X3u1X2u1X1u2]If we only consider two dimensions: ×X:=X2u1X1u2

image-20250717171032182

Divergence of X is the same as curl of 90-degree rotation of X

image-20250717171235174

1.2.7 Hessian in Coordinates

Hessian is operator that gives us partial derivatives of the gradient.

f(x):RnR2f:=[2fx1x12fx1xn2fxnx12fxnxn]

2. Rasterization

image-20250717193824058

2.1 Rasterization 101: Drawing a Triangle

image-20250717193737840

Why triangle?

Key reason: once everything is reduced to triangles, can focus on making an extremely well-optimized pipeline for drawing them

2.1.1 Pinhole camera

image-20250717194036226

2.1.2 Computing triangle coverage

Key question: Which pixels does the triangle overlap?

image-20250717194208562

2.1.3 Aliasing

image-20250717194627973

The sampling process lose some information, leading the reconstruction result not exactly accurate. Or we say undersampling high-frequency signals results in aliasing.

2.1.4 SuperSampling

image-20250717195519778

image-20250717195532772

Split a pixel into N×N grids (e.g. 2×2, 4×4), or generate multiple random sampling points in each pixel. For each sampling points, execute the a complete pipeline and average these points to rasterize the pixel.

2.2 Spatial Transformations

image-20250717200120459

2.2.1 Rotation

Properties:

image-20250717200316632

Matrix Representations:

image-20250717200623424

For rotation matrix, the transpose matrix equals inverse matrix.

RTR=I

image-20250717200924923

Orthogonal Transformations

We said the rotation inverse matrix equals transpose matrix, but not all RTR=I does not mean it is a rotation.

When RTR=I,

  • Rotations additionally preserve orientation: det(R)>0

  • Reflections reverse orientation: det(R)<0

R=[1001]RR=[(1)2001]=I

image-20250717201550035

2.2.2 Scaling

f(u)=au

Matrix Representations:

D=[a000a000a],u=[u1u2u3]Du=[a000a000a][u1u2u3]=[au1au2au3]=au

Spectral Theorem:

A symmetric matrix A=AT has

  • orthonormal eigenvectors e1,...,enRn

  • real eigenvalues λ1,...,λnR

Aei=λiei

Hence, every symmetric matrix performs a non-uniform scaling along some set of orthogonal axes.

If A is positive definite (λi>0), this scaling is positive

2.2.3 Shear

image-20250722110856468

fu,v=x+v,xu

2.2.4 Composition

We can composite transformations:

image-20250717203617714

How do we decompose a linear transformation into pieces?

2.2.5 Polar & Singular Value Decomposition

Polar decomposition decomposes any matrix A into orthogonal matrix Q (rotation) and symmetric positive-semidefinite matrix P (scaling).

A=QP

Since P is symmetric, can take this further via the spectral decomposition P=VDVT (V orthogonal (eigenvectors), D diagonal (eigenvalue)):

A=QVDVT=UDVT

Where U and VT are rotation matrix and D axis-aligned scaling matrix.

2.2.6 Interpolating Transformations—Polar

image-20250717204616722

2.2.7 Translation!

fu(x)=x+u

This transformation is NOT linear!

Translation is AFFINE, not linear. Hence we cannot composite it with other linear transformations.

So, how do we composite all the transformations?

2.2.8 Homogeneous Coordinates

image-20250717205256190image-20250717205316388

Hint: Every points along a ray represents the same point.

Consider a point p=(x,y), and the plane z=1 in 3D. Any three p^=(a,b,c) such that (a/c,b/c)=(x,y) are homogeneous coordinates for p


If we apply a translation to a 2D point p, all the homogeneous coordinates p^ looks like shear transformation.

image-20250717211258585

image-20250717211313093

But shear is a linear transformation!

Let a point p=(p1,p2)be translated by vector u=(u1,u2), resulting in: p=(p1+u1,p2+u2) For homogeneous coordinates p^=(cp1,cp2,c) ( c0 ), the translated coordinates become:

p^=(cp1+cu1,cp2+cu2,c)

Notice that we’re shifting p^ by an amount cu then that’s proportional to the distance along the third axis—a shear.

image-20250717212046801

Homogeneous coordinates can also used to distinguish the vectors and points

For vector, the homogeneous coordinate is 0, for point the homogeneous coordinate is 1. Because we cannot translate a vector! So we need to set homogeneous coordinate to 0 to ignore the translation.

2.2.9 Transformation Composition Order

image-20250717212946732

2.2.10 Scene Graph

image-20250717212830584

2.3 3D Rotations and Complex Representations

2.3.1 Degree of Freedom

We need three degrees of freedom to specify a rotation in 3D

Two determine the "axis" direction and one determine how much spinning around the "axis".

2.3.2 Commutativity of Rotation—3D

Order of rotation matters in 3D. Verify by yourself.

2.3.3 Euler Angles—Gimbal Lock

We can use the Euler Angles to represent a 3D rotation like:

image-20250718143603218

But sometimes we will encounter the Gimbal Lock!

Define rotation matrices for x,y,z axes:

Rx=[1000cosθxsinθx0sinθxcosθx],Ry=[cosθy0sinθy010sinθy0cosθy],Rz=[cosθzsinθz0sinθzcosθz0001]RxRyRz=[cosθycosθzcosθysinθzsinθycosθzsinθxsinθy+cosθxsinθzcosθxcosθzsinθxsinθysinθzcosθysinθxcosθxcosθzsinθy+sinθxsinθzcosθzsinθx+cosθxsinθysinθzcosθxcosθy]

For θy=π2 (so cosθy=0,sinθy=1), the matrix simplifies to:

RxRyRz|θy=π/2=[001cosθzsinθx+cosθxsinθzcosθxcosθzsinθxsinθysinθz0cosθxcosθz+sinθxsinθzcosθzsinθx+cosθxsinθysinθz0]

Now, no matter how we adjust θx and θz, it can only rotate in on plane

2.3.4 Complex Analysis

First, change the way of your thinking!

image-20250718144456464

Instead, imagine it's just a quarter-turn in CCW direction:

image-20250718144509367

And complex numbers are just 2-vectors with 1 and i bases:

image-20250718144642310

And the multiple operation is a little different, but the rest operations are the same:

image-20250718144727627

z1:=(r1,θ1)z2:=(r2,θ2)z1z2=(r1r2,θ1+θ2)

So:

eiπ+1=0Specialization of Euler’s formula:eiθ=cos(θ)+isin(θ)Can use to “implement” complex product:z1=aeiθ,z2=beiϕz1z2=abei(θ+ϕ)

*All the angle use rad.

2.3.5 Rotation: Matrices vs.Complex

image-20250718145557037

2.3.6 Quaternions 四元数image-20250718150346893

Hamilton’s insight: in order to do 3D rotations in a way that mimics complex numbers for 2D, actually need FOUR coordinates.

One real, and three imaginary:

H:=span({1,i,j,k})q=a+bi+cj+dkHQuaternion product determined by:i2=j2=k2=ijk=1ij=k,jk=i,ki=j,ji=k,kj=i,ik=j.

*product no longer commutes!

To encode 3D points x,y,z with quaternions, map them to:

(x,y,z)0+xi+yj+zk

where i,j,kare imaginary units of quaternions.

A quaternion can be represented as a pair:

(scalarR,vectorR3)H
(a,u)(b,v)=(abuv,av+bu+u×v)uv=u×vuv

2.3.7 3D Rotations via Quaternions

Given axis u, angle θ, quaternion q representing rotation is

image-20250718151448585

Here we consider the normal vector x and pure imaginary quaternions. And the rotation is q¯xq

2.4 Perspective Projection

image-20250718154207396

Distant objects appear smaller!

2.4.1 View Frustum

View frustum is region the camera can see:

image-20250718154513536

2.4.2 Clipping

When objects are not visible to the camera / in view frustum, we clip it out!

image-20250718154613976

*Also near/far clipping

2.4.3 Mapping Frustum to Unit Cube

image-20250718155934753

image-20250718155958131

image-20250718160010583

Solve Axi=yi for unknown entries of A

image-20250718160118025

While we take perspective projection into account, it is:

image-20250718160354823

For derivation: OpenGL Projection Matrix

Warp Up:

image-20250718162819109

2.5 Texture Mapping

image-20250718184524758

2.5.1 Barycentric Coordinates

Very useful for interpolation.

image-20250718163120828

You can also regard it as the area proportions.

image-20250718163204817

2.5.2 Perspective Correct Interpolation

Due to perspective projection (homogeneous divide), barycentric interpolation of values on a triangle with different depths is not an affine function of screen XY coordinates.

image-20250718163741440

We want to interpolate attribute values linearly in 3D object space, not image space. If we compute barycentric coordinates using 2D (projected) coordinates, leads to (derivative) discontinuity in interpolation where quad was split:

image-20250718163836457

How do we do?

  1. Evaluate Z:=1/z and P:=ϕ/z at each vertex, where ϕ is the attribute

  2. Interpolate Z and P using standard (2D) barycentric coordinates

  3. Divide interpolated P by interpolated Z

For a derivation, see Microsoft Word - lowk_persp_interp_06.doc

2.5.3 Texture Coordinates

Texture coordinate define a mapping from surface coordinates to points in texture domain. Often defined by linearly interpolating texture coordinates at triangle vertices.

image-20250718184656978

Each vertex has a coordinate (u,v) in texture space

image-20250718184746083image-20250718184921694

2.5.4 Magnification vs. Minification

image-20250718185119536

2.5.5 Bilinear Interpolation (Magnification)

image-20250718185412767

image-20250718185421074

image-20250718185429273

2.5.6 MIP Map (Minification)

When a pixel on the screen covers many pixels of the texture, we can average texture values of these pixels, which is expensive to compute. So, we can precompute it and choose one demanded.

image-20250718190043933

image-20250718190111593

To get the mipmap level, we need to compute differences between texture coordinate values at neighboring samples.

image-20250718190406826

2.5.7 Trilinear Interpolation for MIP Map

We can first bilinear interpolate with mipmap level, and then interpolate between two different levels.

image-20250718191205744

image-20250718191213947

w=dd

2.5.8 Anisotropic Filtering

At grazing angles, samples may be stretched out by (very) different amounts along u and v.

image-20250718191718477

image-20250718191725258

We can sample multiple times along the longer direction and less times along the short direction.

2.6 Depth and Transparency

2.6.1 Depth-Buffer

For each sample, depth-buffer stores the depth of the closest primitive seen so far.

image-20250718192513487

There are also color buffer, which can also be used for super-sampling, like (4 samples per pixel)

image-20250718192656644

2.6.2 Compositing

We can represent opacity as α

image-20250718192842741

An image can have a α channel:

image-20250718192939432

2.6.3 Fringing

No fringingFringing
image-20250718193040854image-20250718193055158

What cause this?

2.6.4 (Non-) Premultiplied Alpha

If we Composite image B with opacity αB over image A with opacity αA

image-20250718193656480

Non-premultiplied alphaPremultiplied alpha
image-20250718193559404image-20250718193609401
image-20250718194726595
image-20250718193637653

image-20250718194402971

If we do not use the premulitplied alpha, there is fringe. Because the upsampled color mix the background color with original color. So we have to pre-multiplied color and then upsample it.

image-20250718194948309

Premultiplied alpha is better!

2.7 Rasterization Pipeline Summary

  1. Transform triangle vertices into camera space

    image-20250718200212341

  2. Apply perspective projection transform to transform triangle vertices into normalized coordinate space

    image-20250718200248013

  3. Clipping

    image-20250718200322968

  4. Transform to screen coordinates. Perform homogeneous divide, transform vertex xy positions from normalized coordinates into screen coordinates (based on screen w,h)

    image-20250718200346392

  5. Setup triangle (triangle preprocessing). Before rasterizing triangle, can compute a bunch of data that will be used by all fragments

    image-20250718200432487

  6. Sample coverage and compute triangle color at sample point

    image-20250718200521161

    image-20250718200540346

  7. Perform depth test (if enabled)

    image-20250718200604510

  8. Update color buffer* (if depth test passed) (* Possibly using OVER operation for transparency)

    image-20250718200653638

OpenGL/Direct3D graphics pipeline:

image-20250718200731356

3. Geometry

3.1 Encode Geometry

3.1.1 Implicit Representations

Points aren’t known directly, but satisfy some relationship. E.g., unit sphere is all points such that x2+y2+z2=1.

f(x,y,z)=21.23

image-20250718202442048

Now, find a point on the plane. And we can observe that implicit surfaces make sampling hard.

f(x,y,z)=x2+y2+z21.

image-20250718202548213

Now check if a point is inside or outside the unit sphere. And we can observe implicit surfaces make inside/outside tests task easy.

Common Implicit Representations:

Pros:

Cons:

3.1.2 Explicit Representations

All points are given directly. E.g., points on sphere are (cos(u)sin(v),sin(u)sin(v),cos(v)), for 0u<2π and 0vπ

Many explicit representations in graphics. Like triangle meshes, polygon meshes, subdivision surfaces, NURBS point clouds…

Unsimilar to implicit representations, explicit representations make sampling easy but inside/outside test hard.

Common Explicit Representations:

3.1.3 Summary

Some representations work better than others—depends on the task!

3.2 Meshes and Manifolds

3.2.1 Manifold Assumption

If you zoom in far enough, can draw a regular coordinate grid. (Very rough definition)

image-20250719162325950

This is not manifold:

image-20250719162427742

Which of shapes are manifold?

image-20250719162458536

Or, we can say: A manifold polygon mesh has fans, not fins

  1. Every edge is contained in only two polygons (no “fins”)

  2. The polygons containing each vertex make a single “fan”

image-20250719162549472

3.2.2 Why Do We Need Manifold?

  1. To make some assumptions about our geometry to keep data structures/algorithms simple and efficient

  2. In many common cases, doesn’t fundamentally limit what we can do with geometry

image-20250719162726353

3.2.3 Halfedge Data Structure

*There are lots data structure can be used to store meshes, here we only talk about halfedge.

image-20250719162914367

Halfedge makes mesh traversal easy:

Halfedge connectivity is always manifold:

3.2.4 Halfedge Meshes Edition

3.3 Digital Geometry Processing

3.3.1 Remeshing as Resampling

We need "good sampling"—"good" mesh. We need good approximation of original shape! Keep only elements that contribute information about shape. Add additional information where, e.g., curvature is large.

Vertices exactly on the surface doesn't mean it is a good approximation.

image-20250719164456367

(Some attributes, like normal is not good).

3.3.2 Upsampling via (Catmull-Clark/Loop) Subdivision

There are lots of ways to do the subdivision.

image-2025071916564137

3.3.3 Simplification via Edge Collapse

Basically, we assign each edge a cost, collapse the edge with least cost, and repeat until we reach the target.

image-20250719170542776

And we use Quadric Error Metrics to determine edge's cost.

image-20250719183316611

image-20250719183516959

For a derivation, see Scotty3D_Benky/assignments/A2/simplify.md at main · tbbbk/Scotty3D_Benky

3.3.4 Isotropic Remeshing Algorithm

How to make triangles uniform shape & size?

Repeat four steps:

3.5 Geometric Queries

3.5.1 Ray Equation

r(t)=o+td

image-20250719190555553

3.5.2 Intersection

For implicit surface intersection, f(r(t))=0 and solve for t.

For explicit surface intersection (e.g. triangle), things become much harder and we do care about performance!

We will introduce Spatial Acceleration Data Structures!

3.6 Spatial Acceleration Data Structures

What we care about most is the ray-triangle intersection!

3.6.1 Affine Map for Triangle

We can parameterize triangle given by vertices p0,p1,p2 using barycentric coordinates:

f(u,v)=(1uv)p0+up1+vp2f(u,v)=p0+u(p1p0)+v(p2p0)

Now it's like:

image-20250719191531371

So now the ray-triangle intersection is like:

p0+u(p1p0)+v(p2p0)=o+td[p1p0p2p0d][uvt]=op0M[uvt]=op0[uvt]=M1(op0)u0,v0,u+v1,t0

We only need to solve for u,v, and t.

3.6.2 Bounding Box

We can pre-compute a bounding box around all primitives. If a ray intersect with a bounding box, then we test each primitives within this bounding box to avoid meaningless tradeoff.

Then use calculate the ray-axis-aligned box intersection:

The uniform equation is:

NT(o+td)=c

Solve for the t, e.g. intersection with x0

NT=[1 0 0]T (we only care about x-axis)c=x0t=x0oxdx

More examples:

image-20250719193429378

3.6.3 Bounding Volume Hierarchy (BVH)

BVH implementation assignment is really the pain in the ass…

image-20250719194340940

How do we build the better BVH? We need a better partition.

image-20250719194912528

A good partitioning minimizes the cost of finding the closest intersection of a ray with primitives in the node.

C=Ctrav+pANACisect+pBNBCisect

image-20250719195228703

P(hitA|hitB)=SASB

The pipeline about building BVH:

image-20250719195332186

Beside BVH, there are also lots data structure to accelerate:

4. Ray Tracing

4.1 Color

For the color section, I literally omit a lot of contents… Because I didn't listen to the color lecture very carefully orz

Light is oscillating electric & magnetic field.

KEY IDEA: frequency determines color of light

4.1.1 Intensity or Absorption

image-20250719201526219

4.1.2 Emission and Reflection

image-20250719201620893

4.1.3 Color Models

4.1.4 Y’CbCr

image-20250719201947336

image-20250719201936232

4.2 Radiometry

4.2.1 Photon

Imagine every photon is a little rubber ball hitting the scene.

4.2.2 Radiant Energy Q

This it "the number of hits". Energy for single photon:

Q=hcλh6.626×1034J·sc3.00×108m/sλ390700×103m (visible)Unit: (J×s)(m/s)m=J

where: h is Planck's constant, c is speed of light, and λ is wavelength (color!).

4.2.3 Radiant Flux Φ (Power)

Energy per unit time (Watts) received by the sensor (or emitted by the light)

Φ=limΔt0ΔQΔt=dQdtQ=t0t1Φ(t)dt

4.2.4 Irradiance E

Area density of radiant flux, given a senor of with area A, the average flux is :

ΦA

Irradiance (E) is given by taking limit of area at a single point on the sensor:

E(p)=limΔ0ΔΦ(p)ΔA=dΦ(p)dA[Wm2]

4.2.5 Lambert's Law

image-20250720153803749image-20250720153821568
E=ΦAE=EA=ΦcosθA

4.2.6 Irradiance Falloff with Distance

Given flux Φ:

E1=Φ4πr12Φ=4πr12E1E2=Φ4πr22Φ=4πr22E2E2E1=r12r22=(r1r2)2

Since same amount of energy is distributed over larger and larger spheres, has to get darker quadratically with distance.

image-20250720154233970

4.2.7 Solid Angles

RadiansSteradians
image-20250720154336701image-20250720154344424
θ=lrΩ=Ar2

Differential solid angle:

image-20250720154646024

dA=(rdθ)(rsinθdϕ)=r2sinθdθdϕdω=dAr2=sinθdθdϕΩ=S2dω=02π0πsinθdθdϕ=4π

4.2.8 Radiance L

Radiance is the solid angle density of irradiance:

L(p,ω)=limΔ0ΔEω(p)Δω=dEω(p)dω[Wm2sr]

where Eω denotes that the differential surface area is oriented to face in the direction ω!

image-20250720160237131

In other words, radiance is energy along a ray defined by origin point p and direction ω!

Energy per unit time per unit area per unit solid angle…!

image-20250720160824013

Surface radiance:

L(p,ω)=dE(p)dωcosθ=d2Φ(p)dAdωcosθ

Reminder: Often need to distinguish between incident radiance and exitant radiance functions at a point on a surface. In general:

Li(p,ω)Lo(pω)

image-20250720161616080

 

4.2.9 Spectral Radiance

image-20250720161451051

Now, the radiance is radiant energy per unit time per unit area per unit solid angle. If we wanna get the COLOR, we need to add a "per unit wavelength"

4.2.10 Ambient Occlusion

Assume spherical (vs. hemispherical) light source, “at infinity”. Irradiance is now rotation, translation invariant. Can pre-compute, “bake” into texture to enhance shading

image-20250720161832092

image-20250720161840990

4.2.11 Radiant Intensity I

image-20250720162659268

Power per solid angle emanating from a point source.

I(ω)=dΦdω[Wsr]

4.3 The Rendering Equation

image-20250720165136981

4.3.1 Recursive Raytracing

Basic strategy: recursively evaluate rendering equation!

image-20250720165211245

Renderer measures radiance along a ray:

image-20250720165250920

4.3.2 Reflection

image-20250720165404977

When the ray bounce in scene, how does the reflection of light affect the outgoing radiance?

image-20250720165422869

What we are talking about is the scatter function in the rendering equation. Choice of reflection function determines surface appearance.

Some basic reflection functions:

ReflectionExamples
Ideal specular: Perfect mirrorimage-20250720165759154image-20250720165806019
Ideal diffuse: Uniform reflection in all directionsimage-20250720165811359image-20250720165817245
Glossy specular: Majority of light distributed in reflection directionimage-20250720165824559image-20250720165832597
Retro-reflective: Reflects light back toward sourceimage-20250720165838997image-20250720165847571

4.3.3 Models of Scattering

image-20250720170704604

What goes in must come out! (Total energy must be conserved)

4.3.4 BRDF (Bidirectional Reflectance Distribution Function)

It encodes behavior of light that “bounces off” surface and calculate, when given incoming direction ωi, how much light gets scattered in any given outgoing direction ωo.

fr(ωiωo)0H2fr(ωiωo)cosθdωi1the sum ≤1 instead of =1 because the surface may absorb the energy and convert it into heat or something.fr(ωiωo)=fr(ωoωi)

Radiometric description of BRDF:For a given change in the incident irradiance, how much does the exitant radiance change?

image-20250720172507596

fr(ωiωo)=dLo(ωo)dEi(ωi)=dLo(ωo)dLi(ωi)cosθi[1sr]

Common BRDF:

4.3.5 Subsurface scattering

image-20250720173654307

image-20250720173706572

BSSRDF:

L(xo,ωo)=AH2S(xi,ωi,xo,ωo)Li(xi,ωi)cosθidωidA
image-20250720173822059image-20250720173827694

5. Optimization for Ray Tracing

image-20250720174045210

How can we possibly evaluate this integral?

5.1 Numerical Integration

image-20250720174218971

Basic idea:

5.1.1 Gauss Quadrature

For any polynomial of degree n, we can always obtain the exact integral by sampling at a special set of n points and taking a special weighted combination.

image-20250720175349086

Weighted combination of sample points.

Key idea so far: To approximate an integral, we need

  1. quadrature points

  2. weights for each point

abf(x)dxi=1nwif(xi)

5.1.2 Trapezoid rule

Approximate integral of f(x) by pretending function is piecewise affine.

image-20250720203645901

h=ban1abf(x)dx=h(i=1n1f(xi)+12(f(x0)+f(xn)))

Work: O(n)

Error: O(h2)=O(1n2)

How about 2D?

image-20250720203936134

Error is still O(h^2), but work now is O(n2) (n x n set of measurements).

How about k dimensions?

let N=nk, then the error is O(h2)=O(1n2)=O(1N2k)

5.1.3 Curse of Dimensionality for Trapezoid Rule

How much does it cost to apply the trapezoid rule as we go up in dimension?

For many problems in graphics (like rendering), k is very, very big (e.g., tens or hundreds or thousands). Applying trapezoid rule does not scale!

5.1.4 Sampling from Discrete Probability Distributions

To randomly select an event, select xi if:

Pi1<ξPi

Here ξ is a uniform random variable [0,1)

image-20250720205359000

5.1.5 Sampling Continuous Random Variables using the Inversion Method

Cumulative probability distribution function P(x)=Pr(X<x), get the inverse function P1(x). ξ is a uniform random variable [0,1), solve for x=P1(ξ).

We must know integral of p(x) (to get P(x)), and also the inverse function

First try: uniformly sampling unit circle

image-20250720212617356

image-20250720212632425

image-20250720212645417

*For the second line:image-20250720212923119

image-20250720213015116

5.1.6 Rejection Sampling

image-20250720213112564

image-20250720213143070

5.2 Monte Carlo Rendering

5.2.1 Expected Value and Variance

Expected value:

E(Y)expected value of random variable Y:=i=1probability of ith outcomekpiprobability of ith outcomeyivalue of ith outcome
E[iYi]=iE[Yi]E[aY]=aE[Y]

Variance:

V[Y]=E[Y2]E[Y]2V[i=1NYi]=i=1NV[Yi]V[aY]=a2V[Y]

5.2.2 Law of Large Number

For any random variable, the average value of N trials approaches the expected value as we increase N.

V[1Ni=1NYi]=1N2i=1NV[Yi]=1N2NV[Y]=1NV[Y]

The variance is always linear in N.

5.2.3 Biasing

Ωf(x)dx1Ni=1Nf(Xi)p(Xi)

To get the accurate integration, we should divide the p to fix the biasing caused by the weighted sampling (like importance sampling)

5.2.4 Importance Sampling

image-20250721184636477

Sample the important area more. Remember divide the probability.

5.2.5 Monte Carlo Integration

According to law of large number, we know no matter how hard the integral is, we can always get the right image by taking more samples.

Keep in mind three key ideas:

The essence of integration is "function's accumulation on area", Monte Carlo Integration convert it into "average value of random sampling × area size"

Ωf(x)dx=limN|Ω|Ni=1Nf(Xi)

The Ω is the area size (volume for 3D, …)

The standard error is independent of dimensionality and only depends on the random samples used: O(n12).

5.2.6 Russian Roulette

Randomly terminate the recursive integral of rendering equation.

5.3 Variance Reduction

Keep in mind: You can’t reduce variance of the integrand! Can only reduce variance of an estimator.

5.3.1 Estimator

An “estimator” is a formula used to approximate an integral, like the Monte Carlo estimator.

image-20250721193810096

5.3.2 Bias & Consistency

Two important things to ask about an estimator

Consistency: “converges to the correct answer”:

limnP(|II^n|>0)=0

Unbiased: “estimate is correct on average”:

E[II^n]=0

Example (Consistent but biased):

image-20250721194826431

Example (Inconsistent but unbiased):

image-20250721194813650

Rasterization and Path Tracing are neither consistent and unbiased.

image-20250721194922785

Light has a very “spiky” distribution, how can we sample the lights more?

image-20250721195228213

5.3.3 Bidirectional Path Tracing

image-20250721195508299

Idea: connect paths from light, eye (“bidirectional”)

Example (path length is 2):

image-20250721195537999

5.3.4 Metropolis-Hastings Algorithm (MH)

Good path can be hard to find!

image-20250721195644594

Basic idea: prefer to take steps that increase sample value

image-20250721195832196

5.3.5 Multiple Importance Sampling

image-20250721200413400

1Ni=1nj=1nif(xij)kckpk(xij)

5.3.6 Sampling Patterns & Variance Reduction

How do we sample our function in the first place?

Stratified Sampling

Split into n bins, pick uniformly in each bin

image-20250721200612402

image-20250721200622279

image-20250721200653343

Low-Discrepancy Sampling: Number of samples should be proportional to area

image-20250721201115915

*A(S) here is the proportion of S to the whole area

Hammersley & Halton Points:

First define radical inverse ϕPr(i)

Halton points in k-dimensions: xi=(ϕP1(i),ϕP2(i),,ϕPk(i)).

Hammersley sequence is xi=(i/n,ϕP1(i),ϕP2(i),,ϕPk1(i))

image-20250721201701474

Blue Noise: Can observe that monkey retina exhibits blue noise pattern

image-20250721201341483

6. Animation

6.1 Keyframe

6.1.1 Keyframing

image-20250721202241470

Specify important events only and computer fills in the rest via interpolation/approximation.

image-20250721202334372

6.1.2 Spline Interpolation

image-20250721202438178

Runge Phenomenon: Tempting to use higher-degree polynomials, in order to get higher-order continuity, but can lead to oscillation, ultimately worse approximation.

image-20250721202546955

6.1.3 Natural Splines

For each interval, want polynomial “piece” pi to interpolate data (e.g., keyframes) at both endpoints:

pi(ti)=fi,pi(ti+1)=fi+1,i=0,,n1

Want tangents to agree at endpoints (“C1 continuity”):

pi(ti+1)=pi+1(ti+1),i=0,,n2

Also want curvature to agree at endpoints (“C2 continuity”):

pi(ti+1)=pi+1(ti+1),i=0,,n2

Degree of freedom:

2n+(n1)+(n1)=4n2

6.1.4 Hermite/Bézier Spline

image-20250721204200812

6.1.5 Catmull-Rom Spline

Use the difference of neighbors to define tangent.

ui:=fi+1fi1ti+1ti1

Details: Scotty3D_Benky/assignments/A4/T1-splines.md at main · tbbbk/Scotty3D_Benky

6.1.6 Evaluation of Spline

image-20250721204851472

6.2 Dynamics

6.2.1 Inverse Kinematics

Set a goal and use algorithm (like grad descent) to come up with a plausible motion.

*Detail: Scotty3D_Benky/assignments/A4/T2-skeleton.md at main · tbbbk/Scotty3D_Benky

6.2.2 Animation EquationF

F=ma

6.2.3 Generalized Config

Collect all points all into a single vector of generalized coordinates:

q=(x0,x1,...,xn)

image-20250722101843585

image-20250722101855201

q˙=(x0˙,x1˙,...,xn˙)

image-20250722101942700

image-20250722101951737

 

6.2.3 Ordinary Differential Equation (ODE)

Many dynamical systems can be described via an ordinary differential equation (ODE) in generalized coordinates:

ddtq=f(q,q˙,t)q¨=F/m

Example:

image-20250722102514896

6.2.4 Lagrangian Mechanicsimage-20250722102609815

  1. Write down kinetic energy K

  2. Write down potential energy U

  3. Write down Lagrangian L:=KU

  4. Dynamics then given by Euler-Lagrange equation:

    ddtLq˙=Lq

6.2.5 Particle Systems

image-20250722103450981

We model phenomenon as large collection of particles

How can we solve all these things numerically?

6.2.6 Forward/Backward Euler

We can use the difference to replace derivatives.

image-20250722103746311

Forward Euler

image-20250722103847607

But this is very unstable!

image-20250722104157368

Backward Euler

image-20250722104219777

But it is unconditionally stable!

image-20250722104314219

6.2.7 Symplectic Euler

Backward Euler was stable, but we also saw (empirically) that it exibits numerical damping (damping not found in original eqn.). Nice alternative is symplectic Euler:

6.2.8 Automatic Differentiation

image-20250722104834574

6.2.9 Symbolic Differentiation

image-20250722104853490

6.2.10 Geometric Differentiation

image-20250722104933384

6.3 Partial Differential Equation (PDE)

ODE: Implicitly describe function in terms of its time derivatives

PDE: Also include spatial derivatives in implicit description

image-20250722105601210

Solving a PDE looks like “take weighted combination of neighbors to get velocity (...and add a little velocity each time)”

image-20250722105740737

6.3.1 Definition of a PDE

Want to solve for a function of time and space

image-20250722105847196

Example: nonlinear / higher order ⇒ HARDER TO SOLVE!

image-20250722105952976

6.3.2 Lagrangian vs. Eulerian

image-20250722110151612

Trade-Offs:

image-20250722110228714

Of course, no reason you have to choose just one! You can mix them!

6.3.3 The Laplace Operator

image-20250722110456273

I sincerely do not understand the PDE well, orz.

Flag Counter