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

Similar documents
Computer Graphics. - Spatial Index Structures - Philipp Slusallek

Acceleration Data Structures

Accelerated Raytracing

Spatial Data Structures

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

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

Spatial Data Structures

Spatial Data Structures

Spatial Data Structures

Ray Tracing Acceleration Data Structures

Spatial Data Structures

Intersection Acceleration

Speeding Up Ray Tracing. Optimisations. Ray Tracing Acceleration

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

More Hidden Surface Removal

Accelerating Ray-Tracing

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

Recall: Inside Triangle Test

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

Improving Memory Space Efficiency of Kd-tree for Real-time Ray Tracing Byeongjun Choi, Byungjoon Chang, Insung Ihm

Lecture 11: Ray tracing (cont.)

SPATIAL DATA STRUCTURES. Jon McCaffrey CIS 565

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

Ray Intersection Acceleration

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

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

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

Ray Tracing Performance

CS 431/636 Advanced Rendering Techniques

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

Algorithms for GIS:! Quadtrees

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

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

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

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

Binary Trees

Computer Graphics. Bing-Yu Chen National Taiwan University

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

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

Accelerating Ray-Scene Intersection Calculations

Lecture 17: Solid Modeling.... a cubit on the one side, and a cubit on the other side Exodus 26:13

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

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

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

Solid Modeling. Ron Goldman Department of Computer Science Rice University

improving raytracing speed

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

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

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

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

Spatial Data Structures for Computer Graphics

Advanced Ray Tracing

Ray Intersection Acceleration

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

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

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

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

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

Bounding Volume Hierarchies. CS 6965 Fall 2011

Subdivision Of Triangular Terrain Mesh Breckon, Chenney, Hobbs, Hoppe, Watts

Organizing Spatial Data

Geometric data structures:

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

Stackless BVH Collision Detection for Physical Simulation

Stackless Ray Traversal for kd-trees with Sparse Boxes

CMSC 754 Computational Geometry 1

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

Ray Tracing Acceleration. CS 4620 Lecture 22

Ray Tracing Acceleration. CS 4620 Lecture 20

UNIVERSITY OF WATERLOO Faculty of Mathematics

Sung-Eui Yoon ( 윤성의 )

Lecture 2 - Acceleration Structures

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

Hidden Surface Elimination: BSP trees

Warped parallel nearest neighbor searches using kd-trees

SAH guided spatial split partitioning for fast BVH construction. Per Ganestam and Michael Doggett Lund University

Lecture 11 - GPU Ray Tracing (1)

Real Time Ray Tracing

In the previous presentation, Erik Sintorn presented methods for practically constructing a DAG structure from a voxel data set.

Previously... contour or image rendering in 2D

Geometric Structures 2. Quadtree, k-d stromy

Physically Based Rendering ( ) Intersection Acceleration

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

Trees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology

Ray Tracing: Intersection

Multi-way Search Trees. (Multi-way Search Trees) Data Structures and Programming Spring / 25

Universiteit Leiden Computer Science

CS535 Fall Department of Computer Science Purdue University

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

On the data structures and algorithms for contact detection in granular media (DEM) V. Ogarko, May 2010, P2C course

Hello, Thanks for the introduction

A Model to Evaluate Ray Tracing Hierarchies

kd-trees for Volume Ray-Casting

Ray Tracing with Sparse Boxes

Visible-Surface Detection Methods. Chapter? Intro. to Computer Graphics Spring 2008, Y. G. Shin

CSE 530A. B+ Trees. Washington University Fall 2013

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs

Shell: Accelerating Ray Tracing on GPU

CSG obj. oper3. obj1 obj2 obj3. obj5. obj4

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs

Transcription:

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

Jim Scott 2009 Spatial cceleration Structures: KD-Trees *Some portions of these slides are adapted from Philipp Slusallek (Saarland University) s Computer Graphics course. 2

