Viewing/Projections IV Week 4, Fri Feb 1 - - PowerPoint PPT Presentation

viewing projections iv week 4 fri feb 1
SMART_READER_LITE
LIVE PREVIEW

Viewing/Projections IV Week 4, Fri Feb 1 - - PowerPoint PPT Presentation

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections IV Week 4, Fri Feb 1 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2008 News extra TA office hours in lab next week to answer questions


slide-1
SLIDE 1

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner http://www.ugrad.cs.ubc.ca/~cs314/Vjan2008

Viewing/Projections IV Week 4, Fri Feb 1

slide-2
SLIDE 2

2

News

  • extra TA office hours in lab next week to

answer questions

  • Mon 1-3
  • Tue 2-4
  • Wed 1-3
  • reminder
  • Wed 2/6: Homework 1 due 1pm sharp
  • Wed 2/6: Project 1 due 6pm.
slide-3
SLIDE 3

3

Review: View Volumes

  • specifies field-of-view, used for clipping
  • restricts domain of z stored for visibility test

z perspective view volume perspective view volume

  • rthographic view volume
  • rthographic view volume

x=left x=right y=top y=bottom z=-near z=-far x VCS x z VCS y y x=left y=top x=right z=-far z=-near y=bottom

slide-4
SLIDE 4

4

Review: Understanding Z

  • z axis flip changes coord system handedness
  • RHS before projection (eye/view coords)
  • LHS after projection (clip, norm device coords)

x z

VCS

y x=left y=top x=right z=-far z=-near y=bottom x z

NDCS

y

(-1,-1,-1) (1,1,1)

slide-5
SLIDE 5

5

Review: Projection Normalization

  • warp perspective view volume to orthogonal

view volume

  • render all scenes with orthographic projection!
  • aka perspective warp

x z=α z=d x z=0 z=d

slide-6
SLIDE 6

6

Review: Projective Rendering Pipeline

OCS - object/model coordinate system WCS - world coordinate system VCS - viewing/camera/eye coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device/display/screen coordinate system

OCS OCS O2W O2W VCS VCS CCS CCS NDCS NDCS DCS DCS

modeling modeling transformation transformation viewing viewing transformation transformation projection projection transformation transformation viewport viewport transformation transformation perspective perspective divide divide

  • bject

world viewing device normalized device clipping W2V W2V V2C V2C N2D N2D C2N C2N WCS WCS

slide-7
SLIDE 7

7

Review: Separate Warp From Homogenization

  • warp requires only standard matrix multiply
  • distort such that orthographic projection of distorted
  • bjects is desired persp projection
  • w is changed
  • clip after warp, before divide
  • division by w: homogenization

CCS CCS NDCS NDCS

alter w alter w / w / w

VCS VCS

projection projection transformation transformation

viewing normalized device clipping

perspective perspective division division

V2C V2C C2N C2N

slide-8
SLIDE 8

8

Reading for Viewing

  • FCG Chapter 7 Viewing
  • FCG Section 6.3.1 Windowing Transforms
  • RB rest of Chap Viewing
  • RB rest of App Homogeneous Coords
slide-9
SLIDE 9

9

Reading for Next Time

  • RB Chap Color
  • FCG Sections 3.2-3.3
  • FCG Chap 20 Color
  • FCG Chap 21.2.2 Visual Perception (Color)
slide-10
SLIDE 10

10

Projective Rendering Pipeline

OCS - object/model coordinate system WCS - world coordinate system VCS - viewing/camera/eye coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device/display/screen coordinate system

OCS OCS O2W O2W VCS VCS CCS CCS NDCS NDCS DCS DCS

modeling modeling transformation transformation viewing viewing transformation transformation projection projection transformation transformation viewport viewport transformation transformation perspective perspective divide divide

  • bject

world viewing device normalized device clipping W2V W2V V2C V2C N2D N2D C2N C2N WCS WCS

slide-11
SLIDE 11

11

NDC to Device Transformation

  • map from NDC to pixel coordinates on display
  • NDC range is x = -1...1, y = -1...1, z = -1...1
  • typical display range: x = 0...500, y = 0...300
  • maximum is size of actual screen
  • z range max and default is (0, 1), use later for visibility

x x y y viewport viewport NDC NDC 500 300

  • 1

1 1

  • 1

x x y y

glViewport(0,0,w,h); glDepthRange(0,1); // depth = 1 by default

