Is it possible to create specular glossiness workflow PBR material in NodeMaterial?

I’m trying to replicate fully GLTF compatible materials in NodeMaterial, including not just the base gltf spec but also the most common GLTF extensions.

Right now I’m trying to replicate KHR_materials_pbrSpecularGlossiness extension behavior but not having much success so far.

From what I have figured out, PBRMaterial switches between metallic workflow and specular-glossiness workflow based on if materia.metallic or material.roughness properties are set to null. This activates some kind of special reflectivity calculation in the shaders.

Is it possible to somehow activate the specular glossines workflow for PBRMetallicRoughnessBlock? Or is it possible to somehow enable the reflectivity behavior and manually pass specularGlossiness derived roughness and metalness values? Anything I have tried so far has failed, but the shaders are so complicated that I may have missed something.

If there currently isn’t any way to do this, would it be possible to expose the related settings somewhere? Perhaps as editable properties of the PBR node block?

Hi @MiikaH - pinging @Evgeni_Popov, who is behind the implementation of PBR material in NME.

Nope, it is not possible thus far.

It mostly boils down to the fact that some properties are not physically plausible in spec gloss workflows and we chose to limit NME due to the already exisiting overall complexity to metal/rough workflows.

That said, you could create roughness from glossiness with (1. - gloss) and you might try to infer the correct metalness value by using some equations @bghgary was using before ???


Yeah, I was already able to calculate roughness and metalness values.

The main issue proved out to be that with specular glossiness workflow a black baseColor can still produce fully reflective surface. Whereas with metallic workflow a black baseColor will produce a black surface, even if metallic. I believe this is what the reflectivity flag triggers.

This became very apparent when looking at the SpecGlossVsMetalRough GLTF sample model, that has most of the comparison model baseColor black.

I guess I need to see if I can somehow trigger the needed #defines from custom shader blocks… Or maybe if I can figure some way to fake the look “close enough” otherwise. But it doesn’t look promising. :worried:

glTF/babylon.pbrUtilities.js at main · KhronosGroup/glTF (

You can try something like this, but I don’t really recommend it in this situation.

@sebavan Maybe we can add something to NME similar to KHR_materials_specular which sits on top of metallic roughness model and can directly translate from specular/glossiness?

1 Like

Interesting. If those options were exposed in NME that would indeed allow replicating KHR_materials_pbrSpecularGlossiness behavior, while staying within the metallic workflow. And it would also directly allow supporting for the mentioned KHR_materials_specular itself in NME, that I have yet to look at. :astonished:

Thanks! That actually looks to be working. I made a custom node block that implements the conversion code in glsl as it would be way too complex to add as node tree.

With that in place at least the GLTF sample model looks correct: :slightly_smiling_face:

So I guess this is good enough workaround for now. Although I’m not sure if the conversion method has some shortcomings that I’m not aware of.

1 Like

I love the overall idea of this node :slight_smile: I wonder if it would be a nice addition to the framework despite the limitations @bghgary ? and obviously if @MiikaH is willing to contribute it back ?

My conversion code will work quite well if the model was originally authored with metallic roughness and converted to specular glossiness (which is what happened with the water bottle).

You can test it with different values here and see how it performs: glTF PBR Conversion (BabylonJS) (

For example, if you use different diffuse and specular colors, the conversion will try to make it work, but it won’t be perfect.

Hmm, so I suppose for perfect support PBR node would have to expose the reflectance factors used here?: Babylon.js/KHR_materials_specular.ts at 1067ed5a09919d4e16ad8c4b9eb59dcae426aff0 · BabylonJS/Babylon.js · GitHub

And with help of those properties it would be possible to create perfect conversion?

That sounds right to me, but @sebavan would know better.

should be closer but I do not thing there would always be a possible solution.

Ok. At least the current conversion code is good enough for my use case for now. :slightly_smiling_face:

Though not sure if adding “flawed” conversion node as official babylon.js feature makes sense. But if any of you think so I can of course send the source code of my custom node block as reference.

1 Like