Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ......

22
Realtime 3D Computer Graphics Virtual Reality Viewing and projection Classical and General Viewing

Transcript of Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ......

Page 1: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer GraphicsVirtual Reality

Viewing and projection

Classical and General Viewing

Page 2: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

vertex

ModelviewMatrix

ProjectionMatrix

PerspectiveDivision

ViewportTransform

Modelview

Modelview

Projection

object eye clip normalizeddevice

window

• other calculations here• material color• shade model (flat)• polygon rendering mode• polygon culling• clipping

TransformationPipeline CPUCPU DLDL

Poly.Poly. PerVertex

PerVertex

RasterRaster FragFrag FBFB

PixelPixelTextureTexture

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Viewing

• Process for “Seeing” a world• Projection of a 3D world onto a 2D plane• Synthetic Camera Model

• Location of viewer and view plane• What can be seen (Culling and Clipping)• How relationships are maintained

• Parallel Lines• Angles• Distances (Foreshortening)• Relation to Viewer

• Objects vs. Scenes:• Some viewing techniques better suited for viewing single objects rather than entire

scenes• Viewing an object from the outside (external viewing)

• Engineering, External Buildings, …• Viewing an object from within (internal viewing)

• Internal Buildings, Games, …

Page 3: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Viewing and projection• Map transformed world from 3D to 2D.

• by appropriate projection matrices.• Several projection types exist:

• Perspective projection is of major interest for 3D-CG.

• Parallel projection importance • Pipeline often separates projection

normalization from 3D-2D projection for additional depth testing.

• Calculation of the perspective projection for VR displays:• Display often require off-axis projection.

• COPs are constantly moving.• Projection calculation has to be performed for 2 eyes.

• Image planes might not be flat.

Planar Geometric Projections

Parallel Perspective

Orthographic ObliqueTop

(Plan)Front

elevation

Side elevation

Axonometric

Cabinet

Cavalier

Other

One-point

Two-point

Three-point

Other

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Definitions• Projection: a transformation that maps from a higher dimensional

space to a lower dimensional space (e.g. 3D->2D)

• Center of projection (COP): the position of the eye or camera with respect to which the projection is performed (also eye point, camera point, proj. reference point)

• Direction of projection (DOP): the direction of an eye or camera assumed to be infinite far away.

• Projection plane: in a 3D->2D projection, the plane to which the projection is performed (also view plane)

• Projectors: lines from coordinate in original space to coordinate in projected space

Page 4: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projections

B

A

B'

A'

Center ofProjection

ProjectionPlane

ProjectorsB

A

B'

A'

Center of Projection atInfinity (Direction of

Projection)

ProjectionPlane

Projectors

Perspective: Distance to COP is finite Parallel: Distance to COP is infinite

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Planar Geometric Projections

• Projection onto a plane• Projectors are straight lines• Alternatives:

• Some Cartographic Projections• Omnimax

Planar Geometric Projections

Parallel Perspective

Orthographic ObliqueTop

(Plan)Front

elevation

Side elevation

Axonometric

Cabinet

Cavalier

Other

One-point

Two-point

Three-point

Other

Page 5: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Parallel Projections• Orthographic: Direction of projection is orthogonal to the projection plane

• Elevations: Projection plane is perpendicular to a principal axis• Front• Top (Plan)• Side

• Axonometric: Projection plane is not orthogonal to a principal axis• Isometric: Direction of projection makes equal angles with each principal axis.

• Oblique: Direction of projection is not orthogonal to the projection plane; projection plane is normal to a principal axis

• Cavalier: Direction of projection makes a 45° angle with the projection plane• Cabinet: Direction of projection makes a 63.4° angle with the projection plane

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Orthographic Projections• “Special case” of

perspective projection• Parallel projectors

perpendicular to projection plane

• Multiview• Projection Plane Parallel to Principle Faces• Classical Drafting Views• Preserves both distance and angles• Suitable to Object Views, not scenes• (a): Front-Elevation• (b): Top or Plan-Elevation• (c): Side-Elevation