slide-12
SLIDE 12

12

Origin Location

  • yet more (possibly confusing) conventions
  • OpenGL origin: lower left
  • most window systems origin: upper left
  • then must reflect in y
  • when interpreting mouse position, have to flip your

y coordinates

x x y y viewport viewport NDC NDC 500 300

  • 1

1 1

  • 1

x x y y

slide-13
SLIDE 13

13

N2D Transformation

  • general formulation
  • reflect in y for upper vs. lower left origin
  • scale by width, height, depth
  • translate by width/2, height/2, depth/2
  • FCG includes additional translation for pixel centers at

(.5, .5) instead of (0,0) x x y y viewport viewport NDC NDC 500 300

  • 1

1 1

  • 1

height width x x y y

slide-14
SLIDE 14

14

N2D Transformation

x x y y viewport viewport NDC NDC 500 300

  • 1

1 1

  • 1

height width x x y y

xD yD zD 1

  • =

1 width 2 1 2 1 height 2 1 2 1 depth 2 1

  • width

2 height 2 depth 2 1

  • 1

1 1 1

  • xN

yN zN 1

  • =

width(xN +1) 1 2 height(yN +1) 1 2 depth(zN +1) 2 1

slide-15
SLIDE 15

15

Device vs. Screen Coordinates

  • viewport/window location wrt actual display not available

within OpenGL

  • usually don’t care
  • use relative information when handling mouse events, not

absolute coordinates

  • could get actual display height/width, window offsets from OS
  • loose use of terms: device, display, window, screen...

x x display display viewport viewport 1024 768 300 500 display height display width x offset y offset y y viewport viewport x x y y

slide-16
SLIDE 16

16

Projective Rendering Pipeline

OCS - object coordinate system WCS - world coordinate system VCS - viewing coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device coordinate system

OCS OCS WCS WCS VCS VCS CCS CCS NDCS NDCS DCS DCS

modeling modeling transformation transformation viewing viewing transformation transformation projection projection transformation transformation viewport viewport transformation transformation alter w alter w / w / w

  • bject

world viewing device normalized device clipping

perspective perspective division division glVertex3f(x,y,z) glVertex3f(x,y,z) glTranslatef glTranslatef(x,y,z) (x,y,z) glRotatef(a,x,y,z glRotatef(a,x,y,z) ) .... .... gluLookAt gluLookAt(...) (...) glFrustum glFrustum(...) (...) glutInitWindowSize glutInitWindowSize(w,h) (w,h) glViewport glViewport(x,y,a,b) (x,y,a,b)

O2W O2W W2V W2V V2C V2C N2D N2D C2N C2N

slide-17
SLIDE 17

17

Coordinate Systems

