Raytracing 1 Overview Recursive Ray Tracing n Shadow

























- Slides: 25
Ray-tracing 1
Overview Recursive Ray Tracing n Shadow Feelers n Snell’s Law for Refraction n When to stop! n 2
Recap: Light Transport 3
Recap: Local Illumination ( Ir = ka. Ia+å j =1 Ii , j kd(n × l j)+ k s (hj×n) M ) m Ambient, diffuse & specular components n The sum is over the specular and diffuse components for each light n 4
Recap: Result of Ray Casting 5
Correcting for Non-Visible Lights E N H L surface 6
Where Sj is the result of intersecting the ray L with the scene objects n Note consider your intersection points along the ray L carefully n • Hint – they might be beyond the light! 7
Result of Shadow Feeler 8
Recursive Ray-Tracing We can simulate specular-specular transmission elegantly by recursing and casting secondary rays from the intersection points n We must obviously chose a termination depth to cope with multiple reflections n 9
Introducing Reflection E N R H L surface n Where 10
Computing the reflection direction N E R n Ideal reflection • = • R same plane as V and N R = a. E + b. N • E. N = N. R = a(N. E)+b • If a = -1, b = 2 N. E R = -E + 2(N. E)N 11
Computing Reflectance Where Ilocal is computed as before n Ray r' is formed from intersection point and the direction R and is cast into the scene as before n 12
Recursive Ray Tracing p’’ L 2 R 1 p p’ L 1 13
Pseudo Code Color Ray. Trace(Point p, Vector direction, int depth) { Point pd /* Intersection point */ Boolean intersection if (depth > MAX) return Black intersect(p, direction, &pd, &intersection) if (!intersection) return Background Ilocal = ka. Ia + Ip. v. (kd(n. l) + ks. (h. n)m) return Ilocal + kr*Ray. Trace(pd, R, depth+1) } Normally kr = ks 14
Result of Recursion 15
Perfect Specular Transmission N H E 1 2 R Snell’s Law L ß T is index of refraction 16
Using Snell’s Law n Using this law it is possible to show that: n Note that if the root is negative then total internal reflection has occurred and you just reflect the vector as normal 17
Recursive Ray Tracing Including Transparent Objects T 2 p’’ L 2 R 1 p p’ T 1 L 1 18
New Pseudo Code Color Ray. Trace(Point p, Vector D, int depth) { Point pd /* Intersection point */ Boolean intersection if (depth > MAX) return Black intersect(p, direction, &pd, &intersection) if (!intersection) return Background Ilocal = ka. Ia + Ip. v. (kd(n. l) + ks. (h. n)m) return Ilocal + kr*Ray. Trace(pd, R, depth+1) + kt*Ray. Trace(pd, T, depth+1) } 19
Direct Specular Transmission n A transparent surface can be illuminated from behind and this should be calculated in Ilocal E H' N L 20
Calculating H' n Use H‘ instead of H in specular term 21
Putting Everything Together 22
Discussion – What Can’t We Simulate? 23
Remark n Specular and transmission only • What should be added to consider diffuse reflection? n Why it’s expensive • Intersection of rays with polygons (90%) n How to reduce the cost? • Reduce the number of rays • Reduce the cost on each ray – First check with bounding box of the object – Methods to sort the scene and make it faster 24
Summary Recursive ray tracing is a good simulation of specular reflections n We’ve seen how the ray-casting can be extended to include shadows, reflections and transparent surfaces n However this is a very slow process and still misses some types of effect! n 25