---
id: "depth-anything-v2"
title: "Depth Anything V2"
domain: "capture"
stage: "capture"
realtime: "interactive"
platforms: [cuda, python, webgpu]
year_introduced: 2024
inputs: [photos]
outputs: [depth]
style: "both"
dynamic: "both"
cost: "medium"
authority: "Yang et al., 2024"
url: "https://texelatlas.vercel.app/t/depth-anything-v2/"
sources_verified_at: "2026-11-29"
---
# Depth Anything V2 (Yang et al., 2024)

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

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

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

Choose it for fast per-frame relative depth, depth conditioning for diffusion, parallax effects or depth priors for splat training. Prefer [Depth Pro](https://texelatlas.vercel.app/t/depth-pro.md) or [MoGe (Monocular Geometry Estimation)](https://texelatlas.vercel.app/t/moge.md) when you need metric scale or intrinsics, and [VGGT (Visual Geometry Grounded Transformer)](https://texelatlas.vercel.app/t/vggt.md) when multiple views are available and consistency matters.

## Cost

medium — Small variants run in real time on modern GPUs; large ones are interactive. Only the small model carries a permissive Apache-2.0 licence.
Measured GPU Weight: 34.92× baseline (heavy) — 1.1488 ms median / 1.2269 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 34.72× baseline (heavy) — 0.5521 ms median (2.08× faster on L4).
Ampere A100 scaling: 23.1× baseline (heavy) — 0.6653 ms median (1.73× faster on A100).

## Failure modes

- 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

## Dataflow

- Inputs: photos
- Outputs: depth
- Platforms: cuda, python, webgpu

## Presets

### Depth Anything V2 — single RGB input view (left) vs fine-detail monocular relative depth (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_DEPTH_CONT": 1,
  "P_CAM_SWAY": 0.75,
  "P_EDGE_SHARP": 1,
  "P_SPLIT": 0.48
}
```

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

## Combines with

- [3D Gaussian Splatting](https://texelatlas.vercel.app/t/gaussian-splatting-3dgs.md): Monocular depth priors regularise Gaussian training in sparse-view settings.

## Combination ideas

- [Light shafts for any photo](https://texelatlas.vercel.app/ideas/photo-depth-god-rays/)

## Sources

1. [primary] Lihe Yang, Bingyi Kang, Zilong Huang, Zhen Zhao, Xiaogang Xu, Jiashi Feng, Hengshuang Zhao (2024) Depth Anything V2. arXiv preprint (cs.CV). https://arxiv.org/abs/2406.09414 (verified via arxiv on 2026-11-29)
2. [implementation] DepthAnything (2024) DepthAnything/Depth-Anything-V2. https://github.com/DepthAnything/Depth-Anything-V2 License: Apache-2.0. (verified via github on 2026-11-29)
3. [tutorial] Yang et al. Depth Anything V2 project page. depth-anything-v2.github.io. https://depth-anything-v2.github.io/ (verified via http on 2026-11-29)

## Cite this entry

Texel. "Depth Anything V2." https://texelatlas.vercel.app/t/depth-anything-v2/ (accessed 2026-12-01).
