introduction to computer graphics
play

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


  1. 
 Introduction to Computer Graphics Toshiya Hachisuka

  2. Last Time • Shading models • BRDF • Lambertian • Specular • Simple lighting calculation • Tone mapping

  3. Today • Acceleration data structure • How to handle lots of objects • Light transport simulation • Rendering equation

  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 ) }

  5. Cost • Number of objects x Number of rays • Example: • 1000 x 1000 image resolution • 1000 objects

  6. Many Objects (Triangles) The teapot has 6320 triangles

  7. Many Objects (Triangles) The teapot has 6320 triangles

  8. Solution • Acceleration data structure • Reorganize the list of objects • Don’t touch every single object per ray

  9. Solution

  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 ) }

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


  12. Two Basic Approaches • Reorganize the space - spatial subdivision • Reorganize the list - object subdivision

  13. Spatial Subdivision

  14. Spatial Subdivision

  15. Spatial Subdivision

  16. Spatial Subdivision

  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 overlap with the subspace

  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 ) ) }

  19. Object Subdivision

  20. Object Subdivision

  21. Object Subdivision

  22. Object Subdivision

  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

  24. Object Subdivision node subdivision( objects, space ) { if ( number of objects is small enough ) { return make_leaf( objects ) } objects.split ( &objects1, &object2 ) subspace1 = bounding_volume( objects1 ) subspace2 = bounding_volume( objects2 ) 
 tree.add_node( subdivision( objects1, subspace1 ) ) tree.add_node( subdivision( objects2, subspace2 ) ) }

  25. Object vs Spatial • Two approaches • Spatial subdivision (kD-tree) • Object subdivision (BVH) • Still debatable • Hybrid is possible and explored • Similar to database queries

  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

  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 )

  28. Only 2 intersection tests out of 8

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

  30. 
 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)

  31. Reflected Radiance Z L o ( x, ~ ! o ) = f ( x, ~ ! i ) L i ( x, ~ ! i ) cos ✓ i d ! i ! o , ~ Ω ~ n ~ ! i ! o ~ ! i ~ ~ ! i f ( x, ~ ! i ) ! o , ~

  32. Incident Illumination Z L o ( x, ~ ! o ) = f ( x, ~ ! i ) L i ( x, ~ ! i ) cos ✓ i d ! i ! o , ~ Ω • Given by light sources or images

  33. Missing Piece

  34. Missing Piece

  35. Missing Piece

  36. 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

  37. Transport Operator • We use the following operator • Input: illumination • Output: reflected radiance • Simply the notation L o ( x → e ) = T [ L i ] Z L o ( x → e ) = f ( l → x → e ) L i ( l → x ) cos θ d ω Ω

  38. Using Transport Operator • One bounce (i.e., direct) I 0 L o ( x → e ) = T [ L i ] • Two bounces I 1 L o ( x → e ) = T [ I 0 L o ]

  39. Using Transport Operator • One bounce (i.e., direct) I 0 L o ( x → e ) = T [ L i ] • Two bounces I 1 L o ( x → e ) = T [ I 0 L o ]

  40. Using Transport Operator • One bounce (i.e., direct) I 0 L o ( x → e ) = T [ L i ] • Two bounces I 1 L o ( x → e ) = T [ I 0 L o ] = T [ T [ L i ]] = T 2 [ L i ]

  41. Using Transport Operator • One bounce (i.e., direct) I 0 L o ( x → e ) = T [ L i ] • Two bounces I 1 L o ( x → e ) = T [ I 0 L o ] = T [ T [ L i ]] = T 2 [ L i ] L o ( x → e ) = T [ L i ] + T 2 [ L i ]

  42. Including All Bounces L o ( x → e ) = T [ L i ] + T 2 [ L i ] + T 3 [ L i ] + · · ·

  43. Including All Bounces L o ( x → e ) = T [ L i ] + T 2 [ L i ] + T 3 [ L i ] + · · · Direct illumination Two bounces Three bounces

  44. Including All Bounces Directly visible light sources L o ( x → e ) = L i + T [ L i ] + T 2 [ L i ] + T 3 [ L i ] + · · · Direct illumination Two bounces Three bounces

  45. To the Rendering Equation • Remember the Neumann series I I − K = I + K + K 2 + K 3 + · · ·

  46. To the Rendering Equation • Remember the Neumann series I I − K = I + K + K 2 + K 3 + · · · L o ( x → e ) = L i + T [ L i ] + T 2 [ L i ] + T 3 [ L i ] + · · · I = I − T [ L i ]

  47. To the Rendering Equation • Remember the Neumann series I I − K = I + K + K 2 + K 3 + · · · L o ( x → e ) = L i + T [ L i ] + T 2 [ L i ] + T 3 [ L i ] + · · · I = I − T [ L i ] ( I − T )[ L o ( x → e )] = L i

  48. To the Rendering Equation ( I − T )[ L o ( x → e )] = L i L o ( x → e ) − T [ L o ( x → e )] = L i L o ( x → e ) = L i + T [ L o ( x → e )] Z L ( x → e ) = L i ( x → e ) + f ( ω , x → e ) L ( ω ) cos θ d ω Ω

  49. To the Rendering Equation ( I − T )[ L o ( x → e )] = L i L o ( x → e ) − T [ L o ( x → e )] = L i L o ( x → e ) = L i + T [ L o ( x → e )] Z L ( x → e ) = L i ( x → e ) + f ( ω , x → e ) L ( ω ) cos θ d ω Ω Rendering Equation

  50. Rendering Equation • Describe the equilibrium of radiance • Rendering algorithms = solvers of R.E. • James Kajiya in 1986 Z L ( x → e ) = L i ( x → e ) + f ( ω , x → e ) L ( ω ) cos θ d ω Ω Self-emission BRDF (zero if x is not light source)

  51. “The Rendering Equation” [Kajiya 1986]

  52. Path Tracing • Recursive expansion by random sampling Z L ( x → e ) = L i ( x → e ) + f ( ω , x → e ) L ( ω ) cos θ d ω Ω L ( x → e ) ≈ L i ( x → e ) + f ( ω 0 , x → e ) L ( ω 0 ) cos θ 0 p ( ω 0 )

  53. Path Tracing

  54. Path Tracing

  55. Path Tracing

  56. Path Tracing

  57. Path Tracing

  58. Path Tracing

  59. 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) }

  60. 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) }

  61. Generating Random Directions • Use spherical coordinates (then get xyz) p ( ω i ) = 1 2 π θ = arccos( u 1 ) φ = 2 π u 2 u 1 , u 2 ∈ [0 , 1]

  62. Generating Random Directions • and are around the normal, not y axis φ θ • Use an orthonormal basis (similar to eye rays) ~ n y = ~ n n x = ~ c × ~ n ~ ~ ! i = x ~ n x + y ~ n y + z ~ n z | ~ n | c × ~ ~ n z = ~ n x × ~ n : a vector that is not parallel to normal ~ c

  63. 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 }

  64. Example • edupt (http://kagamin.net/hole/edupt/)

  65. Light Tracing • Trace paths from light sources http://courses.cs.washington.edu/courses/cse457/14sp/projects/trace/extra/Backward.pdf

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend