ray tracing n.
Skip this Video
Loading SlideShow in 5 Seconds..
Ray Tracing PowerPoint Presentation
Download Presentation
Ray Tracing

Ray Tracing

21 Vues Download Presentation
Télécharger la présentation

Ray Tracing

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. CAP4730: Computational Structures in Computer Graphics Ray Tracing Chapter 10.11

  2. Outline • What is raytracing? • How is raytracing different than what we’ve done before? • Math behind raytracing • Uses of raytracing

  3. Forward Mapping • Forward mapping is what we are used to.

  4. Forward Mapping • Take each primitive • Figure out where on the screen it should appear • Also known is feed-forward

  5. Ray Tracing • Ray tracing is the “inverse” of the “forward” mapping we are used to.

  6. Ray Tracing • Also known as inverse mapping or feed-backward

  7. Feed-Forward vs. Feed-Backward • Pros and Cons of each

  8. Ray-Tracing • Attempts to trace the paths of light that contribute to each pixel that make up a scene • Instead of computing visible surfaces, determine intensity contributions • Compute global illumination • Allows for: • Reflection • Refraction • Atmospheric effects • Shadows • Results in very realistic scenes • Used in movies, animations, cut-scenes

  9. for (j=0;j<IMAGE_HEIGHT;j++) for (i=0;i<IMAGE_WIDTH;i++) result=CheckForIntersection(i,j) SetPixel(i,j,result); CheckForIntersection(i,j) ray = vector from eye through pixel on display plane if (DetermineIntersection(ray, color)) return color; • Center of Projection • Infinite Rays • Care about ones that pass through the virtual screen • For each pixel • Compute ray to a pixel • For each object in the scene • Compute the intersection between ray and object • Find closest intersection • Calculate illumination • Similar to a pinhole camera

  10. Computational Cost of Ray Tracing • Let’s compute a formula for how much work we have to do: • O(i*j*intersection tests) • What is an intersection test? • What is the cost of an intersection test? • We test the ray going from the eye through each pixel for an intersection with any object. • How are objects specified?

  11. Ray Triangle Intersection • Ray is specified as a vector and a starting position (camera) • There are many different methods (search the web) to do ray - triangle intersection • One solution: Intersect with the plane of the triangle. Determine if the intersection point is within the triangle

  12. Defining objects • We don’t have to use triangles exclusively. • Let’s think about other objects and the different intersections. How would we specify: • Spheres • Cylinders • Cubes • Other base geometric objects

  13. Ray Intersections Since performance is so closely tied to ray-object intersections, we’d like to speed it up. How can we speed things up? Break down things into two steps, detecting intersections, and determining location of intersection.

  14. Ray Intersections • We are emulating “reality” where light reaches our eye. • We are asking “what is the path of the light that reached our eye for that pixel?” • Ray Tracing (in the way we know it), was started by Turner Whitted (1980). • With ray tracing, we can solve for global illumination.

  15. Ray Tracing Observations • Each pixel must be evaluated • Hard for non solid objects • No screen space coherence • Difficult to do in parallel • Difficult to accelerate

  16. Recursive Ray-Tracing • How would we compute lighting? Let’s reverse the light ray that got to our eye • Upon intersection, fire ‘secondary rays’ Vector to the light Refraction Ray Reflected Ray

  17. Upon Intersection L, shadow ray • How do we compute each? • Why follow each ray? • Each contributes intensity to the intersection position! R T Θr N Θi u

  18. L, shadow ray • indices of refraction R T Θr N Θi u

  19. Ray-Surface Intersection • Ray • P=P0 + s*u • P0 - initial point of ray • u – unit vector • u = (pixel – COP)/|(pixel-COP) • s – distance along vector

  20. Recursive Ray-Tracing • Shadows Vector to the light Refraction Ray Reflected Ray

  21. Recursive Ray-Tracing • For each ray, we repeat the process • How many “levels of recursion” should we do? Vector to the light Refraction Ray Reflected Ray

  22. Rercursion • How do we compute the refraction vector? • What properties would you want to include with an object? Vector to the light Refraction Ray Reflected Ray

  23. Depth of recursion • Time vs. Accuracy • Tree Data Structure • ray-tracing tree • pg. 599 in book • How deep is the tree? • What are some end conditions? • What are some acceptable end-limits?

  24. Lighting • So how do we compute the final color? • We can employ many lighting models • Phong Lighting • Torrence-Sparrow • BRDF models • What lighting can it not do? • Caustics (focused light like in water) • specular to specular or diffuse • diffuse to diffuse or specular

  25. Lighting • We’ll cover lighting much more in depth later • For now: • Three terms • Ambient – global light that exists (hack) • Diffuse –contribution of a light. Dependent on light location • Specular – contribution of a light that is wrst user’s eye • L = kaIa + kd(n*L) +ks(h*N)ns

  26. Pros Transparency Reflections Shadows Complex Primitives (math equations) Easy to write Cons Hard to accelerate Isn’t the complete global illumination Very slow per pixel calculation. Ray Tracing Pros and Cons

  27. What is slow about Ray Tracing? • Ray Triangle intersections • Let’s talk about bounding volumes • Heirarchies? • What are some properties of the volumes that determines how “good” a bounding volume is?

  28. Spatial Subdivision Divide space into regions Place objects into different regions Compute which regions you can “see” from your current position Only test those objects Developing a hierarchy of tests

  29. Other Tricks • How would we do • antialiasing • texturing • transparency • different material properties Vector to the light Refraction Ray Reflected Ray

  30. Ray Tracing • • POV-Ray (