From 4ad8576541009694f33f3db7468e28b9f8879d29 Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Thu, 30 Sep 2021 10:39:50 -0700 Subject: [PATCH] rasterization header comment fixes Summary: Fix some missing or misplaced argument descriptions. Reviewed By: nikhilaravi Differential Revision: D31305132 fbshipit-source-id: af4fcee9766682b2b7f7f16327e839090e377be2 --- .../csrc/rasterize_meshes/rasterize_meshes.h | 21 +++++++++++++++++++ .../csrc/rasterize_points/rasterize_points.h | 14 +++++++------ pytorch3d/renderer/mesh/rasterize_meshes.py | 2 +- pytorch3d/renderer/points/rasterize_points.py | 2 +- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/pytorch3d/csrc/rasterize_meshes/rasterize_meshes.h b/pytorch3d/csrc/rasterize_meshes/rasterize_meshes.h index 3e4b40ab..15305d5f 100644 --- a/pytorch3d/csrc/rasterize_meshes/rasterize_meshes.h +++ b/pytorch3d/csrc/rasterize_meshes/rasterize_meshes.h @@ -75,6 +75,11 @@ RasterizeMeshesNaiveCuda( // coordinates for each pixel; if this is False then // this function instead returns screen-space // barycentric coordinates for each pixel. +// clip_barycentric_coords: Whether, after any perspective correction +// is applied but before the depth is calculated (e.g. for +// z clipping), to "correct" a location outside the face (i.e. with +// a negative barycentric coordinate) to a position on the edge of the +// face. // cull_backfaces: Bool, Whether to only rasterize mesh faces which are // visible to the camera. This assumes that vertices of // front-facing triangles are ordered in an anti-clockwise @@ -191,6 +196,11 @@ torch::Tensor RasterizeMeshesBackwardCuda( // coordinates for each pixel; if this is False then // this function instead returns screen-space // barycentric coordinates for each pixel. +// clip_barycentric_coords: Whether, after any perspective correction +// is applied but before the depth is calculated (e.g. for +// z clipping), to "correct" a location outside the face (i.e. with +// a negative barycentric coordinate) to a position on the edge of the +// face. // // Returns: // grad_face_verts: float32 Tensor of shape (F, 3, 3) giving downstream @@ -352,6 +362,11 @@ RasterizeMeshesFineCuda( // coordinates for each pixel; if this is False then // this function instead returns screen-space // barycentric coordinates for each pixel. +// clip_barycentric_coords: Whether, after any perspective correction +// is applied but before the depth is calculated (e.g. for +// z clipping), to "correct" a location outside the face (i.e. with +// a negative barycentric coordinate) to a position on the edge of the +// face. // cull_backfaces: Bool, Whether to only rasterize mesh faces which are // visible to the camera. This assumes that vertices of // front-facing triangles are ordered in an anti-clockwise @@ -441,6 +456,7 @@ RasterizeMeshesFine( // blur_radius: float distance in NDC coordinates uses to expand the face // bounding boxes for the rasterization. Set to 0.0 if no blur // is required. +// faces_per_pixel: the number of closeset faces to rasterize per pixel. // bin_size: Bin size (in pixels) for coarse-to-fine rasterization. Setting // bin_size=0 uses naive rasterization instead. // max_faces_per_bin: The maximum number of faces allowed to fall into each @@ -451,6 +467,11 @@ RasterizeMeshesFine( // coordinates for each pixel; if this is False then // this function instead returns screen-space // barycentric coordinates for each pixel. +// clip_barycentric_coords: Whether, after any perspective correction +// is applied but before the depth is calculated (e.g. for +// z clipping), to "correct" a location outside the face (i.e. with +// a negative barycentric coordinate) to a position on the edge of the +// face. // cull_backfaces: Bool, Whether to only rasterize mesh faces which are // visible to the camera. This assumes that vertices of // front-facing triangles are ordered in an anti-clockwise diff --git a/pytorch3d/csrc/rasterize_points/rasterize_points.h b/pytorch3d/csrc/rasterize_points/rasterize_points.h index 25ee9dcd..e97b9dbf 100644 --- a/pytorch3d/csrc/rasterize_points/rasterize_points.h +++ b/pytorch3d/csrc/rasterize_points/rasterize_points.h @@ -48,10 +48,10 @@ RasterizePointsNaiveCuda( // in the batch where N is the batch size. // num_points_per_cloud: LongTensor of shape (N) giving the number of points // for each pointcloud in the batch. -// radius: FloatTensor of shape (P) giving the radius (in NDC units) of -// each point in points. // image_size: Tuple (H, W) giving the size in pixels of the output // image to be rasterized. +// radius: FloatTensor of shape (P) giving the radius (in NDC units) of +// each point in points. // points_per_pixel: (K) The number closest of points to return for each pixel // // Returns: @@ -126,11 +126,13 @@ torch::Tensor RasterizePointsCoarseCpu( // in the batch where N is the batch size. // num_points_per_cloud: LongTensor of shape (N) giving the number of points // for each pointcloud in the batch. -// radius: FloatTensor of shape (P) giving the radius (in NDC units) of -// each point in points. // image_size: Tuple (H, W) giving the size in pixels of the output // image to be rasterized. +// radius: FloatTensor of shape (P) giving the radius (in NDC units) of +// each point in points. // bin_size: Size of each bin within the image (in pixels) +// max_points_per_bin: The maximum number of points allowed to fall into each +// bin when using coarse-to-fine rasterization. // // Returns: // points_per_bin: Tensor of shape (N, num_bins, num_bins) giving the number @@ -303,10 +305,10 @@ torch::Tensor RasterizePointsBackward( // in the batch where N is the batch size. // num_points_per_cloud: LongTensor of shape (N) giving the number of points // for each pointcloud in the batch. -// radius: FloatTensor of shape (P) giving the radius (in NDC units) of -// each point in points. // image_size: Tuple (H, W) giving the size in pixels of the output // image to be rasterized. +// radius: FloatTensor of shape (P) giving the radius (in NDC units) of +// each point in points. // points_per_pixel: (K) The number of points to return for each pixel // bin_size: Bin size (in pixels) for coarse-to-fine rasterization. Setting // bin_size=0 uses naive rasterization instead. diff --git a/pytorch3d/renderer/mesh/rasterize_meshes.py b/pytorch3d/renderer/mesh/rasterize_meshes.py index e10ff92b..102b6033 100644 --- a/pytorch3d/renderer/mesh/rasterize_meshes.py +++ b/pytorch3d/renderer/mesh/rasterize_meshes.py @@ -71,7 +71,7 @@ def rasterize_meshes( bin_size=0 uses naive rasterization; setting bin_size=None attempts to set it heuristically based on the shape of the input. This should not affect the output, but can affect the speed of the forward pass. - faces_per_bin: Only applicable when using coarse-to-fine rasterization + max_faces_per_bin: Only applicable when using coarse-to-fine rasterization (bin_size > 0); this is the maximum number of faces allowed within each bin. This should not affect the output values, but can affect the memory usage in the forward pass. diff --git a/pytorch3d/renderer/points/rasterize_points.py b/pytorch3d/renderer/points/rasterize_points.py index d2741760..1fce0fe3 100644 --- a/pytorch3d/renderer/points/rasterize_points.py +++ b/pytorch3d/renderer/points/rasterize_points.py @@ -62,7 +62,7 @@ def rasterize_points( bin_size=0 uses naive rasterization; setting bin_size=None attempts to set it heuristically based on the shape of the input. This should not affect the output, but can affect the speed of the forward pass. - points_per_bin: Only applicable when using coarse-to-fine rasterization + max_points_per_bin: Only applicable when using coarse-to-fine rasterization (bin_size > 0); this is the maximum number of points allowed within each bin. This should not affect the output values, but can affect the memory usage in the forward pass.