This is a summary blog around "GAMES101: Introduction to Modern Computer Graphics", taught by Lingqi Yan. The knowledge and images involved are quoted from the instructor Lingqi Yan's lecture notes and book "Fundamentals of Computer Graphics 4th".
Catalog
How the transformation process works?
How the transformation process works?
Think about how to take a photo
Steps | What to do? | Modeling | |
---|---|---|---|
Steps1 | Find a good place and arrange people | Model transformation | To adjust objects in the virtual world where they should be |
Steps2 | Find a good “angle” to put the camera | View/Camera transformation | To get the relative position of objects and camera |
Steps3 | Cheese! | Projection transformation | Project 3D space onto standard 2D plane ([-1,1]^2)(by orthographic or perspective projection) |
Viewport transformation | Mapping the standard plane to the screen resolution range, i.e., [-1,1]^2→[0,width]*[0,height] |
1. Model Transformation
2. View/Camera Transformation
2.1 Camera coordinate system
- Position
- Look-at / gaze direction
- Up direction(assuming perp. to loo-at)
2.2 Transform the camera
The purpose of the camera transformation is to get the relative position of all objects to the camera. It is known that simultaneous movement of the object and the camera does not affect the final image result.
We move the object and the camera simultaneously to make camera locate at the origin, up at Y, look at -Z. Then the coordinates of the object is the relative coordinates of object and camera.
The transformation matrix of the rotation is an orthogonal matrix, so the inverse matrix can be obtained by transposing. In other words, we can transpose a rotation transformation matrix to get its inverse transformation matrix.
3. Projection Transformation
After the camera transformation, the result is still three-dimensional space coordinates, how to map it to two-dimensional space coordinates is left to the projection transformation to complete. As we know, projections are mainly divided into orthogonal and perspective projections.

3.1. Orthographic projection
In orthogonal projection, all rays are propagated in parallel and the relative positions of the coordinates do not change.
In general, We want to map a cuboid to the “canonical (正则、规范、标准)” cube
(for calculation convenience).
Consider only the x, y coordinates, it translate (center to origin) first, then scale (length/width/height to 2). Then we can get the transformation matrix.
3.2. Perspective projection
Perspective projection is the way most similar to how the human eye sees things, following the principle that near objects are relatively larger and distant objects are relatively smaller.
We find the relationship between transformed points (x’, y’, z’) and the original points (x, y, z) as follows,
Then, in homogenous coordinates, we wish to find a matrix that completes the following transformation.
i.e.,
First, the first two rows and the last row of this matrix can be determined very quickly,
So how to determine the third row? Then here it is necessary to apply the properties of perspective projection.
1) Any point’s z on the near plane will not change
First we perform a rewrite on transformation result, i.e. ,replace z with n,
So the third row must be of the form , i.e.,
Now we have,
2) Any point’s z on the far plane will not change
Similarly, we can obtain,
Solve for A and B,
Finally, every entry in is known!
At last, do orthographic projection () to finish
4. Viewport Transformation
This step is very simple, as introduced in the orthogonal transformation is the conversion of two range spaces. Mapping the standard plane to the screen resolution range, i.e., .
Reference
[1] Marschner S , Shirley P. Fundamentals of Computer Graphics 4th
[2] Lingqi Yan, GAMES101: 现代计算机图形学入门