Ray Tracing CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain https://en.wikipedia.org/wiki/Ray_tracing_%28graphics%29
Paths of Light http://software.intel.com/file/37491 2 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Paths of Light Light source http://software.intel.com/file/37491 3 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Paths of Light Light interacts with objects in scene http://software.intel.com/file/37491 4 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Paths of Light Image plane http://software.intel.com/file/37491 5 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Problem ?? Most light do not reach the camera http://software.intel.com/file/37491 6 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Forward Ray Tracing Trace rays from light to camera 7 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Backward Ray Tracing Trace rays from light to camera 8 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray Tracing Algorithm Trace a ray through each pixel • Intersect with geometry • Trace a shadow ray to the light • Shade the pixel • http://www.scratchapixel.com/lessons/3d-basic-rendering/introduction-to-ray-tracing/implementing-the-raytracing-algorithm 9 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray Tracing Algorithm Trace a ray through each pixel • Intersect with geometry • Trace a shadow ray to the light • Shade the pixel • Shadow if light not visible • http://www.scratchapixel.com 10 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Simple to implement • For a simple case: • http://www.scratchapixel.com/code.php?id=3&origin=/l essons/3d-basic-rendering/introduction-to-ray-tracing Few lines of code; already impressive 11 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Recursive Ray Tracing http://www.scratchapixel.com/images/upload/ray-tracing-refresher/rt-whitted-example.png? 12 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Whitted Ray Tracing T. Whitted, Communications of ACM, 1980 Render Time: 74 minutes 13 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Today: nVidia OptiX Render Time: 16 ms ! (60 fps): my Macbook Pro nVidia GTX M750 14 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Today: Realism http://images.povcomp.com/entries/images/105_main.jpg 15 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Today: Realism http://images.povcomp.com/entries/images/105_main.jpg 16 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Rasterizer Vs Ray-Tracing Rasterization for (each object in scene) drawObject(); 17 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Rasterizer Vs Ray-Tracing Rasterization for (each object in scene) drawObject(); Ray Tracing for (each pixel in image) sendRay(); 18 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Rasterization Vs Ray Tracing Rasterization for (each object in scene) drawObject(); Ray Tracing for (each pixel in image) sendRay(); 19 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Math for Ray Tracing 20 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray 21 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray 22 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray 23 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Generating a Ray No perspective transformation needed! 24 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray Intersection With a Sphere 25 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray Intersection With a Sphere 26 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray Intersection with a Sphere 27 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray Intersection with a Sphere 28 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray Intersection With a Sphere 29 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray Intersection With a Sphere 30 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Ray Intersection With a Sphere If t* < 0 then what ? 31 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Sphere Surface Normal 32 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Surface Normal http://designjk.files.wordpress.com/2011/12/teapot-decorated.png 33 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Shadow Ray / Light Ray 34 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Reflection Vector (Recap) ~ v i Note the directions ! http://graphics.stanford.edu/courses/cs148-10-summer/docs/2006--degreve--reflection_refraction.pdf 35 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Refraction Vector (Extra) ~ v i http://graphics.stanford.edu/courses/cs148-10-summer/docs/2006--degreve--reflection_refraction.pdf 36 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Shadows http://2.bp.blogspot.com/-2CpxoSdtNE8/T5nMClgobpI/AAAAAAAAAJ4/XgaZ168HpKg/s1600/P0008_I004.png 37 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Shadow Acne / Peter Panning Real life issues ! 38 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Object-Oriented Ray Tracing abstract class surface virtual hit-record hit(ray, t0, t1) virtual box bounding-box() struct hit-record vector3d position, normal surface hit-surface … abstract class material color evaluate(in-ray, normal, pos) … 39 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Recursive Ray Tracing color ray-trace(ray r) hit-record record = intersect(r); … if (record.hit-surface.is-reflective) ray reflected-ray = reflect(r,record.normal); color reflected-color = ray-trace(reflected-ray); compute-spectral-component( reflected-color); … 40 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Recursion Depth Lots of bounces Fewer bounces Avoid infinite recursion: stop after nth depth (typically n=5) 41 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Aliasing: Still Problematic! 42 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain http://www.hackification.com/2008/08/31/experiments-in-ray-tracing-part-8-anti-aliasing/
Distribution Ray Tracing Scatter rays to make ray tracing less crisp. 43 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Distribution Antialiasing Multiple rays per pixel 44 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Distribution Antialiasing Moiré pattern Patterned Noise http://upload.wikimedia.org/wikipedia/commons/f/fb/Moire_pattern_of_bricks_small.jpg 45 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Random Sampling We are less sensitive to granular noise http://en.wikipedia.org/wiki/File:Moire_pattern_of_bricks.jpg 46 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Not Enough Samples! ? ? ? 47 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Stratified (Jittered) Sampling One ray per box 48 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Accelerated Ray Tracing Bounding Volume Hierarchy (BVH) http://sopra.le-gousteau.de/images/2/2e/Bv_bvh_bspheres.jpg http://graphics.ucsd.edu/courses/rendering/2004/ssaha/index_files/finalbvh.jfif 49 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Accelerated Ray Tracing Bounding Volume Hierarchy (BVH) http://sopra.le-gousteau.de/images/2/2e/Bv_bvh_bspheres.jpg http://graphics.ucsd.edu/courses/rendering/2004/ssaha/index_files/finalbvh.jfif 50 CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain
Recommend
More recommend