Ray Intersection Acceleration

Similar documents
Ray Intersection Acceleration

Reading Ray Intersection Chapter 2: Geometry and Transformations Acceleration Covers basic math and PBRT implementation: read on your own

Accelerating Ray-Tracing

Acceleration Data Structures

Accelerated Raytracing

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Accelerating Ray Tracing

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics

Accelerating Geometric Queries. Computer Graphics CMU /15-662, Fall 2016

Intersection Acceleration

Chapter 11 Global Illumination. Part 1 Ray Tracing. Reading: Angel s Interactive Computer Graphics (6 th ed.) Sections 11.1, 11.2, 11.

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

Spatial Data Structures

Ray Tracing. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

Spatial Data Structures

Computer Graphics. - Spatial Index Structures - Philipp Slusallek

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Topics. Ray Tracing II. Intersecting transformed objects. Transforming objects

Topics. Ray Tracing II. Transforming objects. Intersecting transformed objects

Spatial Data Structures

Spatial Data Structures

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Ray Tracing I: Basics

Parallel Physically Based Path-tracing and Shading Part 3 of 2. CIS565 Fall 2012 University of Pennsylvania by Yining Karl Li

Ray Tracing. Computer Graphics CMU /15-662, Fall 2016

Sung-Eui Yoon ( 윤성의 )

Ray Casting. Outline in Code. Outline. Finding Ray Direction. Heckbert s Business Card Ray Tracer. Foundations of Computer Graphics (Fall 2012)

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Acceleration. Welcome!

Questions from Last Week? Extra rays needed for these effects. Shadows Motivation

CS 431/636 Advanced Rendering Techniques

improving raytracing speed

Spatial Data Structures

CPSC GLOBAL ILLUMINATION

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Ray Tracing Acceleration. CS 4620 Lecture 20

Computer Graphics. Bing-Yu Chen National Taiwan University

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

Logistics. CS 586/480 Computer Graphics II. Questions from Last Week? Slide Credits

Ray Tracing Acceleration Data Structures

Lecture 2 - Acceleration Structures

CPSC / Sonny Chan - University of Calgary. Collision Detection II

Computer Graphics. - Ray-Tracing II - Hendrik Lensch. Computer Graphics WS07/08 Ray Tracing II

Acceleration. Digital Image Synthesis Yung-Yu Chuang 10/11/2007. with slides by Mario Costa Sousa, Gordon Stoll and Pat Hanrahan

Ray Casting. To Do. Outline. Outline in Code. Foundations of Computer Graphics (Spring 2012) Heckbert s Business Card Ray Tracer

Intro to Ray-Tracing & Ray-Surface Acceleration

Ray Tracing Acceleration. CS 4620 Lecture 22

COMPUTER GRAPHICS COURSE. Ray Tracing

Ray Genealogy. Raytracing: Performance. Bounding Volumes. Bounding Volume. Acceleration Classification. Acceleration Classification

Lecture 11: Ray tracing (cont.)

Speeding Up Ray Tracing. Optimisations. Ray Tracing Acceleration

Effects needed for Realism. Computer Graphics (Fall 2008) Ray Tracing. Ray Tracing: History. Outline

Bounding Volume Hierarchies. CS 6965 Fall 2011

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

EDAN30 Photorealistic Computer Graphics. Seminar 2, Bounding Volume Hierarchy. Magnus Andersson, PhD student

Solid Modeling. Thomas Funkhouser Princeton University C0S 426, Fall Represent solid interiors of objects

Accelerating Ray-Scene Intersection Calculations

Ray Tracing. Foley & Van Dam, Chapters 15 and 16

Ray Tracing Foley & Van Dam, Chapters 15 and 16

782 Schedule & Notes

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Ray Casting. 3D Rendering. Ray Casting. Ray Casting. Ray Casting. Ray Casting

VIII. Visibility algorithms (II)

Solid Modeling. Ron Goldman Department of Computer Science Rice University

Spatial Data Structures for Computer Graphics

Ray Casting. COS 426, Spring 2015 Princeton University

Ray Tracing with Spatial Hierarchies. Jeff Mahovsky & Brian Wyvill CSC 305

Computer Graphics Ray Casting. Matthias Teschner

Ray Tracing. Outline. Ray Tracing: History

Graphics 2009/2010, period 1. Lecture 8: ray tracing

Last week. Machiraju/Zhang/Möller

Advanced Ray Tracing

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

Ray Tracing: Intersection

Acceleration Structures. CS 6965 Fall 2011

Spatial Data Structures. Steve Rotenberg CSE168: Rendering Algorithms UCSD, Spring 2017

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

The Traditional Graphics Pipeline

Advanced 3D-Data Structures

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

Real Time Ray Tracing

A Model to Evaluate Ray Tracing Hierarchies

Physically Based Rendering ( ) Intersection Acceleration

MSBVH: An Efficient Acceleration Data Structure for Ray Traced Motion Blur

