-
We can simulate 3D scenes on 2D planes by employing several techniques based on the way we see things in real life. We observe parallel lines converge to vanishing points, the size of objects diminish with depth, objects obscure the objects behind them, lighting and shading depict the solid form and volume of 3D objects, and shadows imply the location of light sources and indicate the position of objects relative to other objects in the scene.
-
The point where two edges on a polygon meet is a vertex. A vertex in Direct3D includes a 3D spatial location, but we can also couple other data components to the vertex, such as color, normals, and texture coordinates. In Direct3D we may define our own custom vertex structure. In order for Direct3D to know what to do with our vertex data, we must define a vertex declaration, which provides Direct3D with a description of our vertex structure. A vertex declaration is described by an array of D3DVERTEXELEMENT9 elements.
-
We approximate objects with a triangle mesh. We can define each triangle by specifying its three vertices. In many meshes, vertices are shared among triangles; indexed lists can be used to avoid vertex duplication.
-
The virtual camera is modeled as a frustum. The volume of space inside the frustum is what the camera "sees."
-
Given a geometric description of a 3D scene and a positioned and aimed virtual camera in that scene, the rendering pipeline refers to the entire sequence of steps necessary to generate a 2D image that can be displayed on a monitor screen based on what the virtual camera sees.
-
The vertices of each 3D object are defined relative to the object's local coordinate system. Next, the associated world transform of each object changes the object's vertex coordinates so that they are relative to the world coordinate system. After this, all the vertices in the scene are relative to the same coordinate system and should be positioned, oriented, and scaled correctly in relation to each other. We can think of the camera as an object in the world as well, and we can choose to make the camera our frame of reference instead of the world coordinate system. The view transformation changes all the geometry relative to the world coordinate system so that it is relative to the camera coordinate system (so-called view space). Subsequently, the projection matrix modifies each vertex. After the projection matrix modification, back facing triangles are culled, and geometry outside the frustum is discarded or clipped. Next, the homogeneous divide occurs, which finishes the projection process and transforms vertices to normalized device coordinates. At this point, the normalized device coordinates are mapped to a portion of the back buffer (or the entire back buffer) as defined by the viewport transformation. Finally, rasterization takes place.
-
The rasterization stage is responsible for computing the colors of the individual pixels that make up the interiors and boundaries of 2D triangles in image coordinates. Pixel operations like texturing, pixel shaders, depth buffering, and alpha blending occur in the rasterization stage. Data coupled with the vertices of these 2D triangles are interpolated across the face of the triangle. Hence, data at the vertex level is fed to the pixel level, where it can be used in determining the final color of a pixel.
浙公网安备 33010602011771号