This preview shows page 1. Sign up to view the full content.
Unformatted text preview: CAP4730: Computational Structures in
Computer Graphics Ray Tracing
Chapter 10.11 Outline
What is raytracing?
s How is raytracing different than what we’ve done before?
s Math behind raytracing
s Uses of raytracing
s Forward Mapping
s Forward mapping is what we are used to. Forward Mapping
Take each primitive
s Figure out where on the screen it should appear
s Also known is feedforward
s Ray Tracing
s Ray tracing is the “inverse” of the “forward” mapping we are used to. Ray Tracing
s Also known as inverse mapping or feed
backward FeedForward vs.
FeedForward vs. FeedBackward s Pros and Cons of each RayTracing
s s s
s 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
– s Reflection
Shadows Results in very realistic scenes – Used in movies, animations, cut
scenes s Center of Projection – Infinite Rays
– Care about ones that pass through the virtual screen
– For each pixel
s s Compute ray to a pixel
For each object in the scene – Compute the intersection between ray and object s s s Find closest intersection
Calculate illumination Similar to a pinhole camera for (j=0;j<IMAGE_HEIGHT;j++)
ray = vector from eye through pixel on display plane
if (DetermineIntersection(ray, color))
return color; Computational Cost of Ray Computational Cost of Ray Tracing
s s Let’s compute a formula for how much work we have to do:
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? Ray Triangle Intersection
Ray Triangle Intersection
s s s 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 Defining objects
We don’t have to use triangles exclusively.
s Let’s think about other objects and the different intersections. How would we specify:
s – Spheres
– Other base geometric objects 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. Ray Intersections
We are emulating “reality” where light reaches our eye.
s We are asking “what is the path of the light that reached our eye for that pixel?”
s Ray Tracing (in the way we know it), was started by Turner Whitted (1980).
s With ray tracing, we can solve for global illumination.
s Ray Tracing Observations
Ray Tracing Observations
s Each pixel must be evaluated
Hard for non solid objects
No screen space coherence
Difficult to do in parallel
Difficult to accelerate Recursive RayTracing
Recursive RayTracing How would we compute lighting? Let’s reverse the light ray that got to our eye
s Upon intersection, fire ‘secondary rays’
s Vector to the light Reflected Ray Refraction Ray Upon Intersection
L, shadow ray
s Θi How do we compute each?
Why follow each ray? – Each contributes intensity to the intersection position! R = u − ( 2u • N ) N L, shadow ray
s Θi indices of refraction ηi
T = u − cos θ r − cos θ i N ηr
cos θ r = 1 − η
r 2 1 − cos 2 θ i RaySurface Intersection
s Ray – P=P0 + s*u
– P0 initial point of ray – u – unit vector
– u = (pixel – COP)/|(pixelCOP)
– s – distance along vector Recursive RayTracing
s Shadows Vector to the light Reflected Ray Refraction Ray Recursive RayTracing
For each ray, we repeat the process
s How many “levels of recursion” should we do?
s Vector to the light
Reflected Ray Rercursion
s How do we compute the refraction vector? What properties would you want to include with an object? Vector to the light
Reflected Ray Depth of recursion
Depth of recursion
s Time vs. Accuracy
Tree Data Structure
– raytracing tree
– pg. 599 in book
– How deep is the tree?
s s What are some end conditions?
What are some acceptable end
s s So how do we compute the final color?
We can employ many lighting models
– Phong Lighting
– BRDF models
What lighting can it not do?
– Caustics (focused light like in water)
– specular to specular or diffuse
– diffuse to diffuse or specular Lighting
s We’ll cover lighting much more in depth later
– Three terms
s s 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 Ray Tracing Pros and Cons
Ray Tracing Pros and Cons
s Pros Transparency
Complex Primitives (math equations)
– Easy to write
– s Cons – Hard to accelerate
– Isn’t the complete global illumination
– Very slow per pixel calculation. What is slow about Ray What is slow about Ray Tracing?
s Ray Triangle intersections
Let’s talk about bounding volumes
What are some properties of the volumes that determines how “good” a bounding volume is? Spatial Subdivision
Divide space into regions
Place objects into
Compute which regions
you can “see” from your
Only test those objects
Developing a hierarchy
of tests Other Tricks
s How would we do
different material properties Vector to the light
Reflected Ray Ray Tracing
s POVRay (www.povray.org)
View Full Document
- Fall '08
- Computer Graphics