CS488
Implementation of projections
Luc RENAMBOT
1
CS488 Implementation of projections Luc R ENAMBOT 1 3D Graphics - - PowerPoint PPT Presentation
CS488 Implementation of projections Luc R ENAMBOT 1 3D Graphics Convert a set of polygons in a 3D world into an image on a 2D screen After theoretical view Implementation 2 Transformations P(X,Y,Z) 3D Object Coordinates Modeling
Luc RENAMBOT
1
world into an image on a 2D screen
2
3
P(X,Y,Z) Modeling Transformation Viewing Transformation Projection Transformation Window-to-Viewport Transformation P’(X’,Y’)
3D Object Coordinates 3D World Coordinates 3D Camera Coordinates 2D Screen Coordinates 2D Image Coordinates
4
3D Geometric Primitives Modeling Transformation Lighting Viewing Transformation Projection Transformation Clipping Scan Conversion Image
Transform into 3D world coordinate system Illuminate according to lighting and reflectance Transform into 3D camera coordinate system Transform into 2D camera coordinate system Clip primitives outside camera’s view Draw pixels (including texturing, hidden surface, etc.)
5
6
F B
7
8
Projection Reference Point (PRP) Center of Window (CW) View Reference Point (VRP) View-Plane Normal (VPN)
view volume → Clip against canonical view volume → Project onto projection plane → Translate into viewport
9
calculate intersections
canonical view volumes
10
Y = 1
11
X or Y
1
Front Plane Back Plane
Y = -Z
12
X or Y
1
Front Plane Back Plane
perspective projection: it transforms the world-coordinate positions such that the view volume becomes the perspective projection canonical view volume
projection in order to transform world- coordinate positions such that the view volume is transformed into the canonical view volume
13
performed in world coordinates or homogeneous coordinates
14
coordinates
15
coordinates
homogeneous coordinates
16
homogeneous coordinates
point and add a W=1 (x, y, z, 1)
homogeneous coordinates to make it easy to compose multiple matrices
17
coordinates
so we can clip against the canonical view volumes
world that are in the existing view volume are in the new canonical view volume
perform this normalization
18
VRP to the origin
VRC so n-axis (VPN) is z-axis, u-axis is x-axis, and v-axis is y-axis
z-axis (only needed for oblique parallel projections - that is where the direction of projection is not normal to the view plane)
volume
19
VRP to the origin
20
VRC
VPN / || VPN ||
VPN
VUP x Rz / || VUP x Rz ||
Vup
formed by Rz and Rx
21
axis and V into Y axis
22
Rx = r1x r2x r3x r1y r2y r3y r1z r2z r3z 1
to z-axis (only needed for oblique parallel projections - that is where the direction of projection is not normal to the view plane) makes DOP coincident with the z axis
23
24
DOPx DOPy DOPx = (umax + umin)/2 (vmax + vmin)/2 1 − PRPu PRPv PRPn 1
DOP ′
z
1
1 −DOPx/DOPz 1 −DOPy/DOPz 1 1
into canonical view volume
25
Tpar = T −(umax + umin)/2 −(vmax + vmin)/2 −F Spar = S 2/(umax − umin) 2/(vmax − vmin) 1/(F − B)
26
VRP to the origin
VRC so n-axis (VPN) is z-axis, u-axis is x-axis, and v-axis is y-axis
(PRP) is at the origin
the z-axis
27
VRP to the origin is the same as step 2.1 for Npar
28
VRC so n-axis (VPN) is z-axis, u- axis is x-axis, and v-axis is y-axis is the same as step 2.2 for Npar
29
30
volume is the z-axis
may not be on the Z axis
CW onto the Z axis
31
VRP was at the origin, afterwards it may not be
VRP is:
32
V RP ′ = SHpar ∗ T(−PRP) ∗ 1
Sper = 2V RP ′
z/[(umax − umin)(V RP ′ z + B)]
2V RP ′
z/[(vmax − vmin)(V RP ′ z + B)]
−1/(V RP ′
z + B))
Nper = Sper * SHpar * T(-PRP) * R * T(-VRP)
VRC
VRP to origin
33
the camera parameters
these matrices do not need to be recomputed
camera, these matrices will need to be constantly recreated
34
2 remains in homogeneous coordinates.
be used.
be > 0, and W should remain 1 through the normalization step
35
terms by W to get (x/W, y/W, z/W, 1)
coordinates
W as it should still be 1
36
volume
that is inside the canonical view volume, and clip away everything that is outside the canonical view volume
2D and extend it to 3D, except now there are 6 bits instead of four
37
38
39
Equations in book, page 273
W=1
40
41
at z=0.
Yp = Y and Z is set to 0 to do the projection onto the projection plane.
the same X and Y values
42
(X, Y, Z, 1) holding a given point, gives the resulting vector (X, Y, 0, 1)
43
Mort = 1 1 1
(X, Y, Z, 1) holding a given point, gives the resulting vector (X, Y, Z, -Z)
44
Mort = 1 1 1 −1
Y values do depend on the Z value. Objects that are further away should appear smaller than similar objects that are closer
volume are still within the following range:
Y <= 1
45
device coordinates
is at the origin
(which keeps the corner at the origin)
corner of the viewport
46
47
Mvv3dv = T Xviewmin Y viewmin Zviewmin ∗ Svv3dv ∗ T 1 1 1
Svv3dv = S (Xviewmax − Xviewmin)/2 (Y viewmax − Y viewmin)/2 (Zviewmax − Zviewmin)/1
coordinates
get (x/W, y/W, z/W, 1) and then we ignore the 1 to go back to 3D coordinates
48
clip in homogeneous coordinates to be more general
different here, as both the parallel and perspective projections need to be normalized into the canonical parallel perspective view volume.
49
This is the same normalization that needed to be done in step 8 of method 1 before we could convert to 2D coordinates.
50
cases the clipping routine is the same.
Y= -W, Y= W, Z= -W, Z=0
51
M = 1 1 1/(1 + Zmin) z/(1 + Zmin −1
the corner at the origin)
viewport
Yviewmin, Zviewmin) * Svv3dv * T(1, 1, 1)
2, (Zviewmax-Zview.min)/1 )
52
2D coordinates
by W will affect the transformation of the points
53
54
to bring is a few writing utensils
closed neighbour, and open mind. No calculators allowed.
telephones before coming to class
55