Problem loading materials

I’m having some issues getting this model loading correctly, I’m unsure if it’s something I’m doing wrong in the code, or the way the .blend is exporting. any help would be appreciated.

PG: https://playground.babylonjs.com/#1WE9YQ#2

Blender file: drop/lowpoly_assets.blend at master · NumlockDev/drop · GitHub

Pinging our Blender gods (@Vinc3r or @gryff)

1 Like

Hey @Ateria,

You were really close!

You created a new standard material correctly, and assigned your texture to the diffuse texture property of that new material. Then you correctly loaded your asset, and correctly tried to assign your new material in the onSuccess callback of the asset load.

That was all really close.

The issue was this:
terr = newMeshes[0].

This simply grabs the root item that’s returned, and in this case you have many assets within this root. So it required a small addition.

First you needed to extend this:
terr = newMeshes[0].

to look like this:
terr = newMeshes[0].getChildmeshes()

then you need to loop through each child and assign the material that you’re creating.

here’s a playground with the changes:
https://playground.babylonjs.com/#1WE9YQ#3

I hope this is helpful and what you were attempting to achieve!

Cheers!

1 Like

@PirateJC thank you for your help here.

I feel as though we’re one step closer, but not quite there.

Unfortunately the meshes are still white, while they should appear like this:

Hey @Ateria,

Gotcha…Ok so diving in a little deeper I think I have a better grasp of what’s happening here.

Loading your blender file, it looks like you’re using the Diffuse BSDF shader and piping the lowpoly_tex into that. It looks fine in Blender, but there’s a problem in the Blender exporter…issue referenced here…Diffuse BSDF and use_nodes=False are not supported. · Issue #571 · KhronosGroup/glTF-Blender-IO · GitHub.

In your Blender file, if you switch to using the PrincipledBSDF shader instead of the Diffuse BSDF, and then try to export, your file will actually load into Babylon with both the material and texture assigned properly…no need to reassign them in Babylon. That’s probably the best way to go about this.

Here’s what my shader tree looks like:
image

And then after exporting the asset shows up great in Babylon:

I hope that gets you to the result you want.

1 Like

Well I took a look at @Ateria 's .blend file, and loaded the single texture that goes with it, in Blender 2.8. I then exported as a .babylon file using @JCPalmer 's exporter and viewed it in the sandbox - everything was fine.

Exporting as .glb, I get the same white display as reported above. See attached image. Note that the texture is not being loaded. Sorry but no idea why - i tend to stay away from theis glb stuff as it reminds me of old VRML.

Edit: Looks like @PirateJC C found the fix :smile:

cheers, gryff :slight_smile:

1 Like

@PirateJC, @gryff, @Deltakosh thank you all for looking into this for me, I appreciate this community so much. @PirateJC I would’ve been stuck here for hours to figure out it was an issue with diffuseBSDF in the exporter, you’re a lifesaver :slight_smile:

1 Like

Completely happy to help! That’s what we’re all here for! And I agree, I love this community of people!