{
 "id": "sharc",
 "title": "SHaRC: Spatially Hashed Radiance Cache",
 "aliases": [
  "SHaRC",
  "hash-grid radiance cache"
 ],
 "domain": "gi",
 "subdomain": "radiance caches",
 "stage": "lighting",
 "realtime": "realtime",
 "platforms": [
  "desktop-gpu"
 ],
 "year_introduced": 2023,
 "inputs": [
  "gbuffer",
  "mesh"
 ],
 "outputs": [
  "radiance"
 ],
 "style": "photoreal",
 "dynamic": "dynamic",
 "summary": "A world-space radiance cache stored in a GPU hash table keyed by quantized position and normal. Path-tracing paths end early by reading cached radiance, and a few extra paths update the cache.",
 "how_it_works": "The cache is a hash map from a voxel key (position quantized by a camera-dependent cell size, plus a coarse normal bucket) to an accumulated radiance and a sample count. There is no neural network.\n\nA frame has three steps. **Update**: a sparse subset of screen pixels traces full paths of several bounces. At each vertex, the throughput-weighted contribution of the rest of the path is written to the hash entry for that vertex's cell with atomic adds, so each path trains many cells. **Resolve**: a pass converts raw accumulation to stable averages, blending with the previous frame using an exponential moving average and decaying old entries. **Query**: the normal render traces paths for each pixel but stops after one or two bounces, reading the cell's cached radiance in place of the remaining transport.\n\nCells are quantized with a level-of-detail that grows with distance from the camera, so the cache is compact and fine resolution is spent near the viewer. A compaction and stale-entry eviction scheme keep the table bounded.",
 "when_to_use": "Choose it as a simple, drop-in multi-bounce radiance cache for a path tracer, particularly when you want to avoid a neural network and need broad GPU support.\n\nPrefer [neural-radiance-caching](neural-radiance-caching) when you want a smoother, learned cache and have the hardware for it. Prefer [surfel-gi](surfel-gi) when you want an explicit surface-based cache. Prefer [restir-gi](restir-gi) for high-frequency per-pixel indirect. Prefer [ddgi](ddgi) for regular-grid probes of diffuse irradiance.",
 "cost": {
  "class": "medium",
  "notes": "Cost is one extra sparse path pass plus hash lookups at path ends; the number of update paths and cache capacity are the main tuning knobs."
 },
 "failure_modes": [
  "Blocky or noisy indirect where the voxel size is coarse compared with lighting variation, with visible cell boundaries",
  "Light leaking across thin walls because cells key only on position and a coarse normal",
  "Hash collisions and eviction cause flicker if the table is undersized for the scene",
  "Cached radiance is diffuse-like: glossy and specular reflection hits get inaccurate values"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://github.com/NVIDIA-RTX/RTXGI/blob/main/Docs/SharcGuide.md",
   "type": "web",
   "title": "SHaRC Guide (RTXGI SDK documentation)",
   "authors": [
    "NVIDIA"
   ],
   "year": null,
   "venue": "github.com",
   "url": "https://github.com/NVIDIA-RTX/RTXGI/blob/main/Docs/SharcGuide.md",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20260218004655/https://github.com/NVIDIA-RTX/RTXGI/blob/main/Docs/SharcGuide.md",
     "timestamp": "20260218004655"
    },
    "page_title": "RTXGI/Docs/SharcGuide.md at main · NVIDIA-RTX/RTXGI",
    "host": "github.com",
    "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://github.com/NVIDIA-RTX/RTXGI/blob/main/Docs/SharcGuide.md → 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://github.com/NVIDIA-RTX/RTXGI/blob/main/Docs/SharcGuide.md → 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.16666666666666666,
   "__bib": "nvidiasharc"
  },
  {
   "role": "implementation",
   "key": "gh:nvidia-rtx/sharc",
   "type": "code",
   "title": "NVIDIA-RTX/SHARC",
   "description": "Spatially Hashed Radiance Cache (SHaRC) Library ",
   "authors": [
    "NVIDIA-RTX"
   ],
   "year": 2024,
   "venue": "GitHub",
   "url": "https://github.com/NVIDIA-RTX/SHARC",
   "ids": {
    "repo": "NVIDIA-RTX/SHARC"
   },
   "license": "NOASSERTION",
   "extra": {
    "stars": 162,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-08-02T07:02:17Z",
    "language": "C",
    "homepage": null,
    "license_name": "Other"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/SHARC",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/SHARC",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/SHARC",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/SHARC",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/SHARC",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/SHARC",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "nvidiartx2024nvidiac"
  },
  {
   "role": "implementation",
   "key": "gh:nvidia-rtx/rtxgi",
   "type": "code",
   "title": "NVIDIA-RTX/RTXGI",
   "description": "RTXGI v2.0 Update including Neural Radiance Cache and Spatial Hash Radiance Cache ",
   "authors": [
    "NVIDIA-RTX"
   ],
   "year": 2024,
   "venue": "GitHub",
   "url": "https://github.com/NVIDIA-RTX/RTXGI",
   "ids": {
    "repo": "NVIDIA-RTX/RTXGI"
   },
   "license": "NOASSERTION",
   "extra": {
    "stars": 380,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-12T10:08:02Z",
    "language": "C++",
    "homepage": null,
    "license_name": "Other"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXGI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXGI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXGI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXGI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXGI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXGI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "nvidiartx2024nvidiab"
  }
 ],
 "presets": [
  {
   "id": "sharc-live",
   "title": "SHaRC (Spatial Hash Radiance Cache) — quantized world-space hash voxels (left) vs smooth multi-bounce GI (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_VOXEL_RES": 7,
    "P_BOUNCE_STR": 1.2,
    "P_SUN_SWEEP": 0.55,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_VOXEL_RES = 7.0; // P Hash Grid Density [4.0, 14.0, 1.0]\nconst float P_BOUNCE_STR = 1.20; // P Radiance Gain [0.2, 2.0, 0.05]\nconst float P_SUN_SWEEP = 0.55; // P Sun Motion [0.0, 2.0, 0.05]\nconst float P_SPLIT = 0.48; // P Hash Voxels / GI [0.0, 1.0, 0.02]\n\nvec2 mapCourtyard(vec3 p) {\n  float dFloor = p.y + 0.72;\n  float dBack = p.z + 1.45;\n  vec2 res = vec2(dFloor, 1.0);\n  if (dBack < res.x) res = vec2(dBack, 2.0); // terracotta sun-baked back wall\n\n  // Two staggered modern architectural monoliths casting colored sky/sun bounce\n  vec3 b1 = abs(p - vec3(-0.62, -0.08, -0.25)) - vec3(0.26, 0.64, 0.34);\n  float d1 = length(max(b1, 0.0)) + min(max(b1.x, max(b1.y, b1.z)), 0.0);\n  if (d1 < res.x) res = vec2(d1, 3.0);\n\n  vec3 b2 = abs(p - vec3(0.56, -0.22, -0.45)) - vec3(0.30, 0.50, 0.28);\n  float d2 = length(max(b2, 0.0)) + min(max(b2.x, max(b2.y, b2.z)), 0.0);\n  if (d2 < res.x) res = vec2(d2, 4.0);\n\n  float dSph = length(p - vec3(0.0, -0.40, 0.05)) - 0.32;\n  if (dSph < res.x) res = vec2(dSph, 5.0);\n  return res;\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.0025, 0.0);\n  return normalize(vec3(\n    mapCourtyard(p + e.xyy).x - mapCourtyard(p - e.xyy).x,\n    mapCourtyard(p + e.yxy).x - mapCourtyard(p - e.yxy).x,\n    mapCourtyard(p + e.yyx).x - mapCourtyard(p - e.yyx).x\n  ));\n}\n\n// Compute indirect radiance stored at a world position p & normal n (evaluated at voxel center on left, smooth on right!)\nvec3 evalSharcRadiance(vec3 p, vec3 n, vec3 sunDir, float gain) {\n  // Warm terracotta bounce from sun-lit back wall + cool zenith sky fill + emerald monolith bounce\n  float backBounce = max(dot(n, vec3(0.0, 0.15, -1.0)), 0.0) / (0.65 + (p.z + 1.45) * (p.z + 1.45));\n  float leftBounce = max(dot(n, normalize(vec3(-0.62, -0.1, -0.25) - p)), 0.0) / (0.55 + dot(p - vec3(-0.62, -0.1, -0.25), p - vec3(-0.62, -0.1, -0.25)));\n  float skyFill = 0.5 + 0.5 * n.y;\n  vec3 rad = vec3(0.95, 0.42, 0.22) * backBounce * 0.95\n           + vec3(0.16, 0.72, 0.88) * leftBounce * 0.45\n           + vec3(0.24, 0.44, 0.78) * skyFill * 0.42\n           + vec3(0.98, 0.86, 0.62) * max(dot(n, sunDir), 0.0) * 0.22;\n  return rad * gain;\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 isFinalGI = screenX >= split;\n  float voxRes = clamp(floor(P_VOXEL_RES + 0.5), 3.0, 16.0);\n  float gain = clamp(P_BOUNCE_STR, 0.15, 2.2);\n  float sweep = iTime * max(P_SUN_SWEEP, 0.0);\n\n  vec3 ro = vec3(0.0, 0.35, 2.22);\n  vec3 rd = normalize(vec3(uv.x, uv.y - 0.12, -1.38));\n  vec3 sky = mix(vec3(0.76, 0.82, 0.90), vec3(0.16, 0.38, 0.72), smoothstep(-0.08, 0.52, rd.y));\n  vec3 col = sky;\n\n  float t = 0.05;\n  vec2 hit = vec2(10.0, 0.0);\n  for (int i = 0; i < 64; i++) {\n    vec2 h = mapCourtyard(ro + rd * t);\n    if (h.x < 0.0025) { hit = vec2(t, h.y); break; }\n    t += h.x;\n    if (t > 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 sunDir = normalize(vec3(0.62 * cos(sweep * 0.45), 0.72, 0.48));\n\n    // Direct sun shadow ray\n    float sh = 1.0;\n    float ts = 0.03;\n    for (int s = 0; s < 20; s++) {\n      float ds = mapCourtyard(p + sunDir * ts).x;\n      if (ds < 0.003) { sh = 0.0; break; }\n      ts += max(ds, 0.03);\n      if (ts > 3.5) break;\n    }\n\n    vec3 alb = vec3(0.70, 0.68, 0.64);\n    if (hit.y > 1.5 && hit.y < 2.5) alb = vec3(0.86, 0.38, 0.22);\n    else if (hit.y > 2.5 && hit.y < 3.5) alb = vec3(0.18, 0.64, 0.78);\n    else if (hit.y > 3.5 && hit.y < 4.5) alb = vec3(0.84, 0.80, 0.74);\n    else if (hit.y > 4.5) alb = vec3(0.90, 0.88, 0.84);\n\n    // Distance-adaptive SHaRC cascade LOD level (coarser voxels further from camera!)\n    float camDist = length(p - ro);\n    float lodScale = (camDist > 2.6) ? (voxRes * 0.5) : voxRes;\n    vec3 cellPos = (floor(p * lodScale) + 0.5) / lodScale;\n    // Quantized surface normal direction into octants as in SHaRC hash key\n    vec3 qNorm = normalize(floor(n * 2.5 + 0.5) + vec3(1e-4));\n\n    vec3 direct = alb * vec3(1.0, 0.94, 0.84) * max(dot(n, sunDir), 0.0) * sh * 1.15;\n\n    if (!isFinalGI) {\n      // Left: Raw SHaRC spatial hash-grid cache cells visualized directly (discrete LOD voxel cells + cell borders!)\n      vec3 cellRad = evalSharcRadiance(cellPos, qNorm, sunDir, gain);\n      vec3 fracC = abs(fract(p * lodScale) - 0.5);\n      float border = smoothstep(0.05, 0.012, min(min(0.5 - fracC.x, 0.5 - fracC.y), 0.5 - fracC.z));\n      // Color-tint cascade boundary subtly to reveal camera-distance LOD transition\n      vec3 lodEdgeCol = (camDist > 2.6) ? vec3(0.98, 0.76, 0.20) : vec3(0.20, 0.92, 0.98);\n      col = cellRad * 1.25 + lodEdgeCol * border * 0.38;\n    } else {\n      // Right: Final path-traced render reading SHaRC cache at secondary bounce vertices -> clean, vivid multi-bounce GI!\n      vec3 smoothGI = evalSharcRadiance(p, n, sunDir, gain);\n      col = direct + alb * smoothGI;\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": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "sharc",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T20:35:56.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.7418,
      "std": 0.0838,
      "min": 0.3269,
      "max": 0.9328
     },
     "image": "/specimens/sharc-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "neural-radiance-caching",
  "surfel-gi",
  "ddgi",
  "restir-gi"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "path-tracing",
   "why": "Paths terminate at the hash-grid cache instead of tracing every bounce."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/gi/sharc.json"
 },
 "solves": [
  "real-time gi on ray tracing with limited rays",
  "indirect lighting noise too high for the budget",
  "cache radiance in world space across frames",
  "path traced gi slows frame rate on mid range gpus"
 ],
 "authority": "NVIDIA",
 "url": "https://texelatlas.vercel.app/t/sharc/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 25.71,
  "tier": "heavy",
  "p50_ms": 0.8459,
  "p95_ms": 0.8751,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "sharc-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 23.81,
   "tier": "heavy",
   "p50_ms": 0.3785,
   "p95_ms": 0.3809,
   "speedup_x": 2.23,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 15.57,
   "tier": "moderate",
   "p50_ms": 0.4483,
   "p95_ms": 0.4513,
   "speedup_x": 1.89,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}