3D vision: voxels, point clouds and NeRF

A photo is one 2D grid. With 3D you first have to choose how to store it: as cells, as points, as triangles, or as one function. Start by stepping through how NeRF makes the color of one pixel, one sample at a time.

Short answer. 3D can be stored as voxels (3D cells), a point cloud (a list of points), a mesh (triangles) or a function (an implicit representation), and each form needs a different kind of network. Voxels let you use convolution in 3D as it is, but they grow with the cube of the resolution. In a point cloud the order of the points means nothing, so the points are combined with an operation that ignores order (PointNet). NeRF stores a scene as one function and makes each pixel by combining the colors of points along a ray with volume rendering.

The square on the left is the pixel, and the gray arrow is the ray going from the pixel into the scene. The circles are samples on the ray (darker means more opaque), and the orange arrow is what this step's sample adds to the pixel. Under each sample, the left bar (gray) is the light Tᵢ that survived everything in front of it, and the right bar (in the sample's color) is its share Tᵢαᵢ. The same numbers are in the two rows under the bars. The opacities and colors are made up. They are not output from a trained NeRF, so this is a schematic.

Try this. 1) In "fog, then a wall", press "Next" to the end: the two fog samples add 0.2 and 0.24, and the wall (α 0.9) adds 0.504. Sample 7 behind the wall has α 0.7, but only 0.056 of the light reaches it, so it adds just 0.039. The light left at the end is 0.017. 2) In "wall in front", sample 3 (α 0.95) takes 0.95, and the two behind it add only 0.03 and 0.018. 3) In "thin fog only", every α is 0.15, yet the shares shrink: 0.15, 0.128, ... , 0.048, and 0.272 of the light is left at the end. The same fog shows less the further back it is.

Definitions

The text below explains with the small set of points and the single ray in the lab. Here are the definitions of the ideas this page uses.

voxel
One cell of a grid (a voxel grid) that splits 3D space into cubes of the same size. Each cell holds a value such as "full" or "empty". With N cells on a side, there are N³ cells.
point cloud
A collection of the coordinates of n points taken from an object's surface. The points are not connected, and the order in which they are written has no meaning.

{p1,p2,…,pn},pi∈ℝ3

permutation invariance
The property that a function gives the same value whatever permutation π reorders the input points. PointNet keeps this property by applying the same layer h to every point and combining them with max pooling, which picks the largest value in each entry.

f(pπ(1),…,pπ(n))=f(p1,…,pn)

g({p1,…,pn})=max(h(p1),…,h(pn))

NeRF (neural radiance field)
One scene stored in one fully connected neural network F. Given a position x in space and a viewing direction d, it outputs the volume density σ at that place and the color c seen from that direction.

F(x,d)=(σ,c)

volume rendering
The computation that combines the density and color of N samples on a ray into one pixel color C. The opacity αᵢ of sample i comes from its density σᵢ and the distance δᵢ to the next sample, and it is multiplied by the transmittance Tᵢ (with T₁ = 1), the light that survives all earlier samples to reach sample i, before adding up.

αi=1−exp(−σiδi)

Ti=∏j=1i−1(1−αj)

C=∑i=1NTiαici

3D Gaussian splatting
A method that stores a scene as many 3D Gaussians instead of a neural network and draws them by stamping them onto the screen. Training alternates between controlling the density of Gaussians (adding and removing them) and optimizing each Gaussian's anisotropic covariance (a shape that spreads by a different amount in each direction).

1. Ways to store 3D

A photo is always a width × height grid. 3D has no single shape like that, so you first pick a form.

