Closed xhuan8 closed 11 months ago
I try to render an 3D model with texture image, but the result image is much darker, is it possible to make it the same as input texture image?
def test_render_pytorch3D1(): verts, faces_idx, aux = load_obj("Data/cow.obj") faces = faces_idx.verts_idx verts_uvs = aux.verts_uvs[None, ...].to(device) # (1, V, 2) faces_uvs = faces_idx.textures_idx[None, ...].to(device) # (1, F, 3) texture_image = cv2.imread('Data/cow_texture.png') texture_image_batch = texture_image[None, ...] # (1, H, W, 3) texture_image_batch = torch.from_numpy(texture_image_batch).float().to(device) / 255 textures = TexturesUV(verts_uvs=verts_uvs, faces_uvs=faces_uvs, maps=texture_image_batch) #verts_rgb = torch.ones_like(verts)[None] # (1, V, 3) #textures = TexturesVertex(verts_features=verts_rgb.to(device)) print(verts.shape) print(faces.shape) print(texture_image_batch.shape) mesh = Meshes( verts=[verts.to(device)], faces=[faces.to(device)], textures=textures ) R, T = look_at_view_transform(2.7, 0, 180) cameras = FoVPerspectiveCameras(device=device, R=R, T=T) raster_settings = RasterizationSettings( image_size=512, blur_radius=0.0, faces_per_pixel=1, ) lights = PointLights(device=device, location=[[0.0, 0.0, -3.0]]) renderer = MeshRenderer( rasterizer=MeshRasterizer( cameras=cameras, raster_settings=raster_settings ), shader=SoftPhongShader( device=device, cameras=cameras, lights=lights ) ) images = renderer(mesh) images = images[0, ..., :3].detach().cpu().numpy() cv2.imwrite('Data/2.png', images * 255)
closing as duplicate of #1670.
I try to render an 3D model with texture image, but the result image is much darker, is it possible to make it the same as input texture image?