Download presentation
Presentation is loading. Please wait.
Published byGwenda Banks Modified over 9 years ago
1
Ray Tracing Chapter 10.11 CAP4730: Computational Structures in Computer Graphics
2
Outline n What is raytracing? n How is raytracing different than what we’ve done before? n Math behind raytracing n Uses of raytracing
3
Forward Mapping n Forward mapping is what we are used to.
4
Forward Mapping n Take each primitive n Figure out where on the screen it should appear n Also known is feed-forward
5
Ray Tracing n Ray tracing is the “inverse” of the “forward” mapping we are used to.
6
Ray Tracing n Also known as inverse mapping or feed- backward
7
Feed-Forward vs. Feed-Backward n Pros and Cons of each
8
Ray-Tracing n Attempts to trace the paths of light that contribute to each pixel that make up a scene n Instead of computing visible surfaces, determine intensity contributions n Compute global illumination n Allows for: –Reflection –Refraction –Atmospheric effects –Shadows n Results in very realistic scenes –Used in movies, animations, cut- scenes
9
n Center of Projection –Infinite Rays –Care about ones that pass through the virtual screen –For each pixel n Compute ray to a pixel n For each object in the scene –Compute the intersection between ray and object n Find closest intersection n Calculate illumination n Similar to a pinhole camera 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;
10
Computational Cost of Ray Tracing n Let’s compute a formula for how much work we have to do: n O(i*j*intersection tests) n What is an intersection test? n What is the cost of an intersection test? n We test the ray going from the eye through each pixel for an intersection with any object. n How are objects specified?
11
Ray Triangle Intersection n Ray is specified as a vector and a starting position (camera) n There are many different methods (search the web) to do ray - triangle intersection n One solution: Intersect with the plane of the triangle. Determine if the intersection point is within the triangle
12
Defining objects n We don’t have to use triangles exclusively. n Let’s think about other objects and the different intersections. How would we specify: –Spheres –Cylinders –Cubes –Other base geometric objects
13
Ray Intersections http://www.swin.edu.au/astronomy/pbourke/geometry/sphereline/ 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 n We are emulating “reality” where light reaches our eye. n We are asking “what is the path of the light that reached our eye for that pixel?” n Ray Tracing (in the way we know it), was started by Turner Whitted (1980). n With ray tracing, we can solve for global illumination.
15
Ray Tracing Observations n Each pixel must be evaluated n Hard for non solid objects n No screen space coherence n Difficult to do in parallel n Difficult to accelerate
16
Recursive Ray-Tracing n How would we compute lighting? Let’s reverse the light ray that got to our eye n Upon intersection, fire ‘secondary rays’ Vector to the light Refraction Ray Reflected Ray
17
Upon Intersection n How do we compute each? n Why follow each ray? –Each contributes intensity to the intersection position! u N L, shadow ray T ΘiΘi ΘrΘr R
18
n indices of refraction u N L, shadow ray T ΘiΘi ΘrΘr R
19
Ray-Surface Intersection n Ray –P=P 0 + s*u –P 0 - initial point of ray –u – unit vector –u = (pixel – COP)/|(pixel-COP) –s – distance along vector
20
Recursive Ray-Tracing n Shadows Vector to the light Refraction Ray Reflected Ray
21
Recursive Ray-Tracing n For each ray, we repeat the process n How many “levels of recursion” should we do? Refraction Ray Reflected Ray Vector to the light
22
Rercursion n How do we compute the refraction vector? n What properties would you want to include with an object? Refraction Ray Reflected Ray Vector to the light
23
Depth of recursion n Time vs. Accuracy n Tree Data Structure –ray-tracing tree –pg. 599 in book –How deep is the tree? n What are some end conditions? n What are some acceptable end- limits?
24
Lighting n So how do we compute the final color? n We can employ many lighting models –Phong Lighting –Torrence-Sparrow –BRDF models n What lighting can it not do? –Caustics (focused light like in water) –specular to specular or diffuse –diffuse to diffuse or specular
25
Lighting n We’ll cover lighting much more in depth later n For now: –Three terms n Ambient – global light that exists (hack) n Diffuse –contribution of a light. Dependent on light location n Specular – contribution of a light that is wrst user’s eye –L = k a I a + k d (n*L) +k s (h*N) ns
26
Ray Tracing Pros and Cons n Pros –Transparency –Reflections –Shadows –Complex Primitives (math equations) –Easy to write n Cons –Hard to accelerate –Isn’t the complete global illumination –Very slow per pixel calculation.
27
What is slow about Ray Tracing? n Ray Triangle intersections n Let’s talk about bounding volumes n Heirarchies? n 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 n How would we do –antialiasing –texturing –transparency –different material properties Refraction Ray Reflected Ray Vector to the light
30
Ray Tracing n http://graphics.lcs.mit.edu/classes/6.83 7/F98/Lecture20/RayTrace.java n POV-Ray (www.povray.org)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.