@@ -841,17 +841,19 @@ class GaussianSplat3d {
841841 // / @param cropOriginH Origin of the cropped image in the height dimension (use -1 for no
842842 // / cropping)
843843 // / @param tileSize Size of the tiles used for rendering
844+ // / @param backgrounds Optional [C, D] tensor of background colors for each camera
844845 // / @return Tuple of two tensors:
845846 // / images: A [C, H, W, D|1|D+1] tensor containing the the rendered image
846847 // / (or depth or image and depth) for each camera
847848 // / alphas: A [C, H, W, 1] tensor containing the alpha values of the rendered images
848849 std::tuple<torch::Tensor, torch::Tensor>
849850 renderFromProjectedGaussians (const GaussianSplat3d::ProjectedGaussianSplats &projectedGaussians,
850- const ssize_t cropWidth = -1 ,
851- const ssize_t cropHeight = -1 ,
852- const ssize_t cropOriginW = -1 ,
853- const ssize_t cropOriginH = -1 ,
854- const size_t tileSize = 16 );
851+ const ssize_t cropWidth = -1 ,
852+ const ssize_t cropHeight = -1 ,
853+ const ssize_t cropOriginW = -1 ,
854+ const ssize_t cropOriginH = -1 ,
855+ const size_t tileSize = 16 ,
856+ const std::optional<torch::Tensor> &backgrounds = std::nullopt );
855857
856858 // / @brief Render images of this Gaussian splat scene from the given camera matrices and
857859 // / projection matrices.
@@ -867,6 +869,7 @@ class GaussianSplat3d {
867869 // / @param minRadius2d Minimum radius in pixels below which projected Gaussians are ignored
868870 // / @param eps2d Blur factor for antialiasing (only used if antialias is true)
869871 // / @param antialias Whether to antialias the image
872+ // / @param backgrounds Optional [C, D] tensor of background colors for each camera
870873 // / @return Tuple of two tensors:
871874 // / images: A [C, H, W, D] tensor containing the the rendered image for each camera
872875 // / alphas: A [C, H, W, 1] tensor containing the alpha values of the rendered images
@@ -877,12 +880,13 @@ class GaussianSplat3d {
877880 const size_t imageHeight,
878881 const float near,
879882 const float far,
880- const ProjectionType projectionType = ProjectionType::PERSPECTIVE,
881- const int64_t shDegreeToUse = -1 ,
882- const size_t tileSize = 16 ,
883- const float minRadius2d = 0.0 ,
884- const float eps2d = 0.3 ,
885- const bool antialias = false );
883+ const ProjectionType projectionType = ProjectionType::PERSPECTIVE,
884+ const int64_t shDegreeToUse = -1 ,
885+ const size_t tileSize = 16 ,
886+ const float minRadius2d = 0.0 ,
887+ const float eps2d = 0.3 ,
888+ const bool antialias = false ,
889+ const std::optional<torch::Tensor> &backgrounds = std::nullopt );
886890
887891 // / @brief Render depths of this Gaussian splat scene from the given camera matrices and
888892 // / projection matrices.
@@ -897,6 +901,7 @@ class GaussianSplat3d {
897901 // / @param minRadius2d Minimum radius in pixels below which projected Gaussians are ignored
898902 // / @param eps2d Blur factor for antialiasing (only used if antialias is true)
899903 // / @param antialias Whether to antialias the image
904+ // / @param backgrounds Optional [C, 1] tensor of background depths for each camera
900905 // / @return Tuple of two tensors:
901906 // / images: A [C, H, W, 1] tensor containing the the rendered depths for each camera
902907 // / alphas: A [C, H, W, 1] tensor containing the alpha values of the rendered depths
@@ -907,11 +912,12 @@ class GaussianSplat3d {
907912 const size_t imageHeight,
908913 const float near,
909914 const float far,
910- const ProjectionType projectionType = ProjectionType::PERSPECTIVE,
911- const size_t tileSize = 16 ,
912- const float minRadius2d = 0.0 ,
913- const float eps2d = 0.3 ,
914- const bool antialias = false );
915+ const ProjectionType projectionType = ProjectionType::PERSPECTIVE,
916+ const size_t tileSize = 16 ,
917+ const float minRadius2d = 0.0 ,
918+ const float eps2d = 0.3 ,
919+ const bool antialias = false ,
920+ const std::optional<torch::Tensor> &backgrounds = std::nullopt );
915921
916922 std::tuple<torch::Tensor, torch::Tensor>
917923 renderImagesAndDepths (const torch::Tensor &worldToCameraMatrices,
@@ -925,7 +931,8 @@ class GaussianSplat3d {
925931 const size_t tileSize = 16 ,
926932 const float minRadius2d = 0.0 ,
927933 const float eps2d = 0.3 ,
928- const bool antialias = false );
934+ const bool antialias = false ,
935+ const std::optional<torch::Tensor> &backgrounds = std::nullopt );
929936
930937 // / @brief Render the number of contributing Gaussians for each pixel in the image.
931938 // / @param worldToCameraMatrices [C, 4, 4] Camera-to-world matrices
@@ -1132,13 +1139,14 @@ class GaussianSplat3d {
11321139 const torch::Tensor &projectionMatrices,
11331140 const fvdb::detail::ops::RenderSettings &settings);
11341141
1135- std::tuple<torch::Tensor, torch::Tensor>
1136- renderCropFromProjectedGaussiansImpl (const ProjectedGaussianSplats &state,
1137- const size_t tileSize,
1138- const ssize_t cropWidth,
1139- const ssize_t cropHeight,
1140- const ssize_t cropOriginW,
1141- const ssize_t cropOriginH);
1142+ std::tuple<torch::Tensor, torch::Tensor> renderCropFromProjectedGaussiansImpl (
1143+ const ProjectedGaussianSplats &state,
1144+ const size_t tileSize,
1145+ const ssize_t cropWidth,
1146+ const ssize_t cropHeight,
1147+ const ssize_t cropOriginW,
1148+ const ssize_t cropOriginH,
1149+ const std::optional<torch::Tensor> &backgrounds = std::nullopt );
11421150
11431151 // / @brief Implements index set with a tensor of booleans or integer indices
11441152 // / @param indexOrMask A 1D tensor of indices in the range [0, numGaussians-1] or a boolean mask
@@ -1260,17 +1268,18 @@ gaussianRenderJagged(const JaggedTensor &means, // [N1 + N2 + ..., 3]
12601268 const JaggedTensor &Ks, // [C1 + C2 + ..., 3, 3]
12611269 const uint32_t image_width,
12621270 const uint32_t image_height,
1263- const float near_plane = 0.01 ,
1264- const float far_plane = 1e10 ,
1265- const int sh_degree_to_use = -1 ,
1266- const int tile_size = 16 ,
1267- const float radius_clip = 0.0 ,
1268- const float eps2d = 0.3 ,
1269- const bool antialias = false ,
1270- const bool render_depth_channel = false ,
1271- const bool return_debug_info = false ,
1272- const bool render_depth_only = false ,
1273- const bool ortho = false );
1271+ const float near_plane = 0.01 ,
1272+ const float far_plane = 1e10 ,
1273+ const int sh_degree_to_use = -1 ,
1274+ const int tile_size = 16 ,
1275+ const float radius_clip = 0.0 ,
1276+ const float eps2d = 0.3 ,
1277+ const bool antialias = false ,
1278+ const bool render_depth_channel = false ,
1279+ const bool return_debug_info = false ,
1280+ const bool render_depth_only = false ,
1281+ const bool ortho = false ,
1282+ const std::optional<torch::Tensor> &backgrounds = std::nullopt );
12741283
12751284} // namespace fvdb
12761285
0 commit comments