{
 "id": "score-distillation-sampling",
 "title": "Score Distillation Sampling (DreamFusion)",
 "aliases": [
  "SDS",
  "DreamFusion"
 ],
 "domain": "genai",
 "subdomain": "text-to-3D by optimisation",
 "stage": "generation",
 "realtime": "offline",
 "platforms": [
  "cuda",
  "python"
 ],
 "year_introduced": 2022,
 "inputs": [
  "text-prompt"
 ],
 "outputs": [
  "radiance-field",
  "mesh"
 ],
 "style": "both",
 "dynamic": "static",
 "summary": "Optimises a 3D representation so that its renders look plausible to a frozen 2D text-to-image diffusion model, using the denoiser residual as a gradient instead of a pixel loss.",
 "how_it_works": "A randomly initialised NeRF (or later a mesh / Gaussian set) is rendered from a random camera. The render is noised to a random timestep, the frozen diffusion model predicts the noise given the text prompt (with a large classifier-free guidance weight), and the difference between predicted and injected noise is treated as the gradient on the render. It is back-propagated through the renderer only, skipping the denoiser Jacobian, which makes each step cheap in memory. Thousands of such steps with view-dependent prompt suffixes (\"front view\", \"back view\") sculpt geometry and colour that every viewpoint agrees on. Because no 3D training data is used, the method inherits the 2D model's vocabulary, but also its biases and its habit of mode-seeking.",
 "when_to_use": "Choose it when you need open-vocabulary 3D from text and have GPU hours per asset to spend, or as the loss inside a larger pipeline (texturing, editing, avatar fitting). Prefer `trellis` or `hunyuan3d-2` when you want an asset in seconds from a feed-forward model trained on 3D data, and `large-reconstruction-model` when you have an input image. Prefer `zero-1-to-3` as the guidance model when conditioning on one photograph.",
 "cost": {
  "class": "offline",
  "notes": "Tens of minutes to hours per asset on one GPU in public implementations; qualitative, no benchmark claimed here."
 },
 "failure_modes": [
  "Janus problem: multiple faces because the 2D prior has no notion of a consistent viewpoint",
  "Over-saturated, over-smooth colours caused by the very high guidance scale needed to make the signal strong enough",
  "Mode-seeking collapse yields low-diversity, cartoon-like surfaces and little fine geometric detail",
  "Floaters and noisy density in the NeRF unless regularised",
  "Each asset needs a fresh optimisation run, so iteration is slow"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "arxiv:2209.14988",
   "type": "paper",
   "title": "DreamFusion: Text-to-3D using 2D Diffusion",
   "authors": [
    "Ben Poole",
    "Ajay Jain",
    "Jonathan T. Barron",
    "Ben Mildenhall"
   ],
   "year": 2022,
   "venue": "arXiv preprint (cs.CV)",
   "url": "https://arxiv.org/abs/2209.14988",
   "ids": {
    "arxiv": "2209.14988"
   },
   "license": null,
   "extra": {
    "arxiv_version": "1",
    "category": "cs.CV"
   },
   "provenance": {
    "title": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=2209.14988",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=2209.14988",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=2209.14988",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=2209.14988",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=2209.14988",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "poole2022dreamfusion"
  },
  {
   "role": "implementation",
   "key": "gh:ashawkey/stable-dreamfusion",
   "type": "code",
   "title": "ashawkey/stable-dreamfusion",
   "description": "Text-to-3D & Image-to-3D & Mesh Exportation with NeRF + Diffusion.",
   "authors": [
    "ashawkey"
   ],
   "year": 2022,
   "venue": "GitHub",
   "url": "https://github.com/ashawkey/stable-dreamfusion",
   "ids": {
    "repo": "ashawkey/stable-dreamfusion"
   },
   "license": "Apache-2.0",
   "extra": {
    "stars": 8883,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2023-12-10T23:17:27Z",
    "language": "Python",
    "homepage": null,
    "license_name": "Apache License 2.0"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ashawkey/stable-dreamfusion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ashawkey/stable-dreamfusion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ashawkey/stable-dreamfusion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ashawkey/stable-dreamfusion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ashawkey/stable-dreamfusion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ashawkey/stable-dreamfusion",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "ashawkey2022ashawkey"
  }
 ],
 "presets": [
  {
   "id": "score-distillation-sampling-live",
   "title": "Score Distillation Sampling (DreamFusion) — noisy score gradient field (left) vs sculpted 3D NeRF/SDF (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_NOISE_T": 0.52,
    "P_CFG_GAIN": 1.15,
    "P_ROT_SPEED": 0.55,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_NOISE_T = 0.52; // P Diffusion Noise t [0.05, 0.95, 0.02]\nconst float P_CFG_GAIN = 1.15; // P CFG Guidance [0.3, 2.0, 0.05]\nconst float P_ROT_SPEED = 0.55; // P Orbit Speed [0.0, 2.2, 0.05]\nconst float P_SPLIT = 0.48; // P SDS Field / 3D Split [0.0, 1.0, 0.02]\n\nmat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }\n\nfloat hash31(vec3 p) {\n  p = fract(p * 0.1031);\n  p += dot(p, p.yzx + 33.33);\n  return fract((p.x + p.y) * p.z);\n}\n\n// Target sculpted 3D implicit shape optimized via SDS (DreamFusion)\nfloat mapTarget(vec3 p, float spin) {\n  vec3 q = p;\n  q.xz = rot2(spin * 0.48) * q.xz;\n  // Sculpted fluted vase / chalice with glowing core ring\n  float rXZ = length(q.xz);\n  float profile = 0.36 + 0.14 * sin(q.y * 5.2 + 0.4) - 0.18 * q.y * q.y;\n  float flutes = 0.032 * cos(atan(q.z, q.x) * 8.0);\n  float dVase = max(rXZ - (profile + flutes), abs(q.y) - 0.64);\n  float dRing = length(vec2(rXZ - 0.58, q.y - 0.08)) - 0.075;\n  return min(dVase, dRing) * 0.78;\n}\n\nvec3 calcNormal(vec3 p, float spin) {\n  vec2 e = vec2(0.0025, 0.0);\n  return normalize(vec3(\n    mapTarget(p + e.xyy, spin) - mapTarget(p - e.xyy, spin),\n    mapTarget(p + e.yxy, spin) - mapTarget(p - e.yxy, spin),\n    mapTarget(p + e.yyx, spin) - mapTarget(p - e.yyx, spin)\n  ));\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  float noiseT = clamp(P_NOISE_T, 0.05, 0.95);\n  float cfg = clamp(P_CFG_GAIN, 0.25, 2.2);\n  float spin = iTime * max(P_ROT_SPEED, 0.0);\n\n  vec3 ro = vec3(0.0, 0.16, 2.38);\n  vec3 rd = normalize(vec3(uv - vec2(0.0, 0.03), -1.52));\n  vec3 bg = mix(vec3(0.022, 0.026, 0.048), vec3(0.058, 0.068, 0.118), smoothstep(-0.55, 0.55, uv.y));\n  vec3 col = bg;\n\n  if (screenX < split) {\n    // Left: Volumetric SDS score residual field (eps_hat - eps) pushing noisy latent cloud onto the target SDF\n    float b = dot(ro, rd);\n    float c = dot(ro, ro) - 1.15 * 1.15;\n    float disc = b * b - c;\n    if (disc > 0.0) {\n      float t0 = max(-b - sqrt(disc), 0.2);\n      float t1 = -b + sqrt(disc);\n      float dt = (t1 - t0) / 36.0;\n      vec3 acc = vec3(0.0);\n      float T = 1.0;\n      for (int i = 0; i < 36; i++) {\n        float t = t0 + (float(i) + 0.5) * dt;\n        vec3 p = ro + rd * t;\n        float d = mapTarget(p, spin);\n        // Score gradient pushes inward (amber) outside surface and outward (cyan) inside surface\n        float nVal = hash31(floor(p * 14.0 + vec3(0.0, iTime * 1.6, 0.0))) - 0.5;\n        float band = exp(-abs(d) * (9.0 - 5.5 * noiseT));\n        float sigma = band * (2.6 + 1.4 * abs(nVal)) * (0.4 + 0.6 * cfg);\n        vec3 gradCol = (d > 0.0)\n          ? mix(vec3(0.98, 0.48, 0.14), vec3(1.0, 0.86, 0.35), smoothstep(0.0, 0.22, d))\n          : vec3(0.14, 0.82, 0.96);\n        // Iso-level score shells visualizing gradient descent steps\n        float iso = 0.65 + 0.35 * cos(d * 38.0 - iTime * 4.0);\n        float a = 1.0 - exp(-sigma * dt);\n        acc += T * a * gradCol * iso * (0.85 + 0.4 * nVal);\n        T *= (1.0 - a);\n        if (T < 0.02) break;\n      }\n      col = acc + T * bg;\n    }\n  } else {\n    // Right: Relightable DreamFusion 3D surface optimized under CFG guidance\n    float t = 0.0;\n    bool hit = false;\n    for (int i = 0; i < 56; i++) {\n      float d = mapTarget(ro + rd * t, spin);\n      if (d < 0.0025) { hit = true; break; }\n      t += d;\n      if (t > 5.0) break;\n    }\n    if (hit) {\n      vec3 p = ro + rd * t;\n      vec3 n = calcNormal(p, spin);\n      vec3 objP = p;\n      objP.xz = rot2(spin * 0.48) * objP.xz;\n\n      vec3 l1 = normalize(vec3(0.60, 0.78, 0.50));\n      vec3 l2 = normalize(vec3(-0.70, 0.10, 0.55));\n      float diff1 = max(dot(n, l1), 0.0);\n      float diff2 = max(dot(n, l2), 0.0);\n      float spec = pow(max(dot(n, normalize(l1 - rd)), 0.0), 40.0);\n      float fres = pow(1.0 - max(dot(n, -rd), 0.0), 3.0);\n\n      // CFG saturation boost characteristic of DreamFusion SDS\n      float ringMask = smoothstep(0.50, 0.56, length(objP.xz));\n      vec3 ceramic = mix(vec3(0.86, 0.34, 0.22), vec3(0.96, 0.76, 0.32), smoothstep(-0.55, 0.55, objP.y));\n      ceramic = mix(ceramic, vec3(0.16, 0.78, 0.92), ringMask);\n      // Saturation boost with CFG\n      float lum = dot(ceramic, vec3(0.299, 0.587, 0.114));\n      ceramic = mix(vec3(lum), ceramic, clamp(0.65 + 0.45 * cfg, 0.5, 1.5));\n\n      col = ceramic * (0.26 + 0.82 * diff1 + 0.24 * diff2)\n          + vec3(1.0, 0.96, 0.88) * spec * 0.50\n          + vec3(0.98, 0.62, 0.32) * fres * 0.34;\n    }\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "score-distillation-sampling",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T20:35:55.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.5841,
      "std": 0.2355,
      "min": 0.1556,
      "max": 0.924
     },
     "image": "/specimens/score-distillation-sampling-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "zero-1-to-3",
  "shap-e",
  "trellis"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "zero-1-to-3",
   "why": "Zero-1-to-3 supplies a view-conditioned diffusion prior whose gradients SDS can back-propagate into a 3D model from a single input image."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/genai/score-distillation-sampling.json"
 },
 "solves": [
  "generate a 3d asset from a text prompt using a 2d model",
  "no 3d training data but have a text-to-image model",
  "optimise a 3d representation to look plausible from every view",
  "text-to-3d without a feed-forward generator",
  "edit or texture 3d using diffusion guidance"
 ],
 "authority": "Poole et al., 2022",
 "url": "https://texelatlas.vercel.app/t/score-distillation-sampling/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 43.91,
  "tier": "heavy",
  "p50_ms": 1.4445,
  "p95_ms": 1.5597,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "score-distillation-sampling-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 38.4,
   "tier": "heavy",
   "p50_ms": 0.6106,
   "p95_ms": 0.6163,
   "speedup_x": 2.37,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 30.07,
   "tier": "heavy",
   "p50_ms": 0.866,
   "p95_ms": 0.8774,
   "speedup_x": 1.67,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}