Viewing Steve Marschner CS 4620 Cornell University Cornell CS4620 - - PowerPoint PPT Presentation

viewing
SMART_READER_LITE
LIVE PREVIEW

Viewing Steve Marschner CS 4620 Cornell University Cornell CS4620 - - PowerPoint PPT Presentation

Viewing Steve Marschner CS 4620 Cornell University Cornell CS4620 Fall 2020 Steve Marschner 1 Viewing 1. Projection and perspective Cornell CS4620 Fall 2020 Steve Marschner 2 Parallel projection To render an image of a 3D


slide-1
SLIDE 1

Steve Marschner CS 4620 Cornell University

Steve Marschner • Cornell CS4620 Fall 2020

Viewing

1

slide-2
SLIDE 2
  • 1. Projection and perspective

Steve Marschner • Cornell CS4620 Fall 2020

Viewing

2

slide-3
SLIDE 3
  • To render an image of a 3D scene, we project it onto a plane
  • Simplest kind of projection is parallel projection

Steve Marschner • Cornell CS4620 Fall 2020

Parallel projection

3

image scene projection plane

slide-4
SLIDE 4
  • Projection is along lines parallel to a fixed direction

– projection plane is perpendicular to projection direction

Steve Marschner • Cornell CS4620 Fall 2020

“Orthographic” projection

4

(in graphics we normally don’t distinguish from axonometric)

slide-5
SLIDE 5
  • Projection is along lines parallel to a fixed direction

– projection plane is perpendicular to projection direction – image height determines which objects appear in image

Steve Marschner • Cornell CS4620 Fall 2020

“Orthographic” projection

4

(in graphics we normally don’t distinguish from axonometric)

slide-6
SLIDE 6
  • Projection is along lines parallel to a fixed direction

– projection plane is perpendicular to projection direction – image height determines which objects appear in image – size of projection does not change with distance

Steve Marschner • Cornell CS4620 Fall 2020

“Orthographic” projection

4

(in graphics we normally don’t distinguish from axonometric)

slide-7
SLIDE 7
  • Projection is along lines parallel to a fixed direction

– projection plane is perpendicular to projection direction – image height determines which objects appear in image – size of projection does not change with distance

Steve Marschner • Cornell CS4620 Fall 2020

“Orthographic” projection

4

(in graphics we normally don’t distinguish from axonometric)

slide-8
SLIDE 8
  • Emphasis on cube-like objects

– traditional in mechanical and architectural drawing

Planar Geometric Projections Parallel Oblique Multiview Orthographic Perspective One-point Two-point Three-point Orthographic Axonometric

[after Carlbom & Paciorek 78]

Steve Marschner • Cornell CS4620 Fall 2020

Classical projections—parallel

5

slide-9
SLIDE 9

Steve Marschner • Cornell CS4620 Fall 2020

Orthographic in architecture

[Carlbom & Paciorek 78]

6

slide-10
SLIDE 10

– projection plane parallel to a coordinate plane – projection direction perpendicular to projection plane

[Carlbom & Paciorek 78]

Steve Marschner • Cornell CS4620 Fall 2020

Orthographic in traditional drawing

7

slide-11
SLIDE 11

[Carlbom & Paciorek 78]

Steve Marschner • Cornell CS4620 Fall 2020

Other parallel in traditional drawing

8

axonometric: projection plane perpendicular to projection direction but not parallel to coordinate planes

slide-12
SLIDE 12

Steve Marschner • Cornell CS4620 Fall 2020

View volume: orthographic

9

slide-13
SLIDE 13
  • Ancient times: Greeks wrote about laws of perspective
  • Renaissance: perspective is adopted by artists

Duccio c. 1308

Steve Marschner • Cornell CS4620 Fall 2020

History of projection

10

slide-14
SLIDE 14
  • Later Renaissance: perspective formalized precisely

da Vinci c. 1498

Steve Marschner • Cornell CS4620 Fall 2020

History of projection

11

slide-15
SLIDE 15

Steve Marschner • Cornell CS4620 Fall 2020

Plane projection in drawing

Albrecht Dürer

12

slide-16
SLIDE 16

Steve Marschner • Cornell CS4620 Fall 2020

Plane projection in drawing

source unknown

13

slide-17
SLIDE 17
  • This is another model for what we are doing

– applies more directly in realistic rendering

Steve Marschner • Cornell CS4620 Fall 2020

Plane projection in photography

14

[Source unknown]

slide-18
SLIDE 18

Steve Marschner • Cornell CS4620 Fall 2020

