Docsity

OpenGL Matrix Transformation Pipeline: Perspective Projection and View Volume, Slides of Computer Graphics

Partial preview of the text

Download OpenGL Matrix Transformation Pipeline: Perspective Projection and View Volume and more Slides Computer Graphics in PDF only on Docsity!

Lecture 13:

Viewing 3

 Course schedule Problem…

 Powerpoint version issue (pptx to ppt)

Announcement

Position

Up vector

Look vector

 We need to know 6 things about the synthetic

camera model:

  1. Position of the camera -> P (x, y, z)
  2. Look vector -> V (x, y, z)
  3. Up vector -> U (x, y, z)

 Note that with look and up vectors, we know the orientation of the camera

Constructing the View Volume

  1. Aspect ratio of the film (ratio of width to height)
  2. View angle (or height angle): determines how “wide”

the frustum will be

 Note that the width angle can be inferred from the aspect ratio and the height angle

  1. Front and back clipping planes: limit the extend of the

camera’s view. Only render objects within the two

planes

Constructing the View Volume

Front clipping plane

Back clipping plane

Width angle

Height angle

 For rendering, the middle and right models create the same

image.

 Meaning that we can either think of model transform and view

transforms as Inverses of each other

 In OpenGL, we tend to use the middle model

Camera as a model

 Sometimes referred to as “World-to-Eye” transform.

 The idea is to create a matrix such that we make the

camera:

 1) move to the origin of the World Coordinate (x, y, z)

 2) rotate to align (u, v, w) with (x, y, z)

World-To-Camera Transform

Questions?

Position

Up vector

Look vector

 We need to know 6 things about the synthetic

camera model:

  1. Position of the camera -> P (x, y, z)
  2. Look vector -> V (x, y, z)
  3. Up vector -> U (x, y, z)

 Note that with look and up vectors, we know the orientation of the camera

Constructing the View Volume

 Analogous to the size of film used in a camera

 Determines the ratio of width to height displayed on

screen

 Square window has a ratio of 1:

 Movie theater “letterbox” is 2:

 NTSC television is 4:3, and HDTV is 16:

4) Aspect Ratio

 Determines the amount of perspective distortion, from

no distortion (parallel projection) to high distortion (wide-angle lens)

 In a frustum, there are two viewing angles: width and

height angles (but given the aspect ratio, we just need one of these two values to infer the other)

5) View Angle

 So far, given what we have, our projector rays will

extend to infinity (and therefore an infinite volume)

 Now we need to bound the volume with a front and a

back using near and far clipping planes

 Note that our look vector and the clipping planes are

perpendicular

6) Near and Far Clipping Planes

 Why do we need the clipping planes?

 Near plane:

 Don’t want to draw objects near the camera

 Too much distortion  Objects block the view

 Don’t want to draw objects behind the camera

!!  If we do, objects will appear upside down and inside-out because of the perspective transform

 Far plane:

 Don’t want to draw objects too far way

 Objects will be tiny, but cost the same amount of time to render as objects close by

 Clipping planes need to be carefully placed. We’ll

discuss the technical reasons later.

6) Near and Far Clipping Planes

 Sometimes in games you can see behind a wall, even though your

camera is not colliding with the wall.  This is because the wall is closer than the near plane

 One way to avoid this glitch is to do fading of objects that are very close

to the near plane

Clipping Planes in Games

Screenshots from the game, Okami
 This technique gives a clean look while solving the near clipping problem (the
wooden fence fades out as the camera follows the running wolf).

 This is not covered in our

model, but the idea is to

create blurring effects

 Objects near the specified

focal length are rendered

sharply (in focus)

 Objects away from the focal

length (either too close or

too far) are blurred

Focal Length