DirectX Documentation

Microsoft Developer Network

Rasterization

Understanding Rasterization

Rasterization is the fundamental process in computer graphics where vector or geometric descriptions of an image are converted into a raster image, which is a grid of pixels. In the context of DirectX, this is a core stage within the graphics pipeline responsible for rendering 3D scenes onto a 2D screen.

The Rasterization Stage

The rasterization stage follows the geometry processing stages (vertex shader, tessellation, geometry shader) and precedes the pixel shader. Its primary role is to determine which pixels on the screen are covered by geometric primitives (typically triangles) and to interpolate vertex attributes across those covered pixels.

Key Concepts in Rasterization

How DirectX Handles Rasterization

The DirectX API provides mechanisms to control aspects of rasterization, though much of the core process is handled internally by the graphics hardware. Developers primarily interact with rasterization indirectly through:

Example: Rasterization State

The D3D11_RASTERIZER_DESC structure is used to configure the rasterizer. Key properties include:


D3D11_RASTERIZER_DESC rsDesc = {};
rsDesc.FillMode = D3D11_FILL_SOLID;
rsDesc.CullMode = D3D11_CULL_BACK;
rsDesc.FrontCounterClockwise = FALSE;
rsDesc.DepthClipEnable = TRUE;

ID3D11RasterizerState* pRasterizerState;
HRESULT hr = pd3dDevice->CreateRasterizerState(&rsDesc, &pRasterizerState);
if (SUCCEEDED(hr))
{
    pd3dImmediateContext->RSSetState(pRasterizerState);
}
        
The efficiency and quality of rasterization are critical for overall rendering performance. Understanding its role helps in optimizing scene complexity and ensuring correct visual output.

Further Reading