Role of IOR in glTF Total Internal Reflection

In glTF physically based rendering (PBR), the Index of Refraction (IOR) is the critical parameter that dictates how light bends and reflects when crossing the boundary between different media. Specifically, when handling transparent or transmissive materials via glTF extensions, the IOR determines the threshold at which refraction ceases and Total Internal Reflection (TIR) occurs. This article explains how the IOR defines the critical angle, drives Fresnel calculations, and enables accurate real-time rendering of total internal reflection within the glTF ecosystem.

The Critical Angle and Snell's Law

Total internal reflection is an optical phenomenon that happens strictly when light attempts to travel from an optically denser medium (higher IOR) to a rarer medium (lower IOR). In the glTF specification, the standard material assumes an external ambient medium of air, which has a baseline IOR of 1.0. The material's own IOR is defined using the KHR_materials_ior extension, which defaults to 1.5 for typical dielectric materials.

According to Snell’s Law:

\[n_1 \sin(\theta_1) = n_2 \sin(\theta_2)\]

Where \(n_1\) is the IOR inside the object, \(n_2\) is the IOR of the surrounding medium, \(\theta_1\) is the incident angle, and \(\theta_2\) is the refraction angle.

The IOR sets the critical angle (\(\theta_c\)), defined as:

\[\theta_c = \arcsin\left(\frac{n_2}{n_1}\right)\]

If light strikes the internal boundary at an angle greater than \(\theta_c\), a valid refraction angle (\(\theta_2\)) cannot exist because \(\sin(\theta_2)\) would exceed 1.0. At this point, the refraction ray is fully cancelled, and all energy is diverted into internal reflection.

Calculating Fresnel and TIR in glTF Shaders

glTF renderers utilize the material's IOR to calculate the Fresnel reflectance, which determines the ratio of reflected light to transmitted light. In standard surface shading, Schlick's approximation is commonly used to approximate Fresnel reflectance at the outer interface:

\[F_0 = \left(\frac{n_1 - n_2}{n_1 + n_2}\right)^2\]

However, when light exits a medium (such as the backside of a transmissive surface), standard approximations can fail unless adjusted for \(n_1 > n_2\). Real-time glTF shaders calculate the squared sine of the transmitted angle using the relative IOR (\(\eta = n_1 / n_2\)):

\[\sin^2(\theta_2) = \eta^2 (1 - \cos^2(\theta_1))\]

The IOR directly controls the value of \(\sin^2(\theta_2)\). If the shader computes \(\sin^2(\theta_2) > 1.0\), the mathematical condition for total internal reflection is met. In response, the shader sets the Fresnel reflection factor to exactly 1.0 (100% reflectance) and terminates the transmission path, ensuring no light leaks through the geometry at that angle.

Integration with glTF Material Extensions

The computation of TIR relies on the coordination of several glTF extensions alongside KHR_materials_ior:

  • KHR_materials_transmission: Enables light to pass through the surface. Without transmission, the material is treated as opaque, and interior-to-exterior ray tracing does not occur.
  • KHR_materials_volume: Defines the thickness and interior of the object. It informs the renderer that the ray is currently propagating inside a dense medium, establishing the context where \(n_1\) represents the interior material and \(n_2\) represents the outside environment.

By precisely defining the IOR, content creators ensure that glTF renderers correctly switch between transmission and full specular reflection, producing characteristic visual effects such as the brilliance of cut gemstones, the mirror-like appearance of water surfaces viewed from below, and the realistic edge reflections seen in curved glass objects.