---
id: "surfel-gi"
title: "Surfel-Based Global Illumination (GIBS)"
aliases: [GIBS, surfel cache]
domain: "gi"
stage: "lighting"
realtime: "realtime"
platforms: [desktop-gpu]
year_introduced: 2021
inputs: [gbuffer, depth, mesh]
outputs: [radiance, irradiance-probes]
style: "photoreal"
dynamic: "dynamic"
cost: "medium"
authority: "Halen et al."
url: "https://texelatlas.vercel.app/t/surfel-gi/"
sources_verified_at: "2026-11-29"
---
# Surfel-Based Global Illumination (GIBS) (Halen et al.)

> Covers visible geometry with small oriented discs (surfels) that cache irradiance, updated by hardware ray tracing and reused across frames; pixels shade by gathering nearby surfels. No bake, no UVs.

## Reach for it when

- dynamic gi without probes or baked data
- indirect light on large open worlds in real time
- diffuse bounce that follows geometry detail
- gi must work with fully dynamic scenes cheaply

## How it works

Surfels are position, normal and radius records spawned on demand from the G-buffer. Each frame the pipeline tests screen tiles for coverage by existing surfels; where coverage is insufficient, new surfels are spawned (and ones that fall out of use are recycled), so the cache follows the camera. A spatial hash or grid lets any point quickly find the surfels around it.

Each surfel owns a small budget of rays per frame. It traces them with hardware ray tracing, shading hits using the surfel cache itself as a source of multi-bounce light, and blends the new samples into the stored irradiance (stored as a low-order basis or a small octahedral map). Allocating more rays to surfels that are new or whose result changed concentrates work where it matters.

At shading time, a pixel finds nearby surfels whose disks contain its position, weights them by distance and normal, and sums their irradiance. The result is combined with other contributors in a lighting buffer.

## When to use it

Choose it for fully dynamic diffuse GI in an engine where baking or UV unwrapping is not acceptable, you can afford hardware ray tracing, and the camera sees a bounded amount of geometry.

Prefer [ddgi](ddgi) when you want a regular grid with simple lookups and a fixed memory footprint. Prefer [lumen-gi](lumen-gi) for SDF-based software tracing and large scenes. Prefer [restir-gi](restir-gi) when you need per-pixel indirect accuracy. Prefer [lightmap-baking](lightmap-baking) when the scene is static and you need the lowest runtime cost.

## Cost

medium — Cost scales with the surfel count times rays per surfel plus spatial hash lookups in shading; the cache is capped for a fixed memory budget.
Measured GPU Weight: 69.78× baseline (extreme) — 2.1631 ms median / 2.3056 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 59.99× baseline (heavy) — 0.9539 ms median (2.27× faster on L4).
Ampere A100 scaling: 47.93× baseline (heavy) — 1.3804 ms median (1.57× faster on A100).

## Failure modes

- Surfel popping and temporal instability when surfels spawn or retire as the camera moves
- Light leaking at thin walls or corners where a surfel disk spans two surfaces
- Coverage gaps and noise in fast-moving or newly revealed areas until the cache converges
- Large dynamic moving objects can invalidate surfels and produce trailing lighting

## Engine support

- unreal: builtin — `Lumen Global Illumination parameterizes scene geometry into Surface Cache Mesh Cards and world-space Radiance Cache probes` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/lumen-technical-details-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: gbuffer, depth, mesh
- Outputs: radiance, irradiance-probes
- Platforms: desktop-gpu

## Presets

### Surfel GI (GIBS) — world-space oriented surfel disks (left) vs filtered surfel irradiance (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_SURFEL_SIZE": 0.16,
  "P_BOUNCE_GAIN": 1.3,
  "P_DISK_EDGE": 0.85,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_SURFEL_SIZE = 0.16; // P Surfel Radius [0.08, 0.28, 0.01]
const float P_BOUNCE_GAIN = 1.30; // P Indirect GI [0.3, 2.2, 0.05]
const float P_DISK_EDGE = 0.85; // P Disk Outlines [0.0, 1.5, 0.05]
const float P_SPLIT = 0.48; // P Surfels / GI Split [0.0, 1.0, 0.02]

vec3 hash33(vec3 p) {
  p = fract(p * vec3(0.1031, 0.1030, 0.0973));
  p += dot(p, p.yxz + 33.33);
  return fract((p.xxy + p.yxx) * p.zyx);
}

float sdBox(vec3 p, vec3 b) {
  vec3 q = abs(p) - b;
  return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}

vec2 mapScene(vec3 p) {
  vec2 res = vec2(p.y + 0.85, 1.0);
  float dC = 1.05 - p.y; if (dC < res.x) res = vec2(dC, 1.0);
  float dB = p.z + 1.42; if (dB < res.x) res = vec2(dB, 1.0);
  float dL = p.x + 1.30; if (dL < res.x) res = vec2(dL, 2.0);
  float dR = 1.30 - p.x; if (dR < res.x) res = vec2(dR, 3.0);

  float dSph = length(p - vec3(-0.32, -0.45, -0.20)) - 0.39;
  if (dSph < res.x) res = vec2(dSph, 4.0);
  float dBlk = sdBox(p - vec3(0.50, -0.50, -0.32), vec3(0.28, 0.35, 0.28)) - 0.02;
  if (dBlk < res.x) res = vec2(dBlk, 4.0);
  return res;
}

vec3 calcNormal(vec3 p) {
  vec2 e = vec2(0.0022, 0.0);
  return normalize(vec3(
    mapScene(p + e.xyy).x - mapScene(p - e.xyy).x,
    mapScene(p + e.yxy).x - mapScene(p - e.yxy).x,
    mapScene(p + e.yyx).x - mapScene(p - e.yyx).x
  ));
}

