Support KHR_materials_pbrSpecularGlossiness #1230
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for the KHR_materials_pbrSpecularGlossiness extension in glTF.
It is important to note that this PR does not implement the Specular-Glossiness (SG) workflow itself (nor does pygfx intend to support the SG workflow).
Instead, during model loading, materials that use the SG workflow are converted into an approximate Metallic-Roughness (MR) representation.
For those who are interested in background:
In the early days of PBR rendering, two primary workflows were commonly used: the Metallic-Roughness workflow and the Specular-Glossiness workflow. Some engines supported both workflows simultaneously. The early glTF specification also supported both workflows via extensions. However, with the introduction of extensions such as KHR_materials_ior and KHR_materials_specular, the gap between MR and SG workflows was significantly reduced.
Over the following years, the MR workflow became increasingly dominant. Many newer glTF extensions and advanced PBR features—such as clear coat, thin-surface transmission, volumetric effects, iridescence, and sheen—were designed around the MR workflow. In late 2021, Khronos officially archived the KHR_materials_pbrSpecularGlossiness extension and no longer recommended it for authoring new glTF assets. Many engines gradually dropped SG workflow support and focused solely on MR. pygfx’s PBR pipeline is based on the MR workflow and has no plans to add full SG workflow support.
However, a substantial number of earlier assets were authored using the SG workflow, and many models on platforms such as Sketchfab still export with KHR_materials_pbrSpecularGlossiness. For engines that do not support the SG workflow (such as pygfx), users typically need to convert SG assets to MR using external tools before loading them, which can be inconvenient. This PR streamlines the process by automatically converting SG workflow materials to approximate MR materials during loading, allowing SG-based glTF assets to be used directly.
Test Case: SpecGlossVsMetalRough
The bottle on the right was originally authored using the Specular-Glossiness workflow. During loading, we convert it to the Metallic-Roughness workflow for rendering. As shown, its appearance is almost indistinguishable from the bottle on the left, which was created directly using the MR workflow. The visual differences are minimal and can be considered negligible.