Planar Geometric Projections

Parallel Perspective

Orthographic ObliqueTop

(Plan)Front

elevation

Side elevation

Axonometric

Cabinet

Cavalier

Other

One-point

Two-point

Three-point

Other

(a)

(c)(b)

Page 6: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Axonometric Projections• Projection plane can have any orientation to object• Parallel lines preserved• Angles are not preserved• Foreshortening:

• Length is shorter in image space than in object space

• Uniform Foreshortening(Perspective projections: foreshortening is dependent on distance from object to COP)

Planar Geometric Projections

Parallel Perspective

Orthographic ObliqueTop

(Plan)Front

elevation

Side elevation

Axonometric

Cabinet

Cavalier

Other

One-point

Two-point

Three-point

Other

• Isometric: Symmetric to three faces• Dimetric: Symmetric to two faces• Trimetric: General Axonometric case

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Oblique Projections• Parallel Projections not perpendicular

to projection plane• Oblique projection types:

• Cavalier: 45-degree Angles from Projection Plane• Cabinet: Arctan(2) or 63.4-degree Angles from Projection Plane

Planar Geometric Projections

Parallel Perspective

Orthographic ObliqueTop

(Plan)Front

elevation

Side elevation

Axonometric

Cabinet

Cavalier

Other

One-point

Two-point

Three-point

Other

Page 7: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Perspective Projections• First discovered by Donatello, Brunelleschi,

and DaVinci during Renaissance• Parallel lines appear to converge to single point• Foreshortening:

• Objects closer to viewer look larger• Length is not preserved• Depends on distance from viewer

(a) Three-point:Three principal axes cut by projection planeThree axis vanishing points

(b) Two-point:Two principal axes cut by projection planeTwo axis vanishing points

(c) One-point:One principal axis cut by projection planeOne axis vanishing point

Planar Geometric Projections

Parallel Perspective

Orthographic ObliqueTop

(Plan)Front

elevation

Side elevation

Axonometric

Cabinet

Cavalier

Other

One-point

Two-point

Three-point

Other

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Vanishing Points

• Perspective Projection of any set of parallel line (not perpendicular to the projection plane) converge to a vanishing point

• Infinity of vanishing points • one of each set of parallel lines

• Axis Vanishing Points• Vanishing point of lines parallel to one of the three

principal axes• There is one axis vanishing point for each axis cut

by the projection plane• At most, 3 such points• Perspective Projections are categorized by

number of axis vanishing points

Page 8: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Perspective Foreshortening

How tall shouldthis bunny be?

Projection TransformationsNOTE: Throughout the following discussions, we

assume an OpenGL- like camera coordinate system (COP at the origin, DOP along the z axis,

zvp < 0). The concepts are the same for any arbitrary viewing configuration.

Page 9: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Orthogonal Projections

• DOP parallel to z-axis• Looking down negative z• Display Plane at z=0• Special Case of Perspective Projection

0

,,

=

=

=

p

p

p

z

yy

xx

=

==

11000000000100001

10 z

yx

yx

pMp p

p

orthorth

Z

-Z

[ ]Tzyx 1,,,[ ]Tpp yx 1,0,,

????????????????

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Orthogonal Projections

• DOP parallel to z-axis• Looking down negative z• Display Plane at z=0• Special Case of Perspective Projection

0

,,

=

=

=

p

p

p

z

yy

xx

=

==

11000000000100001

10 z

yx

yx

pMp p

p

orthorth

Z

-Z

[ ]Tzyx 1,,,[ ]Tpp yx 1,0,,

Page 10: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Perspective Projection: Points onto a Plane• Projection of world onto display plane involves a perspective transformation:

• p’=Mperp• Not affine (parallel lines do not remain parallel)• Not reversible • Observe:

• Results in non-uniform foreshorteningdzxx

dx

zxb p

p

