Ray Tracing Optimizations

Slides:



Advertisements
Similar presentations
GR2 Advanced Computer Graphics AGR
Advertisements

Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
CSE 681 Bounding Volumes. CSE 681 Bounding Volumes Use simple volume enclose object(s) tradeoff for rays where there is extra intersection test for object.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Ray Tracing Ray Tracing 1 Basic algorithm Overview of pbrt Ray-surface intersection (triangles, …) Ray Tracing 2 Brute force: Acceleration data structures.
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Ray Tracing CMSC 635. Basic idea How many intersections?  Pixels  ~10 3 to ~10 7  Rays per Pixel  1 to ~10  Primitives  ~10 to ~10 7  Every ray.
Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research.
CS 445 Greg Humphreys, Spring 2003 Ray Tracing 2: Acceleration.
CSE 381 – Advanced Game Programming Scene Management
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Ray Tracing Variants Distributed ray tracing Generalized rays Cone Tracing Beam Tracing Pencil.
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
CS447/ Realistic Rendering -- Solids Modeling -- Introduction to 2D and 3D Computer Graphics.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
Ray Tracing Acceleration Structures Solomon Boulos 4/16/2004.
Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures -Why.
Bounding Volume Hierarchies and Spatial Partitioning Kenneth E. Hoff III COMP-236 lecture Spring 2000.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
10/02/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Octrees.
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
Acceleration Digital Image Synthesis Yung-Yu Chuang 10/4/2005 with slides by Mario Costa Sousa and Pat Hanrahan.
Computer Graphics 2 Lecture x: Acceleration Techniques for Ray-Tracing Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
Data Structures for Computer Graphics Point Based Representations and Data Structures Lectured by Vlastimil Havran.
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
COMP 175: Computer Graphics March 24, 2015
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
1 Speeding Up Ray Tracing Images from Virtual Light Field Project ©Slides Anthony Steed 1999 & Mel Slater 2004.
David Luebke10/9/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
Graphics Graphics Korea University cgvr.korea.ac.kr Solid Modeling 고려대학교 컴퓨터 그래픽스 연구실.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
On a Few Ray Tracing like Algorithms and Structures. -Ravi Prakash Kammaje -Swansea University.
Visible-Surface Detection Jehee Lee Seoul National University.
12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
1 KIPA Game Engine Seminars Jonathan Blow Ajou University December 6, 2002 Day 10.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Interactive Rendering With Coherent Ray Tracing Eurogaphics 2001 Wald, Slusallek, Benthin, Wagner Comp 238, UNC-CH, September 10, 2001 Joshua Stough.
Fast BVH Construction on GPUs (Eurographics 2009) Park, Soonchan KAIST (Korea Advanced Institute of Science and Technology)
Duy & Piotr. How to reconstruct a high quality image with the least amount of samples per pixel the least amount of resources And preserving the image.
Interactive Ray Tracing of Dynamic Scenes Tomáš DAVIDOVIČ Czech Technical University.
第五课 Ray Tracing. Overview of the Section Why Ray Tracing? What is Ray Tracing? How to tracing rays? How to accelerating ray-tracing?
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
Ray Tracing II. HW1 Part A due October 10 Camera module Object module –Read from a file –Sphere and Light only Ray tracer module: –No shading. No reflection.
Advanced topics Advanced Multimedia Technology: Computer Graphics Yung-Yu Chuang 2006/01/04 with slides by Brian Curless, Zoran Popovic, Mario Costa Sousa.
CSE554Contouring IISlide 1 CSE 554 Lecture 5: Contouring (faster) Fall 2015.
CSE554Contouring IISlide 1 CSE 554 Lecture 3: Contouring II Fall 2011.
CSE554Contouring IISlide 1 CSE 554 Lecture 5: Contouring (faster) Fall 2013.
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
Ray Tracing Acceleration (5). Ray Tracing Acceleration Techniques Too Slow! Uniform grids Spatial hierarchies K-D Octtree BSP Hierarchical grids Hierarchical.
David Luebke3/12/2016 Advanced Computer Graphics Lecture 3: More Ray Tracing David Luebke
1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”
Ray Tracing Acceleration (1). Acceleration of Ray Tracing Goal: Reduce the number of ray/primitive intersections.
Solid Modeling Dr. Scott Schaefer.
3D Object Representations 2009, Fall. Introduction What is CG?  Imaging : Representing 2D images  Modeling : Representing 3D objects  Rendering : Constructing.
Ray Tracing Acceleration (3)
CSE 554 Lecture 5: Contouring (faster)
Bounding Volume Hierarchies and Spatial Partitioning
Collision Detection Spring 2004.
Bounding Volume Hierarchies and Spatial Partitioning
Modeliranje kompleksnih modelov
Real-Time Ray Tracing Stefan Popov.
Ray Tracing Acceleration Techniques
3D Object Representations
Binary and Ternary Search
Anti-aliased and accelerated ray tracing
CMSC 635 Ray Tracing.
Collision Detection.
Modeliranje kompleksnih modelov
Data Mining CSCI 307, Spring 2019 Lecture 23
Presentation transcript:

