mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2026-01-17 03:40:34 +08:00
Rendering texturing fixes
Summary: Fix errors raised by issue on GitHub - extending mesh textures + rendering with Gourad and Phong shaders. https://github.com/facebookresearch/pytorch3d/issues/97 Reviewed By: gkioxari Differential Revision: D20319610 fbshipit-source-id: d1c692ff0b9397a77a9b829c5c731790de70c09f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f580ce1385
commit
5d3cc3569a
@@ -135,6 +135,15 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
||||
def test_simple(self):
|
||||
mesh = TestMeshes.init_simple_mesh("cuda:0")
|
||||
|
||||
# Check that faces/verts per mesh are set in init:
|
||||
self.assertClose(
|
||||
mesh._num_faces_per_mesh.cpu(), torch.tensor([1, 2, 7])
|
||||
)
|
||||
self.assertClose(
|
||||
mesh._num_verts_per_mesh.cpu(), torch.tensor([3, 4, 5])
|
||||
)
|
||||
|
||||
# Check computed tensors
|
||||
self.assertClose(
|
||||
mesh.verts_packed_to_mesh_idx().cpu(),
|
||||
torch.tensor([0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2]),
|
||||
@@ -142,9 +151,6 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
||||
self.assertClose(
|
||||
mesh.mesh_to_verts_packed_first_idx().cpu(), torch.tensor([0, 3, 7])
|
||||
)
|
||||
self.assertClose(
|
||||
mesh.num_verts_per_mesh().cpu(), torch.tensor([3, 4, 5])
|
||||
)
|
||||
self.assertClose(
|
||||
mesh.verts_padded_to_packed_idx().cpu(),
|
||||
torch.tensor([0, 1, 2, 5, 6, 7, 8, 10, 11, 12, 13, 14]),
|
||||
@@ -156,9 +162,6 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
||||
self.assertClose(
|
||||
mesh.mesh_to_faces_packed_first_idx().cpu(), torch.tensor([0, 1, 3])
|
||||
)
|
||||
self.assertClose(
|
||||
mesh.num_faces_per_mesh().cpu(), torch.tensor([1, 2, 7])
|
||||
)
|
||||
self.assertClose(
|
||||
mesh.num_edges_per_mesh().cpu(),
|
||||
torch.tensor([3, 5, 10], dtype=torch.int32),
|
||||
@@ -249,6 +252,8 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
||||
self.assertEqual(mesh.faces_padded().shape[0], 0)
|
||||
self.assertEqual(mesh.verts_packed().shape[0], 0)
|
||||
self.assertEqual(mesh.faces_packed().shape[0], 0)
|
||||
self.assertEqual(mesh.num_faces_per_mesh().shape[0], 0)
|
||||
self.assertEqual(mesh.num_verts_per_mesh().shape[0], 0)
|
||||
|
||||
def test_empty(self):
|
||||
N, V, F = 10, 100, 300
|
||||
@@ -323,9 +328,11 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
||||
|
||||
mesh = Meshes(verts=torch.stack(verts), faces=torch.stack(faces))
|
||||
|
||||
# Check verts/faces per mesh are set correctly in init.
|
||||
self.assertListEqual(
|
||||
mesh.num_faces_per_mesh().tolist(), num_faces.tolist()
|
||||
mesh._num_faces_per_mesh.tolist(), num_faces.tolist()
|
||||
)
|
||||
self.assertListEqual(mesh._num_verts_per_mesh.tolist(), [V] * N)
|
||||
|
||||
for n, (vv, ff) in enumerate(zip(mesh.verts_list(), mesh.faces_list())):
|
||||
self.assertClose(ff, faces[n][: num_faces[n]])
|
||||
@@ -364,7 +371,6 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
||||
mesh._num_verts_per_mesh = torch.randint_like(
|
||||
mesh.num_verts_per_mesh(), high=10
|
||||
)
|
||||
|
||||
# Check cloned and original Meshes objects do not share tensors.
|
||||
self.assertFalse(
|
||||
torch.allclose(new_mesh._verts_list[0], mesh._verts_list[0])
|
||||
|
||||
Reference in New Issue
Block a user