Content
While using the Babylon.js Sandbox, I noticed a behavior that can be a bit confusing and wanted to get the community’s thoughts on it.
Scenario
Create a new PBRMaterial in the Sandbox and assign a standard glTF ORM (Occlusion-Roughness-Metallic) texture through the Inspector.
The texture channels are:
- R = Ambient Occlusion
- G = Roughness
- B = Metallic
This is the standard packing defined by the glTF 2.0 specification.
However, after assigning the texture, the material does not render as expected.
Reason
Looking at the PBRMaterial source code, the default configuration is:
useRoughnessFromMetallicTextureAlpha = true;
useRoughnessFromMetallicTextureGreen = false;
useMetallnessFromMetallicTextureBlue = false;
useAmbientOcclusionFromMetallicTextureRed = false;
This means a newly created PBRMaterial does not interpret metallicTexture using the standard glTF ORM channel layout by default.
On the other hand, when loading a glTF model, the glTF loader automatically configures these properties, so the exact same ORM texture works correctly.
As a result, the behavior is different depending on how the material is created:
- Loading a glTF model → ORM works correctly.
- Creating a new
PBRMaterialin the Sandbox and assigning the same ORM texture through the Inspector → the result is incorrect.
Possible Improvements
Could the Inspector provide a more convenient way to configure this?
Option 1: Add a preset
Metallic Texture Preset:
- Babylon Legacy (current default)
- glTF ORM
- Custom
Selecting glTF ORM could automatically configure:
useAmbientOcclusionFromMetallicTextureRed = true;
useRoughnessFromMetallicTextureGreen = true;
useRoughnessFromMetallicTextureAlpha = false;
useMetallnessFromMetallicTextureBlue = true;
Option 2: Expose the channel mapping options directly
For example:
- AO Source
- Roughness Source (Alpha / Green)
- Metallic Source (Constant / Blue)
This would preserve backward compatibility while making it much easier to work with standard ORM textures.
Discussion
Do you think the Inspector should provide this kind of configuration?
Although these properties can be configured in code, having the option directly in the Inspector could make it much easier to preview and debug materials in the Sandbox, especially when working with the standard glTF workflow.