v9.1.1
Menu

Volume Rendering Weights

mediumFREENeural 3D RepresentationsNeural 3DCV: 3D Reconstruction

Compute volume rendering weights along a ray for NeRF.

NeRF renders images by accumulating color along rays. The weight at each sample point is:

wi=Ti⋅αiw_i = T_i \cdot \alpha_i

where:

  • αi=1−exp⁡(−σi⋅δi)\alpha_i = 1 - \exp(-\sigma_i \cdot \delta_i) is the opacity
  • Ti=exp⁡(−∑j<iσj⋅δj)T_i = \exp\left(-\sum_{j<i} \sigma_j \cdot \delta_j\right) is the transmittance
  • σi\sigma_i is the density at sample ii
  • δi\delta_i is the step size (distance to next sample)

The weight represents how much each sample contributes to the final pixel color.

Example

Input
volume_weights([1, 1, 1], [1, 1, 1])
Output
[0.6321, 0.2325, 0.0855]
Reasoning
  • Inputs: densities σ=[1,1,1]\sigma = [1, 1, 1] and deltas δ=[1,1,1]\delta = [1, 1, 1] describe three samples along one ray, each with density 1 over a segment of length 1, so every product σiδi=1\sigma_i \delta_i = 1.
  • Opacity is identical for all three samples: αi=1−e−1≈0.6321\alpha_i = 1 - e^{-1} \approx 0.6321.
  • Transmittance is the light that survives every earlier segment: T0=e0=1T_0 = e^{0} = 1 (nothing in front of it), T1=e−1≈0.3679T_1 = e^{-1} \approx 0.3679, T2=e−(1+1)=e−2≈0.1353T_2 = e^{-(1+1)} = e^{-2} \approx 0.1353.
  • Weights wi=Tiαiw_i = T_i \alpha_i: w0=1×0.6321=0.6321w_0 = 1 \times 0.6321 = 0.6321, w1=0.3679×0.6321≈0.2325w_1 = 0.3679 \times 0.6321 \approx 0.2325, w2=0.1353×0.6321≈0.0855w_2 = 0.1353 \times 0.6321 \approx 0.0855, giving [0.6321, 0.2325, 0.0855] (shown rounded to 4 decimal places).
  • Notice the weights shrink even though the samples are identical: later samples sit behind earlier ones. They sum to 1−e−3≈0.95021 - e^{-3} \approx 0.9502, not 1, because e−3e^{-3} of the light passes through the whole ray. With all densities 0, every αi=0\alpha_i = 0 and every weight is 0.

Constraints

  • densities: list of σ values at each sample
  • deltas: list of step sizes between samples
  • Return list of weights

Learn this in

More from CV: 3D Reconstruction

solution.py

Test results

Sign in to run your code against the test cases.