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

shadows in computer graphics
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Shadows in Computer Graphics

Steven Janke November 2014

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

slide-2
SLIDE 2

Shadows (from Doom)

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

slide-3
SLIDE 3

Simple Shadows

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

slide-4
SLIDE 4

Shadows give position information

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

slide-5
SLIDE 5

Shadow Geometry

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

slide-6
SLIDE 6

Camera Model

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

slide-7
SLIDE 7

View Frustum

Camera Near Far View Plane 0,0,0

z

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

slide-8
SLIDE 8

Ideal City (circa 1485)

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

slide-9
SLIDE 9

Perspective Projection

y z E W C C D

E = (0, 0, e), C = (x, y, z), C ∗ = (xs, ys) EW = e, CD = y, ED = e − z △EWC ∗ ∼ △EDC ys = y · e e − z = y 1 − z

e

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

slide-10
SLIDE 10

Albrecht Durer (Man drawing a Lute - 1525)

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

slide-11
SLIDE 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

slide-12
SLIDE 12

Pedro Berreuguete - Anunciation (circa 1500)

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

slide-13
SLIDE 13

Masaccio - Trinity (1426)

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

slide-14
SLIDE 14

Calculating Cube Perspective

ys = y 1 − z

e

xs = x 1 − z

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

slide-15
SLIDE 15

Cubes in Perspective

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

slide-16
SLIDE 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

slide-17
SLIDE 17

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 = | v|| w|cos(θ) = x1x2 + y1y2 + z1z2. (If v and w are perpendicular, then v · w = 0.) Cross Product:

  • v ×

w =

  • i
  • j
  • k

x1 y1 z1 x2 y2 z2

  • =
  • y1

z1 y2 z2

  • i −
  • x1

z1 x2 z2

  • j +
  • x1

y1 x2 y2

  • k

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

slide-18
SLIDE 18

Vector Products

v w v w Θ x1,y1 x2,y2 0,0

Dot Product

A B A B

Cross Product

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

slide-19
SLIDE 19

Transformations

T v =   a11 a12 a13 a21 a22 a23 a31 a32 a33     x y z   =   a11x + a12y + a13z a21x + a22y + a23z a31x + a32y + a33z   Rotation around z-axis uses this matrix: Rz =   cos θ − sin θ sin θ cos θ 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

slide-20
SLIDE 20

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

wh , yh wh ) be any point on the line 3x + 2y = 7.

= ⇒ 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

slide-21
SLIDE 21

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

slide-22
SLIDE 22

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. P = (−1, −10, −22) represents the Cartesian point P = ( 1

22, 10 22)

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

slide-23
SLIDE 23

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

slide-24
SLIDE 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

slide-25
SLIDE 25

Perspective Matrix

Now we can express the perspective transformation as a matrix multiplication: T(P) = MP =     1 1 − 1

e

1         x y z 1     =     x y 1 − z

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

slide-26
SLIDE 26

Perspective Drawing

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

slide-27
SLIDE 27

Two Point Perspective

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

slide-28
SLIDE 28

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

slide-29
SLIDE 29

Desargues Theorem

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

slide-30
SLIDE 30

Additional Vector Algebra

Tensor Product

  • v ⊗

w = v wT =   vx vy vz   wx wy wz

  • =

  vxwx vxwy vxwz vywx vywy vywz vzwx vzwy vzwz   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

slide-31
SLIDE 31

2D Projection

P P’TP E L

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

slide-32
SLIDE 32

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 =   48 8 −40 12 2 −10 6 1 −5   −   45 45 45   =   3 8 −40 12 −43 −10 6 1 −50   T(P) = MP =   3 8 −40 12 −43 −10 6 1 −50     3 1 1   =   −23 −17 −31   Cartesian coordinates for P are (23/31, 17/31).

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

slide-33
SLIDE 33

3D Projection

n P P’ E

P′ = αP + βE.

  • n · (αP + βE) = 0 =

⇒ α = −β( n · E) ( n · P) P′ = −β( n · E)

  • n · P

P + βE P′ = 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

slide-34
SLIDE 34

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) M = (E ⊗ n) − ( n · E)I =     14 −7 14 28 4 −2 4 8 12 −6 12 24 2 −1 2 4     −     28 28 28 28     =     −14 −7 14 28 4 −30 4 8 12 −6 −16 24 2 −1 2 −24     = ⇒ P′ = (−63, −126, 42, −21) This gives Cartesian coordinates (3, 6, −2)

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

slide-35
SLIDE 35

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). The eye point is E = (0, 0, e, 1) and P = (x, y, z, 1). M =     −e −e 1 −e     = −e     1 1 − 1

e

1    

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

slide-36
SLIDE 36

Shadow Geometry

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

slide-37
SLIDE 37

Points in Shadow

Shadow: Fill in the polygon determined by projected vertices. For convex objects, shadows are convex. Vertices that are not incident on both visible and hidden faces are inside the shadow.

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

slide-38
SLIDE 38

Multiple Shadows

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

slide-39
SLIDE 39

Ray Tracing

Camera View Window To Light Source Reflected Ray

v

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

slide-40
SLIDE 40

Shadow Ray

Light

P

Shadow

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

slide-41
SLIDE 41

Soft Shadows

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

slide-42
SLIDE 42

Penumbra & Umbra

Light Object Umbra Penumbra Penumbra

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

slide-43
SLIDE 43

More Soft Shadows

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

slide-44
SLIDE 44

Multiple Lights

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

slide-45
SLIDE 45

Shadow Volume

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

slide-46
SLIDE 46

More Multiple Lights

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

slide-47
SLIDE 47

Further Refinements

Shadow Maps Curves (NURBS) Complex Lighting Models (Radiosity)

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

slide-48
SLIDE 48

Complex Shadows

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

slide-49
SLIDE 49

Reference (2015

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