{
 "id": "stylized-nonlinear-monte-carlo",
 "title": "Stylized nonlinear Monte Carlo rendering",
 "aliases": [],
 "domain": "npr",
 "subdomain": "stylized light transport",
 "stage": "lighting",
 "realtime": "offline",
 "platforms": [
  "cuda",
  "cpu"
 ],
 "year_introduced": 2025,
 "inputs": [
  "mesh",
  "material-params"
 ],
 "outputs": [
  "hdr-image",
  "ldr-image"
 ],
 "style": "stylized",
 "dynamic": "both",
 "summary": "Applies nonlinear artistic operators inside the path-tracing estimator, so stylization such as banding or thresholding is applied to light transport before it is averaged.",
 "how_it_works": "Ordinary path tracing averages unbiased samples, so applying a nonlinear stylisation (a toon ramp, a threshold) to the final pixel average is not the same as applying it inside the light-transport integral. The paper studies rendering in which artist-defined nonlinear operators act within the Monte Carlo estimator, so that stylisation becomes part of how light bounces (for example banded or thresholded indirect lighting), and develops practical estimators for evaluating those nonlinear expressions from path samples. The result is stylised global illumination rather than a stylised final image. A reference implementation accompanies the paper; see the sources for the project page and code",
 "when_to_use": "Choose it for offline stylised films or stills where indirect light must stay stylised. Prefer `toon-shading` for real-time use where only direct lighting is shaded in toon style, and `guilty-gear-xrd-shading` for artist-directed real-time looks.",
 "cost": {
  "class": "offline",
  "notes": "Offline path-tracing cost; the nonlinearity needs extra samples or estimators for low noise."
 },
 "failure_modes": [
  "Nonlinear functions amplify noise, so more samples are needed than for a plain path tracer",
  "Nonlinear estimators can trade bias against variance",
  "Hard to preview interactively",
  "Reference code repository is archived"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/3721238.3730686",
   "type": "paper",
   "title": "Practical Stylized Nonlinear Monte Carlo Rendering",
   "authors": [
    "Xiaochun Tong",
    "Toshiya Hachisuka"
   ],
   "year": 2025,
   "venue": "Proceedings of the Special Interest Group on Computer Graphics and Interactive Techniques Conference Conference Papers",
   "url": "https://doi.org/10.1145/3721238.3730686",
   "ids": {
    "doi": "10.1145/3721238.3730686"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3721238.3730686",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3721238.3730686",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3721238.3730686",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3721238.3730686",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3721238.3730686",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "tong2025practical"
  },
  {
   "role": "implementation",
   "key": "gh:luisagroup/practical-stylized",
   "type": "code",
   "title": "LuisaGroup/practical-stylized",
   "description": "Source Code for SIGGRAPH North America 2025 Paper \"Practical Stylized Nonlinear Monte Carlo Rendering\"",
   "authors": [
    "LuisaGroup"
   ],
   "year": 2025,
   "venue": "GitHub",
   "url": "https://github.com/LuisaGroup/practical-stylized",
   "ids": {
    "repo": "LuisaGroup/practical-stylized"
   },
   "license": null,
   "extra": {
    "stars": 48,
    "stars_checked": "2026-11-29",
    "archived": true,
    "fork": false,
    "pushed_at": "2025-09-13T18:09:28Z",
    "language": "Rust",
    "homepage": null,
    "license_name": null
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/LuisaGroup/practical-stylized",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/LuisaGroup/practical-stylized",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/LuisaGroup/practical-stylized",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/LuisaGroup/practical-stylized",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/LuisaGroup/practical-stylized",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/LuisaGroup/practical-stylized",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "luisagroup2025luisagroup"
  },
  {
   "role": "primary",
   "key": "url:https://cs.uwaterloo.ca/~thachisu",
   "type": "web",
   "title": "Toshiya Hachisuka's page (paper link)",
   "authors": [
    "Toshiya Hachisuka"
   ],
   "year": null,
   "venue": "cs.uwaterloo.ca",
   "url": "https://cs.uwaterloo.ca/~thachisu",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20260906045113/https://cs.uwaterloo.ca/~thachisu/",
     "timestamp": "20260906045113"
    },
    "page_title": "Toshiya Hachisuka at UWaterloo",
    "host": "cs.uwaterloo.ca",
    "title_confirmed_by_page": false,
    "title_unconfirmed": true
   },
   "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://cs.uwaterloo.ca/~thachisu → 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://cs.uwaterloo.ca/~thachisu → 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.4444444444444444,
   "__bib": "hachisukatoshiya"
  }
 ],
 "presets": [
  {
   "id": "stylized-nonlinear-monte-carlo-live",
   "title": "Stylized Nonlinear Monte Carlo — post-average toon ramp (left) vs in-integrator nonlinear sample stylization (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_BANDS": 4,
    "P_PENUMBRA": 0.75,
    "P_BOUNCE_STYLE": 0.85,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_BANDS = 4.00; // P Toon Bands [2.0, 6.0, 1.0]\nconst float P_PENUMBRA = 0.75; // P Area Light Size [0.15, 1.3, 0.05]\nconst float P_BOUNCE_STYLE = 0.85; // P Nonlinear Bounce [0.0, 1.2, 0.05]\nconst float P_SPLIT = 0.48; // P Post-Toon / NL-MC [0.0, 1.0, 0.02]\n\nfloat hash21(vec2 p) {\n  p = fract(p * vec2(127.1, 311.7));\n  p += dot(p, p + 34.5);\n  return fract(p.x * p.y);\n}\n\n// Nonlinear artistic stylization operator phi(L): quantizes luminance into crisp chromatic ink bands!\nvec3 nonlinearOp(vec3 rad, float bands) {\n  float lum = dot(rad, vec3(0.299, 0.587, 0.114));\n  float qLum = floor(clamp(lum, 0.0, 1.4) * bands + 0.35) / bands;\n  // Subtle artistic warm-highlight / cool-shadow chromatic shift inside the operator\n  vec3 tint = mix(vec3(0.72, 0.84, 1.16), vec3(1.14, 0.98, 0.82), clamp(qLum, 0.0, 1.0));\n  return (rad / max(lum, 0.02)) * qLum * tint;\n}\n\nvec2 mapRoom(vec3 p) {\n  float dFloor = p.y + 0.54;\n  vec2 res = vec2(dFloor, 1.0);\n  // Coral bounce wall on left\n  float dWall = p.x + 1.05;\n  if (dWall < res.x) res = vec2(dWall, 2.0);\n  // Hero central ceramic sphere\n  float dSph1 = length(p - vec3(0.06, -0.14, -0.05)) - 0.40;\n  if (dSph1 < res.x) res = vec2(dSph1, 3.0);\n  // Floating small blocker orb casting a rich soft penumbra across sphere & floor!\n  float dSph2 = length(p - vec3(0.32, 0.36, 0.25)) - 0.16;\n  if (dSph2 < res.x) res = vec2(dSph2, 4.0);\n  return res;\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.0025, 0.0);\n  return normalize(vec3(\n    mapRoom(p + e.xyy).x - mapRoom(p - e.xyy).x,\n    mapRoom(p + e.yxy).x - mapRoom(p - e.yxy).x,\n    mapRoom(p + e.yyx).x - mapRoom(p - e.yyx).x\n  ));\n}\n\nfloat softShadowRay(vec3 p, vec3 lPos) {\n  vec3 toL = lPos - p;\n  float dL = length(toL);\n  vec3 dir = toL / max(dL, 1e-4);\n  float t = 0.03;\n  for (int i = 0; i < 20; i++) {\n    float h = mapRoom(p + dir * t).x;\n    if (h < 0.003) return 0.0;\n    t += max(h, 0.03);\n    if (t > dL - 0.04) break;\n  }\n  return 1.0;\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 isNLMC = screenX >= split;\n  float bands = clamp(floor(P_BANDS + 0.5), 2.0, 6.0);\n  float lightR = clamp(P_PENUMBRA, 0.10, 1.4) * 0.42;\n  float bStyle = clamp(P_BOUNCE_STYLE, 0.0, 1.4);\n\n  vec3 ro = vec3(0.12, 0.24, 2.22);\n  vec3 rd = normalize(vec3(uv.x, uv.y - 0.08, -1.48));\n  vec3 col = mix(vec3(0.08, 0.11, 0.18), vec3(0.20, 0.28, 0.42), smoothstep(-0.4, 0.5, uv.y));\n\n  float dist = 0.05;\n  vec2 hit = vec2(10.0, 0.0);\n  for (int i = 0; i < 64; i++) {\n    vec2 h = mapRoom(ro + rd * dist);\n    if (h.x < 0.002) { hit = vec2(dist, h.y); break; }\n    dist += h.x;\n    if (dist > 8.0) break;\n  }\n\n  if (hit.y > 0.5) {\n    vec3 p = ro + rd * hit.x;\n    vec3 n = calcNormal(p);\n    vec3 alb = vec3(0.84, 0.82, 0.78);\n    if (hit.y > 1.5 && hit.y < 2.5) alb = vec3(0.92, 0.34, 0.24);\n    else if (hit.y > 2.5 && hit.y < 3.5) alb = vec3(0.92, 0.86, 0.76);\n    else if (hit.y > 3.5) alb = vec3(0.22, 0.68, 0.84);\n\n    // Area light center orbiting gently overhead\n    vec3 areaCenter = vec3(0.72 + 0.22 * cos(iTime * 0.5), 1.05, 0.62 + 0.22 * sin(iTime * 0.5));\n\n    // Evaluate 8 stratified Monte Carlo light-transport samples across the area light & bounce hemisphere:\n    // Left (Post-process toon): linear average FIRST, then apply phi(E[L]) -> harsh binary cut, flat indirect!\n    // Right (Nonlinear MC): apply phi(L_i) INSIDE the estimator E[phi(L)] -> smooth painterly penumbra transitions\n    // AND vivid quantized coral indirect bounce bands!\n    vec3 linearAcc = vec3(0.0);\n    vec3 nlAcc = vec3(0.0);\n    float jitter = hash21(floor(fragCoord) * 0.5) * 6.2831853;\n\n    for (int s = 0; s < 8; s++) {\n      float fs = float(s);\n      float ang = (fs / 8.0) * 6.2831853 + jitter * 0.25;\n      float rr = sqrt((fs + 0.5) / 8.0) * lightR;\n      vec3 lPt = areaCenter + vec3(cos(ang) * rr, 0.0, sin(ang) * rr);\n      vec3 lDir = normalize(lPt - p);\n      float vis = softShadowRay(p + n * 0.01, lPt);\n      float ndl = max(dot(n, lDir), 0.0);\n\n      // Colored indirect bounce contribution from coral left wall (x = -1.05)\n      float wallFactor = max(dot(n, normalize(vec3(-1.05, 0.0, 0.0) - p)), 0.0) / (0.65 + (p.x + 1.05) * (p.x + 1.05));\n      vec3 bounceS = vec3(0.96, 0.36, 0.24) * wallFactor * (0.45 + 0.55 * sin(ang) * 0.3 + 0.35) * bStyle;\n      vec3 skyS = vec3(0.22, 0.34, 0.54) * (0.5 + 0.5 * n.y) * 0.36;\n\n      vec3 sampleRad = alb * (vec3(1.28, 1.18, 1.02) * ndl * vis + bounceS + skyS);\n      linearAcc += sampleRad;\n      nlAcc += nonlinearOp(sampleRad, bands);\n    }\n\n    vec3 avgLinear = linearAcc * 0.125;\n    vec3 avgNL = nlAcc * 0.125;\n\n    if (!isNLMC) {\n      // Left: Standard post-process toon ramp phi(E[L]) -- rigid stair-step contour cutting penumbra harshly\n      col = nonlinearOp(avgLinear, bands);\n    } else {\n      // Right: Stylized Nonlinear Monte Carlo E[phi(L)] -- rich ink-wash penumbra + vibrant banded indirect bounce!\n      col = avgNL;\n    }\n    if (hit.y < 1.5) col = mix(vec3(0.08, 0.11, 0.18), col, exp(-hit.x * 0.10));\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.96, 0.98, 1.0), sep);\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": "stylized-nonlinear-monte-carlo",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T21:07:26.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.5783,
      "std": 0.2242,
      "min": 0,
      "max": 0.9022
     },
     "image": "/specimens/stylized-nonlinear-monte-carlo-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "toon-shading",
  "guilty-gear-xrd-shading"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/npr/stylized-nonlinear-monte-carlo.json"
 },
 "solves": [
  "stylisation breaks when path tracing averages samples",
  "toon banding on indirect light in offline renders",
  "thresholded shading gets noisy or washed out in pt",
  "need stylised global illumination in film rendering",
  "art operators applied before averaging light"
 ],
 "authority": "Tong & Hachisuka, 2025",
 "url": "https://texelatlas.vercel.app/t/stylized-nonlinear-monte-carlo/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 61.52,
  "tier": "extreme",
  "p50_ms": 2.024,
  "p95_ms": 2.1282,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "stylized-nonlinear-monte-carlo-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 58.54,
   "tier": "heavy",
   "p50_ms": 0.9308,
   "p95_ms": 0.9357,
   "speedup_x": 2.17,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 40.69,
   "tier": "heavy",
   "p50_ms": 1.172,
   "p95_ms": 1.1768,
   "speedup_x": 1.73,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}