Skip to content

Commit 21da5b6

Browse files
committed
Allow to render accumulation
1 parent 0955231 commit 21da5b6

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

gaussian_renderer/__init__.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from scene.gaussian_model import GaussianModel
1616
from utils.sh_utils import eval_sh
1717

18-
def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor, scaling_modifier = 1.0, override_color = None):
18+
def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor, scaling_modifier = 1.0, override_color = None, return_accumulation=False):
1919
"""
2020
Render the scene.
2121
@@ -32,7 +32,6 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor,
3232
# Set up rasterization configuration
3333
tanfovx = math.tan(viewpoint_camera.FoVx * 0.5)
3434
tanfovy = math.tan(viewpoint_camera.FoVy * 0.5)
35-
3635
raster_settings = GaussianRasterizationSettings(
3736
image_height=int(viewpoint_camera.image_height),
3837
image_width=int(viewpoint_camera.image_width),
@@ -45,7 +44,8 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor,
4544
sh_degree=pc.active_sh_degree,
4645
campos=viewpoint_camera.camera_center,
4746
prefiltered=False,
48-
debug=pipe.debug
47+
debug=pipe.debug,
48+
return_accumulation=return_accumulation
4949
)
5050

5151
rasterizer = GaussianRasterizer(raster_settings=raster_settings)
@@ -82,7 +82,7 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor,
8282
colors_precomp = override_color
8383

8484
# Rasterize visible Gaussians to image, obtain their radii (on screen).
85-
rendered_image, radii = rasterizer(
85+
rendered_image, radii, accumulation = rasterizer(
8686
means3D = means3D,
8787
means2D = means2D,
8888
shs = shs,
@@ -94,7 +94,10 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor,
9494

9595
# Those Gaussians that were frustum culled or had a radius of 0 were not visible.
9696
# They will be excluded from value updates used in the splitting criteria.
97-
return {"render": rendered_image,
98-
"viewspace_points": screenspace_points,
99-
"visibility_filter" : radii > 0,
100-
"radii": radii}
97+
out = {"render": rendered_image,
98+
"viewspace_points": screenspace_points,
99+
"visibility_filter" : radii > 0,
100+
"radii": radii}
101+
if raster_settings.return_accumulation:
102+
out["accumulation"] = accumulation
103+
return out

0 commit comments

Comments
 (0)