Texture issue with GLTF importer


I need to import some 3D textured models made with Blender and duplicate them several times. I use the GLTF format. The vtkGLTFImporter works fine with one object (I can duplicate the imported actor) but I encounter strange behaviour as soon as I import 2 different objetcs. The textures are applied randomly (the 2 original imported actors are correct, but the duplicated ones get all the same texture, and this may change if the original actor get out of the cam view… - All geometry is correct).
To duplicate an actor I use :
NewActor = vtkActor::New();

I’ve made a test doing the same with 2 cubes textured manually with 2 different textures. All works fine with the duplicated ones.

One difference i noticed is that “ImportedActor->GetTexture()” returns a NULL, but returns a valid pointer with the cube test.

What is the difference between the GLTF importer texturing method and a simple manual texturing?
What is the proper way to duplicate a GLTF imported actor with his texture ?



Hello @pbrousson,

As the glTF importer uses VTK’s physically-based rendering functionality, textures are set via the actor’s vtkProperty member (SetBaseColorTexture(), SetORMTexture(), etc…).
To your code might fix the issue.

If you only need to use Phong interpolation with the base color texture, ImportedActor->GetProperty()->GetTexture("BaseColor"); should return the correct texture.

To clarify, are you importing multiple meshes from a single glTF file, or two models from two separate glTF files ?

Hello Adrien,

It works now fine with the " NewActor->SetProperty(ImportedActor->GetProperty());"

Initially all meshes were in the same file. I tried to split it in 2 files with no success.

Thanks for your help.