Graphics 3D Viewing 고려대학교 컴퓨터 그래픽스 연구실 cgvr.korea.ac.kr Graphics Lab @ Korea University 3d Rendering Pipeline CGVR 3D Primitives Model Transformation Lighting Viewing Transformation Projection Transformation Clipping This is a pipelined sequence of.

Download Report

Transcript Graphics 3D Viewing 고려대학교 컴퓨터 그래픽스 연구실 cgvr.korea.ac.kr Graphics Lab @ Korea University 3d Rendering Pipeline CGVR 3D Primitives Model Transformation Lighting Viewing Transformation Projection Transformation Clipping This is a pipelined sequence of.

Graphics
3D Viewing
고려대학교 컴퓨터 그래픽스 연구실
cgvr.korea.ac.kr
Graphics Lab @ Korea University
3d Rendering Pipeline
CGVR
3D Primitives
Model Transformation
Lighting
Viewing Transformation
Projection Transformation
Clipping
This is a pipelined
sequence of operations to
draw a 3D primitive into a
2D image for direct
illumination
Viewport Transformation
Scan Conversion
Image
cgvr.korea.ac.kr
Graphics Lab @ Korea University
In Pipeline
CGVR
3D Primitives
Model Transformation
Transform into3d world coordinate
system
Lighting
Viewing Transformation
Projection Transformation
Clipping
Viewport Transformation
Scan Conversion
Image
cgvr.korea.ac.kr
Graphics Lab @ Korea University
In Pipeline
CGVR
3D Primitives
Model Transformation
Lighting
Transform into3d world coordinate
system
Illustrate according to lighting and
reflectance
Viewing Transformation
Projection Transformation
Clipping
Viewport Transformation
Scan Conversion
Image
cgvr.korea.ac.kr
Graphics Lab @ Korea University
In Pipeline
CGVR
3D Primitives
Model Transformation
Lighting
Viewing Transformation
Transform into3d world coordinate
system
Illustrate according to lighting and
reflectance
Transform into 3D viewing coordinate
system
Projection Transformation
Clipping
Viewport Transformation
Scan Conversion
Image
cgvr.korea.ac.kr
Graphics Lab @ Korea University
In Pipeline
CGVR
3D Primitives
Model Transformation
Lighting
Viewing Transformation
Projection Transformation
Transform into3d world coordinate
system
Illustrate according to lighting and
reflectance
Transform into 3D viewing coordinate
system
Transform into 2D viewing coordinate
system
Clipping
Viewport Transformation
Scan Conversion
Image
cgvr.korea.ac.kr
Graphics Lab @ Korea University
In Pipeline
CGVR
3D Primitives
Model Transformation
Lighting
Viewing Transformation
Projection Transformation
Clipping
Transform into3d world coordinate
system
Illustrate according to lighting and
reflectance
Transform into 3D viewing coordinate
system
Transform into 2D viewing coordinate
system
Clip primitives outside window’s view
Viewport Transformation
Scan Conversion
Image
cgvr.korea.ac.kr
Graphics Lab @ Korea University
In Pipeline
CGVR
3D Primitives
Model Transformation
Lighting
Viewing Transformation
Projection Transformation
Clipping
Viewport Transformation
Transform into3d world coordinate
system
Illustrate according to lighting and
reflectance
Transform into 3D viewing coordinate
system
Transform into 2D viewing coordinate
system
Clip primitives outside window’s view
Transform into viewport
Scan Conversion
Image
cgvr.korea.ac.kr
Graphics Lab @ Korea University
In Pipeline
CGVR
3D Primitives
Model Transformation
Lighting
Viewing Transformation
Projection Transformation
Clipping
Viewport Transformation
Scan Conversion
Image
cgvr.korea.ac.kr
Transform into3d world coordinate
system
Illustrate according to lighting and
reflectance
Transform into 3D viewing coordinate
system
Transform into 2D viewing coordinate
system
Clip primitives outside window’s view
Transform into viewport
Draw pixels(includes texturing,
hidden surface etc.)
Graphics Lab @ Korea University
Transformation
CGVR
3D Primitives
Model Transformation
Lighting
Viewing Transformation
Projection Transformation
Clipping
Viewport Transformation
Scan Conversion
Image
cgvr.korea.ac.kr
Transform into3d world coordinate
system
Illustrate according to lighting and
reflectance
Transform into 3D viewing coordinate
system
Transform into 2D viewing coordinate
system
Clip primitives outside window’s view
Transform into viewport
Draw pixels(includes texturing,
hidden surface etc.)
Graphics Lab @ Korea University
Transformation
CGVR
P(x, y, z)
3D Object Coordinate
Model Transformation
3D Viewing Coordinate
3D World Coordinate
Viewing Transformation
3D Viewing Coordinate
Projection Transformation
2D Projection Coordinate
Viewport Transformation
3D Object Coordinate
3D World Coordinate
2D Device Coordinate
p(x’, y’)
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Viewing Transformation
CGVR
P(x, y, z)
3D Object Coordinate
Model Transformation
3D World Coordinate
Viewing Transformation
3D Viewing Coordinate
Viewing
Transformation
Projection Transformation
2D Projection Coordinate
Viewport Transformation
2D Device Coordinate
p(x’, y’)
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Viewing Transformation

