Differentiable Rendering

The Rendering Equation as a Forward Model

In Chapter 1 we introduced the forward operator y=A(g)+w\mathbf{y} = \mathcal{A}(\mathbf{g}) + \mathbf{w} abstractly. For optical imaging, the forward operator is precisely the rendering equation: given a 3D scene (geometry, materials, lighting), it computes the 2D image observed by a camera. Making this renderer differentiable means we can compute βˆ‡gA(g)\nabla_{\mathbf{g}} \mathcal{A}(\mathbf{g}) and solve the inverse problem β€” inferring geometry, materials, and lighting from images β€” by gradient descent.

This section introduces the rendering equation and its inverse; Section 28.3 adapts both to RF wave propagation.

Definition:

The Rendering Equation

The rendering equation (Kajiya, 1986) describes how light interacts with surfaces:

Lo(p,Ο‰o)=Le(p,Ο‰o)+∫H2(n)fr(p,Ο‰i,Ο‰o) Li(p,Ο‰i) (Ο‰iβ‹…n) dΟ‰i,L_o(\mathbf{p}, \boldsymbol{\omega}_o) = L_e(\mathbf{p}, \boldsymbol{\omega}_o) + \int_{\mathcal{H}^2(\mathbf{n})} f_r(\mathbf{p}, \boldsymbol{\omega}_i, \boldsymbol{\omega}_o)\,L_i(\mathbf{p}, \boldsymbol{\omega}_i)\,(\boldsymbol{\omega}_i \cdot \mathbf{n})\,d\boldsymbol{\omega}_i,

where:

  • Lo(p,Ο‰o)L_o(\mathbf{p}, \boldsymbol{\omega}_o): outgoing radiance at surface point p\mathbf{p} in direction Ο‰o\boldsymbol{\omega}_o.
  • LeL_e: emitted radiance (light sources).
  • frf_r: BRDF (bidirectional reflectance distribution function) describing surface material.
  • Li(p,Ο‰i)L_i(\mathbf{p}, \boldsymbol{\omega}_i): incoming radiance from direction Ο‰i\boldsymbol{\omega}_i.
  • n\mathbf{n}: surface normal at p\mathbf{p}.
  • H2(n)\mathcal{H}^2(\mathbf{n}): hemisphere above the surface.

The integral sums light arriving from all directions, weighted by the BRDF and the cosine foreshortening factor.

Definition:

Bidirectional Reflectance Distribution Function (BRDF)

The BRDF fr(p,Ο‰i,Ο‰o)f_r(\mathbf{p}, \boldsymbol{\omega}_i, \boldsymbol{\omega}_o) characterises how a surface reflects light:

fr=dLo(Ο‰o)Li cos⁑θi dΟ‰i.f_r = \frac{dL_o(\boldsymbol{\omega}_o)}{L_i\,\cos\theta_i\,d\boldsymbol{\omega}_i}.

Physically valid BRDFs satisfy reciprocity (fr(Ο‰i,Ο‰o)=fr(Ο‰o,Ο‰i)f_r(\boldsymbol{\omega}_i, \boldsymbol{\omega}_o) = f_r(\boldsymbol{\omega}_o, \boldsymbol{\omega}_i)) and energy conservation (∫frcos⁑θo dΟ‰o≀1\int f_r \cos\theta_o\,d\boldsymbol{\omega}_o \leq 1).

The Lambertian model (fr=ρ/Ο€f_r = \rho/\pi, constant) is the simplest; the Cook-Torrance microfacet model is the standard in physically-based rendering. In RF, the "BRDF" is replaced by the bistatic scattering cross-section Οƒ(Ο‰i,Ο‰o)\sigma(\boldsymbol{\omega}_i, \boldsymbol{\omega}_o).

Definition:

Differentiable Rendering

A differentiable renderer computes βˆ‡ΞΈRΞΈ\nabla_\theta \mathcal{R}_\theta, enabling gradient-based optimisation of scene parameters ΞΈ\theta. The key challenges:

  1. Visibility discontinuities: When a surface edge moves, pixels transition between seeing different surfaces. The rendering function has discontinuities at silhouette edges.

  2. Solutions:

    • Soft rasterisation (SoftRas): Replace hard visibility with smooth sigmoid-based occupancy.
    • Edge sampling: Explicitly detect and integrate over silhouette edges.
    • Volume rendering (NeRF): Avoids hard visibility entirely by using a continuous density field.
    • 3DGS: Gaussian alpha-compositing is inherently smooth.
,

Definition:

Inverse Rendering

Inverse rendering recovers scene properties (geometry, materials, lighting) from observed images by inverting the rendering equation. Given observed images {Ik}\{I_k\} and a differentiable renderer RΞΈ\mathcal{R}_\theta:

ΞΈ^=arg⁑minβ‘ΞΈβˆ‘kβˆ₯RΞΈ(viewk)βˆ’Ikβˆ₯2+λ Rreg(ΞΈ),\hat{\theta} = \arg\min_\theta \sum_k \|\mathcal{R}_\theta(\text{view}_k) - I_k\|^2 + \lambda\,\mathcal{R}_{\text{reg}}(\theta),

