Shade Programs That Cannot Paint Shadows: Tree-Structured Material Decoding for Multi-View Inverse Rendering

When a 3D reconstruction system recovers an object's surface color from photographs, it often "bakes in" the lighting. Shadows, highlights and light bounced from nearby surfaces get painted permanently into the texture, so the object looks wrong once it is moved into a new scene. The usual cause is that the texture is too flexible. A per-pixel texture map or a neural network over surface coordinates can represent a shadow just as easily as a wood grain, and the optimizer takes whichever explanation fits the training photos fastest. This proposal replaces that flexible texture with a short program: a tree whose leaves are procedural primitives (constants, noise, stripes, cellular patterns) and whose internal nodes are shading operators (mix, multiply, choice of reflectance model). The program is decoded and edited jointly with lighting during multi-view optimization. The bet is that a cast shadow depends on geometry and light direction, so it is expensive to write as a short procedural program over surface coordinates, while real material patterns are cheap to write. A limited program budget should therefore push shadows and highlights out of the material and into the lighting and visibility terms, where they belong.

The same structure brings a second benefit. In tree-structured decoding for math and code, the tree guarantees well-formed outputs and lets errors be localized to subtrees. Here it lets the reflectance model be a discrete choice at a node, conductor versus dielectric, rather than the hard-coded constant that current pipelines fix. The deliverable is an inverse-rendering system whose material output is an editable shader tree. It would be evaluated against the claim that matters: less baked-in lighting in recovered albedo, measured on relighting and albedo accuracy.

Core Claim

Jointly optimizing lighting with a tree-structured procedural material program, under a description-length budget, reduces baked-in lighting relative to continuous material fields. The reduction should hold both against applying the same program fitting after a standard inverse-rendering run and against simpler "keep the material simple" priors such as material palettes. The mechanism is capacity asymmetry. Residual image structure that the program cannot cheaply express must be explained by lighting, visibility or roughness, or else left unexplained. Continuous fields never face that pressure.

Relation to Prior Work

The motivating evidence comes from inverse rendering. The physics-based pipelines that render color from geometry, a spatially varying reflectance function (SVBRDF) and environment light all represent materials as continuous fields or bitmaps. These include Extracting Triangular 3D Models, Materials, and Lighting From Images (a deformable tetrahedral mesh with fast image-based lighting), NeRFactor (surface distillation with a visibility field and a learned BRDF prior), TensoIR (tensor-factorized fields with online indirect light) and Modeling Indirect Illumination for Inverse Rendering (a pretrained radiance field supervising indirect light, plus a sparse material palette). Zexiang Liu et al. document cross-talk that smears gloss into albedo under joint optimization. TensoIR and InvRender also fix a dielectric Fresnel constant (0.04 and 0.02), which they report breaks on metals. We keep their geometry and lighting machinery unchanged and swap only the material representation.

The closest work at the intersection supplies the representation but not the setting. Tree-Structured Shading Decomposition inverts a single spherical reflectance image (a MatCap) into a Cook-style shade tree using an autoregressive structure prior plus derivative-free parameter search. Its authors state that it does not handle spatially varying materials or multi-view 3D. VLMaterial generates Blender shader programs from an isolated material photo. An Inverse Procedural Modeling Pipeline for SVBRDF Maps proceduralizes already-clean SVBRDF maps. All three assume the lighting problem is solved upstream, or absent. Our difference is to put the program inside the multi-view inverse-rendering loop, so that program structure shapes how lighting is separated from material.

The decoding techniques are reused from the math-and-code line. From Decompose, Structure, and Repair we take localized subtree repair driven by an external checker, which there is the Lean compiler. From Neural–Evolutionary Symbolic Regression with Global Constraints we take typed, constraint-aware decoding that makes invalid trees impossible to emit. The general arity and precedence arguments of A Goal-Driven Tree-Structured Neural Model for Math Word Problems justify decoding trees directly instead of flat code. A constraint also comes from this line: DSR reports that errors in the initial decomposition cascade. Our analogue is a wrong initial region partition, and the experiments measure how often repair recovers from it.

Research Program

The material is a typed tree $T$ with continuous parameters $\theta$. The root chooses a reflectance model per region, either a dielectric microfacet model with free Fresnel or a conductor with tinted Fresnel. Its children produce base color, roughness and metallic channels as procedural expressions over surface coordinates (triplanar or UV from the extracted mesh). A shallow "mix" layer selects among a handful of region subprograms. The region mask is itself low-capacity: a small categorical field with a boundary-length penalty. The type system forbids energy-violating combinations and out-of-range microfacet parameters at decode time, so no invalid shader is ever rendered.

Geometry and lighting follow TensoIR or nvdiffrec: a split-sum environment map, a learned visibility field and optional indirect light. They are initialized identically for all methods. The joint objective is

$$\min_{T,\theta,L,r}\ \sum_{v}\big\|I_v - R(G, T_\theta + r, L)_v\big\|^2 + \lambda\,\mathrm{DL}(T) + \mu\,\|r\|_1,$$

