---
id: "blue-noise-screen-space-sampler"
title: "Blue-noise error distribution sampler"
aliases: [Heitz blue-noise sampler, screen-space blue noise sampling, ranking and scrambling tiles]
domain: "gi"
stage: "lighting"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, cuda, unreal, unity]
year_introduced: 2019
inputs: [texture]
outputs: [radiance]
style: "photoreal"
dynamic: "both"
cost: "cheap"
authority: "Heitz et al., 2019"
url: "https://texelatlas.vercel.app/t/blue-noise-screen-space-sampler/"
sources_verified_at: "2026-11-29"
---
# Blue-noise error distribution sampler (Heitz et al., 2019)

> A low-discrepancy sampler whose per-pixel randomisation is optimised so the remaining Monte Carlo error across the screen looks like blue noise. At one to a few samples per pixel it is far less ugly and far easier to denoise.

## Reach for it when

- one sample per pixel noise looks ugly and clumpy
- denoiser struggles with white noise from ray tracing
- want noise that is easy to blur away in screen space
- stochastic shadows or ao look grainy at low ray counts

## How it works

Sampling many pixels at low counts leaves error that depends on how sample sets are assigned. If neighbouring pixels have uncorrelated sets, the error is white noise, which has clumps and is hard to filter. The sampler picks assignments so neighbouring pixels have maximally different sets, pushing error energy into high frequencies where blur and denoising remove it easily.

It works with a small fixed tile of precomputed data. Each pixel looks up a rank for each pair of dimensions and a scrambling value from a tile indexed by pixel coordinates modulo the tile size. The rank reorders the points of a Sobol sequence per pixel and the scramble randomises them with an XOR; both are optimised offline by simulated annealing so differences between neighbours of the error image are blue.

At runtime this is a handful of texture or buffer reads and XORs per dimension. It is typically animated over time with golden-ratio offsets so the pattern changes each frame without losing the screen-space property, which also helps temporal accumulation.

## When to use it

Choose it for real-time ray-traced or stochastic effects at one to four samples per pixel: shadows, ambient occlusion, reflections and DDGI-style noise that a denoiser or [temporal-anti-aliasing](temporal-anti-aliasing) will clean up.

Prefer [owen-scrambled-sobol-sampling](owen-scrambled-sobol-sampling) for offline and high-sample-count rendering, where asymptotic convergence matters more than screen-space error. Prefer [blue-noise-dithering](blue-noise-dithering) for plain quantisation or alpha-test dithering, which uses a single blue-noise texture instead of per-dimension ranking tiles. Prefer [restir-gi](restir-gi) resampling when you want the sampler to be reused across pixels rather than just improving the noise spectrum.

## Cost

cheap — A few table fetches and XORs per sample dimension; tile data is small enough to sit in a single texture.
Measured GPU Weight: 18.67× baseline (moderate) — 0.6143 ms median / 0.6354 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 16.11× baseline (moderate) — 0.2561 ms median (2.4× faster on L4).
Ampere A100 scaling: 12.12× baseline (moderate) — 0.3492 ms median (1.76× faster on A100).

## Failure modes

- Tile repetition becomes visible as a pattern when the tile is small and the image is smooth
- Blue-noise property degrades after reprojection or when the denoiser blurs differently across pixels
- Ranking tile is optimised for a fixed number of dimensions, so exceeding it reuses correlated dimensions
- Temporal offsets that are not decorrelated (a fixed shift) produce crawling dither instead of fresh noise
- Gain over white noise shrinks as sample count rises and the error stops being the dominant artifact

## Engine support

- blender: builtin — `Render Properties > Sampling > Advanced > Pattern = Blue-Noise` (evidence: https://docs.blender.org/manual/en/5.2/render/cycles/render_settings/sampling.html, checked 2026-12-01) — Cycles blue-noise sampling pattern.
- unity: builtin — `HDRP Ray Tracing / Path Tracing (GetBNDSequenceSample in RaytracingSampling.hlsl implements Heitz et al. blue-noise error distribution)` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingSampling.hlsl, checked 2026-12-01) — HDRP-only ray tracing and path tracing sampler.

## Dataflow

- Inputs: texture
- Outputs: radiance
- Platforms: webgl2, webgpu, desktop-gpu, cuda, unreal, unity

## Presets

