Document Sample

Ray Tracing I Ray-Primitive Intersection (2) Ray-Scene Intersection Intersections with geometric primitives: • Sphere • Plane • Triangle • Groups of primitives (scene) Plane Equation (example) Let p1 = (1, -1, -1), p2 = (2, 1, 2) and Ax + By + Cz + D =0 p3 = (2, -2, 1). The vectors p1 – p2 and p1 – p3 will be parallel to the plane (of course, so will p3 – p2, p2 – p1, and so on). A normal vector to the plane will be given by the cross product between p1 – p2 and p1 – p3, let's assume this vector is (n1, n2, n3). The plane will then have the equation n1x + n2y + n3z + d = 0 Finding d is simple since you know a point on the plane (in fact, you know three). Ray-Plane Intersection Ray: P0 and V x0,y0,z0 and xv,yv,zv Plane: Ax + By + Cz + D =0 With A2+B2+C2 = 1 Normal is N = (A,B,C) Plug-in: A(x0+xvt) + B(y0+yvt) + C(z0+zvt) + D = 0 Ray-Plane Intersection A(x0+xvt)+B(y0+yvt)+C(z0+zvt)+D =0 Ax0+Axvt+By0+Byvt+Cz0+Czvt+D =0 t = -(Ax0+By0+Cz0+D)/(Axv+Byv+Czv) if t < 0, plane intersects behind viewer Ray-Scene Intersection Intersections with geometric primitives: • Sphere • Plane • Triangle • Groups of primitives (scene) Ray-Triangle Intersection Parametric Method using barycentric coordinates Ray-Triangle Intersection using barycentric coordinates Advantages of Barycentric Intersection Efficient Stores no plane equation Get the barycentric coordinates for free Useful for interpolation, texture mapping [Möbius, 1827] Barycentric Coordinates P is the barycenter: the single point upon which the plane would balance if weights of size α, β, and γ are placed on points a, b, and c. Barycentric Coordinates A coordinate system for triangles Algebraic viewpoint Geometric viewpoint (areas) Triangle interior test Set ray equation equal to barycentric equation Using Cramer’s rule: What is the normal at P? Advantages of Barycentric Intersection Efficient Stores no plane equation Get the barycentric coordinates for free Useful for interpolation, texture mapping Ray-Scene Intersection Intersections with geometric primitives: • Sphere • Plane • Triangle • Groups of primitives (scene) Looking from above My primitives in the scene 1 2 3 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 1000 2 3 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene ? 1 t-min = 1000 2 3 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 1000 hit 2 3 t = 700 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 700 hit 2 3 t = 700 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 700 closest-hit 2 3 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 700 closest-hit 2 ? 3 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 700 closest-hit 2 3 hit 4 t = 400 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 400 closest-hit 2 3 hit 4 t = 400 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 400 2 3 closest-hit 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 400 2 3 closest-hit 4 t = 50 hit 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 50 2 3 closest-hit 4 t = 50 hit 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 50 2 3 4 closest-hit 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 1000 2 3 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene ? 1 t-min = 1000 ? 2 ? 3 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 450 2 3 hit 4 t = 450 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 450 2 3 closest-hit 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 450 2 3 closest-hit 4 ? 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 450 2 3 closest-hit 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene 1 t-min = 1000 2 3 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene t-min = 200 closest-hit 1 2 3 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene t-min = 200 closest-hit 1 2 hit 3 4 t = 600 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene t-min = 200 closest-hit 1 2 3 ? 4 ? 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit Looking from above My primitives in the scene t-min = 200 closest-hit 1 2 3 4 5 eye for each new ray: t-min = MAX_DEPTH (…) for each primitive prim: (hit, t) = intersect (prim, ray) if (hit AND t < t-min) t-min = t MIN_DEPTH MAX_DEPTH (…) return closest-hit

DOCUMENT INFO

Shared By:

Categories:

Tags:
ray tracing, ray casting, the eye, light source, ray tracer, Shadow Rays, computer graphics, Polygon Intersection, Interactive Ray, Barycentric Coordinates

Stats:

views: | 30 |

posted: | 5/5/2011 |

language: | English |

pages: | 54 |

OTHER DOCS BY wanghonghx

How are you planning on using Docstoc?
BUSINESS
PERSONAL

By registering with docstoc.com you agree to our
privacy policy and
terms of service, and to receive content and offer notifications.

Docstoc is the premier online destination to start and grow small businesses. It hosts the best quality and widest selection of professional documents (over 20 million) and resources including expert videos, articles and productivity tools to make every small business better.

Search or Browse for any specific document or resource you need for your business. Or explore our curated resources for Starting a Business, Growing a Business or for Professional Development.

Feel free to Contact Us with any questions you might have.