Importing the glb files other way

So currently I am loading my assets using the LoadAssetContainerAsync method and its using PBRMaterial as the default when it’s loaded. however I want to use shader Material and change the implementation in such way that would make sense to handle the loading of the asset and material in a different way so we can handle the material uniform values ourselves

So what is your question about, actually?

1 Like

What type of asset do you use, gltf ?

Yes we use gltf

Okay , so basically we have wearables on character loading from the server. So those are glb/gltf and we use loadAssetContainerAsync to load them and by default they get added as PBR Material but now we have written our own Shader , Vertex and Fragment. I want to load these using Shader, so basically I dont want PBR Material at all.

Maybe use a custom glTF loader extension? See the User Extensions section in this blog post.

1 Like

If you use loadAssetContainerAsync you can update the AssetContainer with the materials you want before calling the addAllToScene()

  • You also have the addToScene method with a predicate to filter what you want to add / remove.
  • You could also not use the addAllToScene at all and instead pick the assets, set your shader then add them to the current scene. For example in this playground I set a material and add the mesh with scene.addMesh : https://playground.babylonjs.com/#C3MP99#23 (Line 38)
1 Like

Thanks a lot , this solution worked for me @sharp

1 Like

This works but it’s wasteful since it will load the materials and textures that will just be thrown away, but it might not be a big deal if the materials of the assets are small.

1 Like

You can set skipMaterials to false in the loader to prevent loading them

2 Likes

Okay , I dont exactly understood how they will be thrown away. What I wanted achieve here is that when i do addAlltoScene , it adds up all the material using the PBR by default. Now we have requirement to use custom shaders instead. So using this it completely removes the PBR material. Thanks for the inputs.

@sebavan Okay sure , I will Use this property for the materials we dont require. Thanks

1 Like

Calling loadAssetContainer will load everything including things you don’t want. You can choose not to add them to the scene, but they have already been loaded into the container.

1 Like