How can I defer variant texture loading with KHR_materials_variants? Or is there a better way for multiple changeable materials?

I have a couple of meshes in my scene which I each need to have a couple of material variants (each of the meshes has its own independent variants) which can be switched between programmatically later on in code. I’m using glb files.

I’ve discovered the gltf KHR_materials_variants extension which theoretically more-or-less does what I need it to, however I was wondering if there might be a way I could defer the loading of the non-default-variant textures? :thinking: Or if not with KHR_materials_variants, would it make more sense some other way? I tried having the multiple materials and just changing them for the relevant mesh but Blender seemingly doesn’t include materials in the file if not actively assigned to triangles (even if the material is assigned to a mesh object)…

Any recommendations would be greatly appreciated!

One of common ways is to have additional textures as images and updateURL for texture(s) when needed.

1 Like

Hmm, that’s not a bad idea, then I could preload the other images in the background if necessary as well. Do you know if there’ll be shader re-compile flashing when trying to switch them out? Or should it just switch nicely without issues? Thanks :slight_smile: