Skip to content

Commit 3b4f8a4

Browse files
dsjohns2facebook-github-bot
authored andcommitted
Adding reference and context to PointsRenderer
Summary: User confusion (#1579) about how zbuf is used for alpha compositing. Added small description and reference to paper to help give some context. Reviewed By: bottler Differential Revision: D51374933 fbshipit-source-id: 8c489a5b5d0a81f0d936c1348b9ade6787c39c9a
1 parent 79b4673 commit 3b4f8a4

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

pytorch3d/renderer/points/rasterizer.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,30 @@
1616
from .rasterize_points import rasterize_points
1717

1818

19-
# Class to store the outputs of point rasterization
2019
class PointFragments(NamedTuple):
20+
"""
21+
Class to store the outputs of point rasterization
22+
23+
Members:
24+
idx: int32 Tensor of shape (N, image_size, image_size, points_per_pixel)
25+
giving the indices of the nearest points at each pixel, in ascending
26+
z-order. Concretely `idx[n, y, x, k] = p` means that `points[p]` is the kth
27+
closest point (along the z-direction) to pixel (y, x) - note that points
28+
represents the packed points of shape (P, 3).
29+
Pixels that are hit by fewer than points_per_pixel are padded with -1.
30+
zbuf: Tensor of shape (N, image_size, image_size, points_per_pixel)
31+
giving the z-coordinates of the nearest points at each pixel, sorted in
32+
z-order. Concretely, if `idx[n, y, x, k] = p` then
33+
`zbuf[n, y, x, k] = points[n, p, 2]`. Pixels hit by fewer than
34+
points_per_pixel are padded with -1.
35+
dists: Tensor of shape (N, image_size, image_size, points_per_pixel)
36+
giving the squared Euclidean distance (in NDC units) in the x/y plane
37+
for each point closest to the pixel. Concretely if `idx[n, y, x, k] = p`
38+
then `dists[n, y, x, k]` is the squared distance between the pixel (y, x)
39+
and the point `(points[n, p, 0], points[n, p, 1])`. Pixels hit with fewer
40+
than points_per_pixel are padded with -1.
41+
"""
42+
2143
idx: torch.Tensor
2244
zbuf: torch.Tensor
2345
dists: torch.Tensor

pytorch3d/renderer/points/renderer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ class PointsRenderer(nn.Module):
3030
A class for rendering a batch of points. The class should
3131
be initialized with a rasterizer and compositor class which each have a forward
3232
function.
33+
34+
The points are rendered with with varying alpha (weights) values depending on
35+
the distance of the pixel center to the true point in the xy plane. The purpose
36+
of this is to soften the hard decision boundary, for differentiability.
37+
See Section 3.2 of "SynSin: End-to-end View Synthesis from a Single Image"
38+
(https://arxiv.org/pdf/1912.08804.pdf) for more details.
3339
"""
3440

3541
def __init__(self, rasterizer, compositor) -> None:

0 commit comments

Comments
 (0)