CGVR
Mapping from world to Viewing coordinates

Origin moves to eye position
 Up vector maps to Y axis
 Right vector maps to X axis
Y
Camera
Z
X
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Transformation from
WC to VC

CGVR
Transformation sequences
1. Translate the view reference point to the origin of the
WC system
2. Apply rotations to align the xv, yv, and zv axes with
the world axes
General sequence of translate-rotate transformation
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Transformation from
WC to VC (cont’)

Translation


CGVR
view reference point(x0, y0, z0)
Rotation



1
0
T
0

0
0 0  x0 
1 0  y0 
0 1  z0 

0 0
1 
rotate around the world xw axis to bring zv into the
xwzw plane
rotate around the world yw axis to align the zw and zv
axis
final rotation is about the zw axis to align the yw and yv
axis
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Transformation from
WC to VC (cont’)

Rotation by uvn system

Calculate unit uvn vectors




N : view-plane normal vector
V : view-up vector
U : perpendicular to both N and V
CGVR
N
n
 n1 , n2 , n3 
N
VN
u
 u1 , u2 , u3 
VN
v  n  u  v1 , v2 , v3 
Form the composite rotation matrix
u1 u2
v v
2
R 1
n1 n2

0 0
cgvr.korea.ac.kr
u3
v3
n3
0
0
0
0

1
MW C, VC  R  T
Graphics Lab @ Korea University
Camera Models

CGVR
The most common model is pin-hole camera


All captured light rays arrive along paths toward focal
point without lens distortion (everything is in focus)
Sensor response proportional to radiance

Other models consider…



Depth of field
Motion blur
Lens distortion
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Viewing Parameters

Position



View direction(dx, dy, dz)
Up direction(ux, uy, uz)
Aperture


Eye position(px, py, pz)
Orientation


CGVR
Field of view(xfov, yfov)
Film plane


“look at” point
View plane normal
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Viewing Coordinate

CGVR
Canonical coordinate system


Convention is right-handed (looking down – z axis)
Convention for projection, clipping, etc.
Viewing up vector maps to Y axis
Y
Viewing back vector
maps to Z axis
(potting out of page)
X
cgvr.korea.ac.kr
Viewing right
vector maps to
X axis
Graphics Lab @ Korea University
Viewing Transformation