Ray Tracing Optimizations CS 655 Ray Tracing Optimizations

Ray Tracing Problems Slow Rays are discrete Compare every ray vs. every object Rays are discrete Aliasing problems No coherence taken advantage of We would like to optimize our ray tracer Efficiency Generality Quality

Optimizations Approaches to optimizing the ray tracer: Data structures Numerical methods Computational geometry Optics Statistical methods Distributed computing

Ray Tracing Optimizations Criteria for judging acceleration techniques: (from Kirk and Arvo) Simplicity Applicability All rays? All object types? Performance Recources Storage Multiple processors

What should we optimize Say intersections are 80% of the computation. Give an equation which describes the number of intersections. What should we do?

Intersection Optimizations Reduce intersection computation time Reduce the number of intersections Replace individual rays with a more general entity

Ray Tracing Acceleration Summary Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

Ray Tracing Acceleration Summary Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

Bounding Volumes Idea: Provide a volume that completely encloses an object, but which has a simpler intersection calculation than the actual object If the ray does not intersect the bounding volume, it will not intersect the object Complex intersections are replaced by simpler ones The number of intersection calculations increases, however Want the bounding volume as near to the object as possible Still a linear time complexity in the number of objects

Bounding Volume Example Bounding Sphere Bounding Sphere hit, object missed Bounding Sphere hit, object hit Bounding Sphere missed, object missed

Bounding Volumes Generally, either spheres or axis-aligned bounding volumes are used Simple to intersect against However, these may not provide close fits to the objects being bounded Several different bounding volume types have been used Tradoff – ease of intersection vs. object fit

Types of Bounding Volumes Sphere Axis-aligned Bounding Box Non-axis-aligned Bounding Box Intersection Of Slabs Union of Bounding Boxes Intersection of Bounding Sphere and Bounding Box

Ray Tracing Acceleration Summary Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

Hierarchical Bounding Volumes Bounding volumes by themselves try to reduce intersection time, but not the number of intersections A bounding volume hierarchy can reduce the number of intersections Place each object in its own bounding volume Group the bounding volumes hierarchically Intersection computations proceed down the hierarchy

Hierarchical Bounding Volumes Around a million triangles Log_2(1M) = about 20

Example Bounding Volume Hierarchy 4f 4e 3b 4c 3a 2a 2b 1 1 2a 2b 3a 4a 3b 4d 4c 4b 4e 4f

Bounding Volume Hierarchy Each leaf node is a single object Each interior node consists of a bounding volume and a list of pointers to its children nodes Process: Determine the bounding volume for each object in the scene (usually spheres or orthogonal parallelepipeds) Combine bounding volumes into a tree by selecting some of them and surrounding them with another bounding volume Repeat this process recursively until a bounding volume is generated that surrounds the entire scene

Bounding Volume Hierarchy Once the tree is built, trace rays, intersecting with the hierarchy. If one volume in the hierarchy is missed, you don’t need to intersect the ray with any children of that bounding volume Algorithm: Procedure BVH_Intersect(ray, node) Begin if node is a leaf then Intersect (ray, node_object) else if Intersect_P(ray, node_bounding_volume) then For each child of node BVH_Intersect(ray, child) End

Building the BVH Manually Automatically Difficult Simple n-ary tree Poor, since it doesn’t take the model into consideration Median-cut algorithm Better, but still doesn’t take full advantage of scene properties Heuristic tree search Good, if the heuristic is chosen well

Ray Tracing Acceleration Summary Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

3D Spatial Subdivision Techniques Start with a volume that bounds the entire environment Successively partition the volume into smaller pieces Objects are grouped based on volumes, rather than vice-versa Several approaches using this idea Uniform spatial subdivision Simple, doesn’t match objects well Non-uniform spatial subdivision More complex, but should give a better fit to the objects

Uniform Spatial Subdivision Voxels are all the same size, organized into a 3D grid Space subdivision is independent of the objects in the scene The “next voxel” calculation can be done very efficiently 3DDDA can be used (three-dimensional digital differential analyzer ) The speedup in the 3DDDA may or may not compensate for the loss of object locality gained in non-uniform methods