### Blue-noise screen-space sampler — white noise vs high-frequency blue-noise 1-SPP shadows (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_SAMPLE_SPREAD": 1,
  "P_TEMPORAL_SPIN": 0.65,
  "P_NOISE_GAIN": 1,
  "P_SPLIT": 0.46
}
```

```glsl
const float P_SAMPLE_SPREAD = 1.0; // P Penumbra Spread [0.2, 2.2, 0.05]
const float P_TEMPORAL_SPIN = 0.65; // P R2 Animate [0.0, 2.0, 0.05]
const float P_NOISE_GAIN = 1.0; // P Noise Contrast [0.2, 1.8, 0.05]
const float P_SPLIT = 0.46; // P White/Blue Split [0.0, 1.0, 0.02]

// Uncorrelated white noise hash (clumpy low-frequency energy)
float whiteNoise(vec2 px) {
  vec3 p3 = fract(vec3(px.xyx) * 0.1031);
  p3 += dot(p3, p3.yzx + 33.33);
  return fract((p3.x + p3.y) * p3.z);
}

// High-frequency screen-space blue-noise approximation via Jimenez Interleaved Gradient Noise
// paired with golden-ratio R2 plastic-constant temporal offset
float blueNoiseIGN(vec2 px, float framePhase) {
  vec2 p = px + vec2(framePhase * 5.588238, framePhase * 7.123105);
  return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));
}

// Second independent blue-noise channel via rotated IGN lattice
float blueNoiseIGN2(vec2 px, float framePhase) {
  vec2 p = px.yx + vec2(framePhase * 3.247179, framePhase * 9.414213);
  return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));
}

float mapScene(vec3 p) {
  float dFloor = p.y + 0.72;
  float dS1 = length(p - vec3(-0.38, -0.22, 0.08)) - 0.50;
  float dS2 = length(p - vec3(0.42, -0.34, -0.18)) - 0.38;
  float dS3 = length(p - vec3(0.02, 0.34, -0.58)) - 0.32;
  return min(min(dFloor, dS1), min(dS2, dS3));
}

vec3 calcNormal(vec3 p) {
  vec2 e = vec2(0.002, 0.0);
  return normalize(vec3(
    mapScene(p + e.xyy) - mapScene(p - e.xyy),
    mapScene(p + e.yxy) - mapScene(p - e.yxy),
    mapScene(p + e.yyx) - mapScene(p - e.yyx)
  ));
}

