---
id: "score-distillation-sampling"
title: "Score Distillation Sampling (DreamFusion)"
aliases: [SDS, DreamFusion]
domain: "genai"
stage: "generation"
realtime: "offline"
platforms: [cuda, python]
year_introduced: 2022
inputs: [text-prompt]
outputs: [radiance-field, mesh]
style: "both"
dynamic: "static"
cost: "offline"
authority: "Poole et al., 2022"
url: "https://texelatlas.vercel.app/t/score-distillation-sampling/"
sources_verified_at: "2026-11-29"
---
# Score Distillation Sampling (DreamFusion) (Poole et al., 2022)

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

## Reach for it when

- 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

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

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 (Structured 3D Latents)](https://texelatlas.vercel.app/t/trellis.md) or [Hunyuan3D 2.0](https://texelatlas.vercel.app/t/hunyuan3d-2.md) when you want an asset in seconds from a feed-forward model trained on 3D data, and [Large Reconstruction Model (LRM)](https://texelatlas.vercel.app/t/large-reconstruction-model.md) when you have an input image. Prefer [Zero-1-to-3](https://texelatlas.vercel.app/t/zero-1-to-3.md) as the guidance model when conditioning on one photograph.

## Cost

offline — Tens of minutes to hours per asset on one GPU in public implementations; qualitative, no benchmark claimed here.
Measured GPU Weight: 43.91× baseline (heavy) — 1.4445 ms median / 1.5597 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 38.4× baseline (heavy) — 0.6106 ms median (2.37× faster on L4).
Ampere A100 scaling: 30.07× baseline (heavy) — 0.866 ms median (1.67× faster on A100).

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

## Dataflow

- Inputs: text-prompt
- Outputs: radiance-field, mesh
- Platforms: cuda, python

## Presets

### Score Distillation Sampling (DreamFusion) — noisy score gradient field (left) vs sculpted 3D NeRF/SDF (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_NOISE_T": 0.52,
  "P_CFG_GAIN": 1.15,
  "P_ROT_SPEED": 0.55,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_NOISE_T = 0.52; // P Diffusion Noise t [0.05, 0.95, 0.02]
const float P_CFG_GAIN = 1.15; // P CFG Guidance [0.3, 2.0, 0.05]
const float P_ROT_SPEED = 0.55; // P Orbit Speed [0.0, 2.2, 0.05]
const float P_SPLIT = 0.48; // P SDS Field / 3D Split [0.0, 1.0, 0.02]

mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }

float hash31(vec3 p) {
  p = fract(p * 0.1031);
  p += dot(p, p.yzx + 33.33);
  return fract((p.x + p.y) * p.z);
}

