Rasterizes Gaussians to pixels. Args: means2d: Projected Gaussian means. [..., N, 2] if packed is False, [nnz, 2] if packed is True. conics: Inverse of the projected covariances with only upper triangle values. [..., N, 3] if packed is False, [nnz, 3] if packed is True.
(
means2d: Tensor, # [..., N, 2] or [nnz, 2]
conics: Tensor, # [..., N, 3] or [nnz, 3]
colors: Tensor, # [..., N, channels] or [nnz, channels]
opacities: Tensor, # [..., N] or [nnz]
image_width: int,
image_height: int,
tile_size: int,
isect_offsets: Tensor, # [..., tile_height, tile_width]
flatten_ids: Tensor, # [n_isects]
backgrounds: Optional[Tensor] = None, # [..., channels]
masks: Optional[Tensor] = None, # [..., tile_height, tile_width]
packed: bool = False,
absgrad: bool = False,
)
| 541 | |
| 542 | |
| 543 | def rasterize_to_pixels( |
| 544 | means2d: Tensor, # [..., N, 2] or [nnz, 2] |
| 545 | conics: Tensor, # [..., N, 3] or [nnz, 3] |
| 546 | colors: Tensor, # [..., N, channels] or [nnz, channels] |
| 547 | opacities: Tensor, # [..., N] or [nnz] |
| 548 | image_width: int, |
| 549 | image_height: int, |
| 550 | tile_size: int, |
| 551 | isect_offsets: Tensor, # [..., tile_height, tile_width] |
| 552 | flatten_ids: Tensor, # [n_isects] |
| 553 | backgrounds: Optional[Tensor] = None, # [..., channels] |
| 554 | masks: Optional[Tensor] = None, # [..., tile_height, tile_width] |
| 555 | packed: bool = False, |
| 556 | absgrad: bool = False, |
| 557 | ) -> Tuple[Tensor, Tensor]: |
| 558 | """Rasterizes Gaussians to pixels. |
| 559 | |
| 560 | Args: |
| 561 | means2d: Projected Gaussian means. [..., N, 2] if packed is False, [nnz, 2] if packed is True. |
| 562 | conics: Inverse of the projected covariances with only upper triangle values. [..., N, 3] if packed is False, [nnz, 3] if packed is True. |
| 563 | colors: Gaussian colors or ND features. [..., N, channels] if packed is False, [nnz, channels] if packed is True. |
| 564 | opacities: Gaussian opacities that support per-view values. [..., N] if packed is False, [nnz] if packed is True. |
| 565 | image_width: Image width. |
| 566 | image_height: Image height. |
| 567 | tile_size: Tile size. |
| 568 | isect_offsets: Intersection offsets outputs from `isect_offset_encode()`. [..., tile_height, tile_width] |
| 569 | flatten_ids: The global flatten indices in [I * N] or [nnz] from `isect_tiles()`. [n_isects] |
| 570 | backgrounds: Background colors. [..., channels]. Default: None. |
| 571 | masks: Optional tile mask to skip rendering GS to masked tiles. [..., tile_height, tile_width]. Default: None. |
| 572 | packed: If True, the input tensors are expected to be packed with shape [nnz, ...]. Default: False. |
| 573 | absgrad: If True, the backward pass will compute a `.absgrad` attribute for `means2d`. Default: False. |
| 574 | |
| 575 | Returns: |
| 576 | A tuple: |
| 577 | |
| 578 | - **Rendered colors**. [..., image_height, image_width, channels] |
| 579 | - **Rendered alphas**. [..., image_height, image_width, 1] |
| 580 | """ |
| 581 | |
| 582 | image_dims = means2d.shape[:-2] |
| 583 | channels = colors.shape[-1] |
| 584 | device = means2d.device |
| 585 | if packed: |
| 586 | nnz = means2d.size(0) |
| 587 | assert means2d.shape == (nnz, 2), means2d.shape |
| 588 | assert conics.shape == (nnz, 3), conics.shape |
| 589 | assert colors.shape[0] == nnz, colors.shape |
| 590 | assert opacities.shape == (nnz,), opacities.shape |
| 591 | else: |
| 592 | N = means2d.size(-2) |
| 593 | assert means2d.shape == image_dims + (N, 2), means2d.shape |
| 594 | assert conics.shape == image_dims + (N, 3), conics.shape |
| 595 | assert colors.shape == image_dims + (N, channels), colors.shape |
| 596 | assert opacities.shape == image_dims + (N,), opacities.shape |
| 597 | if backgrounds is not None: |
| 598 | assert backgrounds.shape == image_dims + (channels,), backgrounds.shape |
| 599 | backgrounds = backgrounds.contiguous() |
| 600 | if masks is not None: |
no outgoing calls
searching dependent graphs…