SlideShare a Scribd company logo
CS 354
Acceleration
Structures
Mark Kilgard
University of Texas
April 24, 2012
CS 354                                        2



         Today’s material
        In-class quiz
            On global illumination lecture
        Lecture topic
          Project 4
          Acceleration structures
CS 354                            3



         My Office Hours
        Tuesday, before class
            Painter (PAI) 5.35
            8:45 a.m. to 9:15
        Thursday, after class
            ACE 6.302
            11:00 a.m. to 12


        Randy’s office hours
            Monday & Wednesday
            11 a.m. to 12:00
            Painter (PAI) 5.33
CS 354                                            4



         Last time, this time
        Last lecture, we discussed
            Global illumination
        This lecture
            Acceleration structures
        Projects
            Project 4 on ray tracing on Piazza
               Due May 2, 2012
               Get started!
CS 354                                                                                             5

                                             On a sheet of paper
         Daily Quiz                          • Write your EID, name, and date
                                             • Write #1, #2, #3, #4 followed by its answer
        Multiple choice: In the Russian
         Roulette approach to termination of           Multiple choice: Modeling the
         tracing recursive rays, termination            influence of participating media
         occurs                                         simulates

         a) after a fixed number of ray                 a) motion blur
         traces
                                                        b) fog
         b) after a random number of ray
         casts between 1 and a fixed                    c) smoke
         constant
                                                        d) a., b., and c.
         c) when an analytic solution can
         be reached                                     e) b. and c.

         d) every trace has a random                   True of False: Classic Radiosity
         chance of being terminated                     assume the Bidirectional Reflectance
                                                        Distribution Function of all surfaces in
        True or False: A bidirectional                 the scene are Lambertian.
         reflectance distribution function
         returns a negative value
         approximately 50% of the time.
CS 354                                             6



         Project 4
        Provides ray tracing framework
            Use FLTK toolkit for user interface
            Includes sample scenes—.ray files




                      dragon.ray
CS 354                                                                     7



         Sample File: sphere.ray
     SBT-raytracer 1.0              point_light {
                                       position = (-2, 2, -2);
     camera {                          colour = (1, 0.3, 0.3);
        position = (0,0,-4);           constant_attenuation_coeff= 0.25;
        viewdir = (0,0,1);             linear_attenuation_coeff =
        aspectratio = 1;               0.003372407;
        updir = (0,1,0);               quadratic_attenuation_coeff =
                                       0.000045492;
     }
                                    }
     directional_light {
                                    material = {
        direction = (0, 0, 1);
                                       diffuse = (0.4,0.8,0.2);
        colour = (0.2, 0.2, 0.2);
                                       specular = (1,1,0);
     }
                                       shininess = 64;
                                    }

                                    scale(1.5,
                                       sphere {
                                       })

                                    scale(2,sphere{});
CS 354                                                                   8



         What You Must Implement
        Blinn-Phong lighting              Implement shadow ray
         model                                 Modify most
          Ambient, diffuse, specular           RayTracer.cpp
          Modify scene/material.cpp       Implement triangle mesh
        Point light distance               intersection
         attenuation                         Including normal
          Inverse squared distance           interpolation
           fall-off                          Modify
          Modify scene/light.cpp             SceneObjects/trimesh.cpp
        Implement reflection and
         refraction rays
            Modify most
             RayTracer.cpp
CS 354                                       9



         Extra Credit Embellishments
        Spatial data structures
            Speed up the ray traces
      Texture mapping
      Anti-aliasing
            Cast multiple rays per pixel
        Lighting effects
            Normal mapping, bump mapping,
             environment mapping
CS 354                                                                     10



           Other Project 4 Scenes




         recursive_depth.ray        turtle.ray             hitchcook.ray



                               cone.ray          spheres.ray
CS 354                       11



         Debugging Display
CS 354                                                                                                                                                                     12

             Two Versions of
             Rendering Equation
                                                                                                                                      Occlusion (G) is zero




                                                                                                                                o




                                                Le (x, ω , λ , t ) +
                                                                                                                                         Le (x, ω , λ , t ) +
