isl-org / isl-org/Open3D

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

Open
#6,954 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

### Checklist

- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](https://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](https://www.open3d.org/docs/release/) and the [latest documentation](https://www.open3d.org/docs/latest/) (for `main` branch).

### 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

```python
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](https://github.com/user-attachments/assets/475514c4-6054-4b44-9243-810eda485276)

Model display:
![image](https://github.com/user-attachments/assets/7afe9074-4434-4d6d-ae30-9f892480082a)

### Expected behavior

_No response_

### Open3D, Python and System information

```markdown
python open3d 0.18
```

### Additional information

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.