{
 "id": "marschner-hair-scattering",
 "title": "Marschner hair scattering model",
 "aliases": [
  "Marschner hair BSDF",
  "R TT TRT hair model"
 ],
 "domain": "materials",
 "subdomain": "hair and fur",
 "stage": "material",
 "realtime": "interactive",
 "platforms": [
  "cpu",
  "cuda",
  "blender",
  "houdini",
  "unreal",
  "desktop-gpu"
 ],
 "year_introduced": 2003,
 "inputs": [
  "curves",
  "material-params"
 ],
 "outputs": [
  "radiance"
 ],
 "style": "photoreal",
 "dynamic": "both",
 "summary": "A physically motivated hair fibre model splitting scattering into surface reflection R, transmission TT and internal reflection TRT, each with its own longitudinal and azimuthal term. It explains hair's two highlights and coloured glow.",
 "how_it_works": "Hair is modelled as a smooth dielectric cylinder with a tilted cuticle and an absorbing interior. The scattering function factorises per lobe p into a longitudinal term M_p(theta) and an azimuthal term N_p(phi). R is a mirror-like bounce off the cuticle and stays white. TT is light refracting in and out of the fibre; TRT adds one internal reflection and exits on the same side as the viewer, picking up the colour of the pigment through the absorption coefficient. Longitudinal terms are Gaussians centred at shifts of 2 alpha, -alpha and -4 alpha for the cuticle tilt alpha, with different widths per lobe, which is why the highlights are offset along the strand and differently coloured. The azimuthal terms come from tracing the refracted ray through the circular cross-section with Fresnel weights and attenuation. Modern implementations such as the pbrt formulation add energy-preserving normalisation and importance sampling, and extend the model with ellipse cross-sections or glints.",
 "when_to_use": "Choose it as the reference for path-traced hair in film or look development and as the basis for pre-integrated real-time approximations. Prefer `disney-hair-bsdf` for artist-friendly parameters (melanin, roughness, tint) built on the same lobes. Prefer `kajiya-kay-hair-shading` where shader cost or hair cards dominate. Use `strand-based-real-time-hair` to supply the strand geometry and tangents.",
 "cost": {
  "class": "offline",
  "notes": "Per-sample evaluation is moderate, but the many-fibre geometry and multiple scattering between strands make it an offline or approximated real-time model."
 },
 "failure_modes": [
  "Single-fibre scattering misses inter-fibre multiple scattering, so light hair looks too dark without a dual-scattering or path-traced fix",
  "Azimuthal term evaluated by root solving can have numerical problems near grazing incidence",
  "Unnormalised lobes break energy conservation when roughness changes",
  "Incorrect tangent orientation along the curve flips the highlight order of R and TRT",
  "Noisy highlights at low sample counts since the lobes are very narrow"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/882262.882345",
   "type": "paper",
   "title": "Light scattering from human hair fibers",
   "authors": [
    "Stephen R. Marschner",
    "Henrik Wann Jensen",
    "Mike Cammarano",
    "Steve Worley",
    "Pat Hanrahan"
   ],
   "year": 2003,
   "venue": "ACM Transactions on Graphics",
   "url": "https://doi.org/10.1145/882262.882345",
   "ids": {
    "doi": "10.1145/882262.882345"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/882262.882345",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/882262.882345",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/882262.882345",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/882262.882345",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/882262.882345",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "marschner2003light"
  },
  {
   "role": "secondary",
   "key": "url:https://pbr-book.org/4ed/Reflection_Models/Scattering_from_Hair",
   "type": "web",
   "title": "Scattering from Hair (pbrt-v4)",
   "authors": [
    "Matt Pharr",
    "Wenzel Jakob",
    "Greg Humphreys"
   ],
   "year": null,
   "venue": "pbr-book.org",
   "url": "https://pbr-book.org/4ed/Reflection_Models/Scattering_from_Hair",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20260806014830/https://www.pbr-book.org/4ed/Reflection_Models/Scattering_from_Hair",
     "timestamp": "20260806014830"
    },
    "page_title": "Scattering from Hair",
    "host": "pbr-book.org",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://pbr-book.org/4ed/Reflection_Models/Scattering_from_Hair → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://pbr-book.org/4ed/Reflection_Models/Scattering_from_Hair → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://pbr-book.org/4ed/Reflection_Models/Scattering_from_Hair → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 0.95,
   "__bib": "pharrscattering"
  }
 ],
 "presets": [
  {
   "id": "marschner-hair-scattering-live",
   "title": "Marschner Hair Scattering — single Kajiya-Kay highlight (left) vs physical R + TT + TRT lobes & glints (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_MELANIN": 0.48,
    "P_CUTICLE_SHIFT": 0.11,
    "P_ROUGHNESS": 0.18,
    "P_SPLIT": 0.46
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_MELANIN = 0.48; // P Hair Melanin [0.05, 1.0, 0.02]\nconst float P_CUTICLE_SHIFT = 0.11; // P Cuticle Tilt [0.02, 0.22, 0.01]\nconst float P_ROUGHNESS = 0.18; // P Longitudinal Beta [0.06, 0.42, 0.01]\nconst float P_SPLIT = 0.46; // P Kajiya / Marschner [0.0, 1.0, 0.02]\n\nfloat gauss(float x, float beta) {\n  float b = max(beta, 0.02);\n  return exp(-0.5 * (x * x) / (b * b)) / (2.5066 * b);\n}\n\n// Flowing sculptural lock of curved hair fibers (sweeping ribbon-cylinder SDF)\nfloat mapHairLock(vec3 p) {\n  vec3 q = p;\n  q.x -= 0.18 * sin(q.y * 2.6 + 0.4);\n  q.z -= 0.12 * cos(q.y * 2.2);\n  // Elliptical ribbon bundle tapering slightly at ends\n  float width = 0.56 - 0.16 * q.y * q.y;\n  float d = length(vec2(q.x / max(width, 0.18), q.z / 0.28)) - 1.0;\n  d *= 0.24;\n  // Fine micro-strand grooves running vertically along the tangent\n  float strandPhase = atan(q.z, q.x) * 34.0 + q.x * 28.0;\n  d += 0.008 * sin(strandPhase);\n  return max(d, abs(q.y) - 0.85) * 0.82;\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.0025, 0.0);\n  return normalize(vec3(\n    mapHairLock(p + e.xyy) - mapHairLock(p - e.xyy),\n    mapHairLock(p + e.yxy) - mapHairLock(p - e.yxy),\n    mapHairLock(p + e.yyx) - mapHairLock(p - e.yyx)\n  ));\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  bool isMarschner = screenX >= split;\n  float melanin = clamp(P_MELANIN, 0.04, 1.0);\n  float alphaShift = clamp(P_CUTICLE_SHIFT, 0.01, 0.25);\n  float betaR = clamp(P_ROUGHNESS, 0.05, 0.45);\n\n  vec3 ro = vec3(0.0, 0.0, 2.25);\n  vec3 rd = normalize(vec3(uv, -1.52));\n  vec3 col = mix(vec3(0.022, 0.024, 0.038), vec3(0.062, 0.072, 0.105), smoothstep(-0.55, 0.55, uv.y));\n\n  float t = 0.0;\n  bool hit = false;\n  for (int i = 0; i < 56; i++) {\n    float d = mapHairLock(ro + rd * t);\n    if (d < 0.0025) { hit = true; break; }\n    t += d;\n    if (t > 5.0) break;\n  }\n\n  if (hit) {\n    vec3 p = ro + rd * t;\n    vec3 n = calcNormal(p);\n    // Hair strand tangent follows the S-curve derivative\n    vec3 tang = normalize(vec3(0.18 * 2.6 * cos(p.y * 2.6 + 0.4), 1.0, -0.12 * 2.2 * sin(p.y * 2.2)));\n    // Project tangent orthogonal to macro surface normal for fiber shading\n    tang = normalize(tang - n * dot(tang, n));\n\n    // Animated key light + warm rim backlight to reveal TT transmission!\n    vec3 lKey = normalize(vec3(0.55 * cos(iTime * 0.55), 0.72, 0.55));\n    vec3 lRim = normalize(vec3(-0.62, 0.35, -0.70));\n    vec3 v = -rd;\n\n    // Strand-by-strand subtle melanin & micro-shift jitter\n    float strandId = sin((p.x - 0.18 * sin(p.y * 2.6 + 0.4)) * 95.0) * 0.5 + 0.5;\n    float strandTone = 0.82 + 0.36 * strandId;\n\n    // Physical hair absorption spectrum sigma_a from eumelanin/pheomelanin\n    vec3 sigmaA = mix(vec3(0.18, 0.48, 0.92), vec3(1.15, 2.15, 3.65), melanin);\n    vec3 hairCol = exp(-sigmaA * 0.95) * strandTone;\n\n    // Longitudinal angles theta_i, theta_r relative to normal plane\n    float sinTi = clamp(dot(lKey, tang), -0.99, 0.99);\n    float sinTr = clamp(dot(v, tang), -0.99, 0.99);\n    float thetaH = 0.5 * (asin(sinTi) + asin(sinTr));\n    float thetaD = 0.5 * (asin(sinTr) - asin(sinTi));\n\n    // Azimuthal projections perpendicular to hair tangent\n    vec3 lPerp = normalize(lKey - tang * sinTi + vec3(1e-5));\n    vec3 vPerp = normalize(v - tang * sinTr + vec3(1e-5));\n    float cosPhi = clamp(dot(lPerp, vPerp), -1.0, 1.0);\n    float phi = acos(cosPhi);\n\n    if (!isMarschner) {\n      // Left: Classic Kajiya-Kay single unshifted strand specular band + sin(T, L) diffuse\n      float diff = sqrt(max(1.0 - sinTi * sinTi, 0.0));\n      vec3 hVec = normalize(lKey + v);\n      float dotTH = dot(tang, hVec);\n      float sinTH = sqrt(max(1.0 - dotTH * dotTH, 0.0));\n      float spec = pow(sinTH, 28.0) * 0.75;\n      col = hairCol * (0.20 + 0.85 * diff) + vec3(0.95, 0.92, 0.88) * spec;\n    } else {\n      // Right: Full Marschner R (white primary shifted -alpha), TRT (colored secondary shifted +3*alpha + glints), TT (transmitted rim)\n      float mR = gauss(thetaH + alphaShift, betaR);\n      float mTRT = gauss(thetaH - 1.5 * alphaShift, betaR * 1.9);\n\n      // Azimuthal terms N_R (smooth cosine) and N_TRT (caustic glints near phi ~ 35 deg)\n      float nR = 0.25 + 0.75 * cos(phi * 0.5);\n      float glint = exp(-pow((phi - 0.62) / 0.16, 2.0)) * (0.45 + 0.55 * strandId);\n      float nTRT = 0.45 + 1.35 * glint;\n\n      // Fresnel & internal absorption through hair cross section (twice for TRT)\n      float fres = 0.046 + 0.954 * pow(1.0 - max(cos(thetaD), 0.0), 5.0);\n      vec3 attenTRT = exp(-sigmaA * 1.55) * (1.0 - fres);\n\n      // Backlight TT lobe (forward-scattering translucent halo at grazing rim!)\n      float sinTiRim = clamp(dot(lRim, tang), -0.99, 0.99);\n      float thetaHRim = 0.5 * (asin(sinTiRim) + asin(sinTr));\n      float mTT = gauss(thetaHRim - 0.5 * alphaShift, betaR * 0.75);\n      vec3 lRimPerp = normalize(lRim - tang * sinTiRim + vec3(1e-5));\n      float backAlign = clamp(-dot(lRimPerp, vPerp), 0.0, 1.0);\n      float nTT = pow(backAlign, 3.5);\n      vec3 attenTT = exp(-sigmaA * 0.65);\n\n      float wrapDiff = max(dot(n, lKey) * 0.5 + 0.5, 0.0);\n      vec3 lobeR = vec3(0.96, 0.97, 1.0) * mR * nR * fres * 0.52;\n      vec3 lobeTRT = attenTRT * mTRT * nTRT * 0.95;\n      vec3 lobeTT = attenTT * mTT * nTT * 1.35 * (0.35 + 0.65 * pow(1.0 - max(dot(n, v), 0.0), 2.0));\n\n      col = hairCol * (0.16 + 0.52 * wrapDiff) + lobeR + lobeTRT + lobeTT;\n    }\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "marschner-hair-scattering",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T20:35:52.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.5889,
      "std": 0.2144,
      "min": 0.1474,
      "max": 0.9089
     },
     "image": "/specimens/marschner-hair-scattering-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "kajiya-kay-hair-shading",
  "disney-hair-bsdf",
  "strand-based-real-time-hair",
  "path-tracing"
 ],
 "extends": [
  "kajiya-kay-hair-shading"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "path-tracing",
   "why": "The fibre BSDF is sampled at each strand hit while the path tracer handles inter-strand multiple scattering."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/materials/marschner-hair-scattering.json"
 },
 "solves": [
  "hair looks wrong compared to photographs",
  "want physically based hair highlights and colored glow",
  "path traced hair needs accurate fibre scattering",
  "need separate reflection and transmission lobes for fibres",
  "reference model to validate real-time hair shader"
 ],
 "authority": "Marschner et al., 2003",
 "url": "https://texelatlas.vercel.app/t/marschner-hair-scattering/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 18.79,
  "tier": "moderate",
  "p50_ms": 0.6182,
  "p95_ms": 0.6622,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "marschner-hair-scattering-live",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 17.06,
   "tier": "moderate",
   "p50_ms": 0.2712,
   "p95_ms": 0.2725,
   "speedup_x": 2.28,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 12.24,
   "tier": "moderate",
   "p50_ms": 0.3524,
   "p95_ms": 0.3542,
   "speedup_x": 1.75,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}