1 / 85

CS 431/636 Advanced Rendering Techniques

CS 431/636 Advanced Rendering Techniques. Dr. David Breen University Crossings 149 Tuesday 6PM  8:50PM. Presentation 2 4/7/09. Start Up. Any questions from last time? Go over sampling image plane? Or intersection algorithms?. Slide Credits.

shen
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 2 4/7/09

  2. Start Up • Any questions from last time? • Go over sampling image plane? • Or intersection algorithms?

  3. Slide Credits • Leonard McMillan, Seth Teller, Fredo Durand, Barb Cutler - MIT • G. Drew Kessler, Larry Hodges - Georgia Institute of Technology • John Hart - University of Illinois • Rick Parent - Ohio State University

  4. More Geometry & Intersections

  5. Ray/Plane Intersection 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) Plane is defined by [A, B, C, D] Ax + By + Cz + D = 0 for a point in the plane Normal Vector, N = [A, B, C] (unit vector) A2 + B2 + C2 = 1 D = - N • P0 (P0 - point in plane)

  6. Ray/Plane (cont.) Substitute the ray equation into the plane equation: A(xo + xdt) + B(yo + ydt) + C(zo +zdt) + D = 0 Solve for t: t = -(Axo + Byo + Czo + D) / (Axd + Byd + Czd) t = -(N • Ro - N • P0 ) / (N • Rd)

  7. N • Rd = 0 N • Rd > 0 Ro Ro t < 0 t > 0 What Can Happen?

  8. Ray/Plane Summary Intersection point: (xi, yi, zi) = (xo + xdti, yo + ydti, zo + zdti) • Calculate N • Rd and compare it to zero. • Calculate ti and compare it to zero. • Compute intersection point. • Flip normal if N • Rd is positive

  9. Ray-Parallelepiped Intersection • Axis-aligned • From (X1, Y1, Z1) to (X2, Y2, Z2) • Ray P(t)=Ro+Rdt y=Y2 y=Y1 x=X1 x=X2 Rd Ro

  10. y=Y2 y=Y1 x=X1 x=X2 Rd Ro Naïve ray-box Intersection • Use 6 plane equations • Compute all 6 intersection • Check that points are inside boxAx+By+Cz+D ≤ 0

  11. y=Y2 y=Y1 x=X1 x=X2 Rd Ro Factoring out computation • Pairs of planes have the same normal • Normals have only one non-0 component • Do computations one dimension at a time • Maintain tnear and tfar (closest and farthest so far)

  12. Test if parallel • If Rdx = 0, then ray is parallel • If Rox < X1 or Rox > x2 return false y=Y2 y=Y1 Rd x=X1 x=X2 Ro

  13. t2 y=Y2 t1 y=Y1 x=X1 x=X2 Rd Ro If not parallel • Calculate intersection distance t1 and t2 • t1 = (X1-Rox)/Rdx • t2 = (X2-Rox)/Rdx

  14. t2x t1x tfar tnear y=Y2 t2y tfar Rd Ro y=Y1 t1y x=X1 x=X2 Test 1 • Maintain tnear and tfar • If t1 > t2, swap • if t1 > tnear, tnear = t1 • if t2 < tfar, tfar = t2 • If tnear > tfar, box is missed

  15. Test 2 • If tfar < 0, box is behind Rd Ro y=Y2 tfar t2x t1x y=Y1 x=X1 x=X2

  16. y=Y2 tfar tnear y=Y1 t1y Rd x=X1 x=X2 Ro Algorithm recap • Do for all 3 axes • Calculate intersection distance t1 and t2 • Maintain tnear and tfar • If tnear > tfar, box is missed • If tfar < 0, box is behind • If box survived tests, return intersection at tnear • If tnear is negative, return tfar

  17. Ray/Ellipsoid Intersection Ray/Cylinder Intersection Ellipsoid's surface is defined by the set of points {(xs, ys, zs)} satisfying the equation: (xs/ a)2 + (ys/ b)2 + (zs/ c)2 - 1 = 0 Cylinder's surface is defined by the set of points {(xs, ys, zs)} satisfying the equation: (xs)2 + (ys)2 - r2 = 0 -z0 ≤ zs ≤ z0 Centers at origin

  18. Ray/Ellipsoid Intersection Ray/Cylinder Intersection • Substitute ray equation into surface equations • This is a quadratic equation in t: • At2 + Bt + C = 0 • Analyze as before • Solve for t with quadratic formula • Plug t back into ray equation - Done • Well,… not exactly

  19. Ray/Cylinder Intersection • Is intersection point Pi between -Z0 and Z0? • If not, Pi is not valid • Also need to do intersection test with z = -Z0 , Z0 plane • If (Pix)2 + (Piy)2 ≤ r2, you’ve intersected a “cap” • Which valid intersection is closer?

  20. Superquadrics

  21. Bezier Patch • Patch of order (n, m) can be defined in terms of a set of (n + 1)(m + 1) control points Pi+1,j+1 for integer indices i = 0 to n, j = 0 to m.

  22. Tesselate Patches and Superquadrics

  23. Tesselate Patches and Superquadrics

  24. Utah Teapot • Modeled by 32 Bézier Patches • Control points available at http://www.holmes3d.net/graphics/teapot

  25. SMF Triangle Meshes v -1 -1 -1 v 1 -1 -1 v -1 1 -1 v 1 1 -1 v -1 -1 1 v 1 -1 1 v -1 1 1 v 1 1 1 f 1 3 4 f 1 4 2 f 5 6 8 f 5 8 7 f 1 2 6 f 1 6 5 f 3 7 8 f 3 8 4 f 1 5 7 f 1 7 3 f 2 4 8 f 2 8 6 vertices triangles Draw data structure

  26. Triangle Meshes (.iv)

  27. Transformations & Hierarchical Models

  28. a e i m b f j n c g k o d h l p x y z w x' y' z' w' = p' = M p Homogeneous Coordinates • Add an extra dimension • in 2D, we use 3 x 3 matrices • In 3D, we use 4 x 4 matrices • Each point has an extra value, w

  29. a e i 0 b f j 0 c g k 0 d h l 1 x y z 1 x' y' z' 1 = Homogeneous Coordinates • Most of the time w = 1, and we can ignore it

  30. 1 0 0 0 0 1 0 0 0 0 1 0 tx ty tz 1 x y z 1 x' y' z' 1 x' y' z' = Translate(c,0,0) Translate (tx, ty, tz) y p' p • Why bother with the extra dimension?Because now translations can be encoded in the matrix! x c

  31. sx 0 0 0 0 sy 0 0 0 0 sz 0 0 0 0 1 x y z 1 x' y' z' 1 = Scale(s,s,s) Scale (sx, sy, sz) p' y p q' • Isotropic (uniform) scaling: sx = sy = sz • You only have to implement uniform scaling q x

  32. ZRotate() Rotation y p' θ • About z axis p x z cos  sin  0 0 -sin  cos  0 0 0 0 1 0 0 0 0 1 x y z 1 x' y' z' 1 =

  33. 0 cos  sin  0 0 -sin  cos  0 0 0 0 1 x y z 1 x' y' z' 1 1 0 0 0 = cos  0 -sin  0 0 1 0 0 sin  0 cos  0 0 0 0 1 x y z 1 x' y' z' 1 = Rotation • About x axis: • About y axis:

  34. kxkx(1-c)+c kykx(1-c)+kzs kzkx(1-c)-kys 0 kykx(1-c)-kzs kyky(1-c)+c kzky(1-c)+kxs 0 kxkz(1-c)+kys kykz(1-c)-kxs kzkz(1-c)+c 0 0 0 0 1 x y z 1 x' y' z' 1 = Rotate(k, ) Rotation y θ k • About (kx, ky, kz), an arbitrary unit vector (Rodrigues Formula) x z where c = cos  & s = sin 

  35. 0 0 0 0 0 0 1 1 1 How are transforms combined? Scale then Translate (5,3) (2,2) Scale(2,2) Translate(3,1) (1,1) (3,1) (0,0) (0,0) Use matrix multiplication: p' = T ( S p ) = ((TS) p) 0 1 0 2 0 2 1 0 3 1 2 0 0 0 2 0 3 1 TS = = Caution: matrix multiplication is NOT commutative!

  36. Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p (5,3) (2,2) Scale(2,2) Translate(3,1) (1,1) (3,1) (0,0) (0,0) Translate then Scale: p' = S ( T p ) = ST p (8,4) (4,2) Translate(3,1) Scale(2,2) (6,2) (1,1) (3,1) (0,0)

  37. 0 0 0 0 0 0 1 1 1 Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p 0 1 0 0 2 0 0 2 0 1 0 0 3 1 1 2 0 0 0 0 1 2 0 0 3 1 1 TS = = Translate then Scale: p' = S ( T p ) = ST p 0 2 0 1 0 2 2 0 0 0 1 0 3 1 2 0 6 2 ST = =

  38. Transformations in Ray Tracing

  39. Transformations in Modeling • Position objects in a scene • Change the shape of objects • Create multiple copies of objects • Projection for virtual cameras • Animations

  40. Scene Description Scene Materials Camera Lights Background Objects

  41. Simple Scene Description File Camera { center 0 0 10 direction 0 0 -1 up 0 1 0 } Lights { numLights 1 DirectionalLight { direction -0.5 -0.5 -1 color 1 1 1 } } Background { color 0.2 0 0.6 } Materials { numMaterials <n> <MATERIALS> } Group { numObjects <n> <OBJECTS> }

  42. Hierarchical Models • Logical organization of scene

  43. Simple Example with Groups Group { numObjects 3 Group { numObjects 3 Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { numObjects 2 Group { Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { Box { <BOX PARAMS> } Sphere { <SPHERE PARAMS> } Sphere { <SPHERE PARAMS> } } } Plane { <PLANE PARAMS> } }

  44. Adding Materials Group { numObjects 3 Group { numObjects 3 Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { numObjects 2 Group { Box { <BOX PARAMS> } Box { <BOX PARAMS> } Box { <BOX PARAMS> } } Group { Box { <BOX PARAMS> } Sphere { <SPHERE PARAMS> } Sphere { <SPHERE PARAMS> } } } Plane { <PLANE PARAMS> } }

  45. Adding Transformations

  46. Using Transformations • Position the logical groupings of objects within the scene • Transformation in group

  47. Directed Acyclic Graph is more efficient and useful

  48. Processing Model Transformattions • Goal • Get everything into world coordinates • Traverse graph/tree in depth-first order • Concatenate transformations • Can store intermediate transformations • Apply/associate final transformation to primitive at leaf node • What about cylinders, superquadrics, etc.? • Transform ray!

  49. r minor r major (x,y) r = 1 (0,0) World Space Object Space Transform the Ray • Map the ray from World Space to Object Space pWS = M pOS pOS = M-1 pWS

More Related