where $I_v$ is the photo from view $v$, $R$ the differentiable renderer, $G$ the shared geometry, $L$ the lighting and visibility parameters, and $\mathrm{DL}(T)$ the description length of the tree (node count weighted by primitive cost). The term $r$ is a small unconstrained per-texel residual, and $\lambda,\mu$ trade off program simplicity and residual use. The residual lets us sweep smoothly from "program only" ($\mu\to\infty$) to "continuous texture" ($\mu\to 0$). This sweep is the central ablation.

Search alternates three steps. Gradient steps update $\theta$, $L$ and $r$. A learned tree proposal network, pretrained on the VLMaterial corpus of programs rendered onto shapes, proposes structures. Localized repair then operates on those structures. Per-region render residuals are mapped back to the subtree that controls those texels, in the spirit of DSR, and only that subtree is resampled. This avoids the global rewrites DSR found destructive. The dielectric/conductor node is resampled when a region's specular residual stays high, which gives a discrete answer to the metal problem that fixed-Fresnel pipelines cannot express.

Baselines

The naive reference point is the host pipeline with its native continuous material, run with our shared geometry initialization and lighting model. This is TensoIR on its scenes and nvdiffrec elsewhere. It measures how much baking the loop produces when nothing discourages it.

The strongest existing method on this question is InvRender (Modeling Indirect Illumination for Inverse Rendering). It already attacks baked-in lighting through indirect illumination modeling and a sparse material palette, and it reports an aligned albedo PSNR of 25.25 versus 22.96 for NeRFactor on its four Blender-rendered CAD scenes. We rerun it on those scenes and on our new benchmark with the same geometry and a matched GPU-hour budget. Beating it means higher aligned albedo PSNR on its own scenes and on textured scenes, without losing relighting PSNR. For TensoIR, no per-scene albedo numbers were found on Lacuna, so we report our reruns only.

The critical ablation isolates joint optimization. It runs the host pipeline to convergence and then fits the same typed tree to the recovered albedo, roughness and metallic maps, as in Hu et al. or VLMaterial applied post hoc. The second ablation is the $\mu$ sweep. The third replaces the typed tree decoder with VLMaterial-style flat Python generation inside the same loop, which tests whether tree structure matters beyond having a program at all. All variants share data, geometry, renderer and a fixed budget of structure proposals and GPU hours. Hyperparameters are tuned per method on a held-out validation scene set with equal trial counts.

Why not just…?

Why not just run standard inverse rendering and then proceduralize the maps? This is the most serious threat, because a limited program fitted to a baked albedo will also filter out some shadow structure. But post-hoc projection only discards what it cannot express. It cannot hand that energy back to the visibility and lighting terms, so lighting estimates and roughness stay biased, and relighting inherits the error. The post-hoc ablation measures this directly. If it matches joint optimization on relighting PSNR and environment-map error, the joint claim fails, and the contribution reduces to a better proceduralizer.

Why not just use a material palette or smoothness prior? InvRender's sparse palette already limits material complexity, and it may be enough on the mostly uniform CAD objects where it was evaluated. Palettes and total-variation priors cannot express repeated fine structure such as wood grain, brick or speckle without either blurring it or admitting shadows. Our new textured benchmark separates the two regimes. We expect parity on untextured scenes and a gap on textured ones. If there is no gap, the tree adds editability but not disentanglement, and we will say so.

Why not just freeze albedo first, then solve the other channels? Zexiang Liu et al. show that sequential optimization reduces cross-channel smearing. It does not stop shadows from entering albedo in the first stage, because it changes the order of optimization, not what the texture can represent. We include sequential scheduling as an option for every baseline, so any gain we report is on top of it.

Why not generate shader code with a fine-tuned vision-language model? VLMaterial reaches 91.1% executable programs only after 550,000 augmented pairs, versus 29.4% zero-shot, and it is capped at 30 nodes. Inside an optimization loop, every invalid program is a wasted render. The flat-decoder ablation reports both the invalid-proposal rate and the final albedo quality under an equal proposal budget.

Proposed Experiments

The main benchmark is new. We apply procedural materials from the VLMaterial Blender corpus to meshes, render multi-view images under several environment lights with hard cast shadows and interreflections, and keep the ground-truth programs. This yields ground-truth albedo, roughness, metallic maps and shader trees. Existing evaluations include the NeRF Synthetic scenes, with the Materials scene serving as a metal test; InvRender's four CAD scenes under its aligned albedo protocol; and DTU for qualitative real-world relighting. Metrics are aligned albedo PSNR, relit novel-view PSNR and SSIM, roughness and metallic error, and environment-map error. For recovered structure, we compare trees to ground-truth programs using a tree-edit similarity in the spirit of ASSESS, and report the rate of correct conductor/dielectric classification per region.

Three checks are decisive. First, a "shadow leakage" score: albedo error restricted to ground-truth shadowed texels. It should fall as $\mu$ increases while unshadowed error stays flat, and the continuous baseline should not show this. Second, joint optimization must beat post-hoc proceduralization on relighting, not only on albedo. Third, on the textured subset the method must beat InvRender's palette at matched budget. A stress test perturbs the initial region partition and measures recovery by subtree repair versus full re-decoding, which tests whether the cascading-decomposition weakness DSR reports carries over to materials.