Convert specular/gloss to PBR?

I am trying to come up with a reliable way to convert specular/gloss materials to metallic roughness. The gltf-transform tool appears to just invert the gloss value and set metalness to zero. The gltf.report tool loads my spec-gloss file and displays it correctly, but the exported GLB does not match what I see in the gltf.report tool. Is there a reliable formula for this? I need something that works reliably without adjusting each material.

the exported GLB does not match what I see in the gltf.report tool

What do you mean by this? Are you loading the exported GLB somewhere?

@donmccurdy can confirm, but gltf-transform should be using a combination of KHR_materials_specular and KHR_materials_ior extension to support a conversion from KHR_materials_specular_glossiness. See this for details.

Maybe you are loading the exported GLB into a tool that doesn’t support KHR_materials_specular and/or KHR_materials_ior?

My guess would be the viewer is missing IOR or specular support, agreed. My implementation here. I think it’s possible to approximately convert without those extensions, but requires some guesswork about what’s metallic or non-metallic, and so might not be as reliable without adjusting by hand for your specific materials.

Yes, I wrote an algorithm that tries to do it and is documented in the appendix of the spec, but like @donmccurdy says, it’s not perfect and will result in half metallic materials which are generally not physical. I have it hosted on GitHub IO so people can play around with the values and see what happens.

Apparently it is possible. If you look at the Khronos reference renderer, the specular-gloss path just sets metalness to zero.

However, I have decided not to go through with this because there is no single point in the art pipeline I can automate this process. Even if I implement it for glTF, people will still bring in specular maps from other sources, so I might as well just keep the specular-gloss pathway.