Introduction to Computer Graphics Toshiya Hachisuka Last Time - - PowerPoint PPT Presentation

introduction to computer graphics
SMART_READER_LITE
LIVE PREVIEW

Introduction to Computer Graphics Toshiya Hachisuka Last Time - - PowerPoint PPT Presentation

Introduction to Computer Graphics Toshiya Hachisuka Last Time Shading models BRDF Lambertian Specular Simple lighting calculation Tone mapping Today Acceleration data structure How to handle lots of objects


slide-1
SLIDE 1

Introduction to Computer Graphics


 Toshiya Hachisuka

slide-2
SLIDE 2
  • Shading models
  • BRDF
  • Lambertian
  • Specular
  • Simple lighting calculation
  • Tone mapping

Last Time

slide-3
SLIDE 3
  • Acceleration data structure
  • How to handle lots of objects
  • Light transport simulation
  • Rendering equation

Today

slide-4
SLIDE 4

Cost


 for all pixels { ray = generate_camera_ray( pixel ) for all objects { hit = intersect( ray, object ) if “hit” is closer than “first_hit” {first_hit = hit} } pixel = shade( first_hit ) }

slide-5
SLIDE 5

Cost

  • Number of objects x Number of rays
  • Example:
  • 1000 x 1000 image resolution
  • 1000 objects
slide-6
SLIDE 6

Many Objects (Triangles)

The teapot has 6320 triangles

slide-7
SLIDE 7

Many Objects (Triangles)

The teapot has 6320 triangles

slide-8
SLIDE 8

Solution

  • Acceleration data structure
  • Reorganize the list of objects
  • Don’t touch every single object per ray
slide-9
SLIDE 9

Solution

slide-10
SLIDE 10

Solution


 for all pixels { ray = generate_camera_ray( pixel ) for all objects { hit = intersect( ray, object ) if “hit” is closer than “first_hit” {first_hit = hit} } pixel = shade( first_hit ) }

slide-11
SLIDE 11

Solution


 for all pixels { ray = generate_camera_ray( pixel )
 first_hit = traverse( ray, accel_data_struct ) pixel = shade( first_hit ) }


slide-12
SLIDE 12

Two Basic Approaches

  • Reorganize the space - spatial subdivision
  • Reorganize the list - object subdivision
slide-13
SLIDE 13

Spatial Subdivision

slide-14
SLIDE 14

Spatial Subdivision

slide-15
SLIDE 15

Spatial Subdivision

slide-16
SLIDE 16

Spatial Subdivision

slide-17
SLIDE 17

Spatial Subdivision

  • Hierarchically subdivide the space
  • kD-tree (axis-aligned split)
  • BSP-tree (non-axis-aligned split)
  • Each node stores pointers to the subspaces
  • Leaf node stores the list of objects that
  • verlap with the subspace
slide-18
SLIDE 18

Spatial Subdivision

node subdivision( objects, space ) { if ( space is small enough ) { return make_leaf( objects ) } space.split ( &subspace1, &subspace2 ) for all objects { if (overlap(subspace1, object)) subspace1.add(object) if (overlap(subspace2, object)) subspace2.add(object) } tree.add_node( subdivision( objects1, subspace1 ) ) tree.add_node( subdivision( objects2, subspace2 ) ) }

slide-19
SLIDE 19

Object Subdivision

slide-20
SLIDE 20

Object Subdivision

slide-21
SLIDE 21

Object Subdivision

slide-22
SLIDE 22

Object Subdivision

slide-23
SLIDE 23

Object Subdivision

  • Hierarchically subdivide the list of objects
  • Bounding volume hierarchy (BVH)
  • Choice of volume : sphere, box etc.
  • Each node stores pointers to the sublists
  • Leaf node stores the list of objects
slide-24
SLIDE 24

Object Subdivision

node subdivision( objects, space ) { if ( number of objects is small enough ) { return make_leaf( objects ) }

  • bjects.split ( &objects1, &object2 )

subspace1 = bounding_volume( objects1 ) subspace2 = bounding_volume( objects2 )
 tree.add_node( subdivision( objects1, subspace1 ) ) tree.add_node( subdivision( objects2, subspace2 ) ) }

slide-25
SLIDE 25

Object vs Spatial

  • Two approaches
  • Spatial subdivision (kD-tree)
  • Object subdivision (BVH)
  • Still debatable
  • Hybrid is possible and explored
  • Similar to database queries
slide-26
SLIDE 26