Space partitioning Let s say we want to cast a ray into a scene and find the nearest object the ray intersects. What is the easiest way for us to do this? 3

Space partitioning Let s say we want to cast a ray into a scene and find the nearest object the ray intersects. What is the easiest way for us to do this? Loop through every object, return the closest one. 4

Space partitioning Let s say we want to cast a ray into a scene and find the nearest object the ray intersects. What is the easiest way for us to do this? Loop through every object, return the closest one. What if we have 00 million triangles? Intersection testing every single triangle for every single ray in every single path for every single iteration for every single pixel adds up to a lot of wasted computation Solution: space partitioning! 5

Space partitioning Let s say we want to cast a ray into a scene and find the nearest object the ray intersects. What is the easiest way for us to do this? Loop through every object, return the closest one. What if we have 00 million triangles? Intersection testing every single triangle for every single ray in every single path for every single iteration for every single pixel adds up to a lot of wasted computation We need a way to quickly determine what objects are in the space immediately surrounding a given point, i.e. where the ray is Solution: spatial partitioning! 6

Uniform Grid Partitioning What if we overlay a uniform voxel grid, assign each object to the grid cell it is in, and raymarch through the grid and intersect against only objects in the current grid cell? 7

Uniform Grid Partitioning Uniform grid partitioning is a good start, BUT, there are some potential problems: Memory bound can get out of hand rapidly, since the resolution of the grid has to be proportional to the scene size lot of space is potentially wasted if we have a teapot in a football stadium type scenario lso of no help whatsoever if we have a angry mob in a stadium type scenario What if objects span multiple voxels in the grid? 8

Octrees We can solve some of the problems with uniform grids by allowing cells to be hierarchically subdivided... 9

Octrees However, traversal for octrees can be quite complex, and we still have a lot of potentially wasted space Constructing octrees can also take a while, since geometry-heavy areas will need more time to refine 0

KD-Trees What if instead of using a uniform grid, we recursively split the scene with a split boundary based on the densities of each side of the split boundary?

KD-Trees What if instead of using a uniform grid, we recursively split the scene with a split boundary based on the densities of each side of the split boundary? 2

KD-Trees What if instead of using a uniform grid, we recursively split the scene with a split boundary based on the densities of each side of the split boundary? 3

KD-Trees What if instead of using a uniform grid, we recursively split the scene with a split boundary based on the densities of each side of the split boundary? 4

KD-Trees What if instead of using a uniform grid, we recursively split the scene with a split boundary based on the densities of each side of the split boundary? 5

KD-Trees: Explicit Example 2 3 4 8 7 5 6 6

KD-Trees: Explicit Example 2 3 4 8 7 5 6 7

KD-Trees: Explicit Example 2 3 4 B 8 7 5 6 8

KD-Trees: Explicit Example 2 3 4 B B 8 7 5 6 3,4 9

KD-Trees: Explicit Example 2 3 4 B B 8 7 5 6 5,6 3,4 20

KD-Trees: Explicit Example C 8 2 3 7 5 4 6 B C 7,8 5,6 B 3,4 2

KD-Trees: Explicit Example D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 We keep recursing until we have reached either a certain recursion depth or until we have reached a minimum number of objects per leaf node 22

KD-Tree Splitting Criteria How should we choose our splitting criteria? 23

KD-Tree Splitting Criteria What if we split right down the middle of the volume? Pro: Probability of hitting the left and right subtrees is equal Con: Does not take into account left and right costs 24

KD-Tree Splitting Criteria What if we split at the cost median? Pro: The left and right costs are equal Con: Does not take into account left and right hit probabilities 25

KD-Tree Splitting Criteria Cost optimized split: find splits such that the probability of hitting each child weighted by the cost of each child is equal Probability of hitting a node is proportional to surface area Good heuristic: surface area of a node multiplied by the number of objects in the node. This is the surface area heuristic. 26

