Ray Tracing Forward Ray Tracing Modeling interaction of light with the objects/surfaces Problem: Many rays will not contribute to the image!
Ray Tracing Backward Ray Tracing Rays from camera (viewer) through each pixel to the scene Backward Ray Tracing = Ray Tracing
Primary and Secondary Rays Ray Tracing Backward Ray Tracing Primary and Secondary Rays D B Viewer E C A View Plane F
Ray Tracing Backward Ray Tracing Shadow Rays Visibility check with respect to the light source
Ray Tracing Ray Casting D B Viewer E C A View Plane F
Ray Tracing Two Issues Ray-object intersection Visibility test: Closest to the viewer Pixel color determination (shading) Illumination model
Ray Tracing Ray Object Intersection Sphere Rd Ro
Ray Tracing Ray Object Intersection Sphere Implicit Form Center Sc = [ Xc Yc Zc ] Radius Sr Surface Point [ Xs Ys Zs ]
Ray Tracing Ray Object Intersection Sphere To solve the intersection problem the ray equation is substituted into the sphere equation and the result is solved for t That is
Ray Tracing Ray Object Intersection Sphere
[ Xi Yi Zi ] = [ Xo + Xdt , Yo + Ydt , Zo + Zdt ] Ray Tracing Ray Object Intersection Sphere Smaller positive among t0 and t1 gives the closest intersection point [ Xi Yi Zi ] = [ Xo + Xdt , Yo + Ydt , Zo + Zdt ]
Ray Tracing Ray Object Intersection Sphere Normal
Ray Tracing Ray Sphere Intersection Sum up Calculate A B C Compute the discriminant Calculate min (t0 , t1) Compute the intersection point Compute the normal
Ray Tracing Ray Object Intersection Sphere Geometric Approach tca thc Rd d r R0 L O
Ray Tracing Ray Object Intersection Sphere Geometric Approach tca thc Rd d r R0 L O
Ray Tracing Ray Object Intersection Sphere Geometric Approach tca thc Rd d r R0 L O
Ray Tracing Ray Object Intersection Sphere Geometric Approach tca thc Rd d r R0 L O
Ray Tracing Ray Plane Intersection Ray Ro = [ Xo Yo Zo ] (ray origin) Rd = [ Xd Yd Zd ] (ray direction) Xd2 + Yd2 + Zd2 =1 (normalized) R(t) = Ro + Rdt t > 0 Plane P : Ax + By + Cz + D = 0 A2 + B2 +C2 = 1 Pnormal = Pn = [ A B C ] D : Distance from origin
Ray Tracing Ray Plane Intersection Substituting ray equation in plane’s equation A ( Xo + Xdt ) + B (Yo + Ydt ) + C ( Zo + Zdt ) + D = 0 Solving for t
Ray Tracing Ray Plane Intersection Let If Vd = 0 then the ray is parallel to the plane (no intersection) Vd > 0 normal is pointing away from the ray (may be used for back-face culling) Normal Ray
Ray Tracing Ray Plane Intersection Let If t < 0 then plane is behind ray’s origin else compute intersection ri = [ Xi Yi Zi ] = [Xo + Xdt , Yo + Ydt , Zo + Zdt ] rnormal = Pn Let
Ray Tracing Polygon Intersection Containment Test Parity Test: If the number of intersection is odd then point is inside (special case for vertices)
Triangle: Barycentric Coordinates Ray Tracing Triangle Intersection Containment Test Triangle: Barycentric Coordinates V3 P V1 V2
Triangle: Barycentric Coordinates Ray Tracing Triangle Intersection Containment Test Triangle: Barycentric Coordinates V3 A2 P A1 Total A V1 V2 A3 Area Coordinates
Triangle: Barycentric Coordinates Ray Tracing Triangle Intersection Containment Test Triangle: Barycentric Coordinates V3 A2 A1 P V1 V2 A3
Ray Tracing Ray Quadric Intersection Quadrics: Cylinders, Cone, Sphere, Ellipsoids, Paraboloids, Hyperboloids, etc. Implict form f(X,Y,Z) = 0 Ax2 + 2Bxy + 2Cxz + 2Dx + Ey2 +2Fyz +26y + Hz2 + 2Iz +J = 0 Ray: Parametric form Ro = [ Xo Yo Zo ] (ray origin) Rd = [ Xd Yd Zd ] (ray direction) Xd2 + Yd2 + Zd2 =1 (normalized) R(t) = Ro + Rdt t > 0
Ray Tracing Ray Quadric Intersection Matrix Form f(X,Y,Z) = 0
Ray Tracing Ray Quadric Intersection Substituting
Ray Tracing Ray Quadric Intersection Normal
3D Clipping: Cyrus Beck/Liang Barsky Ray Tracing Ray Box Intersection 3D Clipping: Cyrus Beck/Liang Barsky