Traversal

  • Goal : Don’t touch every single object
  • Given an acceleration data structure
  • Start from the root (entire space)
  • Intersect the ray with child nodes
  • Perform ray-triangle intersections at leaf
slide-27
SLIDE 27

Traversal

hit traverse( ray, node ) { if ( IsLeaf( node ) ) { for all objects in the node { hit = closer( hit, intersect( ray, object ) ) } } if (overlap(ray, node.child1)) traverse( ray, node.child1 ) if (overlap(ray, node.child2)) traverse( ray, node.child2 ) } hit = traverse( ray, root )

slide-28
SLIDE 28
slide-29
SLIDE 29
slide-30
SLIDE 30
slide-31
SLIDE 31
slide-32
SLIDE 32
slide-33
SLIDE 33
slide-34
SLIDE 34
slide-35
SLIDE 35

Only 2 intersection tests out of 8

slide-36
SLIDE 36

Cost


 for all pixels { ray = generate_camera_ray( pixel )
 first_hit = traverse( ray, accel_data_struct )
 pixel = shade( first_hit ) }

slide-37
SLIDE 37

Cost

  • No longer as simple as 


“Number of objects x Number of rays”

  • Order analysis is not helpful
  • Cost of traversal vs intersection tests
  • When should we stop subdivision?



 ⇒ Surface Area Heuristic (SAH)

slide-38
SLIDE 38

Reflected Radiance

~ n ~ !i ~ !o ~ !i ~ !i f(x, ~ !o, ~ !i) Lo(x, ~ !o) = Z

f(x, ~ !o, ~ !i)Li(x, ~ !i) cos ✓id!i

slide-39
SLIDE 39

Incident Illumination

  • Given by light sources or images

Lo(x, ~ !o) = Z

f(x, ~ !o, ~ !i)Li(x, ~ !i) cos ✓id!i

slide-40
SLIDE 40

Missing Piece

slide-41
SLIDE 41

Missing Piece

slide-42
SLIDE 42

Missing Piece

slide-43
SLIDE 43

Missing Piece

  • Light can bounce off from other surfaces
  • Multiple bounces
  • Global illumination
  • Other objects affect illumination
  • Shadowing is one example
  • In contrast to local illumination
slide-44
SLIDE 44

Transport Operator

  • We use the following operator
  • Input: illumination
  • Output: reflected radiance
  • Simply the notation

Lo(x → e) = Z

f(l → x → e)Li(l → x) cos θdω Lo(x → e) = T[Li]

slide-45
SLIDE 45

Using Transport Operator

  • One bounce (i.e., direct)
  • Two bounces

I0Lo(x → e) = T[Li] I1Lo(x → e) = T[I0Lo]

slide-46
SLIDE 46

Using Transport Operator

  • One bounce (i.e., direct)
  • Two bounces

I0Lo(x → e) = T[Li] I1Lo(x → e) = T[I0Lo]

slide-47
SLIDE 47

Using Transport Operator

  • One bounce (i.e., direct)
  • Two bounces

I0Lo(x → e) = T[Li] I1Lo(x → e) = T[I0Lo] = T[T[Li]] = T 2[Li]

slide-48
SLIDE 48

Using Transport Operator

  • One bounce (i.e., direct)
  • Two bounces

I0Lo(x → e) = T[Li] I1Lo(x → e) = T[I0Lo] = T[T[Li]] = T 2[Li] Lo(x → e) = T[Li] + T 2[Li]

slide-49
SLIDE 49

Including All Bounces

Lo(x → e) = T[Li] + T 2[Li] + T 3[Li] + · · ·

slide-50
SLIDE 50

Including All Bounces

Lo(x → e) = T[Li] + T 2[Li] + T 3[Li] + · · ·

Direct illumination Two bounces Three bounces

slide-51
SLIDE 51

Including All Bounces

Direct illumination Two bounces Three bounces

Lo(x → e) = Li + T[Li] + T 2[Li] + T 3[Li] + · · ·

Directly visible light sources

slide-52
SLIDE 52

To the Rendering Equation

  • Remember the Neumann series

I I − K = I + K + K2 + K3 + · · ·

slide-53
SLIDE 53

To the Rendering Equation

  • Remember the Neumann series

I I − K = I + K + K2 + K3 + · · · Lo(x → e) = Li + T[Li] + T 2[Li] + T 3[Li] + · · · = I I − T [Li]

slide-54
SLIDE 54

To the Rendering Equation

  • Remember the Neumann series

