---
id: "multi-view-stereo-patchmatch"
title: "Multi-View Stereo (PatchMatch, COLMAP)"
aliases: [MVS, patch-match stereo]
domain: "capture"
stage: "capture"
realtime: "offline"
platforms: [cuda]
year_introduced: 2016
inputs: [photos, camera-poses]
outputs: [depth, normals, point-cloud]
style: "photoreal"
dynamic: "static"
cost: "offline"
authority: "Schönberger et al., 2016"
url: "https://texelatlas.vercel.app/t/multi-view-stereo-patchmatch/"
sources_verified_at: "2026-11-29"
---
# Multi-View Stereo (PatchMatch, COLMAP) (Schönberger et al., 2016)

> Computes a dense depth and normal map per image from posed photos using PatchMatch propagation with pixelwise view selection, then fuses them into a dense point cloud.

## Reach for it when

- need dense point cloud from photos with known cameras
- turn posed photos into depth maps
- build a mesh for baking from a photo set
- sparse reconstruction is too thin for detail
- photogrammetry dense reconstruction step

## How it works

Given calibrated cameras, each pixel in a reference image carries a hypothesised depth and surface normal. PatchMatch initialises these randomly and iterates: neighbouring pixels propagate good hypotheses along scanlines, and random perturbation refines them. Each hypothesis is scored by photometric consistency (normalised cross-correlation of a slanted patch) against a subset of source images. The key idea is that the subset is chosen per pixel, using a probabilistic occlusion model estimated jointly with depth, so occluded views stop poisoning the cost. Geometric consistency across neighbouring views is added in later passes. Resulting depth maps are filtered for consistency and fused into a point cloud, which can be meshed with Poisson or Delaunay methods.

## When to use it