/:)( =⇔=

dzyy

dy

zyc p

p

/:)( =⇔=

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Perspective Projection: Points onto a Plane• Projection of world onto display plane involves a perspective transformation:

• p’=Mperp• Not affine (parallel lines do not remain parallel)• Not reversible • Observe:

• Results in non-uniform foreshorteningdzxx

dx

zxb p

p

/:)( =⇔=

dzyy

dy

zyc p

p

/:)( =⇔=

Page 11: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

One-point perspective projection• Center of Projection on the negative z-axis

• Viewplane in the x-y plane.

Geometry of similar triangles. Top view:

++

=

+

=

==

10

))/(1/())/(1/(

)/(10

11/100000000100001

dzydzx

dz

yx

zyx

d

pMp perper

xp = xd/(d+z) = x/(1+(z/d))yp = yd/(d+z) = y/(1+(z/d))zp = 0

Z

-Z

[ ]Tzyx 1,,,

[ ]Tpp yx 1,0,,

[ ]Td 1,,0,0View plane

y

-Zd

yp = ? [ ]Td 1,,0,0

[ ]Tzyxp 1,,,:

????????????????

????

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

One-point perspective projection• Center of Projection on the negative z-axis

• Viewplane in the x-y plane.

Geometry of similar triangles. Top view:

++

=

+

=

==

10

))/(1/())/(1/(

)/(10

11/100000000100001

dzydzx

dz

yx

zyx

d

pMp perper

xp = xd/(d+z) = x/(1+(z/d))yp = yd/(d+z) = y/(1+(z/d))zp = 0

Z

-Z

[ ]Tzyx 1,,,

[ ]Tpp yx 1,0,,

[ ]Td 1,,0,0 −View plane

y

-Zd

yp = ? [ ]Td 1,,0,0 −

[ ]Tzyxp 1,,,:

Page 12: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

One-point perspective projection• Center of Projection on the negative z-axis

• Viewplane not in the x-y plane.

• Point p in 3D become lines through origin in 4D:

• As long as w ≠ 0, we can recover original point

View planey

-Zd

yp = ?

[ ]T1,0,0,0

[ ]Tzyxp 1,,,:dzxx

dx

zx

pp

/=⇔=

dzyy

dy

zy

pp

/=⇔=

dz p =

=

=

==

1

)//()//(

/11/100010000100001

ddzydzx

dzzyx

zyx

d

pMp perper

????????????????

????

[ ]Twwzwywxp =

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

One-point perspective projection• Center of Projection on the negative z-axis

• Viewplane not in the x-y plane.

• Point p in 3D become lines through origin in 4D:

• As long as w ≠ 0, we can recover original point

View planey

-Zd

yp = ?

[ ]T1,0,0,0

[ ]Tzyxp 1,,,:dzxx

dx

zx

pp

/=⇔=

dzyy

dy

zy

pp

/=⇔=

dz p =

=

=

==

1

)//()//(

/11/100010000100001

ddzydzx

dzzyx

zyx

d

pMp perper

[ ]Twwzwywxp = Perspective division

Page 13: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

3D Viewing Transformation Projection Matrixes

camorthoproj

campersproj

pMpor

pMp

=

= Just set z to zero(or ignore)

Clip AgainstView Volume

Project ontoProjection

Plane

Data in 3DCamera

Coordinates

NDC or W indowCoordinates

ApplyNormalizing

Transformation

Entire W orld inNormalized DeviceCoordinates (NDC)

Viewable W orld inNormalized DeviceCoordinates (NDC)

TransformWorld intoCamera

Coordinates

Data in 3D WorldCoordinates

pMp camcam =

• Input 3D World Coordinates• Output 3D Normalized Device Coordinates

• (a.k.a. Window Coordinates)

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection normalization• Several issues are not address with the simple

projection matrices we have developed:• 3D Clipping Efficiency in a Frustum Viewing Volume• Hidden Surface Efficiency