voxels36 cells point cloud22 points mesh5 corners · 3 triangles
A schematic of the same house-shaped object in three forms, drawn as a cross-section (2D) to keep it readable. In 3D the voxels are cubes and the mesh faces are triangles in space. The dashed line is the true surface. Voxels turn the roof into stairs at the size of one cell, the point cloud has only points on the surface with nothing joining them, and the mesh follows the surface exactly with 5 corners and 3 triangles.
FormWhat it storesMemoryEasyHard
Depth mapdistances in a grid, from one viewpointone image (width × height)it is a 2D grid, so 2D convolution works as isonly the surface the camera sees. Nothing behind it
Voxel gridvalues in N × N × N cellsN³, the cube of the resolution (section 2)neighbors are fixed, so 3D convolution works as ishard to raise the resolution. Empty cells take space too
Point cloud(x, y, z) of n pointsn × 3, as many points as you tooktaken in directly, no conversion. Only surface pointsno fixed order or neighbors, so grid convolution does not apply directly (section 3)
Meshcorners and triangle facesas many as the corners and facesthe surface is connected, so it is easy to draw (render)the number of corners and how they connect differ per object, which makes it awkward as network input
Implicit (NeRF and others)one function (the network's weights)as many as the weights, separate from any cell countyou can ask about any spot (continuous)drawing one image takes a huge number of function calls (section 4)

2. Voxels: 3D convolution as is, memory cubed

In convolution, the kernel is a small window of weights that slides across the image left to right and top to bottom. A voxel grid is also a grid, so you make the kernel a 3 × 3 × 3 cube and slide it in width, height and depth. That is 3D convolution, and the ideas of kernels and pooling carry over from 2D unchanged.

The problem is size.

cells   = N × N × N = N³
memory  = N³ × (values per cell) × (bytes per value)
Ncells N³one float32 per cell
3232,768128 KiB
64262,1441 MiB
1282,097,1528 MiB
25616,777,21664 MiB

Doubling each side gives 2³ = 8 times the cells. The table is for one input with one value per cell, and when layers add channels it multiplies again. On top of that, every empty cell away from the surface takes up space. The PointNet paper also says that turning point clouds into voxel grids makes the data needlessly large.

3. Point clouds and PointNet: same answer in any order

A point cloud is a list of points. The same object can list its points in any order, and the order means nothing. According to the PointNet paper (Qi et al.), point clouds have an irregular format, so most earlier work turned them into voxel grids or collections of images, which makes the data needlessly large. PointNet takes the point cloud directly and respects permutation invariance of the input points, which means reordering the points does not change the answer. It also uses one architecture for object classification, part segmentation and scene semantic parsing (segmentation).

The idea that makes it ignore order: give every point the same small network (an MLP) on its own to get features, then combine those features with max pooling, which picks the largest value in each slot. The largest value is the same whatever order you look in, so the result is the same too.

g({p₁, p₂, …, pₙ}) = max( h(p₁), h(p₂), …, h(pₙ) )     (max in each slot)
h(p)               = ReLU(W p + b)                     (the h in this page's experiment)

OrderPoint (x, y)Features h = (x, y, max(0, y − x))

Try this. 1) In the first order, max pooling gives (5, 5, 3). The three largest values come from three different points: (5, 3), (4, 5) and (1, 4). 2) Press "Shuffle" once: #1 becomes (3, 2), and the start of the concatenated list changes from 1, 4, 3 to 3, 2, 0. Max pooling stays (5, 5, 3). 3) Shuffle as often as you like: the points and blue tags on the plane never move, only the orange numbers change. It is the same set of points, so it should give the same answer, and max pooling does. Six points, one layer and three features are a toy cut down so you can follow it by hand. In a real model h is several trained layers.

4. NeRF: a whole scene in one function

The NeRF (neural radiance field) paper (Mildenhall et al.) stores one scene in one fully connected network. The network represents the scene as a continuous function. Give it a 3D position and a viewing direction, and it returns the volume density at that spot and a color that depends on the viewing direction.

F(x, d) = (σ, c)

One image is drawn like this.

  1. For each pixel, shoot one ray from the camera into the scene.
  2. Pick several points (samples) along the ray.
  3. Call F at each sample to get σ and c.
  4. Combine the samples' colors and densities into one pixel color with classic volume rendering (section 5, experiment 1).

Training. This rendering is differentiable from start to end. So you can adjust F's weights until the rendered pixels match the pixels in the photos, and all you need is a set of photos and each photo's camera pose: where it was taken from and which way it faced. After training you can draw the scene from angles that no photo had, which is called novel view synthesis.

The NeRF paper expands the position and direction into many sine and cosine values before feeding them to F (positional encoding). This page does not cover that part.

5. Volume rendering by hand

Volume rendering is really an integral along the ray. Cut the ray into samples and add them up, and you get the sum below. Build it up from the front (the pixel side), one sample at a time.

  1. One sample. With opacity α₁ its color shows by α₁: C = α₁c₁. The rest of the light, 1 − α₁, passes behind it.
  2. Two samples. Only the surviving light 1 − α₁ reaches the second sample, so its share is (1 − α₁)α₂c₂.
  3. Sample i. Only the product of all the (1 − α) in front reaches sample i. That value is called the transmittance Tᵢ. The share is Tᵢαᵢcᵢ.
  4. Add them all. The sum of the shares is the pixel color. Adding all the shares Tᵢαᵢ and the light left at the end always gives 1 (checked on all three scenes in the experiment).
