mmatl / pyrender

Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
http://pyrender.readthedocs.io/
MIT License
1.31k stars 225 forks source link

render vertices color on the images #233

Closed Holmes-Alan closed 2 years ago

Holmes-Alan commented 2 years ago

Hello, I have a question about rendering the vertice color on the image. I have a mesh and colors, I tried to do the following codes, but I only get black mesh results with no color like, image

    mesh.visual.vertex_colors = mesh_input.visual.vertex_colors
    mesh = pyrender.Mesh.from_trimesh(mesh, smooth=True)
    mesh_node = self.scene.add(mesh, 'mesh')
    camera_pose = np.eye(4)
    cam_node = self.scene.add(camera, pose=camera_pose)
    rgb, _ = self.renderer.render(self.scene, flags=render_flags)
    valid_mask = (rgb[:, :, -1] > 0)[:, :, np.newaxis]
    output_img = rgb * valid_mask + (1 - valid_mask) * img
    image = output_img.astype(np.uint8)

What should I do? Can you please help me?

Holmes-Alan commented 2 years ago

A follow-up question. I think that the color is shown already. It is just it shows the color at each vertex and not showthe