• Solution: Use Projection Normalization• Get rid of perspective and other problem projections!• Everything is easier in an canonical, orthogonal

world!• Distort world until viewing volume in world fits into a

parallel canonical view volume.• Find a transformation that distorts the vertices in a

way that we can use a simple canonical projection.

ViewVolume

Back ClippingPlane

Front ClippingPlane

-z

-x

+x

+y

-y -1,-1,-1

1,1,-1

z

Page 14: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Idea: Canonical View Volume• Define Viewing Volume via Canonical View Volumes• Plus: Easier Clipping• Minus: Another Transformation

OpenGL’s canonical view volume (other APIs may be different):

ViewVolume

Back ClippingPlane

Front ClippingPlane

-z

-x

+x

+y

-y -1,-1,-1

1,1,-1

z

DOP

ViewVolume

Back ClippingPlane

Front ClippingPlane

ViewPlane

Back ClippingPlane

Front ClippingPlane

……

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization• Distort world until viewing volume in world fits into

a parallel canonical view volume.• Find a transformation that distorts the vertices in a

way that we can use a simple canonical projection.

ViewVolume

Back ClippingPlane

Front ClippingPlane

-z

-x

+x

+y

-y -1,-1,-1

1,1,-1

z

Page 15: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Camera Transformation and Projection Normalization for Orthogonal Views

• Camera Transformation in Orthogonal Views (Mcam)

1. Convert World to Camera Coordinates• Camera at origin, looking in the –z direction• Display plane center along the z axis

2. Combinations of translate, scale, and rotate transformations

• Can be accomplished through camera location specification

• Projection Normalization for Orthographic Views (Mortho)

1. Translate along the z axis until the front clipping plane is at the origin

2. Scale in all three dimensions until the viewing volume is in canonical form

(xmax, ymax, -far)

(1,1,0)(xmin,ymin,-near)

-Z

-Z

X

X

Y

Y

(xmax, ymax, -far)

(xmin,ymin,-near)

Z

X

Y

Z

X

Y

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for Orthogonal Parallel Projections

−+

−−

−+

−−

−+

−−

=

1000

200

020

002

minmax

minmax

minmax

minmax

minmax

minmax

nearfarnearfar

nearfar

yyyy

yy

xxxx

xx

M

+−+−+−

