Tech-Hounds.com

Because gamers play games, not benchmarks




A Primer to 3D Graphics - Part 2

After reading part 1, you should have a basic understanding of how 3D graphics work. We've discussed how objects are defined in 3D space, the math involved and how we try to 'emulate' the real world in 3D graphics. We even discuss a little bit about filtering and anti aliasing techniques that are widely used in real time 3D graphics today. In this part 2, we'll talk about the technical aspects of 3D graphics.

Going Deeper with 3D Graphics

The whole process of displaying 3D graphics on your screen is usually called rendering. Much of this process is done in the graphics pipeline. You might be wondering what this 'pipeline' is - well it's just a term describing the series of task your PC must complete to render 3D graphics. Basically, we've talked about them in part 1 - the geometry stage where we describe the object, perform the needed translation, rotation and scaling, clipping the world and doing perspective correction. We may also choose to 'lit' our object using lights so we have to calculate them too. There's also the rasterization stage where we add color, texture and other special effects to our objects. Information from the geometry part, including lighting will be also be used. Afterwards, the PC sends that image to your screen. Let's go deeper into these topics and discuss them one by one.

Geometry

Transformation & Lighting

While pixels and texels gets all the attention these days, none of them will matter without the basic geometry operations and definitions widely used in 3D graphics. They really are the basic building blocks of 3D. Without them, we will still be looking at mostly 2D images.

From part 1, we know some of the required math involving 3D graphics. Operations such as translation (moving an object parallel to an axis), rotation (rotating an object around an axis), scaling (changing the size of the object along an axis) are usually called transformation operations. Included in geometry transformations is matrix operations needed to present the 3D world to the viewer - us. Every operation - translation, rotation, scaling - are done and then 'perspectively corrected' in reference to the camera - our perspective. If one part of an object - for example the hand of a human model - is moved, the graphics hardware must perform the needed transformation on the related vertex and polygons (the hand). These transformations are usually done in relation to the object's point of origin (its center). Then the graphics hardware must convert the end result position of the hand into world coordinate space. This operation will provide the position of the model in the world. The last matrix conversion will be to determine both the position of the model and the camera - is it visible to the camera? There's also the operation to portray depth - usually scaling it to the center of the screen which serves as the camera's point of focus.

Translation matrix Scaling matrix

X Rotation matrix

Y Rotation matrix

Z Rotation matirx

Additional operations such as back face culling, clipping are also done. These operations are used to minimize unnecessary workload. We don't want 'unseen' objects, polygons and vertices to be included in the rasterization process. Of course, the next step will to to plot the positions of each object, polygon and vertex on the screen - perspectively corrected. But before doing that, we could choose to do some light calculations. They will provide visual cues for the viewer to complete the illusion of seeing the scene in 3D. So, as you can see, geometry transformations plays an important role in 3D graphics.
How a vertex in 3D space is drawn on a 2D screen How an edge / line in 3D space is drawn on a 2D screen

The matrix transforms as defined in OpenGL

Here's a snippet from the OpenGL standard book from www.opengl.org that describes matrix operations involved in 3D graphics: "The vertex coordinates that are presented to the GL are termed object coordinates. The model-view matrix is applied to these coordinates to yield eye coordinates. Then another matrix, called the projection matrix, is applied to eye coordinates to yield clip coordinates. A perspective division is carried out on clip coordinates to yield normalized device coordinates. An additional viewport transformation is applied to convert these coordinates into window coordinates."

A shape as defined in 3D space, projected onto a 2D screenScan conversion fills our shape with color, drawing the shape by filling the pixels affected

After the coordinates are plotted on the screen, the graphics hardware renders the screen, filling the frame buffer line per line until all the pixels are drawn. The rasterization process will fill each pixels with the appropriate textures, comparing Z values when needed and perform filtering to make sure the appropriate samples are chosen for the texture filtering. All these operations can either be done completely on the graphics card or just some of it. Early graphics hardware rely solely on the processing power of the main processor for geometry processing. Newer hardware available today can do all the processing on its own. Not only will the processor be free from the additional burden of geometry processing, but dedicated geometry hardware on these newer graphics card are leaps and bounds over what can be done in software. An added benefit to this is the graphics rasterization hardware doesn't have to wait for the geometry data from the processor since they're already in the graphics card memory and processed internally.

[Previous Page]
[Go to top]
[Next Page]
Disclaimer and Privacy policy.