NeRF


Background & Motivation

  • In the View Synthesis task, existing approaches required an enormous number of input images.
  • Alternatively, for 3D representation they used explicit 3D reconstruction methods based on meshes or voxels, but in complex scenes these were inefficient or failed to capture high-resolution details.
    • Implementing 3D reconstruction with meshes for NN-based View Synthesis has the limitations that generating an appropriate topology is difficult and that it is quite slow.
    • Voxel-based implementations also have the limitation of low memory efficiency, and voxels themselves are inherently unsuitable for high-resolution representation. In addition, the Occlusion-aware projection technique used in place of rendering violates the laws of physics.

      💡

      Figure

      To be consistent with the physical concepts we naturally perceive, Transparency should decrease along the ray as time t increases. This is because, if an object exists ahead and a collision with the ray occurs, the transparency of a sample point behind it cannot be larger. Because voxel-based representations do not use a rendering formula but instead perform 3D reconstruction by encoding the features of a 2D image into the latent features of 3D voxels via a neural network, they do not always conform to these laws of physics.

Contribution

  • With a 5-dimensional input, in addition to the coordinates \((x,y,z)\), it also added the Viewing Direction \((\theta,\phi)\). This enables view-dependent color output.
  • Using a differentiable rendering technique based on the Volume Rendering formula, it optimizes by computing a Rendering Loss. Thanks to this, interpretable variables can be used, enabling View Synthesis that is consistent with physical concepts.
  • Positional Encoding and Hierarchical Sampling improve the ability to learn high-frequency information.

Methods

Architecture

Figure

The overall model structure is as follows:

(a) At each pixel of the image, a ray is cast and points along it are sampled. Then, for each sampling point on a single ray, the position coordinates and the viewing direction of the ray are given as input to the network. At this point, the input is mapped to a high dimension through Positional Encoding.

(b) The network outputs a density and a view-dependent color for each sampling point.

(c) The densities and colors of all sampling points on a single ray are combined to perform Volume Rendering. The output value becomes the predicted value for the pixel from which the ray was cast. Here, to represent high-frequency detail, learning is optimized through Hierarchical Volume Sampling, which performs additional sampling in regions of high density.

(d) Backpropagation is performed by computing the MSE Loss between the GT value of a pixel and the Volume-Rendered predicted value.

Network Structure

Figure

Looking only at the network \(F_{\Theta}\) structure of NeRF, it is quite concise, and its components are as follows:

  • \(F_{\Theta}: (\bold{x}, \bold{d}) \rightarrow (\bold{c}, \sigma)\)
  • Input: \((x,y,z,\theta, \phi)\)
    • \(\bold{x}=(x,y,z)\): position coordinates
    • \(\bold{d}=(\theta, \phi)\): viewing direction
  • Output: density \(\bold{\sigma}\), RGB radiance \(\bold{c}\)
    • \(\sigma\): the density at position \(\bold{x}\)
    • \(\bold{c}\): the RGB color at position \(\bold{x}\) and viewing direction \(\bold{d}\)

The network consists solely of fully-connected layers, and is trained to optimize the weights \(\Theta\) so as to map the input 5D coordinates to the corresponding volume density \(\sigma\) and view-dependent color \(\bold{c}\). Since the density must always be consistent across multiple views, learning proceeds using only \(\bold{x}\) in the 8 fc layers. It passes through a skip connection once at the fifth layer, and in the additional layer that outputs the density \(\sigma\), \(\bold{d}\) is added as input for the view-dependent \(\bold{c}\).

Since the density must always be greater than or equal to 0, the preceding 8 layers use ReLU as the activation function, and before outputting \(\bold{c}\), a Sigmoid function is used to normalize the color value.

Volume Rendering

Ray

In NeRF, to render a single pixel, the colors are accumulated along the ray \(\mathbf{r}(t)\) emitted from the camera. Since a ray is a kind of straight line,

it is expressed as \(\mathbf{r}(t) = \mathbf{o} + t\mathbf{d}\):

  • \(\mathbf{o}\) : the origin of the camera
  • \(\mathbf{d}\) : the viewing direction of the ray received as input
  • \(t\) : parameter

Volume Rendering