Lo (x, ω , λ , t ) =
                       ∫
                       Ω
                           f r (x, ω ′, ω , λ , t ) Li (x, ω ′, λ , t ) (−ω ′ • n) dω ′   Lo (x, ω , λ , t ) =
                                                                                                                 ∫     f r (x, ωyx , ω , λ , t ) L(y, ωyx , λ , t ) G (x, y ) dy
                                                                                                                 y∈Γ



           Integrate over hemisphere                                                                Integrate over all surface points
CS 354                                                            13



         Photon Mapping
        Two-pass global illumination algorithm
            Developed by Henrick Jensen (1996)
            Two passes
                 Randomly distribute photons around the scene
                      Called “photon map construction”
                 Render treating photons as mini-light sources
        Capable of efficiently generating otherwise very
         expensive effects
            Caustics
            Diffuse inter-reflections, such as color bleed
            Sub-surface scattering
CS 354                                                    14



         Light Tracing
        Trace rays from the light
            Contribution rays accumulate image samples
CS 354                                                                  15



         Photon Mapping Examples



                                     without diffuse     photo map
               caustics              interreflection    visualization




          sub-surface scattering

                                   diffuse interreflection
CS 354                                                 16

         Global Illumination Often Gated
         by Ray Tracing Speed
      Shooting rays tends to be the bottleneck
      Why?
          Lots of rays cast for quality
          Shadow rays, lots for soft shadows
          Reflection and refraction rays
        Speeding up global illumination generally
         means speeding up tracing of rays
          Shading operations can be expensive too
          But rays involve data structure traversal
CS 354                                                17

                                  More bounces
         Recursive Rays
        Reflections and
         refractions can spawn
         lots of rays




                                 Fewer bounces   17
CS 354                                    18



         Sufficient Shadow Ray Sampling
CS 354                                                                   19



          Distribution Ray Tracing
         Soft shadows
              Distribute shadow rays over light source region




         All shadow rays        No shadow rays      Some shadow rays
         hit light source,      hit light source,    hit light source,
         fully illuminated      fully shadowed      partially shadowed
CS 354                                                20



         Distribution Ray Tracing
        Motion blur
            Distribute rays over time




                                         Pool Balls
                                         Tom Porter
                                         RenderMan
CS 354                                                                      21



         Distribution Ray Tracing
         Depth of field
               Distribute rays across a discrete camera aperture




               No depth-of-field                              More rays




                                            Jittered
                                          depth-of-field



         More images for depth-of-field                    Even more rays
CS 354                                                                   22



         Acceleration Techniques
              Ray Tracing Acceleration Techniques


               Fast                   Fewer             Generalized
          Intersections               Rays                 Rays
                                     Statistical        Beam tracing
     Faster            Fewer         optimizations
   ray-object        ray-object      for illumination   Cone tracing
                                     convergence
 intersections     intersections                        Pencil tracing
 Object bounding   Bounding volume
 volumes           hierarchies
CS 354                                                      23

          Accelerating Ray Trace
          Intersection Operations
          Two key optimizations

     3.    Exploit binary searching
             Rather than linear searches
     4.    Group objects spatially
             Discard hierarchically
             Use quick-and-coarse tests…
             …to avoid slow-and-exact intersection tests
CS 354                                                           24

         Acceleration Structures:
         Bounding Volume Hierarchies
        Build hierarchy of bounding volumes
            Bounding volume of interior node has its children
CS 354                                          25



         Accelerate Ray Intersections
        Traverse hierarchy to accelerate ray
         intersections
            Intersect node content
             only if ray hits the
             bounding volume




         Skip intersection A, D, E, and F
