Temporary fix for mesh rasterization bug for traingles partially behind the camera

Summary: A triangle is culled if any vertex in a triangle is behind the camera.  This fixes incorrect rendering of triangles that are partially behind the camera, where screen coordinate calculations are strange.  It doesn't work for triangles that are partially behind the camera but still intersect with the view frustum.

Reviewed By: nikhilaravi

Differential Revision: D22856181

fbshipit-source-id: a9cbaa1327d89601b83d0dfd3e4a04f934a4a213
This commit is contained in:
Steve Branson
2020-08-20 22:23:06 -07:00
committed by Facebook GitHub Bot
parent 57a22e7306
commit 9aaba0483c
4 changed files with 39 additions and 8 deletions

View File

@@ -552,6 +552,10 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
+ (zbuf1 * grad_zbuf).sum()
+ (bary1 * grad_bary).sum()
)
# avoid gradient error if rasterize_meshes_python() culls all triangles
loss1 += grad_var1.sum() * 0.0
loss1.backward()
grad_verts1 = grad_var1.grad.data.clone().cpu()
@@ -563,6 +567,10 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
+ (zbuf2 * grad_zbuf).sum()
+ (bary2 * grad_bary).sum()
)
# avoid gradient error if rasterize_meshes_python() culls all triangles
loss2 += grad_var2.sum() * 0.0
grad_var1.grad.data.zero_()
loss2.backward()
grad_verts2 = grad_var2.grad.data.clone().cpu()