Advanced Ray Tracing

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

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

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

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

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

CS 431/636 Advanced Rendering Techniques

Lecture 11: Ray tracing (cont.)

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

Ray Tracing. Last Time? Reading for Today. Reading for Today

Acceleration Data Structures

Intersection Acceleration

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

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

Spatial Data Structures

Spatial Data Structures

Distributed Ray Tracing

Spatial Data Structures

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

Spatial Data Structures

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

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

Spatial Data Structures

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

Ray Tracing. Quiz Discussion. Announcements: Final Projects. Last Time? Durer s Ray Casting Machine. Today

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

Local vs. Global Illumination & Radiosity

Ray Tracing. Last Time? Today. Ray Casting. Durer s Ray Casting Machine. Reading for Today

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Ray Tracing Acceleration Data Structures

Sung-Eui Yoon ( 윤성의 )

CPSC GLOBAL ILLUMINATION

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

Accelerated Raytracing

EECS 487: Interactive Computer Graphics

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

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

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

Ray Tracing. Announcements: Quiz. Last Time? Today. Durer s Ray Casting Machine. Ray Casting

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

Computer Graphics Ray Casting. Matthias Teschner

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

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

Ray Tracing. CS334 Fall Daniel G. Aliaga Department of Computer Science Purdue University

The Traditional Graphics Pipeline

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

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

Lecture 2 - Acceleration Structures

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

Anti-aliasing and Monte Carlo Path Tracing. Brian Curless CSE 457 Autumn 2017

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

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

The Traditional Graphics Pipeline

Ray Tracing. Johns Hopkins Department of Computer Science Course : Rendering Techniques, Professor: Jonathan Cohen

CEng 477 Introduction to Computer Graphics Fall 2007

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

The Traditional Graphics Pipeline

Sampling: Antialiasing - Intro

CS 465 Program 5: Ray II

Photorealism: Ray Tracing

Recursive Ray Tracing. Ron Goldman Department of Computer Science Rice University

Anti-aliasing and Monte Carlo Path Tracing. Brian Curless CSE 557 Autumn 2017

Lecture 11. More Ray Casting/Tracing

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

Ray tracing. EECS 487 March 19,

Anti-aliasing and Monte Carlo Path Tracing

MIT Monte-Carlo Ray Tracing. MIT EECS 6.837, Cutler and Durand 1

Ray Tracing. Outline. Ray Tracing: History

Accelerating Ray-Tracing

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

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

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

CS 4620 Program 4: Ray II

6.837 Introduction to Computer Graphics Final Exam Tuesday, December 20, :05-12pm Two hand-written sheet of notes (4 pages) allowed 1 SSD [ /17]

Distribution Ray Tracing

Distribution Ray-Tracing. Programação 3D Simulação e Jogos

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

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

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15

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

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

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

Introduction to Visualization and Computer Graphics

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

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

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

Ray Tracing Foley & Van Dam, Chapters 15 and 16

Ray Tracing. Kjetil Babington

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

Computer Graphics. Bing-Yu Chen National Taiwan University

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

VIII. Visibility algorithms (II)

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

Schedule. MIT Monte-Carlo Ray Tracing. Radiosity. Review of last week? Limitations of radiosity. Radiosity

Pipeline Operations. CS 4620 Lecture 10

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

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

Specular reflection. Lighting II. Snell s Law. Refraction at boundary of media

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

Ray Tracing Acceleration. CS 4620 Lecture 20

Transcription:

Advanced Ray Tracing Thanks to Fredo Durand and Barb Cutler The Ray Tree Ni surface normal Ri reflected ray Li shadow ray Ti transmitted (refracted) ray 51 MIT EECS 6.837, Cutler and Durand 1