I I − K = I + K + K2 + K3 + · · · Lo(x → e) = Li + T[Li] + T 2[Li] + T 3[Li] + · · · = I I − T [Li] (I − T)[Lo(x → e)] = Li

slide-55
SLIDE 55

To the Rendering Equation

Lo(x → e) − T[Lo(x → e)] = Li (I − T)[Lo(x → e)] = Li Lo(x → e) = Li + T[Lo(x → e)]

L(x → e) = Li(x → e) + Z

f(ω, x → e)L(ω) cos θdω

slide-56
SLIDE 56

To the Rendering Equation

Lo(x → e) − T[Lo(x → e)] = Li (I − T)[Lo(x → e)] = Li Lo(x → e) = Li + T[Lo(x → e)]

L(x → e) = Li(x → e) + Z

f(ω, x → e)L(ω) cos θdω

Rendering Equation

slide-57
SLIDE 57

Rendering Equation

  • Describe the equilibrium of radiance
  • Rendering algorithms = solvers of R.E.
  • James Kajiya in 1986

L(x → e) = Li(x → e) + Z

f(ω, x → e)L(ω) cos θdω

Self-emission (zero if x is not light source) BRDF

slide-58
SLIDE 58

“The Rendering Equation” [Kajiya 1986]

slide-59
SLIDE 59

Path Tracing

  • Recursive expansion by random sampling

L(x → e) = Li(x → e) + Z

f(ω, x → e)L(ω) cos θdω

L(x → e) ≈ Li(x → e) + f(ω0, x → e)L(ω0) cos θ0 p(ω0)

slide-60
SLIDE 60

Path Tracing

slide-61
SLIDE 61

Path Tracing

slide-62
SLIDE 62

Path Tracing

slide-63
SLIDE 63

Path Tracing

slide-64
SLIDE 64

Path Tracing

slide-65
SLIDE 65

Path Tracing

slide-66
SLIDE 66

Path Tracing

  • Recursive call even for Lambertian
  • Use random directions around the normal
  • Add the emission term for light sources

color shade (hit) { return (Kd / PI) * get_irradiance(hit) }

slide-67
SLIDE 67

Path Tracing

  • Recursive call even for Lambertian
  • Use random directions around the normal
  • Add the emission term for light sources

color shade (hit) { w = random_dir(hit. normal) c = max(dot(w, hit.normal), 0) d = ray(hit.position, w) return Le + (Kd / PI) * shade(trace(d)) * c / p(w) }

slide-68
SLIDE 68

Generating Random Directions

  • Use spherical coordinates (then get xyz)

p(ωi) = 1 2π θ = arccos(u1) φ = 2πu2 u1, u2 ∈ [0, 1]

slide-69
SLIDE 69

Generating Random Directions

  • and are around the normal, not y axis
  • Use an orthonormal basis (similar to eye rays)

θ φ ~ ny = ~ n ~ nx = ~ c × ~ n |~ c × ~ n| ~ c ~ nz = ~ nx × ~ n

: a vector that is not parallel to normal

~ !i = x~ nx + y~ ny + z~ nz

slide-70
SLIDE 70

Path Tracing

  • Take the average of random samples

for all pixels { ray = generate_camera_ray( pixel )
 first_hit = traverse( ray, accel_data_struct ) pixel = 0 for i = 1 to N { pixel = pixel + shade( first_hit ) } pixel = pixel / N }

slide-71
SLIDE 71

Example

  • edupt (http://kagamin.net/hole/edupt/)
slide-72
SLIDE 72

Light Tracing

  • Trace paths from light sources

http://courses.cs.washington.edu/courses/cse457/14sp/projects/trace/extra/Backward.pdf

slide-73
SLIDE 73

Bidirectional Path Tracing

  • Trace paths from both light sources and eye

https://graphics.stanford.edu/courses/cs348b-03/papers/veach-chapter10.pdf

slide-74
SLIDE 74

Markov Chain Monte Carlo

  • Generate a new sample by mutating the old

https://graphics.stanford.edu/papers/metro/metro.pdf

slide-75
SLIDE 75

Many Lights Methods

  • Lots of point lights for simulating diffuse bounces

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.40.2213&rep=rep1&type=pdf

slide-76
SLIDE 76

Photon Density Estimation

  • Estimate densities of path vertices

http://www.ci.i.u-tokyo.ac.jp/~hachisuka/starpm2013a/

slide-77
SLIDE 77

Bidirectional Path Tracing + Photon Density Estimation

  • Automatically combine two algorithms

http://www.ci.i.u-tokyo.ac.jp/~hachisuka/ups.pdf