1 / 57

CS 431/636 Advanced Rendering Techniques

CS 431/636 Advanced Rendering Techniques. Dr. David Breen University Crossings 149 Tuesday 6PM  8:50PM. Presentation 1 3/31/09. Class Topics and Objectives. Photo-realistic image generation Ray Tracing! Learn and implement the algorithms needed to create ray traced images

Download Presentation

CS 431/636 Advanced Rendering Techniques

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM  8:50PM Presentation 1 3/31/09

  2. Class Topics and Objectives • Photo-realistic image generation • Ray Tracing! • Learn and implement the algorithms needed to create ray traced images • Serious numerical computing and programming class • Assumes you know CG I material

  3. Class Structure • Weekly lectures & reading assignments • 6 regular programming assignments • 1 extra credit assignment • Post images on the web • E-mail the URL to david@cs.drexel.edu • Upload code to WebCT • Grad students give presentations • No final exam

  4. Grading • Graduate Section • Programming Assignments - 90% • In-class Presentation - 10% • Undergraduate Section • Programming Assignments - 95% • Class Participation (Attend class on Week 5) - 5% • Late policy • 1 point/day • Maximum 5 points off

  5. Go To Web Sites • Class web site • Previous pictures web site

  6. Slide Credits • Kevin Suffern - University of Technology, Sydney, Australia • G. Drew Kessler & Larry Hodges - Georgia Institute of Technology • Fredo Durand & Barb Cutler - MIT • Computer Graphics I

  7. Ray Casting • Determines visible surfaces by tracing “light” rays from the viewer’s eye to the objects • View plane is divided by a pixel grid • The eye ray is fired from the center of projection through each pixel 1994 Foley/VanDam/Finer/Huges/Phillips ICG

  8. Ray Tracing • Extension of ray casting • Idea: Continue to bounce the ray in the scene • Shoot rays to light sources • Simple and powerful • Reflections, shadows, transparency and multiple light sources

  9. Ray Tracing Diagrams

  10. First Ray-Traced Image Whitted 1980

  11. Issues • Ray-object intersections • Complex, hierarchical models (CSG?) • Transformations • Camera models • Recursive algorithms • Surface physics (shading models) • Color representations • Light representations • Sampling, anti-aliasing and filtering • Geometric optics • Acceleration techniques • Texture mapping

  12. Left-handed system!

  13. sj sk

  14. Calculating Primary Rays • Given (in world coordinates) • Camera (eye point) location O • Camera view out direction (Zv) • Camera view up vector (Yv) • Distance to image plane (d) • Horizontal camera view angle () • Pixel resolution of image plane (hres, vres) • Calculate set of rays (d) that equally samples the image plane

  15. Calculate Preliminary Values • Camera view side direction (Xv) • Yv Zv • Horizontal length of image plane (sj) • Next slide • Vertical length of image plane (sk) • sk = sj • (vres / hres) • Assume square pixels

  16. Calculating sj • h = d • tan(/2) • sj = 2h • sj = 2d • tan(/2)

  17. Calculate Preliminary Values • Position of top left pixel (P0,0) • O + d Zv - (Sj/2) Xv + (Sk/2) Yv All in world coordinates!

  18. Calculate Those Rays! • P0,0 +  Xv -  Yv sweeps out image plane • 0    Sj; 0   Sk for (j=0; j++; j < hres) for (k=0; k++; k < vres) { dj,k = (P0,0 + Sj(j/(hres-1)) Xv - Sk(k/(vres-1)) Yv) - O; d’j,k = dj,k / | dj,k | ; Image[j,k] = ray_trace(O, d’j,k , Scene); }

  19. Parameters • X and Y resolution of image • Camera location & direction • Distance between camera & image plane • Camera view angle • Distance between pixels • These are not independent! • Goal  Choose your independent variables and calculate your d’s

  20. I recommend setting … • X and Y resolution of image • (hres, vres) • Camera location & orientation • O & Zv & Yv • Distance between camera & image plane • d (a positive scalar, e.g. 10) • Camera view angle • 

  21. Ray-Sphere Intersection G. Drew Kessler Larry Hodges Georgia Institute of Technology

  22. Ray/Sphere Intersection (Algebraic Solution) Ray is defined by R(t) = Ro + Rd*t where t > 0. Ro = Origin of ray at (xo, yo, zo) Rd = Direction of ray [xd, yd, zd] (unit vector) Sphere's surface is defined by the set of points {(xs, ys, zs)} satisfying the equation: (xs - xc)2 + (ys - yc)2 + (zs - zc)2 - rs2 = 0 Center of sphere: (xc, yc, zc) Radius of sphere: rs

  23. Possible Cases of Ray/Sphere Intersection 1. Ray intersects sphere twice with t>0 2. Ray tangent to sphere 3. Ray intersects sphere with t<0 4. Ray originates inside sphere 5. Ray does not intersect sphere 1 2 3 4 5

  24. Solving For t Substitute the basic ray equation: x = xo + xd*t y = yo + yd*t z = zo + zd*t into the equation of the sphere: (x0 + xdt - xc)2 + (y0 + ydt - yc)2 + (z0 + zdt - zc)2 - rs2 = 0 This is a quadratic equation in t: At2 + Bt + C = 0, where A = xd2 + yd2 + zd2 B = 2[xd(x0 - xc) + yd(y0 - yc) + zd(z0 - zc)] C = (x0 - xc)2 + (y0 - yc)2 + (z0 - zc)2 - rs2 Note: A=1

  25. Relation of t to Intersection We want the smallest positive t - call it ti t0 Discriminant = 0 t1 t0 t0 t1 t1 t0 Discriminant < 0

  26. N N Actual Intersection Intersection point, (xi, yi, zi) = (xo+xd*ti, yo+yd*ti, zo+zd*ti) Unit vector normal to the surface at this point is N = [(xi - xc) / rs, (yi - yc) / rs, (zi - zc) / rs] If the ray originates inside the sphere, N should be negated so that it points back toward the center.

  27. Summary (Algebraic Solution) • Calculate A, B and C of the quadratic intersection equation • Calculate discriminant (If < 0, then no intersection) • Calculate t0 • If t0 < 0, then calculate t1 (If t1 < 0, no intersection point on ray) • Calculate intersection point • Calculate normal vector at point Helpful pointers: • Precompute rs2 • Precompute 1/rs • If computed t is very small then, due to rounding error, you may not have a valid intersection

  28. Ray-Triangle Intersection Fredo Durand Barb Cutler MIT

  29. Matrix A

  30. |A|  determinant of matrix A

More Related