-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GLTFLoader, GLTFExporter: Remove KHR_materials_pbrSpecularGlossiness #24950
GLTFLoader, GLTFExporter: Remove KHR_materials_pbrSpecularGlossiness #24950
Conversation
/cc @takahirox |
I think it's ok to remove them. For users who still need the extension, we can provide the plugins at or somewhere else. |
@elalish following up on #23630 (comment) — the web app https://gltf.report will now do the spec/gloss → metal/rough conversion automatically. The same conversion could be applied in other web-based tools, with: import { WebIO } from '@gltf-transform/core';
import { KHRONOS_EXTENSIONS } from '@gltf-transform/extensions';
import { metalRough } from '@gltf-transform/functions';
const io = new WebIO().registerExtensions(KHRONOS_EXTENSIONS);
const document = await io.readBinary(byteArray);
// spec/gloss → metal/rough
await document.transform(metalRough());
const glb = await io.writeBinary(document); |
I also think it's time 👍 |
SG, thanks @donmccurdy! Now I just need to remember to point people to that tool in our next release notes. |
Also, here's a migration guide for converting existing glTF files: |
It's good to add it to the Three.js migration guide? https://github.com/mrdoob/three.js/wiki/Migration-Guide |
Thanks, I'd missed that it covered r147 already — done! |
@donmccurdy Does |
@elalish the script above, #24950 (comment), will work in a browser, yes. 👍 What I'd do would be to load from the URL or DataTransfer API into glTF Transform, then export a GLB as Uint8Array, and to parse or load from a Blob URL in THREE.GLTFLoader from there. Happy to take questions in discussions as well! |
For future reference - there's a lot of models out there and a lot of code out there that still use KHR_materials_pbrSpecularGlossiness and I personally feel that backwards compatibility should be given a higher priority than it seems to have had here. Pre-processing gltf files is not an option in many cases (i.e. when you have no control over provenance). I'll try and find time to contribute a plugin to handle this on import. |
Our editor does the conversion on import - it's open source so you're welcome to crib the code if it's helpful: https://modelviewer.dev/editor/ |
@elalish Thanks I'll take a look. (I just spotted that you're behind manifold as well - I'd love to chat to you about that also at some point!) |
@elalish How does the conversion code look like? Is it small enough that we could add it to |
Well, we just took a dependency on |
Right, glTF Transform is about 20kb minzipped, plus any extensions you need. Fine for processing user uploads, but pre-processing the model offline would clearly be preferable for production. The conversion work is mainly rewriting textures... ... which isn't a lot of code to re-implement, but is (1) slow, and (2) dependent on Canvas 2D or WebGL or WebGPU, which GLTFLoader otherwise would not require. My main concern was/is complexity and maintenance of GLTFLoader. |
I think being dependent on Canvas 2D is okay. And also that it's slow. We could log a message saying that the textures got converted and suggest using glTF Transform. I think that's better than just black? |
With one the edge case that we can't convert KTX2 textures so easily (but surely that combination is rare...) I think that would work well enough. If someone would like to open a PR rewriting spec/gloss textures to spec/rough (as in the link above), that sounds good to me. |
So does Threejs GLTFExporter support ktx2 textures? |
When you load KTX2 textures in three.js, they become THREE.CompressedTexture instances. When exporting materials with THREE.CompressedTexture textures using THREE.GLTFExporter, the textures are automatically decompressed to PNG or JPG images for export. The exporter cannot transcode backwards from the GPU texture format to the Basis Universal (BasisLZ / ETC1S / UASTC) encoding to produce a universal KTX2 texture. |
Okay, thank you for your answer. I understand now |
The Khronos Group archived the
KHR_materials_pbrSpecularGlossiness
extension ("no longer recommended for creating new files") about a year ago. I think it would be reasonable for us to remove support at this point, and focus efforts on the metal/rough workflow instead. All new and upcoming PBR features — volumetric refraction, iridescence, clearcoat, subsurface scattering, ... — are authored around the metal/rough model. With support forKHR_materials_ior
andKHR_materials_specular
, there is no particular advantage left to the spec/gloss model.Existing spec/gloss models can be converted losslessly to metal/rough with:
Related:
Migration guide: