Score Distillation Sampling (DreamFusion)
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.
Also known as SDS, DreamFusion
In the family Generative & learned 3D, text-to-3D by optimisation
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 | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
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
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) or Hunyuan3D 2.0 when you want an asset in seconds from a feed-forward model trained on 3D data, and Large Reconstruction Model (LRM) when you have an input image. Prefer Zero-1-to-3 as the guidance model when conditioning on one photograph.
Field marks
- 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
Presets
Score Distillation Sampling (DreamFusion) — noisy score gradient field (left) vs sculpted 3D NeRF/SDF (right)
{
"P_NOISE_T": 0.52,
"P_CFG_GAIN": 1.15,
"P_ROT_SPEED": 0.55,
"P_SPLIT": 0.48
}Show GLSL (126 lines)
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.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| score-distillation-sampling-live | Tesla T4 1920x1080 | 43.9× baseline (heavy) · 1.44 ms / 1.56 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| score-distillation-sampling-live | NVIDIA L4 1920x1080 | 38.4× baseline (heavy) · 0.611 ms / 0.616 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| score-distillation-sampling-live | NVIDIA A100-SXM4-40GB 1920x1080 | 30.1× baseline (heavy) · 0.866 ms / 0.877 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Mip-NeRF 360; cited by Hunyuan3D 2.0, Hunyuan3D-Paint, InstantMesh, Large Reconstruction Model (LRM), LL3M (Large Language 3D Modelers), MeshAnything, MeshGPT, Paint3D, Point-E, Shap-E, StopThePop (Sorted Gaussian Splatting), TexFusion, Text2Tex, TRELLIS (Structured 3D Latents), TripoSR, Zero-1-to-3.
Crosses
- Zero-1-to-3: 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
- primaryBen Poole, Ajay Jain, Jonathan T. Barron, Ben Mildenhall (2022). DreamFusion: Text-to-3D using 2D Diffusion. arXiv preprint (cs.CV).Verified via arxiv · 2026-11-29arXiv:2209.14988
- implementationashawkey (2022). ashawkey/stable-dreamfusion. Text-to-3D & Image-to-3D & Mesh Exportation with NeRF + Diffusion.GitHub API · license Apache-2.0 · 2026-11-29