Random-access neural texture compression × LEADR mapping × Anisotropic GGX
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.
Open in StudioReproduced5.35× · 0.166 ms
Verified proof

Split-screen WebGL2 proof comparing naive single-tap point-sampled high-frequency brushed herringbone metal receding to the horizon (left, breaking into severe moire aliasing and sparkling grazing-angle noise) against EWA footprint-filtered neural latent decoding carrying LEADR 5-moment slope covariance directly into anisotropic GGX roughness for smooth, energy-conserving grazing highlights (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · eliminates grazing-angle herringbone moire and preserves directional anisotropic sheen across 3 distance decades via EWA-filtered LEADR moments
Show GLSL proof (139 lines)
const float P_GROOVE_FREQ = 28.0; // P Micro-Groove Freq [12.0, 48.0, 2.0]
const float P_ANISO_RATIO = 0.82; // P Groove Anisotropy [0.1, 1.0, 0.05]
const float P_BASE_ROUGH = 0.14; // P Base Roughness [0.04, 0.45, 0.02]
const float P_LIGHT_SWING = 0.80; // P Grazing Light Sweep [0.0, 1.6, 0.05]
// Procedural woven-twill + brushed herringbone micro-height field (analogous to decoded NTC channels)
// Returns (albedoTint, dH/du, dH/dv, intrinsicVarianceU, intrinsicVarianceV)
void evalMicroMaterial(vec2 uv, float filterScale, out vec3 albedo, out vec2 meanSlope, out vec2 slopeVar, out vec2 tangentDir) {
// Herringbone twill blocks alternate groove direction +45 / -45 deg
float strip = floor(uv.x * 2.2);
float odd = mod(strip, 2.0);
float ang = (odd < 0.5) ? 0.65 : -0.65;
float c = cos(ang), s = sin(ang);
tangentDir = vec2(c, s);
vec2 rotUV = vec2(c * uv.x + s * uv.y, -s * uv.x + c * uv.y);
float k = P_GROOVE_FREQ;
// Attenuation factor for resolved frequency vs sub-footprint unresolved energy
float resolved = exp(-pow(filterScale * k * 0.42, 2.0));
float unresolved = 1.0 - resolved;
float ph1 = rotUV.y * k * 6.2831853;
float ph2 = rotUV.x * k * 0.35 * 6.2831853;
float amp = 0.24 * P_ANISO_RATIO;
// Resolved slope gradient along cross-groove (rotUV.y) and along-groove (rotUV.x)
float dPerp = amp * cos(ph1) * resolved;
float dPara = amp * 0.16 * cos(ph2) * resolved;
// Rotate slope back to world UV
meanSlope = vec2(c * dPara - s * dPerp, s * dPara + c * dPerp);
// LEADR second moments: energy lost by prefiltering moves cleanly into directional slope variance!
float varPerp = 0.5 * amp * amp * unresolved * 1.85;
float varPara = 0.5 * (amp * 0.16) * (amp * 0.16) * unresolved * 1.4;
slopeVar = vec2(varPara, varPerp);
// Subtle metallic bronze vs slate-titanium herringbone stripe contrast
float weaveShade = 0.5 + 0.5 * sin(ph1) * resolved;
vec3 cA = vec3(0.66, 0.46, 0.28);
vec3 cB = vec3(0.42, 0.46, 0.52);
albedo = mix(cA, cB, odd) * (0.82 + 0.18 * weaveShade);
}
// Anisotropic GGX NDF with orthogonal tangent/bitangent roughness (ax, ay)
float D_GGX_Aniso(vec3 N, vec3 T, vec3 B, vec3 H, float ax, float ay) {
float ndh = max(dot(N, H), 1e-4);
float tdh = dot(T, H);
float bdh = dot(B, H);
float a2 = ax * ay;
vec3 v = vec3(ay * tdh, ax * bdh, a2 * ndh);
float v2 = dot(v, v);
float w2 = a2 / max(v2, 1e-6);
return a2 * w2 * w2 / 3.14159265;
}
vec3 acesTone(vec3 x) {
return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
bool useEWA = uv.x > 0.0;
vec2 suv = vec2(useEWA ? (uv.x - 0.25) : (uv.x + 0.25), uv.y);
suv.x *= 1.80;
// Grazing perspective camera hovering over infinite machined plane
vec3 ro = vec3(0.0, 0.55, -iTime * 0.35);
vec3 rd = normalize(vec3(suv.x * 0.85, suv.y - 0.22, 1.42));
vec3 L = normalize(vec3(0.42 * sin(iTime * 0.7 * P_LIGHT_SWING), 0.36, 0.88));
vec3 sky = mix(vec3(0.05, 0.07, 0.11), vec3(0.18, 0.24, 0.36), clamp(rd.y * 2.2 + 0.2, 0.0, 1.0));
sky += vec3(1.2, 0.86, 0.52) * pow(max(dot(rd, L), 0.0), 42.0) * 1.4;
vec3 col = sky;
if (rd.y < -0.005) {
float tHit = -ro.y / rd.y;
if (tHit < 45.0) {
vec3 pos = ro + rd * tHit;
vec2 matUV = pos.xz * 0.85;
// Estimate anisotropic EWA footprint scale from perspective depth & grazing angle
float minorFoot = tHit / max(iResolution.y, 1.0) * 1.35;
float majorFoot = minorFoot / max(-rd.y, 0.04);
vec3 alb = vec3(0.0);
vec2 slope = vec2(0.0);
vec2 sVar = vec2(0.0);
vec2 tDir = vec2(1.0, 0.0);
if (!useEWA) {
// Left: naive point-sampled single decode (filterScale = 0 -> severe aliasing & moire collapse)
evalMicroMaterial(matUV, 0.0, alb, slope, sVar, tDir);
} else {
// Right: 4-tap EWA anisotropic probe along major ellipse axis + LEADR moment aggregation
vec2 majorStep = normalize(rd.xz + vec2(1e-4)) * min(majorFoot * 0.32, 0.16);
vec2 avgSlope = vec2(0.0);
vec2 avgSqSlope = vec2(0.0);
for (int i = 0; i < 4; i++) {
float o = (float(i) - 1.5) * 0.5;
vec3 aT; vec2 slT; vec2 svT; vec2 tdT;
evalMicroMaterial(matUV + majorStep * o, minorFoot * 1.8, aT, slT, svT, tdT);
alb += aT * 0.25;
avgSlope += slT * 0.25;
avgSqSlope += slT * slT * 0.25;
sVar += svT * 0.25;
if (i == 1) tDir = tdT;
}
// Add cross-tap slope variance (second moment - mean^2) directly into LEADR variance
vec2 crossVar = max(avgSqSlope - avgSlope * avgSlope, vec2(0.0));
slope = avgSlope;
sVar += vec2(crossVar.x + crossVar.y) * 0.65;
}
vec3 N = normalize(vec3(-slope.x, 1.0, -slope.y));
vec3 T = normalize(vec3(tDir.x, 0.0, tDir.y) - N * dot(N, vec3(tDir.x, 0.0, tDir.y)));
vec3 B = cross(N, T);
vec3 V = -rd;
vec3 H = normalize(L + V);
float ndl = max(dot(N, L), 0.0);
float ndv = max(dot(N, V), 0.02);
vec3 F0 = mix(vec3(0.04), alb, 0.85);
vec3 F = F0 + (1.0 - F0) * pow(1.0 - max(dot(H, V), 0.0), 5.0);
float ax = clamp(sqrt(P_BASE_ROUGH * P_BASE_ROUGH + (useEWA ? sVar.x * 1.6 : 0.0)), 0.04, 0.92);
float ay = clamp(sqrt(P_BASE_ROUGH * P_BASE_ROUGH + (useEWA ? sVar.y * 2.4 : 0.0)), 0.04, 0.92);
float D = D_GGX_Aniso(N, T, B, H, ax, ay);
float G = 1.0 / (1.0 + 0.35 / max(ndv, 0.06));
vec3 spec = F * D * G * vec3(2.4, 2.05, 1.62) * 0.32;
vec3 diff = alb * 0.18 * (0.30 + 0.70 * ndl);
vec3 envRefl = mix(vec3(0.10, 0.14, 0.22), vec3(0.55, 0.62, 0.72), clamp(reflect(rd, N).y * 1.4 + 0.2, 0.0, 1.0)) * F * (1.0 - 0.55 * ay);
col = diff + spec + envRefl;
float fog = 1.0 - exp(-tHit * 0.055);
col = mix(col, sky, clamp(fog, 0.0, 0.92));
}
}
col = acesTone(col);
if (abs(uv.x) < 0.003) col = vec3(0.95, 0.93, 0.89);
fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Why they connect
Random-access neural texture compression normally decodes albedo, normal and roughness per texel, and its decode-then-filter design sidesteps hardware anisotropic filtering. Here it also decodes a texture of LEADR slope moments (mean slope and second moments), which are linear and safe to average. LEADR mapping takes those moments as its texture input: K decodes along the major axis of the screen-space footprint ellipse are averaged, the footprint's own covariance is added, and the result is a filtered slope distribution. Its material-params output (two roughnesses and an angle) feeds Anisotropic GGX, which shades the stretched highlight that grooved or brushed detail should produce when minified.
How to build it
Offline, extend an NTC trainer (PyTorch) so the material stack includes five LEADR moment channels computed from the height or normal map, with quantisation-aware training as usual. At runtime (D3D12 or Vulkan with cooperative-matrix inference), compute UV derivatives, form the footprint ellipse, choose the latent level from the minor axis, and place two to four decoder taps along the major axis, like hardware anisotropic probes. Average decoded albedo and moments, convert moments to a slope covariance, add base roughness, and rotate into the tangent frame for anisotropic GGX. Compare against a supersampled reference on brushed metal and woven fabric. A stochastic single-tap variant with temporal accumulation is the cheaper fallback.
Field marks
- Each extra decoder tap multiplies the most expensive part of the shader.
- Quantisation error in moment channels can produce negative variance; clamp before building the lobe.
- LEADR's Gaussian slope model does not match GGX tails, so highlight brightness shifts slightly.
- Limited to GPUs with fast small-MLP inference.
Prior art
- Explicit LOD-Conditioned Anisotropic Filtering for Neural Texture Compression. Partial: conditions a neural texture decoder on footprint scale, aspect and orientation and takes taps along the major axis, the same footprint-aware filtering goal; it does not decode slope moments or turn the residual footprint into anisotropic roughness.
- Hardware Accelerated Neural Block Texture Compression with Cooperative Vectors. Partial: keeps neural texture sets in block-compressed formats so hardware anisotropic filtering applies, a different route to filtered neural materials.
- Improved Stochastic Texture Filtering Through Sample Reuse. Uses filtering with neural texture compression for another goal: improves stochastic texture filtering under magnification rather than anisotropic minification.
Searches run (4)
- arXiv: all:"neural texture compression" AND all:"anisotropic filtering" → 2 results
- GitHub repos: "neural texture compression" "anisotropic filtering" → 0 results
- arXiv: all:"neural texture compression" AND all:"texture filtering" → 2 results
- GitHub repos: "neural texture compression" "texture filtering" → 0 results