mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-20 22:30:35 +08:00
Deduplicate texture maps when joining
Summary: If you join several meshes which have TexturesUV textures using join_meshes_as_scene then we amalgamate all the texture images in to a single one. This now checks if some of the images are equal (i.e. the tensors are the same tensor, in the `is` sense; they have the same `id` in Python) and only uses one copy if they are. I have an example of a massive scene made of several textured meshes with some shared, where this makes the difference between fitting the data on the GPU and not. Reviewed By: theschnitz Differential Revision: D25982364 fbshipit-source-id: a8228805f38475c796302e27328a340d9b56c8ef
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cd5af2521a
commit
e12a08133f
@@ -652,6 +652,9 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
verts_shifted2 = verts.clone()
|
||||
verts_shifted2 *= 0.5
|
||||
verts_shifted2[:, 1] -= 7
|
||||
verts_shifted3 = verts.clone()
|
||||
verts_shifted3 *= 0.5
|
||||
verts_shifted3[:, 1] -= 700
|
||||
|
||||
[faces] = plain_torus.faces_list()
|
||||
nocolor = torch.zeros((100, 100), device=device)
|
||||
@@ -697,7 +700,11 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase):
|
||||
mesh1 = Meshes(verts=[verts], faces=[faces], textures=textures1)
|
||||
mesh2 = Meshes(verts=[verts_shifted1], faces=[faces], textures=textures2)
|
||||
mesh3 = Meshes(verts=[verts_shifted2], faces=[faces], textures=textures3)
|
||||
mesh = join_meshes_as_scene([mesh1, mesh2, mesh3])
|
||||
# mesh4 is like mesh1 but outside the field of view. It is here to test
|
||||
# that having another texture with the same map doesn't produce
|
||||
# two copies in the joined map.
|
||||
mesh4 = Meshes(verts=[verts_shifted3], faces=[faces], textures=textures1)
|
||||
mesh = join_meshes_as_scene([mesh1, mesh2, mesh3, mesh4])
|
||||
|
||||
output = renderer(mesh)[0, ..., :3].cpu()
|
||||
output1 = renderer(mesh1)[0, ..., :3].cpu()
|
||||
|
||||
Reference in New Issue
Block a user