28
Advanced Graphics & Animation 3D Viewing Pipeline

3 d viewing

Embed Size (px)

Citation preview

Page 1: 3 d viewing

Advanced Graphics & Animation

3D Viewing Pipeline

Page 2: 3 d viewing

Three-dimensional Viewing Pipeline

Transform into view coordinatesand Canonical view volume

Clip against canonical view volume

Project on to view plane

Map into viewport

Transform to physical Device coordinates

transform

clip

transform

World coordinates(3D)

View coordinates(3D)

View coordinates(3D)

View coordinates(2D)

Normalized device coordinates

Physical device coordinates

Page 3: 3 d viewing

Parallel Projection

Mostly used by drafters and engineers to create working drawings of an object which preserves its scale and shape.

The distance between the COP and the projection plane is infinite i.e. The projectors are parallel to each other and have a fixed direction.

P1

P2

P1’

P2’

Projection plane

Page 4: 3 d viewing

• Orthographic projection: here direction of projection is perpendicular to the

view plane.

• Axonometric projection: when direction of projection is not parallel to any of

three principal axes.

Page 5: 3 d viewing

Perspective Projection

• Generalization of the principles used by artists in drawing of scenes.

• It takes object representation in view space (L.H.S.) and produce a projection on the view plane (canvas used by the artist).

• The projection of a 3D point onto the viewplane is the intersection of the line from the point to the COP (eye position of the artist).

Page 6: 3 d viewing

Cont.

• Distance between the COP and projection plane is finite.

• Perspective projection does not preserve object scale and shape.

P1

P2

P1’

P2’

Projection plane

COP

Page 7: 3 d viewing

Perspective Anomalies

Perspective foreshortening

- the farther an object from the COP, the smaller it appears (i.e. its projected size becomes smaller).

copView plane

Page 8: 3 d viewing

Vanishing points

- there is an illusion that certain sets of parallel lines (that are not parallel to the view plane ) appear to meet at some point on the view plane.

- the vanishing point for any set of parallel lines that are parallel to one of principal axis is referred to as a principal vanishing point (PVP).

- the number of PVPs is determined by the number of principal axes intersected by the view plane.

Page 9: 3 d viewing

One principal vanishing point projection

- occurs when the projection plane is perpendicular to one of the principal axes (x, y or z ).

Vanishing point

View plane is parallel to XY-plane and intersects Z-axis only.

Page 10: 3 d viewing

Two principal vanishing point projection

X-axis Vanishing point Z-axis

Vanishing point

View plane intersects Both X and Z axis but not the Y axis

Page 11: 3 d viewing

• Three principal vanishing point intersection

View plane intersects all Three of the principal axisX, Y and Z axis

VP1

VP3

VP2

Page 12: 3 d viewing

Deriving Perspective Projection

Assume

point vertex denoting COP : (xc,yc,zc)

point on the object : (x1,y1,z1)

representation of “projection ray” containing above two points

x = xc + ( x1-xc) u …………..eq 1

y = yc + ( y1-yc) u …………..eq 2

z = zc + ( z1-zc) u …………..eq 3

The projected point (x2, y2,D) will be the point where this line intersects the XY plane . Putting z=0 for this intersection point in eq 3 .

u = - zc / z1-zc

Page 13: 3 d viewing

Substituting into first two equations,

x2 =

y2 =

Value of D may be computed which is different from zero (to

preserve depth relationship between objects)

D = z1 / (z1 –zc)

z -z

z x- z x

c1

c11c

z -z

z y - z y

c1

c11c

Page 14: 3 d viewing

Standard perspective projection

y

x

z

A (x,0,z)

A’ (x’,0,0)

P (x ,y, z)

P’ (x’,y’,0)

C(0,0,-d)do

(0,0,0)B (0,0,z)

z

Page 15: 3 d viewing

Using similar triangles ABC and A’OC,

x’ = d.x / (z+d)

y’ = d.y / (z+d)

z’ = 0

matrix representation :

d 1 0 0

0 0 0 0

0 0 d 0

0 0 0 d

Page 16: 3 d viewing

viewing based on synthetic camera analogy.

Specifying an arbitrary 3D view

Page 17: 3 d viewing

By selecting different viewing parameters, user can position the synthetic camera.

View distanceView reference point

View-up vector

View planenormal

View plane

Page 18: 3 d viewing

Effect of change of viewing parameters

Imagine a string tied to ‘view reference point’ on one end and to the synthetic camera on the other end.

By changing viewing parameters, we can swing the camera through the arc or change the length of the string.

- changing the view distance is equivalent to how far away from the object the camera is when it takes the picture.

- changing the view reference point will change the part of the object that is shown at the origin.

Page 19: 3 d viewing

Cont.

- changing the view plane normal is equivalent to taking photograph of object from different orientations.

- changing view-up is equivalent to twisting the camera in our hands. It fixes the camera angle.

Page 20: 3 d viewing

View Volume

- The view volume bounds that portion of the 3D space that is to be clipped out and projected onto the view plane.

Page 21: 3 d viewing

View Volume for Perspective Projection - its shape is semi-infinite pyramid with apex at the

view point and edge passing through the corners of the window.

copView window

Front clippingplane

Back clipping plane

Frustum view volume

Page 22: 3 d viewing

View Volume for Parallel Projection

-It's shape is an infinite parallelepiped with sides parallel to the direction of projection.

ParallelepipedViewed volume

View window

Front clippingplane

Back clippingplane

Page 23: 3 d viewing

Producing a Canonical view volume for a perspective projection

cop

View window

Frontclip

Back clip

View frustumcenterlineGeneral shape

for the Perspective View volume

View volume

Page 24: 3 d viewing

Step 1: shear the view volume so that centerline of the frustum is perpendicular to the view plane and passes through the center of the

view window.

Frustum centerline

View volume

Page 25: 3 d viewing

Step2: scale view volume inversely proportional to the distance from the view window, so that shape of view volume becomes rectangular

parallelepiped.

View volume

Page 26: 3 d viewing

Converting object coordinates to view plane coordinates

similar to the process of rotation about an arbitrary axis

zw

Ywxw

World coordinate system

Yv

Xv

VRP

View plane (eye) coordinate system

Page 27: 3 d viewing

Steps:

1. Translate origin to view reference point (VRP).

2. Translate along the view plane normal by view distance.

3. Align object coordinate’s z-axis with view plane coordinates z-axis (the view plane normal).

a)- Rotate about x-axis to place the line (ie. Object coordinates z-axis) in the view plane coordinates xz-plane.

b)- Rotate about y-axis to move the z axis to its proper position.

c)- Rotate about the z-axis until x and y axis are in place in the view plane coordinates.

Page 28: 3 d viewing

Ref: ‘Computer Graphics’ by S. Harrington (pp. 279-284)