CGVR
Transformation matrix maps camera basis
vectors to canonical vectors in viewing
coordinate system
Back
(0, 1, 0)
Up
Matrix
Right
cgvr.korea.ac.kr
Eye
(1, 0, 0)
(0, 0, 1)
Graphics Lab @ Korea University
Viewing Transformation
CGVR
P(x, y, z)
3D Object Coordinate
Model Transformation
3D World Coordinate
Viewing Transformation
3D Viewing Coordinate
Projection Transformation
2D Projection Coordinate
Projection
Transformation
Viewport Transformation
2D Device Coordinate
p(x’, y’)
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Projection

General definition


CGVR
Transform points in n-space to m-space(m<n)
In computer graphics

Map viewing coordinates to 2D screen coordinates
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Taxonomy of Projections
CGVR
Planar geometric projection
Parallel
Orthographic
Perspective
Oblique
One-point
Three-point
Two-point
Top
Front
Axonometric
Side
cgvr.korea.ac.kr
Cabinet
Other
Cavalier
Graphics Lab @ Korea University
Parallel & Perspective

Parallel Projection

Perspective Projection
cgvr.korea.ac.kr
CGVR
Graphics Lab @ Korea University
Taxonomy of Projections
CGVR
Planar geometric projection
Parallel
Orthographic
Perspective
Oblique
One-point
Three-point
Two-point
Top
Front
Axonometric
Side
cgvr.korea.ac.kr
Cabinet
Other
Cavalier
Graphics Lab @ Korea University
Parallel Projection

CGVR
Center of projection is at infinity

Direction of projection (DOP) same for all points
DOP
View Plane
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Taxonomy of Projections
CGVR
Planar geometric projection
Parallel
Orthographic
Perspective
Oblique
One-point
Three-point
Two-point
Top
Front
Axonometric
Side
cgvr.korea.ac.kr
Cabinet
Other
Cavalier
Graphics Lab @ Korea University
Parallel Projection View
Volume
cgvr.korea.ac.kr
CGVR
Graphics Lab @ Korea University
Orthographic & Oblique

Orthographic parallel projection


CGVR
the projection is perpendicular to the view plane
Oblique parallel projection

The projectors are inclined with respect to the view
plane
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Orthographic Projections

CGVR
DOP perpendicular to view plane
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Orthographic Projections

CGVR
DOP perpendicular to view plane
Front
Top
cgvr.korea.ac.kr
Side
Graphics Lab @ Korea University
Orthographic Coordinates
x p  x,
cgvr.korea.ac.kr
CGVR
yp  y
Graphics Lab @ Korea University
Oblique Projections

CGVR
DOP not perpendicular to view plane
Cavalier
(DOP at 45)
cgvr.korea.ac.kr
Cabinet
(DOP at 63.4)
Graphics Lab @ Korea University
Oblique Projections

CGVR
DOP not perpendicular to view plane

Cavalier projection
tan   1,   45

Cabinet projection
tan   2 ,   63.4
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Parallel Projection Matrix

CGVR
General parallel projection transformation
x p  x  L cos  , y p  y  L sin 
z
z
tan   , L 
 zL1
L
tan 
x p  x  z ( L1 cos  )
y p  y  z ( L1 sin  )
Where L1 is the inverse
of tan α , which is also
the value of L when z=1
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Parallel Projection Matrix

CGVR
General parallel projection transformation
 x p  1
y  
 p   0
 z p  0
  
 w p  0
cgvr.korea.ac.kr
0 L1 cos 
1
L1 sin 
0
0
0
0
0  x 
0  y 
0  z 
 
1  1 
Graphics Lab @ Korea University
Parallel Projection Matrix
1
0
M parallel  
0

0
cgvr.korea.ac.kr
0 L1 cos 
1
L1 sin 
0
0
0
0
CGVR
0
0
0

1
Graphics Lab @ Korea University
Taxonomy of Projections
CGVR
Planar geometric projection
Parallel
Orthographic
Perspective
Oblique
One-point
Three-point
Two-point
Top
Front
Axonometric
Side
cgvr.korea.ac.kr
Cabinet
Other
Cavalier
Graphics Lab @ Korea University
Perspective Projection

