LEADR mapping
Linear, Efficient, Antialiased Displacement and Reflectance mapping: pre-filters displaced surfaces with a linear mip-mappable representation so that shading under minification reproduces the average of the detailed surface's BRDF.
In the family Materials, BRDFs & texturing, specular antialiasing
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 | |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Displaced geometry or bump detail below pixel size should not be sampled; it should be folded into the BRDF. Dupuy et al. express the distribution of slopes of the displaced surface as a Beckmann-like lobe, whose first and second moments (mean slope, covariance of slope) are linear and so can be averaged in a mip pyramid. Moments of the height-field's slope are stored; at runtime the filtered moments rebuild a Gaussian slope distribution of the surface, convolved with the base roughness and fed into the shading model, and also used for tracing the displacement via ray marching on the filtered pyramid. The key advantage over Toksvig is that anisotropy and non-zero mean slope are retained, so a groove pattern remains anisotropic when minified.
When to choose it
Reach for it when
- normal map shimmers or aliases at distance
- fine bump detail disappears or sparkles when minified
- specular highlights flicker on tiny surface detail
- filter roughness for displaced geometry properly
Choose it for displacement-mapped or heavily bumped surfaces viewed over a wide range of scales (ocean waves, rock, rough metal) where specular detail must stay stable and plausible. Prefer Toksvig normal-map filtering as the simpler, isotropic baseline. Prefer Normal distribution filtering for specular antialiasing for runtime-derived filtering without per-texture moment pyramids.
Field marks
- Requires precomputed moment mip chains with 2-3 extra channels per displacement texture
- Gaussian slope model fails for multi-modal slope distributions like two facing facets
- Tracing displacement inherits the artifacts of heightfield ray marching
- Not implemented in mainstream engines, so use means custom pipeline
Presets
LEADR Mapping — point-sampled displaced surface aliasing (left) vs linear prefiltered slope-moment anisotropic BRDF (right)
{
"P_GROOVE_FREQ": 24,
"P_SLOPE_AMP": 0.72,
"P_BASE_ROUGH": 0.14,
"P_SPLIT": 0.48
}Show GLSL (154 lines)
const float P_GROOVE_FREQ = 24.0; // P Groove Frequency [8.0, 48.0, 2.0]
const float P_SLOPE_AMP = 0.72; // P Displacement Slope [0.15, 1.2, 0.05]
const float P_BASE_ROUGH = 0.14; // P Base Roughness [0.06, 0.45, 0.02]
const float P_SPLIT = 0.48; // P Point / LEADR Split [0.0, 1.0, 0.02]
vec3 evalEnv(vec3 d) {
vec3 sky = mix(vec3(0.06, 0.09, 0.14), vec3(0.26, 0.42, 0.66), smoothstep(-0.15, 0.75, d.y));
vec3 l1 = normalize(vec3(0.55, 0.48, -0.68));
vec3 l2 = normalize(vec3(-0.62, 0.36, -0.58));
float s1 = pow(max(dot(d, l1), 0.0), 48.0);
float s2 = pow(max(dot(d, l2), 0.0), 24.0);
return sky + vec3(2.8, 2.3, 1.7) * s1 + vec3(0.65, 1.25, 1.95) * s2;
}
// Analytical 2D anisotropic brushed + chevron micro-displacement height gradient
vec2 evalSlope(vec2 uv, float freq, float amp) {
float a = uv.x * freq;
float b = uv.y * freq * 0.25 + sin(uv.x * freq * 0.12) * 1.4;
float gx = cos(a) * amp + 0.35 * cos(a * 2.13 + 0.8) * amp;
float gy = 0.28 * cos(b) * amp;
return vec2(gx, gy);
}
// Evaluate Gaussian anisotropic slope-distribution NDF from LEADR moments (Dupuy et al. 2013)
float evalLEADR_NDF(vec2 hSlope, vec2 meanSlope, vec3 cov, float baseVar) {
vec2 d = hSlope - meanSlope;
float sxx = max(cov.x + baseVar, 1e-4);
float syy = max(cov.y + baseVar, 1e-4);
float sxy = clamp(cov.z, -0.95 * sqrt(sxx * syy), 0.95 * sqrt(sxx * syy));
float det = max(sxx * syy - sxy * sxy, 1e-6);
float invDet = 1.0 / det;
float quad = (syy * d.x * d.x - 2.0 * sxy * d.x * d.y + sxx * d.y * d.y) * invDet;
return exp(-0.5 * min(quad, 40.0)) / (6.2831853 * sqrt(det));
}
float beckmannLambda(float a) {
if (a >= 1.6) return 0.0;
return (1.0 - 1.259 * a + 0.396 * a * a) / max(3.535 * a + 2.181 * a * a, 1e-4);
}
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;
float sx = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
bool useLEADR = sx >= split;
float freq = clamp(P_GROOVE_FREQ, 4.0, 64.0);
float amp = clamp(P_SLOPE_AMP, 0.05, 1.5);
float baseRough = clamp(P_BASE_ROUGH, 0.04, 0.6);
float baseVar = 0.5 * baseRough * baseRough;
vec3 ro = vec3(0.0, 0.62, 1.85);
vec3 rd = normalize(vec3(uv.x, uv.y - 0.16, -1.42));
vec3 col = evalEnv(rd) * 0.45;
// Intersect receding grooved brass plane (y = -0.35) and a grooved hero sphere
vec3 sphC = vec3(0.0, 0.18, -0.55);
float sphR = 0.52;
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)) > 0.05) ? (-b - sqrt(disc)) : 1e5;
float tPl = (rd.y < -0.005) ? ((-0.35 - ro.y) / rd.y) : 1e5;
if (tPl < 0.05 || tPl > 45.0) tPl = 1e5;
float tHit = min(tSph, tPl);
if (tHit < 1e4) {
vec3 p = ro + rd * tHit;
vec3 nG;
vec3 T, B;
vec2 muv;
float footprint;
if (tSph < tPl) {
nG = normalize(p - sphC);
float phi = atan(nG.z, nG.x) + iTime * 0.18;
float th = acos(clamp(nG.y, -1.0, 1.0));
muv = vec2(phi * 1.15, th * 1.15);
T = normalize(vec3(-sin(phi), 0.0, cos(phi)));
B = cross(nG, T);
footprint = (tHit / max(iResolution.y, 1.0)) * 2.2 / max(abs(dot(nG, -rd)), 0.12);
} else {
nG = vec3(0.0, 1.0, 0.0);
T = vec3(1.0, 0.0, 0.0);
B = vec3(0.0, 0.0, 1.0);
muv = p.xz + vec2(0.0, -iTime * 0.25);
footprint = (tHit / max(iResolution.y, 1.0)) * 2.8 / max(abs(rd.y), 0.04);
}
vec3 v = -rd;
vec3 l1 = normalize(vec3(0.55 * cos(iTime * 0.35), 0.52, -0.65));
vec3 l2 = normalize(vec3(-0.62, 0.42, -0.52));
vec3 f0 = (tSph < tPl) ? vec3(0.95, 0.74, 0.36) : vec3(0.76, 0.78, 0.82);
// Filter strength grows linearly with footprint * frequency (mip level of LEADR moments!)
float filterK = clamp(footprint * freq * 0.48, 0.0, 1.0);
float envMip = smoothstep(0.0, 1.0, filterK);
// Instantaneous slope at pixel center
vec2 rawSlope = evalSlope(muv, freq, amp);
// LEADR linear moments: E[s] attenuates as footprint spans cycles, while covariance E[s*s^T] - E[s]E[s]^T absorbs the variance!
float atten = exp(-2.4 * filterK * filterK);
vec2 meanSlope = useLEADR ? (rawSlope * atten) : rawSlope;
// Exact variance of cos(a) + 0.35*cos(2.13a) is 0.5*(1 + 0.35^2)*amp^2 = 0.561*amp^2 along X, 0.039*amp^2 along Y
float varX = useLEADR ? (0.561 * amp * amp * (1.0 - atten * atten)) : 0.0;
float varY = useLEADR ? (0.039 * amp * amp * (1.0 - atten * atten)) : 0.0;
vec3 cov = vec3(varX, varY, 0.0);
vec3 acc = vec3(0.0);
for (int li = 0; li < 2; li++) {
vec3 L = (li == 0) ? l1 : l2;
vec3 lCol = (li == 0) ? vec3(2.8, 2.35, 1.75) : vec3(0.75, 1.25, 1.95);
float ndl = max(dot(nG, L), 0.0);
float ndv = max(dot(nG, v), 0.005);
if (ndl > 0.002) {
vec3 H = normalize(L + v);
float hN = max(dot(H, nG), 0.005);
vec2 hSlope = vec2(-dot(H, T) / hN, -dot(H, B) / hN);
float D = evalLEADR_NDF(hSlope, meanSlope, cov, baseVar) / pow(hN, 4.0);
// Anisotropic Smith masking-shadowing along projected slope variance
float sigV = sqrt(max(baseVar + varX * dot(v, T) * dot(v, T) + varY * dot(v, B) * dot(v, B), 1e-4));
float sigL = sqrt(max(baseVar + varX * dot(L, T) * dot(L, T) + varY * dot(L, B) * dot(L, B), 1e-4));
float tanV = sqrt(max(1.0 - ndv * ndv, 0.0)) / ndv;
float tanL = sqrt(max(1.0 - ndl * ndl, 0.0)) / ndl;
float G = 1.0 / (1.0 + beckmannLambda(1.0 / max(1.414 * sigV * tanV, 1e-4)) + beckmannLambda(1.0 / max(1.414 * sigL * tanL, 1e-4)));
float vdh = max(dot(v, H), 0.005);
vec3 F = f0 + (1.0 - f0) * pow(1.0 - vdh, 5.0);
acc += lCol * F * (D * G / max(4.0 * ndv, 0.04));
}
}
// Filtered ambient reflection using mean normal + effective roughness
vec3 effN = normalize(nG - T * meanSlope.x - B * meanSlope.y);
vec3 rDir = reflect(-v, effN);
float effRough = clamp(sqrt(baseVar + 0.5 * (varX + varY)), 0.05, 0.85);
vec3 envAmb = mix(evalEnv(rDir), evalEnv(nG) * 0.72, effRough);
vec3 Fv = f0 + (1.0 - f0) * pow(1.0 - max(dot(effN, v), 0.0), 5.0);
col = acc + envAmb * Fv * (0.48 + 0.25 * (1.0 - envMip));
if (tPl < tSph) {
col = mix(col, evalEnv(rd) * 0.45, 1.0 - exp(-tPl * 0.075));
}
}
float sep = smoothstep(0.0035, 0.0008, abs(sx - split));
col = mix(col, vec3(0.95, 0.97, 1.0), sep);
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 |
|---|---|---|---|
| leadr-mapping-live | Tesla T4 1920x1080 | 6.54× baseline (moderate) · 0.215 ms / 0.222 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| leadr-mapping-live | NVIDIA L4 1920x1080 | 5.97× baseline (light) · 0.095 ms / 0.095 ms · 2.3× faster on L4 | opengl-timer-query · Cross-architecture validation |
| leadr-mapping-live | NVIDIA A100-SXM4-40GB 1920x1080 | 4.35× baseline (light) · 0.125 ms / 0.126 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Cook-Torrance microfacet BRDF, Oren-Nayar rough diffuse, Spherical-Harmonic Lighting (Irradiance Environment Maps); cited by Normal distribution filtering for specular antialiasing.
Crosses
- Neural materials that filter like EWA: Neural-compressed materials that stay correct at grazing angles. The decoder emits linear slope moments, a few decodes along the pixel footprint's long axis are averaged, and the leftover footprint becomes anisotropic roughness instead of shimmer or blur.
- Sun glitter from horizon to bow: An ocean that sparkles at every distance. Waves too small to see fold into a correctly stretched specular lobe, and the same filtered slope distribution drives discrete glints, so distant water glitters instead of turning into a flat smear.
Sources
- primaryJonathan Dupuy, Eric Heitz, Jean-Claude Iehl, Pierre Poulin, Fabrice Neyret, Victor Ostromoukhov (2013). Linear efficient antialiased displacement and reflectance mapping. ACM Transactions on Graphics.Verified via crossref · 2026-11-29doi:10.1145/2508363.2508422