Ray Casting and Rendering
Total Page:16
File Type:pdf, Size:1020Kb
MIT EECS 6.837 Computer Graphics Part 2 – Rendering Today: Intro to Rendering, Ray Casting © NVIDIA Inc. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. NVIDIA MIT EECS 6.837 – Matusik 1 Cool Artifacts from Assignment 1 © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 2 Cool Artifacts from Assignment 1 © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 3 The Story So Far • Modeling – splines, hierarchies, transformations, meshes, etc. • Animation – skinning, ODEs, masses and springs • Now we’ll to see how to generate an image given a scene description! 4 The Remainder of the Term • Ray Casting and Ray Tracing • Intro to Global Illumination – Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping – What makes materials look like they do? • Image-based Rendering • Sampling and antialiasing • Rasterization, z-buffering • Shadow techniques • Graphics Hardware © ACM. All rights reserved. This content is excluded from our Creative Commons [Lehtinen et al. 2008] license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 5 Today • What does rendering mean? • Basics of ray casting 6 © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. © Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. Scene 7 © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. This image is in the public domain. Source: openclipart © Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved. This content is excluded from our Creative Camera Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. Scene 8 © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. This image is in the public domain. Source: openclipart © Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. Pixels Camera Image Scene plane 9 Rendering = Scene to Image © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. Image This image is in the public domain. Source: openclipart © Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved. Camera This content is excluded from our Creative Commons Pixels license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. Image Scene plane 10 Rendering – Pinhole Camera © source unknown. All rights reserved. This content is excluded from our Creative Image Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. This image is in the public domain. Source: openclipart © Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved. This content is excluded from our Creative Commons Pixels license. For more information, see Each pixel corresponds to http://ocw.mit.edu/help/faq-fair-use/. one ray. We need to figure out which scene point each Scene one hits. 11 Rendering © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, Image see http://ocw.mit.edu/help/faq-fair-use/. This image is in the public domain. Source: openclipart © Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved. This content is excluded from our Creative Commons Pixels What’s the license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. color you put Scene in each pixel? 12 Rendering © source unknown. All rights reserved. This content is excluded from our Creative Image Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. This image is in the public domain. Source: openclipart © Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved. Pixel Color This content is excluded from our Creative Commons license. For more information, see Pixels http://ocw.mit.edu/help/faq-fair-use/. Determined by Lighting/Shading Scene 13 Rendering • “Rendering” refers to the entire process that produces color values for pixels, given a 3D representation of the scene • Pixels correspond to rays; need to figure out the visible scene point along each ray – Called “hidden surface problem” in older texts – “Visibility” is a more modern term – Also, we assume (for now) a single ray per pixel 14 Rendering • “Rendering” refers to the entire process that produces color values for pixels • Pixels correspond to rays; need to figure out the visible scene point along each ray – Called “hidden surface problem” in older texts – “Visibility” is a more modern term – Also, we assume (for now) a single ray per pixel • Major algorithms: Ray casting and rasterization • Note: We are assuming a pinhole camera (for now) 15 Questions? 16 Ray Casting • Ray Casting Basics • Camera and Ray Generation • Ray-Plane Intersection • Ray-Sphere Intersection 17 Ray Casting For every pixel Construct a ray from the eye For every object in the scene Find intersection with the ray Keep if closest 18 Shading For every pixel Construct a ray from the eye For every object in the scene Find intersection with the ray Keep if closest Shade 19 Shading = What Surfaces Look Like • Surface/Scene Properties N – surface normal L – direction to light V – viewpoint • Material Properties – Diffuse (matte) – Specular (shiny) – … • Light properties – Position – Intensity, ... Diffuse sphere Specular spheres • Much more! 20 Ray Casting vs. Ray Tracing • Let’s think about shadows... This image is in the public domain. Source: openclipart 21 Ray Casting vs. Ray Tracing ? “camera rays” This image is in the public domain. are rays from the Source: openclipart camera to the scene 22 Ray Casting vs. Ray Tracing ray from light to hit point is blocked, i.e., X point is in shadow This image is in the public domain. Source: openclipart 23 Ray Casting vs. Ray Tracing • Ray casting = eye rays only, tracing = also secondary Secondary rays are used for X testing shadows, doing reflections, refractions, etc. This image is in the public domain. Source: openclipart We’ll do all this a little later! 24 Secondary Rays Indirect illumination Reflections Refractions Shadows Caustics Courtesy of Henrik Wann Jensen. Used with permission. Henrik Wann Jensen Jensen Wann Henrik 25 Ray Tracing Reflections Courtesy of Henrik Wann Jensen. Used with permission. Reflections, refractions © Turner Whitted, Bell Laboratories. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. Caustics © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 26 Questions? 27 Ray Casting For every pixel Construct a ray from the eye For every object in the scene Find intersection with the ray Keep if closest Shade depending on light and normal vector N Finding the intersection point and normal is the central part of ray casting 28 Ray Representation • Origin – Point How would you • Direction – Vector represent a ray? – normalized is better • Parametric line – P(t) = origin + t * direction P(t) direction origin 29 Ray Representation • Origin – Point Another way to put the ray casting • Direction – Vector problem statement: – normalized is better Find smallest t > 0 • Parametric line such that P(t) lies on a surface in the – P(t) = origin + t * direction scene P(t) direction origin 30 Dürer’s Ray Casting Machine • Albrecht Dürer, 16th century © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 31 Dürer’s Ray Casting Machine • Albrecht Dürer, 16th century © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 32 Ray Casting • Ray Casting Basics • Camera and Ray Generation • Ray-Plane Intersection • Ray-Sphere Intersection 33 Cameras For every pixel Construct a ray from the eye For every object in the scene Find intersection with ray Keep if closest © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 34 Pinhole Camera • Box with a tiny hole • Perfect image if hole • Inverted image infinitely small • Similar triangles • Pure geometric optics • No depth of field issue (everything in focus) 35 Oldest Illustration • From Gemma Frisius, 1545 © source unknown. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 36 Also Called “Camera Obscura” Image courtesy of Wellcome Library, London. License: CC-BY-NC. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.