\[C(\mathbf{r}) = \int_{t_n}^{t_f} T(t)\sigma(\mathbf{r}(t))\mathbf{c}(\mathbf{r}(t),\mathbf{d})\,dt\,, \text{ where } T(t) = \exp\left(-\int_{t_n}^{t}\sigma(\mathbf{r}(s))\,ds\right).\]

This formula computes the radiance of a single ray. That is, it is the formula that determines a single “pixel” value. Our goal was to feed the \(\bold{c}, \sigma\) output from the network into this equation, predict a specific pixel value \(C(\bold{r})\), and compute the Loss by comparing it with the corresponding pixel value of the GT image.

Therefore, at a high level, this formula is the process of integrating, step by step, the radiance information based on the \(\bold{c}, \sigma\) value at points \(t\) on a specific ray from \(t_{near}\) to \(t_{far}\), to obtain the radiance value of the entire ray.

Looking at it in detail, it is as follows:

  • \(T(t)\sigma(\bold{r}(t))\): the collision probability at point \(t\). The probability that the ray maintains transparency up to \(t\) and then collides exactly at \(t\).
    • \(T(t)\): transparency. The probability that the ray passes through up to a specific point \(t\) without colliding

      Figure

      As \(t\) increases, \(T\) decreases, so consistency with the physical concept that was problematic in the voxel representation is achieved

    • \(\sigma(\bold{r}(t))\): extinction coefficient. The probability density of colliding at time \(t\)

  • \(c(\mathbf{r}(t), \mathbf{d})\) : the color at a specific position and viewing direction

Then, for this equation to actually be implemented in code, it is expressed not as a continuous integral but as a summation over sampled intervals, and consequently the radiance value for a single ray is derived through the following equation:

\[\hat{C}(\mathbf{r}) = \sum_{i=1}^{N} T_i (1 - \exp(-\sigma_i \delta_i)) \mathbf{c}_i \,, \ \text{where } T_i = \exp\left(-\sum_{j=1}^{i-1} \sigma_j \delta_j\right)\]

Figure

As a result, as shown in the figure, view-dependent radiance, where the color appears differently depending on the direction, can be represented.

Optimization

Positional Encoding

\[\gamma(p) = \left( \sin(2^0 \pi p), \cos(2^0 \pi p), \cdots, \sin(2^{L-1} \pi p), \cos(2^{L-1} \pi p) \right)\]

Positional Encoding aids in learning high-frequency features.

\(\gamma\) is a function that maps \(\mathbb{R}\) to the high dimension \(\mathbb{R}^{2L}\); similar in form to the positional encoding that appears in the Transformer model architecture, it expands the dimension through sine and cosine transforms, and applied to the input value, the network consequently receives \((\gamma(\mathbf{x}), \gamma(\mathbf{d}))\) as input instead of \((\mathbf{x}, \mathbf{d})\).

The paper states that experimentally the best performance was obtained when \(L=10\).

Hierarchical Volume Sampling

Figure

Likewise, to represent high-frequency information, when sampling a ray, it first samples the large-scale features at uniform intervals, and once again in the high-density intervals.

For this, NeRF uses two networks:

  • Coarse Network
    • Draws \(N_c\) samples along the ray and predicts color and density.
    • Stratified Sampling
  • Fine Network
    • Uses the results of the Coarse Network to additionally sample important regions
    • Draws \(N_f\) additional samples, intensively sampling the more important regions based on the density \(\sigma\) values computed by the Coarse network
    • Non-uniform sampling

Figure

Figure

The ablation study demonstrates that Positional Encoding and Hierarchical Volume Sampling effectively improve model performance.

\[\mathcal{L} = \sum_{\mathbf{r} \in \mathcal{R}} \left[ \left\Vert \hat{C}_c(\mathbf{r}) - C(\mathbf{r}) \right\Vert _2^2 + \left\Vert \hat{C}_f(\mathbf{r}) - C(\mathbf{r}) \right\Vert _2^2 \right]\]

Finally, the Loss is obtained by summing, over all rays, the MSE Loss of the Coarse network output and the MSE Loss of the Fine network output.

Limitation

  • It cannot be applied to Dynamic Scenes.
  • It is not Generalizable.
  • It is slow, so real-time inference is impossible.
  • Lighting cannot be adjusted.