Blender glTF I/O: Support for glTF PBR Material Extensions
Note: this blog summarizes a presentation from the November 15, glTF Meetup. Access the full meetup recording here.
There are many approaches to creating realistic-looking materials for 3D objects. However, not all of them are suitable for transmission over the Web, and many have a prohibitively steep learning curve. Physically Based Rendering (PBR) has emerged as an artist-friendly, intuitive, expressive, and robust technique for adding materials to 3D objects.
The Khronos 3D Formats Working Group has embraced this approach, and over the past few years, they have created formal glTF extensions for a variety of PBR materials. glTF’s growing set of PBR material extensions allow artists to create strikingly realistic 3D objects – suitable for cross-platform applications including browsers, mobile devices, native applications and more – that will perform consistently across a wide range of viewers and devices.
Since Blender 2.80, the glTF Importer/Exporter has shipped with Blender by default. I am pleased to announce that in the current stable LTS (Long Time Support) version of Blender, Blender 3.3, the glTF I/O now supports a variety of glTF PBR material extensions, including:
Additional information on these PBR extensions can be found at: https://github.com/KhronosGroup/glTF/blob/main/extensions/README.md
Physically Based Rendering is accomplished in Blender primarily using the Principled BSDF node. When creating an object, you can plug a base color with mapping and UV maps to the Principled BSDF Node. You can also create ORM (occlusion, roughness, and metallic) textures, as well as add an emission map and a normal map.
Last year, in my capacity as maintainer of the Blender glTF I/O, I added extensions which bring several new features into the core specification. Several of these features are handled within the Principled BSDF node; others require an add-on node or shader for full compatibility. Whenever you import a glTF file, the appropriate node tree is created automatically.
glTF PBR Materials controlled within the Principled BSDF node
Emissive strength values are found in the Principled BSDF node. In the core specification, you only had the ability to add a factor between 0 and 1. Now, in Blender 3.3, emission and emissive strength can be set to any value, and that value will be taken into account with importing and exporting glTF files.
Transmission is also handled in the Principled BSDF node. It can be used with any float value, or with a texture.
Whenever you are using transmission (or volume or specular, for that matter), you are likely also using Index of Refraction. This value is also found in the BSDF node.
Principled BSDF is a surface definition – as such, it contains no volume data. In order to use the KHR_materials_volume extension, you need to add a volume node.
One option would be to use a Volume Absorption Node, which allows you to define color value and density. However, there is no thickness value that can be used with the Volume Absorption Node.
Instead, Blender 3.3 allows you to add a glTF Material Output node, which includes values for occlusion, thickness, and specular – all the data needed for outputting volumes into a glTF file. When importing a glTF file, this node and associated values are automatically added and set.
If you are creating an object from scratch and wish to output to glTF, you can enable the glTF Output Node in preferences: Preferences > Add-ons > Import-Export: glTF 2.0 format > Shader Editor Add-On
Once enabled, the glTF Material Output Node will appear in the menu under Output Nodes.
The glTF specular extension was a bit tricky, because while the Principled BSDF node does include specular and specular tint, this format is not fully compatible with glTF. When importing a glTF file, Blender tries to get the specular data in Principled BSDF as close as possible, but also keeps the original specular data in the custom glTF Material Output node.
When viewing the object in the Blender viewport, you are seeing the BSDF specular values; the glTF Material Output specular values are not displayed. However, when you output to glTF, you can choose whether to use the Principled BSDF or the glTF Material Output specular values.
By default, Blender will output specular and specular tint values from the Principled BSDF node. Because the BSDF model is not fully compatible with glTF, there is some unavoidable data loss with this approach. Therefore, if you know glTF is your target output, set the desired specular values in the glTF Material Output node. Then, when exporting, check the “Export original PBR Specular” box.
While there are a few extra steps involved in leveraging the KHR_materials_specular for now, there won’t be for long. Principled BSDF v2 is currently under development at Blender - once released, it will be fully compatible with all current glTF PBR extensions.
KHR_materials_sheen was tricky for the same reason as specular: sheen and tint values are available in the Principled BSDF node, but the model used by Blender for sheen in BSDF is not compatible with the model used by glTF files. As a work-around, you can manage this material by attaching a Velvet BSDF shader node to the Principled BSDF node using Add Shader.
In order to add the Velvet shader, you will first need to switch from the default render engine in Blender, Eevee, to Cycles. After you add the Velvet BSDF shader, you can go back to Eevee. In the Velvet BSDF node, use the Color input for texture and the Sigma input for roughness. You can then add the Velvet BSDF to the Principled BSDF node.
Again, once Principled BSDF v2 is released, these extra steps will no longer be required.
Finally, the KHR_materials_variants extension: this extension allows you to include multiple material variants in a single glTF file. This extension user interface is available via an option that can be enabled in preferences.
Once enabled, you will be able to see the glTF Variants tab on the side of your model. You can select any variant and instantly display it.
You can also create variants from scratch by following these steps:
- Create multiple slots for materials. These different slots will be exported as a primitive into your glTF mesh.
- Assign the materials to the desired parts of the model.
- Once the materials for one variant have all been assigned, use the glTF Variants tab to “Assign to Variant” – this will create a new model variant with the desired materials
- You can also save one material configuration as Original. This is how the model will display in a viewer that is not using variants.
I invite you to explore the new PBR capabilities for glTF import and export in Blender 3.3. You can also find more detailed guidance and documentation here:
- Blender info & download: https://www.blender.org/
- glTF I/O Documentation: https://docs.blender.org/manual/en/3.3/addons/import_export/scene_gltf2.html
I also welcome your input and requests for additional functionality. Please submit bug reports and feature requests to the glTF Blender I/O GitHub page.