Ray Tracing Acceleration. CS 4620 Lecture 22

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

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

Ray Tracing Acceleration. CS 4620 Lecture 20

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

Acceleration Data Structures

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

Acceleration Structures. CS 6965 Fall 2011

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

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

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

improving raytracing speed

Spatial Data Structures

Spatial Data Structures

Accelerating Ray-Tracing

Accelerating Ray Tracing

Accelerated Raytracing

Spatial Data Structures

Intersection Acceleration

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

Spatial Data Structures

Spatial Data Structures

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

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

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

Computer Graphics. - Spatial Index Structures - Philipp Slusallek

Using Bounding Volume Hierarchies Efficient Collision Detection for Several Hundreds of Objects

Bounding Volume Hierarchies. CS 6965 Fall 2011

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

Ray Tracing Acceleration Data Structures

Computer Graphics Ray Casting. Matthias Teschner

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

Ray Intersection Acceleration

Ray Intersection Acceleration

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

Homework 1: Implicit Surfaces, Collision Detection, & Volumetric Data Structures. Loop Subdivision. Loop Subdivision. Questions/Comments?

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

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

CS 431/636 Advanced Rendering Techniques

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

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

l Without collision detection (CD), it is practically impossible to construct e.g., games, movie production tools (e.g., Avatar)

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

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

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

Recall: Inside Triangle Test

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

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

Lecture 11. More Ray Casting/Tracing

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

The Traditional Graphics Pipeline

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

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

The Traditional Graphics Pipeline

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

CS 563 Advanced Topics in Computer Graphics Culling and Acceleration Techniques Part 1 by Mark Vessella

Lecture 11: Ray tracing (cont.)

Lecture 2 - Acceleration Structures

Holger Dammertz August 10, The Edge Volume Heuristic Robust Triangle Subdivision for Improved BVH Performance Holger Dammertz, Alexander Keller

CPSC GLOBAL ILLUMINATION

Advanced Ray Tracing

COMP 175: Computer Graphics April 11, 2018

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

Lesson 05. Mid Phase. Collision Detection

CS 563 Advanced Topics in Computer Graphics. by Emmanuel Agu

Collision Detection. Jane Li Assistant Professor Mechanical Engineering & Robotics Engineering

Bounding Volume Hierarchies

The Traditional Graphics Pipeline

CS535 Fall Department of Computer Science Purdue University

Exploiting Local Orientation Similarity for Efficient Ray Traversal of Hair and Fur

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

Lecture 4 - Real-time Ray Tracing

RAY-TRACING WITH UNIFORM SPATIAL DIVISION:PRACTICE

Speeding Up Ray Tracing. Optimisations. Ray Tracing Acceleration

CS 465 Program 5: Ray II

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

Collision Detection based on Spatial Partitioning

11 - Spatial Data Structures

MODELING AND HIERARCHY

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

CS 352: Computer Graphics. Hierarchical Graphics, Modeling, And Animation

CS 4620 Program 4: Ray II

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

From curves to surfaces. Parametric surfaces and solid modeling. Extrusions. Surfaces of revolution. So far have discussed spline curves in 2D

Collision and Proximity Queries

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

Recursion and Data Structures in Computer Graphics. Ray Tracing

CS 465 Program 4: Modeller

Transformation Hierarchies. CS 4620 Lecture 5

Motivation. Culling Don t draw what you can t see! What can t we see? Low-level Culling

3D Viewing. CS 4620 Lecture 8

Two Optimization Methods for Raytracing. W. Sturzlinger and R. F. Tobler

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

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

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

Collision Detection. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill

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

Ray tracing idea. Ray Tracing. Ray tracing algorithm. Plane projection in drawing. CS 465 Lecture 3

Ray Casting. COS 426, Spring 2015 Princeton University

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

Dual-Split Trees Supplemental Materials

Transcription:

Ray Tracing Acceleration CS 4620 Lecture 22 2014 Steve Marschner 1

Topics Transformations in ray tracing Transforming objects Transformation hierarchies Ray tracing acceleration structures Bounding volumes Bounding volume hierarchies Uniform spatial subdivision Adaptive spatial subdivision 2014 Steve Marschner 2

Transforming objects In modeling, we ve seen the usefulness of transformations How to do the same in RT? Take spheres as an example: want to support transformed spheres Need a new Surface subclass Option 1: transform sphere into world coordinates Write code to intersect arbitrary ellipsoids Option 2: transform ray into sphere s coordinates Then just use existing sphere intersection routine 2014 Steve Marschner 3

