Smith masking-shadowing function
The statistically grounded geometry term for microfacet BRDFs. Heitz's JCGT analysis shows how to pair Smith's G with the normal distribution, why height-correlated G is the right choice, and where the separable form falls short.
In the family Materials, BRDFs & texturing, microfacet BRDF
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Built in | MeshStandardMaterial / MeshPhysicalMaterial docs Height-correlated Smith visibility. |
| Babylon.js 9.38.0 | Built in | pbrMaterial.brdf.useSmithVisibilityHeightCorrelated = true docs |
| Godot 4.7 | Built in | BaseMaterial3D SPECULAR_SCHLICK_GGX evaluates height-correlated Smith visibility (V_GGX / V_GGX_anisotropic) docs |
| Unity | Built in | Lit shaders in URP and HDRP docs HDRP uses height-correlated Smith joint GGX. |
| Unreal 5.7 | None found | |
| Blender 5.2 | Built in | Cycles Principled / Glossy GGX microfacet closures evaluate Smith masking-shadowing in intern/cycles/kernel/closure/bsdf_microfacet.h docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
A microfacet only contributes if both the incoming and outgoing rays reach it unobstructed. Smith's model derives masking G1(v) from the normal distribution itself via the auxiliary function Lambda, which for GGX has a closed form involving sqrt(1 + a^2 tan^2 theta). The simplest combination multiplies G1(l)*G1(v) (separable, assumes uncorrelated visibility). Heitz showed that the height-correlated form, G2 = 1 / (1 + Lambda(l) + Lambda(v)), is more accurate because rays at similar heights are visible together, and the same paper clarifies the roles of height versus direction correlation. Real-time engines fold G2 and the 1/(4 n.l n.v) denominator into one visibility term V that is cheaper and better behaved. Approximations to Lambda avoid the square roots.
When to choose it
Reach for it when
- specular looks too bright at grazing angles
- which geometry term pairs with ggx
- microfacet highlights lose energy or look wrong when rough
- need a correct shadowing-masking term in a pbr shader
Choose it for the G term of any GGX-based shader; use the height-correlated form unless matching a legacy look. Prefer a simplified Schlick-GGX masking (as in early Unreal) only on very constrained mobile hardware. If bright rough metals look too dark, the missing piece is not G but Kulla-Conty multiple-scattering compensation.
Field marks
- Separable G darkens grazing angles and slightly overestimates energy loss compared with the correlated form
- Fast Lambda approximations (e.g. fused sqrt-free forms) introduce small errors at high roughness
- Smith assumes uncorrelated microfacet heights and normals, so sharply structured surfaces such as scratches and brushed metals deviate from it
- Lost inter-facet bounces make rough conductors darker than reality
Presets
GGX specular without (left) vs with (right) Smith masking-shadowing
{
"ROUGH": 0.45
}Show GLSL (35 lines)
// GGX specular with and without the Smith masking-shadowing term G (roughness 0.45), rim-lit from behind.
// Left: G = 1, specular D*F/(4 NL NV) blows up at grazing angles. Right: height-correlated Smith G.
const float ROUGH = 0.45;
float D_ggx(float nh, float a) { float a2 = a * a; float d = nh * nh * (a2 - 1.0) + 1.0; return a2 / (3.14159 * d * d); }
float G_smith(float nl, float nv, float a) {
float a2 = a * a;
float gv = nl * sqrt((-nv * a2 + nv) * nv + a2), gl = nv * sqrt((-nl * a2 + nl) * nl + a2);
return 2.0 * nl * nv / max(gv + gl, 1e-5);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec3 ro = vec3(0.0, 0.0, 4.0), rd = normalize(vec3(uv, -2.4));
vec3 col = vec3(0.02) + 0.02 * uv.y;
for (int i = 0; i < 2; i++) {
vec3 c = vec3(i == 0 ? -0.5 : 0.5, 0.0, 0.0);
vec3 oc = ro - c; float b = dot(oc, rd); float h = b * b - dot(oc, oc) + 0.46 * 0.46;
if (h < 0.0) continue;
float t = -b - sqrt(h); vec3 n = normalize(ro + rd * t - c); vec3 v = -rd;
vec3 tot = vec3(0.02, 0.03, 0.05);
for (int k = 0; k < 2; k++) {
vec3 l = k == 0 ? normalize(vec3(-0.3, 0.6, -0.75)) : normalize(vec3(0.2, 0.2, 1.0));
float nl = dot(n, l); if (nl <= 0.0) continue;
float nv = max(dot(n, v), 1e-3); vec3 hv = normalize(l + v);
float a = ROUGH * ROUGH; float F = 0.04 + 0.96 * pow(1.0 - max(dot(l, hv), 0.0), 5.0);
float G = i == 0 ? 1.0 : G_smith(nl, nv, a);
float spec = D_ggx(max(dot(n, hv), 0.0), a) * F * G / (4.0 * nl * nv);
tot += (k == 0 ? 2.5 : 1.2) * (spec + vec3(0.06, 0.09, 0.15) / 3.14159) * nl;
}
col = tot;
}
col = col / (1.0 + col);
fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);
}
Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| smith-masking-shadowing-specimen | Tesla T4 1920x1080 | 1.62× baseline (feather) · 0.053 ms / 0.059 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| smith-masking-shadowing-specimen | NVIDIA L4 1920x1080 | 1.31× baseline (feather) · 0.021 ms / 0.021 ms · 2.6× faster on L4 | opengl-timer-query · Cross-architecture validation |
| smith-masking-shadowing-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 1.05× baseline (feather) · 0.030 ms / 0.030 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Sources
- primaryEric Heitz. Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs. JCGT 2014.Verified via live page · 2026-11-29