Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ray Tracing II. HW1 Part A due October 10 Camera module Object module –Read from a file –Sphere and Light only Ray tracer module: –No shading. No reflection.

Similar presentations


Presentation on theme: "Ray Tracing II. HW1 Part A due October 10 Camera module Object module –Read from a file –Sphere and Light only Ray tracer module: –No shading. No reflection."— Presentation transcript:

1 Ray Tracing II

2 HW1 Part A due October 10 Camera module Object module –Read from a file –Sphere and Light only Ray tracer module: –No shading. No reflection and refraction. Display module (in text mode)

3 Ray-Object Intersection For example: sphere (x-x 0 ) 2 +(y-y 0 ) 2 +(z-z 0 ) 2 =r 2 Ray: (x,y,z)=(x 1,y 1,z 1 )+t(x d,y d,z d ) Find t that satisfy (x-x 0 ) 2 +(y-y 0 ) 2 +(z-z 0 ) 2 =r 2 Normal vector? Also easy for planes, cones, …etc.

4 Ray-Triangle Intersection Ray: (x,y,z)=(x 1,y 1,z 1 )+t(x d,y d,z d ) Triangle: (x,y,z)=(x 1,y 1,z 1 )+u(x 01,y 01,z 01 )+v(x 02,y 02,z 02 ) Find t, u, v that produce the same (x,y,z) Intersection found if: t > 0 0 ≦ u, v ≦ 1, and u + v ≦ 1 V0V0 V1V1 V2V2

5 Part B due October 24 Object module –Add at least a plane type. Ray tracer module: –Add shading, reflection, and refraction. Display module: –PPM library will be provided. Add a demo scene of your own.

6 Lighting (Shading) & Shadow Point light is easy to implement. How to determine a surface point is in the shadow? Use a shadow ray (from intersection point to light). Shading will be introduced in the next lecture.

7 Reflection and Refraction Reflected ray is determined by: – incoming ray and normal vector. Refracted ray is determined by: –Incoming ray –Normal vector –And density Snell’s law:  I sin  i =  t sin  t ii tt

8 Advanced Ray Tracing Make it fast. Make it better. –Anti-aliasing –Distributed Ray Tracing

9 Make It Fast From Pharr’s Chapter 4 –Object subdivision (i.e., bounding volume) –Spatial subdivision (e.g., grid, octree, kd- tree) –Ray coherence.

10 Anti-Aliasing Super(or Over)-sampling Adaptive vs. Non-adaptive Uniform vs. Jittered Detail coming in a future lecture

11 Distributed Ray Tracing Published by R. L. Cook in 1984. Antialiasing Motion blur Depth of field (camera) Ideas behind other so-called Monte Carlo methods.

12 Space Partitions

13 Common Operations in 3D Line/object intersection –Given a ray or line, which object will it intersect? View frustum culling Collision detection

14 Sorting/Indexing in 3D Sequential search is too slow for large models. How about storing them in a 3D array? –Size will be overwhelming Think “hierarchy”

15 Octree Divide the space in halves in X/Y/Z. –Always split in the middle. –You may also consider them as splitting in X, then in Y, then in Z. If too many objects are in a partition, divide them again (recursively).

16 K-D Tree More flexible than octree: –Not always splitted in the middle. –Split in X, then in Y, then in Z, or any order.

17 Kd-tree Example 1 1 23 2 3 4567 4 5 6 7 8910111213 8 9 10 11 12 13 Figure Source: CS638 slides by Stephen Chenney, University of Wisconsin – Madison,

18 BSP Trees From the paper by Fuchs et al, “On visible surface generation by a priori tree structures” SIGGRAPH 80.On visible surface generation by a priori tree structures Binary Space Partition trees –A sequence of cuts that divide a region of space into two Cutting planes can be of any orientation

19 Drawing Order from BSP Trees BSP tress can be used to order polygons from back to front, or visa-versa –Descend tree with viewpoint –Things on the same side of a splitting plane as the viewpoint are always in front of things on the far side Can draw from back to front –Gives the correct order for rendering transparent objects with a z-buffer, and by far the best way to do it Can draw front to back too.

20 BSP Example 1 4 2 375 BAout8 D 6 C 1 2 3 4 56 7 8 A B C D Figure Source: CS638 slides by Stephen Chenney, University of Wisconsin – Madison,

21 OBB Tree OBB stands for Oriented Bounding Box. OBB is a rectangular bounding box at an arbitrary orientation. Asymptotically faster for close proximity situations.


Download ppt "Ray Tracing II. HW1 Part A due October 10 Camera module Object module –Read from a file –Sphere and Light only Ray tracer module: –No shading. No reflection."

Similar presentations


Ads by Google