{
 "id": "pre-integrated-skin-shading",
 "title": "Pre-integrated skin shading",
 "aliases": [
  "pre-integrated subsurface scattering",
  "curvature-based skin LUT"
 ],
 "domain": "materials",
 "subdomain": "subsurface scattering",
 "stage": "material",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal",
  "godot"
 ],
 "year_introduced": 2011,
 "inputs": [
  "normals",
  "gbuffer",
  "texture"
 ],
 "outputs": [
  "radiance"
 ],
 "style": "photoreal",
 "dynamic": "both",
 "summary": "Fakes skin subsurface scattering with a lookup texture of diffuse profiles integrated over a ring, indexed by N.L and surface curvature, so the soft terminator and red bleed appear in a single pass without screen-space blur.",
 "how_it_works": "Skin light bleeds across the terminator because light entering in the lit area scatters and leaves in the shadowed area. Penner precomputes this: for a sphere of radius r (curvature 1/r), integrate the lit diffuse falloff convolved with a skin diffusion profile around the ring, and store the result in a 2D LUT with N.L on one axis and curvature on the other. At runtime curvature comes from derivatives of the world normal over derivatives of position, or a baked map, and the LUT fetch replaces the Lambert term, giving red-tinted soft transitions on cheeks and noses. A second trick pre-integrates the shadow edge penumbra for skin in a 1D LUT. For normals, a blurred normal map is used for the diffuse and the sharp one for specular, with per-channel blurs simulating different scattering lengths (red wider than blue). Specular still uses a standard BRDF.",
 "when_to_use": "Choose it when characters need believable skin on mobile or at scale and a full-screen blur is unaffordable. Prefer `separable-sss` when the budget allows screen-space blur and transmission (ears, thin regions). Prefer `christensen-burley-sss` for offline or path-traced subsurface. For general materials with less critical bleeding, `oren-nayar` or wrap lighting suffices.",
 "cost": {
  "class": "cheap",
  "notes": "One extra LUT sample plus a curvature computation per light; no extra passes."
 },
 "failure_modes": [
  "Curvature from screen-space derivatives is noisy and flickers on low-poly or normal-mapped skin",
  "Not shadow aware: light bleeding across shadow-map edges needs the separate shadow LUT",
  "Fixed profile and LUT cannot represent thin transmission such as ears or nostrils",
  "Sphere assumption makes flat regions with high-frequency normal detail look incorrectly soft",
  "Hard to tune per skin tone, as the LUT must be regenerated for each profile"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://advances.realtimerendering.com/s2011/Penner%20-%20Pre-Integrated%20Skin%20Rendering%20(Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course).pptx",
   "type": "web",
   "title": "Pre-Integrated Skin Shading",
   "authors": [
    "Eric Penner"
   ],
   "year": null,
   "venue": "advances.realtimerendering.com",
   "url": "https://advances.realtimerendering.com/s2011/Penner%20-%20Pre-Integrated%20Skin%20Rendering%20(Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course).pptx",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261022024048/https://advances.realtimerendering.com/s2011/Penner%20-%20Pre-Integrated%20Skin%20Rendering%20(Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course).pptx",
     "timestamp": "20261022024048"
    },
    "page_title": null,
    "host": "advances.realtimerendering.com",
    "title_confirmed_by_page": false,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://advances.realtimerendering.com/s2011/Penner%20-%20Pre-Integrated%20Skin%20Rendering%20(Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course).pptx → 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://advances.realtimerendering.com/s2011/Penner%20-%20Pre-Integrated%20Skin%20Rendering%20(Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course).pptx → 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": null,
   "__bib": "pennerintegrated"
  },
  {
   "role": "secondary",
   "key": "url:https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-14-advanced-techniques-realistic-real-time-skin",
   "type": "web",
   "title": "Chapter 14. Advanced Techniques for Realistic Real-Time Skin Rendering",
   "authors": [
    "Eugene d'Eon",
    "David Luebke"
   ],
   "year": null,
   "venue": "developer.nvidia.com",
   "url": "https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-14-advanced-techniques-realistic-real-time-skin",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261103110017/https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-14-advanced-techniques-realistic-real-time-skin",
     "timestamp": "20261103110017"
    },
    "page_title": "Chapter 14. Advanced Techniques for Realistic Real-Time Skin Rendering",
    "host": "developer.nvidia.com",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-14-advanced-techniques-realistic-real-time-skin → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-14-advanced-techniques-realistic-real-time-skin → 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://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-14-advanced-techniques-realistic-real-time-skin → 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": 1,
   "__bib": "deonchapter"
  }
 ],
 "presets": [
  {
   "id": "pre-integrated-skin-shading-live",
   "title": "Pre-integrated skin shading — curvature-driven RGB diffusion ring integral across the terminator",
   "runtime": "glsl-fragment",
   "params": {
    "CURVATURE": 1.15,
    "SSS_STRENGTH": 0.9,
    "SPECULAR": 0.45,
    "ROUGHNESS": 0.36
   },
   "basis": "original",
   "license_note": "MIT — written for this index",
   "code": "const float CURVATURE = 1.15; // P\nconst float SSS_STRENGTH = 0.9; // P\nconst float SPECULAR = 0.45; // P\nconst float ROUGHNESS = 0.36; // P\n\nfloat smin(float a, float b, float k) {\n  float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);\n  return mix(b, a, h) - k * h * (1.0 - h);\n}\n\n// Sculptural organic form with broad low-curvature domes and tight high-curvature ridges\nfloat mapOrganic(vec3 p) {\n  float a = iTime * 0.32;\n  mat2 r = mat2(cos(a), -sin(a), sin(a), cos(a));\n  p.xz = r * p.xz;\n  // Core cranial dome + sculpted cheek/nose/brow ridges for rich curvature variation\n  float head = length(p * vec3(1.08, 0.92, 1.02)) - 0.68;\n  float ridge1 = length(p - vec3(0.0, 0.02, 0.56)) - 0.16;\n  float ridge2 = length((p - vec3(0.0, 0.28, 0.46)) * vec3(0.65, 1.6, 1.2)) - 0.22;\n  float cheekL = length(p - vec3(-0.32, -0.08, 0.42)) - 0.24;\n  float cheekR = length(p - vec3( 0.32, -0.08, 0.42)) - 0.24;\n  float earL = length((p - vec3(-0.62, 0.02, -0.02)) * vec3(1.9, 0.72, 1.25)) - 0.19;\n  float earR = length((p - vec3( 0.62, 0.02, -0.02)) * vec3(1.9, 0.72, 1.25)) - 0.19;\n  float neck = length(vec2(length(p.xz - vec2(0.0, -0.08)) - 0.28, max(abs(p.y + 0.78) - 0.32, 0.0))) - 0.04;\n  float d = smin(head, ridge1, 0.14);\n  d = smin(d, ridge2, 0.16);\n  d = smin(d, min(cheekL, cheekR), 0.18);\n  d = smin(d, min(earL, earR), 0.10);\n  d = smin(d, neck, 0.18);\n  // Subtle pore-like micro-undulation\n  d += 0.004 * sin(p.x * 26.0) * sin(p.y * 26.0) * sin(p.z * 26.0);\n  return d;\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.0025, 0.0);\n  return normalize(vec3(\n    mapOrganic(p + e.xyy) - mapOrganic(p - e.xyy),\n    mapOrganic(p + e.yxy) - mapOrganic(p - e.yxy),\n    mapOrganic(p + e.yyx) - mapOrganic(p - e.yyx)\n  ));\n}\n\n// Penner (SIGGRAPH 2011) pre-integrated skin ring convolution evaluated directly in RGB\nvec3 preIntegratedSkinLUT(float nl, float curv) {\n  float theta = acos(clamp(nl, -1.0, 1.0));\n  float r = 1.0 / max(curv, 0.08);\n  // Multi-Gaussian skin diffusion profile (wider red radius than green/blue)\n  vec3 acc = vec3(0.0);\n  vec3 wSum = vec3(0.0);\n  const int N = 16;\n  for (int i = -N; i <= N; i++) {\n    float dTheta = float(i) * (1.85 / float(N));\n    float s = 2.0 * r * sin(abs(dTheta) * 0.5);\n    float s2 = s * s;\n    vec3 prof = vec3(\n      0.233 * exp(-s2 / 0.0128) + 0.455 * exp(-s2 / 0.22) + 0.312 * exp(-s2 / 1.45),\n      0.455 * exp(-s2 / 0.0128) + 0.410 * exp(-s2 / 0.09) + 0.135 * exp(-s2 / 0.36),\n      0.649 * exp(-s2 / 0.0128) + 0.280 * exp(-s2 / 0.04) + 0.071 * exp(-s2 / 0.15)\n    );\n    float lit = max(cos(theta + dTheta), 0.0);\n    acc += prof * lit;\n    wSum += prof;\n  }\n  return acc / max(wSum, vec3(1e-4));\n}\n\nfloat D_GGX(float nh, float a) {\n  float a2 = a * a;\n  float d = nh * nh * (a2 - 1.0) + 1.0;\n  return a2 / (3.14159265 * d * d + 1e-5);\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  vec3 ro = vec3(0.0, 0.02, 2.35);\n  vec3 rd = normalize(vec3(uv, -1.55));\n\n  float t = 0.2;\n  bool hit = false;\n  for (int i = 0; i < 64; i++) {\n    float d = mapOrganic(ro + rd * t);\n    if (d < 0.002) { hit = true; break; }\n    t += d * 0.85;\n    if (t > 6.0) break;\n  }\n\n  vec3 bg = mix(vec3(0.04, 0.05, 0.075), vec3(0.11, 0.12, 0.16), clamp(uv.y + 0.5, 0.0, 1.0));\n  if (!hit) {\n    fragColor = vec4(pow(clamp(aces(bg), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n    return;\n  }\n\n  vec3 p = ro + rd * t;\n  vec3 n = calcNormal(p);\n  // Screen-space geometric curvature |dN| / |dP| as in Penner 2011\n  float curv = clamp(length(fwidth(n)) / max(length(fwidth(p)), 1e-4), 0.25, 4.5) * max(CURVATURE, 0.05);\n\n  float lAng = 0.72 + 0.45 * sin(iTime * 0.5);\n  if (iMouse.z > 0.5 || length(iMouse.xy) > 1.0) {\n    lAng = (iMouse.x / iResolution.x - 0.5) * 3.14159;\n  }\n  vec3 L = normalize(vec3(sin(lAng), 0.38, cos(lAng)));\n  vec3 V = -rd;\n  float nl = dot(n, L);\n\n  vec3 lambert = vec3(max(nl, 0.0));\n  vec3 sssDiff = preIntegratedSkinLUT(nl, curv);\n  vec3 diffTerm = mix(lambert, sssDiff, clamp(SSS_STRENGTH, 0.0, 1.5));\n\n  vec3 skinAlbedo = vec3(0.84, 0.58, 0.46);\n  vec3 H = normalize(L + V);\n  float nh = max(dot(n, H), 0.0);\n  float ndv = max(dot(n, V), 0.01);\n  float fres = 0.028 + 0.972 * pow(1.0 - max(dot(V, H), 0.0), 5.0);\n  float r1 = clamp(ROUGHNESS, 0.08, 0.95);\n  // Dual-lobe oily skin specular\n  float spec = (0.75 * D_GGX(nh, r1 * r1) + 0.25 * D_GGX(nh, r1 * r1 * 0.22)) * fres * max(SPECULAR, 0.0) * max(nl, 0.0);\n\n  // Soft cool rim bounce + warm subsurface backlight\n  float backScatter = pow(clamp(dot(-L, V), 0.0, 1.0), 3.0) * pow(1.0 - ndv, 2.0) * clamp(curv * 0.4, 0.0, 1.0);\n  vec3 col = skinAlbedo * (diffTerm * vec3(1.65, 1.52, 1.38) + vec3(0.06, 0.08, 0.13)) + vec3(spec) * vec3(1.0, 0.95, 0.90) + vec3(0.85, 0.16, 0.06) * backScatter * SSS_STRENGTH;\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "pre-integrated-skin-shading",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:15:34.232Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6478,
      "std": 0.2004,
      "unique_colors": 149
     },
     "image": "/specimens/pre-integrated-skin-shading-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "separable-sss",
  "christensen-burley-sss",
  "oren-nayar",
  "curvature-map-baking"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "curvature-map-baking",
   "why": "A baked curvature map replaces noisy derivative-based curvature as the LUT's second axis."
  }
 ],
 "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/pre-integrated-skin-shading.json"
 },
 "solves": [
  "skin looks waxy or hard-edged at the terminator",
  "need cheap subsurface scattering for characters on mobile",
  "red bleed on shadow edge of faces",
  "cannot afford screen space blur for skin",
  "soft diffuse falloff depending on surface curvature"
 ],
 "authority": "Penner",
 "url": "https://texelatlas.vercel.app/t/pre-integrated-skin-shading/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 48.19,
  "tier": "heavy",
  "p50_ms": 1.5854,
  "p95_ms": 1.6191,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "pre-integrated-skin-shading-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 38.55,
   "tier": "heavy",
   "p50_ms": 0.613,
   "p95_ms": 0.6322,
   "speedup_x": 2.59,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 30.84,
   "tier": "heavy",
   "p50_ms": 0.8881,
   "p95_ms": 0.9008,
   "speedup_x": 1.79,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}