Docsity

Viewing and Perspective - Introduction to Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download Viewing and Perspective - Introduction to Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Viewing & Perspective

Homogeneous Transformations

z

y

x

z z z y z x z z

y z y y y x y y x z x y x x x x

x y z

z

z

z

z

y

y

y

y

x

x

x

x

x y z

v

v

v

d v c v b v a v

d v c v b v a v

d v c v b v a v

v v v

d

c

b

a

d

c

b

a

d

c

b

a

v v v

v

M

v

ABCD Vectors^ „

We mentioned that the translation information is easilyextracted directly from the matrix, while therotation/scale/shear/reflection information is encodedinto the upper 3x3 portion of the matrix

„

The 9 constants in the upper 3x3 matrix make up 3vectors called

a

b

, and

c

„

If we think of the matrix as a transformation from objectspace to world space, then the

a

vector is essentially the

object’s x-axis transformed into world space,

b

is its y-

axis in world space, and

c

is its z-axis in world space

„

d

is of course the position in world space.

Example: Yaw^ „

A spaceship is floating out in space, with amatrix

W

. The pilot wants to turn the ship

10 degrees to the left (yaw). Show how tomodify

W

to achieve this.

Spaces^ „

So far, we’ve discussed the followingspaces

„

Object space (local space)

„

World space (global space)

„

Camera space

Camera Space^ „

Let’s say we want to render an image of a chair from a certaincamera’s point of view

„

The chair is placed in world space with matrix

W

„

The camera is placed in world space with matrix

C

„

The following transformation takes vertices from the chair’s objectspace into world space, and then from world space into cameraspace:

„

Now that we have the object transformed into a space relative to thecamera, we can focus on the next step, which is to project this 3Dspace into a 2D image space

v

W

C

v

⋅

⋅

= ′

−

1

View Projections^ „

So far we know how to transform objects from object space intoworld space and into camera space

„

What we need now is some sort of transformation that takes pointsin 3D camera space and transforms them into our 2.5D imagespace

„

We will refer to this class of transformations as

view projections

(or

just projections)

„

Simple

orthographic

view projections can just be treated as one

more affine transformation applied after the transformation intocamera space

„

More complex

perspective

projections require a non-affine

transformation followed by an additional division to convert from 4Dhomogeneous space into image space

„

It is also possible to do more elaborate

non-linear projections

to

achieve fish-eye lens effects, etc., but these require significantchanges to the rendering process, not only in the vertextransformation stage, and so we will not cover them…

Orthographic Projection^ „

An

orthographic

projection is an affine

transformation and so it preserves parallel lines

„

An example of an orthographic projection mightbe an architect’s top-down view of a house, or acar designer’s side view of a car

„

These are very valuable for certain applications,but are not used for generating realistic images

Perspective Projection^ „

With a perspective projection, objects become smalleras they get further from the camera, as one normallygets from a photograph or video image

„

The goal of most real-world camera lens makers is toachieve a perfect perspective projection

„

Most realistic computer generated images useperspective projections

„

A fundamental property of perspective projections is thatparallel lines will

not

necessarily remain parallel after the

transformation (making them non-affine)

View Volume^ „

A camera defines some sort of 3D shape in world space thatrepresents the volume viewable by that camera

„

For example, a normal perspective camera with a rectangular imagedescribes a sort of infinite pyramid in space

„

The tip point of the pyramid is at the camera’s origin and thepyramid projects outward in front of the camera into space

„

In computer graphics, we typically prevent this pyramid from beinginfinite by chopping it off at some distance from the camera. Werefer to this as the

far clipping plane

„

We also put a limit on the closest range of the pyramid by choppingoff the tip. We refer to this as the

near clipping plane

„

A pyramid with the tip cut off is known as a

frustum

. We refer to a

standard perspective view volume as a

view frustum

View Frustum^ „

The view frustum is usually defined by a

field of view

(FOV) and an

aspect ratio

, in addition to the near and far clipping plane distances

„

Depending on the convention, the FOV may represent either thehorizontal or vertical field of view. The most common convention isthat the FOV is the entire vertical viewing angle

„

The aspect ratio is the x/y ratio of the final displayed image

„

For example, if we are viewing on a TV that is 24” x 18”, the aspectratio would be 24/18 or 4/

„

Older style TV’s have a 4/3 aspect ratio, while modern wide screenTV’s use a 16/9 aspect. These sizes are common for computermonitors as well

Perspective Matrix

(

)

(

)

(

)

′^

−

tan

tan

1

)

(^4) (

far

near

far

near

far

near

far

near

fov

aspect

fov

far

near

aspect

fov

persp

D

P

v

W

C

P

v

Perspective Transformations^ „

It is important to make sure that straight lines in3D space map to straight lines in image space

„

This is easy for x and y, but because of thedivision, it is possible to have nonlinearities in z

„

The perspective transformation shown in theprevious slide assures a straight line mapping,but there are other perspective transformationspossible that don’t preserve this

Viewports^ „

The final transformation takes points from the -1…1 image spaceand maps them to an actual rectangle of pixels (device coordinates)

„

We can define our final device mapping from normalized view spaceinto an actual rectangular viewport as:

„

The depth value is usually mapped to a 32 bit fixed point valueranging from 0 (near) to 0xffffffff (far) (

)

(

)

(

)

(

)

(

)

0

1

0

0

1

0 1 0 0 1 1 0 1 0 y

y

y

y

y

x x x x x y y x x D