Intersecting transformed objects [S 2014 Steve Marschner 4

Implementing RT transforms Create wrapper object TrasformedSurface Has a transform T and a reference to a surface S To intersect: Transform ray to local coords (by inverse of T) Call surface.intersect Transform hit data back to global coords (by T) Intersection point Surface normal Any other relevant data (maybe none) 2014 Steve Marschner 5

Groups, transforms, hierarchies Often it s useful to transform several objects at once Add SurfaceGroup as a subclass of Surface Has a list of surfaces Returns closest intersection Opportunity to move ray intersection code here to avoid duplication With TransformedSurface and SurfaceGroup you can put transforms below transforms Voilà! A transformation hierarchy. 2014 Steve Marschner 6

A transformation hierarchy Transform Group: car Surface: body Transform Group: wheel assy. Surface: brake disc Transform Group: wheel Surface: tire Surface: hubcap Common optimization: merge transforms with groups 2014 Steve Marschner 7

Instancing Anything worth doing is worth doing n times If we can transform objects, why not transform them several ways? Many models have repeated subassemblies Mechanical parts (wheels of car) Multiple objects (chairs in classroom, ) Nothing stops you from creating two TransformedSurface objects that reference the same Surface Allowing this makes the transformation tree into a DAG (directed acyclic graph) Mostly this is transparent to the renderer 2014 Steve Marschner 8

Hierarchy with instancing Surface: body Transform Group: car Transform Transform Transform Group: wheel 2014 Steve Marschner 9

Hierarchies and performance Transforming rays is expensive minimize tree depth: flatten on input push all transformations toward leaves triangle meshes may do best to stay as group transform ray once, intersect with mesh internal group nodes still required for instancing can t push two transforms down to same child! 2014 Steve Marschner 10

TransformGroup { xf: A Mesh { v1, v2, v3, } TransformGroup { xf: B Sphere { radius: r } } } Mesh { xf: A v1, v2, v3, } Sphere { xf: BA radius: r } Mesh { Av 1, Av 2, Av 3, } Sphere { xf: BA radius: r } 2014 Steve Marschner 11

Ray tracing acceleration Ray tracing is slow. This is bad! Ray tracers spend most of their time in ray-surface intersection methods Ways to improve speed Make intersection methods more efficient Yes, good idea. But only gets you so far Call intersection methods fewer times Intersecting every ray with every object is wasteful Basic strategy: efficiently find big chunks of geometry that definitely do not intersect a ray 2014 Steve Marschner 12

Bounding volumes Quick way to avoid intersections: bound object with a simple volume Object is fully contained in the volume If it doesn t hit the volume, it doesn t hit the object So test bvol first, then test object if it hits [Glassner 89, Fig 4.5] 2014 Steve Marschner 13

Bounding volumes Cost: more for hits and near misses, less for far misses Worth doing? It depends: Cost of bvol intersection test should be small Therefore use simple shapes (spheres, boxes, ) Cost of object intersect test should be large Bvols most useful for complex objects Tightness of fit should be good Loose fit leads to extra object intersections Tradeoff between tightness and bvol intersection cost 2014 Steve Marschner 14

Implementing bounding volume Just add new Surface subclass, BoundedSurface Contains a bounding volume and a reference to a surface Intersection method: Intersect with bvol, return false for miss Return surface.intersect(ray) Like transformations, common to merge with group This change is transparent to the renderer (only it might run faster) Note that all Surfaces will need to be able to supply bounding volumes for themselves 2014 Steve Marschner 15

If it s worth doing, it s worth doing hierarchically! Bvols around objects may help Bvols around groups of objects will help Bvols around parts of complex objects will help Leads to the idea of using bounding volumes all the way from the whole scene down to groups of a few objects 2014 Steve Marschner 16

Implementing a bvol hierarchy A BoundedSurface can contain a list of Surfaces Some of those Surfaces might be more BoundedSurfaces Voilà! A bounding volume hierarchy And it s all still transparent to the renderer 2014 Steve Marschner 17

BVH construction example 2014 Steve Marschner 18

BVH construction example 2014 Steve Marschner 18

BVH construction example 2014 Steve Marschner 18

BVH construction example 2014 Steve Marschner 18

BVH ray-tracing example 2014 Steve Marschner 19

BVH ray-tracing example 2014 Steve Marschner 19

BVH ray-tracing example 2014 Steve Marschner 19

BVH ray-tracing example 2014 Steve Marschner 19

BVH ray-tracing example 2014 Steve Marschner 19

BVH ray-tracing example 2014 Steve Marschner 19

BVH ray-tracing example 2014 Steve Marschner 19

BVH ray-tracing example 2014 Steve Marschner 19

BVH ray-tracing example 2014 Steve Marschner 19

BVH ray-tracing example 2014 Steve Marschner 19

Choice of bounding volumes Spheres -- easy to intersect, not always so tight Axis-aligned bounding boxes (AABBs) -- easy to intersect, often tighter (esp. for axis-aligned models) Oriented bounding boxes (OBBs) -- easy to intersect (but cost of transformation), tighter for arbitrary objects Computing the bvols For primitives -- generally pretty easy For groups -- not so easy for OBBs (to do well) For transformed surfaces -- not so easy for spheres 2014 Steve Marschner 20

Axis aligned bounding boxes Probably easiest to implement Computing for primitives Cube: duh! Sphere, cylinder, etc.: pretty obvious Groups or meshes: min/max of component parts AABBs for transformed surface Easy to do conservatively: bbox of the 8 corners of the bbox of the untransformed surface How to intersect them Treat them as an intersection of slabs (see Shirley) 2014 Steve Marschner 21

Intersecting boxes 2014 Steve Marschner 22

Ray-box intersection Could intersect with 6 faces individually Better way: box is the intersection of 3 slabs Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 23

Ray-box intersection Could intersect with 6 faces individually Better way: box is the intersection of 3 slabs Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 23

Ray-box intersection Could intersect with 6 faces individually Better way: box is the intersection of 3 slabs Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 23

Ray-box intersection Could intersect with 6 faces individually Better way: box is the intersection of 3 slabs Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 23

Ray-slab intersection 2D example 3D is the same! (x max, y max ) (x min, y min ) Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 24

Ray-slab intersection 2D example 3D is the same! y max y min x min x max Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 24

Ray-slab intersection 2D example 3D is the same! (d x, d y ) t xmax t xmin (p x, p y ) x min x max Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 24

Ray-slab intersection 2D example 3D is the same! t ymax t xmax (d x, d y ) y max t ymin t xmin y min (p x, p y ) x min x max Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 24

Intersecting intersections Each intersection is an interval Want last entry point and first exit point t xenter t xexit x min x max Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 25

Intersecting intersections Each intersection is an interval Want last entry point and first exit point t xenter =min(t xmin,t xmax ) t xexit = max(t xmin,t xmax ) t xenter t xexit x min x max Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 25

Intersecting intersections Each intersection is an interval Want last entry point and first exit point t xenter =min(t xmin,t xmax ) t xexit = max(t xmin,t xmax ) t yenter y max t yexit y min Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 25

Intersecting intersections Each intersection is an interval Want last entry point and first exit point t xenter =min(t xmin,t xmax ) t xexit = max(t xmin,t xmax ) t yenter =min(t ymin,t ymax ) t yexit = max(t ymin,t ymax ) t yenter t yexit y max y min Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 25

Intersecting intersections Each intersection is an interval Want last entry point and first exit point t xenter =min(t xmin,t xmax ) t xexit = max(t xmin,t xmax ) t xenter t yenter y max t yenter =min(t ymin,t ymax ) t yexit = max(t ymin,t ymax ) t yexit t xexit y min x min x max Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 25

Intersecting intersections Each intersection is an interval Want last entry point and first exit point t xenter =min(t xmin,t xmax ) t xexit = max(t xmin,t xmax ) t xenter t yenter y max t yenter =min(t ymin,t ymax ) t yexit = max(t ymin,t ymax ) t yexit t xexit y min t enter = max(t xenter,t yenter ) t exit =min(t xexit,t yexit ) x min x max Cornell CS4620 Fall 2013 Lecture 3 2013 Steve Marschner 25

Building a hierarchy Usually do it top-down Make bbox for whole scene, then split into (maybe 2) parts Recurse on parts Stop when there are just a few objects in your box 2014 Steve Marschner 26

Building a hierarchy How to partition? Ideal: clusters Practical: partition along axis Center partition Less expensive, simpler Unbalanced tree (but may sometimes be better) Median partition More expensive More balanced tree Surface area heuristic Model expected cost of ray intersection Generally produces best-performing trees 2014 Steve Marschner 27

Regular space subdivision An entirely different approach: uniform grid of cells 2014 Steve Marschner 28

Regular grid example Grid divides space, not objects 2014 Steve Marschner 29

Traversing a regular grid 2014 Steve Marschner 30

Non-regular space subdivision k-d Tree subdivides space, like grid adaptive, like BVH 2014 Steve Marschner 31

Non-regular space subdivision k-d Tree subdivides space, like grid adaptive, like BVH 2014 Steve Marschner 31

Non-regular space subdivision k-d Tree subdivides space, like grid adaptive, like BVH 2014 Steve Marschner 31

Implementing acceleration structures Conceptually simple to build acceleration structure into scene structure Better engineering decision to separate them 2014 Steve Marschner 32