Basic process of rasterization three-dimensional scene

Source: Internet
Author: User

Common conventions: World Coordinate Systems:

All the objects in the scene are in the world coordinate system, and all the coordinate systems are left-handed, and the left-handed coordinate system is three axes.

Based on the screen, the x axis of the coordinate system is pointing right, the Y axis is pointing up, and the z axis is pointing to the screen .

In this coordinate system we can create a world space. Of course, it's not really created, it's just a convention, it's easy to manage later, just like the latitude and longitude of the Earth, and with this we know where it is.

Object coordinate system:

There are many objects in the world, such as models in the game, players and so on.

All objects in the world have about three data:

1) The center of the object is in the world position (x, y, z)

2) Angle of rotation of the object (Pitch,yaw,roll). Corresponds to the angle of rotation on the x y Z axis, and specifies that the clockwise direction of the past is positive from the negative direction of each axis.

For example (0,0,90) means that the object does not rotate along the x y axis, only rotates 90 degrees along the z axis, and the rotation direction is clockwise.

3) The position of all points constituting the object relative to the center of the object (xi, Yi, zi) (I is the various points constituting the object, such as the 8 vertices of a cube)

The basic idea of rasterization

(Suppose that there is only one object in the world coordinate system, simplifying the description):

1) All points of the object are scaled, rotated, and shifted according to the position and orientation of the object in the world, and this step converts the coordinates of all points of the object from the object coordinate system to the world coordinate system.

For example, an object has only one point, which is at the center of the relative object (1,0,0), and the center of the object is in the World (0,1,0) and is not rotated. Then, after the point has been scaled, rotated, and shifted, the position of the point in the World coordinate system (1,1,0) can be obtained.

2) simplifying the observer in the world (that is, US) into a point where we are looking from, popularly known as the camera . This point also has the same position information (x, y, z) and rotational angle information (pitch, yaw, roll) as the object. With these two sets of data we can find out the position of the camera in the world coordinate system and the direction of our sight.

But the opposite of what we're going to do, we'll take all the points of the world (after the first step the coordinates of these points have been converted from their object coordinate system to the world coordinate system) , and by the inverse transformation of the above-mentioned transformations, you can get the coordinate of all the points centered on the camera. The world space after this step is called the observation space.

3) The next step is fascinating. We know that cameras (or humans) have limited scope to see things. But all the dots, whether we can see them or not, have been transformed. So all the points in the observation space are converted to a space called the homogeneous clipping space. This space has an artificially delineated range with a length and width height of 2, and the center of the cube-shaped range is at the origin (0,0,0).

That is, the range of the range up and down is 1 to 1. After a special matrix multiplication transformation, all the points in the 2X2X2 cube-shaped range will be the ones we can see, all the points that are not within the size of the 2x2x2, are out of our sight, and will not be rendered at all. Stealing a picture:

  

On the left is the observation space, where our camera is at the origin (this coordinate system is not the left-hand coordinate system we use, this is the right-hand coordinate system, and his z-axis is facing out of the screen). The right side is the homogeneous clipping space formed after the third step conversion.

Now all points are converted to this homogeneous clipping space, and all points that are not inside the cube are discarded. But the effect of that near-large is not realized. However, we can now take the x and Y coordinates of each point, and after stretching to match the resolution of the display (the value of x y coordinate of each point is stretched from [ -1,1] to such as [0,1920] and [0,1080]), it is displayed directly. But the projection process is called an orthographic projection, and that near-large effect is the result of a perspective projection.

How to do perspective projection? The general idea is to take the z-coordinates of each point in the viewing space , divided by the value of x y (x = x/z, y = y/z) of the point under the homogeneous clipping space . After division we can stretch the value of x y and show it, and you will get the image after the perspective projection.

Short Summary:

1) object space conversion to world space

2) World space conversion to observation space

3) Watch space transition to homogeneous clipping space

But the above transformation just gets a bit of the final position information, to be displayed on the screen, you also need to fill the points and lines of the surface, even to assign a custom map.

Basic process of rasterization three-dimensional scene

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.