Algorithm Search⌘K

Modelresearch

Neural radiance field

Also called NeRF.

Represent a scene as a function from 3D position and direction to density and color, fitted to posed images by differentiable volume rendering.

A neural radiance field, or NeRF, describes a scene by a function that gives, for every point in space and every viewing direction, a density and a color. The density says how much the point blocks light, and the color is the light that leaves the point in that direction. A picture from any camera is made by sending a ray through each pixel, sampling the function along the ray, and adding up the colors with the weights of classical volume rendering. Mildenhall et al. (2020) represent the function by a small fully connected neural network and fit it to a few dozen photos with known cameras, so that the rendered pixels match the real ones. The result renders new views of high quality. Unlike multi-view stereo, which looks for a surface, NeRF fits a soft volume whose purpose is to reproduce images; 3D Gaussian splatting uses the same blending rule with an explicit set of Gaussians in place of the network. This page gives the representation and the rendering formula; the network itself has no correctness theorem and its cost is outside the page.

The machine

Representation. The scene is a function

FΘ:(x,d)↦(c,σ),x∈R3, d∈S2, c∈[0,1]3, σ≥0.F_\Theta : (x, d) \mapsto (c, \sigma), \qquad x \in \mathbb{R}^3,\ d \in S^2,\ c \in [0, 1]^3,\ \sigma \ge 0.

The density σ\sigma depends only on the position xx, and the color cc depends on xx and the direction dd. This lets the model show highlights that move with the view, while the geometry stays the same for all views. In the paper, xx goes through 8 fully connected layers of 256 units, which give σ\sigma and a feature vector; the feature and the direction then go through one layer of 128 units, which gives cc.

Positional encoding. A plain network of (x,d)(x, d) gives blurry results, because such networks learn low frequencies first. The paper maps each coordinate pp of xx and dd by

γ(p)=(sin⁡(20πp),cos⁡(20πp),…,sin⁡(2L−1πp),cos⁡(2L−1πp)),\gamma(p) = \big(\sin(2^0 \pi p), \cos(2^0 \pi p), \dots, \sin(2^{L-1} \pi p), \cos(2^{L-1} \pi p)\big),

with L=10L = 10 for position and L=4L = 4 for direction, before the network.

Rendering a ray. A pixel defines the ray r(t)=o+tdr(t) = o + t d from the camera center oo, as in the pinhole model. Its expected color between the near and far bounds tnt_n and tft_f is the integral of the emission and absorption model of Max (1995):

C(r)=∫tntfT(t) σ(r(t)) c(r(t),d) dt,T(t)=exp⁡(−∫tntσ(r(s)) ds).C(r) = \int_{t_n}^{t_f} T(t)\, \sigma(r(t))\, c(r(t), d)\, dt, \qquad T(t) = \exp\Big(-\int_{t_n}^{t} \sigma(r(s))\, ds\Big).

T(t)T(t) is the transmittance: the fraction of light from r(t)r(t) that reaches the camera without being blocked.

Quadrature. The paper splits [tn,tf][t_n, t_f] into NN equal bins and draws one sample tit_i uniformly in each bin (stratified sampling). With δi=ti+1−ti\delta_i = t_{i+1} - t_i and the values σi,ci\sigma_i, c_i at tit_i, the estimate is

C^(r)=∑i=1NTi αi ci,αi=1−e−σiδi,Ti=exp⁡(−∑j<iσjδj)=∏j<i(1−αj).\hat C(r) = \sum_{i=1}^{N} T_i\, \alpha_i\, c_i, \qquad \alpha_i = 1 - e^{-\sigma_i \delta_i}, \qquad T_i = \exp\Big(-\sum_{j<i} \sigma_j \delta_j\Big) = \prod_{j<i} (1 - \alpha_j).

This is exact when σ\sigma and cc are constant on each interval [ti,ti+1)[t_i, t_{i+1}), and it is differentiable in all σi\sigma_i and cic_i, so the network can be fitted by gradients (backpropagation). The last form shows that it is front-to-back alpha compositing, the "over" operator of Porter-Duff compositing, with opacity αi\alpha_i.

Hierarchical sampling. Most samples of a ray fall in empty space or behind the surface. The paper evaluates a coarse network at Nc=64N_c = 64 stratified samples, turns the weights wi=Tiαiw_i = T_i \alpha_i into a piecewise constant density along the ray, draws Nf=128N_f = 128 more samples from it by inverse transform sampling, and evaluates a fine network at all Nc+NfN_c + N_f samples. This is importance sampling of the rendering integral.

What it counts

What it predicts. The color of any ray through the scene, so an image from any new camera inside the range of the training views. The weights wiw_i also give an expected depth ∑iwiti\sum_i w_i t_i per ray, which is a by-product.

What a fit minimizes. For a batch R\mathcal{R} of rays from the training images with true colors C(r)C(r), the loss is

L=∑r∈R(∥C^c(r)−C(r)∥22+∥C^f(r)−C(r)∥22),\mathcal{L} = \sum_{r \in \mathcal{R}} \Big( \|\hat C_c(r) - C(r)\|_2^2 + \|\hat C_f(r) - C(r)\|_2^2 \Big),