קורס גרפיקה ממוחשבת 2010/2009 סמסטר א' Rendering 1 חלק מהשקפים מעובדים משקפים של פרדו דוראנד, טומס פנקהאוסר ודניאל כהן-אור

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

CS 465 Program 5: Ray II

The Traditional Graphics Pipeline

Ray Tracer System Design & lrt Overview. cs348b Matt Pharr

Point Cloud Filtering using Ray Casting by Eric Jensen 2012 The Basic Methodology

Today. Acceleration Data Structures for Ray Tracing. Cool results from Assignment 2. Last Week: Questions? Schedule

Ray-tracing Acceleration. Acceleration Data Structures for Ray Tracing. Shadows. Shadows & Light Sources. Antialiasing Supersampling.

Acceleration Data Structures. Michael Doggett Department of Computer Science Lund university

CS354 Computer Graphics Ray Tracing. Qixing Huang Januray 24th 2017

Lecture 11. More Ray Casting/Tracing

B-KD Trees for Hardware Accelerated Ray Tracing of Dynamic Scenes

The Traditional Graphics Pipeline

Transcription:

Ray Intersection Acceleration CMPT 461/761 Image Synthesis Torsten Möller

Reading Chapter 2, 3, 4 of Physically Based Rendering by Pharr&Humphreys An Introduction to Ray tracing by Glassner

Topics today Review of ray-tracing acceleration approaches pbrt Object-space World-space 3

Review of ray-tracing 4

First imaging algorithm Directly derived from the synthetic camera model Follow rays of light from a point light source Determine which rays enter the lens of the camera through the imaging window Compute color of projection Why is this not a good idea? Machiraju/Zhang/Möller 5

Ray tracing When following light from a light source, many (reflected) rays do not intersect the image window and do not contribute to the scene reflected ray shadow ray rays eye pixel Image plane refracted ray Machiraju/Zhang/Möller Reverse the process Cast one ray per pixel from the eye and shoot it into the scene 6

Ray tracing: the basics A point on an object may be illuminated by Light source directly through shadow ray Light reflected off an object through reflected ray Light transmitted through a transparent object through refracted ray eye reflected ray pixel shadow ray refracted ray Machiraju/Zhang/Möller Image plane 7

Ray tracing: the algorithm for each pixel on screen determine ray from eye through pixel if ray shoots into infinity, return a background color if ray shoots into light source, return light color appropriately find closest intersection of ray with an object cast off shadow ray (towards light sources) if shadow ray hits a light source, compute light contribution according to some illumination model cast reflected and refracted ray, recursively calculate pixel color contribution return pixel color after some absorption Machiraju/Zhang/Möller Most expensive 8

Ray Tracing Shoot a ray through each pixel; Find first object intersected by ray Image plane Eye Compute ray. (More linear algebra.) Compute ray-object intersection. Spawn more rays for reflection and refraction

pbrt acceleration architecture 10

Ray Tracing Architecture Scene LRT Parse Sample Generator Film TIFF Image Primitives Camera Radiance Shape Rays intersect Eye rays Lights Material Surf Integrator Shadow, reflection, refraction rays

Optimizing Ray Tracing Main computation load is ray-object intersection 50-90% of run time when profiled Test for possible intersection before committing to computing intersections

Acceleration Strategies Fast/efficient intersection computation (single ray-single object) Not much leeway for acceleration Test fewer rays Trace fewer primary rays Fewer secondary rays Fewer intersection computations Avoid computations with far away objects Space partitioning Direction partitioning Intersection with thick rays Cone tracing Beam tracing 13

Pbrt and Intersections Primitive base class Shapes are subclasses of primitive Methods WorldBound CanIntersect Intersect IntersectP Refine First four return Intersection structures Last returns Primitives Primitives Shape Lights Material

Intersection Geometry Shape independent representation for intersections DifferentialGeometry Intersection::dg Point P Normal N Parametric (u,v) Partial derivatives Tangents: dpdu, dpdv change in normal: dndu, dndv

Object-based vs. World-based Common dichotomy in graphics objects situated in (object) space (world) space in which objects reside Bounding volumes are object-based Spatial Subdivision is world-based approach Sub-linear search

Object-space acceleration 17

Bounding Volumes Surround object with a simple volume Test ray against volume first Test object-space or world-space bound? (pros and cons) Cost model - N*cb + pi*n*co N (number of rays) is given pi fraction of rays intersecting bounding volume Minimize cb (cost of intersecting bounding volume) and co (cost of intersecting object) Reduce ray path Bounding sphere Difficult to compute good one Easy to test for intersection Reduce ray path Bounding box Easy to compute for given object More difficult to intersect

Pbrt s Bounding Boxes Virtual BBox ObjectBound() const=0; Virtual BBox WorldBound() const { return ObjectToWorld(ObjectBound()); } Bool BBox::IntersectP(const Ray &ray, float *hitt0, float *hitt1) const { }

