CSE452 Computer Graphics - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

CSE452 Computer Graphics

Description:

The perspective view frustum (i.e., a truncated pyramid) can be hard for both ... Canonical view volume makes things easy: Easy clipping: Clip against the ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 30
Provided by: SteveO96
Category:

less

Transcript and Presenter's Notes

Title: CSE452 Computer Graphics


1
CSE452 Computer Graphics
  • Lecture 8 Computer Projection 2

2
Review
  • In the last lecture
  • We set up a Virtual Camera
  • Position
  • Orientation
  • Clipping planes
  • Viewing angles
  • Orthographic/Perspective
  • We are ready to project!

3
Preview
  • The perspective view frustum (i.e., a truncated
    pyramid) can be hard for both clipping and
    projection
  • Lets first consider a parallel, canonical volume

4
Canonical View Volume
Near Clipping Plane
Far Clipping Plane
5
Canonical View Volume
  • Canonical view volume makes things easy
  • Easy clipping Clip against the coordinates range
  • Easy projecting drop the z coordinate! (because
    viewing plane is the xy plane, and projectors are
    parallel to z axis)

Coordinates in the canonical volume
Projected 2D coordinates
6
Viewing Transformation
  • For any viewing volume transform it into the
    canonical volume!
  • The transformation brings the blue box into the
    red box
  • The same transformation brings world coordinates
    xw,yw,zw into canonical coordinates within the
    canonical volume xc,yc,zc
  • Clip and project

7
Camera Coordinate System
  • Three orthogonal axes setting up the cameras
    world
  • u (right), v (straight-up), n (negative look)
  • Unit vectors forming an orthonormal basis
  • Observing the right-hand rule

Y
X
Z
8
Camera Coordinate System
  • Computing n
  • Opposite to look vector L, normalized

9
Camera Coordinate System
  • Computing v
  • Projection of up vector U onto the camera plane,
    normalized

10
Camera Coordinate System
  • Computing u

11
Camera Coordinate System
  • Summary
  • Three axes, computed from look vector L and up
    vector U
  • They are unit vectors
  • u,v,n follow the right-hand rule

12
Computing Viewing Transformation
  • Two steps
  • Step 1 aligning camera coordinate system P,u,v,n
    with world coordinate system O,x,y,z
  • Step 2 scale and stretch the viewing volume to
    the cuboid

Y
X
Z
13
Step 1
  • First, translate the eye point P to the origin
  • Homogenous coordinates! Easy to compose
    transformation as matrix product

O (P)
14
Step 1 (cont)
  • Rotate the three axes u,v,n to x,y,z
  • First, set up the equation to solve for the
    rotation matrix R we know that vectors u,v,n are
    rotated to three canonical vectors, and the
    original stays put.
  • In matrix form

15
Step 1 (cont)
  • Simplify our notation
  • Solve for the rotation matrix
  • M is ortho-normal, meaning .
    Therefore

16
After Step 1
  • Eye point at origin, looking down negative z axis

(v)
O (P)
(n)
(u)
17
Step 2
  • Scale the viewing volume to the correct size
  • Here is a look down the Y axis
  • First, force width/height angle to be right
    angles
  • Scaling in x,y coordinates

Z
X
18
Step 2 (cont)
  • Scale the viewing volume to the correct size
  • Next, push the far plane to the xy plane at z-1
  • Scaling in all three coordinates

Z
X
19
Step 2 (cont)
  • Now, the far plane corners are at

(v)
O (P)
(n)
(u)
20
Step 2 (cont)
  • Perspective transformation
  • Stretching the truncated pyramid to the cuboid
  • Stretch in XY plane Non-uniform stretching based
    on z
  • Change Z range (-dn/df,-1 -gt 0,1)

y
y
1
z
z
-1
1
0
-dn/df
-1
21
Step 2 (cont)
  • Perspective transformation
  • Lets see what matrix D does
  • When converting from homogeneous coordinates
    (x,y,z,w) to Cartesian coordinates, we need to
    divide x,y,z by w !!

22
Step 2 (cont)
  • Perspective transformation
  • Stretching the truncated pyramid to the cuboid
  • Stretch in XY plane Non-uniform stretching based
    on z
  • Change Z range (-dn/df,-1 -gt 0,1)

y
y
1
z
z
-1
1
0
-dn/df
-1
23
Putting Together
  • Translation
  • Rotation
  • Scaling
  • Perspective transformation

World-to-camera transformation
  • Final viewing transformation to bring a point
    to the canonical volume

24
Clipping
  • After transformation into the canonical volume,
    each object will be clipped against 6 cuboid
    faces.
  • Point clipping checking coordinates range
  • Edge clipping computing line/plane intersections
  • We will discuss a simplified, 2D clipping problem
    in next lecture.
  • Triangle clipping Need to consider face/face
    intersections

25
Projecting
  • Dropping z coordinate
  • Resulting points have range

26
Viewport Transform
  • Get viewport (pixel) coordinates
  • Viewport coordinate 0,0 is at top-left corner
  • If the viewport is a pixels wide and b pixels
    high, the pixel coordinates for a projected point
    x,y is

27
Summary
  • To compute projection
  • Set up camera parameters
  • Compute viewing transformation
  • Clipping against the canonical volume
  • Projecting to viewport

28
Practice Questions
  • Camera projection using following parameters eye
    point at 0,5,0, look vector 0,-1,0, up vector
    1,1,1, height and width angle 90 degrees, near
    and far plane at distances 0.1 and 10 from the
    eye point.
  • Compute camera coordinate system axes u,v,n. Show
    that u,v,n form an orthonormal basis.
  • Write down the world-to-camera matrix and the
    perspective matrix.

29
Practice Questions
  • 2. Place a unit-radius sphere at the origin. Draw
    the spheres location in the camera coordinate
    system before perspective transformation. That
    is, where does the sphere end up after applying
    the World-to-camera matrices? Draw the canonical
    coordinate system from the side, with y up and z
    to the left, x out of the plane. Give the
    distance along the z axis and the height/size of
    the sphere in the z and y direction.
  • Distance along z (apply D.WTC to the origin, then
    take z coordinate) -1/2
  • Size along z (apply D.WTC to n and -n, then take
    z difference) radius 1/5
  • Size along y (apply D.WTC to v and -v, then take
    z difference) radius 1/5

0,1,-1
Y
Z
0,-1,-1
Write a Comment
User Comments (0)
About PowerShow.com