the squared error of the coarse and the fine rendering. It is a photometric loss: an image space form of photo-consistency. The paper uses batches of 4096 rays, Adam with a learning rate that decays from 5⋅10−45 \cdot 10^{-4} to 5⋅10−55 \cdot 10^{-5}, and 100 to 300 thousand iterations, which took one to two days on one NVIDIA V100 GPU per scene. One scene is one fit; nothing is learned across scenes.

Cost of one ray. Rendering a ray takes Nc+Nf=192N_c + N_f = 192 network evaluations and O(Nc+Nf)O(N_c + N_f) work for the sums and the sampling. The cost of one evaluation of the network is outside the page.

Relation to other models

  • Volume rendering. The rendering integral is the emission and absorption model of Max (1995), used for decades to show medical and scientific volumes. NeRF adds a learned field and fits it to images.
  • Alpha compositing. With αi=1−e−σiδi\alpha_i = 1 - e^{-\sigma_i \delta_i}, the quadrature is the front-to-back "over" of Porter and Duff along the ray.
  • 3D Gaussian splatting. It uses the same sum ∑iTiαici\sum_i T_i \alpha_i c_i, but the αi\alpha_i come from projected 3D Gaussians sorted by depth, not from samples of a network along the ray. This makes it much faster to render.
  • Multi-view stereo. MVS seeks a surface on which the images agree. NeRF seeks a volume that reproduces the images. A NeRF can be dense where a surface is thin, and its geometry can be poor in regions where the color alone can explain the images.
  • Light fields. A light field stores the color of every ray directly. NeRF stores a 3D field, and the rays follow from the rendering integral, which ties the views together through the geometry.

Known results in the model

Weights sum to one (a theorem). For any values σi≥0\sigma_i \ge 0 and δi>0\delta_i > 0,

∑i=1NTiαi+TN+1=1.\sum_{i=1}^{N} T_i \alpha_i + T_{N+1} = 1.

Proof. By the definition, T1=1T_1 = 1 and Ti+1=Ti(1−αi)T_{i+1} = T_i (1 - \alpha_i), so Tiαi=Ti−Ti+1T_i \alpha_i = T_i - T_{i+1}. The sum telescopes to T1−TN+1=1−TN+1T_1 - T_{N+1} = 1 - T_{N+1}. ■\blacksquare

So C^\hat C is a convex combination of the sample colors and of a background color with weight TN+1T_{N+1}. If the colors lie in [0,1][0, 1], so does C^\hat C with a black background.

Check value (exact). Constant density σ\sigma over a length LL gives transmittance e−σLe^{-\sigma L} and opacity 1−e−σL1 - e^{-\sigma L}. With σ=2\sigma = 2 and L=0.5L = 0.5, the opacity is 1−e−1≈0.6321 - e^{-1} \approx 0.632. Splitting the segment into any number of bins gives the same result, since ∏je−σδj=e−σL\prod_j e^{-\sigma \delta_j} = e^{-\sigma L}.

A ray by hand. Two samples have σ1δ1=ln⁡2\sigma_1 \delta_1 = \ln 2 and σ2δ2=ln⁡4\sigma_2 \delta_2 = \ln 4, so α1=0.5\alpha_1 = 0.5 and α2=0.75\alpha_2 = 0.75, with colors c1=1c_1 = 1 and c2=0c_2 = 0 (one channel). Then T1=1T_1 = 1, T2=0.5T_2 = 0.5, T3=0.125T_3 = 0.125, the weights are 0.5 and 0.375, and C^=0.5⋅1+0.375⋅0=0.5\hat C = 0.5 \cdot 1 + 0.375 \cdot 0 = 0.5. The weights and T3T_3 add to 1.

Benchmark results. The paper reports PSNR, SSIM and LPIPS on three data sets (Table 1): 40.15, 0.991 and 0.023 on Diffuse Synthetic 360; 31.01, 0.947 and 0.081 on Realistic Synthetic 360; and 26.50, 0.811 and 0.250 on Real Forward-Facing scenes. In that table NeRF is better than the earlier view synthesis methods it compares with. These are measurements on those data sets with that setup, not properties of the model. See PSNR for the first measure.

What is not proved. There is no theorem that the fit finds the true scene, or that the loss reaches its global minimum. The fitted density is not unique: a texture painted on a wrong surface can reproduce the training views. Rendering of views far from the training views has no error bound.

References

  1. Ben Mildenhall, Pratul P. Srinivasan, Matthew Tancik, Jonathan T. Barron, Ravi Ramamoorthi and Ren Ng, NeRF: representing scenes as neural radiance fields for view synthesis, ECCV 2020, Lecture Notes in Computer Science, pages 405 to 421, Eq. 1 (the rendering integral), Eq. 2 (stratified sampling) and Eq. 3 (the quadrature), the positional encoding with L = 10 and L = 4, hierarchical volume sampling with 64 and 128 samples, the loss and the training settings, and Table 1 (PSNR, SSIM and LPIPS)
  2. Nelson Max, Optical models for direct volume rendering, IEEE Transactions on Visualization and Computer Graphics 1(2), pages 99 to 108, 1995, the absorption and emission models and the integral of the emission and absorption model along a ray

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/WZQ35M/text.yaml