glTF Point Light Attenuation and Distance Cutoff

This article explains the mathematical cutoff mechanism used in glTF-compliant rendering engines to limit the infinite evaluation of point lights. While standard physics dictates an infinite inverse-square falloff, real-time engines rely on defined range thresholds and smooth mathematical windowing functions to eliminate distant calculations, prevent visual popping, and maintain high rendering performance.

The Problem with True Inverse-Square Falloff

In classical physics, the intensity of light emitted from an idealized point source diminishes according to the inverse-square law:

\[\text{Intensity} = \frac{I}{d^2}\]

Where \(I\) is the luminous intensity and \(d\) is the Euclidean distance from the light source to the surface fragment. Mathematically, this value approaches zero as \(d \to \infty\), but it never actually reaches zero. If a real-time graphics engine strictly followed this equation, every point light would theoretically influence every surface in a 3D scene, requiring infinite evaluation passes and severely impacting frame rates.

The glTF Range Parameter

To solve this computational bottleneck, the official glTF punctual lights specification (KHR_lights_punctual) introduces an optional range property (\(r\)). When defined, the light's contribution must strictly fall to zero at or beyond this radius.

Simply clamping the light to zero at \(d = r\) using a step function creates an abrupt, visually jarring boundary artifact known as "light popping." To eliminate this, glTF engines employ a smooth windowing function that modifies the inverse-square curve so that both the light intensity and its derivative hit zero precisely at the cutoff distance.

The Mathematical Cutoff Function

The glTF specification adopts the smooth distance attenuation model originally standardized by Epic Games and Frostbite for real-time physically based rendering (PBR).

The full attenuation factor combines inverse-square decay with a quartic falloff cutoff:

\[\text{Attenuation}(d, r) = \frac{\text{saturate}\left(1 - \left(\frac{d}{r}\right)^4\right)^2}{d^2}\]

In this formula:

  • \(d\) is the distance between the light source and the shading point.
  • \(r\) is the specified cutoff radius (range).
  • \(\text{saturate}(x)\) clamps the input strictly between \(0\) and \(1\): \(\max(0, \min(1, x))\).

The numerator serves as the mathematical cutoff:

\[\text{Window}(d, r) = \max\left(0, 1 - \left(\frac{d}{r}\right)^4\right)^2\]

Why the Quartic Curve is Used

Raising the ratio \((d/r)\) to the fourth power achieves two essential characteristics for real-time rendering:

  1. Preservation of Physical Accuracy: For most of the light's active radius (\(d \ll r\)), the fraction \((d/r)^4\) remains negligible, allowing the light to closely follow the true \(1/d^2\) curve without visible distortion.
  2. Smooth Boundary Gradient: As \(d\) approaches \(r\), the curve drops steeply toward zero. Squaring the result ensures that the first derivative (the slope) reaches zero at \(d = r\). Because the transition is \(C^1\) continuous, the light fades out imperceptibly without hard seams or visual ring artifacts.

Engine Culling and Optimization

Once this mathematical cutoff is applied, a point light has an absolute sphere of influence defined by radius \(r\). glTF renderers can construct a bounding sphere around the light position:

  • Frustum Culling: Lights whose bounding spheres lie outside the camera's viewing frustum are discarded before rendering.
  • Tiled and Clustered Shading: Modern forward+ and deferred engines bin lights into spatial grid cells (clusters). Any cell outside the light's radius \(r\) completely omits that light's index.
  • Shader Early-Exit: Within fragment shaders, if a distance calculation reveals \(d \ge r\), the shader can discard or bypass light evaluation immediately, preventing unnecessary shading calculations.