where ΞΈ=(geometry,materials,lighting)\theta = (\text{geometry}, \text{materials}, \text{lighting}) and Rreg\mathcal{R}_{\text{reg}} provides regularisation.

This is an ill-posed inverse problem: different combinations of geometry, materials, and lighting can produce the same image.

Theorem: Volume Rendering Integral

The colour C^(r)\hat{C}(\mathbf{r}) of a pixel corresponding to camera ray r(t)=o+t d\mathbf{r}(t) = \mathbf{o} + t\,\mathbf{d} is:

C^(r)=∫tntfT(t) σ(r(t)) c(r(t),d) dt,\hat{C}(\mathbf{r}) = \int_{t_n}^{t_f} T(t)\,\sigma(\mathbf{r}(t))\,\mathbf{c}(\mathbf{r}(t), \mathbf{d})\,dt,

where Οƒ(t)\sigma(t) is the volume density, c\mathbf{c} is the emitted colour, and the transmittance is:

T(t)=exp⁑ ⁣(βˆ’βˆ«tntΟƒ(r(s)) ds).T(t) = \exp\!\left(-\int_{t_n}^{t} \sigma(\mathbf{r}(s))\,ds\right).

The discrete (quadrature) approximation used in NeRF is:

C^=βˆ‘i=1NTi (1βˆ’eβˆ’ΟƒiΞ΄i) ci,Ti=exp⁑ ⁣(βˆ’βˆ‘j=1iβˆ’1ΟƒjΞ΄j),\hat{C} = \sum_{i=1}^{N} T_i\,(1 - e^{-\sigma_i \delta_i})\,\mathbf{c}_i, \quad T_i = \exp\!\left(-\sum_{j=1}^{i-1} \sigma_j \delta_j\right),

where Ξ΄i=ti+1βˆ’ti\delta_i = t_{i+1} - t_i and the sum runs over NN samples along the ray.

Volume rendering accumulates colour along a ray, weighting each point by how much light it emits (Οƒβ‹…c\sigma \cdot \mathbf{c}) and how much of the ray has not been absorbed yet (TT). This is analogous to Beer-Lambert absorption β€” and to the RF matched-filter integral along a range cell.

Differentiable Volume Rendering: 1D Ray Marching

Visualise the 1D volume rendering integral along a single ray. The top panel shows the density profile Οƒ(t)\sigma(t) and colour c(t)\mathbf{c}(t) along the ray; the bottom panel shows the transmittance T(t)T(t) and the accumulated colour. Observe how increasing the number of samples improves the quadrature approximation, and how high-density regions absorb light rapidly, causing T(t)T(t) to drop.

Parameters
64
1

Example: NeuS: Neural Implicit Surface Rendering

NeuS represents a scene as a neural SDF fΞΈ(p)f_\theta(\mathbf{p}) (Chapter 24) and renders it via volume rendering. Explain how the SDF value is converted to a volume density for the rendering integral, and why this is preferable to NeRF's unconstrained density field.

Common Mistake: Visibility Discontinuities in Differentiable Rendering

Mistake:

Naively differentiating a hard rasteriser with respect to mesh vertex positions, obtaining zero gradients almost everywhere and undefined gradients at silhouette edges.

Correction:

Hard rasterisation is a step function in object coordinates: a pixel is either inside or outside a triangle. The gradient is zero (no information) in the interior and undefined at edges.

Solutions: (i) Soft rasterisation (SoftRas) replaces the step with a sigmoid: each pixel gets a soft "occupancy" from nearby triangles. (ii) Volume rendering (NeRF/NeuS) avoids hard visibility altogether. (iii) 3DGS uses smooth Gaussian splatting. All three approaches provide informative gradients for inverse rendering.

BRDF (Bidirectional Reflectance Distribution Function)

A function fr(Ο‰i,Ο‰o)f_r(\boldsymbol{\omega}_i, \boldsymbol{\omega}_o) that describes the ratio of reflected radiance to incident irradiance at a surface point, characterising the material's reflective properties.

Related: The Rendering Equation

Inverse Rendering

The problem of recovering scene geometry, materials, and lighting from observed images, typically solved via gradient-based optimisation through a differentiable renderer.

Related: Inverse Rendering

Quick Check

In the volume rendering integral, what does the transmittance T(t)=exp⁑(βˆ’βˆ«tntΟƒ(s) ds)T(t) = \exp(-\int_{t_n}^{t} \sigma(s)\,ds) represent physically?

The probability that the ray has not been absorbed by depth tt

The total emitted light up to depth tt

The surface normal at depth tt

The accumulated density along the ray

Key Takeaway

The rendering equation is the forward model for optical imaging. Differentiable renderers β€” SoftRas for meshes, volume rendering for NeRF/NeuS, Gaussian splatting for 3DGS β€” enable gradient-based inverse rendering: estimating geometry, materials, and lighting from images. The core challenge is handling visibility discontinuities smoothly so that gradients are informative.