failed to load texture. trimesh.util.concatenate
Closed this issue · 2 comments
def load_obj(file_path):
mesh = trimesh.load_mesh(file_path, process=False, force='mesh')
return mesh
def merge_objs(obj_files, output_file):
meshes = [load_obj(f) for f in obj_files]
merged_mesh = trimesh.util.concatenate(meshes)
# merged_mesh.export(output_file)
merged_mesh.show()
Hello, when I use the above code for display, the following error occurs
failed to load texture
Traceback (most recent call last):
File "D:\PycharmProjects\obj3d\venv\lib\site-packages\trimesh\viewer\windowed.py", line 275, in add_geometry
tex = rendering.material_to_texture(visual.material)
File "D:\PycharmProjects\obj3d\venv\lib\site-packages\trimesh\rendering.py", line 337, in material_to_texture
texture = gl_image.get_texture()
File "D:\PycharmProjects\obj3d\venv\lib\site-packages\pyglet\image\__init__.py", line 835, in get_texture
self._current_texture = self.create_texture(Texture, rectangle, force_rectangle)
File "D:\PycharmProjects\obj3d\venv\lib\site-packages\pyglet\image\__init__.py", line 821, in create_texture
texture = cls.create(self.width, self.height, internalformat,
File "D:\PycharmProjects\obj3d\venv\lib\site-packages\pyglet\image\__init__.py", line 1471, in create
glTexImage2D(target, 0,
File "D:\PycharmProjects\obj3d\venv\lib\site-packages\pyglet\gl\lib.py", line 107, in errcheck
raise GLException(msg)
pyglet.gl.lib.GLException: b'\xce\xde\xd0\xa7\xd6\xb5'
I have 6 sets of model data, each with 3 files obj mtl and png, and the texture display of each set of data is normal Whenever I connect with less than 3 sets of data, the exported model can be displayed normally, and the texture can also be displayed normally When there are more than 4 groups, the above exception will occur and the texture cannot be displayed. I also set the following code:
from PIL import Image
Image.MAX_IMAGE_PIXELS = 1500000000000
The above are all the situations where I encountered errors. Looking forward to your answer.
Hey, it looks like the texture concatenates OK, but then perhaps it results in a a texture that is too large for your GPU? What is the size of mesh.visual.material.image
? It would be pretty easy to scale the image using PIL, and UV coordinates are normalized.
Thank you very much for your answer. My question has been resolved The original image was 4096 * 4096, which can be reduced to 1024 * 1024 using PIL. Thank you very much.