{
 "id": "vertex-connection-and-merging",
 "title": "Vertex Connection and Merging",
 "aliases": [
  "VCM",
  "UPS"
 ],
 "domain": "gi",
 "subdomain": "Monte Carlo light transport",
 "stage": "lighting",
 "realtime": "offline",
 "platforms": [
  "cpu",
  "cuda"
 ],
 "year_introduced": 2012,
 "inputs": [
  "mesh",
  "material-params"
 ],
 "outputs": [
  "radiance"
 ],
 "style": "photoreal",
 "dynamic": "static",
 "summary": "Combines bidirectional path tracing's vertex connections with photon-mapping-style vertex merging inside one MIS framework, so both diffuse paths and specular caustic paths converge well.",
 "how_it_works": "BDPT and photon mapping each fail where the other succeeds. BDPT is strong for diffuse-heavy paths but cannot connect through specular vertices; photon mapping handles specular-diffuse-specular caustics but is biased and wasteful on easy paths. VCM treats **merging** (accepting a light vertex that lies within a radius of an eye vertex) as an additional path sampling technique, interpreting it as an unbiased-in-the-limit path sampling strategy with a computable pdf.\n\nWith that interpretation, connection and merging strategies of a given path length can be weighted together using multiple importance sampling. The merge pdf is proportional to the number of light vertices times the area of the merge disk, so the weights depend on a single radius. As in [progressive-photon-mapping](progressive-photon-mapping), the radius shrinks over iterations, which makes the estimator consistent.\n\nIn practice you run one light subpath per pixel, store all light vertices in a grid, then trace the eye path, adding connection and merge contributions with their MIS weights at each vertex.",
 "when_to_use": "Choose it as a robust offline integrator for scenes mixing diffuse interreflection and caustic-heavy specular transport, such as jewelry, glassware or pool scenes with indirect lighting.\n\nPrefer [path-tracing](path-tracing) when scenes are simple, since VCM's bookkeeping and memory are significant. Prefer [bidirectional-path-tracing](bidirectional-path-tracing) when there are no relevant caustics. Prefer [path-guiding](path-guiding) when the problem is general noise rather than specular transport.",
 "cost": {
  "class": "offline",
  "notes": "Costs more than BDPT per iteration because of a light-vertex grid and merge lookups; benefits show on caustic-heavy scenes."
 },
 "failure_modes": [
  "Bias from merging (blur) at early iterations, only vanishing as the radius shrinks",
  "Radius parameter needs tuning: too large smears caustics, too small raises noise",
  "Substantial implementation complexity in the MIS weight recurrence, with tricky reverse-pdf bookkeeping",
  "Memory for the light vertex store grows with image resolution"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/2366145.2366211",
   "type": "paper",
   "title": "Light transport simulation with vertex connection and merging",
   "authors": [
    "Iliyan Georgiev",
    "Jaroslav Křivánek",
    "Tomáš Davidovič",
    "Philipp Slusallek"
   ],
   "year": 2012,
   "venue": "ACM Transactions on Graphics",
   "url": "https://doi.org/10.1145/2366145.2366211",
   "ids": {
    "doi": "10.1145/2366145.2366211"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2366145.2366211",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2366145.2366211",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2366145.2366211",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2366145.2366211",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2366145.2366211",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "georgiev2012light"
  }
 ],
 "presets": [
  {
   "id": "vertex-connection-and-merging-live",
   "title": "Vertex Connection & Merging (VCM) — BDPT connection-only missing caustics (left) vs MIS photon-merged caustics (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_MERGE_RADIUS": 0.42,
    "P_CAUSTIC_GAIN": 1.4,
    "P_IOR": 1.52,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_MERGE_RADIUS = 0.42; // P Merge Radius [0.15, 0.95, 0.05]\nconst float P_CAUSTIC_GAIN = 1.40; // P Caustic Energy [0.4, 2.6, 0.1]\nconst float P_IOR = 1.52; // P Glass IOR [1.2, 1.85, 0.04]\nconst float P_SPLIT = 0.48; // P BDPT / VCM Split [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// Evaluate concentrated dispersive refractive caustic focused through the glass sphere onto the Cornell box floor\nvec3 evalGlassCaustic(vec3 p, vec3 sphC, float sphR, vec3 lightPos, float ior, float radius) {\n  vec3 lDir = normalize(sphC - lightPos);\n  // Intersection of central light axis through sphere with floor y = -0.68\n  float tFocus = (-0.68 - sphC.y) / min(lDir.y, -0.05);\n  vec3 focusCenter = sphC + lDir * tFocus;\n\n  vec2 d = p.xz - focusCenter.xz;\n  float r = length(d);\n  float focalTight = mix(0.28, 0.11, clamp((ior - 1.15) / 0.75, 0.0, 1.0));\n  float sig = max(focalTight * (0.55 + 0.65 * radius), 0.04);\n\n  // Spectral dispersion rings (R/G/B slightly shifted focal radii) + bright central caustic core\n  float cR = exp(-pow(r / (sig * 1.06), 2.0)) + 0.55 * exp(-pow((r - sig * 1.18) / (sig * 0.28), 2.0));\n  float cG = exp(-pow(r / (sig * 1.00), 2.0)) + 0.55 * exp(-pow((r - sig * 1.05) / (sig * 0.25), 2.0));\n  float cB = exp(-pow(r / (sig * 0.94), 2.0)) + 0.55 * exp(-pow((r - sig * 0.92) / (sig * 0.22), 2.0));\n\n  // Fine caustic filament wave structure\n  float ang = atan(d.y, d.x);\n  float fil = 0.82 + 0.18 * cos(ang * 5.0 + iTime * 0.7) * sin(r * 18.0);\n  return vec3(cR, cG, cB) * fil;\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 sx = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  bool useVCM = sx >= split;\n\n  float mergeR = clamp(P_MERGE_RADIUS, 0.1, 1.0);\n  float cGain = clamp(P_CAUSTIC_GAIN, 0.2, 3.0);\n  float ior = clamp(P_IOR, 1.15, 2.0);\n\n  vec3 ro = vec3(0.0, 0.06, 1.88);\n  vec3 rd = normalize(vec3(uv, -1.35));\n  vec3 col = vec3(0.03, 0.03, 0.04);\n\n  vec3 lightPos = vec3(0.28 * sin(iTime * 0.65), 0.76, -0.35);\n  vec3 sphC = vec3(0.0, -0.18, -0.45);\n  float sphR = 0.36;\n\n  // Intersect Cornell box walls (floor y=-0.68, ceil y=0.78, back z=-1.35, left x=-0.95, right x=0.95)\n  float tHit = 1e5;\n  vec3 hitN = vec3(0.0, 1.0, 0.0);\n  int hitId = 0;\n\n  if (rd.y < -1e-4) { float t = (-0.68 - ro.y) / rd.y; if (t > 0.05 && t < tHit) { tHit = t; hitN = vec3(0.0, 1.0, 0.0); hitId = 1; } }\n  if (rd.y > 1e-4)  { float t = (0.78 - ro.y) / rd.y;  if (t > 0.05 && t < tHit) { tHit = t; hitN = vec3(0.0, -1.0, 0.0); hitId = 2; } }\n  if (rd.z < -1e-4) { float t = (-1.35 - ro.z) / rd.z; if (t > 0.05 && t < tHit) { tHit = t; hitN = vec3(0.0, 0.0, 1.0); hitId = 3; } }\n  if (rd.x < -1e-4) { float t = (-0.95 - ro.x) / rd.x; if (t > 0.05 && t < tHit) { tHit = t; hitN = vec3(1.0, 0.0, 0.0); hitId = 4; } }\n  if (rd.x > 1e-4)  { float t = (0.95 - ro.x) / rd.x;  if (t > 0.05 && t < tHit) { tHit = t; hitN = vec3(-1.0, 0.0, 0.0); hitId = 5; } }\n\n  // Intersect glass crystal sphere\n  vec3 oc = ro - sphC;\n  float b = dot(oc, rd);\n  float c = dot(oc, oc) - sphR * sphR;\n  float disc = b * b - c;\n  bool hitGlass = false;\n  if (disc > 0.0) {\n    float tS = -b - sqrt(disc);\n    if (tS > 0.05 && tS < tHit) { tHit = tS; hitN = normalize((ro + rd * tS) - sphC); hitGlass = true; hitId = 6; }\n  }\n\n  if (hitId > 0) {\n    vec3 p = ro + rd * tHit;\n    if (hitGlass) {\n      // Refractive + reflective crystal sphere\n      vec3 v = -rd;\n      float ndv = max(dot(hitN, v), 0.0);\n      float f0 = pow((ior - 1.0) / (ior + 1.0), 2.0);\n      float F = f0 + (1.0 - f0) * pow(1.0 - ndv, 5.0);\n\n      vec3 refr = refract(rd, hitN, 1.0 / ior);\n      vec3 refl = reflect(rd, hitN);\n      // Sample refracted Cornell box interior (crimson left, emerald right, bright floor caustic!)\n      vec3 refrCol = mix(vec3(0.76, 0.72, 0.66), vec3(0.88, 0.22, 0.16), smoothstep(0.15, -0.55, refr.x));\n      refrCol = mix(refrCol, vec3(0.16, 0.74, 0.36), smoothstep(-0.15, 0.55, refr.x));\n      vec3 reflCol = mix(vec3(0.25, 0.28, 0.36), vec3(2.8, 2.5, 2.0), pow(max(dot(refl, normalize(lightPos - p)), 0.0), 32.0));\n      col = mix(refrCol * 0.92, reflCol, clamp(F + 0.15, 0.0, 0.92));\n      // Spectral rim\n      col += vec3(0.45, 0.75, 1.0) * pow(1.0 - ndv, 3.5) * 0.45;\n    } else {\n      // Ceiling area emitter lamp\n      if (hitId == 2 && length(p.xz - lightPos.xz) < 0.24) {\n        col = vec3(3.6, 3.2, 2.6);\n      } else {\n        vec3 alb = vec3(0.76, 0.74, 0.70);\n        if (hitId == 4) alb = vec3(0.86, 0.20, 0.16); // red left wall\n        else if (hitId == 5) alb = vec3(0.16, 0.74, 0.34); // green right wall\n\n        vec3 toL = lightPos - p;\n        float dist2 = max(dot(toL, toL), 0.12);\n        vec3 L = toL / sqrt(dist2);\n        float ndl = max(dot(hitN, L), 0.0);\n\n        // Glass sphere direct shadow test\n        vec3 soc = p - sphC;\n        float sb = dot(soc, L);\n        float sc = dot(soc, soc) - sphR * sphR;\n        float sDisc = sb * sb - sc;\n        float sh = (sDisc > 0.0 && (-sb - sqrt(sDisc)) > 0.01 && (-sb - sqrt(sDisc)) < sqrt(dist2)) ? 0.18 : 1.0;\n\n        // Diffuse Cornell box GI (both BDPT and VCM converge diffuse paths cleanly!)\n        vec3 bounceRed = vec3(0.86, 0.20, 0.16) * max(dot(hitN, vec3(-1.0, 0.1, 0.0)), 0.0) / (0.85 + pow(p.x + 0.95, 2.0));\n        vec3 bounceGrn = vec3(0.16, 0.74, 0.34) * max(dot(hitN, vec3(1.0, 0.1, 0.0)), 0.0) / (0.85 + pow(0.95 - p.x, 2.0));\n        vec3 direct = alb * vec3(1.65, 1.48, 1.24) * (ndl * sh / dist2) * 0.75;\n        vec3 indirect = alb * (bounceRed * 0.28 + bounceGrn * 0.28 + vec3(0.12, 0.12, 0.14));\n        col = direct + indirect;\n\n        // Refractive SDS caustic on the floor beneath the crystal sphere\n        if (hitId == 1) {\n          vec3 caust = evalGlassCaustic(p, sphC, sphR, lightPos, ior, mergeR) * cGain;\n          if (useVCM) {\n            // Right (VCM): Photon vertex merging smoothly resolves the bright dispersive caustic with MIS!\n            col += alb * caust * 1.85;\n          } else {\n            // Left (BDPT connections only): Fails to connect specular-diffuse-specular paths -> dark shadow with sparse fireflies!\n            float rnd = hash21(floor(fragCoord * 0.65) + floor(iTime * 8.0) * 0.31);\n            float firefly = step(0.972, rnd) * 5.5;\n            col += alb * caust * firefly;\n          }\n        }\n      }\n    }\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(sx - split));\n  col = mix(col, vec3(0.95, 0.97, 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": "vertex-connection-and-merging",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T21:07:28.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6884,
      "std": 0.1537,
      "min": 0.3503,
      "max": 0.993
     },
     "image": "/specimens/vertex-connection-and-merging-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "bidirectional-path-tracing",
  "progressive-photon-mapping",
  "photon-mapping"
 ],
 "extends": [
  "bidirectional-path-tracing"
 ],
 "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/gi/vertex-connection-and-merging.json"
 },
 "solves": [
  "path tracing noise with glass and mirrors",
  "bidirectional tracing fails on caustics",
  "want one robust method for diffuse and specular light transport",
  "difficult light paths converge slowly in renderer"
 ],
 "authority": "Georgiev et al., 2012",
 "url": "https://texelatlas.vercel.app/t/vertex-connection-and-merging/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 3.36,
  "tier": "light",
  "p50_ms": 0.1107,
  "p95_ms": 0.1109,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "vertex-connection-and-merging-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 2.9,
   "tier": "light",
   "p50_ms": 0.0461,
   "p95_ms": 0.0461,
   "speedup_x": 2.4,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 2.08,
   "tier": "light",
   "p50_ms": 0.0598,
   "p95_ms": 0.0599,
   "speedup_x": 1.85,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}