viewing (4-space, W=1) clipping (4-space parallelepiped, with COP moved backwards to infinity

normalized device (3-space parallelepiped)

device (3-space parallelipiped) projection matrix divide by w scale & translate framebuffer

slide-18
SLIDE 18

18

Perspective To NDCS Derivation

x z

NDCS

y

(-1,-1,-1) (1,1,1)

x=left x=right y=top y=bottom z=-near z=-far x

VCS

y z

slide-19
SLIDE 19

19

Perspective Derivation

simple example earlier: simple example earlier: complete: shear, scale, projection-normalization complete: shear, scale, projection-normalization

x' y' z' w'

  • =

1 1 1 1/d

  • x

y z 1

  • x'

y' z' w'

  • =

E A F 1 B C D 1

  • x

y z 1

slide-20
SLIDE 20

20

Perspective Derivation

earlier: earlier: complete: shear, scale, projection-normalization complete: shear, scale, projection-normalization

x' y' z' w'

  • =

1 1 1 1/d

  • x

y z 1

  • x'

y' z' w'

  • =

E A F 1 B C D 1

  • x

y z 1

slide-21
SLIDE 21

21

Perspective Derivation

earlier: earlier: complete: shear, scale, projection-normalization complete: shear, scale, projection-normalization

x' y' z' w'

  • =

1 1 1 1/d

  • x

y z 1

  • x'

y' z' w'

  • =

E A F 1 B C D 1

  • x

y z 1

slide-22
SLIDE 22

22

Perspective Derivation

x' y' z' w'

  • =

E A F B C D 1

  • x

y z 1

  • y'= Fy + Bz, y'

w' = Fy + Bz w' , 1= Fy + Bz w' , 1= Fy + Bz z , 1= F y z + B z z , 1= F y z B, 1= F top (near) B, x'= Ex + Az y'= Fy + Bz z'= Cz + D w'= z x = left x'/w'=1 x = right x'/w'= 1 y = top y'/w'=1 y = bottom y'/w'= 1 z = near z'/w'=1 z = far z'/w'= 1 1= F top near B

slide-23
SLIDE 23

23

Perspective Derivation

  • similarly for other 5 planes
  • 6 planes, 6 unknowns

2n r l r + l r l 2n t b t + b t b ( f + n) f n 2 fn f n 1

slide-24
SLIDE 24

24

Perspective Example

tracks in VCS: left x=-1, y=-1 right x=1, y=-1 view volume left = -1, right = 1 bot = -1, top = 1 near = 1, far = 4

z=-1 z=-4 x z VCS top view

  • 1
  • 1

1 1

  • 1

NDCS (z not shown) real midpoint xmax-1 DCS (z not shown) ymax-1 x=-1 x=1

slide-25
SLIDE 25

25

Perspective Example

view volume

  • left = -1, right = 1
  • bot = -1, top = 1
  • near = 1, far = 4

2n r l r + l r l 2n t b t + b t b ( f + n) f n 2 fn f n 1

  • 1

1 5/3 8/3 1

slide-26
SLIDE 26

26

Perspective Example

/ w / w

xNDCS = 1/zVCS yNDCS =1/zVCS zNDCS = 5 3 + 8 3zVCS 1 1 5zVCS /3 8/3 zVCS

  • =

1 1 5/3 8/3 1

  • 1

1 zVCS 1

slide-27
SLIDE 27

27

OpenGL Example

glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45, 1.0, 0.1, 200.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef( 0.0, 0.0, -5.0 ); glPushMatrix() glTranslate( 4, 4, 0 ); glutSolidTeapot(1); glPopMatrix(); glTranslate( 2, 2, 0); glutSolidTeapot(1);

OCS2 OCS2 O2W O2W VCS VCS

modeling modeling transformation transformation viewing viewing transformation transformation projection projection transformation transformation

  • bject

world viewing W2V W2V V2C V2C WCS WCS

  • transformations that

are applied first are specified last

OCS1 OCS1 WCS WCS VCS VCS W2O W2O W2O W2O CCS CCS clipping CCS CCS OCS OCS

slide-28
SLIDE 28

28

Projection Taxonomy

planar planar projections projections perspective: perspective: 1,2,3-point 1,2,3-point parallel parallel

  • blique
  • blique
  • rthographic
  • rthographic

cabinet cabinet cavalier cavalier top, top, front, front, side side axonometric: axonometric: isometric isometric dimetric dimetric trimetric trimetric

http://ceprofs.tamu.edu/tkramer/ENGR%20111/5.1/20

  • perspective: projectors converge
  • orthographic, axonometric: projectors

parallel and perpendicular to projection plane

  • oblique: projectors parallel, but not

perpendicular to projection plane

slide-29
SLIDE 29

29

Perspective Projections

  • projectors converge on image plane
  • select how many vanishing points
  • one-point: projection plane parallel to two axes
  • two-point: projection plane parallel to one axis
  • three-point: projection plane not parallel to any axis
  • ne-point
  • ne-point

perspective perspective two-point two-point perspective perspective three-point three-point perspective perspective

Tuebingen demo: vanishingpoints

slide-30
SLIDE 30

30

Orthographic Projections

  • projectors parallel, perpendicular to image plane
  • image plane normal parallel to one of principal axes
  • select view: top, front, side
  • every view has true dimensions, good for measuring

http://www.cs.fit.edu/~wds/classes/cse5255/thesis/images/proj/orthoProj.gif

slide-31
SLIDE 31

31

Axonometric Projections

  • projectors parallel, perpendicular to image plane
  • image plane normal not parallel to axes
  • select axis lengths
  • can see many sides at once

http://ceprofs.tamu.edu/tkramer/ENGR%20111/5.1/20

slide-32
SLIDE 32

32

Oblique Projections

x x y y z z

  • cavalier

cavalier

d d d d x x y y z z

  • cabinet

cabinet

d d d / 2 d / 2

  • projectors parallel, oblique to image plane
  • select angle between front and z axis
  • lengths remain constant
  • both have true front view
  • cavalier: distance true
  • cabinet: distance half

Tuebingen demo: oblique projections