{
 "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",
 "subdomain": "Monte Carlo sampling",
 "stage": "lighting",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "cuda",
  "unreal",
  "unity"
 ],
 "year_introduced": 2019,
 "inputs": [
  "texture"
 ],
 "outputs": [
  "radiance"
 ],
 "style": "photoreal",
 "dynamic": "both",
 "summary": "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.",
 "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.\n\nIt 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.\n\nAt 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": "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.\n\nPrefer [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": {
  "class": "cheap",
  "notes": "A few table fetches and XORs per sample dimension; tile data is small enough to sit in a single texture."
 },
 "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/3306307.3328191",
   "type": "paper",
   "title": "A low-discrepancy sampler that distributes monte carlo errors as a blue noise in screen space",
   "authors": [
    "Eric Heitz",
    "Laurent Belcour",
    "V. Ostromoukhov",
    "David Coeurjolly",
    "Jean-Claude Iehl"
   ],
   "year": 2019,
   "venue": "ACM SIGGRAPH 2019 Talks",
   "url": "https://doi.org/10.1145/3306307.3328191",
   "ids": {
    "doi": "10.1145/3306307.3328191"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3306307.3328191",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3306307.3328191",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3306307.3328191",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3306307.3328191",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3306307.3328191",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "heitz2019discrepancy"
  },
  {
   "role": "implementation",
   "key": "gh:calinou/free-blue-noise-textures",
   "type": "code",
   "title": "Calinou/free-blue-noise-textures",
   "description": "Free 2D, 3D and 4D blue noise textures from the Moments in Graphics blog",
   "authors": [
    "Calinou"
   ],
   "year": 2019,
   "venue": "GitHub",
   "url": "https://github.com/Calinou/free-blue-noise-textures",
   "ids": {
    "repo": "Calinou/free-blue-noise-textures"
   },
   "license": "NOASSERTION",
   "extra": {
    "stars": 240,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2019-10-05T23:43:28Z",
    "language": null,
    "homepage": "http://momentsingraphics.de/BlueNoise.html",
    "license_name": "Other"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Calinou/free-blue-noise-textures",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Calinou/free-blue-noise-textures",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Calinou/free-blue-noise-textures",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Calinou/free-blue-noise-textures",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Calinou/free-blue-noise-textures",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/Calinou/free-blue-noise-textures",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "calinou2019calinou"
  }
 ],
 "presets": [
  {
   "id": "blue-noise-screen-space-sampler-live",
   "title": "Blue-noise screen-space sampler — white noise vs high-frequency blue-noise 1-SPP shadows",
   "runtime": "glsl-fragment",
   "params": {
    "P_SAMPLE_SPREAD": 1,
    "P_TEMPORAL_SPIN": 0.65,
    "P_NOISE_GAIN": 1,
    "P_SPLIT": 0.46
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_SAMPLE_SPREAD = 1.0; // P Penumbra Spread [0.2, 2.2, 0.05]\nconst float P_TEMPORAL_SPIN = 0.65; // P R2 Animate [0.0, 2.0, 0.05]\nconst float P_NOISE_GAIN = 1.0; // P Noise Contrast [0.2, 1.8, 0.05]\nconst float P_SPLIT = 0.46; // P White/Blue Split [0.0, 1.0, 0.02]\n\n// Uncorrelated white noise hash (clumpy low-frequency energy)\nfloat whiteNoise(vec2 px) {\n  vec3 p3 = fract(vec3(px.xyx) * 0.1031);\n  p3 += dot(p3, p3.yzx + 33.33);\n  return fract((p3.x + p3.y) * p3.z);\n}\n\n// High-frequency screen-space blue-noise approximation via Jimenez Interleaved Gradient Noise\n// paired with golden-ratio R2 plastic-constant temporal offset\nfloat blueNoiseIGN(vec2 px, float framePhase) {\n  vec2 p = px + vec2(framePhase * 5.588238, framePhase * 7.123105);\n  return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));\n}\n\n// Second independent blue-noise channel via rotated IGN lattice\nfloat blueNoiseIGN2(vec2 px, float framePhase) {\n  vec2 p = px.yx + vec2(framePhase * 3.247179, framePhase * 9.414213);\n  return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));\n}\n\nfloat mapScene(vec3 p) {\n  float dFloor = p.y + 0.72;\n  float dS1 = length(p - vec3(-0.38, -0.22, 0.08)) - 0.50;\n  float dS2 = length(p - vec3(0.42, -0.34, -0.18)) - 0.38;\n  float dS3 = length(p - vec3(0.02, 0.34, -0.58)) - 0.32;\n  return min(min(dFloor, dS1), min(dS2, dS3));\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.002, 0.0);\n  return normalize(vec3(\n    mapScene(p + e.xyy) - mapScene(p - e.xyy),\n    mapScene(p + e.yxy) - mapScene(p - e.yxy),\n    mapScene(p + e.yyx) - mapScene(p - e.yyx)\n  ));\n}\n\nfloat traceHardShadow(vec3 ro, vec3 rd) {\n  float t = 0.03;\n  for (int i = 0; i < 24; i++) {\n    float h = mapScene(ro + rd * t);\n    if (h < 0.004) return 0.0;\n    t += h;\n    if (t > 4.5) break;\n  }\n  return 1.0;\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  vec2 screenUV = fragCoord / iResolution.xy;\n\n  float splitX = clamp(P_SPLIT, 0.0, 1.0);\n  bool useBlue = (screenUV.x >= splitX);\n\n  float frameIdx = floor(iTime * 12.0 * max(P_TEMPORAL_SPIN, 0.0));\n  vec2 qCoord = floor(fragCoord * 0.5); // 2x2 pixel blocks make noise distribution crystal clear\n  float u1 = useBlue ? blueNoiseIGN(qCoord, frameIdx) : whiteNoise(qCoord + frameIdx * 13.7);\n  float u2 = useBlue ? blueNoiseIGN2(qCoord, frameIdx) : whiteNoise(qCoord + vec2(41.3, 19.1) + frameIdx * 7.3);\n\n  vec3 ro = vec3(0.0, 0.42, 2.55);\n  vec3 rd = normalize(vec3(uv, -1.52));\n\n  // Soft studio backdrop\n  vec3 col = mix(vec3(0.09, 0.11, 0.14), vec3(0.24, 0.27, 0.32), smoothstep(-0.5, 0.55, uv.y));\n\n  float t = 0.0;\n  bool hit = false;\n  for (int i = 0; i < 56; i++) {\n    float d = mapScene(ro + rd * t);\n    if (d < 0.002) { hit = true; break; }\n    t += d;\n    if (t > 9.0) break;\n  }\n\n  if (hit) {\n    vec3 p = ro + rd * t;\n    vec3 n = calcNormal(p);\n\n    // Area light disk centered overhead-right; jittered by 1-SPP stochastic sample\n    float spread = clamp(P_SAMPLE_SPREAD, 0.15, 2.5) * 0.36;\n    float ang = u1 * 6.2831853;\n    float rad = sqrt(max(u2, 0.0)) * spread;\n    vec3 lBase = normalize(vec3(0.65, 0.92, 0.48));\n    vec3 lTan = normalize(cross(lBase, vec3(0.0, 1.0, 0.0)));\n    vec3 lBit = cross(lBase, lTan);\n    vec3 lDir = normalize(lBase + (cos(ang) * lTan + sin(ang) * lBit) * rad);\n\n    // 1-SPP stochastic area shadow ray + 1-SPP stochastic hemisphere AO ray\n    float sh = traceHardShadow(p + n * 0.015, lDir);\n\n    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)));\n    vec3 nBit = cross(n, nTan);\n    float aoPhi = u2 * 6.2831853;\n    float aoR = sqrt(max(u1, 0.0));\n    vec3 aoDir = normalize(n * sqrt(max(1.0 - aoR * aoR, 0.05)) + (cos(aoPhi) * nTan + sin(aoPhi) * nBit) * aoR);\n    float aoVis = traceHardShadow(p + n * 0.015, aoDir);\n\n    float ndl = max(dot(n, lBase), 0.0);\n    float nGain = clamp(P_NOISE_GAIN, 0.1, 2.0);\n    float shEff = mix(0.5, sh, clamp(nGain, 0.0, 1.0));\n    float aoEff = mix(0.65, aoVis, clamp(nGain * 0.75, 0.0, 1.0));\n\n    vec3 alb = (p.y < -0.70) ? vec3(0.74, 0.73, 0.71) : vec3(0.86, 0.82, 0.76);\n    vec3 direct = alb * vec3(1.65, 1.48, 1.28) * ndl * shEff;\n    vec3 ambient = alb * vec3(0.24, 0.30, 0.42) * (0.28 + 0.72 * aoEff);\n    col = direct + ambient;\n  }\n\n  // Bottom strip inset: direct visualization of the raw White-Noise vs Blue-Noise mask thresholded at 0.5\n  if (screenUV.y < 0.19) {\n    float maskVal = step(0.5, u1);\n    vec3 mCol = useBlue ? mix(vec3(0.05, 0.11, 0.18), vec3(0.45, 0.85, 1.0), maskVal)\n                        : mix(vec3(0.14, 0.08, 0.08), vec3(0.96, 0.62, 0.45), maskVal);\n    col = mix(mCol, col, smoothstep(0.178, 0.19, screenUV.y));\n    if (abs(screenUV.y - 0.19) < 0.004) col = vec3(0.92, 0.94, 0.98);\n  }\n\n  // Crisp vertical divider line between White Noise (left) and Blue Noise (right)\n  if (splitX > 0.01 && splitX < 0.99 && abs(screenUV.x - splitX) < 0.004) {\n    col = vec3(0.35, 0.88, 1.0);\n  }\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "blue-noise-screen-space-sampler",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:50:13.852Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6605,
      "std": 0.1659,
      "unique_colors": 111
     },
     "image": "/specimens/blue-noise-screen-space-sampler-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "owen-scrambled-sobol-sampling",
  "blue-noise-dithering",
  "temporal-anti-aliasing",
  "ray-traced-shadows",
  "ray-traced-ambient-occlusion"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "ray-traced-ambient-occlusion",
   "why": "One ray per pixel with blue-noise directions gives AO whose residual noise a small spatial filter removes."
  },
  {
   "id": "temporal-anti-aliasing",
   "why": "Animated blue-noise offsets give each frame a fresh sample set that history accumulation integrates."
  },
  {
   "id": "restir-di",
   "why": "Initial candidates for resampling are drawn with the sampler so the unresampled error already has a good spectrum."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/gi/blue-noise-screen-space-sampler.json"
 },
 "solves": [
  "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"
 ],
 "authority": "Heitz et al., 2019",
 "url": "https://texelatlas.vercel.app/t/blue-noise-screen-space-sampler/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 18.67,
  "tier": "moderate",
  "p50_ms": 0.6143,
  "p95_ms": 0.6354,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "blue-noise-screen-space-sampler-live",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 16.11,
   "tier": "moderate",
   "p50_ms": 0.2561,
   "p95_ms": 0.2598,
   "speedup_x": 2.4,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 12.12,
   "tier": "moderate",
   "p50_ms": 0.3492,
   "p95_ms": 0.3511,
   "speedup_x": 1.76,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}