Utils#

In addition to the main projection and rasterization functions, a few CUDA kernel and helper functions are exposed to python with the following bindings:

gsplat.bin_and_sort_gaussians(num_points, num_intersects, xys, depths, radii, cum_tiles_hit, tile_bounds, block_size)#

Mapping gaussians to sorted unique intersection IDs and tile bins used for fast rasterization.

We return both sorted and unsorted versions of intersect IDs and gaussian IDs for testing purposes.

Note

This function is not differentiable to any input.

Parameters:
  • num_points (int) – number of gaussians.

  • num_intersects (int) – cumulative number of total gaussian intersections

  • xys (Tensor) – x,y locations of 2D gaussian projections.

  • depths (Tensor) – z depth of gaussians.

  • radii (Tensor) – radii of 2D gaussian projections.

  • cum_tiles_hit (Tensor) – list of cumulative tiles hit.

  • tile_bounds (Tuple) – tile dimensions as a len 3 tuple (tiles.x , tiles.y, 1).

  • block_size (int) –

Returns:

  • isect_ids_unsorted (Tensor): unique IDs for each gaussian in the form (tile | depth id).

  • gaussian_ids_unsorted (Tensor): Tensor that maps isect_ids back to cum_tiles_hit. Useful for identifying gaussians.

  • isect_ids_sorted (Tensor): sorted unique IDs for each gaussian in the form (tile | depth id).

  • gaussian_ids_sorted (Tensor): sorted Tensor that maps isect_ids back to cum_tiles_hit. Useful for identifying gaussians.

  • tile_bins (Tensor): range of gaussians hit per tile.

Return type:

A tuple of {Tensor, Tensor, Tensor, Tensor, Tensor}

gsplat.compute_cov2d_bounds(cov2d)#

Computes bounds of 2D covariance matrix

Parameters:

cov2d (Tensor) – input cov2d of size (batch, 3) of upper triangular 2D covariance values

Returns:

  • conic (Tensor): conic parameters for 2D gaussian.

  • radii (Tensor): radii of 2D gaussian projections.

Return type:

A tuple of {Tensor, Tensor}

gsplat.get_tile_bin_edges(num_intersects, isect_ids_sorted, tile_bounds)#

Map sorted intersection IDs to tile bins which give the range of unique gaussian IDs belonging to each tile.

Expects that intersection IDs are sorted by increasing tile ID.

Indexing into tile_bins[tile_idx] returns the range (lower,upper) of gaussian IDs that hit tile_idx.

Note

This function is not differentiable to any input.

Parameters:
  • num_intersects (int) – total number of gaussian intersects.

  • isect_ids_sorted (Tensor) – sorted unique IDs for each gaussian in the form (tile | depth id).

  • tile_bounds (Tuple) – tile dimensions as a len 3 tuple (tiles.x , tiles.y, 1).

Returns:

  • tile_bins (Tensor): range of gaussians IDs hit per tile.

Return type:

A Tensor

gsplat.spherical_harmonics(degrees_to_use, viewdirs, coeffs)#

Compute spherical harmonics

Note

This function is only differentiable to the input coeffs.

Parameters:
  • degrees_to_use (int) – degree of SHs to use (<= total number available).

  • viewdirs (Tensor) – viewing directions.

  • coeffs (Tensor) – harmonic coefficients.

Returns:

The spherical harmonics.

Return type:

Float[Tensor, ‘*batch C’]

gsplat.map_gaussian_to_intersects(num_points, num_intersects, xys, depths, radii, cum_tiles_hit, tile_bounds, block_size)#

Map each gaussian intersection to a unique tile ID and depth value for sorting.

Note

This function is not differentiable to any input.

Parameters:
  • num_points (int) – number of gaussians.

  • num_intersects (int) – total number of tile intersections.

  • xys (Tensor) – x,y locations of 2D gaussian projections.

  • depths (Tensor) – z depth of gaussians.

  • radii (Tensor) – radii of 2D gaussian projections.

  • cum_tiles_hit (Tensor) – list of cumulative tiles hit.

  • tile_bounds (Tuple) – tile dimensions as a len 3 tuple (tiles.x , tiles.y, 1).

  • block_size (int) –

Returns:

  • isect_ids (Tensor): unique IDs for each gaussian in the form (tile | depth id).

  • gaussian_ids (Tensor): Tensor that maps isect_ids back to cum_tiles_hit.

Return type:

A tuple of {Tensor, Tensor}

gsplat.compute_cumulative_intersects(num_tiles_hit)#

Computes cumulative intersections of gaussians. This is useful for creating unique gaussian IDs and for sorting.

Note

This function is not differentiable to any input.

Parameters:

num_tiles_hit (Tensor) – number of intersected tiles per gaussian.

Returns:

  • num_intersects (int): total number of tile intersections.

  • cum_tiles_hit (Tensor): a tensor of cumulated intersections (used for sorting).

Return type:

A tuple of {int, Tensor}