Point Sampling vs Bilinear Filtering in DirectX

This article examines texture sampling within DirectX applications, specifically contrasting point sampling with bilinear filtering. It defines the mechanics of point sampling, explains how it functions within the DirectX graphics pipeline, and details the specific rendering scenarios where developers choose it over bilinear filtering to preserve visual intent, avoid data corruption, and maximize hardware performance.

Understanding Point Sampling

Point sampling, also known as nearest-neighbor filtering, is the simplest method of mapping a texture coordinate (UV) to a pixel on the screen. When a pixel shader samples a texture using point sampling, the GPU calculates which texel center is closest to the sample coordinate and uses that exact texel's color value without modification.

In DirectX, point sampling is configured through a sampler state description (D3D11_SAMPLER_DESC in DirectX 11 or D3D12_SAMPLER_DESC in DirectX 12) by setting the Filter member to a point-based enumeration, such as:

  • D3D11_FILTER_MIN_MAG_MIP_POINT
  • D3D12_FILTER_MIN_MAG_MIP_POINT

In contrast, bilinear filtering samples the four closest texels to the sample point and performs a weighted linear interpolation based on the fractional distance to each texel center, smoothing out transitions across surfaces.

When Point Sampling is Preferred in DirectX

While bilinear filtering is the standard choice for smoothing natural textures across 3D surfaces, point sampling is required or preferred in several critical graphics workflows.

1. Sampling Non-Color Data and G-Buffers

In deferred rendering pipelines, textures often store discrete mathematical data rather than visible color information. These include:

  • Object and Material IDs: Blending an object ID of 1 with an adjacent object ID of 2 creates non-existent IDs (like 1.5), breaking shader logic.
  • Normals and World Positions: Interpolation across depth discontinuities can average background and foreground values, causing severe rendering artifacts.
  • Stencil and Bitmask Textures: Interpolating discrete bit flags destroys the encoded binary data.

2. Pixel Art and Retro Aesthetics

For 2D games or retro-styled 3D games, maintaining sharp, distinct pixels is a core stylistic requirement. Bilinear filtering blurs sharp pixel boundaries, creating a muddy or out-of-focus visual. Point sampling preserves hard edges and renders textures exactly as authored at low resolutions.

3. Pixel-Perfect User Interfaces (UI) and Text

When rendering HUD elements, vector icons, or bitmap fonts at a 1:1 texel-to-pixel ratio, sub-pixel rounding errors can trigger unwanted linear blending. Point sampling ensures that text and sharp UI borders remain crisp without halo artifacts or inadvertent blurring caused by slight UV offsets.

4. Shadow Mapping Implementations

When reading raw depth values from a shadow map for manual processing—such as implementing custom Percentage-Closer Filtering (PCF), variance shadow maps, or custom screen-space contact shadows—developers often prefer point sampling. Blending raw, non-linear depth values linearly can yield incorrect depth comparisons near silhouette edges.

5. Bandwidth and Performance Optimization

Point sampling reads a single texel from memory cache, whereas bilinear filtering fetches four texels and calculates an interpolated result. In memory-bandwidth-bound scenarios, mobile environments, or low-end rendering contexts, point sampling reduces texture unit workload and memory access overhead.