float traceHardShadow(vec3 ro, vec3 rd) {
  float t = 0.03;
  for (int i = 0; i < 24; i++) {
    float h = mapScene(ro + rd * t);
    if (h < 0.004) return 0.0;
    t += h;
    if (t > 4.5) break;
  }
  return 1.0;
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  vec2 screenUV = fragCoord / iResolution.xy;

  float splitX = clamp(P_SPLIT, 0.0, 1.0);
  bool useBlue = (screenUV.x >= splitX);

  float frameIdx = floor(iTime * 12.0 * max(P_TEMPORAL_SPIN, 0.0));
  vec2 qCoord = floor(fragCoord * 0.5); // 2x2 pixel blocks make noise distribution crystal clear
  float u1 = useBlue ? blueNoiseIGN(qCoord, frameIdx) : whiteNoise(qCoord + frameIdx * 13.7);
  float u2 = useBlue ? blueNoiseIGN2(qCoord, frameIdx) : whiteNoise(qCoord + vec2(41.3, 19.1) + frameIdx * 7.3);

  vec3 ro = vec3(0.0, 0.42, 2.55);
  vec3 rd = normalize(vec3(uv, -1.52));

  // Soft studio backdrop
  vec3 col = mix(vec3(0.09, 0.11, 0.14), vec3(0.24, 0.27, 0.32), smoothstep(-0.5, 0.55, uv.y));

  float t = 0.0;
  bool hit = false;
  for (int i = 0; i < 56; i++) {
    float d = mapScene(ro + rd * t);
    if (d < 0.002) { hit = true; break; }
    t += d;
    if (t > 9.0) break;
  }

  if (hit) {
    vec3 p = ro + rd * t;
    vec3 n = calcNormal(p);

    // Area light disk centered overhead-right; jittered by 1-SPP stochastic sample
    float spread = clamp(P_SAMPLE_SPREAD, 0.15, 2.5) * 0.36;
    float ang = u1 * 6.2831853;
    float rad = sqrt(max(u2, 0.0)) * spread;
    vec3 lBase = normalize(vec3(0.65, 0.92, 0.48));
    vec3 lTan = normalize(cross(lBase, vec3(0.0, 1.0, 0.0)));
    vec3 lBit = cross(lBase, lTan);
    vec3 lDir = normalize(lBase + (cos(ang) * lTan + sin(ang) * lBit) * rad);

    // 1-SPP stochastic area shadow ray + 1-SPP stochastic hemisphere AO ray
    float sh = traceHardShadow(p + n * 0.015, lDir);

    vec3 nTan = normalize(abs(n.y) < 0.9 ? cross(n, vec3(0.0, 1.0, 0.0)) : cross(n, vec3(1.0, 0.0, 0.0)));
    vec3 nBit = cross(n, nTan);
    float aoPhi = u2 * 6.2831853;
    float aoR = sqrt(max(u1, 0.0));
    vec3 aoDir = normalize(n * sqrt(max(1.0 - aoR * aoR, 0.05)) + (cos(aoPhi) * nTan + sin(aoPhi) * nBit) * aoR);
    float aoVis = traceHardShadow(p + n * 0.015, aoDir);

    float ndl = max(dot(n, lBase), 0.0);
    float nGain = clamp(P_NOISE_GAIN, 0.1, 2.0);
    float shEff = mix(0.5, sh, clamp(nGain, 0.0, 1.0));
    float aoEff = mix(0.65, aoVis, clamp(nGain * 0.75, 0.0, 1.0));

    vec3 alb = (p.y < -0.70) ? vec3(0.74, 0.73, 0.71) : vec3(0.86, 0.82, 0.76);
    vec3 direct = alb * vec3(1.65, 1.48, 1.28) * ndl * shEff;
    vec3 ambient = alb * vec3(0.24, 0.30, 0.42) * (0.28 + 0.72 * aoEff);
    col = direct + ambient;
  }

  // Bottom strip inset: direct visualization of the raw White-Noise vs Blue-Noise mask thresholded at 0.5
  if (screenUV.y < 0.19) {
    float maskVal = step(0.5, u1);
    vec3 mCol = useBlue ? mix(vec3(0.05, 0.11, 0.18), vec3(0.45, 0.85, 1.0), maskVal)
                        : mix(vec3(0.14, 0.08, 0.08), vec3(0.96, 0.62, 0.45), maskVal);
    col = mix(mCol, col, smoothstep(0.178, 0.19, screenUV.y));
    if (abs(screenUV.y - 0.19) < 0.004) col = vec3(0.92, 0.94, 0.98);
  }

  // Crisp vertical divider line between White Noise (left) and Blue Noise (right)
  if (splitX > 0.01 && splitX < 0.99 && abs(screenUV.x - splitX) < 0.004) {
    col = vec3(0.35, 0.88, 1.0);
  }

  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).

## Combines with

- [Ray-Traced Ambient Occlusion](https://texelatlas.vercel.app/t/ray-traced-ambient-occlusion.md): One ray per pixel with blue-noise directions gives AO whose residual noise a small spatial filter removes.
- [Temporal Anti-Aliasing](https://texelatlas.vercel.app/t/temporal-anti-aliasing.md): Animated blue-noise offsets give each frame a fresh sample set that history accumulation integrates.
- [ReSTIR DI: Spatiotemporal Reservoir Resampling for Direct Lighting](https://texelatlas.vercel.app/t/restir-di.md): Initial candidates for resampling are drawn with the sampler so the unresampled error already has a good spectrum.

## Sources

1. [primary] Eric Heitz, Laurent Belcour, V. Ostromoukhov, David Coeurjolly, Jean-Claude Iehl (2019) A low-discrepancy sampler that distributes monte carlo errors as a blue noise in screen space. ACM SIGGRAPH 2019 Talks. https://doi.org/10.1145/3306307.3328191 (verified via crossref on 2026-11-29)
2. [implementation] Calinou (2019) Calinou/free-blue-noise-textures. https://github.com/Calinou/free-blue-noise-textures License: NOASSERTION. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Blue-noise error distribution sampler." https://texelatlas.vercel.app/t/blue-noise-screen-space-sampler/ (accessed 2026-12-01).
