Title: http://www.ugrad.cs.ubc.ca/~cs314/Vjan2005
1Projections IIWeek 4, Wed Jan 26
- http//www.ugrad.cs.ubc.ca/cs314/Vjan2005
2Reading (Mon and today)
- FCG
- Section 5.3.1
- rest of Chapter 6
- RB
- rest of Chapter Viewing
- rest of Appendix Homogeneous Coords
3Review Graphics Cameras
- real pinhole camera image inverted
eye point
image plane
- computer graphics camera convenient equivalent
eye point
center of projection
image plane
4Review Basic Perspective Projection
similar triangles
P(x,y,z)
y
P(x,y,z)
z
zd
homogeneous coords
5Review Orthographic Cameras
- center of projection at infinity
- no perspective convergence
- just throw away z values
6Review Transforming View Volumes
NDCS
y
(1,1,1)
z
(-1,-1,-1)
x
7Review Ortho to NDC Derivation
- scale, translate, reflect for new coord sys
VCS
ytop
xleft
y
z
xright
x
z-far
ybottom
z-near
8NDC to Viewport Transformation
- generate pixel coordinates
- map x, y from range 11 (NDC) to pixel
coordinates on the display - involves 2D scaling and translation
y
display
x
viewport
9NDC to Viewport Transformation
- 2D scaling and translation
(1,1)
(w,h)
DCS
b
NDCS
a
y
x
(0,0)
OpenGL
glViewport(x,y,a,b)
default
glViewport(0,0,w,h)
10Origin Location
- yet more possibly confusing conventions
- OpenGL lower left
- most window systems upper left
- often have to flip your y coordinates
- when interpreting mouse position
11Perspective Example
view volume left -1, right 1 bot -1,
top 1 near 1, far 4
tracks in VCS left x-1, y-1 right
x1, y-1
x1
x-1
1
ymax-1
z-4
realmidpoint
-1
z-1
1
-1
xmax-1
0
-1
0
x
NDCS (z not shown)
DCS (z not shown)
z
VCStop view
12Viewing Transformation
y
image plane
VCS
z
OCS
z
y
Peye
y
x
x
WCS
object
world
viewing
VCS
OCS
WCS
OpenGL ModelView matrix
13Projective Rendering Pipeline
object
world
viewing
alter w
WCS
VCS
OCS
projection transformation
clipping
/ w
CCS
perspective division
normalized device
- OCS - object coordinate system
- WCS - world coordinate system
- VCS - viewing coordinate system
- CCS - clipping coordinate system
- NDCS - normalized device coordinate system
- DCS - device coordinate system
NDCS
device
DCS
14Projective Rendering Pipeline
object
world
viewing
alter w
WCS
VCS
OCS
projection transformation
clipping
/ w
CCS
perspective division
normalized device
- OCS - object coordinate system
- WCS - world coordinate system
- VCS - viewing coordinate system
- CCS - clipping coordinate system
- NDCS - normalized device coordinate system
- DCS - device coordinate system
NDCS
device
DCS
15Perspective Projection
- specific example
- assume image plane at z -1
- a point x,y,z,1T projects to -x/z,-y/z,-z/z,1T
? - x,y,z,-zT
-z
16Perspective Projection
projection transformation
perspective division
alter w
/ w
17Canonical View Volumes
- standardized viewing volume representation
- orthographic
perspective - orthogonal
- parallel
x or y /- z
x or y
x or y
backplane
backplane
1
frontplane
FrontPlane
-z
-z
-1
-1
18Why Canonical View Volumes?
- permits standardization
- clipping
- easier to determine if an arbitrary point is
enclosed in volume - consider clipping to six arbitrary planes of a
viewing volume versus canonical view volume - rendering
- projection and rasterization algorithms can be
reused
19Projection Normalization
- one additional step of standardization
- warp perspective view volume to orthogonal view
volume - render all scenes with orthographic projection!
x
x
zd
zd
z0
z?
20Predistortion
21Perspective Normalization
- perspective viewing frustum transformed to cube
- orthographic rendering of cube produces same
image as perspective rendering of original frustum
22Demos
- Tuebingen applets from Frank Hanisch
- http//www.gris.uni-tuebingen.de/projects/grdev/do
c/html/etc/AppletIndex.htmlTransformationen
23Perspective Warp
- matrix formulation
- preserves relative depth (third coordinate)
- what does mean?
24Projection Normalization
normalized device
clipping
viewing
CCS
VCS
NDCS
projection transformation
perspective division
alter w
/ w
- distort such that orthographic projection of
distorted objects is desired persp projection - separate division from standard matrix multiplies
- clip after warp, before divide
- division normalization
25Projective Rendering Pipeline
glVertex3f(x,y,z)
object
world
viewing
alter w
WCS
VCS
OCS
glFrustum(...)
projection transformation
clipping
glTranslatef(x,y,z) glRotatef(th,x,y,z) ....
gluLookAt(...)
/ w
CCS
perspective division
normalized device
- OCS - object coordinate system
- WCS - world coordinate system
- VCS - viewing coordinate system
- CCS - clipping coordinate system
- NDCS - normalized device coordinate system
- DCS - device coordinate system
glutInitWindowSize(w,h) glViewport(x,y,a,b)
NDCS
device
DCS
26Coordinate Systems
http//www.btinternet.com/danbgs/perspective/
27Perspective Derivation
VCS
NDCS
ytop
y
xleft
(1,1,1)
y
z
(-1,-1,-1)
x
z
z-near
ybottom
z-far
x
xright
28Perspective Derivation
earlier
complete shear, scale, projection-normalization
29Perspective Derivation
30Perspective Derivation
- similarly for other 5 planes
- 6 planes, 6 unknowns
31Perspective Example
- view volume
- left -1, right 1
- bot -1, top 1
- near 1, far 4
32Perspective Example
/ w
33Asymmetric Frusta
- our formulation allows asymmetry
- why bother?
x
x
right
right
Frustum
Frustum
-z
-z
left
left
z-n
z-f
34Simpler Formulation
- left, right, bottom, top, near, far
- nonintuitive
- often overkill
- look through window center
- symmetric frustum
- constraints
- left -right, bottom -top
35Field-of-View Formulation
- FOV in one direction aspect ratio (w/h)
- determines FOV in other direction
- also set near, far (reasonably intuitive)
x
w
fovx/2
h
Frustum
-z
?
fovy/2
z-n
z-f
36Perspective OpenGL
glMatrixMode(GL_PROJECTION) glLoadIdentity() gl
Frustum(left,right,bot,top,near,far)
or glPerspective(fovy,aspect,near,far)
37Demo Frustum vs. FOV
- Nate Robins tutorial (take 2)
- http//www.xmission.com/nate/tutors.html
38Projection Taxonomy
planar projections
perspective 1,2,3-point
parallel
orthographic
oblique
cavalier
cabinet
axonometric isometric dimetric trimetric
top, front, side
http//ceprofs.tamu.edu/tkramer/ENGR20111/5.1/20
39Perspective Projections
- classified by vanishing points
two-point perspective
three-point perspective
40Parallel Projection
- projectors are all parallel
- vs. perspective projectors that converge
- orthographic projectors perpendicular to
projection plane - oblique projectors not necessarily perpendicular
to projection plane
Oblique
Orthographic
41Axonometric Projections
- projectors perpendicular to image plane
- select axis lengths
http//ceprofs.tamu.edu/tkramer/ENGR20111/5.1/20
42Oblique Projections
- projectors oblique to image plane
- select angle between front and z axis
- lengths remain constant
- both have true front view
- cavalier distance true
- cabinet distance half
d / 2
y
y
d
d
d
x
z
x
z
cabinet
cavalier
43Demos
- Tuebingen applets from Frank Hanisch
- http//www.gris.uni-tuebingen.de/projects/grdev/do
c/html/etc/AppletIndex.htmlTransformationen