Using the New glTF Extensions: Volume, Index of Refraction, and Specular
The Khronos 3D Formats Working Group recently announced the ratification of three new Physically Based Rendering (PBR) extensions for the glTF 3D asset format: KHR_materials_volume, KHR_materials_ior, and KHR_materials_specular. The three new extensions build on and extend the existing glTF 2.0 PBR capabilities by adding volume-based absorption, refraction, and complex specular reflections. Some or all of these new extensions are already supported by rendering engines such as Babylon.js, Google’s Filament, and three.js, as well as applications including Adobe’s Substance 3D Stager, Dassault Systèmes 3DEXPERIENCE Platform, DGG RapidCompact and UX3D’s Gestaltor. These extensions will grant artists control of photorealistic effects in glTF, enhancing the appearance of 3D assets. This blog will explore how these extensions are implemented and which variables will be available for artists to control.
The new KHR_materials_volume extension makes it possible to represent volumes that provide refraction and absorption within glTF by turning a material surface into an interface between volumes. This new extension must be combined with an extension that allows light to pass through surfaces, such as the KHR_materials_transmission extension. When light passes through the volume, it is refracted appropriately upon both entering and leaving the volume. Attenuation is properly handled by this extension, but scattering is not included. Adjusting the attenuation distance allows artists to set the density of the medium. Color can be adjusted along two parameters: base color and attenuation color. Base color changes the color of light passing through the volume boundary. Attenuation changes the amount of light that travels through the object. The more distance light travels through the object, the more is absorbed -- the color of the object thus depends on its shape.
- The attenuation color is used when determining what white light is turned into due to absorption upon reaching the attenuation distance.
Base color changes the amount of light passing through the volume boundary (left). The overall color of the object is the same everywhere, as if the object is covered with a colored, transparent foil. Attenuation changes the amount of light traveling through the volume (right). The overall color depends on the distance the light traveled through it; at small distances (tail of the dragon) less light is absorbed and the color is brighter than at large distances.
In order to keep glTF as efficient as possible for real-time rasterizers, it is possible to set the thickness of the volume through the use of both a "thickness factor" and a thickness texture map. Thickness is given in the coordinate space of the mesh, and any transformations to the mesh's node will be applied to the thickness. Baking thickness into a texture map is similar to ambient occlusion baking, but the rays are cast into the opposite direction of the surface normal. However, this is a lossy process. Ray-tracers should ignore these thickness texture maps and use the actual ray-traced distance instead. More details regarding this and the "thickness factor" parameter can be found in the extension's documentation, and can be tested using the Attenuation Test Model.
The Index of Refraction of the material can be set by using the new KHR_materials_ior extension. This extension can be used by both materials that have volume and those that do not. By default, the glTF material model uses a fixed value of 1.5 for the Index of Refraction. This is great for most plastics and glass, but is insufficient for materials that represent water, gems, and a variety of other minerals and surfaces. The KHR_materials_ior extension exposes a parameter to adjust the Index of Refraction used by glTF's dielectric BRDF model. The extension's documentation provides some values for common materials, but others can be found on Wikipedia and other sites.
Another new way for artists to adjust glTF's dielectric BRDF model is through the new KHR_materials_specular extension. When using this extension, "specular" and "specular color" parameters are added to the metallic-roughness material model. The "specular" parameter allows artists to configure the strength of the specular reflection within the dielectric BRDF. A value of zero disables the specular reflection entirely. The "specular color" parameter allows changes to the F0 color of the specular reflection. This allows artists to use effects known from the KHR_materials_pbrSpecularGlossiness extension in the metallic-roughness material model. This extension can be used in combination with KHR_materials_ior: full implementation details are available in the extension’s reference materials.
These extensions represent the latest steps forward to enhance and extend the PBR material models within glTF. Work continues within the 3D Formats Working Group to make these extensions easier to use and more accessible to artists, with webinars, tutorials, and artist guidelines to come.
The glTF specification continues to evolve, with more PBR extensions in the pipeline even now. Implementers, engine developers, content creators, and artists are encouraged to share their input and feedback via GitHub -- and as always, any company that wants to participate directly in evolving the glTF specification and ecosystem are warmly invited to join the Khronos Group.