CS 354                                                                26

          Accelerate Ray Intersection
          Algorithm
         Sort hits and detect early termination
         FindIntersection( Ray ray, Node node )
         {
           // Find intersections with child node bounding volumes
           …
           // Sort intersections closest to farthest
           …
           // Process intersections, checking for early termination
           min_t = infinity;
           for each intersected child i {
             if (min_t < bv_t[i]) break;
             shape_t = FindIntersection(ray, child);
             if (shape_t < min_t) { min_t = shape_t; }
           }
           return min_t; // closest intersection
         }
CS 354                                             27



         Bounding Volumes
        Axis-Aligned Bounding Boxes (AABB)
            min (x,y,z) & max(x,y,z)
            Trivial plane equations
        Bounding spheres
            Point and radius
            Ray and sphere intersection is easy
                 Solving a quadratic equation
        Oriented Bounding Box
            Might have tighter bounds than AABB
        Convex Polyhedron (Polytope)
CS 354                                                28



         Spatial Hierarchy
        Uniform grid
        Quadtree (2D) and Octree (3D)
            Exactly four or eight children
            Equal area/volume for each children
        KD Tree
            Two children, splitting in X, Y, or Z
            Axis aligned splitting planes
                 Not necessarily equal area/volume
        Binary Space Partitioning (BSP) Tree
            Arbitrary splitting planes
            Just two children
CS 354                                      29

         Space Subdivision
         Approaches

  Uniform grid               Octree
                             Quadtree




                             Binary
   KD Tree                   Space
                             Partitioning
                             Tree
CS 354                                         30



         Uniform Grid Construction
                        Preprocess scene
                        2. Find bounding box
                        3. Determine grid
                           resolution
CS 354                                               31



         Uniform Grid Construction
                        Preprocess scene
                        2. Find bounding box
                        3. Determine grid
                           resolution
                        4. Place object in cell if
                           its bounding box
                           overlaps the cell
CS 354                                               32



         Uniform Grid Construction
                        Preprocess scene
                        2. Find bounding box
                        3. Determine grid
                           resolution
                        4. Place object in cell if
                           its bounding box
                           overlaps the cell
                        5. Check that object
                           overlaps cell
CS 354                                                  33



         Uniform Grid Traversal
                        After processing…
                        Traverse grid
                         3D line = 3D-DDA
                        Digital Differential Analyzer

                        Advantages
                        Simple construction
                        Simple traversal

                        Disadvantage
                        Poor at sparse or huge
                        scenes
CS 354                                    34



         Binary Space Partitioning Tree
        2D view of BSP
CS 354                                                            35



         Binary Space Partitioning Trees
        Recursive search
            Partitioning plane has two nodes
 FindIntersection( Ray ray, Node node )
 {
   if node is leaf {
     intersect ray with each object in node
     return closest object (or nil)
   }
   near = child of node in half space containing ray’s origin
   far = the other child
   hit = FindIntersection( ray, near )
   if hit is null and ray intersections plane defined by node {
     hit = FindIntersection( ray, far )
   }
   return hit;
 }
CS 354                                 36



         BSP Intersection with a Ray
CS 354                                           37



         Optimizing Bounding Hierarchies
        Complex meshes need to be partitioned
         into bounding hierarchy




           [Saut, Sidobre, 2012]
CS 354                                                  38



         Octree Building
        Building octree from boundary representation
CS 354                                                      39



         KD-tree
        Like an Octree
          But dividing planes aren’t necessarily in even
           octo squares
          Tighter bounds




             [Mahmoud Zidan]
CS 354                                                      40

         Close Cousin of Ray Tracing:
         Volume Rendering
        Common task: visualization of volumetric data
            Data arranged in 3D “voxel” grid
                 Voxel = volume element
            Applications: medical, oil & gas exploration
CS 354                                                              41



         Simple Case of Ray Casting
        Rays are all coherent
        GPU-oriented Volume rendering
          Draw 3D textured polygons slicing through a 3D texture
          Apply transfer function
          Blend in ray order—use framebuffer blending
CS 354                                                        42



         Transfer Function
        Give viewer control of how volumetric data
         maps to color & opacity
            Transfer functions enable visualization of
             otherwise difficult-to-understand mass of data
