Owen-scrambled Sobol and low-discrepancy sampling
Generate sample points from the Sobol sequence and randomise them per pixel with a cheap hash-based Owen scramble, so each pixel gets well-stratified, decorrelated samples at any sample count with no stored tables.
Also known as Owen scrambling, scrambled Sobol sequence, QMC sampling, hash-based Owen scrambling
In the family Light transport & global illumination, Monte Carlo sampling
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | No built-in Owen-scrambled Sobol low-discrepancy sampler. |
| Unity | Built in | HDRP Ray Tracing and Path Tracing (_OwenScrambledTexture Owen-scrambled Sobol sequence in RaytracingSampling.hlsl) docs HDRP-only ray tracing and path tracing sampler. |
| Unreal 5.7 | Built in | ImportanceSamplingLibrary / MaterialExpressionSobol (low-discrepancy Sobol sequence sampling) docs |
| Blender 5.2 | Built in | Render Properties > Sampling > Advanced > Pattern = Classic docs Cycles. |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Low-discrepancy sequences such as Sobol fill the unit hypercube more evenly than random numbers, which cuts error in smooth integrands. Using the same sequence at every pixel produces visible structured artifacts, so each pixel needs its own randomisation that keeps the stratification.
Owen scrambling does this by flipping bits of the binary digits in a nested way: whether a bit is flipped depends on all higher bits. That keeps the point set a valid net, so stratification survives. A hash-based version computes the nested flips with a few integer operations: reverse the bits, apply a hash-like mixing step that only lets higher bits influence lower ones, reverse again. No random permutation tables are needed.
A renderer draws the Sobol index from the sample number and the dimension, applies a per-pixel and per-dimension seed to the scramble, and converts the 32-bit result to a float. Dimensions can be padded so that decorrelated dimensions do not alias. Because the construction is a pure function of (index, seed), it runs on GPUs and supports progressive rendering without state.
When to choose it
Reach for it when
- want faster convergence with few samples per pixel
- sampling pattern shows structured artifacts across pixels
- need a random sampler that works well on gpu without tables
- noise in path tracer is clumpy at low sample counts
Choose it as the default sampler for a path tracer, or for any renderer integrating smooth functions such as direct lighting and ambient occlusion with a few dozen samples per pixel.
Prefer Blue-noise error distribution sampler at one to eight samples per pixel for real-time work, where distributing error as blue noise matters more than convergence rate. Prefer plain pseudo-random or PCG hashes when the integrand is discontinuous and QMC gives little benefit. Prefer Poisson Disk Sampling (Bridson) for placement of objects rather than integration samples. Used with Next-event estimation (direct light sampling) it improves light and BSDF sampling.
Field marks
- Correlated dimensions: reusing the same scramble seed across dimensions gives visible patterns
- Ordering of dimensions matters; assigning low dimensions to low-impact decisions wastes the best stratification
- Convergence gain vanishes for high-dimensional paths because stratification degrades past a few dimensions
- Sample counts that are not powers of two lose the net property and some stratification
- Float conversion of 32-bit integers loses the lowest bits and can create bias if not done carefully
- Progressive rendering must use consistent indexes across frames or scrambles restart and reintroduce noise
Presets
Owen-Scrambled Sobol QMC — clumpy white-noise RNG (left) vs stratified Owen-Sobol sequence (right)
{
"P_SAMPLES": 32,
"P_SCRAMBLE_SEED": 3,
"P_PLOT_RATIO": 0.44,
"P_SPLIT": 0.5
}Show GLSL (162 lines)
const float P_SAMPLES = 32.0; // P Sample Count [8.0, 64.0, 4.0]
const float P_SCRAMBLE_SEED = 3.0; // P Owen Scramble [1.0, 12.0, 1.0]
const float P_PLOT_RATIO = 0.44; // P Scatter Height [0.25, 0.65, 0.02]
const float P_SPLIT = 0.50; // P White / Sobol Split [0.0, 1.0, 0.02]
// 32-bit bit reversal + Laine-Karras hash for authentic Owen scrambling in WebGL2 & GL 3.30
uint bitRev32(uint x) {
x = ((x & 0x55555555u) << 1u) | ((x & 0xAAAAAAAAu) >> 1u);
x = ((x & 0x33333333u) << 2u) | ((x & 0xCCCCCCCCu) >> 2u);
x = ((x & 0x0F0F0F0Fu) << 4u) | ((x & 0xF0F0F0F0u) >> 4u);
x = ((x & 0x00FF00FFu) << 8u) | ((x & 0xFF00FF00u) >> 8u);
return (x << 16u) | (x >> 16u);
}
uint lkHash(uint x, uint seed) {
x += seed;
x ^= x * 0x6c50b47cu;
x ^= x * 0xb82f1e52u;
x ^= x * 0xc7afe638u;
x ^= x * 0x8d22f6e6u;
return x;
}
uint owenScramble(uint x, uint seed) {
return bitRev32(lkHash(bitRev32(x), seed));
}
// 2D Sobol sequence (dim 0: van der Corput, dim 1: Sobol direction numbers via bit ops)
vec2 owenSobol2D(uint idx, uint seed) {
uint x = bitRev32(idx);
uint y = 0u;
uint n = idx;
uint dir = 0x80000000u;
for (int b = 0; b < 16; b++) {
if ((n & 1u) != 0u) y ^= dir;
n >>= 1u;
dir ^= (dir >> 1u);
}
uint sx = owenScramble(x, seed * 0x9e3779b9u + 0x243f6a88u);
uint sy = owenScramble(y, seed * 0x85ebca6bu + 0xb7e15162u);
return vec2(float(sx >> 8u), float(sy >> 8u)) * (1.0 / 16777216.0);
}
vec2 whiteNoise2D(uint idx, uint seed) {
uint h1 = lkHash(idx * 374761393u + seed * 668265263u, 0x1b873593u);
uint h2 = lkHash(idx * 1274126177u + seed * 2246822519u, 0x85ebca77u);
return vec2(float(h1 >> 8u), float(h2 >> 8u)) * (1.0 / 16777216.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 uv01 = fragCoord / max(iResolution.xy, vec2(1.0));
float split = clamp(P_SPLIT, 0.0, 1.0);
float plotH = clamp(P_PLOT_RATIO, 0.22, 0.68);
int nSamp = int(clamp(floor(P_SAMPLES + 0.5), 8.0, 64.0));
uint baseSeed = uint(clamp(floor(P_SCRAMBLE_SEED + 0.5), 1.0, 20.0)) + uint(floor(iTime * 0.6));
bool isSobol = uv01.x >= split;
vec3 col = vec3(0.03, 0.045, 0.072);
if (uv01.y > plotH) {
// Top viewport: real-time Monte Carlo soft-shadow integration on a lit sphere & floor
vec2 pUV = vec2((uv01.x - 0.5) * (iResolution.x / max(iResolution.y, 1.0)), (uv01.y - (plotH + 1.0) * 0.5) / max(1.0 - plotH, 0.15) * 0.62);
vec3 ro = vec3(0.0, 0.42, 2.35);
vec3 rd = normalize(vec3(pUV, -1.65));
// Analytic sphere (center (0, 0.12, 0), R = 0.44) + floor plane (y = -0.32)
vec3 sphC = vec3(0.0, 0.12, 0.0);
float sphR = 0.44;
vec3 oc = ro - sphC;
float b = dot(oc, rd);
float c = dot(oc, oc) - sphR * sphR;
float disc = b * b - c;
float tSph = (disc > 0.0) ? (-b - sqrt(disc)) : 1e5;
float tFlr = (rd.y < -0.001) ? ((-0.32 - ro.y) / rd.y) : 1e5;
float tHit = min(tSph, tFlr);
col = mix(vec3(0.05, 0.07, 0.11), vec3(0.14, 0.19, 0.28), smoothstep(-0.2, 0.45, pUV.y));
if (tHit < 12.0) {
vec3 p = ro + rd * tHit;
bool hitSph = (tSph < tFlr);
vec3 n = hitSph ? normalize(p - sphC) : vec3(0.0, 1.0, 0.0);
vec3 alb = hitSph ? vec3(0.84, 0.78, 0.70) : mix(vec3(0.24, 0.28, 0.36), vec3(0.38, 0.42, 0.50), mod(floor(p.x * 2.5) + floor(p.z * 2.5), 2.0));
// Per-pixel Owen seed so noise decorrelates cleanly into blue-like screen-space error
uvec2 pix = uvec2(fragCoord);
uint pixSeed = lkHash(pix.x + pix.y * 4099u, baseSeed);
// Integrate 16-sample disk area light shadow using White Noise (left) vs Owen-Sobol (right)
vec3 lCenter = vec3(0.75 * cos(iTime * 0.45), 1.65, 0.65);
float lRad = 0.58;
float litSum = 0.0;
int mcN = min(nSamp, 16);
for (int i = 0; i < 16; i++) {
if (i >= mcN) break;
vec2 u = isSobol ? owenSobol2D(uint(i), pixSeed) : whiteNoise2D(uint(i), pixSeed);
float rD = sqrt(max(u.x, 0.0)) * lRad;
float phi = u.y * 6.2831853;
vec3 lPt = lCenter + vec3(cos(phi) * rD, 0.0, sin(phi) * rD);
vec3 lDir = normalize(lPt - p);
float ndl = max(dot(n, lDir), 0.0);
// Check analytic shadow ray against sphere
float vis = 1.0;
if (!hitSph) {
vec3 sOc = p + n * 0.002 - sphC;
float sb = dot(sOc, lDir);
float sc = dot(sOc, sOc) - sphR * sphR;
if (sb < 0.0 && (sb * sb - sc) > 0.0) vis = 0.0;
}
litSum += ndl * vis;
}
float direct = litSum / float(mcN);
col = alb * (0.18 + 1.35 * direct);
}
} else {
// Bottom panel: 2D unit-square point distribution comparison (8x8 strata grid)
float margin = 0.04;
float panelX = isSobol ? ((uv01.x - split) / max(1.0 - split, 0.1)) : (uv01.x / max(split, 0.1));
float panelY = uv01.y / max(plotH, 0.1);
vec2 boxUV = (vec2(panelX, panelY) - 0.5) * vec2(1.45, 1.20) + 0.5;
col = vec3(0.025, 0.036, 0.058);
if (boxUV.x >= 0.0 && boxUV.x <= 1.0 && boxUV.y >= 0.0 && boxUV.y <= 1.0) {
col = vec3(0.042, 0.060, 0.095);
// 4x4 elementary strata grid showing Owen-Sobol hits every stratum cleanly
vec2 g = abs(fract(boxUV * 4.0 - 0.5) - 0.5);
col += vec3(0.05, 0.08, 0.14) * smoothstep(0.03, 0.008, min(g.x, g.y));
float minD = 1e5;
float secondD = 1e5;
for (int i = 0; i < 64; i++) {
if (i >= nSamp) break;
vec2 pt = isSobol ? owenSobol2D(uint(i), baseSeed) : whiteNoise2D(uint(i), baseSeed);
float d = length(boxUV - pt);
if (d < minD) { secondD = minD; minD = d; }
else if (d < secondD) { secondD = d; }
}
// Voronoi distance tint highlights empty voids & clumping in white noise vs uniform Sobol
float voidWarn = smoothstep(0.11, 0.24, minD);
if (!isSobol) col = mix(col, vec3(0.45, 0.12, 0.10), voidWarn * 0.55);
else col = mix(col, vec3(0.06, 0.24, 0.30), (1.0 - voidWarn) * 0.35);
float dotCore = smoothstep(0.026, 0.012, minD);
vec3 dotCol = isSobol ? vec3(0.18, 0.94, 0.96) : vec3(1.0, 0.62, 0.24);
col = mix(col, dotCol, dotCore);
// Frame border
float bdr = min(min(boxUV.x, 1.0 - boxUV.x), min(boxUV.y, 1.0 - boxUV.y));
col = mix(col, vec3(0.45, 0.62, 0.82), smoothstep(0.012, 0.003, bdr));
}
}
// Horizontal panel divider & vertical split line
col = mix(col, vec3(0.42, 0.56, 0.74), smoothstep(0.005, 0.001, abs(uv01.y - plotH)));
col = mix(col, vec3(0.95, 0.97, 1.0), smoothstep(0.0035, 0.0008, abs(uv01.x - split)));
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| owen-scrambled-sobol-sampling-live | Tesla T4 1920x1080 | 22.9× baseline (heavy) · 0.710 ms / 0.730 ms | opengl-timer-query · 36 frames · GPU Weight Atlas · Colab T4 sweep |
| owen-scrambled-sobol-sampling-live | NVIDIA L4 1920x1080 | 20.6× baseline (heavy) · 0.328 ms / 0.334 ms · 2.2× faster on L4 | opengl-timer-query · Cross-architecture validation |
| owen-scrambled-sobol-sampling-live | NVIDIA A100-SXM4-40GB 1920x1080 | 14.7× baseline (moderate) · 0.423 ms / 0.434 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Owen-scrambled Sobol hemisphere sampling for blotch-free irradiance caches: Replacing stratified jittered hemisphere grids in Ward-style irradiance caching with hash-based Owen-scrambled Sobol sequences cuts per-cache-point ray counts by 2-4x while eliminating correlated low-frequency GI blotches.
- Next-event estimation (direct light sampling): The sampler supplies the 2D points that select a light and a point on it at every path vertex.
- Blue-noise error distribution sampler: An Owen-scrambled Sobol point set can be re-ranked per pixel to land error in blue noise, trading convergence for screen-space quality.
- Multiple Importance Sampling: Both strategies in an MIS estimator draw their points from the same scrambled sequence dimensions.
Sources
- primaryBrent Burley. Practical Hash-based Owen Scrambling. JCGT 2020.Verified via live page · 2026-11-29
- tutorialMatt Pharr, Wenzel Jakob, Greg Humphreys. Sobol Samplers. Physically Based Rendering 4th ed..Verified via live page · 2026-11-29
- implementationmmp (2017). mmp/pbrt-v4. Source code to pbrt, the ray tracer described in the forthcoming 4th edition of the "Physically Based Rendering: From Theory to Implementation" book.GitHub API · license Apache-2.0 · 2026-11-29