MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / rasterization

Function rasterization

gsplat/rendering.py:28–582  ·  view source on GitHub ↗

Rasterize a set of 3D Gaussians (N) to a batch of image planes (C). This function provides a handful features for 3D Gaussian rasterization, which we detail in the following notes. A complete profiling of the these features can be found in the :ref:`profiling` page. .. note::

(
    means: Tensor,  # [N, 3]
    quats: Tensor,  # [N, 4]
    scales: Tensor,  # [N, 3]
    opacities: Tensor,  # [N]
    colors: Tensor,  # [(C,) N, D] or [(C,) N, K, 3]
    viewmats: Tensor,  # [C, 4, 4]
    Ks: Tensor,  # [C, 3, 3]
    width: int,
    height: int,
    near_plane: float = 0.01,
    far_plane: float = 1e10,
    radius_clip: float = 0.0,
    eps2d: float = 0.3,
    sh_degree: Optional[int] = None,
    packed: bool = True,
    tile_size: int = 16,
    backgrounds: Optional[Tensor] = None,
    render_mode: Literal["RGB", "D", "ED", "RGB+D", "RGB+ED"] = "RGB",
    sparse_grad: bool = False,
    absgrad: bool = False,
    rasterize_mode: Literal["classic", "antialiased"] = "classic",
    channel_chunk: int = 32,
    distributed: bool = False,
    camera_model: Literal["pinhole", "ortho", "fisheye"] = "pinhole",
    covars: Optional[Tensor] = None,
)

Source from the content-addressed store, hash-verified

26
27
28def rasterization(
29 means: Tensor, # [N, 3]
30 quats: Tensor, # [N, 4]
31 scales: Tensor, # [N, 3]
32 opacities: Tensor, # [N]
33 colors: Tensor, # [(C,) N, D] or [(C,) N, K, 3]
34 viewmats: Tensor, # [C, 4, 4]
35 Ks: Tensor, # [C, 3, 3]
36 width: int,
37 height: int,
38 near_plane: float = 0.01,
39 far_plane: float = 1e10,
40 radius_clip: float = 0.0,
41 eps2d: float = 0.3,
42 sh_degree: Optional[int] = None,
43 packed: bool = True,
44 tile_size: int = 16,
45 backgrounds: Optional[Tensor] = None,
46 render_mode: Literal["RGB", "D", "ED", "RGB+D", "RGB+ED"] = "RGB",
47 sparse_grad: bool = False,
48 absgrad: bool = False,
49 rasterize_mode: Literal["classic", "antialiased"] = "classic",
50 channel_chunk: int = 32,
51 distributed: bool = False,
52 camera_model: Literal["pinhole", "ortho", "fisheye"] = "pinhole",
53 covars: Optional[Tensor] = None,
54) -> Tuple[Tensor, Tensor, Dict]:
55 """Rasterize a set of 3D Gaussians (N) to a batch of image planes (C).
56
57 This function provides a handful features for 3D Gaussian rasterization, which
58 we detail in the following notes. A complete profiling of the these features
59 can be found in the :ref:`profiling` page.
60
61 .. note::
62 **Multi-GPU Distributed Rasterization**: This function can be used in a multi-GPU
63 distributed scenario by setting `distributed` to True. When `distributed` is True,
64 a subset of total Gaussians could be passed into this function in each rank, and
65 the function will collaboratively render a set of images using Gaussians from all ranks. Note
66 to achieve balanced computation, it is recommended (not enforced) to have similar number of
67 Gaussians in each rank. But we do enforce that the number of cameras to be rendered
68 in each rank is the same. The function will return the rendered images
69 corresponds to the input cameras in each rank, and allows for gradients to flow back to the
70 Gaussians living in other ranks. For the details, please refer to the paper
71 `On Scaling Up 3D Gaussian Splatting Training <https://arxiv.org/abs/2406.18533>`_.
72
73 .. note::
74 **Batch Rasterization**: This function allows for rasterizing a set of 3D Gaussians
75 to a batch of images in one go, by simplly providing the batched `viewmats` and `Ks`.
76
77 .. note::
78 **Support N-D Features**: If `sh_degree` is None,
79 the `colors` is expected to be with shape [N, D] or [C, N, D], in which D is the channel of
80 the features to be rendered. The computation is slow when D > 32 at the moment.
81 If `sh_degree` is set, the `colors` is expected to be the SH coefficients with
82 shape [N, K, 3] or [C, N, K, 3], where K is the number of SH bases. In this case, it is expected
83 that :math:`(\\textit{sh_degree} + 1) ^ 2 \\leq K`, where `sh_degree` controls the
84 activated bases in the SH coefficients.
85

Callers 12

test_strategyFunction · 0.90
test_rasterizationFunction · 0.90
rasterize_splatsMethod · 0.90
rasterize_splatsMethod · 0.90
rasterize_splatsMethod · 0.90
rasterize_splatsMethod · 0.90
rasterize_splatsMethod · 0.90
rasterize_splatsMethod · 0.90
rasterize_splatsFunction · 0.90
mainFunction · 0.90
rasterize_splatsMethod · 0.90

Calls 11

all_gather_int32Function · 0.85
all_gather_tensor_listFunction · 0.85
fully_fused_projectionFunction · 0.85
spherical_harmonicsFunction · 0.85
all_to_all_int32Function · 0.85
all_to_all_tensor_listFunction · 0.85
reshape_viewFunction · 0.85
isect_tilesFunction · 0.85
isect_offset_encodeFunction · 0.85
rasterize_to_pixelsFunction · 0.85
updateMethod · 0.80

Tested by 3

test_strategyFunction · 0.72
test_rasterizationFunction · 0.72