CS 354                                           43



         Volume Rendering Examples


                         Head with clip planes




           Liver tumor
CS 354                                                        44



         Next Class
        Next lecture
            Performance analysis
            Considerations for tuning interactive graphics
             applications

        Reading
            Chapter 8, 455-460
            Chapter 11, 578-601

        Project 4
            Project 4 is a simple ray tracer
            Due Wednesday, May 2, 2012

More Related Content

PPT
CS 354 Global Illumination
PPT
CS 354 Lighting
PPT
CS 354 Shadows
PPT
CS 354 More Graphics Pipeline
PPT
CS 354 Understanding Color
PPT
CS 354 Shadows (cont'd) and Scene Graphs
PPT
CS 354 Pixel Updating
PPT
CS 354 Texture Mapping
CS 354 Global Illumination
CS 354 Lighting
CS 354 Shadows
CS 354 More Graphics Pipeline
CS 354 Understanding Color
CS 354 Shadows (cont'd) and Scene Graphs
CS 354 Pixel Updating
CS 354 Texture Mapping

What's hot (20)

PPT
CS 354 Blending, Compositing, Anti-aliasing
PPT
CS 354 Final Exam Review
PPT
CS 354 Ray Casting & Tracing
PPT
CS 354 Typography
PPT
CS 354 Object Viewing and Representation
PPT
CS 354 Project 2 and Compression
PPT
CS 354 Graphics Math
PPT
CS 354 Programmable Shading
PPT
Shadow Volumes on Programmable Graphics Hardware
PPT
CS 354 Surfaces, Programmable Tessellation, and NPR Graphics
PDF
A Physical Approach to Moving Cast Shadow Detection (ICASSP 2009)
PDF
Estimating Human Pose from Occluded Images (ACCV 2009)
PPTX
Robust Stenciled Shadow Volumes
PPT
CS 354 GPU Architecture
PPT
CS 354 Viewing Stuff
PPTX
PPTX
Around the World in 80 Shaders
PPTX
ARCHITECTURAL CONDITIONING FOR DISENTANGLEMENT OF OBJECT IDENTITY AND POSTURE...
PDF
Siggraph2016 - The Devil is in the Details: idTech 666
PPTX
Implementing a modern, RenderMan compliant, REYES renderer
CS 354 Blending, Compositing, Anti-aliasing
CS 354 Final Exam Review
CS 354 Ray Casting & Tracing
CS 354 Typography
CS 354 Object Viewing and Representation
CS 354 Project 2 and Compression
CS 354 Graphics Math
CS 354 Programmable Shading
Shadow Volumes on Programmable Graphics Hardware
CS 354 Surfaces, Programmable Tessellation, and NPR Graphics
A Physical Approach to Moving Cast Shadow Detection (ICASSP 2009)
Estimating Human Pose from Occluded Images (ACCV 2009)
Robust Stenciled Shadow Volumes
CS 354 GPU Architecture
CS 354 Viewing Stuff
Around the World in 80 Shaders
ARCHITECTURAL CONDITIONING FOR DISENTANGLEMENT OF OBJECT IDENTITY AND POSTURE...
Siggraph2016 - The Devil is in the Details: idTech 666
Implementing a modern, RenderMan compliant, REYES renderer
Ad

Viewers also liked (6)

PPT
NVIDIA OpenGL in 2016
ODP
Out-of-Core Construction of Sparse Voxel Octrees
PPT
CS 354 Procedural Methods
PPT
CS 354 Performance Analysis
PPT
CS 354 Project 1 Discussion
PPT
CS 354 Introduction
NVIDIA OpenGL in 2016
Out-of-Core Construction of Sparse Voxel Octrees
CS 354 Procedural Methods
CS 354 Performance Analysis
CS 354 Project 1 Discussion
CS 354 Introduction
Ad

Similar to CS 354 Acceleration Structures (20)

PDF
Learning Moving Cast Shadows for Foreground Detection (VS 2008)
PDF
Simulations of Strong Lensing
PDF
Color Img at Prisma Network meeting 2009
PDF
SA09 Realtime education
PDF
Image formation
PDF
Benchmark Calculations of Atomic Data for Modelling Applications
PPTX
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
PDF
Practical Spherical Harmonics Based PRT Methods
PDF
IVR - Chapter 2 - Basics of filtering I: Spatial filters (25Mb)
PDF
Modern features-part-1-detectors
PDF
Lecture 02 internet video search
PDF
Polariscope: Practical Design
PDF
Intro to threp
PPSX
Practical spherical harmonics based PRT methods.ppsx
PPT
Fingerprint High Level Classification
PDF
Hoip10 presentacion cambios de color_univ_granada
PDF
CVPR2010: Advanced ITinCVPR in a Nutshell: part 2: Interest Points
PPTX
Accommodation-invariant Computational Near-eye Displays - SIGGRAPH 2017
PPTX
Trident International Graphics Workshop2014 3/5
PDF
filter based texture analysis method texture Analysis gabor filter.pdf
Learning Moving Cast Shadows for Foreground Detection (VS 2008)
Simulations of Strong Lensing
Color Img at Prisma Network meeting 2009
SA09 Realtime education
Image formation
Benchmark Calculations of Atomic Data for Modelling Applications
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
Practical Spherical Harmonics Based PRT Methods
IVR - Chapter 2 - Basics of filtering I: Spatial filters (25Mb)
Modern features-part-1-detectors
Lecture 02 internet video search
Polariscope: Practical Design
Intro to threp
Practical spherical harmonics based PRT methods.ppsx
Fingerprint High Level Classification
Hoip10 presentacion cambios de color_univ_granada
CVPR2010: Advanced ITinCVPR in a Nutshell: part 2: Interest Points
Accommodation-invariant Computational Near-eye Displays - SIGGRAPH 2017
Trident International Graphics Workshop2014 3/5
filter based texture analysis method texture Analysis gabor filter.pdf

More from Mark Kilgard (20)

PDF
D11: a high-performance, protocol-optional, transport-optional, window system...
PPT
Computers, Graphics, Engineering, Math, and Video Games for High School Students
PPT
NVIDIA OpenGL and Vulkan Support for 2017
PPT
NVIDIA OpenGL 4.6 in 2017
PPT
Virtual Reality Features of NVIDIA GPUs
PPTX
Migrating from OpenGL to Vulkan
PPT
EXT_window_rectangles
PPT
OpenGL for 2015
PPT
Slides: Accelerating Vector Graphics Rendering using the Graphics Hardware Pi...
PDF
Accelerating Vector Graphics Rendering using the Graphics Hardware Pipeline
PPT
NV_path rendering Functional Improvements
PPTX
OpenGL 4.5 Update for NVIDIA GPUs
PPT
SIGGRAPH Asia 2012: GPU-accelerated Path Rendering
PPT
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
PDF
Programming with NV_path_rendering: An Annex to the SIGGRAPH Asia 2012 paper...
PPT
GPU accelerated path rendering fastforward
PDF
GPU-accelerated Path Rendering
PPT
SIGGRAPH 2012: GPU-Accelerated 2D and Web Rendering
PPT
SIGGRAPH 2012: NVIDIA OpenGL for 2012
PPT
GTC 2012: GPU-Accelerated Path Rendering
D11: a high-performance, protocol-optional, transport-optional, window system...
Computers, Graphics, Engineering, Math, and Video Games for High School Students
NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL 4.6 in 2017
Virtual Reality Features of NVIDIA GPUs
Migrating from OpenGL to Vulkan
EXT_window_rectangles
OpenGL for 2015
Slides: Accelerating Vector Graphics Rendering using the Graphics Hardware Pi...
Accelerating Vector Graphics Rendering using the Graphics Hardware Pipeline
NV_path rendering Functional Improvements
OpenGL 4.5 Update for NVIDIA GPUs
SIGGRAPH Asia 2012: GPU-accelerated Path Rendering
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
Programming with NV_path_rendering: An Annex to the SIGGRAPH Asia 2012 paper...
GPU accelerated path rendering fastforward
GPU-accelerated Path Rendering
SIGGRAPH 2012: GPU-Accelerated 2D and Web Rendering
SIGGRAPH 2012: NVIDIA OpenGL for 2012
GTC 2012: GPU-Accelerated Path Rendering

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPT
Teaching material agriculture food technology
PDF
cuic standard and advanced reporting.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Machine learning based COVID-19 study performance prediction
PDF
Modernizing your data center with Dell and AMD
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Cloud computing and distributed systems.
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Encapsulation theory and applications.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MYSQL Presentation for SQL database connectivity
Teaching material agriculture food technology
cuic standard and advanced reporting.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Machine learning based COVID-19 study performance prediction
Modernizing your data center with Dell and AMD
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
NewMind AI Weekly Chronicles - August'25 Week I
Dropbox Q2 2025 Financial Results & Investor Presentation
Cloud computing and distributed systems.
Spectral efficient network and resource selection model in 5G networks
Mobile App Security Testing_ A Comprehensive Guide.pdf
NewMind AI Monthly Chronicles - July 2025
Encapsulation theory and applications.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing

CS 354 Acceleration Structures

  • 2. CS 354 2 Today’s material  In-class quiz  On global illumination lecture  Lecture topic  Project 4  Acceleration structures
  • 3. CS 354 3 My Office Hours  Tuesday, before class  Painter (PAI) 5.35  8:45 a.m. to 9:15  Thursday, after class  ACE 6.302  11:00 a.m. to 12  Randy’s office hours  Monday & Wednesday  11 a.m. to 12:00  Painter (PAI) 5.33
  • 4. CS 354 4 Last time, this time  Last lecture, we discussed  Global illumination  This lecture  Acceleration structures  Projects  Project 4 on ray tracing on Piazza  Due May 2, 2012  Get started!
  • 5. CS 354 5 On a sheet of paper Daily Quiz • Write your EID, name, and date • Write #1, #2, #3, #4 followed by its answer  Multiple choice: In the Russian Roulette approach to termination of  Multiple choice: Modeling the tracing recursive rays, termination influence of participating media occurs simulates a) after a fixed number of ray a) motion blur traces b) fog b) after a random number of ray casts between 1 and a fixed c) smoke constant d) a., b., and c. c) when an analytic solution can be reached e) b. and c. d) every trace has a random  True of False: Classic Radiosity chance of being terminated assume the Bidirectional Reflectance Distribution Function of all surfaces in  True or False: A bidirectional the scene are Lambertian. reflectance distribution function returns a negative value approximately 50% of the time.
  • 6. CS 354 6 Project 4  Provides ray tracing framework  Use FLTK toolkit for user interface  Includes sample scenes—.ray files dragon.ray
  • 7. CS 354 7 Sample File: sphere.ray SBT-raytracer 1.0 point_light { position = (-2, 2, -2); camera { colour = (1, 0.3, 0.3); position = (0,0,-4); constant_attenuation_coeff= 0.25; viewdir = (0,0,1); linear_attenuation_coeff = aspectratio = 1; 0.003372407; updir = (0,1,0); quadratic_attenuation_coeff = 0.000045492; } } directional_light { material = { direction = (0, 0, 1); diffuse = (0.4,0.8,0.2); colour = (0.2, 0.2, 0.2); specular = (1,1,0); } shininess = 64; } scale(1.5, sphere { }) scale(2,sphere{});
  • 8. CS 354 8 What You Must Implement  Blinn-Phong lighting  Implement shadow ray model  Modify most  Ambient, diffuse, specular RayTracer.cpp  Modify scene/material.cpp  Implement triangle mesh  Point light distance intersection attenuation  Including normal  Inverse squared distance interpolation fall-off  Modify  Modify scene/light.cpp SceneObjects/trimesh.cpp  Implement reflection and refraction rays  Modify most RayTracer.cpp
  • 9. CS 354 9 Extra Credit Embellishments  Spatial data structures  Speed up the ray traces  Texture mapping  Anti-aliasing  Cast multiple rays per pixel  Lighting effects  Normal mapping, bump mapping, environment mapping
  • 10. CS 354 10 Other Project 4 Scenes recursive_depth.ray turtle.ray hitchcook.ray cone.ray spheres.ray
  • 11. CS 354 11 Debugging Display
  • 12. CS 354 12 Two Versions of Rendering Equation Occlusion (G) is zero o Le (x, ω , λ , t ) + Le (x, ω , λ , t ) + Lo (x, ω , λ , t ) = ∫ Ω f r (x, ω ′, ω , λ , t ) Li (x, ω ′, λ , t ) (−ω ′ • n) dω ′ Lo (x, ω , λ , t ) = ∫ f r (x, ωyx , ω , λ , t ) L(y, ωyx , λ , t ) G (x, y ) dy y∈Γ Integrate over hemisphere Integrate over all surface points
  • 13. CS 354 13 Photon Mapping  Two-pass global illumination algorithm  Developed by Henrick Jensen (1996)  Two passes  Randomly distribute photons around the scene  Called “photon map construction”  Render treating photons as mini-light sources  Capable of efficiently generating otherwise very expensive effects  Caustics  Diffuse inter-reflections, such as color bleed  Sub-surface scattering
  • 14. CS 354 14 Light Tracing  Trace rays from the light  Contribution rays accumulate image samples
  • 15. CS 354 15 Photon Mapping Examples without diffuse photo map caustics interreflection visualization sub-surface scattering diffuse interreflection
  • 16. CS 354 16 Global Illumination Often Gated by Ray Tracing Speed  Shooting rays tends to be the bottleneck  Why?  Lots of rays cast for quality  Shadow rays, lots for soft shadows  Reflection and refraction rays  Speeding up global illumination generally means speeding up tracing of rays  Shading operations can be expensive too  But rays involve data structure traversal
  • 17. CS 354 17 More bounces Recursive Rays  Reflections and refractions can spawn lots of rays Fewer bounces 17
  • 18. CS 354 18 Sufficient Shadow Ray Sampling
  • 19. CS 354 19 Distribution Ray Tracing  Soft shadows  Distribute shadow rays over light source region All shadow rays No shadow rays Some shadow rays hit light source, hit light source, hit light source, fully illuminated fully shadowed partially shadowed
  • 20. CS 354 20 Distribution Ray Tracing  Motion blur  Distribute rays over time Pool Balls Tom Porter RenderMan
  • 21. CS 354 21 Distribution Ray Tracing  Depth of field  Distribute rays across a discrete camera aperture No depth-of-field More rays Jittered depth-of-field More images for depth-of-field Even more rays
  • 22. CS 354 22 Acceleration Techniques Ray Tracing Acceleration Techniques Fast Fewer Generalized Intersections Rays Rays Statistical Beam tracing Faster Fewer optimizations ray-object ray-object for illumination Cone tracing convergence intersections intersections Pencil tracing Object bounding Bounding volume volumes hierarchies
  • 23. CS 354 23 Accelerating Ray Trace Intersection Operations  Two key optimizations 3. Exploit binary searching  Rather than linear searches 4. Group objects spatially  Discard hierarchically  Use quick-and-coarse tests…  …to avoid slow-and-exact intersection tests
  • 24. CS 354 24 Acceleration Structures: Bounding Volume Hierarchies  Build hierarchy of bounding volumes  Bounding volume of interior node has its children
  • 25. CS 354 25 Accelerate Ray Intersections  Traverse hierarchy to accelerate ray intersections  Intersect node content only if ray hits the bounding volume Skip intersection A, D, E, and F
  • 26. CS 354 26 Accelerate Ray Intersection Algorithm  Sort hits and detect early termination FindIntersection( Ray ray, Node node ) { // Find intersections with child node bounding volumes … // Sort intersections closest to farthest … // Process intersections, checking for early termination min_t = infinity; for each intersected child i { if (min_t < bv_t[i]) break; shape_t = FindIntersection(ray, child); if (shape_t < min_t) { min_t = shape_t; } } return min_t; // closest intersection }
  • 27. CS 354 27 Bounding Volumes  Axis-Aligned Bounding Boxes (AABB)  min (x,y,z) & max(x,y,z)  Trivial plane equations  Bounding spheres  Point and radius  Ray and sphere intersection is easy  Solving a quadratic equation  Oriented Bounding Box  Might have tighter bounds than AABB  Convex Polyhedron (Polytope)
  • 28. CS 354 28 Spatial Hierarchy  Uniform grid  Quadtree (2D) and Octree (3D)  Exactly four or eight children  Equal area/volume for each children  KD Tree  Two children, splitting in X, Y, or Z  Axis aligned splitting planes  Not necessarily equal area/volume  Binary Space Partitioning (BSP) Tree  Arbitrary splitting planes  Just two children
  • 29. CS 354 29 Space Subdivision Approaches Uniform grid Octree Quadtree Binary KD Tree Space Partitioning Tree
  • 30. CS 354 30 Uniform Grid Construction Preprocess scene 2. Find bounding box 3. Determine grid resolution
  • 31. CS 354 31 Uniform Grid Construction Preprocess scene 2. Find bounding box 3. Determine grid resolution 4. Place object in cell if its bounding box overlaps the cell
  • 32. CS 354 32 Uniform Grid Construction Preprocess scene 2. Find bounding box 3. Determine grid resolution 4. Place object in cell if its bounding box overlaps the cell 5. Check that object overlaps cell
  • 33. CS 354 33 Uniform Grid Traversal After processing… Traverse grid 3D line = 3D-DDA Digital Differential Analyzer Advantages Simple construction Simple traversal Disadvantage Poor at sparse or huge scenes
  • 34. CS 354 34 Binary Space Partitioning Tree  2D view of BSP
  • 35. CS 354 35 Binary Space Partitioning Trees  Recursive search  Partitioning plane has two nodes FindIntersection( Ray ray, Node node ) { if node is leaf { intersect ray with each object in node return closest object (or nil) } near = child of node in half space containing ray’s origin far = the other child hit = FindIntersection( ray, near ) if hit is null and ray intersections plane defined by node { hit = FindIntersection( ray, far ) } return hit; }
  • 36. CS 354 36 BSP Intersection with a Ray
  • 37. CS 354 37 Optimizing Bounding Hierarchies  Complex meshes need to be partitioned into bounding hierarchy [Saut, Sidobre, 2012]
  • 38. CS 354 38 Octree Building  Building octree from boundary representation
  • 39. CS 354 39 KD-tree  Like an Octree  But dividing planes aren’t necessarily in even octo squares  Tighter bounds [Mahmoud Zidan]
  • 40. CS 354 40 Close Cousin of Ray Tracing: Volume Rendering  Common task: visualization of volumetric data  Data arranged in 3D “voxel” grid  Voxel = volume element  Applications: medical, oil & gas exploration
  • 41. CS 354 41 Simple Case of Ray Casting  Rays are all coherent  GPU-oriented Volume rendering  Draw 3D textured polygons slicing through a 3D texture  Apply transfer function  Blend in ray order—use framebuffer blending
  • 42. CS 354 42 Transfer Function  Give viewer control of how volumetric data maps to color & opacity  Transfer functions enable visualization of otherwise difficult-to-understand mass of data
  • 43. CS 354 43 Volume Rendering Examples Head with clip planes Liver tumor
  • 44. CS 354 44 Next Class  Next lecture  Performance analysis  Considerations for tuning interactive graphics applications  Reading  Chapter 8, 455-460  Chapter 11, 578-601  Project 4  Project 4 is a simple ray tracer  Due Wednesday, May 2, 2012