Interactive 3D Graphics Overview -------------------------------- Here's an overview of the rendering process. The terms used are described in the glossary. Currently, fast 3D rendering requires more or less the following steps: (This series of steps is referred to as the "graphics pipeline") 1. Generate geometry 2. Geometric Transformation 3. Culling/Clipping 4. Lighting 5. Triangle setup 6. Rasterization a. perspective correction b. Z-buffering c. texture lookup/filtering d. surface color calculation e. fog f. blending 7. Display In step 1, the application decides which polygons (surfaces) are potentially visible (within the current field of view) in the current scene. "Geometry" refers to the set of polygons representing the objects that make up the scene. Polygons are usually broken up into triangles somewhere during the process. In step 2, the polygons are transformed from object space into screen space. This involves a 3x4 or 4x4 matrix multiply. Object space is the cartesian coordinate system in which the polygons are specified. Screen space refers to the X/Y pixel addresses on the screen, plus a Z depth into the screen. In the next step, you toss away any polygons that fall off the screen, that face the wrong way, or that are too small. You also clip any that fall only partially on the screen. For lighting, you calculate some estimations of how the polygon is affected by light sources. This is based upon the angle between the light and the face of the polygon, and also perhaps the angle between those two and the viewer. [There are other techniques for applying lighting as well.] In triangle setup, you do two major things. First, you calculate various gradients that are used during rasterization. Next, you convert all these numbers from floating point into the fixed point format used by the rasterizer hardware. In rasterization, the hardware steps along the various gradients (performing various linear interpolations). Typically the hardware steps along horizontally (or vertically) and interpolates Z, texture coordinates, and perhaps intrinsic color or alpha. After each line (or column), the hardware adjusts the end points and moves to the next. Z is perspective corrected by interpolating 1/Z instead of Z. The texture coordinates (and perhaps other interpolants) are corrected by premultiplying by 1/Z at the polygon corners, then calculating Z from 1/Z at each pixel, then multiplying to get Z out again. [What's perspective correction? Well, consider looking down a model of a road with texture-mapped dashed lines. Perspective correction is what makes the nearby lines look very long, and the far away lines all short and crowded in the distance. If you used just plain linear interpolation, then all the lines would end up the same length. That would be incorrect, as looking down a real road would tell you.] In Z-buffering, you first look up the Z value stored in the Z buffer and compare this with the Z value you've computed for the current pixel you're considering drawing. If the new pixel is nearer to the viewer, you store its Z value in the Z buffer and continue on. Otherwise, you skip this pixel and go on to the next. In texturing, one to eight texture samples are looked up and blended together (this is where bilinear filtering using 4 samples comes in). See the section on texturing and mipmapping for more details. In rasterization steps d-f, many different values are all put together to come out with what's finally stored in the framebuffer. In step 7, you wait until vertical retrace and swap frame buffer banks to finally enable the scene to be displayed. ---------------------------------------------------------------------- (c) 1997 Carl Mueller