---
id: "smith-masking-shadowing"
title: "Smith masking-shadowing function"
domain: "materials"
stage: "material"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot, blender]
year_introduced: 2014
inputs: [material-params, normals]
outputs: [radiance]
style: "photoreal"
dynamic: "both"
cost: "cheap"
authority: "Heitz"
url: "https://texelatlas.vercel.app/t/smith-masking-shadowing/"
sources_verified_at: "2026-11-29"
---
# Smith masking-shadowing function (Heitz)

> 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.

## 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

## 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 use it

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](https://texelatlas.vercel.app/t/kulla-conty-multiscatter.md).

## Cost

cheap — Two sqrt-and-divide evaluations, or an approximation of Lambda; commonly merged into the visibility term.
Measured GPU Weight: 1.62× baseline (feather) — 0.0533 ms median / 0.0587 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 1.31× baseline (feather) — 0.0208 ms median (2.56× faster on L4).
Ampere A100 scaling: 1.05× baseline (feather) — 0.0302 ms median (1.76× faster on A100).

## Failure modes

- 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

## Engine support

- babylonjs: builtin — `pbrMaterial.brdf.useSmithVisibilityHeightCorrelated = true` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/Materials/PBR/pbrBRDFConfiguration.ts, checked 2026-12-01)
- blender: builtin — `Cycles Principled / Glossy GGX microfacet closures evaluate Smith masking-shadowing in intern/cycles/kernel/closure/bsdf_microfacet.h` (evidence: https://github.com/blender/blender/blob/main/intern/cycles/kernel/closure/bsdf_microfacet.h, checked 2026-12-01)
- godot: builtin — `BaseMaterial3D SPECULAR_SCHLICK_GGX evaluates height-correlated Smith visibility (V_GGX / V_GGX_anisotropic)` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl, checked 2026-12-01)
- threejs: builtin — `MeshStandardMaterial / MeshPhysicalMaterial` (evidence: https://github.com/mrdoob/three.js/blob/r187/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js, checked 2026-12-01) — Height-correlated Smith visibility.
- unity: builtin — `Lit shaders in URP and HDRP` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.core/ShaderLibrary/BSDF.hlsl, checked 2026-12-01) — HDRP uses height-correlated Smith joint GGX.

## Dataflow

- Inputs: material-params, normals
- Outputs: radiance
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot, blender

## Presets

### GGX specular without (left) vs with (right) Smith masking-shadowing (glsl-fragment; rendered 2026-11-29)

```json
{
  "ROUGH": 0.45
}
```

```glsl
// 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

## Lineage

- extends [GGX / Trowbridge-Reitz normal distribution](https://texelatlas.vercel.app/t/ggx-trowbridge-reitz.md)
- extended by [Visible normal distribution sampling (GGX VNDF)](https://texelatlas.vercel.app/t/vndf-sampling.md)

## Sources

1. [primary] Eric Heitz Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs. JCGT 2014. https://jcgt.org/published/0003/02/03 (verified via http on 2026-11-29)

## Cite this entry

Texel. "Smith masking-shadowing function." https://texelatlas.vercel.app/t/smith-masking-shadowing/ (accessed 2026-12-01).
