Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding multiple textures to the mesh can only display the first texture #6954

Open
3 tasks done
teduzhu opened this issue Sep 9, 2024 · 0 comments
Open
3 tasks done
Labels
bug Not a build issue, this is likely a bug.

Comments

@teduzhu
Copy link

teduzhu commented Sep 9, 2024

Checklist

Describe the issue

I see that in the output file, there are all the textures, namely test_0. png and test_1. png. But in the obj file, there is only 'usemtl test_0'. How should this problem be solved? From my understanding, other 3D model libraries, such as VTK, do not support independent UVs for each triangle like Open3D and do require duplicate vertex creation for spliting triangles. If this problem cannot be solved temporarily, are there any alternative solutions? Here is a simple code example:

Steps to reproduce the bug

import open3d as o3d
import numpy as np
texture1 = o3d.io.read_image(r'./0.png')
texture2 = o3d.io.read_image(r'./1.png')

cylinder_mesh = o3d.geometry.TriangleMesh.create_cylinder(radius = 0.1, height = 5, create_uv_map=True)
octahedron_mesh = o3d.geometry.TriangleMesh.create_octahedron(create_uv_map=True)

cylinder_uvs = np.array(cylinder_mesh.triangle_uvs)
octahedron_uvs = np.array(octahedron_mesh.triangle_uvs)

combined_mesh = cylinder_mesh + octahedron_mesh
combined_mesh.textures = [texture1, texture2]
combined_mesh.triangle_uvs = o3d.utility.Vector2dVector(np.vstack([cylinder_uvs, octahedron_uvs]))
combined_mesh.triangle_material_ids = o3d.utility.IntVector([0 for _ in range(len(cylinder_uvs))] + [1 for _ in range(len(octahedron_uvs))])

print(np.asarray(combined_mesh.triangle_material_ids), len(combined_mesh.triangles), len(combined_mesh.triangle_uvs), len(combined_mesh.triangle_material_ids ) ) # [0 0 0 ... 1 1 1] 208 624 624

o3d.io.write_triangle_mesh("test.obj", combined_mesh)
o3d.visualization.draw_geometries([combined_mesh])

Error message

The output files:
image

Model display:
image

Expected behavior

No response

Open3D, Python and System information

python open3d 0.18

Additional information

No response

@teduzhu teduzhu added the bug Not a build issue, this is likely a bug. label Sep 9, 2024
@teduzhu teduzhu changed the title Adding multiple materials to the model can only display the first material Adding multiple textures to the mesh can only display the first texture Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not a build issue, this is likely a bug.
Projects
None yet
Development

No branches or pull requests

1 participant