Plane projection in photography

[Richard Zakia]

15

slide-19
SLIDE 19
  • Projection is along lines through a fixed point

– plane normally perpendicular to center projection line

Steve Marschner • Cornell CS4620 Fall 2020

Perspective projection

16

slide-20
SLIDE 20
  • Projection is along lines through a fixed point

– plane normally perpendicular to center projection line – angular field of view determines which objects appear in image

α = 2 tan−1 h

2d

Steve Marschner • Cornell CS4620 Fall 2020

Perspective projection

16

slide-21
SLIDE 21
  • Projection is along lines through a fixed point

– plane normally perpendicular to center projection line – angular field of view determines which objects appear in image

α = 2 tan−1 h

2d

– size of projection is inversely proportional to distance

y′ = dy/z

Steve Marschner • Cornell CS4620 Fall 2020

Perspective projection

16

slide-22
SLIDE 22
  • Projection is along lines through a fixed point

– plane normally perpendicular to center projection line – angular field of view determines which objects appear in image

α = 2 tan−1 h

2d

– size of projection is inversely proportional to distance

y′ = dy/z

Steve Marschner • Cornell CS4620 Fall 2020

Perspective projection

16

slide-23
SLIDE 23
  • Emphasis on cube-like objects

– traditional in mechanical and architectural drawing

Planar Geometric Projections Parallel Oblique Multiview Orthographic Perspective One-point Two-point Three-point Orthographic Axonometric

[after Carlbom & Paciorek 78]

Steve Marschner • Cornell CS4620 Fall 2020

Classical projections—perspective

17

slide-24
SLIDE 24

Steve Marschner • Cornell CS4620 Fall 2020

Perspective

  • ne-point: projection

plane parallel to a coordinate plane (to two coordinate axes) two-point: projection plane parallel to one coordinate axis three-point: projection plane not parallel to a coordinate axis

[Carlbom & Paciorek 78]

18

slide-25
SLIDE 25

Steve Marschner • Cornell CS4620 Fall 2020

View volume: perspective

19

slide-26
SLIDE 26
  • The angle between the rays corresponding to opposite edges
  • f a perspective image

– simpler to compute for “normal” perspective – have to decide to measure vert., horiz., or diag.

  • In cameras, determined by focal length

– confusing because of many image sizes – for 35mm format (36mm by 24mm image) – 18mm = 67° v.f.o.v. — super-wide angle – 28mm = 46° v.f.o.v. — wide angle – 50mm = 27° v.f.o.v. — “normal” – 100mm = 14° v.f.o.v. — narrow angle (“telephoto”)

Steve Marschner • Cornell CS4620 Fall 2020

Field of view (or f.o.v.)

20

slide-27
SLIDE 27
  • Determines “strength” of perspective effects

close viewpoint wide angle large scale differences far viewpoint narrow angle small scale differences

[Ansel Adams]

Steve Marschner • Cornell CS4620 Fall 2020

Field of view

21

slide-28
SLIDE 28
  • In photography, wide angle lenses are specialty tools

– “hard to work with” – easy to create weird-looking perspective effects

  • In graphics, you can type in

whatever f.o.v. you want – and people often type in big numbers!

[Ken Perlin]

Steve Marschner • Cornell CS4620 Fall 2020

Choice of field of view

22

slide-29
SLIDE 29
  • Lengths, length ratios

[Carlbom & Paciorek 78]

Steve Marschner • Cornell CS4620 Fall 2020

Perspective “distortions”

23

slide-30
SLIDE 30
  • View direction no longer coincides with projection plane

normal (one more parameter) – objects at different distances still same size – objects are shifted in the image depending on their depth

Steve Marschner • Cornell CS4620 Fall 2020

Oblique projection

24

slide-31
SLIDE 31
  • View direction no longer coincides with projection plane

normal (one more parameter) – objects at different distances still same size – objects are shifted in the image depending on their depth

Steve Marschner • Cornell CS4620 Fall 2020

Oblique projection

24

slide-32
SLIDE 32
  • View direction no longer coincides with projection plane

normal (one more parameter) – objects at different distances still same size – objects are shifted in the image depending on their depth

Steve Marschner • Cornell CS4620 Fall 2020

Oblique projection

24

slide-33
SLIDE 33
  • View direction no longer coincides with projection plane

normal (one more parameter) – objects at different distances still same size – objects are shifted in the image depending on their depth

Steve Marschner • Cornell CS4620 Fall 2020

Oblique projection

24