2)(,

2)(,

2)( minmaxminmaxminmax zzyyxxT

Mapping a orthogonal view volume to a canonical view volume requires two affine transformations:

−−− )(2,

)(2,

)(2

minmaxminmaxminmax zzyyxx

S

these can be concatenated to

−+

−−

−+

−−

−+

−−

==

1000

200

020

002

minmax

minmax

minmax

minmax

minmax

minmax

minmax

minmax

minmax

zzzz

zz

yyyy

yy

xxxx

xx

STM

The camera is pointing in the negative z direction. All projectors are from infinity towards the origin. Hence M can be written as:

OpenGL note:OpenGL offers just an interface for the orthogonal case using glOrtho(xmin, xmax, ymax, ymin, near, far)

Page 16: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for Orthogonal Parallel Projections

−+

−−

−+

−−

−+

−−

==

1000

200

020

002

1000000000100001

minmax

minmax

minmax

minmax

minmax

minmax

nearfarnearfar

nearfar

yyyy

yy

xxxx

xx

STMM orth

Finally, the resulting matrix has to be post multiplied by a simple orthogonal parallel projection

−+

−−

−+

−−

=⇒

10000000

020

002

minmax

minmax

minmax

minmax

minmax

minmax

yyyy

yy

xxxx

xx

M

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for Oblique Parallel Projections

• Top and side views (see left) of a projector and the VP z=0.

• characterize the degree of obliqueness.Considering the top view (a), can be found by

• Orthogonal parallel projection can be seen as just a special case of an oblique parallel projection.

• An oblique projection can be characterized by the angle of the projectors with the VP.

),( φθ

pxxz−

=θtan

and likewise following (b):

θcotzxx p −=⇔

φcotzzy p −=

For VP z=0 this results to P:

−−

=

100000000cot100cot01

φθ

M

−−

==

100001000cot100cot01

1000000000100001

),(φθ

φθHMM orth

After extracting the orthogonal projection from M we derive an additional shear:

px

θφ

Page 17: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for Oblique Parallel Projections

−−

==

100001000cot100cot01

1000000000100001

),(φθ

φθHMM orthM is not in canonical form! It is a simple shear followed by an orthographic projection.

The same translation and scaling used for the orthographic case has to be inserted between the shear and the projection:

−−

−+

−−

−+

−−

−+

−−

==

100001000cot100cot01

1000

200

020

002

1000000000100001

),(minmax

minmax

minmax

minmax

minmax

minmax

φθ

φθ

nearfarnearfar

nearfar

yyyy

yy

xxxx

xx

STHMM orth

−+

−−

−−

−+

−−

−−

=⇒

10000000

cot220

cot202

minmax

minmax

minmaxminmax

minmax

minmax

minmaxminmax

yyyy

yyyy

xxxx

xxxx

θ

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Camera Transformation (Mcam) and Projection Normalization (Mpers) for Perspective Views

• Camera Transformation for Perspective Views (Mcam)1. Convert World to Camera Coordinates

• Camera (COP) at origin, looking in the –z direction

• Display plane center along the z axis2. Combinations of translate, scale, and rotate

transformations• Can be accomplished through camera location

specification

• Projection Normalization for Perspective Views (Mpers)1. Convert viewing box to right frustum (on axis)

• This is because many APIs including OpenGL allow non-right viewing volumes

2. Scale the right frustum into canonical form3. Convert viewing box (right frustum) to a right

parallelpiped• “Shrinking” objects that are further away

(xmax, ymax, -far)

(xmin,ymin,-near)

Z

X

Y

Z

X

Y

(1,1,0)

Z

X

Y

(xmax, ymax, -far)

(xmin,ymin,-near)

Z

X

Y

Page 18: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for Perspective Projections

• Again, find a transformation that distorts the vertices in a way that we can use a simple canonical projection: perspective-normalization transformation

=

1100010000100001

perspM

Given 1) a simple perspective projection with VP z=-1 and COP at origin:

Given 2) a perspective view volume with the angle of view being 90° => frustum sides intersect VP at 45° angle. View volume is a semi infinite view pyramid with:x = +/- z, y = +/- zView volume is finite by specifying the near plane z = zmax and the far plane z = zmin with zmax > zmin

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for Perspective Projections

=

010000

00100001

βαN

Let N be a nonsingular matrix similar to M with: 0,0 ≠≠ βα

Applying N to a homogeneous-coordinate point:

=

+−

−+

=

− 1''''''

110100

0000100001

zyx

zazyzx

zzyx

zyx

divisioneperspectiv

ββαβα

Applying an orthographic projection along the z-axis to N:

=

=

0100000000100001

010000

00100001

1000000000100001

βαNM orth

=

=

10

010100

000000100001

'zyzx

z

yx

zyx

NpM divisioneperspectiv

orth

Applying the result to an arbitrary point p’:

If we apply N followed by an orthogonal projection to a point we achieve the same result for x and y as applying a perspective projection to the same point!

Page 19: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for Perspective Projections

Nonsingular matrix N transforms the original viewing volume into a new volume.Now choosing such that the new volume is the canonical view (clipping) volume.Given the sides x = +/- z transformed by x’’ results to x’’ = +/- 1 andy = +/- z transformed by y’’ results to y’’ = +/- 1 and

βα ,

The front of the view volume z=zmax is transformed to:

+−=

max

''z

az β

Now we choose:

The back of the view volume z=zmin is transformed to:

+−=

min

''z

az β

minmax

minmax

zzzz

−+

=αminmax

minmax2zzzz

−−=β

