---
id: "nerf"
title: "Neural Radiance Fields (NeRF)"
aliases: [NeRF]
domain: "capture"
stage: "capture"
realtime: "offline"
platforms: [cuda, python]
year_introduced: 2020
inputs: [photos, camera-poses]
outputs: [radiance-field]
style: "photoreal"
dynamic: "static"
cost: "offline"
authority: "Mildenhall et al., 2020"
url: "https://texelatlas.vercel.app/t/nerf/"
sources_verified_at: "2026-11-29"
---
# Neural Radiance Fields (NeRF) (Mildenhall et al., 2020)

> Represents a scene as an MLP mapping position and view direction to density and colour, trained by differentiable volume rendering to reproduce posed input photos.

## Reach for it when

- synthesise new views from a set of photos
- want an implicit volumetric scene representation
- learn a scene's geometry and colour from images alone
- photo capture to view-dependent renders with a neural net
- baseline for neural scene reconstruction

## How it works

An MLP takes a 3D point (after sinusoidal positional encoding) and viewing direction and outputs volume density and view-dependent RGB. To render a pixel, rays are cast through the camera, points are sampled along each ray (coarse then importance-sampled fine), and colours are alpha-composited using the densities. The loss is simply the photometric error against the training image, and gradients flow through the compositing into the network. Density depends only on position and colour on position plus direction, which encourages consistent geometry with specular effects. Training needs camera poses, typically from [Structure-from-Motion (COLMAP)](https://texelatlas.vercel.app/t/structure-from-motion-colmap.md). The original takes hours per scene and seconds per frame, which later work cut by orders of magnitude.

## When to use it

Choose it as a conceptual baseline or when you need an implicit volumetric representation to experiment with. Prefer [Instant NGP (Multiresolution Hash Encoding)](https://texelatlas.vercel.app/t/instant-ngp.md) for the same model trained in seconds, [3D Gaussian Splatting](https://texelatlas.vercel.app/t/gaussian-splatting-3dgs.md) for real-time rendering, and [NeuS](https://texelatlas.vercel.app/t/neus.md) or [Neuralangelo](https://texelatlas.vercel.app/t/neuralangelo.md) when you need a clean surface rather than a density field.

## Cost

offline — Original formulation: hours of training and several seconds per rendered frame on a single GPU, per the paper's reported setup.
Measured GPU Weight: 127.68× baseline (extreme) — 3.9582 ms median / 4.2383 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 110.75× baseline (extreme) — 1.761 ms median (2.25× faster on L4).
Ampere A100 scaling: 86.51× baseline (extreme) — 2.4914 ms median (1.59× faster on A100).

## Failure modes

- Floaters and fog in empty space when views are sparse or poses are noisy
- Blurry or aliased renders at differing zoom levels because rays are treated as infinitely thin
- Extracted geometry from density is bumpy and not watertight
- Unbounded scenes and distant backgrounds need special parameterisation or they collapse

## Engine support

- blender: plugin — `Blender add-on: BlenderNeRF (dataset/camera export for NeRF training)` (evidence: https://github.com/maximeraafat/BlenderNeRF, checked 2026-12-01) — Creates synthetic NeRF datasets; training is external.

## Dataflow

- Inputs: photos, camera-poses
- Outputs: radiance-field
- Platforms: cuda, python

## Presets

### NeRF Volumetric Raymarching — transmittance & density field (left) vs view-dependent radiance (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_SIGMA_SCALE": 4.5,
  "P_VIEW_DEP": 1,
  "P_ROT_SPEED": 0.65,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_SIGMA_SCALE = 4.5; // P Density Sigma [1.0, 10.0, 0.25]
const float P_VIEW_DEP = 1.0; // P View-Dep Spec [0.0, 2.0, 0.05]
const float P_ROT_SPEED = 0.65; // P Orbit Speed [0.0, 2.2, 0.05]
const float P_SPLIT = 0.48; // P Density / NeRF Split [0.0, 1.0, 0.02]

mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }

// Continuous neural radiance field F_theta(x, d) -> (sigma, rgb)
// Encodes a translucent iridescent botanical lotus-torus with nested glowing filaments
void evalNeRF(vec3 p, vec3 rd, float sigmaGain, float viewGain, out float sigma, out vec3 rad) {
  float r = length(p);
  // Outer translucent shell + nested twisted rings
  vec2 qTor = vec2(length(p.xz) - 0.48, p.y);
  float dRing = length(qTor) - 0.16;
  float ang = atan(p.z, p.x);
  float petals = 0.075 * sin(ang * 5.0 + p.y * 6.0) * cos(r * 8.0);

  float dCore = length(p) - 0.30 + petals * 0.6;
  float dHalo = abs(length(p) - 0.64) - 0.045;

  // Soft continuous volume density sigma(x) >= 0 (ReLU-like softplus around implicit shells)
  float sCore = exp(-max(dCore, 0.0) * 18.0) * smoothstep(0.18, -0.05, dCore);
  float sRing = exp(-max(dRing, 0.0) * 20.0) * smoothstep(0.14, -0.04, dRing);
  float sHalo = exp(-abs(dHalo) * 32.0) * 0.42;

  // Fine high-frequency positional-encoding gamma(x) volumetric veins
  float peVeins = 0.55 + 0.45 * sin(p.x * 14.0 + p.y * 11.0) * cos(p.z * 14.0);
  sigma = (sCore * 1.15 + sRing * 0.95 + sHalo * peVeins) * sigmaGain;

  // Gradient proxy for view-dependent radiance c(x, d)
  vec3 nEst = normalize(p + vec3(0.001));
  float ndv = clamp(dot(nEst, -rd), 0.0, 1.0);
  float fres = pow(1.0 - ndv, 2.5);

  vec3 coreCol = mix(vec3(0.96, 0.42, 0.18), vec3(1.0, 0.86, 0.32), smoothstep(-0.25, 0.35, p.y));
  vec3 ringCol = mix(vec3(0.12, 0.68, 0.96), vec3(0.68, 0.32, 0.96), 0.5 + 0.5 * sin(ang * 2.0));
  vec3 baseC = (sCore > sRing) ? coreCol : ringCol;
  baseC = mix(baseC, vec3(0.24, 0.96, 0.84), sHalo / max(sCore + sRing + sHalo, 1e-4));

  // View-dependent directional MLP color term (iridescent Fresnel rim + anisotropic highlight)
  vec3 lDir = normalize(vec3(0.55, 0.78, 0.45));
  float spec = pow(max(dot(nEst, normalize(lDir - rd)), 0.0), 28.0);
  vec3 viewShift = (vec3(0.32, 0.78, 1.0) * fres * 0.72 + vec3(1.0, 0.95, 0.88) * spec * 0.85) * viewGain;
  rad = baseC * (0.45 + 0.65 * max(dot(nEst, lDir), 0.0)) + viewShift;
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool isRadiance = screenX >= split;
  float sigmaGain = clamp(P_SIGMA_SCALE, 0.8, 12.0);
  float viewGain = clamp(P_VIEW_DEP, 0.0, 2.2);
  float spin = iTime * max(P_ROT_SPEED, 0.0);

  vec3 ro = vec3(0.0, 0.24, 2.25);
  vec3 rd = normalize(vec3(uv - vec2(0.0, 0.04), -1.52));

  // Orbit camera around volume
  ro.xz = rot2(spin * 0.55) * ro.xz;
  rd.xz = rot2(spin * 0.55) * rd.xz;

  vec3 bg = mix(vec3(0.020, 0.028, 0.048), vec3(0.056, 0.075, 0.125), smoothstep(-0.55, 0.55, uv.y));

  // Bounding sphere intersection R = 1.05 for stratified NeRF quadrature
  float b = dot(ro, rd);
  float c = dot(ro, ro) - 1.05 * 1.05;
  float disc = b * b - c;

  vec3 accum = vec3(0.0);
  float T = 1.0;
  float expectedDepth = 0.0;
  float weightSum = 0.0;

  if (disc > 0.0) {
    float tNear = max(-b - sqrt(disc), 0.1);
    float tFar = -b + sqrt(disc);
    int steps = 48;
    float dt = (tFar - tNear) / float(steps);

    for (int i = 0; i < 48; i++) {
      float t = tNear + (float(i) + 0.5) * dt;
      vec3 p = ro + rd * t;
      float sigma;
      vec3 rad;
      evalNeRF(p, rd, sigmaGain, viewGain, sigma, rad);

      // Exact NeRF volume rendering quadrature: alpha_i = 1 - exp(-sigma_i * dt)
      float alpha = 1.0 - exp(-sigma * dt);
      float w = T * alpha;
      accum += w * rad;
      expectedDepth += w * (t - tNear) / max(tFar - tNear, 1e-4);
      weightSum += w;
      T *= (1.0 - alpha);
      if (T < 0.01) break;
    }
  }

  vec3 col;
  if (!isRadiance) {
    // Left: accumulated opacity (1 - T) & expected termination depth colormap (turbo-like plasma ramp)
    float op = 1.0 - T;
    float dNorm = clamp(expectedDepth / max(weightSum, 1e-4), 0.0, 1.0);
    vec3 depthCol = mix(vec3(0.12, 0.88, 0.94), vec3(0.98, 0.42, 0.16), dNorm);
    depthCol = mix(depthCol, vec3(0.54, 0.24, 0.94), smoothstep(0.6, 1.0, dNorm));
    // Iso-depth bands visualizing discrete raymarch quadrature samples
    float bands = 0.78 + 0.22 * cos(dNorm * 32.0);
    col = mix(bg, depthCol * bands * 1.15, op);
  } else {
    // Right: full NeRF alpha-composited view-dependent radiance
    col = accum + T * bg;
  }

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);

  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extended by [Instant NGP (Multiresolution Hash Encoding)](https://texelatlas.vercel.app/t/instant-ngp.md)
- extended by [Mip-NeRF 360](https://texelatlas.vercel.app/t/mip-nerf-360.md)

## Combines with

- [Structure-from-Motion (COLMAP)](https://texelatlas.vercel.app/t/structure-from-motion-colmap.md): COLMAP poses are the camera input that NeRF training assumes.

## Combination ideas

- [Baking trained NeRF radiance fields into directional mesh lightmaps](https://texelatlas.vercel.app/ideas/nerf-oracle-lightmap-baking/)

## Sources

1. [primary] Ben Mildenhall, Pratul P. Srinivasan, Matthew Tancik, Jonathan T. Barron, Ravi Ramamoorthi, Ren Ng (2020) NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis. arXiv preprint (cs.CV). https://arxiv.org/abs/2003.08934 (verified via arxiv on 2026-11-29)
2. [implementation] bmild (2020) bmild/nerf. https://github.com/bmild/nerf License: MIT. (verified via github on 2026-11-29)
3. [implementation] nerfstudio-project (2022) nerfstudio-project/nerfstudio. https://github.com/nerfstudio-project/nerfstudio License: Apache-2.0. (verified via github on 2026-11-29)
4. [tutorial] Nerfstudio team Nerfstudio documentation. docs.nerf.studio. https://docs.nerf.studio/ (verified via http on 2026-11-29)

## Cite this entry

Texel. "Neural Radiance Fields (NeRF)." https://texelatlas.vercel.app/t/nerf/ (accessed 2026-12-01).
