Skip to content

Commit 3d4d45d

Browse files
committed
Render accumulation
1 parent 59f5f77 commit 3d4d45d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

diff_gaussian_rasterization/__init__.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,17 @@ def forward(
9595
ctx.raster_settings = raster_settings
9696
ctx.num_rendered = num_rendered
9797
ctx.save_for_backward(colors_precomp, means3D, scales, rotations, cov3Ds_precomp, radii, sh, geomBuffer, binningBuffer, imgBuffer)
98-
return color, radii
98+
99+
accumulation = None
100+
if raster_settings.return_accumulation:
101+
alignment = 128
102+
offset = (alignment - imgBuffer.data_ptr()) % alignment
103+
total_size = raster_settings.image_height * raster_settings.image_width * 4
104+
accumulation = imgBuffer[offset: offset + total_size].view(torch.float32).clone().view((raster_settings.image_height, raster_settings.image_width))
105+
return color, radii, accumulation
99106

100107
@staticmethod
101-
def backward(ctx, grad_out_color, _):
108+
def backward(ctx, grad_out_color, _1, _2):
102109

103110
# Restore necessary values from context
104111
num_rendered = ctx.num_rendered
@@ -167,6 +174,7 @@ class GaussianRasterizationSettings(NamedTuple):
167174
campos : torch.Tensor
168175
prefiltered : bool
169176
debug : bool
177+
return_accumulation : bool
170178

171179
class GaussianRasterizer(nn.Module):
172180
def __init__(self, raster_settings):

0 commit comments

Comments
 (0)