shadows in computer graphics
play

Shadows in Computer Graphics Steven Janke November 2014 Steven - PowerPoint PPT Presentation

Shadows in Computer Graphics Steven Janke November 2014 Steven Janke (Seminar) Shadows in Computer Graphics November 2014 1 / 49 Shadows (from Doom) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 2 / 49 Simple Shadows


  1. Shadows in Computer Graphics Steven Janke November 2014 Steven Janke (Seminar) Shadows in Computer Graphics November 2014 1 / 49

  2. Shadows (from Doom) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 2 / 49

  3. Simple Shadows Steven Janke (Seminar) Shadows in Computer Graphics November 2014 3 / 49

  4. Shadows give position information Steven Janke (Seminar) Shadows in Computer Graphics November 2014 4 / 49

  5. Shadow Geometry Steven Janke (Seminar) Shadows in Computer Graphics November 2014 5 / 49

  6. Camera Model Steven Janke (Seminar) Shadows in Computer Graphics November 2014 6 / 49

  7. View Frustum Far Near � z Camera � 0,0,0 � View Plane Steven Janke (Seminar) Shadows in Computer Graphics November 2014 7 / 49

  8. Ideal City (circa 1485) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 8 / 49

  9. Perspective Projection y C � C E W z D E = (0 , 0 , e ) , C = ( x , y , z ) , C ∗ = ( x s , y s ) EW = e , CD = y , ED = e − z y s = y · e y △ EWC ∗ ∼ △ EDC e − z = 1 − z e Steven Janke (Seminar) Shadows in Computer Graphics November 2014 9 / 49

  10. Albrecht Durer (Man drawing a Lute - 1525) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 10 / 49

  11. Alberti Perspective Diagram 1. Draw lines from front tile corners to center point C. 2. Select point R on horizontal line so CR is distance to painting. 3. Connect R with front tile corners. 4. Draw horizontal lines through intersections of lines in 3 and vertical line through C. 5. Diagonals through tiles are projected into diagonals. Steven Janke (Seminar) Shadows in Computer Graphics November 2014 11 / 49

  12. Pedro Berreuguete - Anunciation (circa 1500) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 12 / 49

  13. Masaccio - Trinity (1426) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 13 / 49

  14. Calculating Cube Perspective y x y s = x s = 1 − z 1 − z e e Example (Cube Vertices) Eye Coordinates: (0,0,4) World Coordinates: (1 , 1 , 1) , (1 , − 1 , 1) , ( − 1 , − 1 , 1) , ( − 1 , 1 , 1) (1 , 1 , − 1) , (1 , − 1 , − 1) , ( − 1 , − 1 , − 1) , ( − 1 , 1 , − 1) Screen Coordinates: (1 . 33 , 1 . 33) , (1 . 33 , − 1 . 33) , ( − 1 . 33 , − 1 . 33) , ( − 1 . 33 , 1 . 33) (0 . 75 , 0 . 75) , (0 . 75 , − 0 . 75) , ( − 0 . 75 , − 0 . 75) , ( − 0 . 75 , 0 . 75) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 14 / 49

  15. Cubes in Perspective Steven Janke (Seminar) Shadows in Computer Graphics November 2014 15 / 49

  16. Projections Summary Perspective projections and Shadow projections are both projections from a point onto a plane. Next steps: For shadows, we generalize projection to arbitrary plane. Describe calculations compactly and efficiently. Steven Janke (Seminar) Shadows in Computer Graphics November 2014 16 / 49

  17. Vectors � v = ( x 1 , y 1 , z 1 ) and � w = ( x 2 , y 2 , z 2 ) are displacements. Algebra: � v + � w = ( x 1 + x 2 , y 1 + y 2 , z 1 + z 2 ) and a � v = ( ax 1 , ay 1 , az 1 ). Dot Product: � v · � w = | � v || � w | cos ( θ ) = x 1 x 2 + y 1 y 2 + z 1 z 2 . (If � v and � w are perpendicular, then � v · � w = 0 . ) Cross Product: � � � � � i j k � � � � � � � � y 1 z 1 x 1 z 1 x 1 y 1 � � � � � � � � � � � � � � v × � � w = = i − j + x 1 y 1 z 1 k � � � � � � � � y 2 z 2 x 2 z 2 x 2 y 2 � � � � � x 2 y 2 z 2 � � Steven Janke (Seminar) Shadows in Computer Graphics November 2014 17 / 49

  18. Vector Products � x 1 , y 1 � A � B v B v � w Θ w � 0,0 � � x 2 , y 2 � A Dot Product Cross Product Steven Janke (Seminar) Shadows in Computer Graphics November 2014 18 / 49

  19. Transformations      a 11 x + a 12 y + a 13 z  a 11 a 12 a 13 x  = T � v = a 21 a 22 a 23 y a 21 x + a 22 y + a 23 z      a 31 x + a 32 y + a 33 z a 31 a 32 a 33 z Rotation around z-axis uses this matrix:   cos θ − sin θ 0 R z = sin θ cos θ 0   0 0 1 Matrices give linear transformations: T ( � v + � w ) = T � v + T � w and T ( a � v ) = aT � v Cannot represent translations or projections. Steven Janke (Seminar) Shadows in Computer Graphics November 2014 19 / 49

  20. Homogeneous Coordinates The point P 0 = ( − 1 , 5) is on the 2D line 3 x + 2 y = 7. The vector equation of the line: (3 , 2) · ( P − P 0 ) = (3 , 2) · ( x + 1 , y − 5) = 0 w h , y h Let P = ( x , y ) = ( x h w h ) be any point on the line 3 x + 2 y = 7. = ⇒ 3 x h + 2 y h − 7 w h = (3 , 2 , − 7) · ( x h , y h , w h ) = 0 ( x h , y h , w h ) are homogeneous coordinates for the point P . Since w h is arbitrary, there are infinitely many sets of homogeneous coordinates representing P . For example, P 0 = ( − 1 , 5 , 1) = ( − 2 , 10 , 2) = ( − 0 . 5 , 2 . 5 , 0 . 5) Two-dimensional Homogeneous Line equation: � n · P = 0 Steven Janke (Seminar) Shadows in Computer Graphics November 2014 20 / 49

  21. Homogeneous Coordinates for Lines Example (2D Line coordinates) P 1 = (3 , 2 , 1) and P 2 = (5 , 7 , 3) determine a two-dimensional line. � n · (3 , 2 , 1) = 0 and � n · (5 , 7 , 3) = 0. � n = (3 , 2 , 1) × (5 , 7 , 3) = ( − 1 , − 4 , 11) The homogeneous coordinates ( − 1 , − 4 , 11) represent the line. Both points and lines in two dimensions can be represented by homogeneous coordinates ( x , y , w ). Steven Janke (Seminar) Shadows in Computer Graphics November 2014 21 / 49

  22. Calculating with Homogeneous Coordinates Example (2D Intersection Point) Consider two lines: (2 , 2 , − 1) and (6 , − 5 , 2) (They represent the lines 2 x + 2 y − 1 = 0 and 6 x − 5 y + 2 = 0) P is the point of intersection. (2 , 2 , − 1) · P = 0 and (6 , − 5 , 2) · P = 0 P must be a vector perpendicular to the two homogeneous line vectors. P = (2 , 2 , − 1) × (6 , − 5 , 2) = ( − 1 , − 10 , − 22) is the cross product. P = ( − 1 , − 10 , − 22) represents the Cartesian point P = ( 1 22 , 10 22 ) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 22 / 49

  23. Points at Infinity Lines 2 x + 4 y − 8 = 0 and 2 x + 4 y − 10 = 0 are parallel. The homogeneous point (4 , − 2 , 0) is on both lines. Points of the form ( x h , y h , 0) are points at infinity. Notice that (4 , − 2 , 0) and (5 , 3 , 0) are distinct points at infinity. Points in 2D Points at Infinity Steven Janke (Seminar) Shadows in Computer Graphics November 2014 23 / 49

  24. Homogeneous Coordinates in Three Dimensions Homogeneous coordinates for three dimensional points add a fourth coordinate: Cartesian ( x , y , z ) = ⇒ Homogeneous ( x , y , z , 1) or ( tx , ty , tz , t ) Since planes are determined by a normal and a point, ( tx , ty , tz , t ) also represents a plane. Homogeneous plane equation: � n · P = 0 Lines have homogeneous coordinates called Pl¨ ucker coordinates. Steven Janke (Seminar) Shadows in Computer Graphics November 2014 24 / 49

  25. Perspective Matrix Now we can express the perspective transformation as a matrix multiplication:  1 0 0 0   x   x  0 1 0 0 y y       T ( P ) = MP =  =       0 0 0 0 0 z      − 1 1 − z 0 0 1 1 e e In the space of homogeneous coordinates (Projective Space), the perspective transformation is a linear function. Steven Janke (Seminar) Shadows in Computer Graphics November 2014 25 / 49

  26. Perspective Drawing Steven Janke (Seminar) Shadows in Computer Graphics November 2014 26 / 49

  27. Two Point Perspective Steven Janke (Seminar) Shadows in Computer Graphics November 2014 27 / 49

  28. Projective Geometry Girard Desargues (1591 - 1661) was the founding father. Parallel lines intersect in a point at infinity: ( x h , y h , 0) Points at infinity fall on a line. Duality: In 2D, for any theorem about points there is a theorem about lines. No concept of length or angle. Projective transformations are linear transformations. In 2D, there is a projective transformation that sends a given four points to another specified four points. Steven Janke (Seminar) Shadows in Computer Graphics November 2014 28 / 49

  29. Desargues Theorem Steven Janke (Seminar) Shadows in Computer Graphics November 2014 29 / 49

  30. Additional Vector Algebra Tensor Product     v x v x w x v x w y v x w z w T =  � � � v ⊗ � w = � v � = v y w x w y w z v y w x v y w y v y w z    v z v z w x v z w y v z w z Vector Triple Product � A × ( � B × � C ) = ( � A · � C ) � B − ( � A · � B ) � C Dot to Tensor ( � A · � C ) � B = ( � B ⊗ � A ) � C Steven Janke (Seminar) Shadows in Computer Graphics November 2014 30 / 49

  31. 2D Projection L E P’ � T � P � P Line through E and P is E × P . T ( P ) = P ′ = � L × ( E × P ) = ( � L · P ) E − ( � L · E ) P = (( E ⊗ � L ) − ( � L · E ) I ) P = MP Steven Janke (Seminar) Shadows in Computer Graphics November 2014 31 / 49

Recommend


More recommend