Bounding Box Compute min/max for x,y,z 3 options Compute in world space Chance of ill fitting b-box Compute in object space and transform w/ object Object space b-box probably better fit than world space Need to intersect ray with arbitrary hexagon in world sp. Compute in object space and test in object space Inverse transform ray into object space

Bounding Sphere Find min/max points in x,y,z -> 3 pairs Use maximally separated pair to define initial sphere For each point If point is outside of current sphere, increase old sphere to just include new point

P R C R P P rad C P rad newrad = (R+rad)/2 R newc P P P newrad newrad newc C P R newc = P+(newrad/R)(C-P)

Bounding Slabs More complex to compute Better fit of object Use multiple pairs of parallel planes to bound object Can add more slabs to get tighter fit 2004 Pharr, Humphreys

Approximate Convex Hull Find highest vertex Find plane through vertex parallel to ground plane Find second vertex that makes minimum angle with first vertex and up vector Find third vertex that makes plane whose normal makes minimum angle with up vector 1989 Glassner More effort to compute, better fit

Bounding Volume Hierarchies Create tree of bounding volumes Children are contained within parent Creation preprocess From model hierarchy Automatic clustering Query intersect(node,ray,hits) { if( intersectp(node->bound,ray) if( leaf(node) ) intersect(nodeprims,ray,hits) else for each child intersect(child,ray,hits) } Return the closest of all hits!

Problem Subtrees overlap Does not contain all objects it overlaps Balance Tree Organization

Splitting strategies Choose the axis, that has the largest spread of midpoints Split based on the midpoint of the centroids of one axis Split in equal amounts Problem - overlaps 27

The Surface Area Heuristic cost of intersecting all N primitives: NX t isect (i) i=1 cost of splitting into groups N A +N B = N XN A t trav + p A t isect (a i )+ i=1 XN B i=1 t isect (b i ) t trav - traversal time of node p A / p B - prob that ray passes through each child node 28

The Surface Area Heuristic XN A t trav + p A i=1 t isect (a i )+ assume, that t isect (i) is the same for all primitives geometric probabilities XN B i=1 t isect (b i ) p(a B) = s A s B find the axis with the minimal SAH cost 29

30

BSP Trees Octree BSP tree KD tree

Example A D B B C C D A Leaves are unique regions in space Recursive search

Creating Spatial Hierarchies insert(node,prim) { if( overlap(node->bound,prim) ) } if( leaf(node) ) { if( node->nprims > MAXPRIMS && } else } node->depth < MAXDEPTH ) { subdivide(node); foreach child in node insert(child,prim) else list_insert(node->prims,prim); foreach child in node insert(child,prim) // Typically MAXDEPTH=16, MAXPRIMS=2-8

World-space acceleration 34

Spatial Enumeration Divide space into voxels Bucket sort objects in voxels they intersect Object goes into each voxel it touches Reuse results from one voxel calculation Determine voxels that a ray intersects Only deal with the objects in those voxels

Spatial Enumeration Identifying voxels hit is like a line drawing algorithm

Uniform Grids Preprocess scene Find bounding box

Uniform Grids Preprocess scene Find bounding box Determine grid resolution

Uniform Grids Preprocess scene Find bounding box Determine grid resolution Place object in cell if its bounding box overlaps the cell

Uniform Grids Preprocess scene Find bounding box Determine grid resolution Place object in cell if its bounding box overlaps the cell Check that object overlaps cell (expensive!)

Add Sorting If objects/voxels/cells are processed in front-to-back sorted order, stop processing when first intersection is detected e.g., process cells in bottom to top, left to right order and stop at first intersection

Uniform Grids Preprocess scene Traverse grid 3D line = 3D-DDA 6-connected line pbrt algorithm

Amanatides & Woo Algorithm J. Amanatides and A. Woo, "A Fast Voxel Traversal Algorithm for Ray Tracing", Proc. Eurographics '87, Amsterdam, The Netherlands, August 1987, pp 1-10.

A&W Algorithm

A&W Algorithm Results Rendering time for different levels of subdivision

Objects Across Multiple Voxels Mailboxes eliminate redundant intersection tests Objects have mailboxes Assign rays numbers check against objects last tested ray number Intersection within voxel 1989 Glassner

Hierarchical Spatial Subdivision Recursive subdivision of space 1-1 Relationship between scene points and leaf nodes Example: point location by recursive search (log time) Solves the lack-of-adaptivity problem DDA works Effective in practice

Comparison Scheme Spheres Rings Tree Uniform grid D=1 244 129 1517 D=20 38 83 781 Hierarchical grid 34 116 34 See A Proposal for Standard Graphics Environments, IEEE Computer Graphics and Applications, vol. 7, no. 11, November 1987, pp. 3-5

Questions? Scenes to render? Teapot in a stadium versus uniform distribution Constants can be important Adaptivity allows robustness Cache effects are important