CGVR
Map points onto “view plane” along “projectors”
emanating from “center of projection”(cop)
Center of
Projection
cgvr.korea.ac.kr
View Plane
Graphics Lab @ Korea University
Perspective Projection

CGVR
How many vanishing point?
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Perspective Projection

CGVR
How many vanishing point?
Three-point
perspective
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Perspective Projection

CGVR
How many vanishing point?
Three-point
perspective
cgvr.korea.ac.kr
Two-point
perspective
Graphics Lab @ Korea University
Perspective Projection

CGVR
How many vanishing point?
Three-point
perspective
cgvr.korea.ac.kr
Two-point
perspective
One-point
perspective
Graphics Lab @ Korea University
Perspective Projection View
Volume
cgvr.korea.ac.kr
CGVR
Graphics Lab @ Korea University
Perspective Projection

CGVR
Compute 2D coordinates from 3D coordinates
with similar triangles
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Perspective Projection

CGVR
Compute 2D coordinates from 3D coordinates
with similar triangles
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Perspective Projection Matrix

CGVR
4x4 matrix representation?
x p  xD z
x'  x
y p  yD z
y'  y
zp  D
z'  z
wp  1
wp  z D
 x p  ?
y  
 p   ?
 z p  ?
  
 w p  ?
cgvr.korea.ac.kr
? ? ?  x 
? ? ?  y 
? ? ?  z 
 
? ? ?  1 
Graphics Lab @ Korea University
Perspective Projection Matrix

CGVR
4x4 matrix representation?
x p  xD z
x'  x
y p  yD z
y'  y
zp  D
z'  z
wp  1
wp  z D
 x p  1
y  
 p   0
 z p  0
  
 w p  0
cgvr.korea.ac.kr
0  x 
1 0 0  y 
0 1 0  z 
 
0 1 D 0  1 
0
0
Graphics Lab @ Korea University
Perspective Projection Matrix
M PER
1
0

 0

0


0
0
1
0
0
0
1
D
0
0  1

0
 0
0   0

1 
0
 
Center of Projection on the x axis
M PER
cgvr.korea.ac.kr
0
1
0
0
0
0
0
0 1
0

0 
0  0
 0
1 

Orthographic
projection
Perspective
projection
 1
 0

 0
 1
D
 x
0
0
0
1
0
0
0
0
0
0
0

0

1

CGVR
0
0
1
0
0
1
1
D
0
0
0

0

1

Perspective
transformation
Center of Projection on the y axis
M PER
1
0

 0

0

0
0
1
0
0
1
Dy
0
0
0
0

0

1

Graphics Lab @ Korea University
Perspective Projection Matrix
1
0

0

r
0
0
1
0
0
0
s
0
0
1
0
0
 or 
0
0


1
0
0
0
1
0
0
0
s
t
2-point perspectives
cgvr.korea.ac.kr
0
0

0

1
1
0

0

r
CGVR
0
0
1
0
0
0
s
t
0
0

0

1
3-point perspectives
Graphics Lab @ Korea University
Taxonomy of Projections
CGVR
Planar geometric projection
Parallel
Orthographic
Perspective
Oblique
One-point
Three-point
Two-point
Top
Front
Axonometric
Side
cgvr.korea.ac.kr
Cabinet
Other
Cavalier
Graphics Lab @ Korea University
Perspective vs. Parallel

CGVR
Perspective projection
+ Size varies inversely with distance – looks realistic
– Distance and angles are not(in general) preserved
– Parallel line do not (in general) remain parallel

Parallel projection
+ Good for exact measurements
+ Parallel lines remain parallel
– Angles are not (in general) preserved
– Less realistic looking
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Classical Viewing
cgvr.korea.ac.kr
CGVR
Graphics Lab @ Korea University