αᵢ = 1 − exp(−σᵢ δᵢ)
Tᵢ = (1 − α₁)(1 − α₂) … (1 − αᵢ₋₁),    T₁ = 1
C  = T₁α₁c₁ + T₂α₂c₂ + … + T_N α_N c_N

With three samples. Red (1, 0, 0) with α 0.4, green (0, 1, 0) with α 0.5 and blue (0, 0, 1) with α 1, in that order.

SampleαᵢTᵢShare TᵢαᵢWhy
1 red0.411 × 0.4 = 0.4it is in front, nothing hides it
2 green0.51 × (1 − 0.4) = 0.60.6 × 0.5 = 0.3red blocked 0.4 of the light
3 blue10.6 × (1 − 0.5) = 0.30.3 × 1 = 0.3only 0.3 is left after the two in front

The pixel color is C = 0.4·(1, 0, 0) + 0.3·(0, 1, 0) + 0.3·(0, 0, 1) = (0.4, 0.3, 0.3). Blue has α 1, so the light left behind it is 0.3 × (1 − 1) = 0, and the shares add up to 0.4 + 0.3 + 0.3 = 1. On its own blue is fully opaque, yet hidden behind the other two it gets only 0.3 of the pixel.

6. 3D Gaussian splatting: skip the empty space, draw in real time

NeRF calls the network at every sample on every pixel's ray, and many of those samples land in empty space. The 3D Gaussian splatting paper (Kerbl et al.) represents the scene with many 3D Gaussians instead of a network. Think of a 3D Gaussian as a soft, blurry ellipsoid blob that is dense in the middle and fades toward the edges. Drawing means stamping these blobs onto the screen (splatting).

7. When to use what

OptionGoodBadUse when
Depth map + 2D convolutionthe same 2D grid as an image, so 2D networks work as isonly the surface seen from one viewpointthe distance seen by one camera is enough
Voxels + 3D convolutionextends the ideas of 2D convolution directlygrows with the cube of the resolution. Empty cells take spacethe job works at a low resolution
Point cloud + PointNettakes the points directly, no conversion. One architecture for classification, part segmentation and scene parsingthe simple form on this page (each point alone, then max pooling) has no step that looks at nearby points togetheryou get data as points, as from a scanner, and want to classify or segment it
NeRFlearns from photos with known camera poses alone and draws new viewsdrawing calls the network for every sample of every pixel, which is a lot of workyou want to see a scene from new angles, given photos from many angles
3D Gaussian splattingskips work in empty space, real time at 1080pneeds the points from camera calibration to startnew views must be drawn in real time

Frequently asked

How is NeRF different from 3D Gaussian splatting?

NeRF stores a scene as one neural network function. For each pixel it calls that function at points along a ray and combines the colors with volume rendering. 3D Gaussian splatting stores the scene as many 3D Gaussians and draws them by splatting them onto the screen. It avoids wasted work in empty space, and the paper reports real-time novel view synthesis at 30 fps or more at 1080p.

Why not just concatenate the points in order and feed them to a network?

The order of the points means nothing, but concatenation turns the same set of points into a different input for every order. In experiment 2 the concatenated list changes every time you shuffle. So each point goes through the same layer, and an operation that ignores order, such as max pooling, combines them.

Why can't voxels simply use a higher resolution?

Because the number of cells is the resolution cubed. Doubling each side gives 8 times the cells. 128³ is 2,097,152 cells, which is 8 MiB even with one float32 per cell. 256³ is 64 MiB. Empty cells away from the surface take up space too.

Words

Plain words used hereTextbook term
a picture with a distance in each celldepth map
3D pixel · grid of 3D cellsvoxel · voxel grid
list of pointspoint cloud
corners and triangle facesmesh, vertex, face
storing as a functionimplicit representation
sliding a cube-shaped kernel3D convolution
same answer in any orderpermutation invariance
the same layer for every pointshared MLP, multilayer perceptron
largest value in each slotmax pooling
network that holds a sceneneural radiance field (NeRF)
combining colors along a rayvolume rendering
how thick · how much light is blockedvolume density · opacity (alpha)
surviving lighttransmittance
where a photo was taken from and which way it facedcamera pose
drawing from a new anglenovel view synthesis
stamping 3D blobs onto the screen3D Gaussian splatting
a shape that spreads differently in each directionanisotropic covariance

Sources

← Diffusion modelsRegistration: from rigid to non-rigid →