vec3 evalBounce(vec3 p, vec3 n, float t) {
  vec3 sunHit = vec3(0.42 * sin(t * 0.6), -0.84, -0.25);
  float dSun = length(p - sunHit);
  vec3 warmBounce = vec3(1.25, 0.72, 0.28) * exp(-dSun * 1.15) * (0.35 + 0.65 * max(dot(n, normalize(sunHit - p)), 0.0));
  vec3 redWall = vec3(0.90, 0.22, 0.20) * clamp(1.0 - (p.x + 1.30) * 0.5, 0.0, 1.0) * 0.55;
  vec3 tealWall = vec3(0.14, 0.76, 0.82) * clamp(1.0 - (1.30 - p.x) * 0.5, 0.0, 1.0) * 0.55;
  float ao = clamp(0.38 + 0.62 * mapScene(p + n * 0.26).x / 0.26, 0.18, 1.0);
  return (warmBounce + redWall + tealWall + vec3(0.14, 0.16, 0.22)) * ao;
}

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 isSmooth = screenX >= split;
  float sRad = clamp(P_SURFEL_SIZE, 0.07, 0.30);
  float giGain = clamp(P_BOUNCE_GAIN, 0.2, 2.4);
  float edgeVis = clamp(P_DISK_EDGE, 0.0, 1.5);

  vec3 ro = vec3(0.0, 0.04, 2.35);
  vec3 rd = normalize(vec3(uv, -1.52));

  vec3 col = vec3(0.02);
  float t = 0.0;
  float matId = 0.0;
  bool hit = false;
  for (int i = 0; i < 64; i++) {
    vec2 h = mapScene(ro + rd * t);
    if (h.x < 0.002) { hit = true; matId = h.y; break; }
    t += h.x;
    if (t > 9.0) break;
  }

  if (hit) {
    vec3 p = ro + rd * t;
    vec3 n = calcNormal(p);

    vec3 alb = vec3(0.76, 0.76, 0.78);
    if (matId > 1.5 && matId < 2.5) alb = vec3(0.90, 0.24, 0.20);
    if (matId > 2.5 && matId < 3.5) alb = vec3(0.14, 0.74, 0.80);

    vec3 lPos = vec3(0.42 * sin(iTime * 0.6), 0.94, -0.20);
    vec3 lDir = normalize(lPos - p);
    float ndl = max(dot(n, lDir), 0.0);

    // Allocate world-space surfels in a 3D uniform hash grid and gather Mahalanobis disk weights
    float cell = sRad * 1.15;
    vec3 cid = floor(p / cell);

    vec3 surfelIrr = vec3(0.0);
    float wTot = 0.0;
    float bestD = 1e5;
    vec3 bestIdCol = vec3(0.5);
    vec3 bestIrr = vec3(0.0);
    float diskRim = 0.0;

    for (int dz = -1; dz <= 1; dz++) {
      for (int dy = -1; dy <= 1; dy++) {
        for (int dx = -1; dx <= 1; dx++) {
          vec3 nb = cid + vec3(float(dx), float(dy), float(dz));
          vec3 rnd = hash33(nb);
          vec3 sp = (nb + 0.18 + 0.64 * rnd) * cell;
          // Project surfel disk onto surface plane so disks tile cleanly across geometry
          vec3 sOnSurf = sp - n * dot(sp - p, n);
          float d = length(p - sOnSurf);
          float q = d / max(sRad, 0.04);
          if (q < 1.0) {
            // Smooth cubic surfel kernel weight (1 - q)^2
            float w = (1.0 - q) * (1.0 - q);
            vec3 irr = evalBounce(sOnSurf, n, iTime) * giGain;
            surfelIrr += irr * w;
            wTot += w;
            diskRim = max(diskRim, smoothstep(0.09, 0.015, abs(q - 0.86)));
          }
          if (d < bestD) {
            bestD = d;
            bestIdCol = 0.35 + 0.65 * hash33(nb + 19.7);
            bestIrr = evalBounce(sOnSurf, n, iTime) * giGain;
          }
        }
      }
    }

    vec3 filteredGI = (wTot > 1e-4) ? (surfelIrr / wTot) : evalBounce(p, n, iTime) * giGain;

    if (!isSmooth) {
      // Left: raw discrete world-space surfel disks showing cached radiance & allocation tiling
      float inDisk = smoothstep(sRad * 0.94, sRad * 0.84, bestD);
      vec3 diskFill = mix(bestIrr * 0.85, bestIdCol * 0.45 + bestIrr * 0.65, 0.25);
      col = mix(vec3(0.05, 0.07, 0.10), diskFill, inDisk);
      col = mix(col, vec3(0.95, 0.97, 1.0), diskRim * 0.42 * min(edgeVis, 1.2));
    } else {
      // Right: smoothly filtered surfel GI + direct key light
      col = alb * (ndl * 0.55 + filteredGI);
    }
  }

  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.

## Combines with

- [ReSTIR GI: Path Resampling for Real-Time Path Tracing](https://texelatlas.vercel.app/t/restir-gi.md): Surfel irradiance gives a stable low-frequency fallback while resampling adds detail.

## Combination ideas

- [Dynamic surfel GI inside carved snow trenches and footprints](https://texelatlas.vercel.app/ideas/deformed-snow-surfel-gi/)

## Sources

1. [primary] Henrik Halen, Andreas Brinck, Kyle Hayward, Xiangshun Bei Global Illumination Based on Surfels. SIGGRAPH 2021 Advances in Real-Time Rendering. https://advances.realtimerendering.com/s2021/index.html (verified via http on 2026-11-29)

## Cite this entry

Texel. "Surfel-Based Global Illumination (GIBS)." https://texelatlas.vercel.app/t/surfel-gi/ (accessed 2026-12-01).