// Target sculpted 3D implicit shape optimized via SDS (DreamFusion)
float mapTarget(vec3 p, float spin) {
  vec3 q = p;
  q.xz = rot2(spin * 0.48) * q.xz;
  // Sculpted fluted vase / chalice with glowing core ring
  float rXZ = length(q.xz);
  float profile = 0.36 + 0.14 * sin(q.y * 5.2 + 0.4) - 0.18 * q.y * q.y;
  float flutes = 0.032 * cos(atan(q.z, q.x) * 8.0);
  float dVase = max(rXZ - (profile + flutes), abs(q.y) - 0.64);
  float dRing = length(vec2(rXZ - 0.58, q.y - 0.08)) - 0.075;
  return min(dVase, dRing) * 0.78;
}

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

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);
  float noiseT = clamp(P_NOISE_T, 0.05, 0.95);
  float cfg = clamp(P_CFG_GAIN, 0.25, 2.2);
  float spin = iTime * max(P_ROT_SPEED, 0.0);

  vec3 ro = vec3(0.0, 0.16, 2.38);
  vec3 rd = normalize(vec3(uv - vec2(0.0, 0.03), -1.52));
  vec3 bg = mix(vec3(0.022, 0.026, 0.048), vec3(0.058, 0.068, 0.118), smoothstep(-0.55, 0.55, uv.y));
  vec3 col = bg;

  if (screenX < split) {
    // Left: Volumetric SDS score residual field (eps_hat - eps) pushing noisy latent cloud onto the target SDF
    float b = dot(ro, rd);
    float c = dot(ro, ro) - 1.15 * 1.15;
    float disc = b * b - c;
    if (disc > 0.0) {
      float t0 = max(-b - sqrt(disc), 0.2);
      float t1 = -b + sqrt(disc);
      float dt = (t1 - t0) / 36.0;
      vec3 acc = vec3(0.0);
      float T = 1.0;
      for (int i = 0; i < 36; i++) {
        float t = t0 + (float(i) + 0.5) * dt;
        vec3 p = ro + rd * t;
        float d = mapTarget(p, spin);
        // Score gradient pushes inward (amber) outside surface and outward (cyan) inside surface
        float nVal = hash31(floor(p * 14.0 + vec3(0.0, iTime * 1.6, 0.0))) - 0.5;
        float band = exp(-abs(d) * (9.0 - 5.5 * noiseT));
        float sigma = band * (2.6 + 1.4 * abs(nVal)) * (0.4 + 0.6 * cfg);
        vec3 gradCol = (d > 0.0)
          ? mix(vec3(0.98, 0.48, 0.14), vec3(1.0, 0.86, 0.35), smoothstep(0.0, 0.22, d))
          : vec3(0.14, 0.82, 0.96);
        // Iso-level score shells visualizing gradient descent steps
        float iso = 0.65 + 0.35 * cos(d * 38.0 - iTime * 4.0);
        float a = 1.0 - exp(-sigma * dt);
        acc += T * a * gradCol * iso * (0.85 + 0.4 * nVal);
        T *= (1.0 - a);
        if (T < 0.02) break;
      }
      col = acc + T * bg;
    }
  } else {
    // Right: Relightable DreamFusion 3D surface optimized under CFG guidance
    float t = 0.0;
    bool hit = false;
    for (int i = 0; i < 56; i++) {
      float d = mapTarget(ro + rd * t, spin);
      if (d < 0.0025) { hit = true; break; }
      t += d;
      if (t > 5.0) break;
    }
    if (hit) {
      vec3 p = ro + rd * t;
      vec3 n = calcNormal(p, spin);
      vec3 objP = p;
      objP.xz = rot2(spin * 0.48) * objP.xz;

      vec3 l1 = normalize(vec3(0.60, 0.78, 0.50));
      vec3 l2 = normalize(vec3(-0.70, 0.10, 0.55));
      float diff1 = max(dot(n, l1), 0.0);
      float diff2 = max(dot(n, l2), 0.0);
      float spec = pow(max(dot(n, normalize(l1 - rd)), 0.0), 40.0);
      float fres = pow(1.0 - max(dot(n, -rd), 0.0), 3.0);

      // CFG saturation boost characteristic of DreamFusion SDS
      float ringMask = smoothstep(0.50, 0.56, length(objP.xz));
      vec3 ceramic = mix(vec3(0.86, 0.34, 0.22), vec3(0.96, 0.76, 0.32), smoothstep(-0.55, 0.55, objP.y));
      ceramic = mix(ceramic, vec3(0.16, 0.78, 0.92), ringMask);
      // Saturation boost with CFG
      float lum = dot(ceramic, vec3(0.299, 0.587, 0.114));
      ceramic = mix(vec3(lum), ceramic, clamp(0.65 + 0.45 * cfg, 0.5, 1.5));

      col = ceramic * (0.26 + 0.82 * diff1 + 0.24 * diff2)
          + vec3(1.0, 0.96, 0.88) * spec * 0.50
          + vec3(0.98, 0.62, 0.32) * fres * 0.34;
    }
  }

  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.

## Lineage

- extended by [DreamGaussian](https://texelatlas.vercel.app/t/dreamgaussian.md)

## Combines with

- [Zero-1-to-3](https://texelatlas.vercel.app/t/zero-1-to-3.md): 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.

## Sources

1. [primary] Ben Poole, Ajay Jain, Jonathan T. Barron, Ben Mildenhall (2022) DreamFusion: Text-to-3D using 2D Diffusion. arXiv preprint (cs.CV). https://arxiv.org/abs/2209.14988 (verified via arxiv on 2026-11-29)
2. [implementation] ashawkey (2022) ashawkey/stable-dreamfusion. https://github.com/ashawkey/stable-dreamfusion License: Apache-2.0. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Score Distillation Sampling (DreamFusion)." https://texelatlas.vercel.app/t/score-distillation-sampling/ (accessed 2026-12-01).
