You are on page 1of 2

University of British Columbia Projective Rendering Pipeline NDC to Device Transformation Origin Location

CPSC 314 Computer Graphics


Jan-Apr 2016 • map from NDC to pixel coordinates on display • yet more (possibly confusing) conventions
object world viewing • NDC range is x = -1...1, y = -1...1, z = -1...1 • GL origin: lower left
O2W WCS W2V VCS V2C
OCS • typical display range: x = 0...500, y = 0...300 • most window systems origin: upper left
Tamara Munzner modeling viewing projection
transformation transformation transformation • maximum is size of actual screen • then must reflect in y
clipping
C2N • z range max and default is (0, 1), use later for visibility • when interpreting mouse position, have to flip your
OCS - object/model coordinate system CCS
gl.viewport(0,0,w,h);
perspective
gl.depthRange(0,1); // depth = 1 by default
y coordinates
WCS - world coordinate system divide normalized
0 x 500 0 x 500
Viewing 4 VCS - viewing/camera/eye coordinate
system
N2D device y 0 y y 0 y
NDCS
CCS - clipping coordinate system viewport -1 -1
transformation
NDCS - normalized device coordinate device x viewport x viewport
system NDC
http://www.ugrad.cs.ubc.ca/~cs314/Vjan2016 DCS 1
NDC 1
DCS - device/display/screen coordinate 2 3 4
system -1 1 300 -1 1 300

N2D Transformation N2D Transformation Device vs. Screen Coordinates Projective Rendering Pipeline
• general formulation • viewport/window location wrt actual display not available Scene.add(x) THREE.PerspectiveCamera(...)
within GL object world viewing
• reflect in y for upper vs. lower left origin
O2W W2V alter w
• scale by width, height, depth
• usually don’t care
OCS WCS VCS V2C
• use relative information when handling mouse events, not modeling viewing projection
• translate by width/2, height/2, depth/2 absolute coordinates transformation transformation transformation
Display z range is 0 to 1. clipping
• FCG includes additional translation for pixel centers at gl.depthRange(n,f) can • could get actual display height/width, window offsets from OS m.makeTranlation(x,y,z) camera.lookAt(...)
C2N /w
m.makeRotation(a,x,y,z) CCS
(.5, .5) instead of (0,0) reminder: constrain further, but depth = 1 • loose use of terms: device, display, window, screen... perspective
x.setMatrix(m)
NDC z range is -1 to 1 is both max and default 0 x 1024 division normalized
0 x 0 x OCS - object coordinate system
500 500 0 x 500 0 y canvas.{w,h} device
y y y offset N2D
0 y 0 y WCS - world coordinate system gl.viewport(x,y,a,b) NDCS
height height 0 y
1 1 x offset display VCS - viewing coordinate system viewport
viewport viewport height transformation
x viewport x viewport CCS - clipping coordinate system device
NDC NDC
300 display
-1 -1 NDCS - normalized device coordinate system DCS
width width 768
1 5 1 6 7 8
-1 300 -1 300 display width DCS - device coordinate system

Questions? Coordinate Systems Perspective Example Perspective Example


viewing
(4-space, W=1)
view volume view volume
tracks in VCS: left = -1, right = 1
clipping
left x=-1, y=-1 • left = -1, right = 1
projection (4-space parallelepiped, bot = -1, top = 1 • bot = -1, top = 1
matrix with COP moved right x=1, y=-1 near = 1, far = 4
backwards to infinity
• near = 1, far = 4

normalized device
divide by w x=-1 x=1
(3-space
parallelepiped) 1 ymax-1
z=-4
scale & device real
translate (3-space midpoint -1
z=-1 1 xmax-1
parallelipiped) -1 -1 0 0
x
NDCS DCS
(z not shown) (z not shown)
z
framebuffer
VCS
top view
9 10 11 12

Perspective Example Projective Rendering Pipeline OpenGL Example Coord Sys: Frame vs Point
following pipeline from top/left to go back from end of pipeline to beginning: coord frame POV!
read down: transforming read up: transforming points,
scene.add(x) bottom/right: moving object POV object world viewing clipping between coordinate frames, up from frame B coords to
THREE.PerspectiveCamera(...) O2W W2V VCS V2C CCS
object world viewing alter w OCS WCS from frame A to frame B frame A coords
modeling viewing projection
O2W WCS W2V VCS V2C
OCS transformation transformation transformation
OpenGL command order
modeling viewing projection
transformation transformation transformation
clipping CCS DCS display
m.makeTranlation(x,y,z) camera.lookAt(...) gl.viewport(0,0,w,h); D2N gl.viewport(x,y,a,b) N2D
m.makeRotation(a,x,y,z)
C2N /w CCS
x.setMatrix(m) perspective
NDCS normalized device
division normalized VCS N2V THREE.PerspectiveCamera(...) V2N
OCS - object coordinate system THREE.PerspectiveCamera(view angle, aspect, near, far)
canvas.{w,h} VCS viewing
WCS - world coordinate system gl.viewport(x,y,a,b) N2D device
/w NDCS u_xformMatrix = Identity() V2W camera.lookAt(...) W2V
viewport
WCS
VCS - viewing coordinate system gl.uniformMatrix4fv(u_xformMatrix, false, xformMatrix); WCS world
transformation
OCS1 m.makeRotationX(…)
CCS - clipping coordinate system device W2O O2W
torsoGeometry.applyMatrix(u_xformMatrix );
DCS var torso = new THREE.Mesh(torsoGeometry,normalMaterial);
OCS object
NDCS - normalized device coordinate system
scene.add(torso); scene.add(object)
13 14 15 16
DCS - device coordinate system pipeline interpretation
Questions?

17

You might also like