PBRMaterial Metallic Roughness Texture

Yo @Deltakosh or @sebavan … I am having issues with PBRMaterial and Metallic Roughness (GLTF)

First… When using a metallic texture map, is the Roughness Value a Scaler for the GREEN Channel glossiness pixel value

Second… When using metallic texture map, is the Metalness Value a Scaler for the BLUE Channel metallic pixel value

No when i am NOT using a metallic texture, the roughness and metallic values work as expected, but when I am using a metallic texture, what should my roughness and metallic value be… One, since its a scalar value, and if i make less than one it should decrease roughness values encoded in the texture… Right ???

Here is the exact setup we use:

MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;

so this is all configurable and gltf uses:

 babylonMaterial.useMetallnessFromMetallicTextureBlue = true;
babylonMaterial.useRoughnessFromMetallicTextureGreen = true;
babylonMaterial.useRoughnessFromMetallicTextureAlpha = false;

the texture values are multiplied with the values you set as scalar in the roughness and metallic properties.

Hi @sebavan

Do you confirm that if we have a texture with no metalness in it (no blue), then changing the pbr metalness value will change nothing as 0 * 1 = 0 ? (best equation of the year haha)

Is there a way to bypass that if we still want to change the metalness of the material?

Thanks for your help

You could do the opposite put 1 in the texture and control through the factor :slight_smile:

Yes this is our plan actually.

But by default, the model doesn’t have metalness and just sometimes we want to add some. So we would prefer to have the correct model without having to change metalness in every mesh of the model. For instance, is it possible to add that metalness value to the texture?

Yup you store it in the blue channel and set the flag useMetallnessFromMetallicTextureBlue to true and you can put your factor to 0 to disable or 1 to enable metalness