Skip to content

TexturesAtlas to color each face with different colors  #916

@ne1114

Description

@ne1114

❓ Questions on how to use PyTorch3D

Hello, I am trying to color a each mesh faces with different colors. I referred to this issue
I have created a face_colors (shape: (F, 4)). And then converted it to appropriate input format for TexturesAtlas using following :

face_tensor = torch.from_numpy(face_colors[:,:3])   # (F, 3)  --> (R,G,B)  and each value is in 0~1
face_tensor = face_tensor[None, :, None, None, :]   # (1, F, 1, 1, 3) 
print(face_tensor.shape)
------
output: torch.Size([1, 9999, 1, 1, 3])

Also as shown below the obj has 9999 faces :

verts, faces, aux = load_obj(obj_filename)
print(faces.verts_idx.shape)
--------
output : torch.Size([9999, 3])

And I used following code to create texture, generate mesh, visualize:

verts, faces, _ = load_obj(obj_filename)
textures = TexturesAtlas(atlas=face_tensor)

mesh = pytorch3d.structures.Meshes(
    verts=[verts],   
    faces=[faces.verts_idx],
    textures=textures
)

fig = plotly_vis.plot_scene(
            {
                'test':
             {
                 'mesh' : mesh
             }
            },
            xaxis={"backgroundcolor": bgcolor},
            yaxis={"backgroundcolor": bgcolor},
            zaxis={"backgroundcolor": bgcolor}
        )
fig.show()

The displayed mesh does not have appropriate color. (Its just one color not related to the face_colors)

Could I ask for advice please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions