---
id: "enhanced-sphere-tracing"
title: "Enhanced Sphere Tracing"
domain: "geometry"
stage: "geometry"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, cuda]
year_introduced: 2014
inputs: [sdf]
outputs: [depth, normals]
style: "both"
dynamic: "dynamic"
cost: "medium"
authority: "Keinert et al., 2014"
url: "https://texelatlas.vercel.app/t/enhanced-sphere-tracing/"
sources_verified_at: "2026-11-29"
---
# Enhanced Sphere Tracing (Keinert et al., 2014)

> Sphere tracing with over-relaxation: step slightly beyond the safe distance and fall back only when consecutive spheres fail to overlap. Cuts iteration counts, especially for near-grazing rays, with a pixel-exact result.

## Reach for it when

- ray marching is slow at grazing angles
- too many iterations per pixel on distance fields
- want faster raymarcher without changing the result
- shader steps crawl along surfaces seen at a slant
- reduce march step count in an sdf scene

## How it works

Standard sphere tracing steps exactly by the distance d. Enhanced sphere tracing multiplies the step by a relaxation factor omega (around 1.2 to 1.6). After the step, it checks whether the new sphere still overlaps the previous one: the sum of the two radii must be at least the step length. If the check fails, it undoes the relaxation for that step and falls back to the safe step. It also uses the unrelaxed ray parameter with the smallest error to pick the best hit estimate. Automatic variants adapt omega per ray using the local curvature estimate. Some versions add a final refinement from the last spheres so grazing hits are resolved more precisely.

## When to use it

Choose it as a drop-in speed-up for any sphere-traced scene where fields are exact or conservative and you see slow grazing pixels. Prefer plain [Sphere Tracing](https://texelatlas.vercel.app/t/sphere-tracing.md) when your field is far from 1-Lipschitz and fall-backs would be constant, and [Segment Tracing](https://texelatlas.vercel.app/t/segment-tracing.md) when you can supply local Lipschitz constants for warped or animated fields.

## Cost

medium — Typically fewer iterations than basic sphere tracing at the cost of a few extra operations per step; gains depend on scene geometry.
Measured GPU Weight: 11.65× baseline (moderate) — 0.3832 ms median / 0.3897 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 10.11× baseline (moderate) — 0.1608 ms median (2.38× faster on L4).
Ampere A100 scaling: 7.12× baseline (moderate) — 0.2052 ms median (1.87× faster on A100).

## Failure modes

- Overstep followed by backtrack wastes work on cluttered scenes
- Poorly chosen omega leads to rejected relaxations on every step and no gain
- Still assumes a Lipschitz-1 field; warps break the overlap test's guarantees
- Divergent step counts across a warp reduce GPU efficiency

## Dataflow

- Inputs: sdf
- Outputs: depth, normals
- Platforms: webgl2, webgpu, desktop-gpu, cuda

## Presets

### Over-relaxed sphere tracing step counts vs plain sphere tracing (glsl-fragment; rendered 2026-11-29)

```json
{
  "MAX_STEPS": 48,
  "OMEGA": 1.6,
  "EPS": 0.001
}
```

```glsl
// Over-relaxed sphere tracing (omega 1.6 with fallback): left = plain tracing steps, right = relaxed steps, same heat scale.
const int MAX_STEPS = 48;
const float OMEGA = 1.6;
const float EPS = 0.001;
float map(vec3 p) {
    float s = length(p - vec3(-0.9, 0.0, 0.0)) - 0.8;
    vec2 q = vec2(length(p.xz - vec2(1.0, 0.2)) - 0.8, p.y);
    float t = length(q) - 0.25;
    float b = p.y + 0.9;
    return min(min(s, t), b);
}
vec3 heat(float x) { return clamp(vec3(1.5 * x, 1.5 - abs(3.0 * x - 1.5), 1.5 - 1.5 * x), 0.0, 1.0); }
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
    vec3 ro = vec3(0.0, 1.0, -4.0), rd = normalize(vec3(uv.x, uv.y - 0.12, 1.4));
    float om = uv.x > 0.0 ? OMEGA : 1.0;
    float t = 0.0, prevR = 0.0, stepLen = 0.0; int n = 0; bool hit = false;
    for (int i = 0; i < MAX_STEPS; i++) {
        n = i;
        float r = map(ro + rd * t);
        if (om > 1.0 && stepLen > prevR + r) {          // overshoot: back up to the last safe step
            t += prevR - stepLen; stepLen = 0.0; prevR = 0.0; continue;
        }
        if (r < EPS * t + 0.0005) { hit = true; break; }
        stepLen = om * r; prevR = r; t += stepLen;
        if (t > 20.0) break;
    }
    vec3 col = heat(float(n) / float(MAX_STEPS));
    if (!hit && t > 20.0) col *= 0.35;
    col = mix(col, vec3(1.0), smoothstep(0.003, 0.0, abs(uv.x)));
    fragColor = vec4(pow(col, vec3(0.6)), 1.0);
}

```

Attribution: written for this index

## Lineage

- extends [Sphere Tracing](https://texelatlas.vercel.app/t/sphere-tracing.md)

## Combines with

- [SDF Modeling: CSG and Smooth Minimum](https://texelatlas.vercel.app/t/sdf-csg-smooth-min.md): Step bounds rely on the SDF being close to exact.

## Sources

1. [primary] Benjamin Keinert, Henry Schäfer, Johann Korndörfer, Urs Ganse, Marc Stamminger (2014) Enhanced Sphere Tracing. Smart Tools and Apps for Graphics - Eurographics Italian Chapter Conference. https://doi.org/10.2312/stag.20141233 (verified via doi.org on 2026-11-29)
2. [tutorial] Inigo Quilez Distance functions. iquilezles.org. https://iquilezles.org/articles/distfunctions (verified via http on 2026-11-29)

## Cite this entry

Texel. "Enhanced Sphere Tracing." https://texelatlas.vercel.app/t/enhanced-sphere-tracing/ (accessed 2026-12-01).
