pytorch3d.renderer.points.pulsar.unified

unified

class pytorch3d.renderer.points.pulsar.unified.PulsarPointsRenderer(rasterizer: PointsRasterizer, compositor: NormWeightedCompositor | AlphaCompositor | None = None, n_channels: int = 3, max_num_spheres: int = 1000000, **kwargs)[source]

Bases: Module

This renderer is a PyTorch3D interface wrapper around the pulsar renderer.

It provides an interface consistent with PyTorch3D Pointcloud rendering. It will extract all necessary information from the rasterizer and compositor objects and convert them to the pulsar required format, then invoke rendering in the pulsar renderer. All gradients are handled appropriately through the wrapper and the wrapper should provide equivalent results to using the pulsar renderer directly.

__init__(rasterizer: PointsRasterizer, compositor: NormWeightedCompositor | AlphaCompositor | None = None, n_channels: int = 3, max_num_spheres: int = 1000000, **kwargs) None[source]

rasterizer (PointsRasterizer): An object encapsulating rasterization parameters. compositor (ignored): Only keeping this for interface consistency. Default: None. n_channels (int): The number of channels of the resulting image. Default: 3. max_num_spheres (int): The maximum number of spheres intended to render with

this renderer. Default: 1e6.

kwargs (Any): kwargs to pass on to the pulsar renderer.

See pytorch3d.renderer.points.pulsar.renderer.Renderer for all options.

forward(point_clouds, **kwargs) Tensor[source]

Get the rendering of the provided Pointclouds.

The number of point clouds in the Pointclouds object determines the number of resulting images. The provided cameras can be either 1 or equal to the number of pointclouds (in the first case, the same camera will be used for all clouds, in the latter case each point cloud will be rendered with the corresponding camera).

The following kwargs are support from PyTorch3D (depending on the selected camera model potentially overriding camera parameters):

radius_world (bool): use the provided radiuses from the raster_settings

plain as radiuses in world space. Default: False.

znear (Iterable[float]): near geometry cutoff. Is required for

OrthographicCameras and PerspectiveCameras.

zfar (Iterable[float]): far geometry cutoff. Is required for

OrthographicCameras and PerspectiveCameras.

R (torch.Tensor): [Bx3x3] camera rotation matrices. T (torch.Tensor): [Bx3] camera translation vectors. principal_point (torch.Tensor): [Bx2] camera intrinsic principal

point offset vectors.

focal_length (torch.Tensor): [Bx1] camera intrinsic focal lengths. aspect_ratio (Iterable[float]): camera aspect ratios. fov (Iterable[float]): camera FOVs. degrees (bool): whether FOVs are specified in degrees or

radians.

min_x (Iterable[float]): minimum x for the FoVOrthographicCameras. max_x (Iterable[float]): maximum x for the FoVOrthographicCameras. min_y (Iterable[float]): minimum y for the FoVOrthographicCameras. max_y (Iterable[float]): maximum y for the FoVOrthographicCameras.

The following kwargs are supported from pulsar:
gamma (float): The gamma value to use. This defines the transparency for

differentiability (see pulsar paper for details). Must be in [1., 1e-5] with 1.0 being mostly transparent. This keyword argument is required!

bg_col (torch.Tensor): The background color. Must be a tensor on the same

device as the point clouds, with as many channels as features (no batch dimension - it is the same for all images in the batch). Default: 0.0 for all channels.

percent_allowed_difference (float): a value in [0., 1.[ with the maximum

allowed difference in channel space. This is used to speed up the computation. Default: 0.01.

max_n_hits (int): a hard limit on the number of sphere hits per ray.

Default: max int.

mode (int): render mode in {0, 1}. 0: render image; 1: render hit map.