Choose it when you need an explicit dense surface from a photo set with known poses, e.g. for meshing and baking. Prefer [Neuralangelo](https://texelatlas.vercel.app/t/neuralangelo.md) or [NeuS](https://texelatlas.vercel.app/t/neus.md) when surfaces are thin, glossy or textureless and you can afford neural optimisation. Prefer [2D Gaussian Splatting](https://texelatlas.vercel.app/t/2d-gaussian-splatting.md) when you also want fast novel-view rendering from the same capture.

## Cost

offline — GPU-bound; minutes to hours depending on resolution and image count.
Measured GPU Weight: 25.74× baseline (heavy) — 0.7979 ms median / 0.8223 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 25.38× baseline (heavy) — 0.4035 ms median (1.98× faster on L4).
Ampere A100 scaling: 16.35× baseline (moderate) — 0.471 ms median (1.69× faster on A100).

## Failure modes

- Textureless walls and sky give noisy or missing depth because photometric cost is flat
- Specular and transparent surfaces violate photo-consistency and produce holes or floating points
- Thin structures and foliage are smoothed away or fused into blobs
- Fused clouds carry view-dependent colour seams unless colours are blended carefully

## Engine support

- blender: plugin — `Blender add-on: Photogrammetry Importer (imports COLMAP dense / MVS output)` (evidence: https://github.com/SBCV/Blender-Addon-Photogrammetry-Importer, checked 2026-12-01) — Imports results; the MVS itself runs in COLMAP.

## Dataflow

- Inputs: photos, camera-poses
- Outputs: depth, normals, point-cloud
- Platforms: cuda

## Presets

### Multi-View Stereo (PatchMatch) — epipolar disparity & cost planes (left) vs recovered dense depth (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_BASELINE": 0.35,
  "P_COST_BANDS": 10,
  "P_CAM_SWEEP": 0.7,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_BASELINE = 0.35; // P Stereo Baseline [0.10, 0.75, 0.02]
const float P_COST_BANDS = 10.0; // P Sweep Planes [4.0, 20.0, 1.0]
const float P_CAM_SWEEP = 0.70; // P View Motion [0.0, 2.0, 0.05]
const float P_SPLIT = 0.48; // P Stereo / Depth Split [0.0, 1.0, 0.02]

float sdBox(vec3 p, vec3 b) {
  vec3 q = abs(p) - b;
  return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}

// Multi-depth architectural scene with rich foreground, midground, and background parallax layers
vec2 mapScene(vec3 p) {
  vec2 res = vec2(p.y + 0.72, 1.0);
  float dBack = p.z + 2.4; if (dBack < res.x) res = vec2(dBack, 2.0);
  float dArch1 = sdBox(p - vec3(-0.62, -0.15, -0.35), vec3(0.28, 0.56, 0.24)) - 0.02;
  if (dArch1 < res.x) res = vec2(dArch1, 3.0);
  float dSph = length(p - vec3(0.06, -0.24, -0.75)) - 0.44;
  if (dSph < res.x) res = vec2(dSph, 4.0);
  float dArch2 = sdBox(p - vec3(0.76, -0.22, -1.25), vec3(0.32, 0.50, 0.26)) - 0.02;
  if (dArch2 < res.x) res = vec2(dArch2, 5.0);
  return res;
}

vec3 calcNormal(vec3 p) {
  vec2 e = vec2(0.0025, 0.0);
  return normalize(vec3(
    mapScene(p + e.xyy).x - mapScene(p - e.xyy).x,
    mapScene(p + e.yxy).x - mapScene(p - e.yxy).x,
    mapScene(p + e.yyx).x - mapScene(p - e.yyx).x
  ));
}

// High-frequency surface texture required for PatchMatch NCC photometric matching
vec3 surfaceTexture(vec3 p, float matId) {
  float pat = sin(p.x * 16.0) * sin(p.y * 16.0) * sin(p.z * 16.0);
  float brick = smoothstep(0.05, 0.12, abs(fract(p.x * 4.0) - 0.5)) * smoothstep(0.05, 0.12, abs(fract(p.y * 6.0) - 0.5));
  vec3 base = vec3(0.58, 0.62, 0.68);
  if (matId > 2.5 && matId < 3.5) base = vec3(0.84, 0.50, 0.32);
  if (matId > 3.5 && matId < 4.5) base = vec3(0.28, 0.66, 0.78);
  if (matId > 4.5) base = vec3(0.76, 0.72, 0.42);
  return base * (0.76 + 0.24 * brick) * (0.88 + 0.12 * pat);
}

// Trace camera view and return (depth, matId, shadedRGB)
void renderView(vec3 ro, vec3 rd, out float depth, out vec3 col, out vec3 nOut) {
  float t = 0.0;
  float matId = 0.0;
  bool hit = false;
  for (int i = 0; i < 60; i++) {
    vec2 h = mapScene(ro + rd * t);
    if (h.x < 0.0025) { hit = true; matId = h.y; break; }
    t += h.x;
    if (t > 9.0) break;
  }
  depth = hit ? t : 9.0;
  nOut = vec3(0.0, 0.0, 1.0);
  if (!hit) {
    col = vec3(0.04, 0.06, 0.10);
    return;
  }
  vec3 p = ro + rd * t;
  nOut = calcNormal(p);
  vec3 lDir = normalize(vec3(0.55, 0.80, 0.48));
  float diff = max(dot(nOut, lDir), 0.0);
  col = surfaceTexture(p, matId) * (0.28 + 0.82 * diff);
}

vec3 turboDepth(float d) {
  float t = clamp(d, 0.0, 1.0);
  vec3 c0 = vec3(0.10, 0.14, 0.48);
  vec3 c1 = vec3(0.10, 0.78, 0.86);
  vec3 c2 = vec3(0.96, 0.84, 0.22);
  vec3 c3 = vec3(0.96, 0.26, 0.18);
  if (t < 0.33) return mix(c0, c1, t * 3.0);
  if (t < 0.66) return mix(c1, c2, (t - 0.33) * 3.0);
  return mix(c2, c3, (t - 0.66) * 3.0);
}

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 screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool isDepth = screenX >= split;
  float base = clamp(P_BASELINE, 0.08, 0.80);
  float nBands = clamp(floor(P_COST_BANDS + 0.5), 4.0, 22.0);
  float sway = sin(iTime * max(P_CAM_SWEEP, 0.0) * 0.75) * 0.28;

  // Reference camera (center) and stereo source camera (offset along epipolar baseline X)
  vec3 roRef = vec3(sway, 0.12, 2.25);
  vec3 roSrc = vec3(sway + base, 0.12, 2.25);
  vec3 rd = normalize(vec3(uv, -1.52));

  float dRef, dSrc;
  vec3 cRef, cSrc, nRef, nSrc;
  renderView(roRef, rd, dRef, cRef, nRef);

  vec3 col;
  if (!isDepth) {
    // Left: Epipolar stereo anaglyph parallax (Red=ref cam, Cyan=source cam) + horizontal epipolar scanlines
    renderView(roSrc, rd, dSrc, cSrc, nSrc);
    float lRef = dot(cRef, vec3(0.299, 0.587, 0.114));
    float lSrc = dot(cSrc, vec3(0.299, 0.587, 0.114));
    col = vec3(lRef * 1.15, lSrc * 0.95, lSrc * 1.10);
    // Horizontal epipolar lines showing 1D stereo disparity search rows
    float epiLine = smoothstep(0.055, 0.012, abs(fract(uv.y * 12.0) - 0.5));
    col = mix(col, vec3(0.95, 0.88, 0.34), epiLine * 0.24);
  } else {
    // Right: PatchMatch MVS recovered inverse-depth map (1 / z) + plane-sweep iso-cost bands & normal shading
    float invZ = clamp((1.0 / max(dRef, 1.0) - 0.16) * 2.2, 0.0, 1.0);
    vec3 dCol = turboDepth(invZ);
    // Animated active plane-sweep hypothesis slice passing through the cost volume
    float activeSweep = fract(iTime * 0.25);
    float sweepHit = smoothstep(0.045, 0.008, abs(invZ - activeSweep));
    float planeBands = smoothstep(0.06, 0.015, abs(fract(invZ * nBands) - 0.5));

    float nShade = 0.65 + 0.35 * max(dot(nRef, normalize(vec3(0.5, 0.8, 0.5))), 0.0);
    col = dCol * nShade;
    col = mix(col, vec3(0.04, 0.07, 0.12), planeBands * 0.34);
    col = mix(col, vec3(1.0, 0.98, 0.90), sweepHit * 0.85);
  }

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - 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.

## Combines with

- [Structure-from-Motion (COLMAP)](https://texelatlas.vercel.app/t/structure-from-motion-colmap.md): SfM provides the calibrated cameras that MVS needs to compare views.

## Combination ideas

- [Progressive radiosity relighting on PatchMatch multi-view stereo rooms](https://texelatlas.vercel.app/ideas/patchmatch-mvs-radiosity-relighting/)

## Sources

1. [primary] Johannes L. Schönberger, Enliang Zheng, Jan-Michael Frahm, Marc Pollefeys (2016) Pixelwise View Selection for Unstructured Multi-View Stereo. Lecture Notes in Computer Science. https://doi.org/10.1007/978-3-319-46487-9_31 (verified via crossref on 2026-11-29)
2. [implementation] colmap (2014) colmap/colmap. https://github.com/colmap/colmap License: NOASSERTION. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Multi-View Stereo (PatchMatch, COLMAP)." https://texelatlas.vercel.app/t/multi-view-stereo-patchmatch/ (accessed 2026-12-01).
