1 / 39

An Introduction to Ray Tracing

An Introduction to Ray Tracing. Photo-Realism. Introduction. What is Ray Tracing? Ray Tracing is a global illumination based rendering method for generating realistic images on the computer In ray tracing, a ray of light is traced in a backwards direction.

nancy
Download Presentation

An Introduction to Ray Tracing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Introduction to Ray Tracing

  2. Photo-Realism

  3. Introduction • What is Ray Tracing? • Ray Tracing is a global illumination based rendering method for generating realistic images on the computer • In ray tracing, a ray of light is traced in a backwards direction. • We start from the eye or camera and trace the ray through a pixel in the image plane into the scene and determine what it intersects • The pixel is then set to the color values returned by the ray. • If the ray misses all objects, then that pixel is shaded the background color

  4. Overview • Forward Ray tracing • Rays from light source bounce of objects before reaching the camera • Computational wastage • Backward Ray tracing • Track only those rays that finally made it to the camera

  5. Ray Casting • Ray Casting • visible surfaces of objects are found by throwing (or casting) rays of light from the viewer into the scene • Ray Tracing • Extension to Ray casting • Recursively cast rays from the points of intersection

  6. Algorithm – Ray casting

  7. Ray Tracing • Sometimes a ray misses all objects

  8. Ray Tracing (contd.) • Sometimes a ray hits an object

  9. Ray Tracing (contd.) • Is the intersected point in shadow? • “Shadow Rays” to light source

  10. Ray Tracing (contd.) • Shadow rays intersect another object • First intersection point in shadow of the second object

  11. Ray Tracing (contd.) • Shadow rays intersect another object • First intersection point in shadow of the second object

  12. Ray Tracing (contd.) • Reflected ray generated at point of intersection • Tested with all the objects in the scene

  13. Ray Tracing (contd.) • Local illumination model applied at the point of intersection

  14. Ray Tracing (contd.) • Transparent object • Spawn a transmitted ray and test against all objects in the scene

  15. Requirements for Ray tracing • Compute 3D ray into the scene for each 2D image pixel • Compute 3D intersection point of ray with nearest object in scene • Test each primitive in the scene for intersection • Find nearest intersection • Recursively spawn rays from the point of intersection • Shadow Rays • Reflected rays • Transmitted rays • Accumulate the color from each of the spawned rays at the point of intersection

  16. Ray object intersection • Equation of a ray • “S” is the starting point and “c” is the direction of the ray • Given a surface in implicit form F(x,y,z) • plane: • sphere: • cylinder: • All points on the surface satisfy F(x,y,z)=0 • Thus for ray r(t) to intersect the surface • The hit time can be got by solving

  17. Ray object intersection • Ray polygon intersection • Plug the ray equation into the implicit representation of the surface • Solve for “t” • Substitute for “t” to find point of intersection • Check if the point of intersection falls within the polygon

  18. Ray object intersection • Ray sphere intersection • Implicit form of sphere given center (a,b,c) and radius r • Intersection with r(t) gives • By the identity • the intersection equation is a quadratic in “t” • Solving for “t” • Real solutions, indicate one or two intersections • Negative solutions are behind the eye • If discriminant is negative, the ray missed the sphere

  19. Adding shadows • P is not in shadow with respect to L1 • P is in the shadow of the cube with respect to L2 • “Self-shadowing” of P with respect to L3 • “Shadow Feelers” • Spawn a ray from P to the light sources • If there is an intersection of the shadow ray with any object then P is in shadow NOTE: Intersection should be between the point and light source and not behind light source

  20. Adding shadows • “Self-Shadowing” • Always an intersection of shadow feeler with object itself • Move start point of the shadow ray towards the eye by a small amount • No intersection with itself

  21. Reflection • Given surface normal “n” and incident ray “a” find the reflected ray “r”

  22. Reflection

  23. Reflection

  24. Reflection

  25. Reflection

  26. Refraction • Bending of light rays as it crosses interface between media having different refractive indices • Snell’s Law c1,c2 – Refractive index

  27. Refraction • Estimation the refracted ray T, given u and N (unit vectors) • If we assume that ni and nr are the refractive indices of the medium having the incoming ray and refracted ray respectively • Let and be the corresponding angle of incidence and refraction • Let k be a unit vector perpendicular to N • By Snell’s Law we have

  28. Refraction • Decomposing the incident ray (u) • Decomposing the refracted ray (T) • Solving for k from u

  29. Refraction • Substituting in T • From Snell’s Law • Solving for T

  30. Tree of Light • Contributions of light grows at each contact point • I is the sum of reflected component R1, transmitted component T1 and the local component L1 • Local component is the ambient, diffuse and specular reflections at Ph • R1 is the sum of R3, T3 and local L3 and so on ad infinitum

  31. Ray tracing flow Local Phong illumination Figure out reflected/ refracted ray direction and recurse

  32. Super-sampling • Ray tracing is a point-sampling process • Take discrete looks at the scene along individual rays passing through each pixel • Reduce aliasing due to this discrete signal sampling

  33. Super-sampling • Instead of shooting one ray per pixel, shoot four rays through the corners of a pixel • Color at the pixel is the average of the colors at each corners • Adaptive super-sampling (Whitted’s approach) • Compute the intensity variation between the four corners with the average • Shoot more rays through corners with higher intensity variation • Compute final color as a weighted average rather than the regular average

  34. Using Extents • Ray tracing is slow, performing the same functions. • Most of the time is spent in computing intersections • Each ray should be intersected with every object in the scene • Each ray, spawns out reflected/transmitted rays which have to be interested with the objects in the scene

  35. Using Extents • Extent of an object is a shape that encloses the object • Compute complicated intersections if and only if the ray hits the extent • Two shapes most commonly used as extents • Sphere – specified by a center and radius (C , r) • Box – specified by sides aligned to the coordinate axis

  36. References • Textbooks • F. S. Hill, “Computer Graphics Using OpenGL” • Commonly used ray tracing program (completely free and available for most platforms) • http://www.povray.org/ • Interesting Links • Interactive Ray Tracer – Alyosha Efros • http://www.cs.berkeley.edu/~efros/java/tracer/tracer.html • Ray Tracing explained • http://www.geocities.com/jamisbuck/raytracing.html • http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtrace0.htm

More Related