GLTFExporter not working with PBRMaterial

Hello Guys,

I’m creating a simple plane with PBRMaterial on it. I’m applying an albedotexture and setting the unlit property to true. Then I’m using the export to glb option in the inspector to export the scene as a glb model.

It works correctly for StandardMaterial but when I switch it to PBRMaterial it doesn’t export the material/texture the created glb file has no texture.

Playground Link for reproducing the issue.

Also, thank you creating an amazing 3d framework. One of the most easiest and simple to use.

Hello and welcome!

The generated texture is all white in the resulting glb file.

The issue comes from the readTexturePixels function.

I’ve created a PR here for another reason. Fortunately it fixes your issue as well. So I suggest you to wait for this PR merge.

However you can try it here already:

Hello Roland,

Thank you for replying over the weekend.

In the playground you shared, it’s exporting the texture but it’s all weird now.

Below is the plane with the artwork fully covering the plane in Babylonjs

Below is the same plane in another viewer. As you can see most of the plane is black and from what I can understand it’s somehow writing the canvas pixel values onto the plane. The purple border around the artwork is coming from the babylonjs canvas background, and it is being applied on to the plane as a texture.

1 Like

Yep, it can be seen on my screenshot. Sorry, I didn’t pay attention to the details.

Let me see what’s the issue with the texture, why is it exported the way it is.

EDIT: fixing this

1 Like

cc @bghgary

@sebavan I just wanted to confirm if I should create an issue on GitHub for this.

Please:) I will have a look shortly. Unless @ryantrem wants to give it a try?

I’ve created a GitHub issue for it. Link

I could probably look a little later in the week, though it sounds like it may require @roland’s other fix first, and it also sounds like @roland might already be looking?

The main issue is not related to reading textures or at least it does not look like it.

It comes from how we convert spec/gloss pbr workflow into metal/rough ones as some cases are simply not possible there.

As it is done before applying extension like unlit to allow all the greatness of gltf later on, we end up with a converted white texture.

I would strongly advise to rely on a metal/rough workflow when using export to prevent any misleading surprises: https://playground.babylonjs.com/#Q9VZS9#2155

3 Likes

Thank you so much @sebavan. The playground you shared works for me.

1 Like