Then the plane z=z is mapped to the plane z’’=-1 and the plane z=z is mapped to the plane z’’=1, hence we achieve the canonical volume:

N transforms the viewing volume to a right parallelepiped, a following orthographic projection is the same as a perspective transformation. N is called the perspective normalization matrix.

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for Perspective Projections

is nonlinear but preserves depth-ordering, hence

+−=z

az β'' 2121 '''' zzzz >⇒>

Notes:• Hidden surface removal works in the normalized volume.• Nonlinearity can cause numerical problems due to limited resolution in the depth buffer.• Only one viewing pipeline is required by carefully choosing a projection matrix to insert into the

pipeline.

• Perspective-Normalization Matrix (Nper) converts frustum view volume into canonical orthogonal view volume:

−⋅

−−+

−=

0100

20000100001

nearfarnearfar

nearfarnearfarN per

Page 20: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for non-right Perspective Projections

•The right (symmetric) perspective projection is a special case for an arbitrary perspective projection like the orthographic projection was for the parallel oblique case.•An arbitrary perspective projection is required, e.g., for driving several large-screen projection-based VR display types which

1. use head tracking and2. fix the VPs w.r.t. the moving COP

and which hence require dynamic frustum calculation (responsive workbenches, Holoscreens, CAVEs,…)

This type of projection is a.k.a. off-axis projection!

Do derive the projection matrix for off-axis set-ups we follow the same path as we did for the parallel projection case:

Insertion of a shear transformation into the projection pipeline.

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for non-right Perspective Projections

Find H which satisfies:

=

+

+

1

00

1

2)(

2)(

minmin

maxmin

maxmin

zz

yy

xx

H

+

+= −−

max

minmax1

max

maxmin1

2cot,

2cot),(

zyy

zxxHH φθ

The resulting frustum is described by the planes:

maxminmax

minmax

max

minmax ,,2

)(,2

)( zzzzzyyy

zxxx ==

−±=

−±=

Page 21: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for non-right Perspective Projections

Now scale the sides to achieve zyzx ±=±= ,

−−

= 1,2,2

minmax

max

minmax

max

yyz

xxzSS

S is without reference to z since it is uniquely determined by its results on four points, here the intersection points of the near plane and the sides. Now

without changing near/far planes .

=

110000

00100001

βαN

gets the far plane to -1 and the near plane to 1 with the already chosen

minmax

minmax

zzzz

−+

=αminmax

minmax2zzzz

−−=β

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Projection Normalization for Perspective Views

−⋅

−−+

−+

−−

−+

−−

==

0100

200

0)(20

00)(2

minmax

minmax

minmax

minmax

minmax

minmax

nearfarnearfar

nearfarnearfaryyyy

yynear

xxxx

xxnear

SHNP perpers

• Where H converts a non- right frustum to a right frustum• Where S scales the frustum into a canonical perspective view

volume • Where N is the Perspective- Normalization Matrix

• This results to the projection matrix:

Page 22: Realtime 3D Computer Graphics Virtual Reality · Realtime 3D Computer Graphics Virtual Reality ... • Parallel Lines • Angles ... • Projectors are straight lines

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

Project onto Projection Plane

• Since normalization changed all projections into an orthogonal projection:• Just ignore the z value!• In effect, a non- event!

• In reality, we retain the z-value for hidden-surface removal and shading effects.

• Viewable world now in Normalized Device Coordinates (NDC) or Window Coordinates

Realtime 3D Computer Graphics / Virtual Reality – WS 2005/2006 – Marc Erich Latoschik

3D Viewing Summary

TransformObject to

WorldCoordinates

Data in localObject

Coordinates

Clip AgainstView Volume

Data in 3DCamera

Coordinates

ApplyNormalizing

Transformation

Entire World inNormalized DeviceCoordinates (NDC)

Viewable World inNormalized DeviceCoordinates (NDC)

(aka World Coordinates)

TransformWorld intoCamera

Coordinates

Data in 3D WorldCoordinates

CTM

Model-View Projection