
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 Steven Janke (Seminar) Shadows in Computer Graphics November 2014 3 / 49 Shadows give position information Steven Janke (Seminar) Shadows in Computer Graphics November 2014 4 / 49 Shadow Geometry Steven Janke (Seminar) Shadows in Computer Graphics November 2014 5 / 49 Camera Model Steven Janke (Seminar) Shadows in Computer Graphics November 2014 6 / 49 View Frustum Far Near -z Camera H0,0,0L View Plane Steven Janke (Seminar) Shadows in Computer Graphics November 2014 7 / 49 Ideal City (circa 1485) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 8 / 49 Perspective Projection y * C C E W z D ∗ E = (0; 0; e); C = (x; y; z); C = (xs ; ys ) EW = e; CD = y; ED = e − z ∗ y · e y 4EWC ∼ 4EDC ys = = z e − z 1 − e Steven Janke (Seminar) Shadows in Computer Graphics November 2014 9 / 49 Albrecht Durer (Man drawing a Lute - 1525) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 10 / 49 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 Pedro Berreuguete - Anunciation (circa 1500) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 12 / 49 Masaccio - Trinity (1426) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 13 / 49 Calculating Cube Perspective y x ys = z xs = z 1 − e 1 − 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 Cubes in Perspective Steven Janke (Seminar) Shadows in Computer Graphics November 2014 15 / 49 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 Vectors ~v = (x1; y1; z1) and w~ = (x2; y2; z2) are displacements. Algebra: ~v + w~ = (x1 + x2; y1 + y2; z1 + z2) and a~v = (ax1; ay1; az1). Dot Product: ~v · w~ = j~vjjw~ jcos(θ) = x1x2 + y1y2 + z1z2. (If ~v and w~ are perpendicular, then ~v · w~ = 0:) Cross Product: ~i ~j ~k y1 z1 ~ x1 z1 ~ x1 y1 ~ ~v × w~ = x1 y1 z1 = i − j + k y2 z2 x2 z2 x2 y2 x2 y2 z2 Steven Janke (Seminar) Shadows in Computer Graphics November 2014 17 / 49 Vector Products Hx1,y1L A ´ B v v - w B Θ w H0,0L Hx2,y2L A Dot Product Cross Product Steven Janke (Seminar) Shadows in Computer Graphics November 2014 18 / 49 Transformations 2 3 2 3 2 3 a11 a12 a13 x a11x + a12y + a13z T~v = 4a21 a22 a235 4y5 = 4a21x + a22y + a23z5 a31 a32 a33 z a31x + a32y + a33z Rotation around z-axis uses this matrix: 2cos θ − sin θ 03 Rz = 4sin θ cos θ 05 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 Homogeneous Coordinates The point P0 = (−1; 5) is on the 2D line 3x + 2y = 7. The vector equation of the line: (3; 2) · (P − P0) = (3; 2) · (x + 1; y − 5) = 0 Let P = (x; y) = ( xh ; yh ) be any point on the line 3x + 2y = 7. wh wh =) 3xh + 2yh − 7wh = (3; 2; −7) · (xh; yh; wh) = 0 (xh; yh; wh) are homogeneous coordinates for the point P. Since wh is arbitrary, there are infinitely many sets of homogeneous coordinates representing P. For example, P0 = (−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 Homogeneous Coordinates for Lines Example (2D Line coordinates) P1 = (3; 2; 1) and P2 = (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 Calculating with Homogeneous Coordinates Example (2D Intersection Point) Consider two lines: (2; 2; −1) and (6; −5; 2) (They represent the lines 2x + 2y − 1 = 0 and 6x − 5y + 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. 1 10 P = (−1; −10; −22) represents the Cartesian point P = ( 22 ; 22 ) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 22 / 49 Points at Infinity Lines 2x + 4y − 8 = 0 and 2x + 4y − 10 = 0 are parallel. The homogeneous point (4; −2; 0) is on both lines. Points of the form (xh; yh; 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 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 Perspective Matrix Now we can express the perspective transformation as a matrix multiplication: 21 0 0 03 2x3 2 x 3 60 1 0 07 6y7 6 y 7 T (P) = MP = 6 7 6 7 = 6 7 40 0 0 05 4z5 4 0 5 1 z 0 0 − e 1 1 1 − 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 Perspective Drawing Steven Janke (Seminar) Shadows in Computer Graphics November 2014 26 / 49 Two Point Perspective Steven Janke (Seminar) Shadows in Computer Graphics November 2014 27 / 49 Projective Geometry Girard Desargues (1591 - 1661) was the founding father. Parallel lines intersect in a point at infinity: (xh; yh; 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 Desargues Theorem Steven Janke (Seminar) Shadows in Computer Graphics November 2014 29 / 49 Additional Vector Algebra Tensor Product 2 3 2 3 vx vx wx vx wy vx wz T ~v ⊗ w~ = ~vw~ = 4vy 5 wx wy wz = 4vy wx vy wy vy wz 5 vz vz wx vz wy vz wz 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 2D Projection L E P’=THPL P Line through E and P is E × P. T (P) = P0 = ~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 2D Projection Example Project P = (3; 1) onto the line 6x + y − 5 = 0 from the point (8; 2). ~L = (6; 1; −5) E = (8; 2; 1) P = (3; 1; 1) M = (E ⊗ ~L) − (~L · E)I 248 8 −403 245 0 0 3 2 3 8 −403 = 412 2 −105 − 4 0 45 0 5 = 412 −43 −105 6 1 −5 0 0 45 6 1 −50 2 3 8 −403 233 2−233 T (P) = MP = 412 −43 −105 415 = 4−175 6 1 −50 1 −31 Cartesian coordinates for P are (23=31; 17=31). Steven Janke (Seminar) Shadows in Computer Graphics November 2014 32 / 49 3D Projection E P n 0 P’ P = αP + βE. −β(~n · E) ~n · (αP + βE) = 0 =) α = (~n · P) −β(~n · E) P0 = P + βE ~n · P P0 = T (P) = (~n · P)E − (~n · E)P = (E ⊗ ~n)P − (~n · E)P =) M = (E ⊗ ~n) − (~n · E)I Steven Janke (Seminar) Shadows in Computer Graphics November 2014 33 / 49 3D Projection Example Eye point: E = (7; 2; 6) Vertex: P = (4; 5; 0) Plane: 2x − y + 2z = −4 ~n = (2; −1; 2; 4) E = (7; 2; 6; 1) P = (4; 5; 0; 1) 214 −7 14 283 228 0 0 0 3 6 4 −2 4 8 7 6 0 28 0 0 7 M = (E ⊗ ~n) − (~n · E)I = 6 7 − 6 7 412 −6 12 245 4 0 0 28 0 5 2 −1 2 4 0 0 0 28 2−14 −7 14 28 3 6 4 −30 4 8 7 0 = 6 7 =) P = (−63; −126; 42; −21) 4 12 −6 −16 24 5 2 −1 2 −24 This gives Cartesian coordinates (3; 6; −2) Steven Janke (Seminar) Shadows in Computer Graphics November 2014 34 / 49 Compare to earlier 3D matrix M = (E ⊗ ~n) − (~n · E)I Perspective projection: Viewing plane is the xy plane with homogeneous representation ~n = (0; 0; 1; 0).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages49 Page
-
File Size-