15
15
from scene .gaussian_model import GaussianModel
16
16
from utils .sh_utils import eval_sh
17
17
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 ):
19
19
"""
20
20
Render the scene.
21
21
@@ -32,7 +32,6 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor,
32
32
# Set up rasterization configuration
33
33
tanfovx = math .tan (viewpoint_camera .FoVx * 0.5 )
34
34
tanfovy = math .tan (viewpoint_camera .FoVy * 0.5 )
35
-
36
35
raster_settings = GaussianRasterizationSettings (
37
36
image_height = int (viewpoint_camera .image_height ),
38
37
image_width = int (viewpoint_camera .image_width ),
@@ -45,7 +44,8 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor,
45
44
sh_degree = pc .active_sh_degree ,
46
45
campos = viewpoint_camera .camera_center ,
47
46
prefiltered = False ,
48
- debug = pipe .debug
47
+ debug = pipe .debug ,
48
+ return_accumulation = return_accumulation
49
49
)
50
50
51
51
rasterizer = GaussianRasterizer (raster_settings = raster_settings )
@@ -82,7 +82,7 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor,
82
82
colors_precomp = override_color
83
83
84
84
# Rasterize visible Gaussians to image, obtain their radii (on screen).
85
- rendered_image , radii = rasterizer (
85
+ rendered_image , radii , accumulation = rasterizer (
86
86
means3D = means3D ,
87
87
means2D = means2D ,
88
88
shs = shs ,
@@ -94,7 +94,10 @@ def render(viewpoint_camera, pc : GaussianModel, pipe, bg_color : torch.Tensor,
94
94
95
95
# Those Gaussians that were frustum culled or had a radius of 0 were not visible.
96
96
# 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