Download presentation
Presentation is loading. Please wait.
Published byCatherine Hawkins Modified over 6 years ago
1
Viewing 3 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2016
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Viewing 3
2
perspective view volume orthographic view volume
View Volumes specifies field-of-view, used for clipping restricts domain of z stored for visibility test perspective view volume orthographic view volume x=left x=right y=top y=bottom z=-near z=-far x VCS z y z
3
Canonical View Volumes
standardized viewing volume representation perspective orthographic orthogonal parallel x or y = +/- z x or y x or y back plane back plane 1 front plane front plane -z -z -1 -1
4
Why Canonical View Volumes?
permits standardization clipping easier to determine if an arbitrary point is enclosed in volume with canonical view volume vs. clipping to six arbitrary planes rendering projection and rasterization algorithms can be reused
5
Normalized Device Coordinates
convention viewing frustum mapped to specific parallelepiped Normalized Device Coordinates (NDC) same as clipping coords only objects inside the parallelepiped get rendered which parallelepiped? depends on rendering system
6
Normalized Device Coordinates
left/right x =+/- 1, top/bottom y =+/- 1, near/far z =+/- 1 Camera coordinates NDC x x x=1 right Frustum -z z left x= -1 z= -1 z=1 z=-n z=-f
7
Understanding Z z axis flip changes coord system handedness
RHS before projection (eye/view coords) LHS after projection (clip, norm device coords) VCS NDCS y=top y (1,1,1) x=left y z z (-1,-1,-1) x=right x x z=-far y=bottom z=-near
8
perspective view volume
Understanding Z near, far always positive in GL calls THREE.OrthographicCamera(left,right,bot,top,near,far); mat4.frustum(left,right,bot,top,near,far, projectionMatrix); perspective view volume x=left x=right y=top y=bottom z=-near z=-far x VCS y orthographic view volume y=top x=left y z x=right VCS x z=-far y=bottom z=-near
9
Understanding Z why near and far plane? near plane: far plane:
avoid singularity (division by zero, or very small numbers) far plane: store depth in fixed-point representation (integer), thus have to have fixed range of values (0…1) avoid/reduce numerical precision artifacts for distant objects
10
Orthographic Derivation
scale, translate, reflect for new coord sys VCS x z NDCS y (-1,-1,-1) (1,1,1) y=top x=left y z x=right x z=-far y=bottom z=-near
11
Orthographic Derivation
scale, translate, reflect for new coord sys VCS x z NDCS y (-1,-1,-1) (1,1,1) y=top x=left y z x=right x z=-far y=bottom z=-near
12
Orthographic Derivation
scale, translate, reflect for new coord sys
13
Orthographic Derivation
scale, translate, reflect for new coord sys VCS y=top x=left y z x=right x z=-far y=bottom z=-near same idea for right/left, far/near
14
Orthographic Derivation
scale, translate, reflect for new coord sys
15
Orthographic Derivation
scale, translate, reflect for new coord sys
16
Orthographic Derivation
scale, translate, reflect for new coord sys
17
Orthographic Derivation
scale, translate, reflect for new coord sys
18
Projective Rendering Pipeline
object world viewing O2W W2V V2C OCS WCS VCS projection transformation modeling transformation viewing transformation clipping C2N CCS OCS - object/model coordinate system WCS - world coordinate system VCS - viewing/camera/eye coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device/display/screen coordinate system perspective divide normalized device N2D NDCS viewport transformation device DCS
19
Projection Warp warp perspective view volume to orthogonal view volume
render all scenes with orthographic projection! aka perspective warp x x z=d z=d z= z=0
20
Perspective Warp perspective viewing frustum transformed to cube
orthographic rendering of cube produces same image as perspective rendering of original frustum
21
Predistortion
22
Projective Rendering Pipeline
object world viewing O2W W2V V2C OCS WCS VCS projection transformation modeling transformation viewing transformation clipping C2N CCS OCS - object/model coordinate system WCS - world coordinate system VCS - viewing/camera/eye coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device/display/screen coordinate system perspective divide normalized device N2D NDCS viewport transformation device DCS
23
Separate Warp From Homogenization
viewing clipping normalized device VCS V2C CCS C2N NDCS projection transformation perspective division alter w / w warp requires only standard matrix multiply distort such that orthographic projection of distorted objects is desired persp projection w is changed clip after warp, before divide division by w: homogenization
24
Perspective Divide Example
specific example assume image plane at z = -1 a point [x,y,z,1]T projects to [-x/z,-y/z,-z/z,1]T [x,y,z,-z]T -z
25
Perspective Divide Example
after homogenizing, once again w=1 projection transformation perspective division alter w / w
26
Perspective Normalization
matrix formulation warp and homogenization both preserve relative depth (z coordinate)
27
Perspective To NDCS Derivation
VCS y=top NDCS x=left y (1,1,1) y z (-1,-1,-1) x z z=-near y=bottom z=-far x x=right
28
Perspective Derivation
simple example earlier: complete: shear, scale, projection-normalization
29
Perspective Derivation
earlier: complete: shear, scale, projection-normalization
30
Perspective Derivation
earlier: complete: shear, scale, projection-normalization
31
Perspective Derivation
32
Perspective Derivation
similarly for other 5 planes 6 planes, 6 unknowns
33
Projective Rendering Pipeline
object world viewing O2W W2V V2C OCS WCS VCS projection transformation modeling transformation viewing transformation clipping C2N CCS OCS - object/model coordinate system WCS - world coordinate system VCS - viewing/camera/eye coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device/display/screen coordinate system perspective divide normalized device N2D NDCS viewport transformation device DCS
34
NDC to Device Transformation
map from NDC to pixel coordinates on display NDC range is x = , y = , z = typical display range: x = , y = maximum is size of actual screen z range max and default is (0, 1), use later for visibility gl.viewport(0,0,w,h); gl.depthRange(0,1); // depth = 1 by default x 500 y y -1 x viewport NDC 1 -1 1 300
35
Origin Location yet more (possibly confusing) conventions
GL origin: lower left most window systems origin: upper left then must reflect in y when interpreting mouse position, have to flip your y coordinates x 500 y y -1 x viewport NDC 1 -1 1 300
36
N2D Transformation general formulation
reflect in y for upper vs. lower left origin scale by width, height, depth translate by width/2, height/2, depth/2 FCG includes additional translation for pixel centers at (.5, .5) instead of (0,0) x y viewport NDC 500 300 -1 1 height width
37
N2D Transformation Display z range is 0 to 1.
gl.depthRange(n,f) can constrain further, but depth = 1 is both max and default reminder: NDC z range is -1 to 1 x y viewport NDC 500 300 -1 1 height width
38
Device vs. Screen Coordinates
viewport/window location wrt actual display not available within GL usually don’t care use relative information when handling mouse events, not absolute coordinates could get actual display height/width, window offsets from OS loose use of terms: device, display, window, screen... x 1024 x 500 y y offset y display height x offset viewport viewport 300 display 768 display width
39
Projective Rendering Pipeline
glVertex3f(x,y,z) object world viewing O2W W2V V2C alter w OCS WCS VCS glFrustum(...) projection transformation modeling transformation viewing transformation clipping glTranslatef(x,y,z) glRotatef(a,x,y,z) .... gluLookAt(...) C2N / 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) N2D NDCS viewport transformation device DCS
40
Coordinate Systems viewing (4-space, W=1) clipping
(4-space parallelepiped, with COP moved backwards to infinity projection matrix normalized device (3-space parallelepiped) divide by w device (3-space parallelipiped) scale & translate framebuffer
41
Perspective Example view volume left = -1, right = 1 tracks in VCS:
bot = -1, top = 1 near = 1, far = 4 tracks in VCS: left x=-1, y=-1 right x=1, y=-1 x=-1 x=1 1 ymax-1 z=-4 real midpoint z=-1 -1 -1 1 -1 xmax-1 x NDCS (z not shown) DCS (z not shown) z VCS top view
42
Perspective Example view volume left = -1, right = 1 bot = -1, top = 1
near = 1, far = 4
43
Perspective Example / w
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.