Multi-View Stereo (PatchMatch, COLMAP)
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.
Also known as MVS, patch-match stereo
In the family Capture, reconstruction & splatting, photogrammetry
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | Not applicable | Offline reconstruction/generative method, not an engine feature. |
| Unity | None found | |
| Unreal 5.7 | None found | External photogrammetry/MVS reconstruction pipeline; not built into Unreal Engine. |
| Blender 5.2 | Plugin | Blender add-on: Photogrammetry Importer (imports COLMAP dense / MVS output) docs Imports results; the MVS itself runs in COLMAP. |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
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
Choose it when you need an explicit dense surface from a photo set with known poses, e.g. for meshing and baking. Prefer Neuralangelo or NeuS when surfaces are thin, glossy or textureless and you can afford neural optimisation. Prefer 2D Gaussian Splatting when you also want fast novel-view rendering from the same capture.
Field marks
- 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
Presets
Multi-View Stereo (PatchMatch) — epipolar disparity & cost planes (left) vs recovered dense depth (right)
{
"P_BASELINE": 0.35,
"P_COST_BANDS": 10,
"P_CAM_SWEEP": 0.7,
"P_SPLIT": 0.48
}Show GLSL (131 lines)
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.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| multi-view-stereo-patchmatch-live | Tesla T4 1920x1080 | 25.7× baseline (heavy) · 0.798 ms / 0.822 ms | opengl-timer-query · 36 frames · GPU Weight Atlas · Colab T4 sweep |
| multi-view-stereo-patchmatch-live | NVIDIA L4 1920x1080 | 25.4× baseline (heavy) · 0.404 ms / 0.412 ms · 2.0× faster on L4 | opengl-timer-query · Cross-architecture validation |
| multi-view-stereo-patchmatch-live | NVIDIA A100-SXM4-40GB 1920x1080 | 16.4× baseline (moderate) · 0.471 ms / 0.477 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Progressive radiosity relighting on PatchMatch multi-view stereo rooms: Dense depth and normal maps recovered by PatchMatch MVS are clustered into planar architectural patches whose diffuse inter-reflection is solved by progressive radiosity, turning multi-view room photos into interactively relit global-illumination spaces.
- Structure-from-Motion (COLMAP): SfM provides the calibrated cameras that MVS needs to compare views.
Sources
- primaryJohannes L. Schönberger, Enliang Zheng, Jan-Michael Frahm, Marc Pollefeys (2016). Pixelwise View Selection for Unstructured Multi-View Stereo. Lecture Notes in Computer Science.Verified via crossref · 2026-11-29doi:10.1007/978-3-319-46487-9_31
- implementationcolmap (2014). colmap/colmap. COLMAP - Structure-from-Motion and Multi-View StereoGitHub API · license NOASSERTION · 2026-11-29