Uniform Spatial Subdivision 3 1 2 4 Start with a volume enclosing the entire scene Uniformly subdivide it until each subspace contains less than n objects 4 2 5 1 3

Non-uniform Spatial Subdivision Space is discretized into regions of varying size Several approaches Octree BSP Tree Median Split

Octrees An octree is created that approximates the scene The octree is subdivided as necessary based on the scene

BSP Trees Another non-uniform spatial subdivision technique is Binary Space Partitioning trees Idea: Split space into two subspaces (not axis aligned) based on the objects in the subspaces Check each subspace. If a subspace has more than n objects, split that subspace into two smaller subspaces Each subspace maintains a list of objects in it

BSP Trees 2a 2b 4 2 1 5 3 1 3

BSP Trees Divide a ray into two components – one on each side of the partitioning plane Check the nearest sub-ray first If it intersects another plane, subdivide the ray at the plane Intersect the nearest sub-ray against the objects in that space If no intersections, move to the next sub-ray, splitting the ray as necessary, then compute ray/object intersections

BSP Example Region 4 2a 2 4 Region 3 Region 2 5 3 1 3 1 Region 5 2b Ray is split at the 2b plane Region 1 is intersected against Ray is split at plane 1 Region 2 is intersected against Ray is split at plane 2a Region 3 is intersected against Region 4 is intersected against 4 2 Region 3 Region 2 5 1 3 1 3 Region 5 2b ray Region 1

Median Split BVH Technique An alternative method for creating a BVH is the “Median Split” technique Simpler than the Goldsmith and Salmon technique Not as object-centric, however Idea: Split space into two subspaces, based on the dimensions of the space Check each subspace If a subspace has several objects still in it, split it again

Median Split 2a 4 2 4a 1 8a 2b 5 6a 8b 5a 7a 1 3 3 8c 4b 6b 7b 5b

Median Split Pseudocode Surround all of the objects in the scene in an axis-aligned bounding box. Determine the largest magnitude extent of the bounding box. Subdivide the bounding box at the middle of the box, in the coordinate direction determined by the extent from step 2. If the level of subdivision is less than m (for m something like 20 or so), and the number of objects in the space is greater than n, (n being some small number like 1 or 5 or 10 or so), subdivide that sub-space by repeating steps 2 through 4 on the sub-space. For each subspace in the final divided space, maintain a list of those objects associated with that sub-space.

Median Split With the bounding volume subspaces determined, ray tracing proceeds: Send out a ray Determine which subspace is first hit Compute intersections with all objects associated with that subspace If an intersection exists, report the first intersection If no intersection, proceed to the next subspace hit by the ray and repeat this process

Ray Tracing Acceleration Summary Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

Directional Techniques Another approach at reducing the number of ray/object intersections is to exploit directional information Move processing to a higher level i.e. rather than on a per ray basis, move computation to a group of rays These techniques typically require large amounts of storage

Direction Cube Axis aligned cube centered at (0, 0, 0) with edges of length 2 Cube is placed on the ray origin A ray can now be represented by a face and a (u,v) coordinate on that face Ray

Direction Cube The direction cube faces are subdivided into smaller sub-faces Can be either uniform or non uniform Each direction cell defines an infinite skewed pyramid with its apex at the origin and its edges through cell corners

Direction Cube Given the subdivided cube we can determine which cell is pierced by each ray Determine the dominant axis of the ray to get the intersection face Determine the (u, v) coordinate Determine which cell this (u, v) point is in Each cell keeps a list of candidate intersection objects based on direction neighborhoods Is this practical for standard rays?

The Light Buffer Used to accelerate shadow calculations using the directional idea Assumes point light sources Idea: Each light source is given a uniformly subdivided direction cube. Prior to ray tracing, each object is projected onto each direction cube. Each cell contains a list of all objects that project to that cell. For shadow computations, determine which cell is intersected by the shadow ray, and only intersect objects in that cell’s list

The Light Buffer Find where ray intersects light buffer Intersect against objects in that cell’s list Light Buffer Shadow Ray Point light source Incoming Ray

Ray Tracing Acceleration Summary Acceleration Techniques Faster Intersections Fewer Rays Generalized Rays Faster Ray/Object Intersections Fewer Ray/Object Intersections Object Bounding Volumes Efficient intersectors Bounding Volume Hierarchies Space Subdivision Directional Techniques Adaptive Tree Depth Control Statistical Optimizations Beam Tracing Cone Pencil

Beam Tracing Funkhouser et al., “A Beam Tracing method for interactive architectural acoustics” in J. of Acoust. Soc. of Am. 115(2) 2004