ray tracing
play

Ray Tracing CPSC 453 Fall 2018 Sonny Chan Ray Tracing A method - PowerPoint PPT Presentation

Ray Tracing CPSC 453 Fall 2018 Sonny Chan Ray Tracing A method for synthesizing images of virtual 3D scenes. Image Capture Devices Which one shall we use? Goal: Simulate a Camera Obscura! Spheres & Checkerboard Turner Whitted,


  1. Ray Tracing CPSC 453 – Fall 2018 Sonny Chan

  2. Ray Tracing A method for synthesizing images of virtual 3D scenes.

  3. Image Capture Devices Which one shall we use?

  4. Goal: Simulate a Camera Obscura!

  5. “Spheres & Checkerboard” Turner Whitted, 1979

  6. Whitted Ray Tracing • “An improved illumination model for shaded display” - T. Whitted, SIGGRAPH 1979 • 512 × 512 image • Rendered on VAX 11/780 • 74 minutes compute time • How fast would your computer render this today? [image courtesy of P . Hanrahan, Stanford University]

  7. The Ray Tracing Algorithm • For every pixel or position on your image, do 1. ray generation : where am I looking? 2. ray intersection : do I see something? 3. shading : what colour is it?

  8. Ray Generation

  9. virtual image plane

  10. [from photojojo.com]

  11. Let’s see how we might generate those rays

  12. Ray Generation r ( t ) = e + t ( s − e )

  13. Ray Intersection What do we see?

  14. Ray Intersection • For every object we have in our scene, we need a way to determine whether or not we can see it • Usually amounts to solving an equation of one variable • We will examine three key intersection tests today: spheres - planes - triangles -

  15. spheres

  16. Ray-Sphere Intersection o d A ray: r ( t ) = o + t d A sphere: || p − c || = R R ( p − c ) · ( p − c ) − R 2 = 0 c ( r ( t ) − c ) · ( r ( t ) − c ) − R 2 = 0 Intersection: ( o + t d − c ) · ( o + t d − c ) − R 2 = 0 Solve for t…

  17. planes

  18. Ray-Plane Intersection o d A ray: r ( t ) = o + t d ˆ n A plane: ( p − q ) · ˆ n = 0 q Intersection: ( r ( t ) − q ) · ˆ n = 0 ( o + t d − q ) · ˆ n = 0 Solve for t…

  19. triangles

  20. How might we test intersection of a ray and a triangle?

  21. Barycentric Coordinates p 2 v ( . 6 , . 4 , 0) p 1 ( . 3 , . 2 , . 5) w u p 0 f ( u, v ) = (1 − u − v ) p 0 + u p 1 + v p 2

  22. p 2 Another Interpretation A 0 p 1 A 1 Ratio of (signed) areas of triangles: ( . 3 , . 2 , . 5) A = 1 2 ( p 1 − p 0 ) × ( p 2 − p 0 ) A 2 u = A 1 v = A 2 A A p 0 f ( u, v ) = (1 − u − v ) p 0 + u p 1 + v p 2

  23. A Direct Approach for Intersection A ray: r ( t ) = o + t d A triangle: f ( u, v ) = (1 − u − v ) p 0 + u p 1 + v p 2 Ray-triangle intersect: o + t d = (1 − u − v ) p 0 + u p 1 + v p 2     t Rearrange terms:  − d p 1 − p 0 p 2 − p 0  = o − p 0 u   v Solve for t, u, and v…

  24. Cramer’s Rule • Given a set of linear equations in matrix form     x  a b c  = d y   z • Write the determinant of the matrix � � a 1 b 1 c 1 � � � � det( a , b , c ) = a 2 b 2 c 2 � � � � a 3 b 3 c 3 � � • Then the solutions are x = det( d , b , c ) y = det( a , d , c ) z = det( a , b , d ) det( a , b , c ) det( a , b , c ) det( a , b , c )

  25. A Direct Approach for Intersection     t Our equation:  − d p 1 − p 0 p 2 − p 0  = o − p 0 u   v     det( s , e 1 , e 2 ) t 1 Applying Cramer’s rule:  = det( − d , s , e 2 ) u    det( − d , e 1 , e 2 ) det( − d , e 1 , s ) v where e 1 = p 1 − p 0 , e 2 = p 2 − p 0 , s = o − p 0 Check that t > 0 and u, v, u+v are within [0,1] interval!

  26. Ray-Object Intersection Tests • Now we know how to draw spheres, planes, and triangles in perspective with a ray tracer! • What else can we do?

  27. [from photojojo.com]

  28. I think we need some shading… What we’ve got now… and what we really want!

  29. Shadows & More

  30. What happens if we have more than one light?

  31. How do we get these nice, soft shadows?

  32. Depth of Field Can we ray trace it?

  33. image object

  34. The Ray Tracing Algorithm • For every pixel position on your image: 1. Generate a parametric viewing ray. 2. Test for intersection against each object in your scene. - What happens if it intersections more than one object? 3. Determine the colour to be carried back on the ray - Trace shadow ray(s) to obtain shadow effect

  35. Things to Remember • Ray tracing is a relatively simple way for us to synthesize images of a 3D scene in perspective simulates the optics of a pinhole camera - • We need to devise a ray-object intersection for each kind of object geometry in the scene • Some effects like shadows are relatively easy to compute • Soft shadows and depth of field are possible if you’re willing to wait!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend