Coordinate Systems
Coordinate Systems
● Local space
● World space
● View space
● Clip space
● Screen space
Coordinate systems transform pipeline
Alternative representation of the Coordinate system
Transform Pipeline
Coordinate Systems
Local space
A coordinate space local to your object.
Measurement scale specific to the objects.
World space
A coordinate space where the vertices of your
objects will be placed relative to the scale in the
game world.
Object coordinates get transformed from local to
world space.
Coordinate Systems
View space (eye/camera space)
The result of transforming your world-space coordinates
to coordinates that are in front of the user’s view.
Clip space
Coordinates that end up clipped are discarded while the
rest become fragments. and the space local to your
object.
Transformation from view to clip space coordinates is
done via projection matrix.
Screen space
Transformation of the clip coordinates to screen
coordinates in a process call viewport transform
Coordinate Transform Pipeline
Model Transform
View Transform
1. Perspective Projection
2. Orthographic Projection
Projection Transform
Perspective Projection Transform
The 'e' in Figure A becomes 'n' in Figure B; consequently the simple raw projection eqns. for x
and y also become:
x = −npx /pz .
y = −npy /pz .
OpenGL Frustum
OpenGL maps the frustum given by l, r, b, t, n, f (abbreviating the six directions defined in
the glFrustum method) to the homogeneous clip space cube shown in below in Figure C, It
maps: l → −1, r → +1, b → −1, t → +1
v = au + b , (1)
(6)
Derivation of Perspective Transformation
Substituting eq.6 to eq.4, we have:
(7)
(8)
(9)
OpenGL Frustum
Recalling the previously generated formula (eq.9) maps u0→ v0 and u1→ v1 here:
In the present case x = l → x' = −1 and x = r → x' = +1 and likewise for y, y' .
For the x mapping, eq. 9 gives:
OpenGL Frustum
Finally substituting x and y respectively by:
x = −npx /pz .
y = −npy /pz .
We get: and
Rewritten:
OpenGL Frustum
Now pz has to be mapped; the problem here is that the rasterization stage needs the
reciprocal of pz (1/pz) rather than pz so that we need z = a(1/pz) + b. Eq.9 is still usable if we
define s = 1/pz and define the mappings s = −1/ n → z = −1 and s = −1/ f → z = +1, so eq. 9
gives:
Now we have got the coefficients of our projective transformation (-x'pz , -y'pz and -z'pz ).
OpenGL Frustum
From the projected 3D point p = (x , y , z ) (the mapped image of (p x , p y , p z )) we now
create the ‘homogeneous’ coordinates p = (-x'pz , -y'pz , -z'pz and -pz ); note the -pz in the w
component.
The whole projective transformation can now be written in terms of a matrix multiplication and
homogeneous coordinates
OpenGL Frustum
From the projected 3D point p = (x , y , z ) (the mapped image of (p x , p y , p z )) we now
create the ‘homogeneous’ coordinates p = (-x'pz , -y'pz , -z'pz and -pz ); note the -pz in the w
component.
The whole projective transformation can now be written in terms of a matrix multiplication and
homogeneous coordinates
Orthographic Projection Transform
.
World and Viewport Coordinate Systems