Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.

Similar presentations


Presentation on theme: "CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi."— Presentation transcript:

1 CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi

2 Ray Tracing Courtesy POV-Ray gallery

3 Ray Tracing: Forward Rendering Point Directional Or Both Color normal View Direction Light Direction

4 Basic Ray-casting For each pixel For each pixel Form the Ray Form the Ray For each Object For each Object Find point of intersection Find point of intersection If closest, save object If closest, save object Shade Ray Shade Ray If no intersection, return background color If no intersection, return background color Otherwise, shade(saved object) Otherwise, shade(saved object) For each light: For each light: Form light ray Form light ray Shade surface and accumulate color Shade surface and accumulate color

5 Ray-traced picture

6 Shadow Rays Shade Ray: If no intersection, return Background Otherwise, For each light: Compute Shadow Ray If(shadow Ray doesn’t intersect light first) ignore and continue; ignore and continue; Otherwise Otherwise shade surface and accumulate color shade surface and accumulate color

7 Shadow Rays

8 Recursive Ray Tracing

9 L n v c r t c

10 Color RayTrace(Ray &ray, int depth) { Point IntersectionPoint; Point IntersectionPoint; if (depth > MAX) return Background; if (depth > MAX) return Background; if(! intersect(IntersectionPoint, ray)) if(! intersect(IntersectionPoint, ray)) return Background; return Background; I local = k a I a + I p.v.(k d (n.l) + k s.(h.n) m ) I local = k a I a + I p.v.(k d (n.l) + k s.(h.n) m ) return I local + k r *RayTrace(ReflectRay, depth+1) + return I local + k r *RayTrace(ReflectRay, depth+1) + k t *RayTrace(RefractRay, depth+1); k t *RayTrace(RefractRay, depth+1);}

11 Computing the reflection direction Ideal reflection  =  -v + r = -2(v.n) n r = v - 2(v.n)n n r v   r

12 Refraction  Snell’s Law: index of refraction 11 22 ß n v n t m

13 Refracted Ray Computation Notes: Negative root => Total internal reflection Transparent => Invert light behind object

14 Specular Transmission A transparent surface can be illuminated from behind and this should be calculated in I local A transparent surface can be illuminated from behind and this should be calculated in I local  11 22 ß v n l l’

15 Make Ray ref tan(fovx/2) tan(fovy/2) y x Origin Origin Direction Direction o + t d o + t d

16 Algebraic Intersection Point satisfies Point satisfies o + t d o + t d f (x, y, z) = 0 f (x, y, z) = 0 f (o x + t d x, o y + t d y, o z + t d z ) = 0 f (o x + t d x, o y + t d y, o z + t d z ) = 0 Example Example (0, 0, 5) + t (0, 0, 1) (0, 0, 5) + t (0, 0, 1) X 2 +y 2 +z 2 = 1 X 2 +y 2 +z 2 = 1 0 + 0 + (5+t) 2 = 1, i.e., t = +-1 – 5, -4/-6 0 + 0 + (5+t) 2 = 1, i.e., t = +-1 – 5, -4/-6 (0, 0, 5) – 4(0, 0, 1) = (0, 0, 1) (0, 0, 5) – 4(0, 0, 1) = (0, 0, 1)

17 Geometric Intersection e c d (c-e).d (c-e).(c-e) d 2 = r 2 – {(c-e).(c-e) - (c-e).d}

18 Triangle Intersection? Intersect with plane Intersect with plane Ax + By + Cz = 1 Ax + By + Cz = 1 Check if point inside triangle Check if point inside triangle Barycentric coordinates must be +ve Barycentric coordinates must be +ve Point must be in the positive half-planes Point must be in the positive half-planes

19 Half-plane Method Ax + By + Cz = 1 o v1v1v1v1 v2v2v2v2 n = op X oq n.(p-o) > 0 p Orient edges in CW order

20 Distributed Ray Tracing Multiple randomly jittered rays

21 Depth of Field Use multiple origins Use multiple origins Distributed on a disk Distributed on a disk

22 Motion Blur Jitter rays in time Jitter rays in time

23 Soft Shadows Light has area Light has area Shoot multiple rays to light Shoot multiple rays to light Take average contribution Take average contribution Courtesy H.P. Seidel

24 Monte-Carlo Integration At intersection At intersection Generate multiple rays Generate multiple rays Typically based on material properties Typically based on material properties Weighted average of resulting ray colors Weighted average of resulting ray colors Path tracing Path tracing Global illumination Global illumination More later More later

25 Tracing Efficiency “Embarassingly” parallel “Embarassingly” parallel Bounding volume hierarchy Bounding volume hierarchy `

26 Bounding Box Test tx0tx0 tx1tx1 ty0ty0 ty1ty1 x = a o + t d o x + t d x = a t = (a – o x )/d x


Download ppt "CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi."

Similar presentations


Ads by Google