Load glb asset using duplicated texture, material

Hi, everone.
I need a little help ! It’s about the glb load.

When load glb asset, if exist same texture or material (like comparing name),
can I connect the assets at glb container?

I checked the AssetRegister.

Asset 50 and 69 are the same thing.
But filename is different. Automatically followed by “-number”. Can’t only one file exist?

Also, I see that asset task option. It’s supports overwrite model, material, texture, is this only available on the editor?

Hi @Hizard,

The Overwrite properties are to indicate if PlayCanvas should override assets imported by a previous import of this container file. Or to create new versions/copies of these instead.

To your question, I did see that behavior in the past when importing GLB files, getting multiple textures assets of the same image. Not sure if it was an issue with my models or a PlayCanvas bug.

Can you make sure that those files are using the exact same image reference and image name in your modelling app before exporting?

1 Like

Thank you for comment, @Leonidas.

NPC1.glb and NPC4.glb use several identical texture.

Isn’t it the same file if it’s displayed like this?
File Size, File Name, etc… It’s all the same.

Isn’t there a way to use only one of the same file?

It seems this issue has come up before and it was a bug in the PlayCanvas importer: [SOLVED] PlayCanvas duplicates textures from GLB file which causes high VRAM

Calling @Elliott in case there is a regression here.

1 Like

Would it be possible to share the project/GLB please?

CC @slimbuck as it’s related to asset import

2 Likes

Hi @Hizard,

The GLB import system doesn’t reuse or resolve textures across different GLB files during import currently. This is probably something we could add support for though. We could base a match on texture filename, but GLB files will usually be imported into their own folder. So should any matching texture filename in the entire project count as a match?

The options to overwrite materials and textures only applies when reimporting a GLB file. In that case it’ll attempt to overwrite the textures and materials that were previously imported for the GLB (it won’t check the textures and materials of another GLB previously imported).

Thanks

3 Likes

Thank you for the detailed explanation. @slimbuck :slightly_smiling_face:

If possible, I would like only one texture file to exist in my project through the file name.
Or I’ll solve it in the direction of reducing the size of the texture.

Thanks once again. @Leonidas @yaustar @slimbuck

1 Like

Unfortunately, that’s not possible at the moment and you would have to do some manual fix up after importing to have all the materials reference the same texture.

If you right click on a texture asset, there is a ‘replace’ option that allows you swap the material references of that texture asset with another to make it easier.

2 Likes

@yaustar Will there be a way to replace the current materials used in a loaded glb asset in javascript on the fly?