alanjiach@gmail.com

← all writing

Score distillation and 3D generation

study notes3D generation

Part of the generative visual computing notes.

A shared scene

Let θ\theta describe a scene and let g(θ,v)g(\theta,v) render it from camera vv. Score distillation sampling uses a pretrained image diffusion model to guide changes to θ\theta through rendered images.

This differs from ordinary image sampling. A reverse diffusion sampler updates an image state. SDS updates parameters that generate images. Different camera views share the same scene parameters, which couples their updates.

A surface that has no effect on the current image receives no gradient through that view. More noise samples from the same camera do not fix missing visibility. The camera distribution must expose the relevant scene structure.

The update

Render x=g(θ,v)x=g(\theta,v) and corrupt it using xt=atx+σtϵx_t=a_tx+\sigma_t\epsilon. Let the frozen teacher predict ϵ^(xt,t,c)\hat\epsilon(x_t,t,c) for prompt cc. A standard SDS update uses

∇θLSDS≈Ev,t,ϵ[w(t)Jg(θ,v)T(ϵ^−ϵ)].\nabla_\theta L_{\mathrm{SDS}}\approx \mathbb E_{v,t,\epsilon}\left[w(t)J_g(\theta,v)^T(\hat\epsilon-\epsilon)\right].

The time-dependent weight absorbs the chosen scaling convention. The renderer Jacobian converts an image-space correction into a scene-space gradient. Gradient descent moves opposite this gradient.

For a scalar example, take x=θ2x=\theta^2, θ=2\theta=2, residual ϵ^−ϵ=0.5\hat\epsilon-\epsilon=0.5, and weight two. The gradient is 2⋅4⋅0.5=42\cdot4\cdot0.5=4. A learning rate of 0.10.1 changes θ\theta to 1.61.6, so the rendered value decreases from four to 2.562.56.

Camera corrections must be mapped through their own Jacobians before averaging. Equal image residuals can produce opposite parameter gradients when the views depend differently on the scene.

Freezing and stopping gradients

Freezing the teacher’s weights does not remove derivatives with respect to its input. Standard SDS treats its residual as a supplied gradient. A surrogate implementation is

x = render(theta, camera)
xt = a * x + sigma * noise
residual = (teacher(xt, t, prompt) - noise).detach()
loss = weight * (residual * x).sum()
loss.backward()

The renderer remains on the backward path. Replacing this surrogate with the squared noise-prediction error introduces a derivative through the teacher and gives a different update.

Why subtract the sampled noise

For fixed scene, camera, and time, the renderer Jacobian is independent of the fresh Gaussian noise. Subtracting zero-mean noise can leave the expected update unchanged while changing its variance.

Consider ϵ^=b+kϵ\hat\epsilon=b+k\epsilon with Var⁡(ϵ)=1\operatorname{Var}(\epsilon)=1. The raw prediction has variance k2k^2. The residual has variance (k−1)2(k-1)^2. Subtraction reduces variance when k>1/2k>1/2 and increases it when k<1/2k<1/2. Zero mean alone does not establish a variance reduction.

Geometry and diversity

A plausible image prior does not guarantee consistent 3D geometry. Different views may each favor familiar frontal features, producing repeated faces or heads. Inspecting a held-out camera orbit helps expose these failures. Textureless and depth renders help distinguish geometry from painted appearance.

Variational score distillation represents multiple candidate scenes and learns an auxiliary model of their noisy renders. Scene updates compare the teacher’s prediction with that auxiliary prediction. The auxiliary model and the scene particles are trained in alternating steps. LoRA can reduce the number of parameters used to adapt the auxiliary network.

Varying the camera around one scene measures view consistency. Varying the scene at a fixed camera measures diversity across candidates. They answer different questions and should be reported separately.

Worked example: a renderer distributes the gradient

Consider a toy renderer with two outputs, x1=θ1+θ2x_1=\theta_1+\theta_2 and x2=θ1−θ2x_2=\theta_1-\theta_2. Suppose the weighted image-space residual supplied by the frozen diffusion model is [2,−2][2,-2]. Multiplying by the transpose of the renderer Jacobian gives the scene gradient [0,4][0,4]. The two residuals cancel for θ1\theta_1 and reinforce each other for θ2\theta_2.

This example separates two roles. The diffusion model provides an image-space direction, while the renderer determines how that direction changes the scene. A useful image prior does not by itself resolve ambiguity between views. Camera sampling and scene representation still matter.

Further reading

DreamFusion introduces score distillation for text-to-3D optimization. ProlificDreamer develops variational score distillation. Compare their treatment of a single scene estimate and a distribution of scene parameters.