-
Notifications
You must be signed in to change notification settings - Fork 0
/
coordinate-system-convention.txt
64 lines (42 loc) · 1.56 KB
/
coordinate-system-convention.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Model -> World -> View -> Projection -> NDC -> Screen -> shs::Canvas
Model space 3D coordinate system:
origin is (0,0,0) and center of all vertices of individual model
x is to the right
y is to the up
z is to the forward
World space 3D coordinate system
origin is (0,0,0) and center of all models
x is to the right
y is to the up
z is to the forward
View space 3D coordinate system
origin is (0,0,0) and viewer is at origin, all models are on this coordinate system
x is to the right
y is to the up
z is to the forward
Projection space coordinate system
used for simulating camera perspective
x is to the right
y is to the up
z is to the forward
w is used for normalization
Clip space aka NDC(Normalized Device Coordinates) space aka homogeneous coordinate space
axis are mapped to range of [-1.0, 1.0], scaled by z_near and z_far
x is to the right
y is to the up
z is to the forward
glm::vec3 point_in_NDC = glm::vec3(point_in_CLIP_SPACE) / point_in_CLIP_SPACE.w;
Screen space 2D coordinate system
maps x in NDC[-1, 1] -> [0, SCREEN_WIDTH ]
maps y in NDC[-1, 1] -> [0, SCREEN_HEIGHT]
origin (0,0) is at top-left corner
x is from left to the right
y is from top to the bottom
Rasterizatin happen in this space
shs::Canvas 2D coordinate system:
origin (0,0) is at left-bottom corner
x is left to right
y is bottom to up
Converting from Screen space to the shs::Canvas space
x_at_canvas = x_at_screen_space
y_at_canvas = SCREEN_HEIGHT - y_at_screen