Graphics turns a scene description into pixels. Vision is the same problem run backwards: given the pixels, find the description. The oldest working recipe is to guess a scene, render it, compare the render with the photo, and fix the guess. That loop is called analysis by synthesis.
Learn why recovering a scene from pixels is hard (many scenes draw the same picture), how render-and-compare turns it into optimisation, what priors and gradients add, and why a trained encoder and a 2026 VLM agent are two answers to the same question.
The left image is a photo of a hidden scene. Move the shapes of your guess with the sliders and watch the loss. Then press Fit and let render-and-compare finish the job.
You need school algebra and the idea of a function. We build everything else from zero.
A toy renderer of two shapes on a 32 × 32 grid. "Fit" runs gradient descent on the pixel loss over six numbers (position and size of each shape), with gradients from finite differences and a coarse-to-fine blur. All numbers are illustrative.
Chapter 0
Meet the two directions between a scene and its pixels, and see why one is easy and the other is the whole of vision
You look at a photo of a kitchen. In a fraction of a second you know there is a table, a cup on it, and a lamp to the left. You know the cup is round, even though the photo only shows one side. You know the lamp is the light source.
None of that is in the pixels. A photo is only a grid of numbers: how much light hit each spot of the sensor. The table, the cup and the lamp are causes. The pixels are their effects. Seeing means working back from the effects to the causes.
Computer graphics does the opposite job. A scene description is a list of what is in the world: shapes, their positions and sizes, their materials, the lights and the camera. A renderer is a program that takes that description and computes the pixels. Graphics goes from causes to effects. It is a solved problem: films and games do it every day.
So here is the idea of this lesson, in one line. Inverse graphics treats vision as graphics run backwards: given the pixels, recover the scene description that would render them. If the description is a short program, vision becomes "find the program behind the picture".
Left: a scene program of four lines. Right: the image it renders. Click any pixel to see which line caused it. Change the resolution and compare how many numbers each side holds.
A toy renderer: each line paints one shape over the ones before it. Later lines cover earlier ones, as in a painter's algorithm.
Going forward, each pixel has exactly one answer. You run the program, you get the image. Going backward, the program is short and the image is huge. At 64 × 64 there are 4,096 pixel values, and the program holds 11 numbers. The image is a very redundant record of a few causes. That is what makes recovery possible at all.
But going backward also has traps. A shadow could be a dark object or a missing light. A small ball near the camera looks like a big ball far away. Chapter 2 shows these traps one by one.
The idea is old. Larry Roberts's 1963 MIT thesis, "Machine Perception of Three-Dimensional Solids", recovered block-world models from photos, and the 2026 VIGA paper still names it as the start of the field VIGA · §1. Ulf Grenander's pattern theory built a mathematics of images as patterns generated by rules. Alan Yuille and Daniel Kersten later summed up this tradition as "analysis by synthesis" Yuille & Kersten 2006. This lesson builds it from zero.
Chapter 1
Build a renderer from scratch as a plain function, from a list of numbers to a grid of pixels, and see what each number does
Start small. Our world is a flat square. It holds one ball, seen from above. Four numbers describe it: its centre x and y, its radius r, and its shade s (how much light it reflects, from 0 to 1). We call the list of numbers the scene parameters, written θ (theta).
The renderer visits every pixel. For each one, it measures the distance d from the pixel centre to the ball's centre. If d is less than r, the pixel is inside the ball and takes the shade s. Otherwise it stays black. That is the whole renderer.
Real renderers have to decide what happens at the edge. A pixel on the boundary is partly inside the ball. A hard renderer says "in" or "out". A soft renderer gives the pixel a coverage a between 0 and 1 that slides smoothly across the edge. Chapter 5 shows why this small choice matters so much. Here is the soft rule:
Worked: r = 0.20, d = 0.22, w = 0.02 → (r − d)/w = −1 → a = σ(−1) = 0.27 → with s = 0.9, pixel = 0.24
So a pixel just outside the edge still gets a little ink. With w = 0.005 instead, (r − d)/w = −4 and a = 0.018: almost nothing. Try it below.
Four sliders are the whole scene. Left: the rendered 32 × 32 image. Right: the pixel values along the middle row. Widen the edge and watch the step turn into a ramp.
The same renderer runs every toy on this page. Coordinates go from 0 to 1 across the image.
Here is the same renderer in Python, with no libraries beyond NumPy. Several shapes are painted in order, each over the last. The "painter's" rule handles occlusion for free.
import numpy as np
def render(shapes, n=32, w=0.01):
"""shapes: list of dicts {kind, x, y, r, s}. Returns an n x n image."""
c = (np.arange(n) + 0.5) / n # pixel centres in [0, 1]
X, Y = np.meshgrid(c, c) # each is (n, n)
img = np.zeros((n, n))
for sh in shapes: # painter's order: later covers earlier
dx, dy = X - sh["x"], Y - sh["y"]
if sh["kind"] == "disc":
edge = np.hypot(dx, dy) - sh["r"] # signed distance to the edge
else: # axis-aligned square
edge = np.maximum(abs(dx), abs(dy)) - sh["r"]
a = 1 / (1 + np.exp(edge / max(w, 1e-6))) # coverage in [0, 1]
img = img * (1 - a) + sh["s"] * a
return img
img = render([{"kind": "disc", "x": .5, "y": .5, "r": .2, "s": .9}])
print(img.shape, img.max().round(2)) # (32, 32) 0.9
Chapter 2
Slide along three families of different scenes that all render the exact same image
A function is easy to invert when each output comes from exactly one input. Rendering is not like that. Many different scenes give the same picture. Mathematicians call such a problem ill-posed (or under-constrained): the data alone do not fix a single answer.
The losses come from what a camera throws away. A camera keeps directions, not distances. It keeps the product of light and paint, not each one. And it keeps only the front surfaces. Each loss gives a family of scenes that look identical. Slide along each family below.
Pick an ambiguity. The slider changes the scene a lot. The image on the right does not change at all.
Pinhole camera with focal length 500 pixels; Lambertian shading (matte paint). All values are illustrative.
A pinhole camera divides by distance. An object of real radius R at distance Z appears with an image radius r of:
Worked: f = 500, R = 0.10 m, Z = 2 m → r = 25 px. R = 0.20 m, Z = 4 m → r = 25 px. Same image.
Only the ratio R / Z reaches the image. Double both and nothing changes. For matte paint, the brightness of a pixel is the product of the surface's paint and the light falling on it:
Worked: ρ = 0.8, L = 0.5 → b = 0.40 (facing the light). ρ = 0.4, L = 1.0 → b = 0.40. Same pixel.
The third trap needs no formula. Pixels show only the surfaces nearest the camera. Anything behind them, or no thing at all, gives the same picture.
Chapter 3
Score any guess by rendering it and measuring how far its pixels are from the photo, and turn seeing into finding the lowest score
We cannot run the renderer backwards. But we can run it forwards as often as we like. That suggests a plan. Guess a scene. Render the guess. Compare the render with the photo. If they differ, change the guess and try again. This is analysis by synthesis: you analyse an image by synthesising candidates for it.
To compare, we need one number that says how wrong a guess is. The simplest is the pixel loss: the mean squared difference between the render and the observed image.
Worked, a 4-pixel image: render (0.9, 0.9, 0, 0), photo (0.9, 0, 0.9, 0) → differences (0, 0.9, −0.9, 0) → L = (0 + 0.81 + 0.81 + 0) / 4 = 0.405
Now vision is a search problem: find the θ with the lowest L. The best guess, written θ*, is the argmin (the argument that minimises) of the loss.
A hidden ball made the blue photo. Move your warm guess. The difference image shows warm where your render has ink the photo lacks, and blue where the photo has ink you miss. Bring the loss to zero.
32 × 32 pixels, soft edges of width 0.012. The best possible loss is 0.0000.
Render-and-compare needs only two things: a renderer you can run, and a way to score a match. It does not need anyone to label scenes. It does not need a model of how to see. The renderer is the model, and it knows physics.
Its weak point is the search. A real scene has thousands of numbers. The next two chapters are about how to search that space well.
Chapter 4
Map the loss over every possible guess, find its valleys, flat plains and false bottoms, and see how blurring reshapes it
Fix everything about the guess except its position. Then the loss is a function of two numbers, x and y. We can draw it as a map: for every spot, render a ball there and colour the spot by its loss. That map is the loss landscape. Searching for the best scene is walking downhill on it.
The simplest walker is gradient descent. Stand somewhere. Find the direction in which the loss drops fastest, which is minus the gradient (the vector of slopes). Take a small step that way. Repeat.
Worked: θ = (0.60, 0.50), ∇L = (0.08, −0.02), η = 0.5 → θ = (0.60 − 0.04, 0.50 + 0.01) = (0.56, 0.51)
Each spot on the map is the loss of a guessed ball placed there. Strong yellow is high loss; faint is low. Click anywhere to start gradient descent from that spot. Try the two-ball photo, and change how blurry the images are.
The map renders 1,024 guesses on a 24 × 24 image. Gradients come from finite differences. The blue ring marks the true ball (the brighter one, in the two-ball photo).
Plateaus. With sharp edges, a guess that does not touch the true ball has the same loss wherever it is: the overlap is zero everywhere. The ground is flat, the gradient is zero, and the walker never moves. This is the most common way render-and-compare fails.
Local minima. With two balls in the photo, the guess can settle on the dim one. It is a valley, but not the lowest one. Every small step from there goes uphill, so gradient descent stays.
The blur fix. Blurring both images widens every shape's influence. Far-away guesses now overlap the target a little, so the plain tilts toward it. This is coarse-to-fine optimisation: solve a blurry version first, then sharpen and refine. The hero's Fit button does exactly this.
Chapter 5
Race a differentiable renderer against gradient-free search, count the renders each one spends, and see when each wins
Gradient descent needs ∇L. There are two ways to get it.
The first is to nudge each number in turn and re-render: finite differences. With n numbers this costs 2n renders per step. For a scene with 10,000 numbers, that is 20,000 renders for one step. Too slow.
The second is the chain rule. The loss depends on pixels, and pixels depend on scene numbers. So:
Worked, one edge pixel: residual = −0.5 (too dark), ∂R/∂r = 4 (growing the ball brightens it), P = 1 → ∂L/∂r = 2 × (−0.5) × 4 = −4: grow the radius
A renderer that computes ∂Rp/∂θ for every pixel is a differentiable renderer. One forward render plus one backward pass gives the whole gradient, for any number of parameters. Loper and Black's OpenDR (ECCV 2014) was an early general one. The catch is the edge. With hard edges, a pixel is fully in or fully out, so ∂Rp/∂θ is zero almost everywhere. Soft edges (Chapter 1) are the usual fix: they make coverage change smoothly, so the derivative exists.
The alternative is to skip gradients. Gradient-free search proposes a random change, renders it, and keeps it only if the loss drops. It works with any renderer, even a black box like Blender. It pays one render per proposal, and it wastes most proposals.
Both start from the same wrong guess of a two-shape scene, with a budget of 600 renders. Run the race with soft edges, then with hard edges. Then make the gradient cost what finite differences cost.
Six numbers to find. A gradient step is counted as 3 renders (a forward pass plus a backward pass that costs about twice as much, a common rule of thumb), or 13 with finite differences. With hard edges, autodiff gives exactly zero (the slope of a step); finite differences see only pixels that flip. Random search is a (1+1) evolution strategy with an adaptive step. Illustrative.
With soft edges and cheap gradients, gradient descent wins clearly: every step points downhill. With hard edges, its gradient is zero and it barely moves, while random search still finds its way. With finite differences, gradients cost 13 renders per step and the lead shrinks. With 10,000 numbers it would vanish.
That is the real trade-off. Differentiable renderers scale to huge scenes but need soft, smooth physics. Gradient-free search works with any renderer, including the full Blender, but only for a handful of numbers at a time. AgentSTAR (2026) uses exactly this split: a VLM agent picks a small region of poses, and a gradient-free optimiser (differential evolution) searches it, because a Blender silhouette is not differentiable in the pose.
def loss(theta, photo):
return ((render(unpack(theta)) - photo) ** 2).mean()
def grad_fd(theta, photo, eps=1e-3): # 2n renders per call
g = np.zeros_like(theta)
for i in range(len(theta)):
e = np.zeros_like(theta); e[i] = eps
g[i] = (loss(theta + e, photo) - loss(theta - e, photo)) / (2 * eps)
return g
def random_search(theta, photo, steps=600, step=0.06): # 1 render per proposal
best = loss(theta, photo)
for _ in range(steps):
cand = theta + step * np.random.randn(len(theta))
l = loss(cand, photo)
if l < best: theta, best, step = cand, l, step * 1.5 # success: be bolder
else: step *= 0.9 # failure: be careful
return theta
Chapter 6
Combine what the pixels say with what you knew before looking, and watch a ridge of equally good answers collapse to one
Back to the ball that could be small and near or big and far. You see a ball in a photo, and someone tells you it is a tennis ball. Now you know its distance. You did not get that from the pixels. You got it from knowing how big tennis balls are.
That knowledge is a prior: a probability over scenes before you look. Bayes' rule combines it with the pixels. The pixels give the likelihood: how probable this photo is, if the scene were θ. The result is the posterior: how probable each scene is, after looking.
Worked: f = 500 px, image radius r = 25 px, prior R ≈ 3.3 cm → Z = f · R / r = 500 × 0.033 / 25 = 0.66 m
The map covers every size (across) and distance (up). The blue ridge is every scene that fits the pixels equally well. Add a prior on what the object is, or a second cue from the floor, and watch the purple posterior shrink.
Image radius 25 ± 1.5 px; camera 0.3 m above a flat floor; the ball's contact point appears 224 ± 8 px below the horizon. The true scene is a tennis ball at 0.67 m. All values are illustrative.
Take the minus log of Bayes' rule. Maximising the posterior becomes minimising a sum: the pixel loss, plus a penalty for implausible scenes. The best scene under this rule is the MAP estimate (maximum a posteriori).
So a prior is just an extra term in the loss. It turns flat valley floors into a single low point. Priors can be simple (sizes of known objects, light from above, smooth surfaces) or learned from data. Yuille and Kersten's 2006 review treats vision exactly this way: Bayesian inference over structured models of how images are made, with bottom-up cues proposing hypotheses and top-down rendering checking them Yuille & Kersten 2006.
Chapter 7
Describe the same picture as a list of primitives, as a short program, and as a neural field, then try to edit each one
So far the scene was a few numbers. Real work must choose a scene representation: the language in which the answer is written. The choice decides what the search looks for, how big the search space is, and what you can do with the answer.
Three families matter.
All three describe the same image. Pick a representation, then press the edit button to make the fence taller. Count what has to change.
The neural field is a small network with 2 inputs, two hidden layers of 32 and 1 output: 1,185 weights. Its squares are a picture of those weights, not real trained values.
Worked: 6 posts → primitives 4 × 6 = 24 numbers; program 4 numbers (start 0.12, spacing 0.15, count 6, height 0.36). At 60 posts: 240 against 4.
A smaller description is a smaller search space, and it generalises: the program "knows" the posts are alike. That is why the newest work writes scenes as programs. The answer is also editable: you can move, relight or re-render it, which is what a designer, a robot simulator or a game engine needs. Neural fields win the other way: they can represent anything, including fur and glass, but you cannot ask one to "move the chair".
Chapter 8
Train an encoder in this page on synthetic renders, then race its one-pass guess against search, and combine the two
Every method so far starts from scratch for each new photo. Search a thousand photos and you pay a thousand searches. There is another way. Learn a function that goes straight from image to scene in one pass. You pay once, in training, and every later photo is nearly free. This is called amortized inference: the cost of inference is spread, like a loan, over every future input.
The function is an encoder: a neural network E that reads an image and outputs scene numbers. Where do the training examples come from? From the renderer. Pick random scenes, render them, and you have perfect (image, scene) pairs for free. No human labels.
Worked: search spends 40 steps × 7 renders = 280 renders of 144 pixels per photo. The encoder spends 144 × 32 + 32 × 3 = 4,704 multiply-adds, about what a few renders cost, and needs no search.
Press Train to fit a small network on synthetic renders of single balls. Then test it on a new photo. Pink is the encoder's one-pass answer, warm is search from scratch, purple is search that starts from the encoder's answer. Try the unusual photo.
A real network trained in your browser: 144 pixels in, 32 tanh units, 3 numbers out (x, y, radius), Adam, 2,500 mini-batches of 16. Training balls have radius 0.08 to 0.20 and centres in the middle half of the image. Search is gradient descent with finite differences (7 renders a step).
The encoder is fast, but its answers are a little off, and far off on photos unlike its training data. The unusual photo has a ball much bigger than any it saw. The encoder answers as if it were a training ball. This shortfall is the amortization gap. Search does not have it: it fits this photo, whatever it is.
The practical answer uses both. The encoder proposes; search refines from there. Started near the answer, search converges in a few steps and avoids the plateaus and false valleys of Chapter 4. This is exactly the loop Yuille and Kersten described in 2006: bottom-up proposals, then top-down rendering to accept or reject them Yuille & Kersten 2006.
The idea of an encoder trained to output graphics codes is older than the agent era. Kulkarni, Whitney, Kohli and Tenenbaum's Deep Convolutional Inverse Graphics Network (DC-IGN, NeurIPS 2015) trained an encoder-decoder so that parts of its code stood for pose and lighting, and could re-render faces and chairs under new ones.
Chapter 9
Watch a toy agent write a scene program, render it, look, and edit, and meet three 2026 papers that do this in Blender
Programs are the best representation for editing (Chapter 7). But they are the hardest to search: you cannot take a gradient through a line of code, and the space of programs is enormous. For decades, program-based inverse graphics stayed in small toy worlds.
Vision-language models (VLMs) changed that. A VLM can read an image and write Blender Python. It knows that a mug has a handle and that lamps sit on tables. That is a strong learned prior over programs. And it can look at its own render and say "the lamp is too tall". That is a comparison step in words, instead of a pixel loss. Put the two in a loop and you have render-and-compare, with the agent as the search.
A toy agent rebuilds a four-object scene. Each round it writes four coarse code edits ("move the ball left a bit"). When it looks, it aims them at the object whose region differs most, and keeps the best. Compare writing once, editing without looking at renders, and editing with render-and-compare.
A toy, not a VLM. The "agent" writes edits from a fixed menu with random sizes, and its first draft is the true scene plus large errors, as a one-shot VLM's often is. Only the loop structure follows the papers below.
| Work | Input → output | How it searches |
|---|---|---|
| Thinking in Blender (He, Luo, Ma, Averbuch-Elor, 2026) | One image → an editable Blender program | A staged generator–verifier loop driven by a pretrained VLM: geometry, then materials, then composition, then lighting. No specialised 2D or 3D models, no differentiable rendering, no multiple views TiB · abstract. |
| VIGA (Yin et al., 2026) | An image → an executable program; also 2D slides, 3D edits and 4D physics | A code–render–inspect loop from an empty scene, with an evolving multimodal memory. Training-free VIGA · abstract. |
| AgentSTAR (Mazur et al., 2026) | A monocular video → object shape, joints and pose over time | A VLM agent writes the object as code and steers a gradient-free optimiser through render-and-compare. |
The numbers show how much the loop matters. VIGA reports that its loop improves on one-shot baselines by 35.32% on BlenderGym, 117.17% on SlideBench and 124.70% on the authors' new BlenderBench VIGA · abstract. Thinking in Blender reports that staging the reconstruction "substantially improves reconstruction fidelity" TiB · abstract. One-shot writing, like one-shot guessing, is rarely enough.
What is new and what is old? The loop is Chapter 3's render-and-compare. The representation is Chapter 7's program. What is new is the searcher: a model with a huge prior over scenes, which proposes whole lines of sensible code instead of tiny numeric steps.
Chapter 10
Pick the right method for a job, keep the cheat sheet, know the limits, and follow the path onward
Every method in this lesson answers the same question: which scene made this picture? They differ in three choices. How you search (gradients, random proposals, an encoder, an agent). What you search over (numbers, programs, fields). And what you know beforehand (priors, training data). Use the device to match a job to a method.
Answer three questions about your job. The pipeline below shows the method that fits.
A rule of thumb, not a law. Real systems mix these parts freely.
| Idea | In one line |
|---|---|
| Forward renderer | I = R(θ): scene numbers in, pixels out. Easy and exact. |
| Inverse graphics | Find θ (or a program) such that R(θ) matches the photo. |
| Ill-posed | Size vs distance, light vs paint, hidden parts: many scenes, one image. |
| Analysis by synthesis | Guess, render, compare with a loss, update. Repeat. |
| Loss landscape | Plateaus and false valleys; coarse-to-fine blur helps. |
| Differentiable rendering | All gradients in one backward pass; needs soft edges; local only. |
| Gradient-free search | Any renderer, few parameters, many renders. |
| Prior | An extra loss term; turns a ridge of answers into one (MAP). |
| Representation | Primitives < programs (compact, editable) < fields (expressive, not editable). |
| Amortized | Encoder trained on synthetic renders: one pass, with an amortization gap. |
| VLM agents | A learned prior over programs plus render-and-look, as the search. |
This lesson is background for the Agentic Vision and Robotics path. Go on to:
Now press Present or Teach and explain, out loud and from memory, why seeing is graphics run backwards, and why that is hard. Then go back to the hero and fit a new photo by hand before you press Fit.