cg18 ray tracing.pptyu/teaching/cisc440_s15/... · 2015-04-20 · ray tracing • model: perceived...
TRANSCRIPT
![Page 1: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/1.jpg)
Ray Tracing
Courtesy of Prof. RasmussenCourtesy of Prof. Rasmussen
![Page 2: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/2.jpg)
Outline
• Recursive rays
– Reflection
– Refraction– Refraction
• HW #3 details
![Page 3: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/3.jpg)
Ray “tracing” for more realism
• Ray casting does not account for two important visual phenomena:
– Mirror-like surfaces should
court
esy
of
J. A
rvo
– Mirror-like surfaces should reflect other objects in scene
– Transparent surfaces should refract scene objects behind them
court
esy
of
J. A
rvo
Refraction
Glossy reflection
![Page 4: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/4.jpg)
Ray Tracing• Model: Perceived color at point p is an additive combination of
local illumination (e.g., Phong), reflection, and refraction effects
• Compute reflection, refraction contributions by tracingrespective rays back from p to surfaces they came from and evaluating local illumination at those locations
• Apply operation recursively to some maximum depth to get:– Reflections of reflections of ...– Reflections of reflections of ...– Refractions of refractions of ...– And of course mixtures of the two
from Hill
![Page 5: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/5.jpg)
Reflections
incident ray v reflected ray r
![Page 6: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/6.jpg)
Review: Reflectance direction for Phong model
• We calculated r from normal n, light direction l via:
(twice the projection of l onto n)
![Page 7: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/7.jpg)
Ray Tracing Reflection Formula
• The formula used for Phong illumination is not what we want here because our incident ray v is pointing in toward the surface, whereas the in toward the surface, whereas the light direction l was pointed awayfrom the surface
• So just negate the formula to get:
![Page 8: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/8.jpg)
Example: Reflections at depth = 0
![Page 9: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/9.jpg)
Example: Reflections at depth = 1
![Page 10: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/10.jpg)
Example: Reflections at depth = 2
![Page 11: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/11.jpg)
Example: Reflections at depth = 3
![Page 12: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/12.jpg)
• Definition: Bending of light ray as it crosses interface between media (e.g., air → glass or vice versa)
• Index of refraction (IOR) n for a medium: Ratio of speed of light in vacuum to that in medium (wavelength-dependent ⇒ prisms)– By definition, n ≥ 1
Refraction
– By definition, n ≥ 1 – Examples: nair (1.00) < nwater (1.33) < nglass (1.52)
θ1: Angle of incidence
θ2: Angle of refraction
courtesy ofWolfram
![Page 13: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/13.jpg)
Snell’s Law
• The relationship between the angle of incidence and the angle of refraction is given by:
courtesy ofWolfram
![Page 14: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/14.jpg)
Snell’s Law: Implications• Since θ ≈ sin θ over the range [0, π/2] and the
angle of refraction is given by
we can infer the following from their IORs:
divergence
we can infer the following from their IORs:n1 < n2 ⇒ θ2 < θ1 and n1 > n2 ⇒ θ2 > θ1
courtesy ofWolfram
So n1 < n2
in this image(like air to water)
convergence
![Page 15: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/15.jpg)
Refraction: Critical Angle
• Snell’s law says that n1 > n2
⇒ θ2 > θ1 (e.g., water to air), but biggest angle θ2 that exiting ray can be bent is π/2 (along tangent to the surface)
• Thus, no light escapes—all light is reflected internally—for θ1 greater than or equal to the critical angle of:for θ1 greater than or equal to the critical angle of:
courtesy of G. Kessler
n1
n2
θ2
θ1θcritical
![Page 16: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/16.jpg)
Critical Angle: Example
• Going from water (IOR = 1.33) to air (IOR = 1.00), we have:
courtesy of J. Alward
θcritical
![Page 17: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/17.jpg)
Computing the Transmission Direction t
v
n
n
m
v n1
n2
adapted from Hill
Total internal reflection happens when the term in the square root above isn’t positive, which is when
![Page 18: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/18.jpg)
Example: Refraction
![Page 19: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/19.jpg)
Ray Tracing Example (with texture mapping)
courtesy of J. Lee
![Page 20: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/20.jpg)
Ray Tracing: Recursion
from Hill
![Page 21: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/21.jpg)
Anatomy of shade_ray()
Local Phongillumination
make sure all channels are clamped to [0, 1] range
Figure outreflected/
refracted raydirection
and recurse
![Page 22: cg18 ray tracing.pptyu/Teaching/CISC440_S15/... · 2015-04-20 · Ray Tracing • Model: Perceived color at point pis an additive combination of local illumination (e.g., Phong),](https://reader035.vdocuments.mx/reader035/viewer/2022070721/5ee2df13ad6a402d666d1717/html5/thumbnails/22.jpg)
HW #3 (due May 4)
• Basic requirements– Complete shade_ray_diffuse()– Complete shade_ray_local(), which adds specular and shadow effects
– Complete reflection component of shade_ray_recursive()– Complete reflection component of shade_ray_recursive()– Add sphere intersection testing in intersect_ray_sphere()– Scene complexity and creativity
• Grad student requirements– Add support for refraction in shade_ray_recursive()– Add some version of adaptive supersampling, glossy
reflection, ambient occlusion, or another advanced distributed-ray technique
– Implement bounding spheres around objects to speed intersection calculations