ECS 298 Photorealistic Image Synthesis Rendering Acceleration Brian Budge Center for Image Processing and Integrated Computing Computer Science Department.

Slides:



Advertisements
Similar presentations
CSG and Raytracing CPSC 407.
Advertisements

GR2 Advanced Computer Graphics AGR
Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Restart Trail for Stackless BVH Traversal Samuli Laine NVIDIA Research.
Exponential Functions Logarithmic Functions
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
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.
CS 445 Greg Humphreys, Spring 2003 Ray Tracing 2: Acceleration.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
Computational Support for RRTs David Johnson. Basic Extend.
Ray Tracing Acceleration Structures Solomon Boulos 4/16/2004.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
Introduction to Volume Rendering Presented by Zvi Devir.
1cs533d-term Notes  list Even if you’re just auditing!
Bounding Volume Hierarchies and Spatial Partitioning Kenneth E. Hoff III COMP-236 lecture Spring 2000.
ECS 298 Photorealistic Image Synthesis course overview Brian Budge Center for Image Processing and Integrated Computing Computer Science Department University.
How to build your own computer And why it will save you time and money.
Estruturas de Dados Espaciais MC-930 MO-603. Speeding Up Ray Tracing.
Please open your laptops, log in to the MyMathLab course web site, and open Daily Quiz 18. You will have 10 minutes for today’s quiz. The second problem.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
Hidden Surface Removal
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.
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.
Finding dense components in weighted graphs Paul Horn
The Visibility Problem In many environments, most of the primitives (triangles) are not visible most of the time –Architectural walkthroughs, Urban environments.
David Luebke10/9/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
On a Few Ray Tracing like Algorithms and Structures. -Ravi Prakash Kammaje -Swansea University.
Visible-Surface Detection Jehee Lee Seoul National University.
IT253: Computer Organization
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
MA 1128: Lecture 17 – 6/17/15 Adding Radicals Radical Equations.
Real-time Graphics for VR Chapter 23. What is it about? In this part of the course we will look at how to render images given the constrains of VR: –we.
1 KIPA Game Engine Seminars Jonathan Blow Ajou University December 6, 2002 Day 10.
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)
CAP4730: Computational Structures in Computer Graphics
Lecture 11 Page 1 CS 111 Online Virtual Memory A generalization of what demand paging allows A form of memory where the system provides a useful abstraction.
Clustering Prof. Ramin Zabih
Sorting: Implementation Fundamental Data Structures and Algorithms Klaus Sutner February 24, 2004.
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.
Ray Tracing Optimizations
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
1 Taking Notes. 2 STOP! Have I checked all your Source cards yet? Do they have a yellow highlighter mark on them? If not, you need to finish your Source.
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
Algebra Tiles How to sort, making the equation smaller and easier: 2x+1x+3 to 3x+3 How to make zero pairs, 1x+-1x=0, then take them away from the equation.
Ray Tracing Acceleration (1). Acceleration of Ray Tracing Goal: Reduce the number of ray/primitive intersections.
Ray Tracing Acceleration (3)
Bounding Volume Hierarchies and Spatial Partitioning
Week 9 - Monday CS 113.
Bounding Volume Hierarchies and Spatial Partitioning
Deformable Collision Detection
Real-Time Ray Tracing Stefan Popov.
Ray Tracing Acceleration Techniques
Anti-aliased and accelerated ray tracing
CMSC 635 Ray Tracing.
Deformable Collision Detection
Anti-aliased and accelerated ray tracing
Presentation transcript:

