Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
113 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

  Contents

 Introduction
 DirectX
 DirectDraw
 Direct3D
 Rendering Engine
 File Format
 DirectX and COM
 Summary and
 Appendix


 Printable version

 


Rendering Engine

The rendering engine forms an important part of Direct3D. It is responsible for taking a scene definition in terms of points in 3D, the different texture specifications, the lights and the camera specifications, and rendering ready, so that it can be displayed on the display device.

The functionality of the rendering engine is provided using three modules, namely the transformation module, the lighting module and the rasterization module. Each of these modules can be hardware accelerated, transparent to the user of the application. The application developer only has to put the detection facility into the application, which will allow it to query the hardware to find and use its capabilities, if present.

Figure 2 shows the three modules of the rendering engine and their interactions with the Direct3D API, before displaying the results on the rendering target, which is the 2D display surface. The diagram shows the sequence of operations performed on the data, before it is displayed.

modules
Figure 2: Rendering Engine Modules

The 3D data to be displayed, is given to the transformation module, which maps the 3D data onto its equivalent 2D data. This 2D data is then given to the lighting module, which calculates the light received by the data, considering the lights in the scene. The lit data is then given to the rasterization module, which calculates the transparency and applies the texture to the data. After rasterization, the data is 2D, lit using the different lights in the scene and may also have the specified texture maps applied to them.

Let us now consider each of the modules in a bit more detail.

Transformation Module

The transformation module is the first of the three modules of the rendering engine. This module handles the geometry transformations in the rendering engine. To do this, it uses three four-by-four (4x4) matrices, namely the view transformation matrix, the world transformation matrix and the projection matrix. For an explanation of these three matrices, refer [5], [6], [11], [12], [13] and [14]. The three matrices are maintained in three state registers, namely the viewing matrix, the world matrix and the projection matrix, repectively. This module uses one more state register, the viewport, for holding the dimensions of the 2D display area.

The transformation module combines all the matrices into one composite matrix and uses this for computations, as using only one matrix, as opposed to four, speeds up the calculations in the application.

It is possible to set the states of the state registers separately, in addition to setting the value of the composite matrix. But, it is advisible to let Direct3D calculate the composite matrix, as the matrix multiplication operations required, have been specially optimized in Direct3D. Additionally, the newer versions of DirectX make use of MMX technology.

Figure 3 shows a diagrammatic representation of the transformation module.

transmod
Figure 3: Transformation Module

Lighting Module

The lighting module of the rendering engine is the second of the three modules. It uses the data provided by the transformation module and calculates the lighting information for the received data.

This module maintains a stack of the current lights and the ambient light level and the different material properties of the data. All this information is used while calculating the light falling at a particular point in the scene.

Figure 4 shows a diagrammatic representation of the lighting module.

lightmod
Figure 4: Lighting Module

The lighting module can be operated in any one of the two lighting models it supports. The two models supported are:

Monochromatic model
- also known as the ramp model. This model uses only the gray component of each light source specified in the scene, to calculate a single shade value. This shade value is the diffuse component. Though this model supports multiple light sources, the colour components of the lights are ignored.

A restriction of this model is that only gray shades can be displayed and the textures used have to be of 8-bit depth. An advantage of this model over the RGB model is that it gives better performance than the RGB model.

RGB model
- is the other model supported by the lighting module of the rendering engine. This model helps produce more realistic effects of the given scene, as it uses the full colour content of the light sources and the material of the object being lit. This model supports multiple coloured light sources.

A limitation of this model is that it may produce a banding effect if the colour depth available is not very good. In the banding effect, the transition from one colour to another, is not smooth. It is as if two different coloured bands have been placed side-by-side. This effect is produced when the number of pixels available for representing the colours is far less than the number of colours actually required by the application to display the data properly. Also, its performance as compared to the monochromatic model may be less

Rasterization Module

The rasterization module is the last of the three modules of the rendering engine. This module takes only execute calls and the data and displays it onto the display surface.

On being given the execute call, the module goes through the list of vertices to be displayed and generates the transfomed vertices to be rendered. Clipping parameters can also be specified in this module. The module also culls back-facing triangles, viz. the triangles whose surface normals face away from the camera. An important point about this module is that it renders only clockwise oriented triangles.

Figure 5 shows a diagrammatic representation of the rasterization module.

rastmod
Figure 5: Rasterization Module

For more details on the Direct3D API and its features, refer [3] and [2].


Next : File Format