Ray Tree Draw the ray-tree to depth 3 for the following initial ray (boxes are solid plastic, sphere is glass): N Basic Ray Tracing: Notes Intersection calculations are expensive, and even more so for more complex objects Not currently suitable for real-time (i.e., games) Only global illumination effect is purely specular reflection/transmission No diffuse reflection from other objects! Still using ambient term One remedy is radiosity (slow, offline, precompute Ambient Occlusion Shadows have sharp edges, which is unrealistic want to soften (coming up) 2

Phong shading Ambient Occlusion 3

Ambient Occlusion Ambient Occlusion 4

Ambient Occlusion Ray Tracing: Improvements Image quality: Anti-aliasing Supersampling: Shoot multiple rays per pixel (grid or jittered) Adaptive: More rays in areas where image is changing more quickly Efficiency: Bounding extents Idea: Enclose complex objects in shapes (e.g., sphere, box) that are less expensive to test for intersection Comping up 5

Supersampling Rasterize at higher resolution Regular grid pattern around each normal image pixel Irregular jittered sampling pattern reduces artifacts Combine multiple samples into one pixel via weighted average Box filter: All samples associated with a pixel have equal weight (i.e., directly take their average) Gaussian/cone filter: Sample weights inversely proportional to distance from associated pixel Regular supersampling Jittered with 2x supersampling frequency from Hill Adaptive Supersampling (Whitted s method) Shoot rays through 4 pixel corners and collect colors Provisional color for entire pixel is average of corner contributions If you stop here, the only overhead vs. center-of-pixel ray-tracing is another row, column of rays If any corner s color is too different, subdivide pixel into quadrants and recurse on quadrants from Hill 6

Adaptive Supersampling: Details surface OK Must subdivide Ray-tracing Acceleration Motivation Distribution Ray Tracing Soft shadows Antialiasing (getting rid of jaggies) Glossy reflection Motion blur Depth of field (focus) Bounding Boxes Spatial Acceleration Data Structures Flattening the Transformation Hierarchy 7

Shadows one shadow ray per intersection per point light source no shadow rays one shadow ray Shadows & Light Sources http://www.davidfay.com/index.php http://3media.initialized.org/photos/2000-10-18/index_gall.htm clear bulb frosted bulb http://www.pa.uky.edu/~sciworks/light/preview/bulb2.htm 8

Soft Shadows Multiple shadow rays to sample area light source Distribute rays over an interval light source one shadow ray lots of shadow rays Antialiasing Supersampling Multiple rays per pixel Distribute rays over an interval multiple rays per pixel point light jaggies w/ antialiasing area light 9

Reflection one reflection ray per intersection θ θ perfect mirror Glossy Reflection multiple reflection rays Distribute rays over an interval multiple reflection rays Justin Legakis θ θ polished surface 10

Motion Blur Sample objects temporally Distribute rays over an interval time Rob Cook Depth of Field Distribute rays over an interval - lens area film focal length Justin Legakis 11

Ray Tracing Algorithm Analysis Ray casting Lots of primitives Recursive Distributed Ray Tracing Effects Soft shadows Anti-aliasing Glossy reflection Motion blur Depth of field cost height * width * num primitives * intersection cost * size of recursive ray tree * num shadow rays * num supersamples * num glossy rays * num temporal samples * num focal samples *... can we reduce this? Ray-Tracing Taxonomy by James Arvo and David Kirk 12

Ray-tracing Acceleration Motivation Distribution Ray Tracing Bounding Boxes of each primitive of groups of transformed primitives Spatial Acceleration Data Structures Flattening the Transformation Hierarchy Acceleration of Ray Casting Goal: Reduce the number of ray/primitive intersections 13

Conservative Bounding Region First check for an intersection with a conservative bounding region Early reject Conservative Bounding Regions tight avoid false positives bounding sphere fast to intersect non-aligned bounding box axis-aligned bounding box arbitrary convex region (bounding half-spaces) 14

Intersection with Axis-Aligned Box t far t 2y t 2x y=y2 For all 3 axes, calculate the intersection distances t 1 and t 2 t near = max (t 1x, t 1y, t 1z ) t far = min (t 2x, t 2y, t 2z ) If t near > t far, box is missed t 1y t near t 1x x=x1 y=y1 x=x2 If t far < t min, box is behind If box survived tests, report intersection at t near Bounding Box of a Triangle (x 1, y 1, z 1 ) (x 0, y 0, z 0 ) (x max, y max, z max ) = (max(x 0,x 1,x 2 ), max(y 0,y 1,y 2 ), max(z 0,z 1,z 2 )) (x min, y min, z min ) (x 2, y 2, z 2 ) = (min(x 0,x 1,x 2 ), min(y 0,y 1,y 2 ), min(z 0,z 1,z 2 )) 15

Bounding Box of a Sphere r (x max, y max, z max ) = (x+r, y+r, z+r) (x, y, z) (x min, y min, z min ) = (x-r, y-r, z-r) Bounding Box of a Plane (x max, y max, z max ) = (+, +, + )* ax + by + cz = d n = (a, b, c) (x min, y min, z min ) = (-, -, - )* * unless n is exactly perpendicular to an axis 16

Bounding Box of a Group (x max_a, y max_a, z max_a ) (x max_b, y max_b, z max_b ) (x max, y max, z max ) = (max(x max_a,x max_b ), max(y max_a,y max_b ), max(z max_a,z max_b )) (x min_b, y min_b, z min_b ) (x min_a, y min_a, z min_a ) (x min, y min, z min ) = (min(x min_a,x min_b ), min(y min_a,y min_b ), min(z min_a,z min_b )) Bounding Box of a Transform (x max, y max, z max ) (x' max, y' max, z' max ) = (max(x 0,x 1,x 2,x 3,x 4,x 5,x 6,x 7 ), max(y 0,y 1,y 2,y 3,y 4,x 5,x 6,x 7 ), max(z 0,z 1,z 2,z 3,z 4,x 5,x 6,x 7 )) M (x 3,y 3,z 3 ) = M (x max,y max,z min ) (x 2,y 2,z 2 ) = M (x min,y max,z min ) (x 1,y 1,z 1 ) = M (x max,y min,z min ) (x min, y min, z min ) (x' min, y' min, z' min ) = (min(x 0,x 1,x 2,x 3,x 4,x 5,x 6,x 7 ), min(y 0,y 1,y 2,y 3,y 4,x 5,x 6,x 7 ), min(z 0,z 1,z 2,z 3,z 4,x 5,x 6,x 7 )) (x 0,y 0,z 0 ) = M (x min,y min,z min ) 17

Special Case: Transformed Triangle Can we do better? M Special Case: Transformed Triangle (x 0, y 0, z 0 ) M (x' 0,y' 0,z' 0 ) = M (x 0,y 0,z 0 ) (x max, y max, z max ) = (max(x' 0,x' 1,x' 2 ), max(y' 0,y' 1,y' 2 ), max(z' 0,z' 1,z' 2 )) (x 1, y 1, z 1 ) (x' 1,y' 1,z' 1 ) = M (x 1,y 1,z 1 ) (x' 2,y' 2,z' 2 ) = M (x 2,y 2,z 2 ) (x 2, y 2, z 2 ) (x min, y min, z min ) = (min(x' 0,x' 1,x' 2 ), min(y' 0,y' 1,y' 2 ), min(z' 0,z' 1,z' 2 )) 18

Ray-tracing Acceleration Motivation Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures Regular Grid Adaptive Grids Hierarchical Bounding Volumes Flattening the Transformation Hierarchy Regular Grid 19

Create Grid Find bounding box of scene Choose grid resolution (n x, n y, n z ) grid x need not = grid y Cell (i, j) grid y grid x Insert Primitives into Grid Primitives that overlap multiple cells? Insert into multiple cells (use pointers) 20

For Each Cell Along a Ray Does the cell contain an intersection? Yes: return closest intersection No: continue Preventing Repeated Computation Perform the computation once, "mark" the object Don't re-intersect marked objects 21

Don't Return Distant Intersections If intersection t is not within the cell range, continue (there may be something closer) Which Cells Should We Examine? Should we intersect the ray with each voxel? No! we can do better! 22

Where Do We Start? Intersect ray with scene bounding box Ray origin may be inside the scene bounding box Cell (i, j) t next_y t next_x t min t next_y t min t next_x Is there a Pattern to Cell Crossings? Yes, the horizontal and vertical crossings have regular spacing dt x = grid x / dir x dir x dir y dt y = grid y / dir y grid y grid x 23

What's the Next Cell? if ( t next_x < t next_y ) i += sign x t min = t next_x Cell (i, j) Cell (i+1, j) t next_x += dt x else j += sign y t min = t next_y t min t next_x t next_y t next_y += dt y (dir x, dir y ) dt y dt x if (dir x > 0) sign x = 1 else sign x = -1 if (dir y > 0) sign y = 1 else sign y = -1 What's the Next Cell? 3DDDA Three Dimensional Digital Difference Analyzer Similar to Bresenham s Line Rasterization! 24

Pseudo-Code create grid insert primitives into grid for each ray r find initial cell c(i,j), t min, t next_x & t next_y compute dt x, dt y, sign x and sign y while c!= NULL for each primitive p in c intersect r with p if intersection in range found return c = find next cell Regular Grid Discussion Advantages? easy to construct easy to traverse Disadvantages? may be only sparsely filled geometry may still be clumped 25

Ray-tracing Acceleration Motivation Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures Regular Grid Adaptive Grids Hierarchical Bounding Volumes Flattening the Transformation Hierarchy Adaptive Grids Subdivide until each cell contains no more than n elements, or maximum depth d is reached Nested Grids Octree/(Quadtree) 26

Primitives in an Adaptive Grid Can live at intermediate levels, or be pushed to lowest level of grid Octree/(Quadtree) Adaptive Grid Discussion Advantages? grid complexity matches geometric density Disadvantages? more expensive to traverse (especially octree) 27

Ray-tracing Acceleration Motivation Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures Regular Grid Adaptive Grids Hierarchical Bounding Volumes Flattening the Transformation Hierarchy Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse 28

Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse 29

Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse Bounding Volume Hierarchy Find bounding box of objects Split objects into two groups Recurse 30

Where to split objects? At midpoint OR Sort, and put half of the objects on each side OR Use modeling hierarchy Intersection with BVH Check sub-volume with closer intersection first 31

Intersection with BVH Don't return intersection immediately if the other subvolume may have a closer intersection Bounding Volume Hierarchy Discussion Advantages easy to construct easy to traverse binary Disadvantages may be difficult to choose a good split for a node poor split may result in minimal spatial pruning 32

Ray-tracing Acceleration Motivation Distribution Ray Tracing Bounding Boxes Spatial Acceleration Data Structures Flattening the Transformation Hierarchy Transformation Hierarchy group Group & Transformation hierarchy may not be a good spatial hierarchy transform A transform B transform C group transform transform D E Flatten transform A B group transform C D transform C E 33

Ray Marching Visualization sphere voxelization cells traversed primitive density entered faces Next time: ray-tracing at Pixar (or cancel class) 34