slide-34
SLIDE 34

Steve Marschner • Cornell CS4620 Fall 2020

Off-axis parallel

axonometric: projection plane perpendicular to projection direction but not parallel to coordinate planes

  • blique: projection plane

parallel to a coordinate plane but not perpendicular to projection direction.

[Carlbom & Paciorek 78]

25

slide-35
SLIDE 35
  • Perspective but with projection plane not perpendicular to

view direction – additional parameter: projection plane normal – exactly equivalent to cropping out an off-center rectangle from a larger “normal” perspective – corresponds to view camera in photography

Steve Marschner • Cornell CS4620 Fall 2020

Shifted perspective projection

26

slide-36
SLIDE 36
  • Perspective but with projection plane not perpendicular to

view direction – additional parameter: projection plane normal – exactly equivalent to cropping out an off-center rectangle from a larger “normal” perspective – corresponds to view camera in photography

Steve Marschner • Cornell CS4620 Fall 2020

Shifted perspective projection

26

slide-37
SLIDE 37
  • Perspective but with projection plane not perpendicular to

view direction – additional parameter: projection plane normal – exactly equivalent to cropping out an off-center rectangle from a larger “normal” perspective – corresponds to view camera in photography

Steve Marschner • Cornell CS4620 Fall 2020

Shifted perspective projection

26

slide-38
SLIDE 38
  • Perspective but with projection plane not perpendicular to

view direction – additional parameter: projection plane normal – exactly equivalent to cropping out an off-center rectangle from a larger “normal” perspective – corresponds to view camera in photography

Steve Marschner • Cornell CS4620 Fall 2020

Shifted perspective projection

26

slide-39
SLIDE 39
  • Control convergence of parallel lines
  • Standard example: architecture

– buildings are taller than you, so you look up – top of building is farther away, so it looks smaller

  • Solution: make projection plane parallel to facade

– top of building is the same distance from the projection plane

  • Same perspective effects can be achieved using post-

processing – (though not the focus effects) – choice of which rays vs. arrangement of rays in image

Steve Marschner • Cornell CS4620 Fall 2020

Why shifted perspective?

27

slide-40
SLIDE 40

Steve Marschner • Cornell CS4620 Fall 2020

[Philip Greenspun]

camera tilted up: converging vertical lines

28

slide-41
SLIDE 41

Steve Marschner • Cornell CS4620 Fall 2020

[Philip Greenspun]

lens shifted up: parallel vertical lines

29

slide-42
SLIDE 42
  • 2. Cameras for ray tracing

Steve Marschner • Cornell CS4620 Fall 2020

Viewing

30

slide-43
SLIDE 43

Steve Marschner • Cornell CS4620 Fall 2020

Ray tracing algorithm

for each pixel { compute viewing ray intersect ray with scene compute illumination at visible point put result into image }

31

slide-44
SLIDE 44

Steve Marschner • Cornell CS4620 Fall 2020

Ray tracing algorithm

for each pixel { compute viewing ray intersect ray with scene compute illumination at visible point put result into image }

31

slide-45
SLIDE 45

Steve Marschner • Cornell CS4620 Fall 2020

Generating eye rays

32

viewing ray viewing window pixel position viewing ray pixel position viewing window viewpoint

perspective

  • rthographic
  • ray origin fixed
  • ray direction varies
  • ray origin varies
  • ray direction fixed
slide-46
SLIDE 46
  • Ray origin (varying): pixel position on viewing window
  • Ray direction (constant): view direction

– but where exactly is the view rectangle?

Steve Marschner • Cornell CS4620 Fall 2020

Generating eye rays—orthographic

33

viewing ray viewing window pixel position

slide-47
SLIDE 47
  • Positioning the view rectangle

– establish three vectors to be camera basis: u, v, w – view rectangle is in u–v plane, specified by l, r, t, b (often l = –r and b = –t)

  • Generating rays

– for (u, v) in [l, r] × [b, t] – ray.origin = e + u u + v v – ray.direction = –w

Steve Marschner • Cornell CS4620 Fall 2020

Generating eye rays—orthographic

34

u e w v

slide-48
SLIDE 48
  • Could require user to provide e, u, v, and w

– but this is error prone and unintuitive

  • Instead, calculate basis from things the user cares about

– viewpoint: where the camera is: e – view direction: which way the camera is looking: d – up vector: how the camera is oriented

  • This is enough to calculate u, v, and w

– set w parallel to v.p. normal, facing away from d – set u perpendicular to w and perpendicular to up-vector – set v perpendicular to w and u to form a right-handed ONB

