Depth Anything V2
A monocular relative-depth model trained on synthetic labels plus pseudo-labelled real images, giving sharp, fine-detail depth maps from a single RGB image at several model sizes.
In the family Capture, reconstruction & splatting, monocular depth
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 | External monocular depth neural network; not shipped natively. |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Depth Anything V2 uses a DINOv2-based encoder with a DPT decoder. Its main contribution is the training recipe: a large teacher is first trained only on accurate synthetic depth, avoiding the noisy labels of real-world depth sensors, then used to pseudo-label millions of unlabelled real images. Smaller student models are trained on these pseudo labels, which transfers synthetic sharpness to real images. Output is affine-invariant relative inverse depth, not metric, so scale and shift must be recovered separately if needed; fine-tuned metric variants exist. It handles thin structures, transparency and reflective surfaces better than earlier V1 and MiDaS-style models.
When to choose it
Reach for it when
- need depth from a single photo quickly
- want parallax effect from one image
- depth prior to condition a diffusion model
- monocular depth maps look blurry and lose fine detail
- get a depth guide for splat training without extra sensors
Choose it for fast per-frame relative depth, depth conditioning for diffusion, parallax effects or depth priors for splat training. Prefer Depth Pro or MoGe (Monocular Geometry Estimation) when you need metric scale or intrinsics, and VGGT (Visual Geometry Grounded Transformer) when multiple views are available and consistency matters.
Field marks
- Output is relative, so depth scale and shift are inconsistent across frames in video (flicker)
- Sky and far regions can be unreliable
- Edges are sharp visually but not metrically accurate for geometry
- Metric conversion needs fine-tuned variants or external scale
Presets
Depth Anything V2 — single RGB input view (left) vs fine-detail monocular relative depth (right)
{
"P_DEPTH_CONT": 1,
"P_CAM_SWAY": 0.75,
"P_EDGE_SHARP": 1,
"P_SPLIT": 0.48
}Show GLSL (121 lines)
const float P_DEPTH_CONT = 1.0; // P Depth Contrast [0.4, 1.8, 0.05]
const float P_CAM_SWAY = 0.75; // P Camera Sway [0.0, 2.0, 0.05]
const float P_EDGE_SHARP = 1.0; // P Fine Structure [0.2, 1.5, 0.05]
const float P_SPLIT = 0.48; // P RGB / 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);
}
// Architectural colonnade with thin foreground railings, mid-ground arch, and distant tower
vec2 mapScene(vec3 p) {
vec2 res = vec2(p.y + 0.85, 1.0); // stone floor
// Foreground thin railing posts & handrail (showcases Depth Anything V2 fine thin-structure fidelity!)
float rx = mod(p.x + 0.25, 0.5) - 0.25;
float post = sdBox(vec3(rx, p.y + 0.42, p.z - 0.15), vec3(0.022, 0.42, 0.022));
float rail = sdBox(p - vec3(0.0, -0.02, 0.15), vec3(2.4, 0.025, 0.03));
float dRail = min(post, rail);
if (dRail < res.x) res = vec2(dRail, 2.0);
// Midground colonnade pillars & floating bronze sphere
float colL = sdBox(p - vec3(-0.78, 0.05, -1.15), vec3(0.18, 0.90, 0.18));
float colR = sdBox(p - vec3(0.78, 0.05, -1.15), vec3(0.18, 0.90, 0.18));
float lintel = sdBox(p - vec3(0.0, 0.82, -1.15), vec3(1.15, 0.14, 0.22));
float dArch = min(min(colL, colR), lintel);
if (dArch < res.x) res = vec2(dArch, 3.0);
float dOrb = length(p - vec3(0.02, -0.18, -1.10)) - 0.34;
if (dOrb < res.x) res = vec2(dOrb, 4.0);
// Distant monumental obelisk / tower
float dTower = sdBox(p - vec3(-0.18, 0.35, -3.45), vec3(0.36, 1.25, 0.36));
if (dTower < res.x) res = vec2(dTower, 5.0);
return res;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.003, 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
));
}
// Inferno-like perceptual disparity colormap (bright yellow-white = near, crimson = mid, deep indigo = far)
vec3 infernoRamp(float d) {
float t = clamp(d, 0.0, 1.0);
vec3 c0 = vec3(0.03, 0.02, 0.14);
vec3 c1 = vec3(0.36, 0.07, 0.44);
vec3 c2 = vec3(0.84, 0.26, 0.24);
vec3 c3 = vec3(0.98, 0.68, 0.16);
vec3 c4 = vec3(0.99, 0.97, 0.68);
if (t < 0.25) return mix(c0, c1, t * 4.0);
if (t < 0.50) return mix(c1, c2, (t - 0.25) * 4.0);
if (t < 0.75) return mix(c2, c3, (t - 0.50) * 4.0);
return mix(c3, c4, (t - 0.75) * 4.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 cont = clamp(P_DEPTH_CONT, 0.3, 2.0);
float sway = clamp(P_CAM_SWAY, 0.0, 2.0);
float sharp = clamp(P_EDGE_SHARP, 0.1, 1.6);
vec3 ro = vec3(sin(iTime * 0.55 * sway) * 0.36, 0.24, 1.65);
vec3 rd = normalize(vec3(uv.x - sin(iTime * 0.55 * sway) * 0.08, uv.y - 0.06, -1.35));
float t = 0.05;
vec2 hit = vec2(12.0, 0.0);
for (int i = 0; i < 60; i++) {
vec2 h = mapScene(ro + rd * t);
if (h.x < 0.003) { hit = vec2(t, h.y); break; }
t += h.x;
if (t > 12.0) break;
}
vec3 col;
if (!isDepth) {
// Left: Standard monocular RGB camera view
vec3 sky = mix(vec3(0.86, 0.66, 0.50), vec3(0.24, 0.44, 0.74), smoothstep(-0.08, 0.52, rd.y));
col = sky;
if (hit.y > 0.5) {
vec3 p = ro + rd * hit.x;
vec3 n = calcNormal(p);
vec3 lDir = normalize(vec3(0.58, 0.78, 0.48));
float diff = max(dot(n, lDir), 0.0);
float spec = pow(max(dot(n, normalize(lDir - rd)), 0.0), 32.0);
vec3 alb = vec3(0.76, 0.72, 0.66);
if (hit.y < 1.5) {
vec2 tile = floor(p.xz * 2.0);
alb = mix(vec3(0.32, 0.30, 0.28), vec3(0.52, 0.48, 0.44), mod(tile.x + tile.y, 2.0));
} else if (hit.y < 2.5) alb = vec3(0.16, 0.20, 0.26);
else if (hit.y < 3.5) alb = vec3(0.82, 0.74, 0.64);
else if (hit.y < 4.5) alb = vec3(0.88, 0.46, 0.22);
else alb = vec3(0.46, 0.52, 0.62);
col = alb * (0.28 + 0.85 * diff) + vec3(1.0) * spec * (hit.y > 3.5 && hit.y < 4.5 ? 0.55 : 0.16);
col = mix(col, sky, 1.0 - exp(-hit.x * 0.08));
}
} else {
// Right: Crisp affine-invariant inverse-depth disparity (1/z) predicted by Depth Anything V2
float invZ = (hit.y > 0.5) ? (1.28 / max(hit.x, 0.35)) : 0.02;
float disp = clamp(pow(clamp(invZ, 0.0, 1.0), 0.85 / cont), 0.0, 1.0);
// Subtle iso-depth contours to reveal smooth continuous metric gradient
float iso = 0.90 + 0.10 * cos(disp * 42.0 * sharp);
col = infernoRamp(disp) * iso;
}
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 |
|---|---|---|---|
| depth-anything-v2-live | Tesla T4 1920x1080 | 34.9× baseline (heavy) · 1.15 ms / 1.23 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| depth-anything-v2-live | NVIDIA L4 1920x1080 | 34.7× baseline (heavy) · 0.552 ms / 0.557 ms · 2.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| depth-anything-v2-live | NVIDIA A100-SXM4-40GB 1920x1080 | 23.1× baseline (heavy) · 0.665 ms / 0.669 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites 3D Gaussian Splatting, Segment Anything (SAM); cited by Depth Pro, MoGe (Monocular Geometry Estimation), VGGT (Visual Geometry Grounded Transformer).
Crosses
- Light shafts for any photo: Add sun shafts to a single photo or video frame in the browser, occluded by the real objects in the picture. Monocular depth supplies both the occluder mask and the per-pixel distance that sets how much haze sits in front.
- 3D Gaussian Splatting: Monocular depth priors regularise Gaussian training in sparse-view settings.
Sources
- primaryLihe Yang, Bingyi Kang, Zilong Huang, Zhen Zhao, Xiaogang Xu, Jiashi Feng et al. (2024). Depth Anything V2. arXiv preprint (cs.CV).Verified via arxiv · 2026-11-29arXiv:2406.09414
- implementationDepthAnything (2024). DepthAnything/Depth-Anything-V2. [NeurIPS 2024] Depth Anything V2. A More Capable Foundation Model for Monocular Depth EstimationGitHub API · license Apache-2.0 · 2026-11-29
- tutorialYang et al.. Depth Anything V2 project page. depth-anything-v2.github.io.Verified via live page · 2026-11-29