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:
Nikhila Ravi
2020-03-17 08:55:57 -07:00
committed by Facebook GitHub Bot
parent f580ce1385
commit 5d3cc3569a
10 changed files with 348 additions and 152 deletions

View File

@@ -1,6 +1,7 @@
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import numpy as np
import unittest
import torch
@@ -61,3 +62,28 @@ class TestTensorProperties(TestCaseMixin, unittest.TestCase):
example = TensorPropertiesTestClass(x=(), y=())
self.assertTrue(len(example) == 0)
self.assertTrue(example.isempty())
def test_gather_props(self):
N = 4
x = torch.randn((N, 3, 4))
y = torch.randn((N, 5))
test_class = TensorPropertiesTestClass(x=x, y=y)
S = 15
idx = torch.tensor(np.random.choice(N, S))
test_class_gathered = test_class.gather_props(idx)
self.assertTrue(test_class_gathered.x.shape == (S, 3, 4))
self.assertTrue(test_class_gathered.y.shape == (S, 5))
for i in range(N):
inds = idx == i
if inds.sum() > 0:
# Check the gathered points in the output have the same value from
# the input.
self.assertClose(
test_class_gathered.x[inds].mean(dim=0), x[i, ...]
)
self.assertClose(
test_class_gathered.y[inds].mean(dim=0), y[i, ...]
)