CS 6958 LECTURE 8 TRIANGLES, BVH February 3, 2014 Last Time 2 - - PowerPoint PPT Presentation

cs 6958 lecture 8 triangles bvh
SMART_READER_LITE
LIVE PREVIEW

CS 6958 LECTURE 8 TRIANGLES, BVH February 3, 2014 Last Time 2 - - PowerPoint PPT Presentation

CS 6958 LECTURE 8 TRIANGLES, BVH February 3, 2014 Last Time 2 derived ray-triangle intersection clarification: ray tracing inherently abstract in terms of object specification we can use any object once we define an algorithm


slide-1
SLIDE 1

CS 6958 LECTURE 8 TRIANGLES, BVH

February 3, 2014

slide-2
SLIDE 2

Last Time

 derived ray-triangle intersection  clarification:

 ray tracing inherently abstract in terms of object

specification

 we can use any object once we define an

algorithm for intersecting it with a ray (and computing localized normal direction)

2

slide-3
SLIDE 3

Ray Tracing Algorithm

foreach frame foreach pixel foreach sample generate ray intersect ray with objects shade intersection point

3

slide-4
SLIDE 4

Ray Tracing Algorithm

foreach frame foreach pixel foreach sample generate ray intersect ray with objects shade intersection point

4

foreach object t_new = object.intersect(ray) t_closest = min(t_closest, t_new)

slide-5
SLIDE 5

Ray Tracing Algorithm

/// Abstract Primitive class defining properties which are required for our ray tracer. /// For now, it specifies just ray-object intersection routine, but can be extended to /// support shadow rays, bounding volumes, etc class Primitive { public: virtual bool Intersect(const Ray &ray) const = 0; } /// Sphere primitive class Sphere : public Primitive { bool Intersect(const Ray &ray) const; } // Triangle primitive class Triangle : public Primitive { bool Intersect(const Ray &ray) const; }

5

slide-6
SLIDE 6

Ray Tracing Algorithm

/// Abstract Primitive class defining properties which are required for our ray tracer. /// For now, it specifies just ray-object intersection routine, but can be extended to /// support shadow rays, bounding volumes, etc class Primitive { public: virtual bool Intersect(const Ray &ray) const = 0; } /// Sphere primitive class Sphere : public Primitive { bool Intersect(const Ray &ray) const; } // Triangle primitive class Triangle : public Primitive { bool Intersect(const Ray &ray) const; }

6

Others:

  • Torus
  • Cone / Cylinder
  • Box / Rectangle
  • Extrusions
  • Surfaces of revolution
  • Metaballs
  • Iso-surface
  • Spline surfaces
  • Subdivision surfaces
slide-7
SLIDE 7

Others:

  • Torus
  • Cone / Cylinder
  • Box / Rectangle
  • Extrusions
  • Surfaces of revolution
  • Metaballs
  • Iso-surface
  • Spline surfaces
  • Subdivision surfaces

Ray Tracing Algorithm

/// Abstract Primitive class defining properties which are required for our ray tracer. /// For now, it specifies just ray-object intersection routine, but can be extended to /// support shadow rays, bounding volumes, etc class Primitive { public: virtual bool Intersect(const Ray &ray) const = 0; } /// Sphere primitive class Sphere : public Primitive { bool Intersect(const Ray &ray) const; } // Triangle primitive class Triangle : public Primitive { bool Intersect(const Ray &ray) const; }

7

Note! We can’t use inheritance, hence we are restricted to a single primitive

slide-8
SLIDE 8

Making Ray Tracing Faster

 faster rays

 packets (less overhead per ray, cache coherence)  CPU optimizations

 fewer rays

 adaptive super-sampling (less samples)

 faster ray-primitive intersection tests  fewer ray-primitive intersection tests

 acceleration structures

8

slide-9
SLIDE 9

Which Operation Most Costly?

foreach frame foreach pixel foreach sample generate ray intersect ray with objects shade intersection point

9

slide-10
SLIDE 10

Acceleration Structures

foreach frame foreach pixel foreach sample generate ray traverse ray through acceleration structure shade intersection point

 change O(n) to O(log n), n – objects in scene  intersecting ray with structure primitive must

be cheap

10

slide-11
SLIDE 11

Acceleration Structures

11

slide-12
SLIDE 12

Acceleration Structures

 Grid

12

slide-13
SLIDE 13

Acceleration Structures

 Grid  Octree

13

slide-14
SLIDE 14

Acceleration Structures

 Grid  Octree

14

slide-15
SLIDE 15

Acceleration Structures

 Grid  Octree  KD tree (K-dimensional)

15

slide-16
SLIDE 16

Acceleration Structures

 Grid  Octree  KD tree (K-dimensional)

16

slide-17
SLIDE 17

Acceleration Structures

 Grid  Octree  KD tree (K-dimensional)  BSP tree (Binary Space Partitioning)

17

slide-18
SLIDE 18

Acceleration Structures

 Grid  Octree  KD tree (K-dimensional)  BSP tree (Binary Space Partitioning)  BVH (Boundary Volume Hierarchy)

18

slide-19
SLIDE 19

Acceleration Structures

 Grid  Octree  KD tree (K-dimensional)  BSP tree (Binary Space Partitioning)  BVH (Boundary Volume Hierarchy)

19

slide-20
SLIDE 20

Acceleration Structures

 Grid  Octree  KD tree (K-dimensional)  BSP tree (Binary Space Partitioning)  BVH (Boundary Volume Hierarchy)

20

slide-21
SLIDE 21

Acceleration Structures

 Grid  Octree  KD tree (K-dimensional)  BSP tree (Binary Space Partitioning)  BVH (Boundary Volume Hierarchy)

21

slide-22
SLIDE 22

BVH Traversal - Idea

22

slide-23
SLIDE 23

BVH Traversal - Idea

23

slide-24
SLIDE 24

BVH Traversal - Idea

24

slide-25
SLIDE 25

BVH Traversal - Idea

25

slide-26
SLIDE 26

BVH Traversal - Idea

26

slide-27
SLIDE 27

BVH Traversal - Idea

27

slide-28
SLIDE 28

BVH Traversal - Idea

28

slide-29
SLIDE 29

BVH Traversal - Idea

29

slide-30
SLIDE 30

BVH Traversal - Idea

30

slide-31
SLIDE 31

BVH Traversal - Pseudocode

 description is recursive, but

TPs have small stack memory, so manage it

  • urselves

code will run faster

int stack[32]; // holds node IDs to traverse int sp = 0; // stack pointer into the above

31

slide-32
SLIDE 32

BVH Traversal - Pseudocode

current_node = root while(true) { if( ray intersects current_node ) { if( current_node._is_interior() ) { stack._push( current_node._right_child_id() ) current_node = current_node._left_child_id() continue } else intersect all triangles in leaf } if( stack._is_empty() ) break current_node = stack._pop() }

32

slide-33
SLIDE 33

BVH Traversal - Optimizations

 traverse closer child first  don’t traverse subtree if closer hit found

33

slide-34
SLIDE 34

Axis Aligned Bounding Box

 Let’s try to derive an intersection test  Box representation?

34

slide-35
SLIDE 35

End

35