Building good KD-Trees. Pick an optimum split axis 2. Select a set of candidate split locations (can be random, or use bounding box edges, etc) 3. Sort the candidate locations via the surface area heuristic 4. Pick the candidate split with the lowest weighted cost 5. Recurse on the new children nodes until leaf nodes are reached We want tall, stringy, narrow trees with a low number of objects per leaf and large empty cells Ideal depth and leaf size will depend on the given scene Internal nodes should contain a flag indicating leaf or internal status, a split axis, the split location, and pointers to the children 27

KD-Trees: Normal Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 28

KD-Trees: Normal Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 29

KD-Trees: Normal Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 Intersection Test: 3,4 30

KD-Trees: Normal Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 Intersection Test: 3,4 3

KD-Trees: Normal Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 Intersection Test: 3,4 32

KD-Trees: Normal Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 Intersection Test: 3,4,2,3 33

KD-Trees: Normal Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 Intersection Test: 3,4,2,3,7,8 34

KD-Trees: Normal Traversal Normally, KD-Tree traversal is implemented recursively, but on the GPU we have no stack and no recursion... 35

Stackless KD-Trees There are several possible ways to approach KD-Trees on the GPU: Create a pseudo-stack Rope-based KD-Trees (Popov et. al. 2007) Breadth-first-search construction (Zhou et. al. 2008) Finite state machine based 36

Stackless KD-Trees There are several possible ways to approach KD-Trees on the GPU: Create a pseudo-stack Rope-based KD-Trees (Popov et. al. 2007) Breadth-first-search construction (Zhou et. al. 2008) Finite state machine based Why is the pseudo-stack a bad idea? 37

Stackless KD-Trees There are several possible ways to approach KD-Trees on the GPU: Create a pseudo-stack Rope-based KD-Trees (Popov et. al. 2007) We ll look at this one today Breadth-first-search construction (Zhou et. al. 2008) Finite state machine based The other ones would make great final project ideas! 38

Stackless KD-Trees: Rope KD-Trees The goal of KD-Tree traversal is to create an ordered front-to-back list of objects that we need to intersection test Normally we do this by traversing up and down the KD-Tree, which requires a stack to keep track of where we have been in the tree What if we can get rid of the up traversal? 39

Stackless KD-Trees: Rope KD-Trees The goal of KD-Tree traversal is to create an ordered front-to-back list of objects that we need to intersection test Normally we do this by traversing up and down the KD-Tree, which requires a stack to keep track of where we have been in the tree What if we can get rid of the up traversal? Solution: have each node store pointers of its children or contents, ND store pointers to all six of its adjacent neighbours ( ropes ) 40

Stackless KD-Trees: Rope KD-Trees D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 If a face does not have an adjacent neighbour, point to NULL or a special empty node 4

Stackless KD-Trees: Rope KD-Trees D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 42

Stackless KD-Trees: Rope KD-Trees D? 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7? 6 2,3 What if a node has more than one adjacent neighbour for a face? 43

Stackless KD-Trees: Rope KD-Trees D? 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7? 6 2,3 Solution: choose the nearest common ancestor for the adjacent faces 44

Stackless KD-Trees: Rope KD-Trees Since we now know what nodes are adjacent to any given node, we can now traverse without having to unwind previous steps of our path! Upon reaching a leaf node, instead of going back up to the parent, we examine which face of the node the ray exits through and follow that rope to the neighbour node 45

Stackless KD-Trees: Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 46

Stackless KD-Trees: Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 47

Stackless KD-Trees: Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 48

Stackless KD-Trees: Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 49

Stackless KD-Trees: Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 50

Stackless KD-Trees: Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 5

Stackless KD-Trees: Traversal D 4 C B 2 3 C B 5,6 3,4 7,8 5 D 8 7 6 2,3 Our traversal has successfully visited all relevant leaf nodes without ever returning to a parent node that we already visited! 52