How does ray tracing work

how ray tracing works and introduction to computer graphics ppt
Dr.ShaneMatts Profile Pic
Dr.ShaneMatts,United States,Teacher
Published Date:23-07-2017
Your Website URL(Optional)
Comment
MIT EECS 6.837 Computer Graphics Ray Tracing Wojciech Matusik, MIT EECS Many slides from Jaakko Lehtinen and Fredo Durand Courtesy of Henrik Wann Jensen. Used with permission. 1 Henrik Wann Jensen 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 2 Earlier • Camera definitions – Perspective and orthographic – View coordinate system -1,1 – field of view, aspect ratio, etc. • Ray representation – origin + t direction – Generating rays based in image coordinates • Ray-geometry intersection – Planes, spheres, triangles (barycentric coordinates) – CSG – Transformations NVIDIA © 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/. 3 Today – Ray Tracing (Indirect illumination) Reflections Refractions Shadows (Caustics) Courtesy of Henrik Wann Jensen. Used with permission. 4 Henrik Wann Jensen Overview of Today • Shadows • Reflection • Refraction • Recursive Ray Tracing – “Hall of mirrors” 5 How Can We Add Shadows? For every pixel Construct a ray from the eye For every object in the scene Find intersection with the ray Keep if closest Shade 6 How Can We Add Shadows? color = ambienthit-getMaterial()-getDiffuseColor() for every light Ray ray2(hitPoint, directionToLight) ambient = k a Hit hit2(distanceToLight, NULL, NULL) diffuseColor = k d For every object object-intersect(ray2, hit2, 0) if (hit2-getT() = distanceToLight) color += hit-getMaterial()-Shade (ray, hit, directionToLight, lightColor) return color 7 Problem: Self-Shadowing color = ambienthit-getMaterial()-getDiffuseColor() for every light Ray ray2(hitPoint, directionToLight) Hit hit2(distanceToLight, NULL, NULL) For every object object-intersect(ray2, hit2, 0) epsilon) if (hit2-getT() = distanceToLight) color += hit-getMaterial()-Shade (ray, hit, directionToLight, lightColor) return color Bad Good Without epsilon With epsilon 8 Let’s Think About Shadow Rays • What’s special about shadow rays compared to eye rays? P R R d o 9 Let’s Think About Shadow Rays • What’s special about shadow rays compared to eye rays? P R R d o 10 Let’s Think About Shadow Rays • What’s special about shadow rays compared to eye rays? P R R d o 11 Let’s Think About Shadow Rays • What’s special about shadow rays compared to eye rays? – We do not need to find the closest intersection, any will do P R R d o 12 Shadow Optimization • We only want to know whether there is an intersection, not which one is closest • Special routine Object3D::intersectShadowRay() – Stops at first intersection 13 Questions? Courtesy of Henrik Wann Jensen. Used with permission. 14 Henrik Wann Jensen Overview of Today • Shadows • Reflection • Refraction • Recursive Ray Tracing 15 Mirror Reflection • Cast ray symmetric with respect to the normal • Multiply by reflection coefficient k (color) s Without epsilon • Don’t forget to add epsilon to the ray With epsilon 16 Perfect Mirror Reflection • Reflection angle = view angle – Normal component is negated – Remember particle collisions? • R = V – 2 (V · N) N N R V  V  R V N N N N V V 17 Amount of Reflection • Traditional ray tracing (hack) – Constant k s • More realistic (we’ll do this later): – Fresnel reflection term (more reflection at grazing angle) 5 – Schlick’s approximation: R()=R +(1-R )(1-cos ) 0 0 • Fresnel makes a big difference metal Dielectric (glass) 18 Questions? “Sphereflake” fractal Courtesy of Henrik Wann Jensen. Used with permission. 19 Henrik Wann Jensen Overview of Today • Shadows • Reflection • Refraction • Recursive Ray Tracing 20

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.