ECS 298 Photorealistic Image Synthesis Rendering Acceleration Brian Budge Center for Image Processing and Integrated Computing Computer Science Department University of California, Davis

Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Overview Why do we need acceleration? Box/Bounding Box intersection Sub-linear acceleration via bounding volume hierarchies Sub-linear acceleration via space partitioning Mailboxing Common code optimizations

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Acceleration: Why do we need it? The methods we use take a long time It can take several hours or even days to compute a realistic image Brute force is pretty stupid

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Meet the bounding box, your new best friend We need a bounding volume Two come to mind immediately – sphere and box Why these? Because the intersection tests are fast. Only need a boolean test – do we hit the bounding volume? Why choose one over the other? –Need to try to bound objects closely Obviously, spheres bound spheres best and boxes bound boxes best Worst case: polygon. Boxes much better for polygons Oh, I should mention, we’re talking about axis aligned boxes

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Bounding box intersection test The best current bbox test is one based off of Brian Smitt’s work, by Amy Williams Makes use of IEEE floating point rules to eliminate redundant conditionals Basically it’s three slab intersections, one in X, one in Y, and one in Z If the parametric value t is valid for all three slab intersections, there is an intersection Especially if you end up using a BVH, you should get her code (it’s online – I’ll provide the URL)

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Bounding Volume Hierarchies (BVH) This is probably the easiest acceleration structure to write Sometimes it even works okay when it’s broken Starts being faster than naïve testing after just a handful of objects Like I said before, sphere’s are okay, but I’d recommend axis aligned bounding boxes Let’s look at a 2D example

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Notes… We can see problems here already –Overlap is a potential killer Can get better or worse builds of the same data –Alternate x,y,z –Each alteration choose best x,y,z –Try some magical function to optimize the whole thing –Also, can try different levels of termination

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Spatial subdivision Lots of data structures for spatial subdivision Uniform Grid (and Hierarchical Grid) Octree BSP Tree Kd Tree

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Uniform Grid Uniform Grids are the best data structure for: –Uniformly spread objects –Small self-contained objects Example of a good scene: Millions of little spheres randomly distributed in a cube Example of a bad scene: A room with 4 walls, a floor and a ceiling

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Building a uniform grid Easiest way is to make bounding boxes for each object, and place the object in all grid voxels that overlap with the bounding box Decide the grid layout by –Approximating the number of objects in each direction Shirley has a reasonable heuristic in his book (also has some code) Want to try to have few object in each voxel, but also want few empty voxels

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Traversing a uniform grid Algorithm called 3D-DDA Can end up being painful if there are lots of objects in each voxel Seidel suggests using a hierarchical grid 2 levels deep to eliminate a bunch of this

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Octrees I could probably have many of you explain this Octrees are better than uniform grids for many scenes Not so much of a dependency on uniformity Traversal isn’t as fast, but there could be a lot less to traverse (making it faster)

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Building an Octree Start with a bounding box of all your objects If there are enough objects inside, split space into 8 uniformly sized voxels Recursively descend and decide if each of your new voxels should be split into 8 Could be split into 8 non-uniform voxels, but this is complicated, and traversal would be much harder Again, you’d probably use bounding boxes for each object to decide if the object is within a voxel

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Traversing an Octree Much more time consuming than uniform grid Lots of ways to do it What is most efficient? Not sure. Quite honestly, I haven’t implemented this See ray tracing news for a HUGE overview of this topic

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization BSP Trees BSP trees are binary space partitioning trees They do exactly what they say: split space into two pieces General BSP trees can have arbitrarily aligned polygons splitting up space This allows for the best possible linear split of space (could do better if we allowed splitting space by trimmed NURBS or something)

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization BSP Trees (continued) There are problems with generalized BSP trees that cause most people not to want to use them It is probably an NP-complete problem to split up space in the best possible case That’s okay – for other data structures, same thing But the problem is that even finding good heuristics for good partitioning is difficult (Note that BSP trees work great if all you have is triangles – good algorithms for splitting triangles for best-case partitioning exist)

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Kd-trees Special case of BSP tree – axis aligned Kd-trees seem to be one of the best data structures for ray tracing Traversal is extremely fast – testing intersection against the plane is trivial as it is solving a parametric equation for one variable More truly logarithmic than bounding volume hierarchy, since there is early out

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Building Kd-trees This part is the pain in the butt Getting a good partitioning can be hard Note that you don’t want your partition to go through many objects, since those need to be duplicated on both sides of the split Many heuristics out there for building one of these. I’m not sure which is best, but maybe we should have a look at Havran’s work (best efficiency scheme project)

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Which one is best? They all have their benefits I believe that in the general case where things will tend to be clustered, the trees win out Seems that if you can get a good partitioning, kd-trees are the best because of their easy fast traversal (and did I mention low memory overhead?) Different scenes will be good with different schemes

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Which one is best? (continued) We could implement them all, and try them on all scenes ;-) Yeah right Implement a few and know when they work well The cool part is that you can treat an acceleration scheme the same as an object This makes it easy to nest acceleration schemes, which is very very good

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Mailboxing So when you’re traversing spatial partitioning data structures, you might possibly intersect the same object over and over (if it lies in more than one voxel) Mailboxing keeps track of this. When you encounter an object, check to see if you’ve already hit it at some point! Doing this cleverly can reduce running time pretty dramatically in real scenes where overlap is common

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Mailboxing (continued) I’m not a huge fan of mailboxing though Reason being that it is hard to parallelize Well, not hard really – too big. You’re keeping around to much data for each ray. Just too heavyweight Possible research topic: Some kind of caching scheme. It would be a lot of toying around with cache sizes and replacement schemes

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Other optimizations One that I use is to keep track of the interval where the ray is valid If you hit an object at t=20, there’s no point searching past that point! Likewise, you can avoid self intersection by having an interval (epsilon,infinity) Can use a special memory allocator (preferably one that is already written and tested )

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Code optimization Remember Knuth: Premature optimization is evil! However, in bottleneck situations, it can be extremely important Remember that 90% of the time is spent in 10% of the code Optimize only what you need to for the greatest benefit!

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Code optimization (continued) Remember that conditionals are not the same as arithmetic operations They are expensive if branch prediction is incorrect! So try to avoid them (can’t really do this that much) Also place the one that is most likely in the if condition, since that is what Intel chooses without other information

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Code optimization (continued) Early exit is usually a good idea Divides, sqrt, and trig functions are expensive If you’re dividing by the same value multiple times, do it once and multiply instead (could be hundreds of times faster) I use that one everywhere If possible delay expensive computations like sqrt until after a conditional –Example is when doing the quadratic equation

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization References Ray tracing news, specifically – Hans-Peter Seidel’s notes – Pete Shirley’s book –Pete Shirley and Russel Morley, Realistic Ray Tracing, 2003, AK Peters Amy Williams’ paper and code – Havran’s Best Efficiency Project – Matt Pharr and Greg Humphries’ book – good info on kd-trees and mailboxing –I have this in printed form that can be borrowed

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Additional Info I need you guys to sign up for presentations! They start Tuesday It’ll be tricky to get everyone signed up for separate lectures Fill out the sheet after class Class web page is at Should be more filled in by tomorrow

University of California, Davis Visualization and Graphics Research Group CIPIC Hardware Flow Visualization Scene file format After class, I’d like to get together and decide on a scene file format We will need something user editable, and yet not ridiculous for real scenes Mine currently is something like this: Camera{ –Lens{ Pinhole (or thin lens, or fisheye) Aperture 8mm Etc… –} } Color red {0.8,0.5,0.6,0.4,0.3,0.2,0.1,0.1,0.1,0.1} Object{ –Type Trimesh –Location “my_mesh.tmf” –Material my_mat }