Pytorch3d: Saving .obj with textures

Created on 15 Apr 2020  路  2Comments  路  Source: facebookresearch/pytorch3d

In pytorch3d.io module there is a function to save .obj file. After deforming one mesh to another I would like to export new .obj but with textures and uv from source mesh. Could you please explain how can I do this?

how to

Most helpful comment

@hadhoryth we currently don't provide support for saving '.obj' meshes with textures as you describe and don't have plans to support this in the short term as this isn't a primary use case.

If you would like to write your own function, you would need to use the three components returned from load_obj: verts, faces, aux. The names of the materials in the source mesh are given by aux.material_colors.keys() and the index of the material for each face is given by faces.faces_materials_idx which indexes into list(material_colors.keys()). You can then use this to construct the .obj based on the standard .obj format - i.e. write usemtl material_1 before the set of faces which use that material.

All 2 comments

@hadhoryth we currently don't provide support for saving '.obj' meshes with textures as you describe and don't have plans to support this in the short term as this isn't a primary use case.

If you would like to write your own function, you would need to use the three components returned from load_obj: verts, faces, aux. The names of the materials in the source mesh are given by aux.material_colors.keys() and the index of the material for each face is given by faces.faces_materials_idx which indexes into list(material_colors.keys()). You can then use this to construct the .obj based on the standard .obj format - i.e. write usemtl material_1 before the set of faces which use that material.

that would be convenient.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eliemichel picture eliemichel  路  3Comments

cihanongun picture cihanongun  路  3Comments

AndreiBarsan picture AndreiBarsan  路  3Comments

abhi1kumar picture abhi1kumar  路  3Comments

ldepn picture ldepn  路  3Comments