MSDN Documentation

Windows API Reference - DirectX Graphics Concepts

Rasterization

Rasterization is the process of converting vector graphics descriptions (geometric primitives like triangles, lines, and points) into a raster image, which is a grid of pixels. This is a fundamental step in the 3D graphics rendering pipeline. The graphics hardware is highly optimized to perform rasterization efficiently.

Conceptual Diagram of Rasterization
Conceptual view of a vector primitive being rasterized into pixels.

The Rasterization Process

The rasterization stage takes geometric primitives, typically defined by vertices in screen space coordinates, and determines which pixels on the screen the primitive covers. For each covered pixel, it also interpolates attribute values (like color, texture coordinates, or depth) from the primitive's vertices.

Triangle Rasterization

Triangle rasterization is the most common form. For a given triangle with vertices P1, P2, and P3:

The formula for interpolating an attribute A at a point P inside a triangle with vertices P1, P2, P3 and corresponding attributes A1, A2, A3 using barycentric coordinates (u, v, w) is:

A = u * A1 + v * A2 + w * A3

where u + v + w = 1.

Key Aspects and Considerations

Rasterization in DirectX

In DirectX, the graphics pipeline includes a dedicated rasterizer stage. This stage receives primitives from the vertex shader (after clipping and perspective division) and generates fragments. These fragments are then passed to the pixel shader for per-pixel processing before being written to the render target (framebuffer) after depth, stencil, and alpha testing.

DirectX provides APIs and control over certain aspects of rasterization, such as:

Understanding rasterization is crucial for optimizing rendering performance and achieving the desired visual quality in DirectX applications.