Download presentation
Presentation is loading. Please wait.
1
Ray-tracing
2
Overview Recursive Ray Tracing Shadow Feelers
Snell’s Law for Refraction When to stop!
3
Recap: Light Transport
The point to note here is the amount of computation involved in each of these scenarios: In (a) a single beam generates one primary reflection and one secondary reflection. In (b) a single beam generates one primary reflection and N secondary reflections. In (c) a single beam generates N primary reflections, each of which generates one secondary reflection i.e. there are N secondary reflections In (d) a single beam generates N primary reflections, each of which generates N secondary reflections i.e. there are N2 secondary reflections Where N is the number of discrete samples taken over the hemisphere above the surface.
4
Recap: Local Illumination
( ) å = × + M j m s d i a r n h k l I 1 , I a Ambient, diffuse & specular components The sum is over the specular and diffuse components for each light
5
Recap: Result of Ray Casting
6
Correcting for Non-Visible Lights
surface
7
Note consider your intersection points along the ray L carefully
Where Sj is the result of intersecting the ray L with the scene objects Note consider your intersection points along the ray L carefully Hint – they might be beyond the light!
8
Result of Shadow Feeler
9
Recursive Ray-Tracing
We can simulate specular-specular transmission elegantly by recursing and casting secondary rays from the intersection points We must obviously chose a termination depth to cope with multiple reflections
10
Introducing Reflection
H R E L surface Where
11
Computing the reflection direction
Ideal reflection = R same plane as V and N R = aE + bN E.N = N.R = a(N.E)+b If a = -1, b = 2N.E R = -E + 2(N.E)N V is referred to in all preceding slides as E Should read: -V.N = N.R = a(N.-V
12
Computing Reflectance
Where Ilocal is computed as before Ray r' is formed from intersection point and the direction R and is cast into the scene as before
13
Recursive Ray Tracing L1 L2 p p’ p’’ R1 R2
14
Pseudo Code Color RayTrace(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 = kaIa + Ip.v.(kd(n.l) + ks.(h.n)m) return Ilocal + kr*RayTrace(pd, R, depth+1) } Normally kr = ks
15
Result of Recursion
16
Perfect Specular Transmission
H E R Snell’s Law L 1 is index of refraction 2 T ß
17
Using Snell’s Law Using this law it is possible to show that:
Note that if the root is negative then total internal reflection has occurred and you just reflect the vector as normal
18
Recursive Ray Tracing Including Transparent Objects
19
New Pseudo Code Color RayTrace(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 = kaIa + Ip.v.(kd(n.l) + ks.(h.n)m) return Ilocal + kr*RayTrace(pd, R, depth+1) kt*RayTrace(pd, T, depth+1) }
20
Direct Specular Transmission
A transparent surface can be illuminated from behind and this should be calculated in Ilocal H' E L
21
Calculating H' Use H‘ instead of H in specular term
22
Putting Everything Together
23
Discussion – What Can’t We Simulate?
Can do (a) and (c) Can’t do (b) and (d) Do hands up for this!
24
Remark Specular and transmission only Why it’s expensive
What should be added to consider diffuse reflection? Why it’s expensive Intersection of rays with polygons (90%) 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
25
Summary Recursive ray tracing is a good simulation of specular reflections We’ve seen how the ray-casting can be extended to include shadows, reflections and transparent surfaces However this is a very slow process and still misses some types of effect!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.