Steve Marschner • Cornell CS4620 Fall 2020

Establishing the camera basis

35

slide-49
SLIDE 49

Steve Marschner • Cornell CS4620 Fall 2020

Camera basis

36

d v dup w u

forming the basis with d and up vector given

slide-50
SLIDE 50
  • To calculate the frame we need:

– eye (or “from”) point – view direction (vector pointing in direction camera is looking) – up vector

  • Common alternate form: (“from-at-up”)

– replace view direction with target (or “at”) point (point towards which camera is looking) – then

  • Also need a rectangle on the view plane

– need left, right, top, bottom ( ) – can assume centered and just give width and height – then , , ,

e d a d = a − e l, r, b, t w h l = − w/2 r = w/2 b = − h/2 t = h/2

Steve Marschner • Cornell CS4620 Fall 2020

Specifying orthographic views

37

slide-51
SLIDE 51

Steve Marschner • Cornell CS4620 Fall 2020

Orthographic views of a cube

38

eye: 10, 4.2, 6 target: 0, 0, 0 up: 0, 1, 0 size: 8 x 5 eye: –10, 0, 0 target: 0, 0, 0 up: 0, 1, 0 size: 8 x 5 eye: 10, 4.2, 6 viewDir: –5, –2.1, –3 up: 0, 1, 0 rect: [-4,4] x [–2.5, 2.5] eye: –10, 0, 0 viewDir: 1, 0, 0 up: 0, 1, 0 rect: [-4,4] x [–2.5, 2.5]

slide-52
SLIDE 52
  • Ray origin (constant): viewpoint
  • Ray direction (varying): toward pixel position on viewing

window

Steve Marschner • Cornell CS4620 Fall 2020

Generating eye rays—perspective

39

viewing ray pixel position viewing window viewpoint

slide-53
SLIDE 53
  • Positioning the view rectangle

– establish three vectors to be camera basis: u, v, w – view rectangle is parallel to u–v plane, at w = –d, specified by l, r, t, b

  • Generating rays

– for (u, v) in [l, r] × [b, t] – ray.origin = e – ray.direction = –d w + u u + v v

Steve Marschner • Cornell CS4620 Fall 2020

Generating eye rays—perspective

40

u e v w

slide-54
SLIDE 54
  • Frame is the same as orthographic case
  • Still need a rectangle on the view plane
  • Additionally need projection distance
  • Direct approach:

– provide rectangle as

  • r

– provide projection distance

  • Field-of-view approach:

– provide vertical angular field of view

(occasionally horizontal, rarely diagonal)

– establishes ratio of to – provide aspect ratio

d l, r, b, t w, h d α h d r = w/h h = 2d tan α

2

w = rh

Steve Marschner • Cornell CS4620 Fall 2020

Specifying perspective views

41

slide-55
SLIDE 55

Steve Marschner • Cornell CS4620 Fall 2020

Perspective views of a cube

42

eye: 10, 4.2, 6 target: 0, 0, 0 up: 0, 1, 0 vfov: 36.87° aspect: 1.6 eye: 2.5, 1.05, 1.5 target: 0, 0, 0 up: 0, 1, 0 vfov: 106.26° aspect: 1.6 eye: 10, 4.2, 6 viewDir: –5, –2.1, –3 up: 0, 1, 0 projDist: 12 size: 8 x 5 eye: 2.5, 1.05, 1.5 viewDir: –5, –2.1, –3 up: 0, 1, 0 projDist: 3 size: 8 x 5

slide-56
SLIDE 56
  • Key operation: generate ray for image position
  • Modularity problem: Camera shouldn’t have to worry about

image resolution – better solution: normalized coordinates

Steve Marschner • Cornell CS4620 Fall 2020

Software interface for cameras

43

class Camera { … Ray generateRay(int col, int row); } class Camera { … Ray generateRay(float u, float v); }

args go from 0, 0 to width – 1, height – 1 args go from 0, 0 to 1, 1

slide-57
SLIDE 57
  • One last detail: exactly where are pixels located?

Steve Marschner • Cornell CS4620 Fall 2020

Pixel-to-image mapping

44

u = l + (r − l)(i + 0.5)/nx v = b + (t − b)(j + 0.5)/ny

u = l u = r v = b v = t

j i

i = –.5 i = 3.5 j = 2.5 j = –.5

u = 0 u = 1 v = 0 v = 1

u = (i + 0.5)/nx v = (j + 0.5)/ny