Skip to content

Commit 6cf71af

Browse files
committed
Render accumulation
1 parent 59f5f77 commit 6cf71af

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

diff_gaussian_rasterization/__init__.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,24 @@ 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 = (
105+
imgBuffer[offset: offset + total_size]
106+
.view(torch.float32)
107+
.clone()
108+
.mul_(-1)
109+
.add_(1)
110+
.view((raster_settings.image_height, raster_settings.image_width))
111+
)
112+
return color, radii, accumulation
99113

100114
@staticmethod
101-
def backward(ctx, grad_out_color, _):
115+
def backward(ctx, grad_out_color, _1, _2):
102116

103117
# Restore necessary values from context
104118
num_rendered = ctx.num_rendered
@@ -167,6 +181,7 @@ class GaussianRasterizationSettings(NamedTuple):
167181
campos : torch.Tensor
168182
prefiltered : bool
169183
debug : bool
184+
return_accumulation : bool
170185

171186
class GaussianRasterizer(nn.Module):
172187
def __init__(self, raster_settings):

0 commit comments

Comments
 (0)