---
id: "vertex-connection-and-merging"
title: "Vertex Connection and Merging"
aliases: [VCM, UPS]
domain: "gi"
stage: "lighting"
realtime: "offline"
platforms: [cpu, cuda]
year_introduced: 2012
inputs: [mesh, material-params]
outputs: [radiance]
style: "photoreal"
dynamic: "static"
cost: "offline"
authority: "Georgiev et al., 2012"
url: "https://texelatlas.vercel.app/t/vertex-connection-and-merging/"
sources_verified_at: "2026-11-29"
---
# Vertex Connection and Merging (Georgiev et al., 2012)

> 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.

## Reach for it when

- 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

## 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.

With 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.

In 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 it

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.

Prefer [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

offline — Costs more than BDPT per iteration because of a light-vertex grid and merge lookups; benefits show on caustic-heavy scenes.
Measured GPU Weight: 3.36× baseline (light) — 0.1107 ms median / 0.1109 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 2.9× baseline (light) — 0.0461 ms median (2.4× faster on L4).
Ampere A100 scaling: 2.08× baseline (light) — 0.0598 ms median (1.85× faster on A100).

## 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

## Dataflow

- Inputs: mesh, material-params
- Outputs: radiance
- Platforms: cpu, cuda

## Presets

### Vertex Connection & Merging (VCM) — BDPT connection-only missing caustics (left) vs MIS photon-merged caustics (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_MERGE_RADIUS": 0.42,
  "P_CAUSTIC_GAIN": 1.4,
  "P_IOR": 1.52,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_MERGE_RADIUS = 0.42; // P Merge Radius [0.15, 0.95, 0.05]
const float P_CAUSTIC_GAIN = 1.40; // P Caustic Energy [0.4, 2.6, 0.1]
const float P_IOR = 1.52; // P Glass IOR [1.2, 1.85, 0.04]
const float P_SPLIT = 0.48; // P BDPT / VCM Split [0.0, 1.0, 0.02]

float hash21(vec2 p) {
  p = fract(p * vec2(127.1, 311.7));
  p += dot(p, p + 34.5);
  return fract(p.x * p.y);
}

// Evaluate concentrated dispersive refractive caustic focused through the glass sphere onto the Cornell box floor
vec3 evalGlassCaustic(vec3 p, vec3 sphC, float sphR, vec3 lightPos, float ior, float radius) {
  vec3 lDir = normalize(sphC - lightPos);
  // Intersection of central light axis through sphere with floor y = -0.68
  float tFocus = (-0.68 - sphC.y) / min(lDir.y, -0.05);
  vec3 focusCenter = sphC + lDir * tFocus;

  vec2 d = p.xz - focusCenter.xz;
  float r = length(d);
  float focalTight = mix(0.28, 0.11, clamp((ior - 1.15) / 0.75, 0.0, 1.0));
  float sig = max(focalTight * (0.55 + 0.65 * radius), 0.04);

  // Spectral dispersion rings (R/G/B slightly shifted focal radii) + bright central caustic core
  float cR = exp(-pow(r / (sig * 1.06), 2.0)) + 0.55 * exp(-pow((r - sig * 1.18) / (sig * 0.28), 2.0));
  float cG = exp(-pow(r / (sig * 1.00), 2.0)) + 0.55 * exp(-pow((r - sig * 1.05) / (sig * 0.25), 2.0));
  float cB = exp(-pow(r / (sig * 0.94), 2.0)) + 0.55 * exp(-pow((r - sig * 0.92) / (sig * 0.22), 2.0));

  // Fine caustic filament wave structure
  float ang = atan(d.y, d.x);
  float fil = 0.82 + 0.18 * cos(ang * 5.0 + iTime * 0.7) * sin(r * 18.0);
  return vec3(cR, cG, cB) * fil;
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float sx = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool useVCM = sx >= split;

  float mergeR = clamp(P_MERGE_RADIUS, 0.1, 1.0);
  float cGain = clamp(P_CAUSTIC_GAIN, 0.2, 3.0);
  float ior = clamp(P_IOR, 1.15, 2.0);

  vec3 ro = vec3(0.0, 0.06, 1.88);
  vec3 rd = normalize(vec3(uv, -1.35));
  vec3 col = vec3(0.03, 0.03, 0.04);

  vec3 lightPos = vec3(0.28 * sin(iTime * 0.65), 0.76, -0.35);
  vec3 sphC = vec3(0.0, -0.18, -0.45);
  float sphR = 0.36;

  // Intersect Cornell box walls (floor y=-0.68, ceil y=0.78, back z=-1.35, left x=-0.95, right x=0.95)
  float tHit = 1e5;
  vec3 hitN = vec3(0.0, 1.0, 0.0);
  int hitId = 0;

  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; } }
  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; } }
  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; } }
  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; } }
  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; } }

  // Intersect glass crystal sphere
  vec3 oc = ro - sphC;
  float b = dot(oc, rd);
  float c = dot(oc, oc) - sphR * sphR;
  float disc = b * b - c;
  bool hitGlass = false;
  if (disc > 0.0) {
    float tS = -b - sqrt(disc);
    if (tS > 0.05 && tS < tHit) { tHit = tS; hitN = normalize((ro + rd * tS) - sphC); hitGlass = true; hitId = 6; }
  }

  if (hitId > 0) {
    vec3 p = ro + rd * tHit;
    if (hitGlass) {
      // Refractive + reflective crystal sphere
      vec3 v = -rd;
      float ndv = max(dot(hitN, v), 0.0);
      float f0 = pow((ior - 1.0) / (ior + 1.0), 2.0);
      float F = f0 + (1.0 - f0) * pow(1.0 - ndv, 5.0);

      vec3 refr = refract(rd, hitN, 1.0 / ior);
      vec3 refl = reflect(rd, hitN);
      // Sample refracted Cornell box interior (crimson left, emerald right, bright floor caustic!)
      vec3 refrCol = mix(vec3(0.76, 0.72, 0.66), vec3(0.88, 0.22, 0.16), smoothstep(0.15, -0.55, refr.x));
      refrCol = mix(refrCol, vec3(0.16, 0.74, 0.36), smoothstep(-0.15, 0.55, refr.x));
      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));
      col = mix(refrCol * 0.92, reflCol, clamp(F + 0.15, 0.0, 0.92));
      // Spectral rim
      col += vec3(0.45, 0.75, 1.0) * pow(1.0 - ndv, 3.5) * 0.45;
    } else {
      // Ceiling area emitter lamp
      if (hitId == 2 && length(p.xz - lightPos.xz) < 0.24) {
        col = vec3(3.6, 3.2, 2.6);
      } else {
        vec3 alb = vec3(0.76, 0.74, 0.70);
        if (hitId == 4) alb = vec3(0.86, 0.20, 0.16); // red left wall
        else if (hitId == 5) alb = vec3(0.16, 0.74, 0.34); // green right wall

        vec3 toL = lightPos - p;
        float dist2 = max(dot(toL, toL), 0.12);
        vec3 L = toL / sqrt(dist2);
        float ndl = max(dot(hitN, L), 0.0);

        // Glass sphere direct shadow test
        vec3 soc = p - sphC;
        float sb = dot(soc, L);
        float sc = dot(soc, soc) - sphR * sphR;
        float sDisc = sb * sb - sc;
        float sh = (sDisc > 0.0 && (-sb - sqrt(sDisc)) > 0.01 && (-sb - sqrt(sDisc)) < sqrt(dist2)) ? 0.18 : 1.0;

        // Diffuse Cornell box GI (both BDPT and VCM converge diffuse paths cleanly!)
        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));
        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));
        vec3 direct = alb * vec3(1.65, 1.48, 1.24) * (ndl * sh / dist2) * 0.75;
        vec3 indirect = alb * (bounceRed * 0.28 + bounceGrn * 0.28 + vec3(0.12, 0.12, 0.14));
        col = direct + indirect;

        // Refractive SDS caustic on the floor beneath the crystal sphere
        if (hitId == 1) {
          vec3 caust = evalGlassCaustic(p, sphC, sphR, lightPos, ior, mergeR) * cGain;
          if (useVCM) {
            // Right (VCM): Photon vertex merging smoothly resolves the bright dispersive caustic with MIS!
            col += alb * caust * 1.85;
          } else {
            // Left (BDPT connections only): Fails to connect specular-diffuse-specular paths -> dark shadow with sparse fireflies!
            float rnd = hash21(floor(fragCoord * 0.65) + floor(iTime * 8.0) * 0.31);
            float firefly = step(0.972, rnd) * 5.5;
            col += alb * caust * firefly;
          }
        }
      }
    }
  }

  float sep = smoothstep(0.0035, 0.0008, abs(sx - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);
  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extends [Bidirectional Path Tracing](https://texelatlas.vercel.app/t/bidirectional-path-tracing.md)

## Sources

1. [primary] Iliyan Georgiev, Jaroslav Křivánek, Tomáš Davidovič, Philipp Slusallek (2012) Light transport simulation with vertex connection and merging. ACM Transactions on Graphics. https://doi.org/10.1145/2366145.2366211 (verified via crossref on 2026-11-29)

## Cite this entry

Texel. "Vertex Connection and Merging." https://texelatlas.vercel.app/t/vertex-connection-and-merging/ (accessed 2026-12-01).
